mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Fix device interface detail data not working on 32bit
This commit is contained in:
parent
8bdb39cb9e
commit
4b4da185c8
@ -13,6 +13,7 @@ from ctypes import (
|
|||||||
wstring_at, addressof, create_unicode_buffer, string_at, c_uint64 as QWORD)
|
wstring_at, addressof, create_unicode_buffer, string_at, c_uint64 as QWORD)
|
||||||
from ctypes.wintypes import DWORD, WORD, ULONG, LPCWSTR, HWND, BOOL, LPWSTR, UINT, BYTE, HANDLE
|
from ctypes.wintypes import DWORD, WORD, ULONG, LPCWSTR, HWND, BOOL, LPWSTR, UINT, BYTE, HANDLE
|
||||||
|
|
||||||
|
from calibre.constants import is64bit
|
||||||
from calibre.utils.winreg.lib import Key, HKEY_LOCAL_MACHINE
|
from calibre.utils.winreg.lib import Key, HKEY_LOCAL_MACHINE
|
||||||
|
|
||||||
# Data and function type definitions {{{
|
# Data and function type definitions {{{
|
||||||
@ -371,7 +372,9 @@ def get_device_interface_detail_data(dev_list, p_interface_data, buf=None):
|
|||||||
if buf is None:
|
if buf is None:
|
||||||
buf = create_string_buffer(512)
|
buf = create_string_buffer(512)
|
||||||
detail = cast(buf, PSP_DEVICE_INTERFACE_DETAIL_DATA)
|
detail = cast(buf, PSP_DEVICE_INTERFACE_DETAIL_DATA)
|
||||||
detail.contents.cbSize = sizeof(SP_DEVICE_INTERFACE_DETAIL_DATA)
|
# See http://stackoverflow.com/questions/10728644/properly-declare-sp-device-interface-detail-data-for-pinvoke
|
||||||
|
# for why cbSize needs to be hardcoded below
|
||||||
|
detail.contents.cbSize = 8 if is64bit else 6
|
||||||
required_size = DWORD(0)
|
required_size = DWORD(0)
|
||||||
devinfo = SP_DEVINFO_DATA()
|
devinfo = SP_DEVINFO_DATA()
|
||||||
devinfo.cbSize = sizeof(devinfo)
|
devinfo.cbSize = sizeof(devinfo)
|
||||||
@ -381,7 +384,7 @@ def get_device_interface_detail_data(dev_list, p_interface_data, buf=None):
|
|||||||
if err == ERROR_INSUFFICIENT_BUFFER:
|
if err == ERROR_INSUFFICIENT_BUFFER:
|
||||||
buf = create_string_buffer(required_size + 50)
|
buf = create_string_buffer(required_size + 50)
|
||||||
detail = cast(buf, PSP_DEVICE_INTERFACE_DETAIL_DATA)
|
detail = cast(buf, PSP_DEVICE_INTERFACE_DETAIL_DATA)
|
||||||
detail.contents.cbSize = sizeof(SP_DEVICE_INTERFACE_DETAIL_DATA)
|
detail.contents.cbSize = 8 if is64bit else 6
|
||||||
continue
|
continue
|
||||||
raise WinError(err)
|
raise WinError(err)
|
||||||
break
|
break
|
||||||
|
Loading…
x
Reference in New Issue
Block a user