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 converting Lua to Auto Assembler

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

Joined: 04 Feb 2016
Posts: 56

PostPosted: Wed Nov 30, 2016 8:46 pm    Post subject: Help converting Lua to Auto Assembler Reply with quote

I have this custom type that was made in Lua, and I want to convert it to Auto Assembler. The problem is that I know next to nothing about how the Auto Assembler coding works. So can someone help me with this?

The custom type is this:
Code:

typename="Timer Big Endian" --shown as the typename in ce
bytecount=8  --number of bytes of this type
functionbasename="b8t"

function b8t_bytestovalue(b0,b1,b2,b3,b4,b5,b6,b7)
  local time = byteTableToQword{b7,b6,b5,b4,b3,b2,b1,b0}
  local sec  = math.floor(time / 40500000)
  if sec>=0 and sec < 0x15752A00 then
    local ss = sec % 60
    local mm = math.floor(sec/60) % 60
    local hh = math.floor(sec/3600)
    return hh*10000+mm*100+ss
  else
    return 0x80000000
  end
end

function b8t_valuetobytes(i,address)
  local b = readBytes(address,8,true)
  if i>=0 and i<=999995959 then
    local ss = i % 100
    if ss<60 then
      local mm = math.floor(i/100)%100
      if mm<60 then
        local hh = math.floor(i/10000)
        local sec = hh*3600+mm*60+ss
        local time = sec*40500000
        b = qwordToByteTable(time)
        for i=1,4 do
          local j = 9-i
          b[i],b[j]=b[j],b[i] -- reverse
        end
      end
    end
  end

  local UnPack = table.unpack or unpack
  return UnPack(b)
end
return typename,bytecount,functionbasename
Back to top
View user's profile Send private message
Corroder
Grandmaster Cheater Supreme
Reputation: 75

Joined: 10 Apr 2015
Posts: 1667

PostPosted: Thu Dec 01, 2016 4:55 am    Post subject: Reply with quote

I think lua script can be handling and running within AA by :

Code:

[ENABLE]
{$lua}
put lua script here
{$asm}
[DISABLE]



Is this right ?

also check : http://forum.cheatengine.org/viewtopic.php?t=599814
Back to top
View user's profile Send private message
Zephiles
Advanced Cheater
Reputation: 0

Joined: 04 Feb 2016
Posts: 56

PostPosted: Thu Dec 01, 2016 7:54 am    Post subject: Reply with quote

Corroder wrote:
I think lua script can be handling and running within AA by :

Code:

[ENABLE]
{$lua}
put lua script here
{$asm}
[DISABLE]



Is this right ?

also check : http://forum.cheatengine.org/viewtopic.php?t=599814

This does not work with custom types. And besides, doing this isn't actually converting the code to AA in the first place.
Back to top
View user's profile Send private message
ParkourPenguin
I post too much
Reputation: 138

Joined: 06 Jul 2014
Posts: 4275

PostPosted: Thu Dec 01, 2016 9:33 am    Post subject: Reply with quote

Last time I checked AA custom types don't work that well with value sizes greater than 4 bytes.

If this is a continuation of this topic, do note that mgr.inz.Player's customTypesExt has been updated to work for Lua custom types.

_________________
I don't know where I'm going, but I'll figure it out when I get there.
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 457

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

PostPosted: Thu Dec 01, 2016 11:02 am    Post subject: Reply with quote

aa custom types can even do 4096 byte custom types, only issue is that people don't understand that the result has to be a 32 bit integer value (or float)

these types are very useful for hashes, which in turn can be useful for the graphical memory view

anyhow, the lua script can be converted to asm, but it's going to be difficult. Try porting it to c first, and then make it generate assembly code which you then port to AA

_________________
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
panraven
Grandmaster Cheater
Reputation: 54

Joined: 01 Oct 2008
Posts: 941

PostPosted: Thu Dec 01, 2016 3:02 pm    Post subject: Reply with quote

The attached is source of a AA h-m-s version , verified with the lua d-h-m-s version, hopefully no error.

Copy the content and make a new custom type, then paste and edit type name.

bye~

ADDED:
invalid value is -1, not 0x80000000.

_________________
- Retarded.
Back to top
View user's profile Send private message
mgr.inz.Player
I post too much
Reputation: 218

Joined: 07 Nov 2008
Posts: 4438
Location: W kraju nad Wisla. UTC+01:00

PostPosted: Thu Dec 01, 2016 3:24 pm    Post subject: Reply with quote

My version (only for 64bit CE):

Code:
alloc(ConvertRoutine,1024)
alloc(ConvertBackRoutine,1024)
alloc(TypeName,256)
alloc(ByteSize,4)
alloc(UsesFloat,1)
alloc(CallMethod,1)
alloc(PreferedAlignment,4)

TypeName:
db 'weird timer',0

ByteSize:
dd 8

UsesFloat:
db 0

CallMethod:
db 1

PreferedAlignment:
dd 4

ConvertRoutine:
[64-bit]
mov    rcx,[rcx]
bswap  rcx

xor    edx,edx
mov    r8d,269fb20
mov    rax,rcx
div    r8

cmp    rax,157529ff
ja     wrong

mov    r10,rax
mov    r8,21f25b7200
mov    rax,rcx
xor    edx,edx
div    r8
imul   r8,rax,2710
mov    r9d,3c
mov    rax,r10
xor    edx,edx
mov    r10d,90d6db80
div    r9
mov    rax,rcx
add    r8,rdx
xor    edx,edx
div    r10
xor    edx,edx
div    r9
imul   rax,rdx,64
add    rax,r8
ret

wrong:
mov    eax,ffffffff
[/64-bit]
ret

ConvertBackRoutine:
[64-bit]
cmp    ecx,3b9aba37
ja     wrong2
xor    edx,edx
mov    r9d,64
mov    rax,rcx
div    r9
cmp    rdx,3b
mov    r11,rdx
ja     wrong2
xor    edx,edx
div    r9
cmp    rdx,3b
mov    r10,rdx
ja     wrong2
mov    rax,rcx
mov    r9d,2710
xor    edx,edx
div    r9
imul   rcx,rax,e10
imul   rax,r10,3c
add    rcx,r11
add    rax,rcx
imul   rax,rax,269fb20
bswap rax
mov [r8],rax
ret

wrong2:
[/64-bit]
ret

_________________
Back to top
View user's profile Send private message MSN Messenger
Zephiles
Advanced Cheater
Reputation: 0

Joined: 04 Feb 2016
Posts: 56

PostPosted: Thu Dec 01, 2016 4:00 pm    Post subject: Reply with quote

Alright both of these work. There is one thing I noticed though, which is a little annoying but I'm not sure if anything can be done about it. When using both of those, the number put into the fast scan option is 4, but I want it to be 8. Can this be done?
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 457

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

PostPosted: Thu Dec 01, 2016 4:10 pm    Post subject: Reply with quote

alloc(preferedalignment,4)
preferedalignment:
dd 8

_________________
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
Zephiles
Advanced Cheater
Reputation: 0

Joined: 04 Feb 2016
Posts: 56

PostPosted: Thu Dec 01, 2016 4:15 pm    Post subject: Reply with quote

Dark Byte wrote:
alloc(preferedalignment,4)
preferedalignment:
dd 8

Alright this worked. Thanks for the help everyone!
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