In the process of creating a thread function RtlCreateUserThread
RtlCreateUserThread(hProcess, NULL, true, 0, 0, 0, (PVOID)GetProcAddress(hModule, function), NULL, &hThread, &cid);
In the case of functions without parameters, such as ExitProcess
from kernel32
, everything works fine, but when I try to transfer, for example, MessageBox
from user32.dll
, I don’t know how to pass the parameters of this function (3rd from the end RtlCreateUserThread
parameter) such as parent, text, type etc. How to pass parameters ( PVOID StartParameter
)?
Update
Tried to do so, declared function
void message(){ MessageBoxA(NULL, "text", "aption", MB_OK); }
And caused RtlCreateUserThread(hProcess, NULL, true, 0, 0, 0, &message, NULL, &hThread, &cid);
Process crashed
Doesn’t have the appropriate access
Update 2
Challenge doing in someone else's process. What is needed for now is just for common development. As for the rights, it is strange that before the call I receive an access token with TOKEN_ALL_ACCESS
OpenProcessToken(GetCurrentProcess(), TOKEN_ALL_ACCESS, &hToken);
And I open the process with PROCESS_ALL_ACCESS HANDLE hProcess = OpenProcess(PROCESS_ALL_ACCESS, false, PID);
EXTERN_C NTSTATUS WINAPI RtlCreateUserThread( HANDLE hProcess, SECURITY_DESCRIPTOR* pSec, BOOLEAN fCreateSuspended, ULONG StackZeroBits, SIZE_T* StackReserved, SIZE_T* StackCommit, void* StartAddress, void* Parametr, HANDLE* pThreadHandle, CLIENT_ID* pResult);
As for the function, again for the sake of interest - Louis Cauchy