RE FORUM
[REVERSE ENGINEERING] => Programming => Topic started by: Master on May 29, 2008, 04:05:53 PM
-
Zdarec lidi.Nevi nekdo,jak injectnout do suspendnuteho procesu dll?
Dikes za rady
-
Cus, mozna neco najdes tady
http://www.codeproject.com/KB/system/hooksys.aspx
nebo zkus mrknout sem http://deroko.phearless.org/index.html
-
Koukal sem na to,a moc mi to nepomohlo.
Konkretne vam reknu,co potrebuju.
Jde mi o to,ze potrebuju urcite exe nahrat do pamate jako novy proces,ale suspended.To neni problem.Ale potrebuju,aby ten suspendnuty proces jiz mel nacteny v pameti veskere dll.Co vim a co sem cetl,tak pri vytvareni a suspendnuti se linknute dll do pameti jeste nenahraji.A ja bych je prave potreboval nahrat.
Cetl sem na builderu:
http://forum.builder.cz/read.php?16,1474668,1497968#msg-1497968
Ze timhle malym figlem se da obelhat system a prinutit ho,aby dll nacetl.Ale nevim,jak je to presne mysleno.
Co myslite?
-
Nevim jestli myslíš zrovna tohle....
main.cpp
/*
* Max Payne DLL injector v1.0
* File Author: stym
*/
//Project Includes
#include "Includes.h"
#include <sys/stat.h>
//Namespace and Struct Declaration
using namespace std;
Vars Var = {0};
// define
#define PROCSS "maxpayne.exe" // exe process name
#define DLL_NAME "stym_dynamic.dll" // my dll inject
//Remove Thread
DWORD WINAPI RemoteThread (LPVOID)
{
while(!GetModuleHandle(DLL_NAME))
{
LoadLibrary(Var.DLL_Path);
Sleep(100);
}
return true;
}
//Check If the DLL Exist
bool CheckIfDLLExist (void)
{
Var.DLL_Exists = false;
Var.Stats = 0;
Var.Stats = stat(Var.DLL_Path,&Var.FileInfo);
if(!Var.Stats)
Var.DLL_Exists = true;
return Var.DLL_Exists;
}
//Main Routine
void main (void)
{
GetModuleFileName(Var.hInjector, Var.Injector_Dir, 512);
for(int i = strlen(Var.Injector_Dir); i > 0; i--) { if(Var.Injector_Dir == '\\') { Var.Injector_Dir[i+1] = 0; break; } }
strcpy(Var.DLL_Path,Var.Injector_Dir);
cout <<"Max Payne Injector v1.0 \n" <<endl;
cout <<"coded: stym (c) 2005 \n" <<endl;
strcat(Var.DLL_Path,DLL_NAME);
if(!CheckIfDLLExist())
{
cout<<"\nDLL does not exist in the Folder of the Injector.exe\n"<<endl;
system("PAUSE");
}
else
{
cout<<"\nStart game [Max Payene]... DLL will auto Inject\n" <<endl;
while(1)
{
Var.DLL_Injected = false;
Var.Snapshot = CreateToolhelp32Snapshot( TH32CS_SNAPPROCESS, 0 );
Var.ProcessEntry32.dwSize = sizeof(PROCESSENTRY32);
Process32First( Var.Snapshot, &Var.ProcessEntry32 );
while( Process32Next( Var.Snapshot, &Var.ProcessEntry32 ) )
{
if( strcmp( Var.ProcessEntry32.szExeFile, PROCSS ) == 0 )
{
cout<<"Found Process\n"<<endl;
cout<<"15 Seconds till injection...\n"<<endl;
Sleep(10000);
Var.Snapshot = OpenProcess(PROCESS_ALL_ACCESS, FALSE, Var.ProcessEntry32.th32ProcessID);
Var.AllocatedMemory = VirtualAllocEx(Var.Snapshot,NULL,MAX_PATH,MEM_COMMIT,PAGE_READWRITE);
if(!Var.AllocatedMemory)
cout<<"\nCouldnt allocate Memory for the Injecting Process\n"<<endl;
Var.KernelModule = GetModuleHandle("Kernel32.dll");
if(!Var.KernelModule)
cout<<"\nCouldnt get the Kernel32 Module Handle"<<endl;
Var.ThreadRet = (LPTHREAD_START_ROUTINE)GetProcAddress(Var.KernelModule,"LoadLibraryA");
if(!Var.ThreadRet)
cout<<"\Couldnt get LoadLibrary\n"<<endl;
if(!WriteProcessMemory(Var.Snapshot,Var.AllocatedMemory,(LPVOID)Var.DLL_Path,strlen(Var.DLL_Path),NULL))
cout<<"\Couldnt Write the DLL Path in the Process Memspace\n"<<endl;
Var.RemoteThread = CreateRemoteThread(Var.Snapshot,NULL,NULL,Var.ThreadRet,Var.AllocatedMemory,NULL,NULL);
if(!Var.RemoteThread)
cout<<"\nCouldnt load the DLL into the Process Memspace\n"<<endl;
else
cout<<"\nLoading Dll...\n"<<endl;
WaitForSingleObject(Var.RemoteThread,INFINITE);
ExitProcess(0);
}
Sleep(100);
}
Sleep(100);
}
}
}
Includes.h
/*
* Max Payne DLL injector v1.0
* File Author: stym
*/
#pragma once
//Project Includes
#include <windows.h>
#include <iostream>
#include <Tlhelp32.h>
#include <fstream>
#include "Vars.h"
//Disable Warnings
#pragma warning (disable:4129)
#pragma warning (disable:4267)
#pragma warning (disable:4800)
#pragma warning (disable:4996)
Vars.h
/*
* Max Payne DLL injector v1.0
* File Author: stym
*/
#pragma once
struct Vars
{
HANDLE RemoteThread;
HANDLE Snapshot;
LPTHREAD_START_ROUTINE ThreadRet;
HMODULE KernelModule;
LPVOID AllocatedMemory;
HMODULE hInjector;
PROCESSENTRY32 ProcessEntry32;
BOOL DLL_Exists;
BOOL DLL_Injected;
int Stats;
struct stat FileInfo;
char DLL_Path [MAX_PATH];
char Injector_Dir [MAX_PATH];
};
-
Co jsem tak okem sjel ten kod, tak je to temer to same, co mi poradili dalsi a co sem nakonec nejak dokutil.
Jinak vitej mezi nama :)