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 


[Help] C++ DLL
Goto page 1, 2  Next
 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
Ziztey
Grandmaster Cheater
Reputation: 0

Joined: 20 Dec 2007
Posts: 535
Location: 127.0.0.1

PostPosted: Thu Oct 30, 2008 1:14 pm    Post subject: [Help] C++ DLL Reply with quote

Okay, so I followed a TUT and I get errors.

This is my code:


Code:

#include <windows.h>
// include header
bool WINAPI DllMain(HMODULE hInst, DWORD reason, LPVOID reserved)
{
   return TRUE;
}
 switch (reason)
    {
      case DLL_PROCESS_ATTACH:
      DisableThreadLibraryCalls( hInst );
      MessageBoxA (NULL, "Success!", "", MB_OK);
      Func();
      break;

      case DLL_PROCESS_DETACH:
        break;

      /*case DLL_THREAD_ATTACH:
        break;

      case DLL_THREAD_DETACH:
        break;*/
   }

 DisableThreadLibraryCalls( hInst );


MainLoop(int pause)
{
while(enabled_var == true)
{
//Code
Sleep(pause); // Less CPU intensive
}
}
// STUFF, DLLMAIN, ETC
case DLL_PROCESS_ATTACH:
MainLoop(10);
break;

DWORD address; //Create a DWORD variable
address = 0x46f08c; //Put the address into the variable
*(DWORD*)address = 0x9090 //Change the 2 bytes (DWORD)

if (GetAsyncKeyState(0x9090))
{
//Checks if key 0x71 (F1) is down
//If's go here, elses go there, etc
}


Errors:

Code:

(7) : error C2059: syntax error : 'switch'
(8) : error C2143: syntax error : missing ';' before '{'
(8) : error C2447: '{' : missing function header (old-style formal list?)
(25) : error C2065: 'hInst' : undeclared identifier
(25) : error C2065: 'hInst' : undeclared identifier

(25) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int

(25) : error C2365: 'DisableThreadLibraryCalls' : redefinition; previous definition was 'function'
        d:\program\microsoft sdks\windows\v6.0a\include\winbase.h(2600) : see declaration of 'DisableThreadLibraryCalls'

(29) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int

(30) : error C2065: 'enabled_var' : undeclared identifier

(30) : warning C4805: '==' : unsafe mix of type ''unknown-type'' and type 'bool' in operation

(30) : fatal error C1903: unable to recover from previous error(s); stopping compilation
[/code]
_________________
kenta7795 wrote:
Lol, how do I know its fake?

The source is a .cpp, and a .h

Private server much?
Back to top
View user's profile Send private message
lurc
Grandmaster Cheater Supreme
Reputation: 2

Joined: 13 Nov 2006
Posts: 1900

PostPosted: Thu Oct 30, 2008 1:23 pm    Post subject: Reply with quote

Ok so I suggest you get a new tut cause that's fucking retarded...
I also suggest you LEARN SIMPLE C++ AND SYNTAX BEFORE ATTEMPTING API. Rolling Eyes
Cause you obviously have no damn clue what your doing.

Proper DLL Code & Looping for Hotkeys:
Code:
#include <Windows.h>

VOID MainLoop()
{
   for (;;Sleep(10))
   {
        if (GetAsyncKeyState(VK_F1))
        {
              // Place code here.
        }
   }
}

BOOL WINAPI DllMain(HMODULE hModule, DWORD dwReason, LPVOID lpReserved)
{
    if (dwReason == DLL_PROCESS_ATTACH)
         CreateThread(0, 0, (LPTHREAD_START_ROUTINE)MainLoop, 0, 0, 0);
    return TRUE;
}

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

Joined: 20 Dec 2007
Posts: 535
Location: 127.0.0.1

PostPosted: Thu Oct 30, 2008 1:43 pm    Post subject: Reply with quote

Hah, thanks.

