JRowe Posted October 23, 2009 Share Posted October 23, 2009 I discovered this in the hunt for a method of IPC I could use between a dll and an AutoIt script. It's essentially a way to share variables between instances of a dll. I was wondering if someone might guide me in the right direction to using this, because I'm encountering some unexpected behavior.The linker settings are correct:/SECTION:.myseg,R,W,SI created a variable to be shared#pragma data_seg (".myseg") double sharedTestVar = 0; #pragma data_seg()I then load the dll into the application. Once loaded, I run a simple script:$myDLL = DllOpen("AutoItRelay.dll") $result = DllCall($myDll, "double:cdecl", "test_interact", "double", 10) ConsoleWrite($result[0] & @CRLF) DllClose($myDll)test_interact is an exported function that increments sharedTestVar by the parameter.Inside the application that's loaded the dll, sharedTestVar doesn't seem to change. However, when I run the script, it shows sharedTestVar incrementing as I expected, up by 10 for every time I run the script.What am I missing? [center]However, like ninjas, cyber warriors operate in silence.AutoIt Chat Engine (+Chatbot) , Link Grammar for AutoIt , Simple Speech RecognitionArtificial Neural Networks UDF , Bayesian Networks UDF , Pattern Matching UDFTransparent PNG GUI Elements , Au3Irrlicht 2Advanced Mouse Events MonitorGrammar Database GeneratorTransitions & Tweening UDFPoker Hand Evaluator[/center] Link to comment Share on other sites More sharing options...
Valik Posted October 23, 2009 Share Posted October 23, 2009 (edited) First thing I see is you only need to use the S flag.I've used the following with success:#pragma data_seg (".shared") // Variables #pragma data_seg()/SECTION:.shared,S Edited October 23, 2009 by Valik Typo Link to comment Share on other sites More sharing options...
JRowe Posted October 23, 2009 Author Share Posted October 23, 2009 Fixed that part, thanks for pointing that out. I'm still getting the same problem from inside the application, though. Do I need to compile the data_seg to the application as well, in order to have the communication open both ways? [center]However, like ninjas, cyber warriors operate in silence.AutoIt Chat Engine (+Chatbot) , Link Grammar for AutoIt , Simple Speech RecognitionArtificial Neural Networks UDF , Bayesian Networks UDF , Pattern Matching UDFTransparent PNG GUI Elements , Au3Irrlicht 2Advanced Mouse Events MonitorGrammar Database GeneratorTransitions & Tweening UDFPoker Hand Evaluator[/center] Link to comment Share on other sites More sharing options...
Valik Posted October 23, 2009 Share Posted October 23, 2009 How are you accessing the variable in your application? You do realize you have to use the same interface the DLL provides, right? Link to comment Share on other sites More sharing options...
JRowe Posted October 23, 2009 Author Share Posted October 23, 2009 Ahh, k, I think I got it. I'd just added the new function without thought for what the application was expecting. I'll figure out how to fit it in correctly. Thanks very much. [center]However, like ninjas, cyber warriors operate in silence.AutoIt Chat Engine (+Chatbot) , Link Grammar for AutoIt , Simple Speech RecognitionArtificial Neural Networks UDF , Bayesian Networks UDF , Pattern Matching UDFTransparent PNG GUI Elements , Au3Irrlicht 2Advanced Mouse Events MonitorGrammar Database GeneratorTransitions & Tweening UDFPoker Hand Evaluator[/center] 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