92 lines
2.3 KiB
Plaintext
92 lines
2.3 KiB
Plaintext
{$LUA}
|
|
if syntaxcheck then return end
|
|
|
|
[ENABLE]
|
|
|
|
|
|
local function safeMain()
|
|
-- 1. Executable of the attached process
|
|
local path = '<no process attached>'
|
|
local ok, mods = pcall(enumModules)
|
|
if ok and type(mods) == 'table' then
|
|
local target = string.lower(tostring(process or ''))
|
|
for i = 1, #mods do
|
|
local m = mods[i]
|
|
if type(m) == 'table' and m.PathToFile
|
|
and string.lower(tostring(m.Name or '')) == target then
|
|
path = m.PathToFile
|
|
break
|
|
end
|
|
end
|
|
if path == '<no process attached>'
|
|
and type(mods[1]) == 'table' and mods[1].PathToFile then
|
|
path = mods[1].PathToFile
|
|
end
|
|
end
|
|
|
|
|
|
-- 3. All active memory records
|
|
local names = {}
|
|
local al = getAddressList()
|
|
if al ~= nil then
|
|
local count = 0
|
|
local okc, c = pcall(function() return al:getCount() end)
|
|
if okc and type(c) == 'number' then count = c end
|
|
for i = 0, count - 1 do
|
|
local rec = nil
|
|
local okr, r = pcall(function() return al:getMemoryRecord(i) end)
|
|
if okr then rec = r end
|
|
if rec ~= nil then
|
|
local isActive = false
|
|
local oka, a = pcall(function() return rec.Active end)
|
|
if oka and a then isActive = true end
|
|
if isActive then
|
|
local d = ''
|
|
local okd, dd = pcall(function() return rec.Description end)
|
|
if okd and type(dd) == 'string' then d = dd end
|
|
if d == '' then d = '<no description>' end
|
|
names[#names + 1] = d
|
|
end
|
|
end
|
|
end
|
|
end
|
|
|
|
-- 4. Build and copy the report
|
|
local out = {}
|
|
out[#out + 1] = 'Executable: ' .. path
|
|
|
|
|
|
out[#out + 1] = 'Active Memory Records:'
|
|
if #names == 0 then
|
|
out[#out + 1] = '- <none>'
|
|
else
|
|
for i = 1, #names do
|
|
out[#out + 1] = '- ' .. names[i]
|
|
end
|
|
end
|
|
|
|
local text = table.concat(out, '\r\n')
|
|
|
|
if writeToClipboard ~= nil then
|
|
writeToClipboard(text)
|
|
showMessage('Your report has been copied to your clipboard.')
|
|
else
|
|
showMessage('Clipboard API not available.')
|
|
end
|
|
print(text)
|
|
end
|
|
|
|
local ok, err = pcall(safeMain)
|
|
if not ok then
|
|
showMessage('Report error: ' .. tostring(err))
|
|
print('Report error: ' .. tostring(err))
|
|
end
|
|
|
|
if memrec ~= nil then
|
|
createTimer(100, function() memrec.Active = false end)
|
|
end
|
|
|
|
[DISABLE]
|
|
-- Read-only report; nothing to undo.
|
|
|