Ok hook types

This commit is contained in:
Guus Waals 2025-06-01 23:01:05 +08:00
parent cde5c7c313
commit 947165067c
2 changed files with 17 additions and 9 deletions

View File

@ -8,7 +8,7 @@ undefined FUN_00401320(void); // 00401320 // FUN_00401320 // cdecl
undefined r3_windowUnlockCursor(void); // 004013a0 // r3_windowUnlockCursor // cdecl undefined r3_windowUnlockCursor(void); // 004013a0 // r3_windowUnlockCursor // cdecl
// 004025e0 // 004025e0
long r3_windowProc(HWND hwnd,UINT uMsg,WPARAM wParam,LPARAM lParam) long __stdcall r3_windowProc(HWND hwnd,UINT uMsg,WPARAM wParam,LPARAM lParam)
{ {
long lVar1; long lVar1;

View File

@ -133,7 +133,8 @@ public class FunctionDumper {
// Extract calling convention from Ghidra function // Extract calling convention from Ghidra function
String callingConventionName = externalFunction.getCallingConventionName(); String callingConventionName = externalFunction.getCallingConventionName();
FunctionDatabase.CallingConvention callingConvention = FunctionDatabase.CallingConvention.fromString(callingConventionName); FunctionDatabase.CallingConvention callingConvention = FunctionDatabase.CallingConvention
.fromString(callingConventionName);
script.println("Detected calling convention: " + callingConventionName + " -> " + callingConvention); script.println("Detected calling convention: " + callingConventionName + " -> " + callingConvention);
try (PrintWriter writer2 = new PrintWriter(f4, "UTF-8")) { try (PrintWriter writer2 = new PrintWriter(f4, "UTF-8")) {
@ -212,7 +213,8 @@ public class FunctionDumper {
// Extract calling convention from Ghidra function // Extract calling convention from Ghidra function
String callingConventionName = function.getCallingConventionName(); String callingConventionName = function.getCallingConventionName();
FunctionDatabase.CallingConvention callingConvention = FunctionDatabase.CallingConvention.fromString(callingConventionName); FunctionDatabase.CallingConvention callingConvention = FunctionDatabase.CallingConvention
.fromString(callingConventionName);
script.println("Detected calling convention: " + callingConventionName + " -> " + callingConvention); script.println("Detected calling convention: " + callingConventionName + " -> " + callingConvention);
// Handle forceFixType flag // Handle forceFixType flag
@ -290,6 +292,17 @@ public class FunctionDumper {
List<Function> externalFunctionCalls = new ArrayList<>(); List<Function> externalFunctionCalls = new ArrayList<>();
HashMap<String, String> replacementMap = new HashMap<>(); HashMap<String, String> replacementMap = new HashMap<>();
String newFunctionName = sanitizedFunctionName;
if (callingConvention != FunctionDatabase.CallingConvention.Stdcall ||
callingConvention != FunctionDatabase.CallingConvention.Fastcall) {
newFunctionName = callingConventionName + " " + newFunctionName;
}
String originalFunctionName = function.getName();
if (newFunctionName != originalFunctionName) {
replacementMap.put(originalFunctionName, newFunctionName);
}
DecompileResults decompRes = RemanConfig.INSTANCE.decompCache.getOrInsert(function); DecompileResults decompRes = RemanConfig.INSTANCE.decompCache.getOrInsert(function);
try (PrintWriter writer2 = new PrintWriter(f0, "UTF-8")) { try (PrintWriter writer2 = new PrintWriter(f0, "UTF-8")) {
writer2.println("// AUTO-GENERATED FILE, MOVE TO 'gh_fix' FOLDER PREVENT OVERWRITING!!!!! "); writer2.println("// AUTO-GENERATED FILE, MOVE TO 'gh_fix' FOLDER PREVENT OVERWRITING!!!!! ");
@ -316,11 +329,6 @@ public class FunctionDumper {
// Parse preliminary line tokens // Parse preliminary line tokens
for (int i = 0; i < line.getNumTokens(); i++) { for (int i = 0; i < line.getNumTokens(); i++) {
ClangToken token = line.getToken(i); ClangToken token = line.getToken(i);
// Remove some of the calling conventions, keep __stdcall/fastcall
if (token.getText().equals("__cdecl") || token.getText().equals("__thiscall")) {
// Remove function declaration
continue;
}
if (!token.getText().isEmpty()) if (!token.getText().isEmpty())
tokens.add(token); tokens.add(token);
} }
@ -421,7 +429,7 @@ public class FunctionDumper {
String proto = externalFunction.getSignature().getPrototypeString(false); String proto = externalFunction.getSignature().getPrototypeString(false);
String name = externalFunction.getName(); String name = externalFunction.getName();
proto = proto.replace(name, Utils.sanitizeIdentifier(name)); proto = proto.replace(name, Utils.sanitizeIdentifier(name));
// Add calling convention information to the comment // Add calling convention information to the comment
String callingConv = externalFunction.getCallingConventionName(); String callingConv = externalFunction.getCallingConventionName();
FunctionDatabase.CallingConvention conv = FunctionDatabase.CallingConvention.fromString(callingConv); FunctionDatabase.CallingConvention conv = FunctionDatabase.CallingConvention.fromString(callingConv);