Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //##############################################
- //######### Dll Injector , Coded By IVDZ #########
- //##############################################
- #include <Windows.h>
- #include <tlhelp32.h>
- #include <comdef.h>
- LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
- bool Inject(char* Dll ,char* Process);
- HWND button,TXT1,TXT2;
- int WINAPI WinMain (HINSTANCE hThisInstance,HINSTANCE hPrevInstance,LPSTR lpszArgument,int nFunsterStil)
- {
- //Create Window with Controls :
- WNDCLASS Form1;
- Form1.cbClsExtra = 0;
- Form1.cbWndExtra = 0;
- Form1.hbrBackground = (HBRUSH)5;
- Form1.hCursor = LoadCursor(0,IDC_ARROW);
- Form1.hIcon = LoadIcon(0,IDI_APPLICATION);
- Form1.hInstance = hThisInstance;
- Form1.lpfnWndProc = WndProc;//-------------------------
- Form1.lpszClassName = TEXT("Form1");
- Form1.lpszMenuName = 0;
- Form1.style= 0;
- RegisterClass(&Form1);
- HWND a =CreateWindow(TEXT("Form1"),TEXT("Injector By IVDZ"),WS_OVERLAPPEDWINDOW,CW_USEDEFAULT,CW_USEDEFAULT,400,200,0,0,0,0);
- button = CreateWindowEx(0,TEXT("Button"),TEXT("Inject Dll"),WS_CHILD |WS_VISIBLE,160,100,100,50,a,0,0,0);
- TXT1 = CreateWindowEx(0,TEXT("edit"),TEXT("c:\\MyDll.dll"),WS_CHILD |WS_VISIBLE,50,20,300,30,a,0,0,0);
- TXT2 = CreateWindowEx(0,TEXT("edit"),TEXT("Example.exe"),WS_CHILD |WS_VISIBLE,50,60,300,30,a,0,0,0);
- ShowWindow(a,1);
- UpdateWindow(a);
- MSG msg;
- while (GetMessage(&msg,a,0,0))
- {
- TranslateMessage(&msg);
- DispatchMessage(&msg);
- }
- }
- LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
- {
- switch (msg)
- {
- case WM_CLOSE:
- ExitProcess(0);
- case WM_COMMAND:
- if ((DWORD)lParam == (DWORD)button )
- {
- char Dll[256] ;
- char Proc[256] ;
- GetWindowTextA(TXT1,Dll,256);
- GetWindowTextA(TXT2,Proc,256);
- if (CreateFile(_bstr_t(Dll),0,0,0,OPEN_EXISTING,0,0)==0)
- {
- MessageBoxA(0,"Dll Not Found","Error",MB_ICONWARNING);
- return 0;
- }
- Inject(Dll,Proc);
- }
- default:
- return DefWindowProc(hwnd,msg,wParam,lParam);
- }
- return 0;
- }
- bool Inject(char* Dll ,char* Process)
- {
- DWORD ProcID = NULL;
- //Get Torget Process ID
- HANDLE snap =CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS,0);
- PROCESSENTRY32 info;
- info.dwSize = sizeof(PROCESSENTRY32);
- bool a = Process32First(snap,&info);
- while (a)
- {
- if (_bstr_t(info.szExeFile) == _bstr_t(Process))
- {
- ProcID = info.th32ProcessID;
- goto Go;
- }
- a = Process32Next(snap,&info);
- }
- MessageBoxA(0,"Torget Process Not Found","Error",MB_ICONWARNING);
- return 0;
- Go:
- //Get LoadLibraryA Address :
- LPVOID LoadLibraryAddres = GetProcAddress(GetModuleHandleA("kernel32"),"LoadLibraryA");
- //Write Dll Path in Torget Process Memoiry :
- HANDLE pro = OpenProcess(PROCESS_ALL_ACCESS,0,ProcID);
- LPVOID Address = VirtualAllocEx(pro,0,strlen(Dll),MEM_COMMIT,PAGE_EXECUTE_READWRITE);
- WriteProcessMemory(pro,Address,Dll,strlen(Dll),0);
- //Create New Thread in Torget Process and Load Dll in it :
- DWORD crea = (DWORD)CreateRemoteThread(pro,0,0,(LPTHREAD_START_ROUTINE)LoadLibraryAddres,Address,0,0);
- if (crea == 0)
- {
- MessageBoxA(0,"Injecting Failed , May Your Process Envermment Not Compatibilite With Injector Envoremment . ","Error",MB_ICONERROR);
- return 0;
- }
- MessageBoxA(0,"Dll injected Sucessfully","Sucessfully",MB_ICONINFORMATION);
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement