Probleme mit dem g++ Inlineassembler
-
Hallo zusammen.
Ich möchte ein Macro schreiben, welches zwei aktive Argumente hat: 'y' ist ein Integer und z ist eine Funktion oder Methode (z.B. "Klasse::Methode"). Diese Argumente sollen beide als unsigned integer an eine andere Funktion übergeben werden.
Bisher sieht das folgendermaßen aus:
#define HookAsJump(x,y,z) \ __asm__ __volatile__ \ ( \ "push %1;" \ "push $0x00;" \ "push %0;" \ "push $0xE9;" \ "mov %2, %%eax;" \ "call *%%eax;" \ "add $16, %%esp;" \ : \ : "i" (y), \ "r" (&z), \ "g" (&HookAsOpcode) \ : "%eax" \ ); void HookAsOpcode (uint8 uCode, uint32 uAddress, uint8 uLength, uint32 uProc);
Der erzeugte Code für einen HookAsJump-Aufruf sieht in IDA Pro folgendermaßen aus:
mov edx, offset _Z14Create_ObjectMPKcRK8Matrix3D push edx push 0 push 819C728h push 0E9h mov eax, offset _Z12HookAsOpcodehjhj call eax add esp, 10h
Ich hätte es aber gerne folgendermaßen, weiß aber nicht, wie ich das dem Inline-Assembler klar mache:
push offset _Z14Create_ObjectMPKcRK8Matrix3D push 0 push 819C728h push 0E9h call Z12HookAsOpcodehjhj add esp, 10h
Grüße,
Marc