Refreshing pointer addresses from Lua

Husky2490

What is cheating?
Mar 10, 2018
3
0
1
#1
I'm working on making a custom text hooker in Lua and I've run into a bit of a snag. I've identified the pointers that point to the string of text (and associated string object) that will be displayed but there are a few major complications:
  1. The string object moves when text is appended
  2. The string of text moves upon any modification
  3. Each line of text is appended in turn
  4. The string is deleted one character at a time prior to being rendered
  5. All of this happens in under 1 frame @~30 fps, meaning actively looking for updates would require insane update frequencies
I'm attempting to use breakpoints to get around the update problem but my script is only working some of the time. I added a few print statements and I'm finding that some of the time my script is setting a breakpoint at an outdated address. I've added 2 whole seconds of delay per line of text and have only gotten it to ~70% success, even after setting the update frequencies in the settings to 100 ms. I couldn't find any documentation for any function that will trigger a refresh of the addresses. What should I do?

Here's a snippet of some of the code I'm using
Code:
function resetBreakpoints()
    local breakpointList = debug_getBreakpointList()
    for k,v in ipairs(breakpointList) do
        debug_removeBreakpoint(v)
    end
    -- Pointer to string object
    debug_setBreakpoint(messageString.getCurrentAddress()+0x08, 4, bptWrite, setPtrBreakpoint)
end

function setPtrBreakpoint()
    if readPointer(messageString.getCurrentAddress()+0x08) == 0x04 then
        debug_continueFromBreakpoint(co_run)
        return 1
    end
    createThread(function(Thread,...)
        print('Message write detected')
        print('Setting text breakpoint...')
        resetBreakpoints()
        -- Pointer to string in memory
        sleep(2000) -- Wait for Cheat Engine to update the addresses in the address table (X my fingers it works at least 50% of the time)
        print(string.format('%08X', msize.getCurrentAddress())) -- Debugging
        debug_setBreakpoint(msize.getCurrentAddress()+0x04, 4, bptWrite, hookText)
        debug_continueFromBreakpoint(co_run)
    end)
    return 1
end

function hookText()
    print('Message being processed, grabbing message...')
    resetBreakpoints()
    updateRecordSize(mtxt, msize)
    MessageText = mtxt.Value
    writeToClipboard(MessageText)
    print(MessageText)
    debug_continueFromBreakpoint(co_run)
    return 1
end
 
Last edited:

Husky2490

What is cheating?
Mar 10, 2018
3
0
1
#2
I've figured it out:
Code:
debug_setBreakpoint(readPointer(messageString.getCurrentAddress()+0x08)+0x0c, 4, bptWrite, hookText)