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 


[VC++]Asm script, take a look

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

Joined: 09 Jul 2006
Posts: 762
Location: Poland.

PostPosted: Fri Dec 19, 2008 8:44 am    Post subject: [VC++]Asm script, take a look Reply with quote

I put asm script in C++ dll but it crash ms in game , take a look.

Script:
Code:
[enable]
alloc(newmem,2048)
alloc(blaaaa,3670018)
label(originalcode)
loadbinary(blaaaa,Wiw3K.CEM)

newmem:
cmp ecx,00400000
jb originalcode

cmp ecx,00780000
ja originalcode

mov eax,blaaaa
sub eax,00400000
add ecx, eax

originalcode:
mov eax,[ebp+10]
push esi
push edi
jmp 4664E4

004664DF:
jmp newmem

[disable]
004664DF:
mov eax,[ebp+10]
push esi
push edi
dealloc(newmem)
dealloc(blaaaa)


In My dll:

Code:
__declspec(naked) void CRC_hook()
{
   __asm
   {
      pop [ReturnMe]
      cmp ecx, 0x00400000
      jb original
      cmp ecx, 0x00780000
      ja original
      sub ecx, 0x00400000
      add ecx, [CRC]

      original:
      mov eax,[ebp+0x10]
      push esi
      push edi

      push [ReturnMe]
      ret
   }
}


then

Code:
   CRC = VirtualAlloc(NULL, 0x00400000, MEM_COMMIT, PAGE_EXECUTE_READWRITE);
   memcpy((void *)MEMDUMP, (void *)0x00400000, 0x00400000);
   memcpy((void *)CRC, (void *)MEMDUMP, 0x00400000);

   CRCdelay:
   MSWIN = FindWindow(L"MapleStoryClass",NULL);
   if(MSWIN == 0)
   {
      Sleep(100);
      goto CRCdelay;
   }

      FixMem(GetCurrentProcess(), (void*)CRCADDY, 5, PAGE_EXECUTE_READWRITE, (DWORD*)oldprot);
   *(BYTE*)CRCADDY = 0xE8;
   *(DWORD*)(CRCADDY + 1) = JMP(CRCADDY, CRC_hook);


and everything defined. without errors, whats wrong? Confused
Back to top
View user's profile Send private message
Zerith
Master Cheater
Reputation: 1

Joined: 07 Oct 2007
Posts: 468

PostPosted: Fri Dec 19, 2008 9:10 am    Post subject: Reply with quote

It always jmps to Original, since you did not specify what to do if nothing jmps.

Probably causing stack corruption.
Back to top
View user's profile Send private message MSN Messenger
Symbol
I'm a spammer
Reputation: 0

Joined: 18 Apr 2007
Posts: 5094
Location: Israel.

PostPosted: Fri Dec 19, 2008 9:47 am    Post subject: Reply with quote

Probably because of:
Code:
      pop [ReturnMe]
      push [ReturnMe]

Not only that it's useless, the compiler probably ignores brackets since you didn't specify the size.
I suggest you using JMP instead. (0xE9 instead of 0xE8 and instead of pop/push/ret use JMP CRCADDY+5)
Back to top
View user's profile Send private message
sponge
I'm a spammer
Reputation: 1

Joined: 07 Nov 2006
Posts: 6009

PostPosted: Fri Dec 19, 2008 5:14 pm    Post subject: Reply with quote

Symbol wrote:
Probably because of:
Code:
      pop [ReturnMe]
      push [ReturnMe]

Not only that it's useless, the compiler probably ignores brackets since you didn't specify the size.
I suggest you using JMP instead. (0xE9 instead of 0xE8 and instead of pop/push/ret use JMP CRCADDY+5)
Not quite. It is incredibly useful if you are actually hooking a call function. (The head of the call.) No one pushes 16 bit values onto the stack anymore. If there is no size, it should be assumed to be a DWORD.
_________________
Back to top
View user's profile Send private message
nog_lorp
Grandmaster Cheater
Reputation: 0

Joined: 26 Feb 2006
Posts: 743

PostPosted: Fri Dec 19, 2008 5:30 pm    Post subject: Reply with quote

Yep, if the assembler is doing its job, should default to whatever the BITS setting indicated (for 32 bit, 32 bit...)
_________________
Mutilated lips give a kiss on the wrist of the worm-like tips of tentacles expanding in my mind
I'm fine accepting only fresh brine you can get another drop of this yeah you wish
Back to top
View user's profile Send private message
GMZorita
Grandmaster Cheater Supreme
Reputation: 0

Joined: 21 Mar 2007
Posts: 1361

PostPosted: Fri Dec 19, 2008 8:15 pm    Post subject: Reply with quote

replace
Code:
memcpy((void *)MEMDUMP, (void *)0x00400000, 0x00400000);
   memcpy((void *)CRC, (void *)MEMDUMP, 0x00400000);

with
Code:

   memcpy((void *)CRC, (void *)0x400000, 0x00400000);

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

Joined: 08 Aug 2006
Posts: 929

PostPosted: Sat Dec 20, 2008 12:20 am    Post subject: Reply with quote

In the asm script i see a jmp. Your using E8 which is a call, try changing it to E9
Back to top
View user's profile Send private message AIM Address MSN Messenger
sponge
I'm a spammer
Reputation: 1

Joined: 07 Nov 2006
Posts: 6009

PostPosted: Sat Dec 20, 2008 1:48 am    Post subject: Reply with quote

slippppppppp wrote:
In the asm script i see a jmp. Your using E8 which is a call, try changing it to E9
That has nothing to do with it.
_________________
Back to top
View user's profile Send private message
Trucido
Moderator
Reputation: 6

Joined: 08 Sep 2007
Posts: 2792

PostPosted: Sat Dec 20, 2008 2:16 am    Post subject: Reply with quote

Code:
LPVOID CopyModule(__in HMODULE hModule)
{
  MODULEINFO  ModuleInfo;
  LPVOID      lpBuffer = NULL
 
  if (GetModuleInformation(GetCurrentProcess(), hModule, &ModuleInfo, sizeof(MODULEINFO)))
  {
    lpBuffer = VirtualAlloc(NULL, ModuleInfo.SizeOfImage, MEM_COMMIT, PAGE_EXECUTE_READWRITE);
    if (lpBuffer != NULL)
    {
      if (memcpy_s(lpBuffer, ModuleInfo.SizeOfImage, ModuleInfo.lpBaseOfDll, ModuleInfo.SizeOfImage) == 0)
        return lpBuffer;
      else
        VirtualFree(lpBuffer, ModuleInfo.SizeOfImage, MEM_DECOMMIT);
    }
  }
  return NULL;
}
 
 
BOOL InitializeCRC_Bypass(void)
{
  while (FindWindow(TEXT("MapleStoryClass"), NULL) == NULL) Sleep(100);
  lpCRC = CopyModule(GetModuleHandle(TEXT("MapleStory.exe"));
  return (lpCRC != NULL) ? HookFunction(X86_CALL, CRC_Function, &CRC_Hook) : FALSE;
}

_________________
I'm out.
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