Created
August 7, 2020 01:04
-
-
Save bats3c/75bc4e84d0869625904d541cda786944 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
VOID InjectDll(DWORD dwPid, LPCVOID lpDllPath) | |
{ | |
LPVOID lpBuffer; | |
HANDLE hProcess, hThread; | |
hProcess = OpenProcess(PROCESS_ALL_ACCESS, 0, dwPid); | |
if (!hProcess) | |
{ | |
return; | |
} | |
lpBuffer = VirtualAllocEx(hProcess, NULL, strlen(lpDllPath), MEM_RESERVE | MEM_COMMIT, PAGE_EXECUTE_READWRITE); | |
WriteProcessMemory(hProcess, lpBuffer, lpDllPath, strlen(lpDllPath), NULL); | |
PTHREAD_START_ROUTINE pLoadLib = (PTHREAD_START_ROUTINE)GetProcAddress(GetModuleHandle("kernel32.dll"), "LoadLibraryA"); | |
CreateRemoteThread(hProcess, NULL, 0, pLoadLib, lpBuffer, 0, NULL); | |
return; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment