В этом случае ProcessReadMemory вернёт 4 байта в виде Int.
Если приложение хранит строки в системной ANSI кодировке, то каждый символ в строке занимает 1 байт и считывать следует 12 байт, по числу символов в строке, иначе, если строки в UTF-16LE, то байт нужно получить 24.
str := ProcessReadMemory(0x3AA2310, "test.exe", "Str", 12)
if (StrGet(&str, "CP0") = "You are lose") {
; действия
}
ProcessReadMemory(address, processIDorName, type := "Int", numBytes := 4) {
VarSetCapacity(buf, numBytes, 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 (type = "Str")
? StrGet(&buf, numBytes)
: NumGet(buf, type)
}