lvlrdka22 Posted June 6, 2011 Share Posted June 6, 2011 Search failed me... or maybe it's the other way around. I need some help on calling functions in atiadlxy.dll. It's mainly the initialization function that I can't get right . Here's the code in C# (Open Hardware Monitor): http://code.google.com/p/open-hardware-monitor/source/browse/trunk/Hardware/ATI/ADL.cs?r=214&spec=svn280 According to documentation lying around the web, I'm supposed to call ADL_Main_Control_Create to initialize it, ADL_Main_Control_Refresh to refresh the data, and ADL_Main_Control_Destroy to free, but I've tried a few times, and can't get the initialization to complete (always end up with "stopped working" etc.). Link to comment Share on other sites More sharing options...
lvlrdka22 Posted June 7, 2011 Author Share Posted June 7, 2011 Bump. Link to comment Share on other sites More sharing options...
lvlrdka22 Posted June 8, 2011 Author Share Posted June 8, 2011 Here's what I've thought of so far: $dll=dllopen(@systemdir & "\atiadlxy.dll") $handle=dllcallbackregister("allocatememory","int_ptr","int") $t=dllcall($dll,"int","ADL_Main_Control_Create","ptr",dllcallbackgetptr($handle),"int",0) dllcallbackfree($handle) func allocatememory($i) _memglobalalloc($i) endfunc But it doesn't work . Desperately looking for some assistance. Link to comment Share on other sites More sharing options...
lvlrdka22 Posted June 9, 2011 Author Share Posted June 9, 2011 Bump. Anyone? Link to comment Share on other sites More sharing options...
lvlrdka22 Posted June 11, 2011 Author Share Posted June 11, 2011 Bump Link to comment Share on other sites More sharing options...
JohnOne Posted June 11, 2011 Share Posted June 11, 2011 Well for a start, try adding some error checking to see what exactly is going wrong.If @error etc... for all the dll* functions you are using. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
lvlrdka22 Posted June 11, 2011 Author Share Posted June 11, 2011 Thing is, I need to start with the init (Main_Create) function. @error doesn't help, since it's the DLL itself (autoit has stopped responding, etc.). According to the source of Open Hardware Monitor (link in the first post), I think I'm supposed to pass in a memory-allocating function as an argument, but not sure how exactly it's done. Link to comment Share on other sites More sharing options...
JohnOne Posted June 11, 2011 Share Posted June 11, 2011 (edited) If you believe that the @error macro wont help you or other people who might help you, determine why you script is not working then I fear your thread will be pages of your own bumps in the end. Best of luck. EDIT: Are you sure you dllcallbackregister function takes a type as a parameter? Edited June 11, 2011 by JohnOne AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
trancexx Posted June 11, 2011 Share Posted June 11, 2011 And try changing the calling convention to cdecl. That is usually the thing that causes this kind of errors. Maybe even for callback too. ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
lvlrdka22 Posted June 12, 2011 Author Share Posted June 12, 2011 (edited) Relevant functions in the link I provided: public delegate int ADL_Adapter_NumberOfAdapters_GetDelegate( ref int numAdapters); private static ADL_Main_Control_CreateDelegate _ADL_Main_Control_Create; private static void CreateDelegates(string name) { int p = (int)System.Environment.OSVersion.Platform; if ((p == 4) || (p == 128)) dllName = name + ".so"; else dllName = name + ".dll"; GetDelegate("ADL_Main_Control_Create", out _ADL_Main_Control_Create); } public static int ADL_Main_Control_Create(int enumConnectedAdapters) { try { try { return _ADL_Main_Control_Create(Main_Memory_Alloc, enumConnectedAdapters); } catch { CreateDelegates("atiadlxy"); return _ADL_Main_Control_Create(Main_Memory_Alloc, enumConnectedAdapters); } } catch { return ADL.ADL_ERR; } } private delegate IntPtr ADL_Main_Memory_AllocDelegate(int size); private static IntPtr Main_Memory_Alloc(int size) { return Marshal.AllocHGlobal(size);; } In C++: void* __stdcall ADL::sADL_Main_Memory_Alloc (int iSize) { void* lpBuffer = malloc ( iSize ); return lpBuffer; } ADL::ADL() : ADL_Main_Control_Create(NULL) // Initialize ADL. if (ADL_OK != ADL_Main_Control_Create (sADL_Main_Memory_Alloc, 1)) { return false; } //header: typedef int ( *ADL_MAIN_CONTROL_CREATE ) (ADL_MAIN_MALLOC_CALLBACK callback, int iEnumConnectedAdapters); So yeah, the memory allocating function is passed by callback. Any ideas how I should be porting that to autoit? @error won't help, since it's crashing at the DLL inside the dllcall. And try changing the calling convention to cdecl. That is usually the thing that causes this kind of errors. Maybe even for callback too. Huh, that worked! Just needed to change the DLL call convention only, not the callback. Thank you so much! Edited June 12, 2011 by lvlrdka22 Link to comment Share on other sites More sharing options...
JohnOne Posted June 12, 2011 Share Posted June 12, 2011 I see, once again, I'm not an expert, but "void* __stdcall ADL::sADL_Main_Memory_Alloc (int iSize)" to me suggests that function takes one parameter as int (dont see any overloads). And in your call "$t=dllcall($dll,"int","ADL_Main_Control_Create","ptr",dllcallbackgetptr($handle),"int",0)"" you are passing it two, including a pointer type. I apologize if I'm missing something. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
lvlrdka22 Posted June 13, 2011 Author Share Posted June 13, 2011 I see, once again, I'm not an expert, but "void* __stdcall ADL::sADL_Main_Memory_Alloc (int iSize)" to me suggests that function takes one parameter as int (dont see any overloads). And in your call "$t=dllcall($dll,"int","ADL_Main_Control_Create","ptr",dllcallbackgetptr($handle),"int",0)"" you are passing it two, including a pointer type. I apologize if I'm missing something. This part ADL_Main_Control_Create (sADL_Main_Memory_Alloc, 1) is where it's calling the init function. sADL_Main_Memory_Alloc is just a memory-allocating function, that's passed by callback through ADL_Main_Control_Create, which takes 2 arguments. The first is the function pointer (obviously), and the second is just some int. 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