I've made a test script designed to find a string in notepad (based off an example by RHCP)
It's supposed to find a string, then read part of that string into a temporary variable. The "finding a string" part is coded by RHCP (it has proven to work as expected since I include a file with his plugin in it) and the part I'm investigating is the readRaw part, which seems to return "0" or "1" instead of actual data.
Code: Select all
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
#Include ReadMemory.ahk
LoadData() {
notepad := new _ClassMemory("ahk_exe Notepad.exe", "", hProcessCopy)
if !isObject(notepad)
{
if (hProcessCopy = 0)
msgbox The program isn't running (not found) or you passed an incorrect program identifier parameter.
else if (hProcessCopy = "")
msgbox OpenProcess failed. If the target process has admin rights, then the script also needs to be ran as admin. Consult A_LastError for more information.
}
text := "this is a test"
pattern := notepad.stringToPattern(text, "UTF-16")
patternAddress := notepad.processPatternScan(,, pattern*)
if patternAddress > 0
{
patternAddressString := "0x" ConvertBase(10, 16, patternAddress)
msgbox % patternAddressString
;tempvar := 0
notepad.readRaw(patternAddress, ByRef tempvar, 2*)
msgbox % tempvar
}
else
{
msgbox Not Found!`nReturn Value: %stringPattern%
}
}
ConvertBase(InputBase, OutputBase, number)
{
static u := A_IsUnicode ? "_wcstoui64" : "_strtoui64"
static v := A_IsUnicode ? "_i64tow" : "_i64toa"
VarSetCapacity(s, 65, 0)
value := DllCall("msvcrt.dll\" u, "Str", number, "UInt", 0, "UInt", InputBase, "CDECL Int64")
DllCall("msvcrt.dll\" v, "Int64", value, "Str", s, "UInt", OutputBase, "CDECL")
return s
}
^!F3::
LoadData()
return
I don't know
-which arguments are actually required to obtain the contents of the addresses (I thought the address and the program would be enough??)
-why some of the arguments are "optional", and whether that means I'm required to put in the non-optional arguments, especially because of the *
-whether this function should be initialized to a variable's value (i.e. tempvar := 0 or tempvar := notepad.readRaw etc...) or if that's unneccesary because of the usage of ByRef
-whether ByRef needs to be stated in the function call, or only in the function itself
-where the * goes to imply not all arguments are present, or if it's necessary at all in this case or any, since it's in the function declaration in the first place...
I've been messing around with this ******* code for days and I can't figure out what's supposed to make it WORK. Any help or direction would be highly appreciated. Am I just a scrub who doesn't know how to ******* write code or am I missing something HUGE here?!