Re: DeviceIOControl calls respond with parameter incorrect
Tim Roberts <[email protected]>
| Newsgroups | gmane.comp.python.windows |
|---|---|
| Message-ID | <[email protected]> |
On Feb 8, 2021, at 8:23 PM, Doug Campbell <[email protected]> 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, [email protected] Providenza & Boekelheide, Inc. _______________________________________________ python-win32 mailing list [email protected] https://mail.python.org/mailman/listinfo/python-win32