I'm working on a plugin for somthing (which I don't have access to the source of) and have run into an issue. The following assembly extract is from the main program and is the start of the procedure that is responsible for calling into my code (the entire code for this is very very long since it is very generall being able to call any function with upto 16 arguments plus relevant memory management for strings, and supporting either __stdcall or __cdecl). Unfortunatly one very important value is not passed through this function into my code, the "this" pointer held in the edx register.
So I need to inject some sort of code into the start of this function (The provided API's allow me to get the address of it, in this case 0x00613ED4) that will store the value in the edx register for me to retrieve later.
Ive done some x86 assembly before, however I never needed to inject new code into an existing module at runtime before and I couldnt find any information on how to go about doing such things :( If such things can actually be done from within C/C++ without me having to write all the stuff in assembly that would be even better.
00613ED4 push ebp
00613ED5 mov ebp,esp
00613ED7 add esp, 0FFFFFE64h
00613EDD push ebx
00613EDE push esi
00613EDF push edi
00613EE0 mov dword ptr [ebp-19Ch],ecx
00613EE6 mov ecx,11h
00613EEB lea eax, [ebp-198h]
...