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 


Unstable behavior of auto assembler

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

Joined: 23 Apr 2015
Posts: 33

PostPosted: Mon Oct 05, 2020 9:19 am    Post subject: Unstable behavior of auto assembler Reply with quote

In some conditions it produced inconsistent result if lua string expression is involved.
Code:
[ENABLE]
{$lua}
s = "-3A"
function setstr(argstr, syntaxcheckonly)
  print("setstr", tostring(syntaxcheckonly), argstr)
  return argstr
end
unregisterAutoAssemblerCommand("setstr")
registerAutoAssemblerCommand("setstr", setstr)
{$asm}
define(as, -3A)
alloc(sa, $4096)
registerSymbol(sa)
sa:
  cmp eax, -3A
  cmp eax, $s
  cmp eax, as
  setstr(cmp eax, -3A)
  cmp ecx, -3A
  cmp ecx, $s
  cmp ecx, as
  setstr(cmp ecx, -3A)
  cmp esi, -3A
  cmp esi, $s
  cmp esi, as
  setstr(cmp esi, -3A)
  xor eax,eax
  xor eax,eax
  xor eax,eax
  xor eax,eax

[DISABLE]
dealloc(sa)

Result:
Code:
sa - 83 F8 C6              - cmp eax,-3A { 198 }
0F010003- 83 F8 C6              - cmp eax,-3A { 198 }
0F010006- 83 F8 C6              - cmp eax,-3A { 198 }
0F010009- 83 F8 C6              - cmp eax,-3A { 198 }
0F01000C- 83 F9 C6              - cmp ecx,-3A { 198 }
0F01000F- 81 F9 C6FFFFFF        - cmp ecx,FFFFFFC6 { -58 }  !!! cmp ecx, $s
0F010015- 83 F9 C6              - cmp ecx,-3A { 198 }
0F010018- 83 F9 C6              - cmp ecx,-3A { 198 }
0F01001B- 83 FE C6              - cmp esi,-3A { 198 }
0F01001E- 81 FE C6FFFFFF        - cmp esi,FFFFFFC6 { -58 } !!! cmp esi, $s
0F010024- 83 FE C6              - cmp esi,-3A { 198 }
0F010027- 83 FE C6              - cmp esi,-3A { 198 }
0F01002A- 31 C0                 - xor eax,eax
0F01002C- 31 C0                 - xor eax,eax
0F01002E- 31 C0                 - xor eax,eax
0F010030- 31 C0                 - xor eax,eax

I would expect all of them encoded as imm8, as the input is equivalent.

Looks define() is safe to use, but such inconsistent behavior doesn't look very correct.
Back to top
View user's profile Send private message
myocytebd2
Cheater
Reputation: 0

Joined: 23 Apr 2015
Posts: 33

PostPosted: Tue Oct 06, 2020 11:12 am    Post subject: Reply with quote

nop 6 is translated to
Code:
nop word ptr [eax+eax+00]

Good, but if this is used as input, it is reduced to
Code:
nop word ptr [eax+eax]

Workaround is to set imm16 offset to non zero.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine 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