[python-win32] DeviceIOControl calls respond with parameter incorrect

Tim Roberts timr at probo.com
Tue Feb 9 00:46:43 EST 2021


On Feb 8, 2021, at 8:23 PM, Doug Campbell <wdouglascampbell at hotmail.com> wrote:
> 
> In my python 2 script, I am trying to connect to the VeraCrypt device driver to get some information on my mounted volumes.

There are a lot of things to go wrong here.  You may be in for a long slog.  Your ctypes definition does look fundamentally correct.


> This is what I have so far.  I tried a bunch of different ideas on how to construct the input buffer for the DeviceIoControl function call but I keep getting the following response.
> 
> Traceback (most recent call last):
>   File "test.py", line 188, in <module>
>     info=win32file.DeviceIoControl(hDisk,VC_IOCTL_GET_VOLUME_PROPERTIES,b'x05x00x00x00' + (b'x00' * 702),65536)
> pywintypes.error: (87, 'DeviceIoControl', 'The parameter is incorrect.')

The last parameter is the size of the output buffer, and that does get passed to the driver.  It should be sizeof(VOLUME_PROPERTIES_STRUCT) which is, I believe, 1280.


> #info=win32file.DeviceIoControl(hDisk,VC_IOCTL_GET_VOLUME_PROPERTIES,struct.pack('ii520sQiiiiLLLLLQQiii66sL64sL',prop),17424)

Last should be 1280, I think.

> info=win32file.DeviceIoControl(hDisk,VC_IOCTL_GET_VOLUME_PROPERTIES,b'0x00' + b'x05x00x00x00' + b'x00' * 702),65536)

The first b’0x00’ is wrong; the first byte of the struct needs to be 5.
— 
Tim Roberts, timr at probo.com
Providenza & Boekelheide, Inc.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.python.org/pipermail/python-win32/attachments/20210208/626ce420/attachment.html>


More information about the python-win32 mailing list