Code: Select all
ReadMemory(MADDRESS=0,PROGRAM="")
{
Static OLDPROC, ProcessHandle
VarSetCapacity(MVALUE,4,0)
If PROGRAM != %OLDPROC%
{
WinGet, pid, pid, % OLDPROC := PROGRAM
;QUESTION #0, On the line above, is it the old value of OLDPROC which is used in the winget command, and the ;OLDPROC is set to the value of PROGRAM, first after the winget command is executed?
;QUESTION #1, What does the question mark after "processHandle" below mean?
;QUESTION #2, What does the 0* mean?
ProcessHandle := ( ProcessHandle ? 0*(closed:=DllCall("CloseHandle"
,"UInt",ProcessHandle)) : 0 )+(pid ? DllCall("OpenProcess"
,"Int",16,"Int",0,"UInt",pid) : 0)
;QUESTION #3 What is the ": 0" doing in the lines above?
}
If (ProcessHandle) && DllCall("ReadProcessMemory","UInt"
,ProcessHandle,"UInt",MADDRESS,"Str",MVALUE,"UInt",4,"UInt *",0)
return *(&MVALUE+3)<<24 | *(&MVALUE+2)<<16 | *(&MVALUE+1)<<8 | *(&MVALUE)
;QUESTION #6 Please explain how the line above works, for example why is there an & before MVALUE, and what does << ;mean?
return !ProcessHandle ? "Handle Closed: " closed : "Fail"
;QUESTION #4 Does the two return lines above mean that the function returns two different values?
;QUESTION #5 What is the meaning of the exclamation mark before "ProcessHandle"?