Sign in to follow this  
Followers 0
AzKay

DllCall windivert.dll, "unable to use the DLL file"

9 posts in this topic

#1 ·  Posted (edited)

Hi, trying to call WinDivert.dll

#RequireAdmin

#cs
   handle = DivertOpen(argv[1], 0, priority, DIVERT_FLAG_SNIFF);

   HANDLE DivertOpen(
        __in const char *filter,
        __in DIVERT_LAYER layer,
        __in INT16 priority,
        __in UINT64 flags
    );
#ce

$dllWinDivert = DllOpen("WinDivert.dll")
$hWinDivert = DllCall($dllWinDivert, "handle", "DivertOpen", "char*", "true", "struct", 0, "uint16", 0, "uint64", 0)
If @error Then MsgBox(0, "", @error)
DllClose($dllWinDivert)

I'm getting an "1 unable to use the DLL file" error at the DllCall().

If I play around with the types, I'll get "bad parameter" errors, so I'm assuming the ones I've used are at least "close", else would it not give a bad param error?

Any ideas? Thanks.

Edited by AzKay

# MY LOVE FOR YOU... IS LIKE A TRUCK- #

Share this post


Link to post
Share on other sites



Use 'str' instead of char*.


Programming today is a race between software engineers striving to
build bigger and better idiot-proof programs, and the Universe
trying to produce bigger and better idiots.
So far, the Universe is winning.

Share this post


Link to post
Share on other sites

Your DLLCall should be using the return from your DLLOpen, not the variable you're assigning the result of the call to.


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Use 'str' instead of char*.

 

That gives me a @error 5, bad parameter error

 

Your DLLCall should be using the return from your DLLOpen, not the variable you're assigning the result of the call to.

Do you mean the $hWinDivert? That was a typo, meant $dllWinDivert

Edited by AzKay

# MY LOVE FOR YOU... IS LIKE A TRUCK- #

Share this post


Link to post
Share on other sites

Global $hDLLWinDivert = DllOpen("WinDivert.dll")

Global $aWinDivert = DllCall($hDLLWinDivert, "handle:cdecl", "DivertOpen", "str", "true", "ptr", 0, "short", 0, "UINT64", 0)
If @error Then
    MsgBox(0, "Error", @error)
    DllClose($hDLLWinDivert)
    Exit
EndIf

MsgBox(0,"Result", $aWinDivert[0])

Programming today is a race between software engineers striving to
build bigger and better idiot-proof programs, and the Universe
trying to produce bigger and better idiots.
So far, the Universe is winning.

Share this post


Link to post
Share on other sites

Doesn't seem to get past the DllCall with that, exits right after(?) it, if I MsgBox() after it it just exits without calling it


# MY LOVE FOR YOU... IS LIKE A TRUCK- #

Share this post


Link to post
Share on other sites

For me it works, both x86 und x64. Be sure to use the right version of dllwith the right compiled script (x86, x64).


Programming today is a race between software engineers striving to
build bigger and better idiot-proof programs, and the Universe
trying to produce bigger and better idiots.
So far, the Universe is winning.

Share this post


Link to post
Share on other sites

Tried with both, doesn't get past the DllCall with the x86, gives me the @error = 1 with the x64 dll


# MY LOVE FOR YOU... IS LIKE A TRUCK- #

Share this post


Link to post
Share on other sites

Hm, DllCall with x86 gave you an error with the x64 dll??? Of course!!


Programming today is a race between software engineers striving to
build bigger and better idiot-proof programs, and the Universe
trying to produce bigger and better idiots.
So far, the Universe is winning.

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
Sign in to follow this  
Followers 0