GrammaTech / gtirb-rewriting

Python API for rewriting GTIRB files
GNU General Public License v3.0
16 stars 3 forks source link

gtirb_rewriting.assembler.assembler.UndefSymbolError: test is an undefined symbol reference #5

Open Pl0414141 opened 1 year ago

Pl0414141 commented 1 year ago

I am doing binary rewriting on Windows binaries, the tested binary is compiled with Visual Studio 2022 and the dependences are the following:

KERNEL32.dll VCRUNTIME140.DLL

I have used the following code to load these external libraries and solve the following error:

class NilMsgPass(Pass):
    def begin_module(self, module, functions, context):
        context.get_or_insert_extern_symbol(
            "test", "libraries.dll")
        context.register_insert(
            #AllFunctionsScope(FunctionPosition.ENTRY, BlockPosition.ENTRY),
            SingleBlockScope(module.entry_point, BlockPosition.ENTRY),
            Patch.from_function(self.nop_patch),
        )

    @patch_constraints(x86_syntax=X86Syntax.INTEL)
    def nop_patch(self, context):
        return """
            call test
            ret
        """

but it dont work, any solution?

File "C:\Users\mar\AppData\Local\Programs\Python\Python38\lib\site-packages\gtirb_rewriting-0.1.2.dev0-py3.8.egg\gtirb_rewriting\assembler\assembler.py", line 1458, in _resolve_symbol gtirb_rewriting.assembler.assembler.UndefSymbolError: test is an undefined symbol reference

jranieri-grammatech commented 1 year ago

Hi, I apologize for the late reply. Between deadlines and parental leave this sort of fell off my radar.

Is this still a problem you're having? This code looks to be correct.