Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/idouble/simple-dll-injection
🔧 Simple DLL Injection into a Process with C++ 🔧
https://github.com/idouble/simple-dll-injection
cplusplus cpp dll dll-injection dword findwindow handle hwnd injection process simple snippets template thread windows
Last synced: about 1 month ago
JSON representation
🔧 Simple DLL Injection into a Process with C++ 🔧
- Host: GitHub
- URL: https://github.com/idouble/simple-dll-injection
- Owner: IDouble
- License: mit
- Created: 2019-08-16T07:07:14.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2024-02-29T17:13:57.000Z (11 months ago)
- Last Synced: 2024-12-24T08:25:51.831Z (about 1 month ago)
- Topics: cplusplus, cpp, dll, dll-injection, dword, findwindow, handle, hwnd, injection, process, simple, snippets, template, thread, windows
- Language: C++
- Homepage:
- Size: 28.5 MB
- Stars: 90
- Watchers: 4
- Forks: 8
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# 🔧 Simple DLL Injection 🔧
🔧 Simple DLL Injection into a Process with C++ 🔧## 🔧 Inject DLL into Process (DLL Injection) 🔧
```
#include
#includeusing namespace std;
int main()
{
LPCSTR DllPath = "C:\\Simple-DLL-Injection\\C++\\Debug\\testlib.dll"; // The Path to our DLL
HWND hwnd = FindWindowA(NULL, "Tutorial-x86_64"); // HWND (Windows window) by Window Name
DWORD procID; // A 32-bit unsigned integer, DWORDS are mostly used to store Hexadecimal Addresses
GetWindowThreadProcessId(hwnd, &procID); // Getting our Process ID, as an ex. like 000027AC
HANDLE handle = OpenProcess(PROCESS_ALL_ACCESS, FALSE, procID); // Opening the Process with All Access// Allocate memory for the dllpath in the target process, length of the path string + null terminator
LPVOID pDllPath = VirtualAllocEx(handle, 0, strlen(DllPath) + 1, MEM_COMMIT, PAGE_READWRITE);// Write the path to the address of the memory we just allocated in the target process
WriteProcessMemory(handle, pDllPath, (LPVOID)DllPath, strlen(DllPath) + 1, 0);// Create a Remote Thread in the target process which calls LoadLibraryA as our dllpath as an argument -> program loads our dll
HANDLE hLoadThread = CreateRemoteThread(handle, 0, 0,
(LPTHREAD_START_ROUTINE)GetProcAddress(GetModuleHandleA("Kernel32.dll"), "LoadLibraryA"), pDllPath, 0, 0);WaitForSingleObject(hLoadThread, INFINITE); // Wait for the execution of our loader thread to finish
cout << "Dll path allocated at: " << hex << pDllPath << endl;
cin.get();VirtualFreeEx(handle, pDllPath, strlen(DllPath) + 1, MEM_RELEASE); // Free the memory allocated for our dll path
return 0;
}
```![Simple DLL Injection into a Process with C++](Images/DLLInjection.png)
![Binance Ready to give crypto a try ? buy bitcoin and other cryptocurrencies on binance](Images/binance.jpg)