Тема: AHK: Узнать адрес памяти Dll файла
Помогите пожалуйста. Программа в свой процесс загружает свои Dll. Как можно узнать адрес в памяти программы Dll файла?
То есть например типо такого:
processName := igra.exe
adres1 := kakoito.dll
adres2 := 0x123
adres3 := adres1 + adres2
ProcessReadMemory(adres3, processName)
Для чтения и записи в память я использую это:
ProcessReadMemory(address, processIDorName, type := "Int", numBytes := 4) {
VarSetCapacity(buf, numBytes, 0)
VarSetCapacity(numBytesRead, A_PtrSize, 0)
Process Exist, %processIDorName%
if !processID := ErrorLevel
throw Exception("Invalid process name or process ID:`n`n""" . processIDorName . """")
if !processHandle := DllCall("OpenProcess", "Int", 24, "UInt", 0, "UInt", processID, "Ptr")
throw Exception("Failed to open process.`n`nError code:`t" . A_LastError)
result := DllCall("ReadProcessMemory", "Ptr", processHandle, "Ptr", address, "Ptr", &buf, "Ptr", numBytes, "PtrP", numBytesRead, "UInt")
if !DllCall("CloseHandle", "Ptr", processHandle, "UInt") && !result
throw Exception("Failed to close process handle.`n`nError code:`t" . A_LastError)
if !result
throw Exception("Failed to read process memory.`n`nError code:`t" . A_LastError)
if !numBytesRead
throw Exception("Read 0 bytes from the`n`nprocess:`t" . processIDorName . "`naddress:`t" . address)
return NumGet(buf, 0, type)
}
ProcessWriteMemory(data, address, processIDorName, type := "Int", numBytes := 4) {
VarSetCapacity(buf, numBytes, 0)
NumPut(data, buf, 0, type)
Process Exist, %processIDorName%
if !processID := ErrorLevel
throw Exception("Invalid process name or process ID:`n`n""" . processIDorName . """")
if !processHandle := DllCall("OpenProcess", "Int", 40, "UInt", 0, "UInt", processID, "Ptr")
throw Exception("Failed to open process.`n`nError code:`t" . A_LastError)
result := DllCall("WriteProcessMemory", "Ptr", processHandle, "Ptr", address, "Ptr", &buf, "Ptr", numBytes, "UInt", 0, "UInt")
if !DllCall("CloseHandle", "Ptr", processHandle, "UInt") && !result
throw Exception("Failed to close process handle.`n`nError code:`t" . A_LastError)
if !result
throw Exception("Failed to write process memory.`n`nError code:`t" . A_LastError)
return result
}