I want to create a remote stream, and after that I want to read its result

In the code below, I would like to read the result of LoadLibrayA created using CreateRemoteThread.

I will be grateful for the help, because it seems impossible,

Perhaps the result is free on time to read, any proposal will be happy to receive

procedure InjectDLL(hProcess : Cardinal; ADllPath : String); var lSize : Cardinal; hThread : Cardinal; szLibPath : array [0..MAX_PATH] of char; pLibRemote : Pointer; hLibModule : DWORD ; hKernel32 : HMODULE; begin hKernel32 := GetModuleHandle('Kernel32.dll'); FillMemory(@szLibPath, sizeOf(szLibPath), 0); CopyMemory(@szLibPath, Pointer(ADllPath), length(ADllPath)); pLibRemote := VirtualAllocEx( hProcess, nil, sizeOf(szLibPath), MEM_COMMIT, PAGE_READWRITE ); try WriteProcessMemory( hProcess, pLibRemote, @szLibPath, sizeOf(szLibPath), lSize ); hThread := CreateRemoteThread( hProcess, nil, 0, GetProcAddress(hKernel32, 'LoadLibraryA'), pLibRemote, 0, lSize ); try WaitForSingleObject(hThread, INFINITE); //------------> HERE I WANT TO READ LoadLibraryA RESULT GetExitCodeThread(hThread, hLibModule); finally // Clean up CloseHandle(hThread); end; finally VirtualFreeEx(hProcess, pLibRemote, sizeof(szLibPath), MEM_RELEASE); end; 
+4
source share
1 answer

Your LoadLibrary Flow Procedure. The return value of your stream procedure is the stream exit code. Therefore, the return value of the LoadLibrary call can be read by calling GetExitCodeThread . What are you already doing.

+2
source

Source: https://habr.com/ru/post/1484719/


All Articles