<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">On Feb 8, 2021, at 8:23 PM, Doug Campbell <<a href="mailto:wdouglascampbell@hotmail.com" class="">wdouglascampbell@hotmail.com</a>> wrote:<br class=""><div><blockquote type="cite" class=""><br class="Apple-interchange-newline"><div class=""><meta charset="UTF-8" class=""><div style="font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; font-family: Calibri, Helvetica, sans-serif; font-size: 12pt;" class="">In my python 2 script, I am trying to connect to the VeraCrypt device driver to get some information on my mounted volumes.</div></div></blockquote><div><br class=""></div>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.</div><div><br class=""></div><div><br class=""><blockquote type="cite" class=""><div style="font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; font-family: Calibri, Helvetica, sans-serif; font-size: 12pt;" class=""><span style="font-size: 12pt;" class="">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.</span></div><div style="font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; font-family: Calibri, Helvetica, sans-serif; font-size: 12pt;" class=""><br class=""></div><div style="font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; font-family: Calibri, Helvetica, sans-serif; font-size: 12pt;" class="">Traceback (most recent call last):<div class=""> File "test.py", line 188, in <module></div><div class=""> info=win32file.DeviceIoControl(hDisk,VC_IOCTL_GET_VOLUME_PROPERTIES,b'x05x00x00x00' + (b'x00' * 702),65536)</div>pywintypes.error: (87, 'DeviceIoControl', 'The parameter is incorrect.')<br class=""></div></blockquote><div><br class=""></div>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.</div><div><br class=""></div><div><br class=""><blockquote type="cite" class=""><div style="font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; font-family: Calibri, Helvetica, sans-serif; font-size: 12pt;" class=""><div class="">#info=win32file.DeviceIoControl(hDisk,VC_IOCTL_GET_VOLUME_PROPERTIES,struct.pack('ii520sQiiiiLLLLLQQiii66sL64sL',prop),17424)</div></div></blockquote><div><br class=""></div><div>Last should be 1280, I think.</div><br class=""><blockquote type="cite" class=""><div style="font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; font-family: Calibri, Helvetica, sans-serif; font-size: 12pt;" class=""><div class=""><span style="font-size: 12pt;" class="">info=win32file.DeviceIoControl(hDisk,VC_IOCTL_GET_VOLUME_PROPERTIES,b'0x00' + b'x05x00x00x00' + b'x00' * 702),65536)</span></div></div></blockquote><div><br class=""></div>The first b’0x00’ is wrong; the first byte of the struct needs to be 5.</div><div>— </div><div class="">Tim Roberts, <a href="mailto:timr@probo.com" class="">timr@probo.com</a><br class="">Providenza & Boekelheide, Inc.
</div>
<br class=""></body></html>