serdem Posted October 15, 2008 Share Posted October 15, 2008 (edited) Hi everyone, Is it possible to get/set content of a dllStruct that created by another script? Edited October 15, 2008 by serdem Link to comment Share on other sites More sharing options...
martin Posted October 15, 2008 Share Posted October 15, 2008 Hi everyone,Is it possible to get/set content of a dllStruct that created by another script?Yes. You need to use a memory udf. Memory.au3 or NomadMemory.au3 say.Or you could use messages so that one script creates the struct and the other can request a coy of the current data or request that the data is changed. Even if you use the Memory approach you will need a mesage or some way to tell the second script what the memory address is for the struct. Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
monoceres Posted October 15, 2008 Share Posted October 15, 2008 (edited) Hi! This is very easy to do with the memory functions in WinAPI.au3 (included in autoit install package). I've made a little demo that shows how you do it Save this script and run it: CODE #include <ButtonConstants.au3> $secretvalue = Random(0, 1000000, 1) $struct = DllStructCreate("int;") DllStructSetData($struct, 1, $secretvalue) $hwnd = GUICreate("Secret", 170, 80) $button = GUICtrlCreateButton("Secret value at " & DllStructGetPtr($struct) & @CRLF & "My PID is: " & @AutoItPID, 10, 10, 150, 60, $BS_MULTILINE) GUISetState() Do $msg = GUIGetMsg() If $msg = $button Then $guess = InputBox("What is my value?", "Input your answer here:") If $guess <> $secretvalue Then MsgBox(16, "Wrong", "Wrong answer, try again ") Else MsgBox(64, "Success", "Good job, I'm choosing a new value and a new ptr") $secretvalue = Random(0, 1000000, 1) $struct = DllStructCreate("int;") DllStructSetData($struct, 1, $secretvalue) GUICtrlSetData($button,"Secret value at " & DllStructGetPtr($struct) & @CRLF & "My PID is: " & @AutoItPID) EndIf EndIf Until $msg = -3 Then you can use this script to find out what value the first script is holding: CODE #include <WINAPI.au3> Local $read Local $pid Local $pointer $pid=InputBox("PID of process to read","PID here") If $pid="" Then Exit $pointer=InputBox("Pointer to the memory","Pointer here") If $pointer="" Then Exit $struct=DllStructCreate("int;") ; Open process with PROCESS_VM_READ access $hprocess=_WinAPI_OpenProcess(0x0010,false,$pid,false) _WinAPI_ReadProcessMemory($hprocess,$pointer,DllStructGetPtr($struct),4,$read) MsgBox(0,"The Secret value is: ",DllStructGetData($struct,1)) Edited October 15, 2008 by monoceres Broken link? PM me and I'll send you the file! Link to comment Share on other sites More sharing options...
serdem Posted October 15, 2008 Author Share Posted October 15, 2008 Yes. You need to use a memory udf. Memory.au3 or NomadMemory.au3 say.Or you could use messages so that one script creates the struct and the other can request a coy of the current data or request that the data is changed. Even if you use the Memory approach you will need a mesage or some way to tell the second script what the memory address is for the struct.Thanks Martin,What I want to do is to create a dllstruct and set some data into that struct from first script and make second script informed using dllCall 'sendmessage'.With this message I also send the pointer of dllstruct (DLLStructGetPtr). But I never succeed it up to now. Link to comment Share on other sites More sharing options...
martin Posted October 15, 2008 Share Posted October 15, 2008 Thanks Martin,What I want to do is to create a dllstruct and set some data into that struct from first script and make second script informed using dllCall 'sendmessage'.With this message I also send the pointer of dllstruct (DLLStructGetPtr). But I never succeed it up to now.This example might help.Also have a look at ChrisL's udf in example scripts which makes using messages simpler. Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
serdem Posted October 16, 2008 Author Share Posted October 16, 2008 Hi!This is very easy to do with the memory functions in WinAPI.au3 (included in autoit install package).I've made a little demo that shows how you do it Thank you monoceres,This is exactly what I want. Your demo scripts are great! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now