Nah, I'm not that "into" it yet, but I'm just trying to make a simple DLL with a few hacks, thanks Smile

BTW:

Since I'm very young, (12) from Sweden it's very hard for me to explain this part:

Let me try.

If I want to get this into my DLL, how do I do it?

jbe 006b3dc0
and jae, and all that parts that is required.
Sorry for my bad explaning, but hopefully you can help me.

_________________
kenta7795 wrote:
Lol, how do I know its fake?

The source is a .cpp, and a .h

Private server much?
Back to top
View user's profile Send private message
HomerSexual
Grandmaster Cheater Supreme
Reputation: 5

Joined: 03 Feb 2007
Posts: 1657

PostPosted: Thu Oct 30, 2008 2:15 pm    Post subject: Reply with quote

Ziztey wrote:
Hah, thanks.

Nah, I'm not that "into" it yet, but I'm just trying to make a simple DLL with a few hacks, thanks Smile

BTW:

Since I'm very young, (12) from Sweden it's very hard for me to explain this part:

Let me try.

If I want to get this into my DLL, how do I do it?

jbe 006b3dc0
and jae, and all that parts that is required.
Sorry for my bad explaning, but hopefully you can help me.


I agree with lurc here. Don't use your age as an excuse. You can't just take code (ugly and not working) and expect to make a hack .dll.

You have to learn the basics first.

_________________
Back to top
View user's profile Send private message
Innovation
Grandmaster Cheater
Reputation: 12

Joined: 14 Aug 2008
Posts: 617

PostPosted: Thu Oct 30, 2008 3:57 pm    Post subject: Reply with quote

Note: This is for your first post in this thread.
Your DLL's coding should turn out something like this:

Code:
#include <windows.h>

VOID MainLoop()
{
   while (GetAsyncKeyState(VK_F2) == false)
   {
      if (GetAsyncKeyState(VK_F1))
      {
         *(WORD*)0x0046F08C = 0x9090;
      }
      Sleep(10);
   }
}

BOOL WINAPI DllMain(HMODULE hModule, DWORD dwReason, LPVOID lpReserved)
{
    if (dwReason == DLL_PROCESS_ATTACH)
         CreateThread(0, 0, (LPTHREAD_START_ROUTINE)MainLoop, 0, 0, 0);
    return TRUE;
}

/*
Note: In the code above F1 edits the bytes and F2 exits the loop.

If you want a continous loop:

#include <windows.h>

VOID MainLoop()
{
   for (;;Sleep(10))
   {
      if (GetAsyncKeyState(VK_F1))
      {
         *(WORD*)0x0046F08C = 0x9090;
      }
   }
}

BOOL WINAPI DllMain(HMODULE hModule, DWORD dwReason, LPVOID lpReserved)
{
    if (dwReason == DLL_PROCESS_ATTACH)
         CreateThread(0, 0, (LPTHREAD_START_ROUTINE)MainLoop, 0, 0, 0);
    return TRUE;
}
*/


Last edited by Innovation on Thu Oct 30, 2008 4:49 pm; edited 1 time in total
Back to top
View user's profile Send private message
Ziztey
Grandmaster Cheater
Reputation: 0

Joined: 20 Dec 2007
Posts: 535
Location: 127.0.0.1

PostPosted: Thu Oct 30, 2008 4:18 pm    Post subject: Reply with quote

Thanks!
And how do I add more hacks?

_________________
kenta7795 wrote:
Lol, how do I know its fake?

The source is a .cpp, and a .h

Private server much?
Back to top
View user's profile Send private message
Hieroglyphics
I post too much
Reputation: 0

Joined: 06 Dec 2007
Posts: 2007
Location: Your bedroom

PostPosted: Thu Oct 30, 2008 4:47 pm    Post subject: Reply with quote

Code:
 *(WORD*)0x46F08C = 0x9090;

That is the part that activates the hack. Just find the bytes of the opcode you want to write in CE then flip it and input

