ffalcinelli / pydivert

A Python binding for WinDivert driver

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Problem with driver loading

JazJazgot opened this issue · comments

Python 2.7.2 i386 on x64 machine, WinDivert 1.1.0

Traceback (most recent call last):
  File "C:\Projects\c9\test.py", line 3, in <module>
    handle = WinDivert(r"c:\Projects\c9\lib\i386\WinDivert.dll").open_handle(filter="false")
  File "C:\Python27\lib\site-packages\pydivert\windivert.py", line 45, in open_handle
    return Handle(self, filter, layer, priority, flags).open()
  File "C:\Python27\lib\site-packages\pydivert\decorators.py", line 32, in wrapper
    result = funct(instance, *args, **kwargs)
  File "C:\Python27\lib\site-packages\pydivert\windivert.py", line 244, in open
    self._handle = self._lib.DivertOpen(self._filter, self._layer, self._priority, self._flags)
ValueError: Procedure called with not enough arguments (20 bytes missing) or wrong calling convention

I've reproduced your error, and I'm almost ready to commit a fix for not having included the argtypes of methods. So far, you will most likely get one of the following errors:

  • WindowsError 1275: "This driver has been blocked from loading"
  • ImportError: DLL load failed: ... is not a valid Win32 application

The first in case you try to load the 32bit driver windows64 kernel will block it. As stated on WinDivert documentation:

You use the 32-bit WinDivert.sys for 32-bit Windows, and the 64-bit WinDivert.sys for 64-bit windows.

The second one if you try to load a 64bit dll from a 32bit interpreter.

Last but not least. Currently I'm using the WinDivert 1.0 version only. When 1.1 will be released I'll update the library to reflect changes.

Anyway, thank you a lot for reporting this and any other feedback will be more than welcome :)

I'm closing this issue hoping the fix has been useful to address the problems.

Seems like this commit on the WinDivert driver addresses this issue. So I'm reopening the issue to write some tests about it in future.

This should be fixed now.