I'm trying to call a function with the appropriate arguments inside a process remotely and somehow retrieve the return value which the function outputs. So far i'm capable of calling a function with arguments, like this.
DWORD read;
BYTE AsmStub[] = {
0x68, 00,00,00,00,
0xB8, 00,00,00,00, // MOV EAX, 0x00
0xFF, 0xD0, // Call Eax
0xC3,
};
*(DWORD*)&AsmStub[1] = ;
*(DWORD*)&AsmStub[6] = ;
LPVOID Address = VirtualAllocEx(handle, NULL, sizeof(AsmStub), MEM_COMMIT, PAGE_EXECUTE_READWRITE);
WriteProcessMemory(handle, Address, AsmStub, sizeof(AsmStub), &read);
HANDLE pHandle = CreateRemoteThread(handle, NULL, sizeof(DWORD), (LPTHREAD_START_ROUTINE)Address, NULL, NULL, NULL);
WaitForSingleObject(pHandle,INFINITE);
CloseHandle(pHandle);
VirtualFreeEx(handle, (LPVOID)Address, sizeof(AsmStub), MEM_RELEASE);
I'm aware that the credit for this apporach belongs to someone else.
So how can i achieve the return value?