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 


Reading XMM0 in Auto Assemble script using LUA

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

Joined: 01 Dec 2016
Posts: 2

PostPosted: Thu Dec 01, 2016 6:00 pm    Post subject: Reading XMM0 in Auto Assemble script using LUA Reply with quote

I'm trying to read one of the floats in XMM0 when paused on a breakpoint using a LUA Auto Assemble script.

XMM0 looks like this in the memory viewer:
Code:
xmm0: 980.00 - 0.00 - 0.00 - 0.00


Autoassembly script:
Code:
{$lua}

address = 0x...

function debugger_onBreakpoint()
    if (RIP ~= address) then return 0 end

    test = readFloat(XMM0)
    print(test) -- Prints a blank line

    debug_continueFromBreakpoint(co_run)

    return 1
end

[ENABLE]
debugProcess()
debug_setBreakpoint(address)

[DISABLE]
debug_removeBreakpoint(address)


I'm trying to get the X0 value (980.00) and assign it to a local variable.
How can I do this in my LUA script?
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 6:25 pm    Post subject: Reply with quote

main.lua:
Quote:
debug_getXMMPointer(xmmregnr) :
Returns the address of the specified xmm register of the thread that is currently broken
This is a LOCAL Cheat Engine address. Use Local memory access functions to read and modify
xmmregnr can be 0 to 15 (0 to 7 on 32-bit)


Code:
print(readFloatLocal(debug_getXMMPointer(0)))

_________________
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 10:00 pm    Post subject: Reply with quote

call
Code:

debug_getContext(true)

the XMM registers will then be set as well

note that XMM registers are stored as byteTable's so, use byteTableToFloat(XMM0) to get the float value out of the first 32 bits

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

Joined: 01 Dec 2016
Posts: 2

PostPosted: Fri Dec 02, 2016 2:11 am    Post subject: Reply with quote

Thanks!

Both of your methods worked.
A note for Dark Byte's method: debug_getContext(true) needs to be called before every read or else the value of XMM0 won't change.

Code:
function debugger_onBreakpoint()
    ...

    -- This works
    print(readFloatLocal(debug_getXMMPointer(0)))

    -- So does this
    debug_getContext(true)
    print(byteTableToFloat(XMM0))

    ...
end
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 Lua Scripting 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