Hi,
i injected a own function into the memory scope of a process and want to call this procedure with CreateRemoteThreat.
I Allocated some Memory with access protection EXECUTE_READWRITE and binary wrote the function into the allocated memory.
this is how my injected function looks like:
But if i call my function with CreateRemoteThreat i get a access violation.
EDIT2: I've looked over this piece of code again and again and the only possible mistake for me is that you have set the wrong address at your call (line 5). Maybe you can try to set a breakpoint at the beginning of your function in Olly and then have a look when the programm crashes or throws an error. Then you know the location which causes the crash. I guess (hope) it is the call...
CreateRemoteThread wants a function defined as
DWORD (__stdcall *)(LPVOID)
your code (which should be the thread entry point if i understood you right) doesnt save the registers like a __stdcall function does it and you use RETN, instead of RET 4 (which you should use since a thread has one parameter and you have to remove the stack allocation for it)
your code should look like that:
Code:
push ebp
mov ebp, esp
push 5
push 0B110000
push 24D78E88
CALL 006EC051
mov esp, ebp
pop ebp
RET 4
additionally, it is important which calling convention the function you are calling has.
if it has __stdcall, the code will work like that, but if it has __cdecl you have to remove the parameters from the stack after the call!
in this case, use:
Code:
push ebp
mov ebp, esp
push 5
push 0B110000
push 24D78E88
CALL 006EC051
sub esp, 0C
mov esp, ebp
pop ebp
RET 4
Here is your mistake I think. You mustn't free the allocated memory after creating the thread. The created thread runs independently from the main thread. In order to achieve multitasking, 'CreateRemoteThread' is not a blocking call. As a result you are trying to free your allocated memory before the created thread has finished executing. So you have to ensure that your thread has done its job before you want to free the memory.
[Hilfe]Ungelöstes Server Erstell Problem, ausführliche Problem Schilderung 09/15/2011 - Flyff Private Server - 8 Replies Hey Com!
Ich hoffe, dass dieser Thread nicht als Spamthread angesehen wird, da ich ja gestern schon einen zu diesem Thema eröffnet habe.
Sorry wenn ich euch mit dem Thema nerve, aber ich sitze nun schon 4 Tage über dem Problem, und finde einfach keine Lösung.
Nun werde ich hier allerdings eine ausführlichere Beschreibung des Problems geben.
Mein Problem ist, dass ich den Windows Mssql Server 2008/2005 aus Sedrika's TuT nicht installieren kann, da sobald ich ihn immer installiere...