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 problem

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General Gamehacking
View previous topic :: View next topic  
Author Message
aeree
Cheater
Reputation: 3

Joined: 23 Jan 2010
Posts: 42
Location: Germany

PostPosted: Mon Oct 07, 2013 9:31 am    Post subject: DLL injection problem Reply with quote

When I try to inject my code into a game nothing happens. I doesn't crash and I doesn't seem to run any of my code. What am I doing wrong?

Code:

#include <windows.h>


DWORD WINAPI Thread(LPVOID unused)
{
    int *foo;
    foo = (int *)0x30100;

    MessageBoxA(0,"Something happened","yay",0);

    while(true)
    {
        if(GetAsyncKeyState('X'))
        {
            foo+= 2;

            Sleep(250);
        }
        Sleep(10);
    }
}

void poo()
{
    MessageBoxA(0,"Didn't work too well","nope",0);
}

BOOL WINAPI DllMain(HINSTANCE mod, DWORD DWORD_GRUND, LPVOID res)
{
    switch(DWORD_GRUND)
    {
    case DLL_PROCESS_ATTACH:
        CreateThread(0, 0, &Thread , 0, 0, 0);
        break;
     case DLL_PROCESS_DETACH:
        poo();
        break;
    }
    return true;
}

_________________
1 + 1 =
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 470

Joined: 09 May 2003
Posts: 25807
Location: The netherlands

PostPosted: Mon Oct 07, 2013 9:55 am    Post subject: Reply with quote

you need to give the address of Thread, not the address to the address of thread

so try:
Code:

CreateThread(0, 0, Thread , 0, 0, 0);

_________________
Do not ask me about online cheats. I don't know any and wont help finding them.

Like my help? Join me on Patreon so i can keep helping
Back to top
View user's profile Send private message MSN Messenger
aeree
Cheater
Reputation: 3

Joined: 23 Jan 2010
Posts: 42
Location: Germany

PostPosted: Mon Oct 07, 2013 9:58 am    Post subject: Reply with quote

Dark Byte wrote:
you need to give the address of Thread, not the address to the address of thread

so try:
Code:

CreateThread(0, 0, Thread , 0, 0, 0);


Did that. Still no luck Sad

_________________
1 + 1 =
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 470

Joined: 09 May 2003
Posts: 25807
Location: The netherlands

PostPosted: Mon Oct 07, 2013 10:01 am    Post subject: This post has 1 review(s) Reply with quote

is the source filename .C or .CPP?
If .CPP I recommend changing it to .C or mess around with headers that tell not to obfuscate symbol names

_________________
Do not ask me about online cheats. I don't know any and wont help finding them.

Like my help? Join me on Patreon so i can keep helping
Back to top
View user's profile Send private message MSN Messenger
aeree
Cheater
Reputation: 3

Joined: 23 Jan 2010
Posts: 42
Location: Germany

PostPosted: Mon Oct 07, 2013 10:14 am    Post subject: Reply with quote

Dark Byte wrote:
is the source filename .C or .CPP?
If .CPP I recommend changing it to .C or mess around with headers that tell not to obfuscate symbol names


Ok I did that and now I'm getting an error saying:
undefined reference to 'WinMain@16'

But this only happened when I compile it in Codeblocks.
I then compiled it in Dev-C++ and now everything works fine.


Why is that?

Edit: Also thank you so much. I've been trying this for so long and never got it working until now Smile

_________________
1 + 1 =
Back to top
View user's profile Send private message
atom0s
Moderator
Reputation: 205

Joined: 25 Jan 2006
Posts: 8587
Location: 127.0.0.1

PostPosted: Mon Oct 07, 2013 10:56 am    Post subject: Reply with quote

fishbone105 wrote:
Dark Byte wrote:
is the source filename .C or .CPP?
If .CPP I recommend changing it to .C or mess around with headers that tell not to obfuscate symbol names


Ok I did that and now I'm getting an error saying:
undefined reference to 'WinMain@16'

But this only happened when I compile it in Codeblocks.
I then compiled it in Dev-C++ and now everything works fine.


Why is that?

Edit: Also thank you so much. I've been trying this for so long and never got it working until now Smile


You didn't select the proper type of project then. WinMain is the entrypoint for a standard Windows application.

_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General Gamehacking 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