Today I got an LoadLibraryA injector that works perfectly but it doesn't let delete the dll after injection (loadlibrary things) and I tried doing FreeLibraryAndExitThread but it didnt work.
The code I tried:
FreeLibraryAndExitThread(hThread, 0);
The injection code:
const char* procName = "notepad.exe";
DWORD procID = 0;
while (!procID)
{
procID = GetProcID(procName);
Sleep(30);
}
HANDLE hProc = OpenProcess(PROCESS_ALL_ACCESS, 0, procID);
if (hProc && hProc != INVALID_HANDLE_VALUE)
{
void* loc = VirtualAllocEx(hProc, 0, MAX_PATH, MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE);
if (loc)
{
WriteProcessMemory(hProc, loc, dllPath, strlen(dllPath) + 1, 0);
}
HANDLE hThread = CreateRemoteThread(hProc, 0, 0, (LPTHREAD_START_ROUTINE)LoadLibraryA, loc, 0, 0);
if (hThread)
{
CloseHandle(hThread);
}
if (hProc)
{
CloseHandle(hProc);
}
FreeLibraryAndExitThread(hThread, 0);
return 0;
}
btw sorry for stupid questions, I'm new to cpp and didn't find an solution in internet that does work.