


You had some problems with condition checking. Here You have, had to rewrite it to the more "proper" code. The above code can open a 32 bit process and runs without a function call failing but the DLL is not injecting? Always successful, even in the cases which lead to OpenProcess failureĬout << "SUCCESSFULLY CHANGED TOKEN PRIVILEGES" << endl Ĭout << "FAILED TO CHANGE TOKEN PRIVILEGES, CODE: " << GetLastError() << endl If (AdjustTokenPrivileges(hToken, FALSE, &tokenPriv, 0, NULL, NULL) != FALSE) If (LookupPrivilegeValue(NULL, SE_DEBUG_NAME, &luidDebug) != FALSE)

If (OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES, &hToken) != FALSE) Note: Enabling SeDebugPrivilege adapted from sample VirtualFreeEx(handleToProc, baseAddr, dllPath->length(), MEM_RELEASE) Ĭout << "Failed to close handle to remote thread.\n" Ĭout << "Failed to close handle to target process.\n" WaitForSingleObject(remThread, INFINITE) Wait untill DLL exits then deallocate memmory RemThread = CreateRemoteThread(handleToProc, NULL, NULL, (LPTHREAD_START_ROUTINE)LoadLibAddr, baseAddr, 0, NULL) If (!WriteProcessMemory(handleToProc, baseAddr, dllPath, dllPath->length(), NULL)) *handleToProc = OpenProcess(PROCESS_ALL_ACCESS, false, pid) Ĭout length(), MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE) Int getProc(HANDLE* handleToProc, DWORD pid) PS remThread is value 0x0000011c // DLL Injector.cpp : Defines the entry point for the console application. Any suggestions on why this runs fine but is not injecting? I can delete the test.dll I used which means it is not being used. However I know the DLL is not injecting because when I run this application on a 32 bit game. I ran the program in the debugger and it looks like all the functions passed. I am using visual studios 2017 on windows 10 and I wrote a c++ program to open a handle to a process.
