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 


[c++] Dll help
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
homer_simpson
Grandmaster Cheater
Reputation: 0

Joined: 25 Feb 2007
Posts: 596

PostPosted: Thu Jul 10, 2008 7:53 am    Post subject: [c++] Dll help Reply with quote

Im making a C++ dll for maplestory heres a chunk of the source:
Code:
void MainThread()
{
   Sleep(2500); //give time for maple to start
     BypassCRC();                                       
}

void BypassCRC()
{
   FixMemEx(GetCurrentProcess(), (void*)CRCaddy, 0x1000, PAGE_EXECUTE_READWRITE, (DWORD*)oldprot);
   CRC = VirtualAlloc(NULL, 0x00400000, MEM_COMMIT, PAGE_EXECUTE_READWRITE);
   memcpy((void *)MEMDUMP, (void *)0x00400000, 0x00400000);
   memcpy((void *)CRC, (void *)MEMDUMP, 0x00400000);

   CRCaddy =  0x0047cc9e;

   *(BYTE*)CRCaddy = 0xE8;
   *(DWORD*)((unsigned long)CRCaddy + 1) = JMP(CRCaddy, CRCCave);

   OutputDebugString("Bypassed CRC!");
        }


But my bulder keeps telling me this:
Code:
 [C++ Error] dll.cpp(54): E2268 Call to undefined funcion 'BypassCRC'


What am I doing wrong?
Back to top
View user's profile Send private message
atom0s
Moderator
Reputation: 205

Joined: 25 Jan 2006
Posts: 8588
Location: 127.0.0.1

PostPosted: Thu Jul 10, 2008 7:57 am    Post subject: Reply with quote

Either create a function prototype for BypassCRC at the top of the file, or put the BypassCRC function above the MainThread function.
_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
homer_simpson
Grandmaster Cheater
Reputation: 0

Joined: 25 Feb 2007
Posts: 596

PostPosted: Thu Jul 10, 2008 8:27 am    Post subject: Reply with quote

Thanks it worked but now it gives me this error:
Code:
[C++ Error] dll.cpp(36): E2448 Undefined label 'VPX'

And this is the code:
Code:
#include <windows.h>
#pragma hdrstop
#include "Unit2.h"
#pragma link "Unit2"
#pragma argsused
#define JMP(frm, to) (int)(((int)to - (int)frm) - 5);

HINSTANCE hMod;
LPVOID CRC;

DWORD oldp = 0;
PDWORD oldprot = &oldp;

BYTE MEMDUMP[0x400000];
DWORD Addy = 0x00400000, CRCaddy, ReturnMe;

static const FARPROC VPX = (FARPROC)((DWORD)GetProcAddress(GetModuleHandleA("kernel32.dll"), "VirtualProtectEx")+5);

WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
{
   Application->Initialize();
   Application->CreateForm(__classid(TForm2), &Form2);
   Application->Run();
        OutputDebugString("HomerTrainer activated ;)");
        return 0;
}

__declspec(naked) BOOL WINAPI FixMemEx(HANDLE hProcess, LPVOID lpAddress, SIZE_T dwSize, DWORD flNewProtect, PDWORD lpflOldProtect)
{
   _asm
   {
     mov edi,edi
     push ebp
     mov ebp,esp
     jmp VPX
   }
   return 0;
}

Guessing jmp VPX is the problem because VPX isn't properly defined?
Back to top
View user's profile Send private message
Zand
Master Cheater
Reputation: 0

Joined: 21 Jul 2006
Posts: 424

PostPosted: Thu Jul 10, 2008 8:30 am    Post subject: Reply with quote

get rid of all the FARPROC crap and declare it as a DWORD.
Back to top
View user's profile Send private message
homer_simpson
Grandmaster Cheater
Reputation: 0

Joined: 25 Feb 2007
Posts: 596

PostPosted: Thu Jul 10, 2008 8:36 am    Post subject: Reply with quote

You mean like this?
Code:
static const DWORD VPX = ((DWORD)GetProcAddress(GetModuleHandleA("kernel32.dll"), "VirtualProtectEx")+5);
Back to top
View user's profile Send private message
Zand
Master Cheater
Reputation: 0

Joined: 21 Jul 2006
Posts: 424

PostPosted: Thu Jul 10, 2008 8:41 am    Post subject: Reply with quote

That should probably work.
Back to top
View user's profile Send private message
homer_simpson
Grandmaster Cheater
Reputation: 0

Joined: 25 Feb 2007
Posts: 596

PostPosted: Thu Jul 10, 2008 8:56 am    Post subject: Reply with quote

Still the same error.
Back to top
View user's profile Send private message
oib111
I post too much
Reputation: 0

Joined: 02 Apr 2007
Posts: 2947
Location: you wanna know why?

PostPosted: Thu Jul 10, 2008 9:02 am    Post subject: Reply with quote

Just do this.

Code:

DWORD VPX = (DWORD)GetProcAddress(LoadLibrary("KERNEL32.DLL"), "VirtualProtectEx")+5;