BYTE = 1byte
WORD = 2 bytes
DWORD = 4 byte
For more you do DWORD then do like +4 to the addy then another

_________________

Back to top
View user's profile Send private message AIM Address MSN Messenger
Innovation
Grandmaster Cheater
Reputation: 12

Joined: 14 Aug 2008
Posts: 617

PostPosted: Thu Oct 30, 2008 4:55 pm    Post subject: Reply with quote

Ziztey wrote:
Thanks!
And how do I add more hacks?


Below:
Code:
if (GetAsyncKeyState(VK_F1))
{
   *(WORD*)0x0046F08C = 0x9090;
}


Add:
Code:
if (GetAsyncKeyState(VK_[INSERT SOMETHING F1 - F12 HERE])
{
   *([INSERT BYTE,WORD, or DWORD HERE]*)0x[INSERT ADDRESS HERE] = 0x[INSERT THE BYTES TO WRITE]; 
}

Replace [INSERT SOMETHING F1 - F12 HERE] with the F + Number key you want to activate the code (the hotkey).
Replace [INSERT BYTE, WORD, or DWORD HERE] with Byte if you are only writing 1 byte, WORD if you are writing 2 bytes and DWORD if you are writing 4 bytes.
Replace [INSERT ADDRESS HERE] with the address you want to edit the bytes of.
Replace [INSERT THE BYTES TO WRITE] the bytes you want to write to the address.

Edit: If the bytes go over 4

Below:
Code:
*([INSERT BYTE,WORD, or DWORD HERE]*)0x[INSERT ADDRESS HERE] = 0x[INSERT THE BYTES TO WRITE];


Copy and past the same line below and add 5 to the address you are writing to and continue the bytes.

Make sure you do not go over 4 bytes in one writing "session."
Back to top
View user's profile Send private message
kitterz
Grandmaster Cheater Supreme
Reputation: 0

Joined: 24 Dec 2007
Posts: 1268

PostPosted: Thu Oct 30, 2008 5:32 pm    Post subject: Reply with quote

Hieroglyphics wrote:
Code:
 *(WORD*)0x46F08C = 0x9090;

That is the part that activates the hack. Just find the bytes of the opcode you want to write in CE then flip it and input

BYTE = 1byte
WORD = 2 bytes
DWORD = 4 byte
For more you do DWORD then do like +4 to the addy then another


you forgot QWORD O.O

_________________
Back to top
View user's profile Send private message Send e-mail
Innovation
Grandmaster Cheater
Reputation: 12

Joined: 14 Aug 2008
Posts: 617

PostPosted: Thu Oct 30, 2008 5:43 pm    Post subject: Reply with quote

I feel like I need to make a table >.>

Code:
-----------------
Name - Bytes
-----------------
BYTE - 1
WORD - 2
DWORD - 4
QDWORD - 8
OWORD(Microsoft Macro Assembler)/DQWORD(Intel) - 16
-----------------


There maybe be more but this is all that I know of them...

Also you can use this as a reference:
http://en.wikipedia.org/wiki/Word_(computer_science)
Back to top
View user's profile Send private message
Hieroglyphics
I post too much
Reputation: 0

Joined: 06 Dec 2007
Posts: 2007
Location: Your bedroom

PostPosted: Thu Oct 30, 2008 10:50 pm    Post subject: Reply with quote

kitterz wrote:
Hieroglyphics wrote:
Code:
 *(WORD*)0x46F08C = 0x9090;

That is the part that activates the hack. Just find the bytes of the opcode you want to write in CE then flip it and input

BYTE = 1byte
WORD = 2 bytes
DWORD = 4 byte
For more you do DWORD then do like +4 to the addy then another


you forgot QWORD O.O


Nobody uses QWORD o.O.

_________________

Back to top
View user's profile Send private message AIM Address MSN Messenger
hcavolsdsadgadsg
I'm a spammer
Reputation: 26

Joined: 11 Jun 2007
Posts: 5801

PostPosted: Thu Oct 30, 2008 11:47 pm    Post subject: Reply with quote

You know, except MMX, SSE, etc...

Your compiler will very happily use it.
Back to top
View user's profile Send private message
Henley
Grandmaster Cheater
Reputation: 0

Joined: 03 Oct 2006
Posts: 671

PostPosted: Fri Oct 31, 2008 12:49 am    Post subject: Reply with quote

Ziztey wrote:
Hah, thanks.

Nah, I'm not that "into" it yet, but I'm just trying to make a simple DLL with a few hacks, thanks Smile

BTW:

Since I'm very young, (12) from Sweden it's very hard for me to explain this part:

Let me try.

If I want to get this into my DLL, how do I do it?

jbe 006b3dc0
and jae, and all that parts that is required.
Sorry for my bad explaning, but hopefully you can help me.


you find out what the bytes are (written backwards) when you enable the hack and
Code:
*(blabla*)addy=0x"byteshere"
Back to top
View user's profile Send private message
Ziztey
Grandmaster Cheater
Reputation: 0

Joined: 20 Dec 2007
Posts: 535
Location: 127.0.0.1

PostPosted: Fri Oct 31, 2008 2:48 am    Post subject: Reply with quote

Ah, thanks! Very Happy

And if i want to write for example "db 84" for one address, how can I do it?

Sorry for all questions, but I'm intressted Razz

Edit:
I was trying to add more hacks, but I got one error.

This is my code:

Code:

#include <windows.h>

VOID MainLoop()
{
   while (GetAsyncKeyState(VK_F2) == false)
   {
      if (GetAsyncKeyState(VK_F1))
      {
         *(WORD*)0x46F08C = 0x9090;
      }
      Sleep(10);
   }
}

BOOL WINAPI DllMain(HMODULE hModule, DWORD dwReason, LPVOID lpReserved)
{
    if (dwReason == DLL_PROCESS_ATTACH)
         CreateThread(0, 0, (LPTHREAD_START_ROUTINE)MainLoop, 0, 0, 0);
    return TRUE;
}

if (GetAsyncKeyState(VK_F3])

   *(DWORD*)0x46F08C = 0x90;

/*
Note: In the code above F1 edits the bytes and F2 exits the loop.

If you want a continous loop:

#include <windows.h>

VOID MainLoop()
{
   for (;;Sleep(10))
   {
      if (GetAsyncKeyState(VK_F1))
      {
         *(WORD*)0x0046F08C = 0x9090;
      }
   }
}

BOOL WINAPI DllMain(HMODULE hModule, DWORD dwReason, LPVOID lpReserved)
{
    if (dwReason == DLL_PROCESS_ATTACH)
         CreateThread(0, 0, (LPTHREAD_START_ROUTINE)MainLoop, 0, 0, 0);
    return TRUE;
}
*/


Error:

Code:

error C2059: syntax error : 'if'

_________________
kenta7795 wrote:
Lol, how do I know its fake?

The source is a .cpp, and a .h

Private server much?
Back to top
View user's profile Send private message
Slugsnack
Grandmaster Cheater Supreme
Reputation: 71

Joined: 24 Jan 2007
Posts: 1857

PostPosted: Fri Oct 31, 2008 4:15 am    Post subject: Reply with quote

Hieroglyphics wrote:
kitterz wrote:
Hieroglyphics wrote:
Code:
 *(WORD*)0x46F08C = 0x9090;

That is the part that activates the hack. Just find the bytes of the opcode you want to write in CE then flip it and input

BYTE = 1byte
WORD = 2 bytes
DWORD = 4 byte
For more you do DWORD then do like +4 to the addy then another


you forgot QWORD O.O


Nobody uses QWORD o.O.

i do. it wouldn't be there if nobody used it..
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
Goto page 1, 2  Next
Page 1 of 2

 
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