I try to use Python types to work with DLLs, but sometimes I encounter a problem when I try to call a function passed as a pointer to another function.
A bit of background ... I'm trying to create a userpace file system using Dokan (version 0.6.0). In a way, Dokan is mostly FUSE for Windows. I wrapped the dokan header file with ctypes (similar to pydokan ). This header file contains a definition for a function pointer that looks like this:
typedef int (WINAPI *PFillFindData) (PWIN32_FIND_DATAW, PDOKAN_FILE_INFO);
It also contains a prototype of another function.
int (DOKAN_CALLBACK *FindFilesWithPattern) (
LPCWSTR,
LPCWSTR,
PFillFindData,
PDOKAN_FILE_INFO);
The relevant ctypes definitions are as follows
PFillFindData = ctypes.WINFUNCTYPE(ctypes.c_int,
PWIN32_FIND_DATAW,
PDOKAN_FILE_INFO)
FindFilesWithPattern = ctypes.WINFUNCTYPE(ctypes.c_int,
ctypes.c_wchar_p,
ctypes.c_wchar_p,
PFillFindData,
PDOKAN_FILE_INFO)
(FindFilesWithPattern) FillFindData, . :
def FindFilesWithPattern(self,
FileName,
SearchPattern,
FillFindData,
DokanFileInfo):
if FileName == '\\':
File = WIN32_FIND_DATAW(FILE_ATTRIBUTE_NORMAL | FILE_ATTRIBUTE_READONLY,
FILETIME(1, 1),
FILETIME(1, 1),
FILETIME(1, 1),
0,
len(self.HelloWorldText),
0,
0,
'Hello_World.txt',
'Hello_~1.txt')
pFile = PWIN32_FIND_DATAW(File)
FillFindData(pFile, DokanFileInfo)
return 0
else:
return -ERROR_FILE_NOT_FOUND
:
Traceback (most recent call last):
File "_ctypes/callbacks.c", line 313, in 'calling callback function'
File "src/test.py", line 385, in FindFilesWithPattern
FillFindData(pFile, DokanFileInfo)
WindowsError: exception: access violation reading 0x0000000000000008
. , , . . , , . ( , , , , . , .)
, , , . , if , " ". , , , . , Heapy Meliae, , , Python 2.7 Windows 64-bit.
, 64- . , , , . , - Googling, , ctypes Win64. Dokan 64- . Python?
. .
. .
. python , (, PDOKAN_FILE_INFO). , , .