__declspec(naked) BOOL WINAPI FixMemEx(HANDLE hProcess, LPVOID lpAddress, SIZE_T dwSize, DWORD flNewProtect, PDWORD lpflOldProtect)
{
   _asm
   {
     mov edi,edi
     push ebp
     mov ebp,esp
     jmp[VPX]
   }
}

_________________


8D wrote:

cigs dont make people high, which weed does, which causes them to do bad stuff. like killing
Back to top
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
homer_simpson
Grandmaster Cheater
Reputation: 0

Joined: 25 Feb 2007
Posts: 596

PostPosted: Thu Jul 10, 2008 9:08 am    Post subject: Reply with quote

Worked but now it gives me this:
Code:
[C++ Error] dll.cpp(36): E2448 Undefined label '['

And I had to add return 0;
Back to top
View user's profile Send private message
oib111
I post too much
Reputation: 0

Joined: 02 Apr 2007
Posts: 2947
Location: you wanna know why?

PostPosted: Thu Jul 10, 2008 9:15 am    Post subject: Reply with quote

Don't add return 0. And what compiler are you using? I'm assuming VC++ because you're using forms. Well if it doesn't recognize [ then just do "jmp VPX".
_________________


8D wrote:

cigs dont make people high, which weed does, which causes them to do bad stuff. like killing
Back to top
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
GMZorita
Grandmaster Cheater Supreme
Reputation: 0

Joined: 21 Mar 2007
Posts: 1361

PostPosted: Thu Jul 10, 2008 9:16 am    Post subject: Reply with quote

WOW How surprising, you are using my leaked code, just changed some vars so it doesn't looks exactly the same.
Instead of
Code:
jmp [VPX]

Just use
Code:
jmp VPX


oib111 wrote:
Don't add return 0. And what compiler are you using? I'm assuming VC++ because you're using forms. Well if it doesn't recognize [ then just do "jmp VPX".

No he is using Borland Developer Studio w/ my Leaked Trainer Source,
But he changed some vars so he get those problems.

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

Joined: 25 Feb 2007
Posts: 596

PostPosted: Thu Jul 10, 2008 9:22 am    Post subject: Reply with quote

GMZorita wrote:
WOW How surprising, you are using my leaked code, just changed some vars so it doesn't looks exactly the same.
Instead of
Code:
jmp [VPX]

Just use
Code:
jmp VPX


oib111 wrote:
Don't add return 0. And what compiler are you using? I'm assuming VC++ because you're using forms. Well if it doesn't recognize [ then just do "jmp VPX".

No he is using Borland Developer Studio w/ my Leaked Trainer Source,
But he changed some vars so he get those problems.


Well at least im learning... And that gave be back to the VPX label error.
Back to top
View user's profile Send private message
atom0s
Moderator
Reputation: 205

Joined: 25 Jan 2006
Posts: 8588
Location: 127.0.0.1

PostPosted: Thu Jul 10, 2008 12:09 pm    Post subject: Reply with quote

Be sure you are defining things ABOVE what is calling them. Or you will get undefined errors like the one you are getting.
_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
GMZorita
Grandmaster Cheater Supreme
Reputation: 0

Joined: 21 Mar 2007
Posts: 1361

PostPosted: Thu Jul 10, 2008 12:11 pm    Post subject: Reply with quote

homer_simpson wrote:
GMZorita wrote:
WOW How surprising, you are using my leaked code, just changed some vars so it doesn't looks exactly the same.
Instead of
Code:
jmp [VPX]

Just use
Code:
jmp VPX


oib111 wrote:
Don't add return 0. And what compiler are you using? I'm assuming VC++ because you're using forms. Well if it doesn't recognize [ then just do "jmp VPX".

No he is using Borland Developer Studio w/ my Leaked Trainer Source,
But he changed some vars so he get those problems.


Well at least im learning... And that gave be back to the VPX label error.

For god sake just use this code.

Code:

static const FARPROC VPX = (FARPROC)((DWORD)GetProcAddress(GetModuleHandleA("kernel32.dll"), "VirtualProtectEx")+5);
DWORD oldp2 = 0;
PDWORD oldprot2 = &oldp2;

_declspec(naked) BOOL WINAPI FixMemEx(HANDLE hProcess, LPVOID lpAddress, SIZE_T dwSize, DWORD flNewProtect, PDWORD lpflOldProtect)
{
   _asm
   {
     mov edi,edi
     push ebp
     mov ebp,esp
     jmp VPX
   }
   return 0;
}
//---------------------------------
void FixMem()
{
   FixMemEx(GetCurrentProcess(), (void*)0x400000, 0x400000, PAGE_EXECUTE_READWRITE, (DWORD*)oldprot2);
}

When you need to fix the memory just use
Code:
FixMem()


And no you are not learning you are mostly leeching.

_________________
Gone
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 Jul 10, 2008 12:38 pm    Post subject: Reply with quote

Why not make FixMemEx void?
Back to top
View user's profile Send private message MSN Messenger
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