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 with my first CE asm to C++

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
Fuzzgillian
How do I cheat?
Reputation: 0

Joined: 06 Nov 2012
Posts: 3
Location: Amurica

PostPosted: Tue Nov 06, 2012 5:43 pm    Post subject: Help with my first CE asm to C++ Reply with quote

This is my first attempt at converting a CE asm script to C++. When I run the script ingame I do not crash, however when I run my version of it in C++ I do crash. Here is the CE asm script -

Code:
[ENABLE]
alloc(IntersectRectHook,00000128)
label(returnhere_intersectrect)
label(ret_false)

IntersectRect:
jmp IntersectRectHook
returnhere_intersectrect:

IntersectRectHook:
cmp [esp],0074F806
je ret_false
mov edi,edi
push ebp
mov ebp,esp
jmp returnhere_intersectrect

ret_false:
mov eax,0
ret 0C

[DISABLE]
IntersectRect:
mov edi,edi
push ebp
mov ebp,esp

dealloc(IntersectRectHook)


Here is my conversion to C++ (After updating the script, phiscalgm addy changed)

This is how I activate it

Code:
void Form1::checkBox2PGM_CheckedChanged(System::Object^  sender, System::EventArgs^  e){
           if(checkBox2PGM->Checked){
            CreateThread(NULL, 0, (::LPTHREAD_START_ROUTINE)&PGMAinThread, NULL, 0, NULL);;
         }
         else
         {
            //asm disable
         }

}

I can't seem to find the problem, can you guys help me?[/code]

_________________
"There's not more hackers then players, there's just more hacker accusations."


Last edited by Fuzzgillian on Tue Nov 06, 2012 6:24 pm; edited 1 time in total
Back to top
View user's profile Send private message MSN Messenger
Dark Byte
Site Admin
Reputation: 470

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

PostPosted: Tue Nov 06, 2012 5:50 pm    Post subject: Reply with quote

Without setuphook you're forgetting to make IntersectRect writable.
(Use VirtualProtect for that)

With setuphook you're passing it the first 4 bytes of PhysicalGMAsm instead of the address

_________________
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
Fuzzgillian
How do I cheat?
Reputation: 0

Joined: 06 Nov 2012
Posts: 3
Location: Amurica

PostPosted: Tue Nov 06, 2012 6:07 pm    Post subject: Reply with quote

Dark Byte wrote:
Without setuphook you're forgetting to make IntersectRect writable.
(Use VirtualProtect for that)

With setuphook you're passing it the first 4 bytes of PhysicalGMAsm instead of the address


Thank you sir, this is what I did. Works perfectly.

Code:
/*DWORD WINAPI*/ void PGMAinThread()//(LPVOID)
{
   unsigned long oldProtect;
   VirtualProtect((LPVOID)ulIntersectRect, 128, PAGE_EXECUTE_READWRITE, &oldProtect);
   // SetupHook(ulIntersectRect,*(DWORD*)PhysicalGMAsm,5);
   //return 0;
   *(BYTE*)ulIntersectRect = 0xE9;
//now that we changed the 1st byte. we want to jump over it and write 4 more bytes.
// 4 bytes is a DWORD.
*(DWORD*)(ulIntersectRect + 1) = jmp(ulIntersectRect, PhysicalGMAsm);

}

_________________
"There's not more hackers then players, there's just more hacker accusations."
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
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