Skip to content

Instantly share code, notes, and snippets.

@Nisto
Created December 12, 2021 21:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Nisto/1c95042eca01df5af7b620ab35f0a09d to your computer and use it in GitHub Desktop.
Save Nisto/1c95042eca01df5af7b620ab35f0a09d to your computer and use it in GitHub Desktop.
-- [!] assumes following version of pcsx2-dev is used:
-- https://github.com/PCSX2/pcsx2/tree/c16db05e0c3a5806fad1fd571141284facc7b421
-- [!] assumes breakpoint exists at:
-- pcsx2-dev.dmaSIF1+603
outputfile = assert(io.open("X:/output.file", "wb"))
outputsize = 0
outputwant = 0x35A000 -- from header @ 0x14
function DumpMemToFile(file, addr, size)
local data_table = readBytes(addr, size, true)
local data_string = byteTableToString(data_table)
file:write(data_string)
return string.len(data_string)
end
MEMCPY_ADDR = getAddress("VCRUNTIME140.memcpy")
function debugger_onBreakpoint()
if EIP == MEMCPY_ADDR then
local dest = readInteger(ESP+0x4)
-- 24xxxxxx is the base for IOP RAM in PCSX2 process
-- 0x10BD00-0x1A7D00 (size 0x9C000) contains "PK3" data
if (dest >= 0x2410BD00) and (dest < 0x241A7D00) then
local src = readInteger(ESP+0x8)
local count = readInteger(ESP+0xC)
outputsize = outputsize + DumpMemToFile(outputfile, src, count)
if (outputsize >= outputwant) then
if (outputfile ~= nil) then
outputfile.close()
outputfile = nil
return 0 -- stop
end
end
end
end
return 1 -- continue
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment