Basic DLL Injector
PUBLISHED
FILE_ID: BASIC DLL INJECTOR

Basic DLL Injector

Willian Frantz
Feb 21, 2026
PerformanceOptimizationWeb VitalsMonitoring

Basic DLL Injector

injector.cpp

1#include <Windows.h> 2#include <stdio.h> 3 4int main() { 5 char cmdLine[] = "SPEED2.EXE /s"; 6 char dllPath[] = "nfsu2.dll"; 7 8 STARTUPINFOA si{}; 9 PROCESS_INFORMATION pi{}; 10 si.cb = sizeof(si); 11 12 if (!CreateProcessA( 13 nullptr, 14 cmdLine, 15 nullptr, nullptr, 16 FALSE, 17 CREATE_SUSPENDED, 18 nullptr, nullptr, 19 &si, &pi)) 20 { 21 printf("CreateProcess failed: %lu\n", GetLastError()); 22 return 0; 23 } 24 25 SIZE_T len = strlen(dllPath) + 1; 26 27 void* remoteBuf = VirtualAllocEx( 28 pi.hProcess, 29 nullptr, 30 len, 31 MEM_COMMIT | MEM_RESERVE, 32 PAGE_READWRITE); 33 34 WriteProcessMemory( 35 pi.hProcess, 36 remoteBuf, 37 dllPath, 38 len, 39 nullptr); 40 41 HMODULE k32 = GetModuleHandleA("kernel32.dll"); 42 auto pLoadLibraryA = 43 (LPTHREAD_START_ROUTINE)GetProcAddress(k32, "LoadLibraryA"); 44 45 HANDLE hThread = CreateRemoteThread( 46 pi.hProcess, 47 nullptr, 48 0, 49 pLoadLibraryA, 50 remoteBuf, 51 0, 52 nullptr); 53 54 WaitForSingleObject(hThread, INFINITE); 55 56 CloseHandle(hThread); 57 VirtualFreeEx(pi.hProcess, remoteBuf, 0, MEM_RELEASE); 58 59 ResumeThread(pi.hThread); 60 61 CloseHandle(pi.hThread); 62 CloseHandle(pi.hProcess); 63 64 return 1; 65} 66
END_OF_FILE • ARTICLE_COMPLETE