Last active
May 24, 2019 09:53
-
-
Save NotAdam/2d6c9914a100c64183f2f8ea1c8a5327 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- init global variable | |
g_dump = io.open(os.date("dump_%Y-%m-%d-%H-%M-%S.txt"), "a") | |
g_dump:write("ptr, name\n") | |
g_count = 0 | |
-- relative virtual address(rva) to register_whatever function | |
-- this assume ffxiv sb benchmark | |
-- YOU MUST EDIT THIS TO RIGHT VALUE TO WORK | |
-- check http://imgur.com/a/nJCef for disasm | |
g_addr = {} | |
-- signature: 4053 4881EC60010000 488B??????????4833C4 4889842450010000 C70100000000 488BD9 4585C0 7514 | |
g_addr.load_master = 0x171F20 -- looks like below function is called from this | |
g_loadseen = {} | |
g_xiv = {} | |
g_xiv.proc_name = "ffxiv_dx11.exe" | |
g_xiv.path = "C:\\Program Files (x86)\\Steam\\steamapps\\common\\FINAL FANTASY XIV Online\\game\\ffxiv_dx11.exe" | |
-- because I don't want to login and out every single try | |
g_xiv.arg = "DEV.TestSID=825636a8aa2e581ef1d165f3f132f0f9607bb23ba8ff8563bb1a5e94 DEV.UseSqPack=1 DEV.DataPathType=1 DEV.LobbyHost01=127.0.0.1 DEV.LobbyPort01=54994 DEV.LobbyHost02=127.0.0.1 DEV.LobbyPort02=54994 DEV.LobbyHost03=127.0.0.1 DEV.LobbyPort03=54994 DEV.LobbyHost04=127.0.0.1 DEV.LobbyPort04=54994 DEV.LobbyHost05=127.0.0.1 DEV.LobbyPort05=54994 DEV.LobbyHost06=127.0.0.1 DEV.LobbyPort06=54994 DEV.LobbyHost07=127.0.0.1 DEV.LobbyPort07=54994 DEV.LobbyHost08=127.0.0.1 DEV.LobbyPort08=54994 SYS.Region=3 language=1 version=1.0.0.0 DEV.MaxEntitledExpansionID=2 DEV.GMServerHost=127.0.0.1" | |
g_mode = "attach" | |
function init() | |
-- attach debugger | |
if g_mode == "create" then | |
print(string.format("Launching ffxiv.exe w/ arg %s", g_xiv.arg)) | |
createProcess(g_xiv.path, g_xiv.arg, true, true) | |
elseif g_mode == "attach" then | |
print("Looking for ffxiv.exe..") | |
while not openProcess(g_xiv.proc_name) do sleep(1) end | |
print("Attaching...") | |
debugProcess() | |
while not getAddress(g_xiv.proc_name) do sleep(1) end | |
print("Module loaded") | |
else | |
print("Unsupported mode!") | |
return | |
end | |
for k, v in pairs(g_addr) do | |
-- k = name | |
-- v = rva | |
print(string.format("Attaching %s breakpoint on 0x%X", k, v)) | |
debug_setBreakpoint(get_va(v)) | |
end | |
print("Now waiting for breakpoints..") | |
end | |
function debugger_onBreakpoint() | |
if RIP == get_va(g_addr.load_master) then | |
-- dump_message("master>>") | |
dump_addr(RDX) | |
else | |
-- user bp, update gui on ce, but who gives a shit? | |
-- continue execution anyway | |
debug_continueFromBreakpoint("co_run") | |
return 0 | |
end | |
-- something is missing on the text file because it takes ageeeeeeeeees to write to file | |
-- let just wait it | |
-- continue execution | |
debug_continueFromBreakpoint("co_run") | |
--return 0 -- update gui | |
return 1 | |
end | |
function dump_addr(addr) | |
local vfspath = readString(addr, 256) | |
if not g_loadseen[vfspath] then | |
g_loadseen[vfspath] = true -- set seen flag | |
local message = string.format("%X, %s", addr, vfspath) | |
dump_line(message) | |
end | |
end | |
function dump_line(message) | |
dump_message(message) | |
end | |
function dump_message(message) | |
g_dump:write(message .. '\n') | |
g_dump:flush() | |
print(message) | |
end | |
-- mod_base + rva = va | |
function get_va(rva) | |
return getAddress(g_xiv.proc_name) + rva | |
end | |
-- rva = va - mod_base | |
function get_rva(va) | |
return va - getAddress(g_xiv.proc_name) | |
end | |
-- check mod_base <= va <= mod_base + mod_size | |
function is_mmod_addr(va) | |
local mod_base = getAddress(g_xiv.proc_name) | |
local mod_size = getModuleSize(g_xiv.proc_name) | |
if mod_base <= va and va <= mod_base + mod_size then | |
return true | |
end | |
return false | |
end | |
function split(str) | |
local result = {} | |
for token in string.gmatch(str..",", "([^,]+),%s*") do | |
table.insert(result, all_trim(token)) | |
end | |
return result | |
end | |
init() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment