| View previous topic :: View next topic |
| Author |
Message |
PsychicSymphony Newbie cheater
Reputation: 0
Joined: 17 May 2011 Posts: 13 Location: Ontario
|
Posted: Tue May 17, 2011 4:39 pm Post subject: c++ making a dll to inject to a program |
|
|
Im trying to make a dll to inject to a program that will draw a bitmap to the desktop that has info about the hack. All I know about dlls is that the entry point is
[code]BOOL WINAPI DllMain[code]
thats all I know can anyone tell me what goes in the dll main method and how I put a update method into a dll?[/code] _________________
Psychic Symphony
////
// //
// //
//// |
|
| Back to top |
|
 |
atom0s Moderator
Reputation: 205
Joined: 25 Jan 2006 Posts: 8587 Location: 127.0.0.1
|
Posted: Tue May 17, 2011 6:14 pm Post subject: |
|
|
If you are asking basics like this, you need to do more research and work before you should even be touching DLLs. You are basically asking for the entire thing to be coded for you. _________________
- Retired. |
|
| Back to top |
|
 |
PsychicSymphony Newbie cheater
Reputation: 0
Joined: 17 May 2011 Posts: 13 Location: Ontario
|
Posted: Tue May 17, 2011 7:27 pm Post subject: |
|
|
Ok I researched and I found out how to make a dll
my dll consists of
the dllmain method and all the
dllprocessattached cases and stuff
I added a while loop in the dllprocessattached case but the while loop doesnt work should I put it in another one or what? _________________
Psychic Symphony
////
// //
// //
//// |
|
| Back to top |
|
 |
Innovation Grandmaster Cheater
Reputation: 12
Joined: 14 Aug 2008 Posts: 617
|
Posted: Wed May 18, 2011 6:31 am Post subject: |
|
|
| PsychicSymphony wrote: | | I added a while loop in the dllprocessattached case but the while loop doesnt work should I put it in another one or what? |
DllMain should return as soon as possible since it holds the OS loader lock. Create a new thread using CreateThread.
| Code: | #include <windows.h>
DWORD WINAPI MainThread(LPVOID lpThreadParameter)
{
// ...
}
BOOL APIENTRY DllMain(__in HMODULE hModule, __in DWORD dwReason, __in LPVOID lpReserved)
{
if(dwReason == DLL_PROCESS_ATTACH)
{
DisableThreadLibraryCalls(hModule);
if(CreateThread(NULL, 0, MainThread, NULL, 0, NULL) == NULL)
{
return FALSE;
}
}
else if(dwReason == DLL_PROCESS_DETACH)
{
// ...
}
return TRUE;
} |
|
|
| Back to top |
|
 |
Slugsnack Grandmaster Cheater Supreme
Reputation: 71
Joined: 24 Jan 2007 Posts: 1857
|
|
| Back to top |
|
 |
b6oy Newbie cheater
Reputation: 0
Joined: 21 Sep 2009 Posts: 10
|
Posted: Wed May 18, 2011 1:12 pm Post subject: |
|
|
| Slugsnack wrote: | MSDN says you should actually not create a thread from within dllmain. What I do is inject a dll which exports an init function then call createremotethread from the injector
|
thanks, this method helped me bypassing a game protection. |
|
| Back to top |
|
 |
Innovation Grandmaster Cheater
Reputation: 12
Joined: 14 Aug 2008 Posts: 617
|
Posted: Wed May 18, 2011 2:03 pm Post subject: |
|
|
| MSDN wrote: | You should never perform the following tasks from within DllMain:
...
• Call CreateThread. Creating a thread can work if you do not synchronize with other threads, but it is risky. |
What can be done in DllMain generally lies in the gray area. While not recommended by MSDN, it's still a working method under certain restrictions. |
|
| Back to top |
|
 |
atom0s Moderator
Reputation: 205
Joined: 25 Jan 2006 Posts: 8587 Location: 127.0.0.1
|
Posted: Wed May 18, 2011 3:45 pm Post subject: |
|
|
| Innovation wrote: |
| MSDN wrote: | You should never perform the following tasks from within DllMain:
...
• Call CreateThread. Creating a thread can work if you do not synchronize with other threads, but it is risky. |
What can be done in DllMain generally lies in the gray area. While not recommended by MSDN, it's still a working method under certain restrictions. |
I wouldn't consider it a gray area when the developers of the operating system are telling you not to do it. They're pretty clear in the document that you should not do the given list of things inside of DllMain. The article is fairly old so if things have changed, Microsoft would have updated the article to go along with the changes. Given that it hasn't, it's safe to assume the article is still followed in standards for DllMain handling on Windows. _________________
- Retired. |
|
| Back to top |
|
 |
Slugsnack Grandmaster Cheater Supreme
Reputation: 71
Joined: 24 Jan 2007 Posts: 1857
|
Posted: Wed May 18, 2011 4:26 pm Post subject: |
|
|
| i just would avoid it given that there is a perfectly viable alternative which i stated above |
|
| Back to top |
|
 |
Innovation Grandmaster Cheater
Reputation: 12
Joined: 14 Aug 2008 Posts: 617
|
Posted: Wed May 18, 2011 6:03 pm Post subject: |
|
|
| Slugsnack wrote: | | i just would avoid it given that there is a perfectly viable alternative which i stated above |
The only problem would be if the DLL injector doesn't support thread creation at an arbitrary export, which is the case for most DLL injectors I have seen that are in wide use. Of course, there are exceptions (as with Cheat Engine). |
|
| Back to top |
|
 |
PsychicSymphony Newbie cheater
Reputation: 0
Joined: 17 May 2011 Posts: 13 Location: Ontario
|
Posted: Wed May 18, 2011 6:39 pm Post subject: |
|
|
Ok lol sorry for not listening to anyone about the threads I just made my own, this is my code
[CODE]
#include "main.h"
HANDLE thread;
int Thread() {
while (1) {
ofstream file;
file.open("test.txt");
file << "worked";
file.close();
Sleep(1);
}
return 0;
}
BOOL APIENTRY DllMain(__in HMODULE hModule, __in DWORD dwReason, __in LPVOID lpReserve) {
if(dwReason == DLL_PROCESS_ATTACH) {
DisableThreadLibraryCalls(hModule);
thread = CreateThread(0, 0, (LPTHREAD_START_ROUTINE)Thread, NULL, 0, NULL);
}
return true;
}
[/CODE]
The code works it does write to test.txt so im really happy thanks
I am trying to now make a menu. This is a question about hooks like keyboard hooks and mouse hooks.
Keyboard and mouse hooks intercepts the input coming from the window and reads them then stops them or sends them back to the window.
Example:
press 1 key->| window gets input
V ^
My program intercepts and reads|
what if the window doesnt use keyboard input like Diablo 2 the game im trying to make a menu for. Diablo 2 uses no keyboard input so would a keyboard hook not work? _________________
Psychic Symphony
////
// //
// //
//// |
|
| Back to top |
|
 |
atom0s Moderator
Reputation: 205
Joined: 25 Jan 2006 Posts: 8587 Location: 127.0.0.1
|
Posted: Thu May 19, 2011 9:08 am Post subject: |
|
|
| Innovation wrote: | | Slugsnack wrote: | | i just would avoid it given that there is a perfectly viable alternative which i stated above |
The only problem would be if the DLL injector doesn't support thread creation at an arbitrary export, which is the case for most DLL injectors I have seen that are in wide use. Of course, there are exceptions (as with Cheat Engine). |
If the personal is capable of coding the DLL to be injected, they should be able to create the injector as well. Calling remote exports isn't hard to do. _________________
- Retired. |
|
| Back to top |
|
 |
Innovation Grandmaster Cheater
Reputation: 12
Joined: 14 Aug 2008 Posts: 617
|
Posted: Thu May 19, 2011 10:35 am Post subject: |
|
|
| Wiccaan wrote: | | Innovation wrote: | | Slugsnack wrote: | | i just would avoid it given that there is a perfectly viable alternative which i stated above |
The only problem would be if the DLL injector doesn't support thread creation at an arbitrary export, which is the case for most DLL injectors I have seen that are in wide use. Of course, there are exceptions (as with Cheat Engine). |
If the personal is capable of coding the DLL to be injected, they should be able to create the injector as well. Calling remote exports isn't hard to do. |
I never claimed it was hard. What I meant is that many DLL injectors anticipate that no other call is needed other than to DllMain for the proper functionality because CreateThread works. |
|
| Back to top |
|
 |
atom0s Moderator
Reputation: 205
Joined: 25 Jan 2006 Posts: 8587 Location: 127.0.0.1
|
Posted: Thu May 19, 2011 1:16 pm Post subject: |
|
|
Which would be the point of them making their own injector vs. using a premade one. _________________
- Retired. |
|
| Back to top |
|
 |
|