#include <Windows.h>
#include <TlHelp32.h>
int main() {
// Get handle to the target process
DWORD pid = 0;
HANDLE hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
PROCESSENTRY32 pe32;
pe32.dwSize = sizeof(PROCESSENTRY32);
if (Process32First(hSnapshot, &pe32)) {
do {
if (!_stricmp(pe32.szExeFile, "csgo.exe")) {
pid = pe32.th32ProcessID;
break;
}
} while (Process32Next(hSnapshot, &pe32));
}
CloseHandle(hSnapshot);
if (!pid) {
printf("Failed to find csgo process\n");
return 1;
}
HANDLE hProcess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, pid);
// Allocate memory for the DLL path in the target process
LPVOID remoteString = VirtualAllocEx(hProcess, NULL, strlen("path\\to\\dll.dll") + 1, MEM_COMMIT, PAGE_READWRITE);
// Write the DLL path to the allocated memory
WriteProcessMemory(hProcess, remoteString, "path\\to\\dll.dll", strlen("path\\to\\dll.dll") + 1, NULL);
// Create a remote thread that will call LoadLibraryA with the DLL path as a parameter
HANDLE hThread = CreateRemoteThread(hProcess, NULL, 0, (LPTHREAD_START_ROUTINE)GetProcAddress(GetModuleHandleA("kernel32.dll"), "LoadLibraryA"), remoteString, 0, NULL);
// Wait for the thread to finish
WaitForSingleObject(hThread, INFINITE);
// Free the memory allocated in the target process
VirtualFreeEx(hProcess, remoteString, strlen("path\\to\\dll.dll") + 1, MEM_RELEASE);
// Close handles
CloseHandle(hThread);
CloseHandle(hProcess);
return 0;
}