MCPcopy Create free account
hub / github.com/PenguLoader/PenguLoader / InjectThisDll

Function InjectThisDll

core/src/dllmain.cc:101–118  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

99}
100
101static void InjectThisDll(HANDLE hProcess)
102{
103 HMODULE kernel32 = GetModuleHandleA("kernel32");
104 auto pVirtualAllocEx = (decltype(&VirtualAllocEx))GetProcAddress(kernel32, "VirtualAllocEx");
105 auto pWriteProcessMemory = (decltype(&WriteProcessMemory))GetProcAddress(kernel32, "WriteProcessMemory");
106 auto pCreateRemoteThread = (decltype(&CreateRemoteThread))GetProcAddress(kernel32, "CreateRemoteThread");
107
108 WCHAR thisDllPath[2048]{};
109 GetModuleFileNameW((HMODULE)&__ImageBase, thisDllPath, _countof(thisDllPath));
110
111 size_t pathSize = (wcslen(thisDllPath) + 1) * sizeof(WCHAR);
112 LPVOID pathAddr = pVirtualAllocEx(hProcess, NULL, pathSize, MEM_COMMIT, PAGE_READWRITE);
113 pWriteProcessMemory(hProcess, pathAddr, thisDllPath, pathSize, NULL);
114
115 HANDLE loader = pCreateRemoteThread(hProcess, NULL, 0, (LPTHREAD_START_ROUTINE)&LoadLibraryW, pathAddr, 0, NULL);
116 WaitForSingleObject(loader, INFINITE);
117 CloseHandle(loader);
118}
119
120int APIENTRY _BootstrapEntry(HWND, HINSTANCE, LPWSTR commandLine, int)
121{

Callers 2

Hooked_CreateProcessWFunction · 0.85
_BootstrapEntryFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected