Trolleule

[solved] DllCall on 64-Bit AutoIT Version not work properly

14 posts in this topic

#1 ·  Posted (edited)

Hey,

i'm working with a dll which comes with Windows 10 (Pro x64) called dismapi.dll, which is located under C:\Windows\system32\dismapi.dll.

I tested some of it's functions with my compiled script on Windows 10 (x86) and it worked properly, but when i run my script on my x64 system with

#AutoIt3Wrapper_UseX64=y

 directive set, it doesn't work anymore (AutoIT breaks on line 1255 in DISM.au3). Without this directive it works.

Is there something i have to change to get it work? Thanks for help...(You can use my attach. If you use WIndows 10, it will work directly, on Windows 8 you might have to adjust the dism api path ($ghdismapi) in DISM.au3. On Windows 7, you will need Windows ADK to get DISM.) _DLLStructDisplay.au3 is only for debug.

https://msdn.microsoft.com/de-de/library/windows/desktop/hh825837.aspx

 

Misc.au3

_DLLStructDisplay.au3

DismConstants.au3

DismExample.au3

DISM.au3

Edited by Trolleule

Share this post


Link to post
Share on other sites



AutoIT breaks on line 1255 in DISM.au3

Your description is very vague. What you you mean by "breaks"? Does it give an error message? Crash? Or ???

Also, this line is commented code. Post the section of code that is problematic so that we can see exactly which line the error is occurring.

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

sorry, it's line 1251. AutoIT crashes on this line, where i try to read the pointer in a array of WCHAR.

MsgBox(0, "ProductName", GetPCWSTR($tImageInfo_sub, "ProductName"))

 The function GetPCWSTR can be found in Misc.au3 and looks like:

Func GetPCWSTR(ByRef $struct, $sElementName) ; avoids memory access conflicts
    Local $char_struct
    Local $anz = 0 ; counter for signs
    Local $ptr = DllStructGetData($struct, $sElementName) ; ptr
    Do
        $char_struct = DllStructCreate("WCHAR", $ptr + $anz) ; get memory location
        $anz += 2
    Until DllStructGetData($char_struct, 1) = Chr(0) ; end of string
    Local $PCWSTR_struct = DllStructCreate("WCHAR[" & $anz / 2 & "]", $ptr) ; create struct with correct amount of bytes
    Local $PCWSTR = DllStructGetData($PCWSTR_struct, 1)
    _DISM_Delete($PCWSTR_struct) ; free resources
    Return $PCWSTR ; return string
EndFunc

The problem only occurs when i use 64-bit AutoIT and 64-bit dll version. I think some of the data types are not compatible with 64-bit anymore, although the first 6 elements are readable properly:

MsgBox(0, "ImageType", _DISM_GetImageType(DllStructGetData($tImageInfo_sub, "ImageType")))
            MsgBox(0, "ImageIndex", DllStructGetData($tImageInfo_sub, "ImageIndex"))
            MsgBox(0, "ImageName", GetPCWSTR($tImageInfo_sub, "ImageName"))
            MsgBox(0, "ImageDescription", GetPCWSTR($tImageInfo_sub, "ImageDescription"))
            MsgBox(0, "ImageSize", DllStructGetData($tImageInfo_sub, "ImageSize"))
            MsgBox(0, "Architecture", DllStructGetData($tImageInfo_sub, "Architecture"))
            MsgBox(0, "ProductName", GetPCWSTR($tImageInfo_sub, "ProductName")) ; autoit crashes

EDIT: The exact line where it crashes is in Misc.au3

$char_struct = DllStructCreate("WCHAR", $ptr + $anz) ; get memory location

, when i try to read the pointer of 

"ProductName" in DISM.au3 on line 1251.

I'm not able to read one char of this pointer :S

Edited by Trolleule

Share this post


Link to post
Share on other sites

Based on your latest post, it sounds like the issue isn't in the DLLCall like you originally suggested. What's the definition of $tImageInfo_sub?

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Local $tagDismImageInfo = "INT ImageType;UINT ImageIndex;PTR ImageName;PTR ImageDescription;UINT64 ImageSize;UINT Architecture;PTR ProductName;PTR EditionId;PTR InstallationType;" & _
                                 "PTR Hal;PTR ProductType;PTR ProductSuite;UINT MajorVersion;UINT MinorVersion;UINT Build;UINT SpBuild;UINT SpLevel;INT Bootable;PTR SystemRoot;" & _
                                 "PTR Language;UINT LanguageCount;UINT DefaultLanguageIndex;PTR CustomizedInfo"

Local $tImageInfo_sub = DllStructCreate($tagDismImageInfo, $pImageInfo)

My first expection was to change some of these data types... otherwise it might be more complicated :S

Perhaps you can test it. You only need Windows ADK + some .wim file. Thanks in advance!

EDIT: Try this DISM.au3, it's better to understand :) (i updated the DISM.au3 in my first post too)

DISM.au3

Edited by Trolleule

Share this post


Link to post
Share on other sites

Have you looked at this thread? It appears to work in both x32 and x64,

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

Sure :)

But DISM API is more powerfull! You can't delete packages with wimgapi.dll.

Edited by Trolleule

Share this post


Link to post
Share on other sites

A friend tested it in C++, the x64 dismapi.dll works properly.

Are there some debug techniques i can use to check what is wrong with pointers or a possibility to read the pointer byte by byte?

Share this post


Link to post
Share on other sites

Looking at the output from _DLLStructDisplay, it appears that the high / low orders are reversed for elements 7 - 11 and 19. Reverse the order and Autoit no longer crashes.

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

ui that sounds nice. What do you mean with reverse? ->

Local $tagDismImageInfo = "INT ImageType;UINT ImageIndex;PTR ImageName;PTR ImageDescription;UINT64 ImageSize;UINT Architecture;" & _
                              "PTR;SystemRoot;PTR ProductType;PTR Hal;PTR InstallationType;PTR EditionId;PTR ProductName;" & _
                              "PTR ProductSuite;UINT MajorVersion;UINT MinorVersion;UINT Build;UINT SpBuild;UINT SpLevel;INT Bootable;" & _
                              "PTR Language;UINT LanguageCount;UINT DefaultLanguageIndex;PTR CustomizedInfo"

instead of

Local $tagDismImageInfo = "INT ImageType;UINT ImageIndex;PTR ImageName;PTR ImageDescription;UINT64 ImageSize;UINT Architecture;" & _
                              "PTR ProductName;PTR EditionId;PTR InstallationType;PTR Hal;PTR ProductType;PTR ProductSuite;" & _
                              "UINT MajorVersion;UINT MinorVersion;UINT Build;UINT SpBuild;UINT SpLevel;INT Bootable;PTR SystemRoot;" & _
                              "PTR Language;UINT LanguageCount;UINT DefaultLanguageIndex;PTR CustomizedInfo"

?

Reversed:

reversed.png

Normal:

normal.png

Edited by Trolleule

Share this post


Link to post
Share on other sites

No, reverse the actual high / low order values. Here's how I did it:

MsgBox(0, "ProductName", GetPCWSTR($tImageInfo, "ProductName", True))
Func GetPCWSTR(ByRef $struct, $sElementName, $lSwap = False) ; avoids memory access conflicts
    Local $char_struct
    Local $anz = 0 ; counter for signs
    Local $ptr = DllStructGetData($struct, $sElementName) ; ptr

    If $lSwap Then
        $ptr = '0x' & hex(_WinAPI_LoDWord($ptr), 8) & hex(_WinAPI_HiDWord($ptr), 8)
    EndIf

    Do
        $char_struct = DllStructCreate("WCHAR", $ptr + $anz) ; get memory location
        $anz += 2
    Until DllStructGetData($char_struct, 1) = Chr(0) ; end of string
    Local $PCWSTR_struct = DllStructCreate("WCHAR[" & $anz / 2 & "]", $ptr) ; create struct with correct amount of bytes
    Local $PCWSTR = DllStructGetData($PCWSTR_struct, 1)
    _DISM_Delete($PCWSTR_struct) ; free resources
    Return $PCWSTR ; return string
EndFunc

You'll need to add "#include <WinAPIMisc.au3>" to Misc.au3.

 

Share this post


Link to post
Share on other sites

#12 ·  Posted (edited)

big thanks! Now i can read from pointer, but something is strange:

ConsoleWrite("ImageType: " & DllStructGetData($tImageInfo, "ImageType") & @CRLF) ; ok
ConsoleWrite("ImageIndex: " & DllStructGetData($tImageInfo, "ImageIndex") & @CRLF) ; ok
ConsoleWrite("ImageName: " & GetPCWSTR($tImageInfo, "ImageName") & @CRLF) ; ok
ConsoleWrite("ImageDescription: " & GetPCWSTR($tImageInfo, "ImageDescription") & @CRLF) ; ok
ConsoleWrite("ImageSize: " & DllStructGetData($tImageInfo, "ImageSize") & @CRLF) ; ok
ConsoleWrite("Architecture: " & DllStructGetData($tImageInfo, "Architecture") & @CRLF) ; ok
ConsoleWrite("ProductName: " & GetPCWSTR($tImageInfo, "ProductName", True) & @CRLF) ; x86: Betriebssystem Microsoft® Windows® x64: Professional
ConsoleWrite("EditionId: " & GetPCWSTR($tImageInfo, "EditionId", True) & @CRLF) ; x86: Professional x64: Client
ConsoleWrite("InstallationType: " & GetPCWSTR($tImageInfo, "InstallationType", True) & @CRLF) ; x86: Client x64:
ConsoleWrite("Hal: " & GetPCWSTR($tImageInfo, "Hal", True) & @CRLF) ; x86:  x64: WinNT
ConsoleWrite("ProductType: " & GetPCWSTR($tImageInfo, "ProductType", True) & @CRLF) ; x86: WinNT x64: Terminal Server
ConsoleWrite("ProductSuite: " & DLLStructGetData($tImageInfo, "ProductSuite") & @CRLF) ; x86: Terminal Server x64: 0x0000000A000000C8 (PCWSTR will crash AutoIT)
ConsoleWrite("MajorVersion: " & DllStructGetData($tImageInfo, "MajorVersion") & @CRLF) ; x86: 10 x64: 0
ConsoleWrite("MinorVersion: " & DllStructGetData($tImageInfo, "MinorVersion") & @CRLF) ; x86: 0 x64: 10586
ConsoleWrite("Build: " & DllStructGetData($tImageInfo, "Build") & @CRLF) ; x86: 10586 x64: 0
ConsoleWrite("SpBuild: " & DllStructGetData($tImageInfo, "SpBuild") & @CRLF) ; x86: 0 x64: 0
ConsoleWrite("SpLevel: " & DllStructGetData($tImageInfo, "SpLevel") & @CRLF) ; x86: 0 x64: 1
ConsoleWrite("Bootable: " & DllStructGetData($tImageInfo, "Bootable") & @CRLF) ; x86: 1 x64: -1950295936
ConsoleWrite("SystemRoot: " & GetPCWSTR($tImageInfo, "SystemRoot", True) & @CRLF) ; x86: WINDOWS x64: ??o
ConsoleWrite("Language: " & DllStructGetData($tImageInfo, "Language") & @CRLF) ; x86: ok x64: 0x000000010000006F
ConsoleWrite("LanguageCount: " & DllStructGetData($tImageInfo, "LanguageCount") & @CRLF) ; x86: 1 x64: 0
ConsoleWrite("DefaultLanguageIndex: " & DllStructGetData($tImageInfo, "DefaultLanguageIndex") & @CRLF) ; x86: 0 x64: 2291066752
ConsoleWrite("CustomizedInfo: " & DllStructGetData($tImageInfo, "CustomizedInfo") & @CRLF) ; x86: ok x64: 0x000000000000006F

the order is messy. "ProductName" keeps information of "EditionId" and so on, but i think if we can get the order right, the rest would be right too...

Do you know why this happens and do you have a solution?

 

EDIT:

I tested around and campe up with this:

Local $tagDismImageInfo = "INT ImageType;UINT ImageIndex;PTR ImageName;PTR ImageDescription;UINT64 ImageSize;" & _
                          "UINT Architecture;PTR EditionId;PTR InstallationType;" & _
                          "PTR Hal;PTR ProductType;PTR ProductSuite;UINT MajorVersion;UINT MinorVersion;" & _
                          "UINT Build;UINT SpBuild;UINT SpLevel;UINT Bootable;INT SystemRoot;" & _
                         "PTR Language;PTR LanguageCount;UINT DefaultLanguageIndex;UINT CustomizedInfo;PTR ProductName"

ConsoleWrite("ImageType: " & DllStructGetData($tImageInfo, "ImageType") & @CRLF)
ConsoleWrite("ImageIndex: " & DllStructGetData($tImageInfo, "ImageIndex") & @CRLF)
ConsoleWrite("ImageName: " & GetPCWSTR($tImageInfo, "ImageName") & @CRLF)
ConsoleWrite("ImageDescription: " & GetPCWSTR($tImageInfo, "ImageDescription") & @CRLF)
ConsoleWrite("ImageSize: " & DllStructGetData($tImageInfo, "ImageSize") & @CRLF)
ConsoleWrite("Architecture: " & DllStructGetData($tImageInfo, "Architecture") & @CRLF)
ConsoleWrite("ProductName: " & DllStructGetData($tImageInfo, "ProductName") & @CRLF)
ConsoleWrite("EditionId: " & GetPCWSTR($tImageInfo, "EditionId", True) & @CRLF)
ConsoleWrite("InstallationType: " & GetPCWSTR($tImageInfo, "InstallationType", True) & @CRLF)
ConsoleWrite("Hal: " & GetPCWSTR($tImageInfo, "Hal", True) & @CRLF)
ConsoleWrite("ProductType: " & GetPCWSTR($tImageInfo, "ProductType", True) & @CRLF)
ConsoleWrite("ProductSuite: " & GetPCWSTR($tImageInfo, "ProductSuite", True) & @CRLF)
ConsoleWrite("MajorVersion: " & DllStructGetData($tImageInfo, "MajorVersion") & @CRLF)
ConsoleWrite("MinorVersion: " & DllStructGetData($tImageInfo, "MinorVersion") & @CRLF)
ConsoleWrite("Build: " & DllStructGetData($tImageInfo, "Build") & @CRLF)
ConsoleWrite("SpBuild: " & DllStructGetData($tImageInfo, "SpBuild") & @CRLF)
ConsoleWrite("SpLevel: " & DllStructGetData($tImageInfo, "SpLevel") & @CRLF)
ConsoleWrite("Bootable: " & DllStructGetData($tImageInfo, "Bootable") & @CRLF)
ConsoleWrite("SystemRoot: " & DllStructGetData($tImageInfo, "SystemRoot") & @CRLF)
ConsoleWrite("Language: " & GetPCWSTR($tImageInfo, "Language", True) & @CRLF)
ConsoleWrite("LanguageCount: " & DllStructGetData($tImageInfo, "LanguageCount") & @CRLF)
ConsoleWrite("DefaultLanguageIndex: " & DllStructGetData($tImageInfo, "DefaultLanguageIndex") & @CRLF)
ConsoleWrite("CustomizedInfo: " & DllStructGetData($tImageInfo, "CustomizedInfo") & @CRLF)

You can see, the order is wrong, but this gives the best results...

Output:

ImageType: 0
ImageIndex: 1
ImageName: Windows 10 Pro Technical Preview
ImageDescription: Windows 10 Pro Technical Preview
ImageSize: 13298258120
Architecture: 9
EditionId: Professional
InstallationType: Client
Hal: 
ProductType: WinNT
ProductSuite: Terminal Server
MajorVersion: 224
MinorVersion: 10
Build: 0
SpBuild: 10586
SpLevel: 0
Bootable: 0
SystemRoot: 1
Language: ?°Ã
LanguageCount: 0x00000001000000E0
DefaultLanguageIndex: 0
CustomizedInfo: 572084256

Something is really strange :S

 

testing.png

Edited by Trolleule

Share this post


Link to post
Share on other sites

Fuck...i got it and i don't know why :D

I only add "align 4" to my struct, default is "align 8". Now it works properly and without Lo/Hi reverse.

$tagDismImageInfo = "align 4;INT ImageType;UINT ImageIndex;PTR ImageName;PTR ImageDescription;UINT64 ImageSize;" & _
                    "UINT Architecture;PTR ProductName;PTR EditionId;PTR InstallationType;" & _
                    "PTR Hal;PTR ProductType;PTR ProductSuite;UINT MajorVersion;UINT MinorVersion;UINT Build;UINT SpBuild;" & _
                    "UINT SpLevel;INT  Bootable;PTR SystemRoot;" & _
                    "PTR Language;UINT LanguageCount;UINT DefaultLanguageIndex;PTR CustomizedInfo"

Big thanks Danp2! I think i have to change the topic title to mark this as resolved right?

Share this post


Link to post
Share on other sites

Nice find! Glad you were able to figure out the proper solution.

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now

  • Similar Content

    • RTFC
      By RTFC
      Please answer me these questions three, ere the other side you see:
      Are you running a 64-bit machine with a 64-bit Windows operating system? Can your AutoIt scripts cope with having directive #AutoIt3Wrapper_UseX64=Y, and thus @AutoItX64=True? Are you sick and tired of seeing this error message?
      If you (like me) answered "YES" to all three questions, then the _HighMem library may ease your pain (the name commemorates a useful utility from the days when CPUs were still steam-powered). Forget about pathetic boot switches /3GB and /userva; in a full-fledged 64-bit environment, _HighMem can pre-allocate all available physical/virtual RAM you've got (or any smaller size you need), and manage individual allocations therein with four simple functions:
      _HighMem_StartUp( $nSize, $sUnit="GB" ) ; parse size of total region to pre-allocate, e.g. (10,"GB") _HighMem_Allocate( $nSize, $sUnit="B" ) ; returns $pOffset (new allocation's base address) _HighMem_Release( $pOffset ) ; existing allocations are identified by their offset (base address) _HighMem_CleanUp() ; close handles, release all pre-allocated memory Of course, existing AutoIt limitations remain in force (e.g., DllstructCreate() is still limited to 2 GB per call), but the maximum of 2-4 GB of virtual memory per Windows process can (under the right circumstances, in the proper environment) be circumvented. However, this is the first beta release, so glitches are likely, and performance may vary. In fact, it may not work at all for you (if you're running 32-bit, for example). And since this involves your own hardware, it's unlikely I would be able to reproduce your issues in my own work environment. Nevertheless, if you find obvious bugs or mistakes in the code, please do post. And if it works for you, that's also good to hear. My own motivation for developing it was to supercharge my matrix computing environment (Eigen4AutoIt), so it can handle matrices of any size that fit in machine RAM.
      The attached zip contains the library itself (HighMem.au3) and two test examples. HighMem_Test1 performs a dry run stress test of the allocation management system; it does not actually do any memory I/O. By contrast, HighMem_Test2 pre-allocates a 6 GB space, stores 3 x 2GB structs there, performs some basic I/O, and releases the allocations one by one. Obviously, for this to work you'll need at least that much free RAM to begin with (check with Task Manager -> Performance -> Memory if you're unsure). My own test environment has 16 GB of physical RAM, and runs W10Pro/64.
      EDIT: minor edits added to improve user experience (many more status messages if $_HighMem_Verbose=True)
      HighMem.v0.85.7z
      EDIT: from beta version 0.9, HighMem supports shared memory, including mutex negotiation.
       
      HighMem.v0.91.7z
    • luckyluke
      By luckyluke
      Hello,
      Im trying to read the output from CMD using Dllcall, here is my code:
      #include <WinAPI.au3> #include <array.au3> Global Const $STD_OUTPUT_HANDLE = -11 Global Const $_CONSOLE_SCREEN_BUFFER_INFO = _ "struct;int dwSizeX;" & _ "short dwSizeY;" & _ "short dwCursorPositionX;" & _ "short dwCursorPositionY;" & _ "short wAttributes;" & _ "short Left;" & _ "short Top;" & _ "short Right;" & _ "short Bottom;" & _ "short dwMaximumWindowSizeX;" & _ "short dwMaximumWindowSizeY;endstruct" $pCmd = Run( "cmd.exe" ) Sleep(1000) $hCmd = WinGetHandle("") ConsoleWrite('handle:' & $hCmd & @CRLF) $aRet = DllCall("kernel32.dll", "int", "AttachConsole", "dword", $pCmd) ;_ArrayDisplay($aRet) If $aRet[0] <> 0 Then $vHandle_data='' $vHandle='' $vHandle_data = DllStructCreate($_CONSOLE_SCREEN_BUFFER_INFO) ; Screen Buffer structure $aRet1 = DllCall("kernel32.dll", "hwnd", "GetStdHandle", "dword", $STD_OUTPUT_HANDLE) if not @error Then $vHandle = $aRet1[0] $aRet = DllCall("kernel32.dll", "int", "GetConsoleScreenBufferInfo", "hwnd", $vHandle, _ "ptr", $vHandle_data) MsgBox(0, '1',DllStructGetData($vHandle_data, 'dwSizeX') & _WinAPI_GetLastErrorMessage()) EndIf It did not work, i got the message 'The handle is invalid'. Please help?
      Thank you in advance!
    • MazeM
      By MazeM
      Hi
      here's another UDF for the serial port. It is very similar to CommAPI using kernel32.dll, but all code is packed into a single file without any dependencies, not even using WinAPI.au3. It differs from existing UDF that it doesn't allow a timeout when reading, instead it always returns immediately, either with the requested amount ob bytes read or with a failure status. And of course there is a function provided to query the amount of available bytes in the receive buffer. The reason behind this design decision: You can do 1000 other things in the main loop while checking from time to time if enough data bytes arrived. There's no point to block the program waiting for the serial port.
      It is currently a work-in-progress, as I didn't test all functions yet. The code was developed and tested on Windows 7 64 bit.  The ComUDF-Tests.au3 shows some tests and basic usage of the UDF. Maybe there's no reason to use this UDF, given the existence of the others UDFs, but I did it to get to know DllCall better - I use structs no only to pass but also to get data back (I don't use the array returned by DllCall to read that data, unless required). You're welcome to test it on older and newer Windows versions.
      Here's a list of the implemented functions:
      ; _ComListPorts ; _ComOpenPort ; _ComSetTimeouts ; _ComClosePort ; ; _ComSetBreak ; _ComClearBreak ; _ComGetInputcount ; _ComGetOutputcount ; _ComClearOutputBuffer ; _ComClearInputBuffer ; ; _ComSendByte ; _ComReadByte ; _ComSendBinary ; _ComReadBinary ; ; _ComSendChar ; _ComReadChar ; _ComSendCharArray ; _ComReadCharArray ; _ComSendString ; _ComReadString ; ; __ComClearCommError ; __PurgeComm Maze
       
      ComUDF.au3
      ComUDF-Tests.au3
    • astrionn
      By astrionn
      So I had this Idea of creating a tooltip which shows me my ping.
      That itself was made quickly and I thought too add a couple features.
      I want the tooltip background to be a different color depending on the ping. (good ping is green, medium ping is yellow,...)
      So how do I color in a tooltip? google brought me to this: 
       
      where in the comments I found this:
      $s = "LOW" ToolTip($s, 0, 0, "Battery Information");, $icon) $H_TOOLTIP1 = WinGetHandle($s) DllCall("UxTheme.dll", "int", "SetWindowTheme", "hwnd", $H_TOOLTIP1, "wstr", "", "wstr", "") DllCall("user32.dll", "int", "SendMessage", "hwnd", $H_TOOLTIP1, "int", 1043, "int", 2552550, "int", 0) Sleep(1000) Which I then used in my code with different color codes... Trial and Error brought me these that I wanted to use:
       
      The Problem is if I loop through my code it only sets the color for the 1st loop and then sticks to it.
      The real problem is tho that I don't exactly understand the dllcalls... And I guess that's why it isn't working
      So if someone would be so awesome to explain to me how they work, or at least can give me a list of these parameters then I would really appreciate that and learn something new
      Obviously a solution to my problem is awesome aswell ^^
      I run this under Windows 8.1
      There is my code in a paste.
      https://pastebin.com/q525f7mS
    • Leo1906
      By Leo1906
      Hello Guys,
      once aggain I need your help on a DLL Topic
      I need to pass arguments to my function via a structure, because I am limited to only one argument that can be passed.
      But I don't think that thats so important.
      So here's my approach:
      C++ Code (just the important part):
      extern "C" { struct ParamStruct { const char* test1; const char* test2; const char* test3; int size; }; int testFunc(struct ParamStruct * params) { return params->size; } } And thats how I try to call the function using Autoit:
      Local $struct = "struct;char shapefile[128];char output[128];char filename[128];int size;endstruct" Local $tTest = DllStructCreate($struct) DllStructSetData($tTest, "test1", "Bla") DllStructSetData($tTest, "test2", "BlaBla") DllStructSetData($tTest, "test3", "BlaBlaBla") DllStructSetData($tTest, "size", 40) $dll = DLLOpen("myDLL.dll") $ret = DllCall($dll, "int:cdecl", "testFunc", "STRUCT*", DllStructGetPtr($tTest)) MsgBox(0, 0, $ret[0]) DllClose($dll) Just for testing I want the function to just return the integer value in the struct.
      But this aint working. I tested many things, but still I'm not able to get it running. I even don't know if the mistakes are in the C++ code or the Autoit code or both .. I'm not that skilled at C++ and also not that skilled at Autoit DLLCalls :-/
      I would really appreciate some help!
      Kind regards,
      leo