HITOA

Basic DLL injection with suspended

Oct 29th, 2020 (edited)
463
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. #include <Windows.h>
  3.  
  4. int main()
  5. {
  6.     wchar_t processName[] = L"Process.exe";
  7.     char dllName[] = "Dll.dll";
  8.  
  9.     STARTUPINFO si;
  10.     PROCESS_INFORMATION pi;
  11.  
  12.     memset(&si, 0, sizeof(si));
  13.     memset(&pi, 0, sizeof(pi));
  14.  
  15.     if (CreateProcessW(processName, NULL, NULL, NULL, FALSE, CREATE_SUSPENDED, NULL, NULL, &si, &pi)) {
  16.         LPVOID loadlibrary_adress = GetProcAddress(GetModuleHandleW(L"kernel32.dll"), "LoadLibraryA");
  17.  
  18.         LPVOID argmemadress = VirtualAllocEx(pi.hProcess, nullptr, sizeof(dllName), MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE);
  19.  
  20.         WriteProcessMemory(pi.hProcess, argmemadress, dllName, sizeof(dllName), NULL);
  21.         CreateRemoteThread(pi.hProcess, nullptr, 0, (LPTHREAD_START_ROUTINE)loadlibrary_adress, argmemadress, 0, nullptr);
  22.         ResumeThread(pi.hThread);
  23.     }
  24.  
  25.     return 0;
  26. }
RAW Paste Data