Advertisement
cnsnipermike

BASEAddr

Jun 12th, 2025 (edited)
850
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.50 KB | None | 0 0
  1. gg.showUiButton()
  2. gg.alert("已切換到基址查詢模式\n\n點擊 SX 按鈕可調出功能表\n同時也可以使用修改器功能")
  3. function Start()
  4. MAIN = gg.choice({
  5. "查询",
  6. "返回",
  7. "退出",
  8. })
  9. if MAIN == nil then
  10. else
  11. if MAIN == 1 then CK() end
  12. if MAIN == 2 then BACK() end
  13. if MAIN == 3 then END() end
  14. end
  15. FMXR=-1
  16. end
  17. local results = {}
  18. function formatHex(num)
  19.     if not num then return "未知" end
  20.     return string.format("0x%X", num)
  21. end
  22. function getAllMemoryRanges()
  23.     local ranges = gg.getRangesList()
  24.     if not ranges then
  25.         gg.alert("无法获取内存区域信息")
  26.         return nil
  27.     end
  28.     return ranges
  29. end
  30. function findMemoryRegion(address, ranges)
  31.     for i, region in ipairs(ranges) do
  32.         if address >= region.start and address <= region['end'] then
  33.             return region
  34.         end
  35.     end
  36.     return nil
  37. end
  38. function analyzeAddress(address, number, ranges)
  39.     local region = findMemoryRegion(address, ranges)
  40.     if not region then
  41.         return {
  42.             number = number,
  43.             address = formatHex(address),
  44.             moduleName = "未找到",
  45.             moduleBase = "未知",
  46.             offset = "无法计算"
  47.         }
  48.     end
  49.     local offset = address - region.start
  50.     return {
  51.         number = number,
  52.         address = formatHex(address),
  53.         moduleName = region.name or "未命名模块",
  54.         moduleBase = formatHex(region.start),
  55.         offset = formatHex(offset)
  56.     }
  57. end
  58. function processAddresses()
  59.     local selected = gg.getSelectedResults()
  60.     if not selected or #selected == 0 then
  61.         gg.alert("请先勾选要分析的地址!")
  62.         return false
  63.     end
  64.     local ranges = getAllMemoryRanges()
  65.     if not ranges then return false end
  66.     results = {}
  67.     for i, item in ipairs(selected) do
  68.         local address = item.address
  69.         if address and address ~= 0 then
  70.             local info = analyzeAddress(address, i, ranges)
  71.             table.insert(results, info)
  72.         end
  73.     end
  74.     return true
  75. end
  76. function showResults()
  77.     local resultText = "地址分析结果:\n\n"
  78.     for _, info in ipairs(results) do
  79.         resultText = resultText ..
  80.             "编号: " .. info.number .. "\n" ..
  81.             "地址: " .. info.address .. "\n" ..
  82.             "模块名: " .. info.moduleName .. "\n" ..
  83.             "模块基址: " .. info.moduleBase .. "\n" ..
  84.             "偏移量: " .. info.offset .. ""
  85.     end
  86.     gg.alert(resultText)
  87. end
  88. function CK()
  89.     local status, err = pcall(function()
  90.         if processAddresses() then
  91.             showResults()
  92.         end
  93.     end)
  94.     if not status then
  95.         gg.alert("脚本执行出错:" .. tostring(err))
  96.     end
  97. end
  98. function BACK()
  99. local menu = gg.alert('請選擇要切換的模式\n如果搜索列表有數據請先保存到列表中再繼續返回操作', "返回", "正常模式", "調試模式")
  100. if menu == 1 then
  101. Start()
  102. elseif menu == 2 then
  103. API = gg.makeRequest('  https://pastebin.com/raw/YuSvmysd  ').content
  104. if not API then
  105. gg.alert('no interned access,please try again later')
  106. else
  107. pcall(load(API))
  108. end
  109. elseif menu == 3 then
  110. API = gg.makeRequest('  https://pastebin.com/raw/vhMuGyGv  ').content
  111. if not API then
  112. gg.alert('no interned access,please try again later')
  113. else
  114. pcall(load(API))
  115. end
  116. end
  117. end
  118. function END()
  119. gg.setVisible(true)
  120. os.exit()
  121. end
  122. while(true)do
  123. gg.sleep(1)
  124. if gg.isClickedUiButton() then
  125. FMXR=1
  126. else
  127. FMXR=-1
  128. end
  129. if FMXR==1 then
  130. Start()
  131. end
  132. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement