| View previous topic :: View next topic |
| Author |
Message |
xxhehe Expert Cheater
Reputation: 0
Joined: 11 Mar 2015 Posts: 154
|
Posted: Sun Sep 01, 2024 10:54 pm Post subject: notepad.exe + getProcessMemoryInfo |
|
|
| Code: | -- Function to open the specified process (notepad.exe) and get its memory info
function getNotepadMemoryInfo()
-- Specify the process name (notepad.exe)
local processName = "notepad.exe"
-- Find the process ID of notepad.exe
local pid = nil
local processList = getProcessList()
for pID, pName in pairs(processList) do
if string.lower(pName) == string.lower(processName) then
pid = pID
break
end
end
if pid == nil then
print("Notepad process not found")
return
end
-- Open the notepad process
openProcess(pid)
-- Allocate memory for the PROCESS_MEMORY_COUNTERS structure
local pmc = allocateMemory(40) -- The structure is 40 bytes (on a 32-bit system)
if not pmc then
print("Failed to allocate memory")
return
end
writeInteger(pmc, 40) -- Set the cb field to the size of the structure
-- Get the address of GetProcessMemoryInfo API from kernel32.dll
local kernel32_base = getAddress("kernel32.dll")
if not kernel32_base then
print("Failed to get kernel32.dll base address")
return
end
-- Get the GetProcessMemoryInfo function address
local GetProcessMemoryInfo = getAddress("K32GetProcessMemoryInfo", kernel32_base)
if not GetProcessMemoryInfo then
GetProcessMemoryInfo = getAddress("GetProcessMemoryInfo", kernel32_base)
end
if not GetProcessMemoryInfo then
print("Failed to find GetProcessMemoryInfo function")
return
end
-- Debug output: Print address of GetProcessMemoryInfo
print("GetProcessMemoryInfo address: " .. string.format("0x%X", GetProcessMemoryInfo))
-- Call the API
local result = executeCode(GetProcessMemoryInfo, getOpenedProcessHandle(), pmc, 40)
-- Check if result is valid before proceeding
if result == nil or result == 0 then
print("Failed to execute GetProcessMemoryInfo")
freeMemory(pmc) -- Clean up memory allocation
return
end
-- Debug output: Print result of executeCode
print("Result of executeCode: " .. tostring(result))
-- Read the values from the PROCESS_MEMORY_COUNTERS structure
local PageFaultCount = readInteger(pmc + 4)
local PeakWorkingSetSize = readQword(pmc + 8)
local WorkingSetSize = readQword(pmc + 16)
local PagefileUsage = readQword(pmc + 32)
local PeakPagefileUsage = readQword(pmc + 24)
print("Page Fault Count: " .. PageFaultCount)
print("Peak Working Set Size: " .. PeakWorkingSetSize)
print("Working Set Size: " .. WorkingSetSize)
print("Pagefile Usage: " .. PagefileUsage)
print("Peak Pagefile Usage: " .. PeakPagefileUsage)
-- Clean up: Ensure memory is properly released
freeMemory(pmc)
end
-- Call the function to get notepad memory information
getNotepadMemoryInfo()
|
GetProcessMemoryInfo address: 0x7FFFD553B950
Failed to execute GetProcessMemoryInfo
错误:[string "-- Function to open the specified process (no..."]:59: attempt to call a nil value (global 'freeMemory')
|
|
| Back to top |
|
 |
Dark Byte Site Admin
Reputation: 470
Joined: 09 May 2003 Posts: 25807 Location: The netherlands
|
Posted: Mon Sep 02, 2024 1:10 am Post subject: |
|
|
freeMemory doesn't exist. try deAlloc instead
_________________
Do not ask me about online cheats. I don't know any and wont help finding them.
Like my help? Join me on Patreon so i can keep helping |
|
| Back to top |
|
 |
xxhehe Expert Cheater
Reputation: 0
Joined: 11 Mar 2015 Posts: 154
|
Posted: Mon Sep 02, 2024 4:36 am Post subject: |
|
|
| Dark Byte wrote: | | freeMemory doesn't exist. try deAlloc instead |
| Code: |
-- Get the address of GetProcessMemoryInfo API from kernel32.dll
local kernel32_base = getAddress("kernel32.dll")
if not kernel32_base then
print("Failed to get kernel32.dll base address")
deAlloc(pmc)
return
end
-- Get the GetProcessMemoryInfo function address
local GetProcessMemoryInfo = getAddress("K32GetProcessMemoryInfo", kernel32_base)
if not GetProcessMemoryInfo then
GetProcessMemoryInfo = getAddress("GetProcessMemoryInfo", kernel32_base)
end
if not GetProcessMemoryInfo then
print("Failed to find GetProcessMemoryInfo function")
deAlloc(pmc)
return
end
-- Debug output: Print address of GetProcessMemoryInfo
print("GetProcessMemoryInfo address: " .. string.format("0x%X", GetProcessMemoryInfo))
-- Call the API
local result = executeCode(GetProcessMemoryInfo, getOpenedProcessHandle(), pmc, 40)
-- Check if result is valid before proceeding
if result == nil or result == 0 then
print("Failed to execute GetProcessMemoryInfo")
deAlloc(pmc) -- Clean up memory allocation
return
end
-- Debug output: Print result of executeCode
print("Result of executeCode: " .. tostring(result))
-- Read the values from the PROCESS_MEMORY_COUNTERS structure
local PageFaultCount = readInteger(pmc + 4)
local PeakWorkingSetSize = readQword(pmc + 8)
local WorkingSetSize = readQword(pmc + 16)
local PagefileUsage = readQword(pmc + 32)
local PeakPagefileUsage = readQword(pmc + 24)
print("Page Fault Count: " .. PageFaultCount)
print("Peak Working Set Size: " .. PeakWorkingSetSize)
print("Working Set Size: " .. WorkingSetSize)
print("Pagefile Usage: " .. PagefileUsage)
print("Peak Pagefile Usage: " .. PeakPagefileUsage)
-- Clean up: Ensure memory is properly released
deAlloc(pmc)
end
-- Call the function to get the current process memory information
getCurrentProcessMemoryInfo()
|
Modified but still invalid.It looks like the program is crashing when trying to execute GetProcessMemoryInfo. This may be due to incorrect parameters or a problem with how executeCode is being used.
Please ask if enumMemoryRegions() can get the result of getProcessMemoryInfo():Retrieve and display memory information
|
|
| Back to top |
|
 |
Dark Byte Site Admin
Reputation: 470
Joined: 09 May 2003 Posts: 25807 Location: The netherlands
|
Posted: Mon Sep 02, 2024 11:48 am Post subject: |
|
|
you may want to look into ExecuteCodeEx if you intend on using parameters
_________________
Do not ask me about online cheats. I don't know any and wont help finding them.
Like my help? Join me on Patreon so i can keep helping |
|
| Back to top |
|
 |
|