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 


Mov Byte Ptr doesn't work properly

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

Joined: 07 Sep 2009
Posts: 5

PostPosted: Tue Sep 08, 2009 5:15 am    Post subject: Mov Byte Ptr doesn't work properly Reply with quote

I am using auto assembler but something is wrong on the below
Code:
MOV BYTE PTR DS:[EAX], 39
It works as a
Code:
MOV DWORD PTR DS:[EAX], 00000039

I traced source of CE and the problem seems to me in tokenize routine
Code:
tokenize(opcode,tokens);

given parameter is
Code:
opcode: 'MOV BYTE PTR DS:[EAX], 39'

and returned parameter is
Code:
tokens: ('MOV', '00000000[EAX]', '39')


Why it is parsing as dword value? Anybody have any idea?
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 470

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

PostPosted: Tue Sep 08, 2009 7:51 am    Post subject: Reply with quote

not sure why, i'll see if I can find it

for now, type the instruction as "mov byte ptr [eax],39" instead of "mov byte ptr ds:[eax],39"

_________________
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
Dark Byte
Site Admin
Reputation: 470

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

PostPosted: Tue Sep 08, 2009 8:16 am    Post subject: Reply with quote

not sure how your tokenizer returned a tokenlist of 00000000[EAX] (did you declare byte , ptr or DS as a registered symbol ? )


anyhow, it is fixed in the svn

in assemblerunit.pas at gettokentype replace
Code:

         if pos('[',token)>0 then result:=ttMemorylocation;
         if (pos('BYTE PTR [',token)>0) then result:=ttMemorylocation8;
         if (pos('WORD PTR [',token)>0) then result:=ttMemorylocation16;
         if (pos('DWORD PTR [',token)>0) then result:=ttMemorylocation32;
         if (pos('QWORD PTR [',token)>0) then result:=ttMemorylocation64;
         if (pos('TBYTE PTR [',token)>0) then result:=ttMemorylocation80;
         if (pos('TWORD PTR [',token)>0) then result:=ttMemorylocation80;
         if (pos('DQWORD PTR [',token)>0) then result:=ttMemorylocation128;


with
Code:

     if pos('[',token)>0 then
     begin         
       if (pos('BYTE ',token)>0) then result:=ttMemorylocation8 else
       if (pos('WORD ',token)>0) then result:=ttMemorylocation16 else
       if (pos('DWORD ',token)>0) then result:=ttMemorylocation32 else
       if (pos('QWORD ',token)>0) then result:=ttMemorylocation64 else
       if (pos('TBYTE ',token)>0) then result:=ttMemorylocation80 else
       if (pos('TWORD ',token)>0) then result:=ttMemorylocation80 else
       if (pos('DQWORD ',token)>0) then result:=ttMemorylocation128 else
         result:=ttMemorylocation;
     end;


and just completely remove this piece of code in the main assembler routine:
Code:

    if pos('DS:',parameter1)>0 then
    begin
      setlength(bytes,length(bytes)+1);
      bytes[length(bytes)-1]:=$3e;
    end;

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

Joined: 07 Sep 2009
Posts: 5

PostPosted: Tue Sep 08, 2009 9:56 am    Post subject: Reply with quote

Dark Byte wrote:
not sure how your tokenizer returned a tokenlist of 00000000[EAX] (did you declare byte , ptr or DS as a registered symbol ? )

Nope I didn't use registered symbol, didn't declare anything. And I remember I removed DS: prefix and it was still buggy.

I am reflecting your changings now, I'll let you know about result.
Back to top
View user's profile Send private message
SONSiVRi
How do I cheat?
Reputation: 0

Joined: 07 Sep 2009
Posts: 5

PostPosted: Wed Sep 09, 2009 1:36 am    Post subject: Reply with quote

Yep you solved it, thanks.

btw, is there any below limit on donations?

For who wants to apply these codes; it won't work on 5.5 source that is located on download page, you need to checkout from SVN source (there are differences).

EDIT: Ignore the next question, I saw bugtracker, I'll file next bugs in there.

And I wanna ask you something; I found another bug in JMP opcode, I am going to work on that assembler thingy too much, if I found another bug want me to tell you or I just ignore it?

When I type one of these codes
Code:
JMP FAR 00123456
JMP SHORT 00123456

everything is written memory as it typed. But in this code
Code:
JMP 00123456

(Current address is not far then FF) it writes memory
Code:
JMP SHORT 00123456
NOP
NOP
NOP

It assembles as a SHORT but allocates as a FAR.
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 470

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

PostPosted: Wed Sep 09, 2009 3:01 am    Post subject: Reply with quote

yes, the 5-byte allocation for an unmarked jmp is the reason jmp far and long got explicitly implemented

At code generation time it's not know if the difference in address will be smaller or bigger than 127 bytes. So when it encounters a jmp to an yet unimplemented label address it can't predict the offset, so allocates 5 bytes for it(unless far or short is used), adds it to a list and continues assembling.
Then when everything is assembled it fills in the offsets for the jmp instructions that haven't been set yet. (see it like linking)
I could probably reassemble the instructions from that jump when the offset has been found, but for every single jmp instruction it would have to start reassembling each time it reaches the end. Which would probably be very slow


also, if you would jump to a location previously declared(above it), the distance would be known and would have used the short jmp instead (or long jump if it was more than 127 byte difference)

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

Joined: 07 Sep 2009
Posts: 5

PostPosted: Thu Sep 10, 2009 7:52 am    Post subject: Reply with quote

Dark Byte
I filed report in bug tracker, changes you made are reasoned to another bug.
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 470

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

PostPosted: Thu Sep 10, 2009 8:23 am    Post subject: Reply with quote

fixed
_________________
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
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Source 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