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 


Memory protection

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

Joined: 13 Mar 2007
Posts: 894
Location: Canada

PostPosted: Fri Jul 20, 2007 4:42 pm    Post subject: Memory protection Reply with quote

Hey guys, I saw this code in a book before and they said that if I wanted to write to OS data structures I had to un-protect the memory and they gave me a code sample:
Code:
// UN-protect memory
      __asm
      {
            push eax
            mov  eax, CR0
            and  eax, 0FFFEFFFFh
            mov  CR0, eax
            pop  eax
       }

      // do something

      // RE-protect memory
      __asm
      {
            push eax
            mov  eax, CR0
            or   eax, NOT 0FFFEFFFFh
            mov  CR0, eax
            pop  eax

      }


So I was using this code, but today, I was reading this article, and they used this:
Code:

ULONG CR0Reg;

__asm
{
    cli
    mov eax, cr0
    mov CR0Reg,eax
    and eax,0xFFFEFFFF
    mov cr0, eax
}

//Do stuff

__asm
{
mov eax, CR0Reg
mov cr0, eax
sti


They look almost the same, except the fact that the second one used cli/sti to disable/enable interrupt processing.

So yeah, I tried both methods in my code, and I didn't see any difference. Which one should I use? Are those codes the same Shocked ?

_________________
Back to top
View user's profile Send private message
appalsap
Moderator
Reputation: 0

Joined: 27 Apr 2006
Posts: 6753
Location: Pakistan

PostPosted: Fri Jul 20, 2007 4:53 pm    Post subject: Reply with quote

you shouldn't use that method at all, it's global and dangerous.
Back to top
View user's profile Send private message
UnLmtD
Grandmaster Cheater
Reputation: 0

Joined: 13 Mar 2007
Posts: 894
Location: Canada

PostPosted: Fri Jul 20, 2007 4:55 pm    Post subject: Reply with quote

So that leaves me with the MDL method right?
_________________
Back to top
View user's profile Send private message
appalsap
Moderator
Reputation: 0

Joined: 27 Apr 2006
Posts: 6753
Location: Pakistan

PostPosted: Fri Jul 20, 2007 4:59 pm    Post subject: Reply with quote

Yes
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: Fri Jul 20, 2007 5:55 pm    Post subject: Reply with quote

appalsap wrote:
you shouldn't use that method at all, it's global and dangerous.


CE Uses this =\. Its quick and easy.
Back to top
View user's profile Send private message MSN Messenger
Trow
Grandmaster Cheater
Reputation: 2

Joined: 17 Aug 2006
Posts: 957

PostPosted: Mon Jul 23, 2007 6:31 pm    Post subject: Reply with quote

noz3001 wrote:
appalsap wrote:
you shouldn't use that method at all, it's global and dangerous.


CE Uses this =\. Its quick and easy.


and thats why my C drive is gone one day (partition label) and i had to ghost it back.

_________________
Get kidnapped often.
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 471

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

PostPosted: Mon Jul 23, 2007 6:38 pm    Post subject: Reply with quote

gameguard uses it as well, and it was probably gameguard that whiped your c-drive on purpose
_________________
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
Trow
Grandmaster Cheater
Reputation: 2

Joined: 17 Aug 2006
Posts: 957

PostPosted: Mon Jul 23, 2007 6:41 pm    Post subject: Reply with quote

or maybe some guy just leaves a line of code out for the UCE I used
_________________
Get kidnapped often.
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