Created
May 21, 2022 00:13
-
-
Save danecando/e3d9dd0c1ef54d323bd43e1f00f8fb16 to your computer and use it in GitHub Desktop.
The first code that I ever open sourced on gamedeception.net
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Some dll injection code | |
// November 21, 2004 | |
// by SpuN [ http://spun.gamedeception.net ] | |
// injection_thread.cpp | |
DWORD WINAPI InjectionThread(LPVOID lpParam) | |
{ | |
while(1) | |
{ | |
HANDLE hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0); | |
PROCESSENTRY32 PE32; | |
PE32.dwSize = sizeof(PROCESSENTRY32); | |
if(!Process32First(hSnapshot, &PE32)) | |
return 0; | |
while(Process32Next(hSnapshot, &PE32)) | |
{ | |
if(strcmp(PE32.szExeFile, "hl.exe")== 0) | |
{ | |
Sleep(100); | |
HANDLE hProcess = OpenProcess(PROCESS_ALL_ACCESS, false, PE32.th32ProcessID); | |
HANDLE hModule = VirtualAllocEx(hProcess, 0, sizeof(szDllToInject), MEM_COMMIT, PAGE_EXECUTE_READWRITE); | |
WriteProcessMemory(hProcess, hModule, (LPVOID)szDllToInject, sizeof(szDllToInject), NULL); | |
CreateRemoteThread(hProcess, NULL, 0, (unsigned long(__stdcall *)(void *))GetProcAddress(GetModuleHandle("kernel32"), "LoadLibraryA"), hModule, 0, NULL); | |
CloseHandle(hProcess); | |
CloseHandle(hModule); | |
ExitProcess(0); | |
break; | |
} | |
} | |
CloseHandle(hSnapshot); | |
Sleep(5); | |
} | |
return 0; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment