Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


[DLL Injection]

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
assaf84
Expert Cheater
Reputation: 0

Joined: 03 Oct 2006
Posts: 238

PostPosted: Thu Aug 23, 2007 6:04 am    Post subject: [DLL Injection] Reply with quote

Hey

I want to inject a dll into gamemon.des, but I have no idea how to do it without being detected. I know I can inject it with injecTOR for example, but I want to do it in my own code.
The thing that I mainly don't know is how to make a process watcher to catch GG. Another thing that I'm not quite sure about is how to write the code of loading a dll into GG's process without being detected.

Is it possible to do this without writing a kernel mode driver? Because I don't know sh!t about it...

Thanks anyone..
Back to top
View user's profile Send private message
Noz3001
I'm a spammer
Reputation: 26

Joined: 29 May 2006
Posts: 6220
Location: /dev/null

PostPosted: Thu Aug 23, 2007 7:25 am    Post subject: Reply with quote

LOL, kernel mode drivers have nothing to do with DLL injection..
Back to top
View user's profile Send private message MSN Messenger
assaf84
Expert Cheater
Reputation: 0

Joined: 03 Oct 2006
Posts: 238

PostPosted: Thu Aug 23, 2007 7:27 am    Post subject: Reply with quote

So what can I do?
Back to top
View user's profile Send private message
UnLmtD
Grandmaster Cheater
Reputation: 0

Joined: 13 Mar 2007
Posts: 894
Location: Canada

PostPosted: Thu Aug 23, 2007 7:57 am    Post subject: Reply with quote

For the DLL injection question, there's many ways of injecting a DLL into a process address space. But you probably want to easiest/working method. So yeah this is a function I found in a old source code.
Code:

HANDLE (*LoadLib)(LPCSTR);
HANDLE inject(DWORD pid, char* dllname) 
{
   HANDLE process, pointless;
   char* dllnamet;

   if(!pid)
      return false;

   process = OpenProcess(PROCESS_ALL_ACCESS, TRUE, pid);
   LoadLib = (HANDLE (*)(LPCSTR))GetProcAddress(LoadLibrary("kernel32.dll"), "LoadLibraryA");
   dllnamet = (char*)VirtualAllocEx(process, NULL, strlen(dllname) + 1, MEM_COMMIT, PAGE_READWRITE);
   
   c = GetLastError();
   
   WriteProcessMemory(process, dllnamet, dllname, strlen(dllname) + 1, NULL);
   HANDLE thread = CreateRemoteThread(process, NULL, 0, (LPTHREAD_START_ROUTINE)LoadLib, dllnamet, 0, NULL);
   WaitForSingleObject(thread, INFINITE);
   GetExitCodeThread(thread, (DWORD*)&pointless );

   if(!pointless)
      printf(" [X] Cannot inject\n");
   else
      printf(" [!] Injected Succesfully\n");
   
   VirtualFreeEx(process, NULL, strlen(dllname) + 1, MEM_DECOMMIT);
   printf(" [!] Dll Name: %s\n", dllname);

   CloseHandle(process);
   CloseHandle(thread);

   return pointless;
}   


Basically it creates a thread in the targeted process, and uses LoadLibraryA to load the DLL.

For the GameGuard watcher, use the function I pointed out in your last thread, and put it a loop. If it succeeds, means that gameguard is running and not yet hidden.

To use the "inject" function, you do: (If the DLL is in your folder)
Code:
                  TCHAR CURRENTDIR[MAX_PATH];
                  GetCurrentDirectory(BUFSIZE,CURRENTDIR);
                  strcat(CURRENTDIR, "\\YourDLL.dll");
                  inject(pID, CURRENTDIR);


Sorry if I forgot something, I just woke up Confused

_________________
Back to top
View user's profile Send private message
assaf84
Expert Cheater
Reputation: 0

Joined: 03 Oct 2006
Posts: 238

PostPosted: Thu Aug 23, 2007 9:26 am    Post subject: Reply with quote

Thanks a lot... I've just seen something like this somewhere..
And wouldn't GG detect this? I mean, wouldn't it detect OpenProcess or WriteProcessMemory?
Well, maybe I should just terminate the injector after the DLL is injected or something..?
Back to top
View user's profile Send private message
UnLmtD
Grandmaster Cheater
Reputation: 0

Joined: 13 Mar 2007
Posts: 894
Location: Canada

PostPosted: Thu Aug 23, 2007 9:30 am    Post subject: Reply with quote

Thats why you inject while GameGuard is initializing. I think x0r injector was using this method.
_________________
Back to top
View user's profile Send private message
assaf84
Expert Cheater
Reputation: 0

Joined: 03 Oct 2006
Posts: 238

PostPosted: Thu Aug 23, 2007 9:45 am    Post subject: Reply with quote

And will GG detect it after it's initialization?
Back to top
View user's profile Send private message
UnLmtD
Grandmaster Cheater
Reputation: 0

Joined: 13 Mar 2007
Posts: 894
Location: Canada

PostPosted: Thu Aug 23, 2007 9:47 am    Post subject: Reply with quote

The dll? Doesn't look like it does.
_________________
Back to top
View user's profile Send private message
assaf84
Expert Cheater
Reputation: 0

Joined: 03 Oct 2006
Posts: 238

PostPosted: Thu Aug 23, 2007 9:50 am    Post subject: Reply with quote

I meant, will it detect the injector?
Back to top
View user's profile Send private message
UnLmtD
Grandmaster Cheater
Reputation: 0

Joined: 13 Mar 2007
Posts: 894
Location: Canada

PostPosted: Thu Aug 23, 2007 9:52 am    Post subject: Reply with quote

No, but it won't work after GG is done loading.
_________________
Back to top
View user's profile Send private message
assaf84
Expert Cheater
Reputation: 0

Joined: 03 Oct 2006
Posts: 238

PostPosted: Thu Aug 23, 2007 9:56 am    Post subject: Reply with quote

Oh.. cool, good enough for me Smile

Tnx a lot!
+rep
edit: I need to +rep someone else before you, it just won't let me XD
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites