Fix Ghidra import call type (#1093)

Co-authored-by: jonschz <jonschz@users.noreply.github.com>
This commit is contained in:
jonschz
2024-08-31 17:00:35 +02:00
committed by GitHub
parent b898d98515
commit 0256fc4acf
2 changed files with 8 additions and 8 deletions

View File

@@ -162,30 +162,30 @@ class FullPdbFunctionImporter(PdbFunctionImporter):
return_type_match = True return_type_match = True
# match arguments: decide if thiscall or not, and whether the `this` type matches # match arguments: decide if thiscall or not, and whether the `this` type matches
thiscall_matches = ( calling_convention_match = (
self.signature.call_type == ghidra_function.getCallingConventionName() self.signature.call_type == ghidra_function.getCallingConventionName()
) )
ghidra_params_without_this = list(ghidra_function.getParameters()) ghidra_params_without_this = list(ghidra_function.getParameters())
if thiscall_matches and self.signature.call_type == "__thiscall": if calling_convention_match and self.signature.call_type == "__thiscall":
this_argument = ghidra_params_without_this.pop(0) this_argument = ghidra_params_without_this.pop(0)
thiscall_matches = self._this_type_match(this_argument) calling_convention_match = self._this_type_match(this_argument)
if self.is_stub: if self.is_stub:
# We do not import the argument list for stubs, so it should be excluded in matches # We do not import the argument list for stubs, so it should be excluded in matches
args_match = True args_match = True
elif thiscall_matches: elif calling_convention_match:
args_match = self._parameter_lists_match(ghidra_params_without_this) args_match = self._parameter_lists_match(ghidra_params_without_this)
else: else:
args_match = False args_match = False
logger.debug( logger.debug(
"Matches: namespace=%s name=%s return_type=%s thiscall=%s args=%s", "Matches: namespace=%s name=%s return_type=%s calling_convention=%s args=%s",
namespace_match, namespace_match,
name_match, name_match,
return_type_match, return_type_match,
thiscall_matches, calling_convention_match,
"ignored" if self.is_stub else args_match, "ignored" if self.is_stub else args_match,
) )
@@ -193,7 +193,7 @@ class FullPdbFunctionImporter(PdbFunctionImporter):
name_match name_match
and namespace_match and namespace_match
and return_type_match and return_type_match
and thiscall_matches and calling_convention_match
and args_match and args_match
) )

View File

@@ -61,7 +61,7 @@ class PdbFunctionExtractor:
_call_type_map = { _call_type_map = {
"ThisCall": "__thiscall", "ThisCall": "__thiscall",
"C Near": "__thiscall", "C Near": "default",
"STD Near": "__stdcall", "STD Near": "__stdcall",
} }