diff --git a/ctypes_generation/definitions/functions/file.txt b/ctypes_generation/definitions/functions/file.txt index 5ef391c..b74c02b 100644 --- a/ctypes_generation/definitions/functions/file.txt +++ b/ctypes_generation/definitions/functions/file.txt @@ -70,4 +70,21 @@ BOOL ReadDirectoryChangesExW( LPOVERLAPPED lpOverlapped, LPOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine, READ_DIRECTORY_NOTIFY_INFORMATION_CLASS ReadDirectoryNotifyInformationClass +); + +BOOL LockFile( + [in] HANDLE hFile, + [in] DWORD dwFileOffsetLow, + [in] DWORD dwFileOffsetHigh, + [in] DWORD nNumberOfBytesToLockLow, + [in] DWORD nNumberOfBytesToLockHigh +); + +BOOL LockFileEx( + [in] HANDLE hFile, + [in] DWORD dwFlags, + DWORD dwReserved, + [in] DWORD nNumberOfBytesToLockLow, + [in] DWORD nNumberOfBytesToLockHigh, + [in, out] LPOVERLAPPED lpOverlapped ); \ No newline at end of file diff --git a/ctypes_generation/definitions/structures/winstruct.txt b/ctypes_generation/definitions/structures/winstruct.txt index dda5ea8..efb9932 100644 --- a/ctypes_generation/definitions/structures/winstruct.txt +++ b/ctypes_generation/definitions/structures/winstruct.txt @@ -1542,7 +1542,13 @@ typedef struct _OSVERSIONINFOEXW { typedef struct _OVERLAPPED { ULONG_PTR Internal; ULONG_PTR InternalHigh; - PVOID Pointer; + union { + struct { + DWORD Offset; + DWORD OffsetHigh; + } _ANON_OVERLAPPED_DUMMYSTRUCTNAME; + PVOID Pointer; + } _ANON_OVERLAPPED_DUMMYUNIONNAME; HANDLE hEvent; } OVERLAPPED, *LPOVERLAPPED; diff --git a/windows/generated_def/meta.py b/windows/generated_def/meta.py index c5e573d..0a562c5 100644 --- a/windows/generated_def/meta.py +++ b/windows/generated_def/meta.py @@ -14409,6 +14409,8 @@ functions = set(['AccessCheck', 'LoadLibraryW', 'LoadResource', 'LocalFree', + 'LockFile', + 'LockFileEx', 'LockResource', 'LookupAccountNameA', 'LookupAccountNameW', diff --git a/windows/generated_def/winfuncs.py b/windows/generated_def/winfuncs.py index bea99e1..c5b8e7a 100644 --- a/windows/generated_def/winfuncs.py +++ b/windows/generated_def/winfuncs.py @@ -1210,6 +1210,16 @@ ReadDirectoryChangesWParams = ((1, 'hDirectory'), (1, 'lpBuffer'), (1, 'nBufferL ReadDirectoryChangesExWPrototype = WINFUNCTYPE(BOOL, HANDLE, LPVOID, DWORD, BOOL, DWORD, LPDWORD, LPOVERLAPPED, LPOVERLAPPED_COMPLETION_ROUTINE, READ_DIRECTORY_NOTIFY_INFORMATION_CLASS) ReadDirectoryChangesExWParams = ((1, 'hDirectory'), (1, 'lpBuffer'), (1, 'nBufferLength'), (1, 'bWatchSubtree'), (1, 'dwNotifyFilter'), (1, 'lpBytesReturned'), (1, 'lpOverlapped'), (1, 'lpCompletionRoutine'), (1, 'ReadDirectoryNotifyInformationClass')) +#def LockFile(hFile, dwFileOffsetLow, dwFileOffsetHigh, nNumberOfBytesToLockLow, nNumberOfBytesToLockHigh): +# return LockFile.ctypes_function(hFile, dwFileOffsetLow, dwFileOffsetHigh, nNumberOfBytesToLockLow, nNumberOfBytesToLockHigh) +LockFilePrototype = WINFUNCTYPE(BOOL, HANDLE, DWORD, DWORD, DWORD, DWORD) +LockFileParams = ((1, 'hFile'), (1, 'dwFileOffsetLow'), (1, 'dwFileOffsetHigh'), (1, 'nNumberOfBytesToLockLow'), (1, 'nNumberOfBytesToLockHigh')) + +#def LockFileEx(hFile, dwFlags, dwReserved, nNumberOfBytesToLockLow, nNumberOfBytesToLockHigh, lpOverlapped): +# return LockFileEx.ctypes_function(hFile, dwFlags, dwReserved, nNumberOfBytesToLockLow, nNumberOfBytesToLockHigh, lpOverlapped) +LockFileExPrototype = WINFUNCTYPE(BOOL, HANDLE, DWORD, DWORD, DWORD, DWORD, LPOVERLAPPED) +LockFileExParams = ((1, 'hFile'), (1, 'dwFlags'), (1, 'dwReserved'), (1, 'nNumberOfBytesToLockLow'), (1, 'nNumberOfBytesToLockHigh'), (1, 'lpOverlapped')) + #def HeapAlloc(hHeap, dwFlags, dwBytes): # return HeapAlloc.ctypes_function(hHeap, dwFlags, dwBytes) HeapAllocPrototype = WINFUNCTYPE(LPVOID, HANDLE, DWORD, SIZE_T) diff --git a/windows/generated_def/winstructs.py b/windows/generated_def/winstructs.py index beb195d..18317b5 100644 --- a/windows/generated_def/winstructs.py +++ b/windows/generated_def/winstructs.py @@ -5504,11 +5504,25 @@ OSVERSIONINFOEXW = _OSVERSIONINFOEXW POSVERSIONINFOEXW = POINTER(_OSVERSIONINFOEXW) RTL_OSVERSIONINFOEXW = _OSVERSIONINFOEXW +class _ANON__ANON__OVERLAPPED_SUB_UNION_1_SUB_STRUCTURE_1(Structure): + _fields_ = [ + ("Offset", DWORD), + ("OffsetHigh", DWORD), + ] + +class _ANON__OVERLAPPED_SUB_UNION_1(Union): + _anonymous_ = ("_ANON_OVERLAPPED_DUMMYSTRUCTNAME",) + _fields_ = [ + ("_ANON_OVERLAPPED_DUMMYSTRUCTNAME", _ANON__ANON__OVERLAPPED_SUB_UNION_1_SUB_STRUCTURE_1), + ("Pointer", PVOID), + ] + class _OVERLAPPED(Structure): + _anonymous_ = ("_ANON_OVERLAPPED_DUMMYUNIONNAME",) _fields_ = [ ("Internal", ULONG_PTR), ("InternalHigh", ULONG_PTR), - ("Pointer", PVOID), + ("_ANON_OVERLAPPED_DUMMYUNIONNAME", _ANON__OVERLAPPED_SUB_UNION_1), ("hEvent", HANDLE), ] LPOVERLAPPED = POINTER(_OVERLAPPED) diff --git a/windows/winproxy/apis/kernel32.py b/windows/winproxy/apis/kernel32.py index 25aa3a0..3001c2f 100644 --- a/windows/winproxy/apis/kernel32.py +++ b/windows/winproxy/apis/kernel32.py @@ -580,7 +580,13 @@ def ReadDirectoryChangesW(hDirectory, lpBuffer, nBufferLength, bWatchSubtree, dw def ReadDirectoryChangesExW(hDirectory, lpBuffer, nBufferLength, bWatchSubtree, dwNotifyFilter, lpBytesReturned, lpOverlapped, lpCompletionRoutine, ReadDirectoryNotifyInformationClass): return ReadDirectoryChangesExW.ctypes_function(hDirectory, lpBuffer, nBufferLength, bWatchSubtree, dwNotifyFilter, lpBytesReturned, lpOverlapped, lpCompletionRoutine, ReadDirectoryNotifyInformationClass) +@Kernel32Proxy() +def LockFile(hFile, dwFileOffsetLow, dwFileOffsetHigh, nNumberOfBytesToLockLow, nNumberOfBytesToLockHigh): + return LockFile.ctypes_function(hFile, dwFileOffsetLow, dwFileOffsetHigh, nNumberOfBytesToLockLow, nNumberOfBytesToLockHigh) +@Kernel32Proxy() +def LockFileEx(hFile, dwFlags, dwReserved, nNumberOfBytesToLockLow, nNumberOfBytesToLockHigh, lpOverlapped): + return LockFileEx.ctypes_function(hFile, dwFlags, dwReserved, nNumberOfBytesToLockLow, nNumberOfBytesToLockHigh, lpOverlapped) ## Tlhelp (snapshoot) diff --git a/windows/winproxy/apis/netapi32.py b/windows/winproxy/apis/netapi32.py index 516e015..fdbc16a 100644 --- a/windows/winproxy/apis/netapi32.py +++ b/windows/winproxy/apis/netapi32.py @@ -2,11 +2,11 @@ import ctypes import windows.generated_def as gdef from ..apiproxy import ApiProxy, NeededParameter -from ..error import succeed_on_zero +from ..error import result_is_error_code class NetApi32Proxy(ApiProxy): APIDLL = "netapi32" - default_error_check = staticmethod(succeed_on_zero) + default_error_check = staticmethod(result_is_error_code) @NetApi32Proxy()