From 89fe39fadf4462ac8d9b8190af36a7ecfb56f218 Mon Sep 17 00:00:00 2001 From: Clement Rouault Date: Tue, 11 Jul 2017 18:42:51 +0200 Subject: [PATCH] Adding some ALPC struct/funcs --- ctypes_generation/definitions/winfunc.txt | 73 ++++ ctypes_generation/definitions/winstruct.txt | 96 +---- ctypes_generation/generate.py | 3 + windows/generated_def/__init__.py | 4 +- windows/generated_def/winfuncs.py | 52 ++- windows/generated_def/winstructs.py | 368 ++++++++++++++------ windows/winproxy.py | 26 ++ 7 files changed, 422 insertions(+), 200 deletions(-) diff --git a/ctypes_generation/definitions/winfunc.txt b/ctypes_generation/definitions/winfunc.txt index 7b80105..7dcc14f 100644 --- a/ctypes_generation/definitions/winfunc.txt +++ b/ctypes_generation/definitions/winfunc.txt @@ -948,6 +948,13 @@ NTSTATUS WINAPI NtAlpcCreatePort( _In_opt_ PALPC_PORT_ATTRIBUTES PortAttributes ); +NTSTATUS WINAPI NtAlpcQueryInformation( + _In_opt_ HANDLE PortHandle, + _In_ ALPC_PORT_INFORMATION_CLASS PortInformationClass, + _Inout_opt_ PVOID PortInformation, + _In_ ULONG Length, + _Out_opt_ PULONG ReturnLength +); NTSTATUS WINAPI NtAlpcConnectPort( _Out_ PHANDLE PortHandle, @@ -1013,6 +1020,72 @@ NTSTATUS WINAPI NtAlpcSendWaitReceivePort( _In_opt_ PLARGE_INTEGER Timeout ); +NTSTATUS WINAPI NtAlpcCreatePortSection( + _In_ HANDLE PortHandle, + _In_ ULONG Flags, + _In_opt_ HANDLE SectionHandle, + _In_ SIZE_T SectionSize, + _Out_ PALPC_HANDLE AlpcSectionHandle, + _Out_ PSIZE_T ActualSectionSize + ); + +NTSTATUS WINAPI NtAlpcDeletePortSection( + _In_ HANDLE PortHandle, + _Reserved_ ULONG Flags, + _In_ ALPC_HANDLE SectionHandle + ); + + + +NTSTATUS WINAPI NtAlpcCreateResourceReserve( + _In_ HANDLE PortHandle, + _Reserved_ ULONG Flags, + _In_ SIZE_T MessageSize, + _Out_ PALPC_HANDLE ResourceId + ); + + +NTSTATUS WINAPI NtAlpcDeleteResourceReserve( + _In_ HANDLE PortHandle, + _Reserved_ ULONG Flags, + _In_ ALPC_HANDLE ResourceId + ); + + +NTSTATUS WINAPI NtAlpcCreateSectionView( + _In_ HANDLE PortHandle, + _Reserved_ ULONG Flags, + _Inout_ PALPC_DATA_VIEW_ATTR ViewAttributes + ); + + +NTSTATUS WINAPI NtAlpcDeleteSectionView( + _In_ HANDLE PortHandle, + _Reserved_ ULONG Flags, + _In_ PVOID ViewBase + ); + + +NTSTATUS WINAPI NtAlpcCreateSecurityContext( + _In_ HANDLE PortHandle, + _Reserved_ ULONG Flags, + _Inout_ PALPC_SECURITY_ATTR SecurityAttribute + ); + + +NTSTATUS WINAPI NtAlpcDeleteSecurityContext( + _In_ HANDLE PortHandle, + _Reserved_ ULONG Flags, + _In_ ALPC_HANDLE ContextHandle + ); + + +NTSTATUS WINAPI NtAlpcRevokeSecurityContext( + _In_ HANDLE PortHandle, + _Reserved_ ULONG Flags, + _In_ ALPC_HANDLE ContextHandle + ); + INT WINAPI lstrcmpA( __in LPCSTR lpString1, diff --git a/ctypes_generation/definitions/winstruct.txt b/ctypes_generation/definitions/winstruct.txt index 9684849..dc952db 100644 --- a/ctypes_generation/definitions/winstruct.txt +++ b/ctypes_generation/definitions/winstruct.txt @@ -510,6 +510,8 @@ typedef enum NET_FW_RULE_DIRECTION_ { NET_FW_RULE_DIR_MAX = 3 } NET_FW_RULE_DIRECTION; + + typedef enum tag_WBEMSTATUS { WBEM_NO_ERROR = 0, WBEM_S_NO_ERROR = 0, @@ -2367,100 +2369,6 @@ typedef struct _SECURITY_QUALITY_OF_SERVICE { BOOLEAN EffectiveOnly; } SECURITY_QUALITY_OF_SERVICE, * PSECURITY_QUALITY_OF_SERVICE; -typedef struct _ALPC_PORT_ATTRIBUTES32 -{ - ULONG Flags; - SECURITY_QUALITY_OF_SERVICE SecurityQos; - SIZE_T MaxMessageLength; - SIZE_T MemoryBandwidth; - SIZE_T MaxPoolUsage; - SIZE_T MaxSectionSize; - SIZE_T MaxViewSize; - SIZE_T MaxTotalSectionSize; - ULONG DupObjectTypes; -} ALPC_PORT_ATTRIBUTES32, *PALPC_PORT_ATTRIBUTES32; - - -typedef struct _ALPC_PORT_ATTRIBUTES64 -{ - ULONG Flags; - SECURITY_QUALITY_OF_SERVICE SecurityQos; - SIZE_T MaxMessageLength; - SIZE_T MemoryBandwidth; - SIZE_T MaxPoolUsage; - SIZE_T MaxSectionSize; - SIZE_T MaxViewSize; - SIZE_T MaxTotalSectionSize; - ULONG DupObjectTypes; - ULONG Reserved; -} ALPC_PORT_ATTRIBUTES64, *PALPC_PORT_ATTRIBUTES64; - -typedef struct _ALPC_MESSAGE_ATTRIBUTES -{ - ULONG AllocatedAttributes; - ULONG ValidAttributes; -} ALPC_MESSAGE_ATTRIBUTES, *PALPC_MESSAGE_ATTRIBUTES; - - -typedef union _PORT_MESSAGE32_TMP_UNION -{ - ULONG ClientViewSize; - ULONG CallbackId; -} PORT_MESSAGE_TMP_UNION; - -typedef union _PORT_MESSAGE64_TMP_UNION -{ - ULONGLONG ClientViewSize; - ULONG CallbackId; -} PORT_MESSAGE_TMP_UNION; - - -typedef struct _PORT_MESSAGE_TMP_SUBSTRUCT_S1 -{ - CSHORT DataLength; - CSHORT TotalLength; -} _PORT_MESSAGE_TMP_SUBSTRUCT_S1; - - -typedef union _PORT_MESSAGE_TMP_UNION_U1 -{ - ULONG Length; - _PORT_MESSAGE_TMP_SUBSTRUCT_S1 s1; -} _PORT_MESSAGE_TMP_UNION_U1; - - -typedef struct _PORT_MESSAGE_TMP_SUBSTRUCT_S2 -{ - CSHORT Type; - CSHORT DataInfoOffset; -} _PORT_MESSAGE_TMP_SUBSTRUCT_S2; - - -typedef union _PORT_MESSAGE_TMP_UNION_U2 -{ - ULONG ZeroInit; - _PORT_MESSAGE_TMP_SUBSTRUCT_S2 s2; -} _PORT_MESSAGE_TMP_UNION_U2; - - -typedef struct _PORT_MESSAGE32 -{ - _PORT_MESSAGE_TMP_UNION_U1 u1; - _PORT_MESSAGE_TMP_UNION_U2 u2; - CLIENT_ID32 ClientId; - ULONG MessageId; - _PORT_MESSAGE32_TMP_UNION tmp_union; -} PORT_MESSAGE32, *PPORT_MESSAGE32; - -typedef struct _PORT_MESSAGE64 -{ - _PORT_MESSAGE_TMP_UNION_U1 u1; - _PORT_MESSAGE_TMP_UNION_U2 u2; - CLIENT_ID64 ClientId; - ULONG MessageId; - _PORT_MESSAGE64_TMP_UNION tmp_union; -} PORT_MESSAGE64, *PPORT_MESSAGE64; - typedef struct _SERVICE_STATUS { DWORD dwServiceType; diff --git a/ctypes_generation/generate.py b/ctypes_generation/generate.py index a6da456..ee8f913 100644 --- a/ctypes_generation/generate.py +++ b/ctypes_generation/generate.py @@ -83,6 +83,8 @@ TYPE_EQUIVALENCE = [ ('SC_HANDLE', 'HANDLE'), ('HCERTCHAINENGINE', 'HANDLE'), ('LPHANDLE', 'POINTER(HANDLE)'), + ('ALPC_HANDLE', 'HANDLE'), + ('PALPC_HANDLE', 'POINTER(ALPC_HANDLE)'), ('PHKEY', 'POINTER(HKEY)'), ('ACCESS_MASK', 'DWORD'), ('REGSAM', 'ACCESS_MASK'), @@ -728,6 +730,7 @@ defs_with_ntstatus.append_input_file(from_here("definitions\\windef_error.txt")) structs = StructGenerator(from_here("definitions\\winstruct.txt"), from_here(r"..\windows\generated_def\\winstructs.py"), dependances=[defs_with_ntstatus]) structs.append_input_file(from_here("definitions\\display_struct.txt")) structs.append_input_file(from_here("definitions\\winstruct_bits.txt")) +structs.append_input_file(from_here("definitions\\winstruct_alpc.txt")) functions = FuncGenerator(from_here("definitions\\winfunc.txt"), from_here(r"..\windows\generated_def\\winfuncs.py"), dependances=[structs]) functions.append_input_file(from_here("definitions\\wintrust_crypt_func.txt")) diff --git a/windows/generated_def/__init__.py b/windows/generated_def/__init__.py index 576bbcc..918a5af 100644 --- a/windows/generated_def/__init__.py +++ b/windows/generated_def/__init__.py @@ -39,8 +39,8 @@ else: winstructs.PALPC_PORT_ATTRIBUTES = winstructs.PALPC_PORT_ATTRIBUTES64 winstructs.ALPC_PORT_ATTRIBUTES = winstructs.ALPC_PORT_ATTRIBUTES64 - winstructs.PORT_MESSAGE64 = winstructs.PORT_MESSAGE64 - winstructs.PPORT_MESSAGE64 = winstructs.PPORT_MESSAGE64 + winstructs.PORT_MESSAGE = winstructs.PORT_MESSAGE64 + winstructs.PPORT_MESSAGE = winstructs.PPORT_MESSAGE64 from . import winfuncs diff --git a/windows/generated_def/winfuncs.py b/windows/generated_def/winfuncs.py index f04eec2..e87b25c 100644 --- a/windows/generated_def/winfuncs.py +++ b/windows/generated_def/winfuncs.py @@ -6,7 +6,7 @@ from ctypes.wintypes import * from winstructs import * -functions = ['ExitProcess', 'TerminateProcess', 'GetLastError', 'GetCurrentProcess', 'CreateFileA', 'CreateFileW', 'NtCreateFile', 'LdrLoadDll', 'NtQuerySystemInformation', 'NtQueryInformationProcess', 'NtQueryVirtualMemory', 'NtCreateThreadEx', 'NtQueryInformationThread', 'GetExitCodeThread', 'GetExitCodeProcess', 'VirtualAlloc', 'VirtualAllocEx', 'NtProtectVirtualMemory', 'VirtualFree', 'VirtualFreeEx', 'VirtualProtect', 'VirtualProtectEx', 'VirtualQuery', 'VirtualQueryEx', 'QueryWorkingSet', 'QueryWorkingSetEx', 'GetModuleFileNameA', 'GetModuleFileNameW', 'CreateThread', 'CreateRemoteThread', 'VirtualProtect', 'CreateProcessA', 'CreateProcessW', 'CreateProcessAsUserA', 'CreateProcessAsUserW', 'GetThreadContext', 'NtGetContextThread', 'SetThreadContext', 'NtSetContextThread', 'OpenThread', 'OpenProcess', 'CloseHandle', 'ReadProcessMemory', 'NtWow64ReadVirtualMemory64', 'NtReadVirtualMemory', 'WriteProcessMemory', 'NtWow64WriteVirtualMemory64', 'CreateToolhelp32Snapshot', 'Thread32First', 'Thread32Next', 'Process32First', 'Process32Next', 'Process32FirstW', 'Process32NextW', 'GetProcAddress', 'LoadLibraryA', 'LoadLibraryW', 'OpenProcessToken', 'OpenThreadToken', 'LookupPrivilegeValueA', 'LookupPrivilegeValueW', 'LookupPrivilegeNameA', 'LookupPrivilegeNameW', 'AdjustTokenPrivileges', 'FindResourceA', 'FindResourceW', 'SizeofResource', 'LoadResource', 'LockResource', 'GetVersionExA', 'GetVersionExW', 'GetVersion', 'GetCurrentThread', 'GetCurrentThreadId', 'GetCurrentProcessorNumber', 'AllocConsole', 'FreeConsole', 'GetStdHandle', 'SetStdHandle', 'SetThreadAffinityMask', 'ReadFile', 'WriteFile', 'GetExtendedTcpTable', 'GetExtendedUdpTable', 'SetTcpEntry', 'AddVectoredContinueHandler', 'AddVectoredExceptionHandler', 'TerminateThread', 'ExitThread', 'RemoveVectoredExceptionHandler', 'ResumeThread', 'SuspendThread', 'WaitForSingleObject', 'GetThreadId', 'LoadLibraryExA', 'LoadLibraryExW', 'SymInitialize', 'SymFromName', 'SymLoadModuleEx', 'SymSetOptions', 'SymGetTypeInfo', 'DeviceIoControl', 'GetTokenInformation', 'RegOpenKeyExA', 'RegOpenKeyExW', 'RegGetValueA', 'RegGetValueW', 'RegCloseKey', 'Wow64DisableWow64FsRedirection', 'Wow64RevertWow64FsRedirection', 'Wow64EnableWow64FsRedirection', 'Wow64GetThreadContext', 'SetConsoleCtrlHandler', 'WinVerifyTrust', 'GlobalAlloc', 'GlobalFree', 'GlobalUnlock', 'GlobalLock', 'OpenClipboard', 'EmptyClipboard', 'CloseClipboard', 'SetClipboardData', 'GetClipboardData', 'EnumClipboardFormats', 'GetClipboardFormatNameA', 'GetClipboardFormatNameW', 'WinVerifyTrust', 'OpenProcessToken', 'OpenThreadToken', 'GetTokenInformation', 'SetTokenInformation', 'GetSidIdentifierAuthority', 'GetSidSubAuthority', 'GetSidSubAuthorityCount', 'GetLengthSid', 'CreateWellKnownSid', 'DebugBreak', 'WaitForDebugEvent', 'ContinueDebugEvent', 'DebugActiveProcess', 'DebugActiveProcessStop', 'DebugSetProcessKillOnExit', 'DebugBreakProcess', 'GetProcessId', 'Wow64SetThreadContext', 'GetMappedFileNameW', 'GetMappedFileNameA', 'RtlInitString', 'RtlInitUnicodeString', 'RtlAnsiStringToUnicodeString', 'RtlDecompressBuffer', 'OpenEventA', 'OpenEventW', 'NtOpenEvent', 'NtAlpcCreatePort', 'NtAlpcConnectPort', 'NtAlpcConnectPortEx', 'NtAlpcAcceptConnectPort', 'AlpcInitializeMessageAttribute', 'AlpcGetMessageAttribute', 'NtAlpcSendWaitReceivePort', 'lstrcmpA', 'lstrcmpW', 'CreateFileMappingA', 'CreateFileMappingW', 'MapViewOfFile', 'OpenSCManagerA', 'OpenSCManagerW', 'CloseServiceHandle', 'EnumServicesStatusExA', 'EnumServicesStatusExW', 'StartServiceA', 'StartServiceW', 'OpenServiceA', 'OpenServiceW', 'EnumWindows', 'GetWindowTextA', 'GetWindowTextW', 'GetWindowModuleFileNameA', 'GetWindowModuleFileNameW', 'CryptCATAdminCalcHashFromFileHandle', 'CryptCATAdminEnumCatalogFromHash', 'CryptCATAdminAcquireContext', 'CryptCATCatalogInfoFromContext', 'CryptCATAdminReleaseCatalogContext', 'CryptCATAdminReleaseContext', 'GetLogicalDriveStringsA', 'GetLogicalDriveStringsW', 'GetVolumeInformationA', 'GetVolumeInformationW', 'GetVolumeNameForVolumeMountPointA', 'GetVolumeNameForVolumeMountPointW', 'GetDriveTypeA', 'GetDriveTypeW', 'QueryDosDeviceA', 'QueryDosDeviceW', 'NtQueryObject', 'DuplicateHandle', 'ZwDuplicateObject', 'GetModuleBaseNameA', 'GetModuleBaseNameW', 'GetProcessImageFileNameA', 'GetProcessImageFileNameW', 'GetFileVersionInfoA', 'GetFileVersionInfoW', 'GetFileVersionInfoSizeA', 'GetFileVersionInfoSizeW', 'VerQueryValueA', 'VerQueryValueW', 'GetSystemMetrics', 'GetComputerNameA', 'GetComputerNameW', 'LookupAccountSidA', 'LookupAccountSidW', 'CoInitializeEx', 'CoInitializeSecurity', 'CoCreateInstance', 'GetInterfaceInfo', 'GetIfTable', 'GetIpAddrTable', 'NtOpenDirectoryObject', 'NtQueryDirectoryObject', 'NtQuerySymbolicLinkObject', 'NtOpenSymbolicLinkObject', 'GetProcessTimes', 'GetShortPathNameA', 'GetShortPathNameW', 'GetLongPathNameA', 'GetLongPathNameW', 'GetProcessDEPPolicy', 'GetCursorPos', 'WindowFromPoint', 'GetWindowRect', 'GetNamedSecurityInfoA', 'GetNamedSecurityInfoW', 'GetSecurityInfo', 'ConvertStringSidToSidA', 'ConvertStringSidToSidW', 'ConvertSidToStringSidA', 'ConvertSidToStringSidW', 'LocalFree', 'RegQueryValueExA', 'RegQueryValueExW', 'ShellExecuteA', 'ShellExecuteW', 'InitializeProcThreadAttributeList', 'UpdateProcThreadAttribute', 'DeleteProcThreadAttributeList', 'MessageBoxA', 'MessageBoxW', 'CryptQueryObject', 'CryptMsgGetParam', 'CryptDecodeObject', 'CertFindCertificateInStore', 'CertGetNameStringA', 'CertGetNameStringW', 'CertGetCertificateChain', 'CertCreateSelfSignCertificate', 'CertStrToNameA', 'CertStrToNameW', 'CertOpenStore', 'CertAddCertificateContextToStore', 'PFXExportCertStoreEx', 'PFXImportCertStore', 'CryptGenKey', 'CryptDestroyKey', 'CryptAcquireContextA', 'CryptAcquireContextW', 'CryptReleaseContext', 'CryptExportKey', 'CertGetCertificateContextProperty', 'CertEnumCertificateContextProperties', 'CryptEncryptMessage', 'CryptDecryptMessage', 'CryptAcquireCertificatePrivateKey', 'CertDuplicateCertificateContext', 'CertEnumCertificatesInStore', 'CryptEncodeObjectEx', 'CertCreateCertificateContext', 'CertCompareCertificate'] +functions = ['ExitProcess', 'TerminateProcess', 'GetLastError', 'GetCurrentProcess', 'CreateFileA', 'CreateFileW', 'NtCreateFile', 'LdrLoadDll', 'NtQuerySystemInformation', 'NtQueryInformationProcess', 'NtQueryVirtualMemory', 'NtCreateThreadEx', 'NtQueryInformationThread', 'GetExitCodeThread', 'GetExitCodeProcess', 'VirtualAlloc', 'VirtualAllocEx', 'NtProtectVirtualMemory', 'VirtualFree', 'VirtualFreeEx', 'VirtualProtect', 'VirtualProtectEx', 'VirtualQuery', 'VirtualQueryEx', 'QueryWorkingSet', 'QueryWorkingSetEx', 'GetModuleFileNameA', 'GetModuleFileNameW', 'CreateThread', 'CreateRemoteThread', 'VirtualProtect', 'CreateProcessA', 'CreateProcessW', 'CreateProcessAsUserA', 'CreateProcessAsUserW', 'GetThreadContext', 'NtGetContextThread', 'SetThreadContext', 'NtSetContextThread', 'OpenThread', 'OpenProcess', 'CloseHandle', 'ReadProcessMemory', 'NtWow64ReadVirtualMemory64', 'NtReadVirtualMemory', 'WriteProcessMemory', 'NtWow64WriteVirtualMemory64', 'CreateToolhelp32Snapshot', 'Thread32First', 'Thread32Next', 'Process32First', 'Process32Next', 'Process32FirstW', 'Process32NextW', 'GetProcAddress', 'LoadLibraryA', 'LoadLibraryW', 'OpenProcessToken', 'OpenThreadToken', 'LookupPrivilegeValueA', 'LookupPrivilegeValueW', 'LookupPrivilegeNameA', 'LookupPrivilegeNameW', 'AdjustTokenPrivileges', 'FindResourceA', 'FindResourceW', 'SizeofResource', 'LoadResource', 'LockResource', 'GetVersionExA', 'GetVersionExW', 'GetVersion', 'GetCurrentThread', 'GetCurrentThreadId', 'GetCurrentProcessorNumber', 'AllocConsole', 'FreeConsole', 'GetStdHandle', 'SetStdHandle', 'SetThreadAffinityMask', 'ReadFile', 'WriteFile', 'GetExtendedTcpTable', 'GetExtendedUdpTable', 'SetTcpEntry', 'AddVectoredContinueHandler', 'AddVectoredExceptionHandler', 'TerminateThread', 'ExitThread', 'RemoveVectoredExceptionHandler', 'ResumeThread', 'SuspendThread', 'WaitForSingleObject', 'GetThreadId', 'LoadLibraryExA', 'LoadLibraryExW', 'SymInitialize', 'SymFromName', 'SymLoadModuleEx', 'SymSetOptions', 'SymGetTypeInfo', 'DeviceIoControl', 'GetTokenInformation', 'RegOpenKeyExA', 'RegOpenKeyExW', 'RegGetValueA', 'RegGetValueW', 'RegCloseKey', 'Wow64DisableWow64FsRedirection', 'Wow64RevertWow64FsRedirection', 'Wow64EnableWow64FsRedirection', 'Wow64GetThreadContext', 'SetConsoleCtrlHandler', 'WinVerifyTrust', 'GlobalAlloc', 'GlobalFree', 'GlobalUnlock', 'GlobalLock', 'OpenClipboard', 'EmptyClipboard', 'CloseClipboard', 'SetClipboardData', 'GetClipboardData', 'EnumClipboardFormats', 'GetClipboardFormatNameA', 'GetClipboardFormatNameW', 'WinVerifyTrust', 'OpenProcessToken', 'OpenThreadToken', 'GetTokenInformation', 'SetTokenInformation', 'GetSidIdentifierAuthority', 'GetSidSubAuthority', 'GetSidSubAuthorityCount', 'GetLengthSid', 'CreateWellKnownSid', 'DebugBreak', 'WaitForDebugEvent', 'ContinueDebugEvent', 'DebugActiveProcess', 'DebugActiveProcessStop', 'DebugSetProcessKillOnExit', 'DebugBreakProcess', 'GetProcessId', 'Wow64SetThreadContext', 'GetMappedFileNameW', 'GetMappedFileNameA', 'RtlInitString', 'RtlInitUnicodeString', 'RtlAnsiStringToUnicodeString', 'RtlDecompressBuffer', 'OpenEventA', 'OpenEventW', 'NtOpenEvent', 'NtAlpcCreatePort', 'NtAlpcQueryInformation', 'NtAlpcConnectPort', 'NtAlpcConnectPortEx', 'NtAlpcAcceptConnectPort', 'AlpcInitializeMessageAttribute', 'AlpcGetMessageAttribute', 'NtAlpcSendWaitReceivePort', 'NtAlpcCreatePortSection', 'NtAlpcDeletePortSection', 'NtAlpcCreateResourceReserve', 'NtAlpcDeleteResourceReserve', 'NtAlpcCreateSectionView', 'NtAlpcDeleteSectionView', 'NtAlpcCreateSecurityContext', 'NtAlpcDeleteSecurityContext', 'NtAlpcRevokeSecurityContext', 'lstrcmpA', 'lstrcmpW', 'CreateFileMappingA', 'CreateFileMappingW', 'MapViewOfFile', 'OpenSCManagerA', 'OpenSCManagerW', 'CloseServiceHandle', 'EnumServicesStatusExA', 'EnumServicesStatusExW', 'StartServiceA', 'StartServiceW', 'OpenServiceA', 'OpenServiceW', 'EnumWindows', 'GetWindowTextA', 'GetWindowTextW', 'GetWindowModuleFileNameA', 'GetWindowModuleFileNameW', 'CryptCATAdminCalcHashFromFileHandle', 'CryptCATAdminEnumCatalogFromHash', 'CryptCATAdminAcquireContext', 'CryptCATCatalogInfoFromContext', 'CryptCATAdminReleaseCatalogContext', 'CryptCATAdminReleaseContext', 'GetLogicalDriveStringsA', 'GetLogicalDriveStringsW', 'GetVolumeInformationA', 'GetVolumeInformationW', 'GetVolumeNameForVolumeMountPointA', 'GetVolumeNameForVolumeMountPointW', 'GetDriveTypeA', 'GetDriveTypeW', 'QueryDosDeviceA', 'QueryDosDeviceW', 'NtQueryObject', 'DuplicateHandle', 'ZwDuplicateObject', 'GetModuleBaseNameA', 'GetModuleBaseNameW', 'GetProcessImageFileNameA', 'GetProcessImageFileNameW', 'GetFileVersionInfoA', 'GetFileVersionInfoW', 'GetFileVersionInfoSizeA', 'GetFileVersionInfoSizeW', 'VerQueryValueA', 'VerQueryValueW', 'GetSystemMetrics', 'GetComputerNameA', 'GetComputerNameW', 'LookupAccountSidA', 'LookupAccountSidW', 'CoInitializeEx', 'CoInitializeSecurity', 'CoCreateInstance', 'GetInterfaceInfo', 'GetIfTable', 'GetIpAddrTable', 'NtOpenDirectoryObject', 'NtQueryDirectoryObject', 'NtQuerySymbolicLinkObject', 'NtOpenSymbolicLinkObject', 'GetProcessTimes', 'GetShortPathNameA', 'GetShortPathNameW', 'GetLongPathNameA', 'GetLongPathNameW', 'GetProcessDEPPolicy', 'GetCursorPos', 'WindowFromPoint', 'GetWindowRect', 'GetNamedSecurityInfoA', 'GetNamedSecurityInfoW', 'GetSecurityInfo', 'ConvertStringSidToSidA', 'ConvertStringSidToSidW', 'ConvertSidToStringSidA', 'ConvertSidToStringSidW', 'LocalFree', 'RegQueryValueExA', 'RegQueryValueExW', 'ShellExecuteA', 'ShellExecuteW', 'InitializeProcThreadAttributeList', 'UpdateProcThreadAttribute', 'DeleteProcThreadAttributeList', 'MessageBoxA', 'MessageBoxW', 'CryptQueryObject', 'CryptMsgGetParam', 'CryptDecodeObject', 'CertFindCertificateInStore', 'CertGetNameStringA', 'CertGetNameStringW', 'CertGetCertificateChain', 'CertCreateSelfSignCertificate', 'CertStrToNameA', 'CertStrToNameW', 'CertOpenStore', 'CertAddCertificateContextToStore', 'PFXExportCertStoreEx', 'PFXImportCertStore', 'CryptGenKey', 'CryptDestroyKey', 'CryptAcquireContextA', 'CryptAcquireContextW', 'CryptReleaseContext', 'CryptExportKey', 'CertGetCertificateContextProperty', 'CertEnumCertificateContextProperties', 'CryptEncryptMessage', 'CryptDecryptMessage', 'CryptAcquireCertificatePrivateKey', 'CertDuplicateCertificateContext', 'CertEnumCertificatesInStore', 'CryptEncodeObjectEx', 'CertCreateCertificateContext', 'CertCompareCertificate'] #def ExitProcess(uExitCode): @@ -784,6 +784,11 @@ NtOpenEventParams = ((1, 'EventHandle'), (1, 'DesiredAccess'), (1, 'ObjectAttrib NtAlpcCreatePortPrototype = WINFUNCTYPE(NTSTATUS, PHANDLE, POBJECT_ATTRIBUTES, PALPC_PORT_ATTRIBUTES) NtAlpcCreatePortParams = ((1, 'PortHandle'), (1, 'ObjectAttributes'), (1, 'PortAttributes')) +#def NtAlpcQueryInformation(PortHandle, PortInformationClass, PortInformation, Length, ReturnLength): +# return NtAlpcQueryInformation.ctypes_function(PortHandle, PortInformationClass, PortInformation, Length, ReturnLength) +NtAlpcQueryInformationPrototype = WINFUNCTYPE(NTSTATUS, HANDLE, ALPC_PORT_INFORMATION_CLASS, PVOID, ULONG, PULONG) +NtAlpcQueryInformationParams = ((1, 'PortHandle'), (1, 'PortInformationClass'), (1, 'PortInformation'), (1, 'Length'), (1, 'ReturnLength')) + #def NtAlpcConnectPort(PortHandle, PortName, ObjectAttributes, PortAttributes, Flags, RequiredServerSid, ConnectionMessage, BufferLength, OutMessageAttributes, InMessageAttributes, Timeout): # return NtAlpcConnectPort.ctypes_function(PortHandle, PortName, ObjectAttributes, PortAttributes, Flags, RequiredServerSid, ConnectionMessage, BufferLength, OutMessageAttributes, InMessageAttributes, Timeout) NtAlpcConnectPortPrototype = WINFUNCTYPE(NTSTATUS, PHANDLE, PUNICODE_STRING, POBJECT_ATTRIBUTES, PALPC_PORT_ATTRIBUTES, ULONG, PSID, PPORT_MESSAGE, PULONG, PALPC_MESSAGE_ATTRIBUTES, PALPC_MESSAGE_ATTRIBUTES, PLARGE_INTEGER) @@ -814,6 +819,51 @@ AlpcGetMessageAttributeParams = ((1, 'Buffer'), (1, 'AttributeFlag')) NtAlpcSendWaitReceivePortPrototype = WINFUNCTYPE(NTSTATUS, HANDLE, ULONG, PPORT_MESSAGE, PALPC_MESSAGE_ATTRIBUTES, PPORT_MESSAGE, PSIZE_T, PALPC_MESSAGE_ATTRIBUTES, PLARGE_INTEGER) NtAlpcSendWaitReceivePortParams = ((1, 'PortHandle'), (1, 'Flags'), (1, 'SendMessage'), (1, 'SendMessageAttributes'), (1, 'ReceiveMessage'), (1, 'BufferLength'), (1, 'ReceiveMessageAttributes'), (1, 'Timeout')) +#def NtAlpcCreatePortSection(PortHandle, Flags, SectionHandle, SectionSize, AlpcSectionHandle, ActualSectionSize): +# return NtAlpcCreatePortSection.ctypes_function(PortHandle, Flags, SectionHandle, SectionSize, AlpcSectionHandle, ActualSectionSize) +NtAlpcCreatePortSectionPrototype = WINFUNCTYPE(NTSTATUS, HANDLE, ULONG, HANDLE, SIZE_T, PALPC_HANDLE, PSIZE_T) +NtAlpcCreatePortSectionParams = ((1, 'PortHandle'), (1, 'Flags'), (1, 'SectionHandle'), (1, 'SectionSize'), (1, 'AlpcSectionHandle'), (1, 'ActualSectionSize')) + +#def NtAlpcDeletePortSection(PortHandle, Flags, SectionHandle): +# return NtAlpcDeletePortSection.ctypes_function(PortHandle, Flags, SectionHandle) +NtAlpcDeletePortSectionPrototype = WINFUNCTYPE(NTSTATUS, HANDLE, ULONG, ALPC_HANDLE) +NtAlpcDeletePortSectionParams = ((1, 'PortHandle'), (1, 'Flags'), (1, 'SectionHandle')) + +#def NtAlpcCreateResourceReserve(PortHandle, Flags, MessageSize, ResourceId): +# return NtAlpcCreateResourceReserve.ctypes_function(PortHandle, Flags, MessageSize, ResourceId) +NtAlpcCreateResourceReservePrototype = WINFUNCTYPE(NTSTATUS, HANDLE, ULONG, SIZE_T, PALPC_HANDLE) +NtAlpcCreateResourceReserveParams = ((1, 'PortHandle'), (1, 'Flags'), (1, 'MessageSize'), (1, 'ResourceId')) + +#def NtAlpcDeleteResourceReserve(PortHandle, Flags, ResourceId): +# return NtAlpcDeleteResourceReserve.ctypes_function(PortHandle, Flags, ResourceId) +NtAlpcDeleteResourceReservePrototype = WINFUNCTYPE(NTSTATUS, HANDLE, ULONG, ALPC_HANDLE) +NtAlpcDeleteResourceReserveParams = ((1, 'PortHandle'), (1, 'Flags'), (1, 'ResourceId')) + +#def NtAlpcCreateSectionView(PortHandle, Flags, ViewAttributes): +# return NtAlpcCreateSectionView.ctypes_function(PortHandle, Flags, ViewAttributes) +NtAlpcCreateSectionViewPrototype = WINFUNCTYPE(NTSTATUS, HANDLE, ULONG, PALPC_DATA_VIEW_ATTR) +NtAlpcCreateSectionViewParams = ((1, 'PortHandle'), (1, 'Flags'), (1, 'ViewAttributes')) + +#def NtAlpcDeleteSectionView(PortHandle, Flags, ViewBase): +# return NtAlpcDeleteSectionView.ctypes_function(PortHandle, Flags, ViewBase) +NtAlpcDeleteSectionViewPrototype = WINFUNCTYPE(NTSTATUS, HANDLE, ULONG, PVOID) +NtAlpcDeleteSectionViewParams = ((1, 'PortHandle'), (1, 'Flags'), (1, 'ViewBase')) + +#def NtAlpcCreateSecurityContext(PortHandle, Flags, SecurityAttribute): +# return NtAlpcCreateSecurityContext.ctypes_function(PortHandle, Flags, SecurityAttribute) +NtAlpcCreateSecurityContextPrototype = WINFUNCTYPE(NTSTATUS, HANDLE, ULONG, PALPC_SECURITY_ATTR) +NtAlpcCreateSecurityContextParams = ((1, 'PortHandle'), (1, 'Flags'), (1, 'SecurityAttribute')) + +#def NtAlpcDeleteSecurityContext(PortHandle, Flags, ContextHandle): +# return NtAlpcDeleteSecurityContext.ctypes_function(PortHandle, Flags, ContextHandle) +NtAlpcDeleteSecurityContextPrototype = WINFUNCTYPE(NTSTATUS, HANDLE, ULONG, ALPC_HANDLE) +NtAlpcDeleteSecurityContextParams = ((1, 'PortHandle'), (1, 'Flags'), (1, 'ContextHandle')) + +#def NtAlpcRevokeSecurityContext(PortHandle, Flags, ContextHandle): +# return NtAlpcRevokeSecurityContext.ctypes_function(PortHandle, Flags, ContextHandle) +NtAlpcRevokeSecurityContextPrototype = WINFUNCTYPE(NTSTATUS, HANDLE, ULONG, ALPC_HANDLE) +NtAlpcRevokeSecurityContextParams = ((1, 'PortHandle'), (1, 'Flags'), (1, 'ContextHandle')) + #def lstrcmpA(lpString1, lpString2): # return lstrcmpA.ctypes_function(lpString1, lpString2) lstrcmpAPrototype = WINFUNCTYPE(INT, LPCSTR, LPCSTR) diff --git a/windows/generated_def/winstructs.py b/windows/generated_def/winstructs.py index 5f0a4c9..2531033 100644 --- a/windows/generated_def/winstructs.py +++ b/windows/generated_def/winstructs.py @@ -67,6 +67,8 @@ HBITMAP = HANDLE SC_HANDLE = HANDLE HCERTCHAINENGINE = HANDLE LPHANDLE = POINTER(HANDLE) +ALPC_HANDLE = HANDLE +PALPC_HANDLE = POINTER(ALPC_HANDLE) PHKEY = POINTER(HKEY) ACCESS_MASK = DWORD REGSAM = ACCESS_MASK @@ -1001,6 +1003,25 @@ class _BG_JOB_TYPE(EnumType): BG_JOB_TYPE = _BG_JOB_TYPE +AlpcBasicInformation = EnumValue("_ALPC_PORT_INFORMATION_CLASS", "AlpcBasicInformation", 0x0) +AlpcPortInformation = EnumValue("_ALPC_PORT_INFORMATION_CLASS", "AlpcPortInformation", 0x1) +AlpcAssociateCompletionPortInformation = EnumValue("_ALPC_PORT_INFORMATION_CLASS", "AlpcAssociateCompletionPortInformation", 0x2) +AlpcConnectedSIDInformation = EnumValue("_ALPC_PORT_INFORMATION_CLASS", "AlpcConnectedSIDInformation", 0x3) +AlpcServerInformation = EnumValue("_ALPC_PORT_INFORMATION_CLASS", "AlpcServerInformation", 0x4) +AlpcMessageZoneInformation = EnumValue("_ALPC_PORT_INFORMATION_CLASS", "AlpcMessageZoneInformation", 0x5) +AlpcRegisterCompletionListInformation = EnumValue("_ALPC_PORT_INFORMATION_CLASS", "AlpcRegisterCompletionListInformation", 0x6) +AlpcUnregisterCompletionListInformation = EnumValue("_ALPC_PORT_INFORMATION_CLASS", "AlpcUnregisterCompletionListInformation", 0x7) +AlpcAdjustCompletionListConcurrencyCountInformation = EnumValue("_ALPC_PORT_INFORMATION_CLASS", "AlpcAdjustCompletionListConcurrencyCountInformation", 0x8) +AlpcRegisterCallbackInformation = EnumValue("_ALPC_PORT_INFORMATION_CLASS", "AlpcRegisterCallbackInformation", 0x9) +AlpcCompletionListRundownInformation = EnumValue("_ALPC_PORT_INFORMATION_CLASS", "AlpcCompletionListRundownInformation", 0xa) +AlpcWaitForPortReferences = EnumValue("_ALPC_PORT_INFORMATION_CLASS", "AlpcWaitForPortReferences", 0xb) +MaxAlpcPortInfoClass = EnumValue("_ALPC_PORT_INFORMATION_CLASS", "MaxAlpcPortInfoClass", 0xc) +class _ALPC_PORT_INFORMATION_CLASS(EnumType): + values = [AlpcBasicInformation, AlpcPortInformation, AlpcAssociateCompletionPortInformation, AlpcConnectedSIDInformation, AlpcServerInformation, AlpcMessageZoneInformation, AlpcRegisterCompletionListInformation, AlpcUnregisterCompletionListInformation, AlpcAdjustCompletionListConcurrencyCountInformation, AlpcRegisterCallbackInformation, AlpcCompletionListRundownInformation, AlpcWaitForPortReferences, MaxAlpcPortInfoClass] + mapper = {x:x for x in values} +ALPC_PORT_INFORMATION_CLASS = _ALPC_PORT_INFORMATION_CLASS + + # Self referencing struct tricks class _LIST_ENTRY(Structure): pass PLIST_ENTRY = POINTER(_LIST_ENTRY) @@ -3024,109 +3045,6 @@ class _SECURITY_QUALITY_OF_SERVICE(Structure): PSECURITY_QUALITY_OF_SERVICE = POINTER(_SECURITY_QUALITY_OF_SERVICE) SECURITY_QUALITY_OF_SERVICE = _SECURITY_QUALITY_OF_SERVICE -class _ALPC_PORT_ATTRIBUTES32(Structure): - _fields_ = [ - ("Flags", ULONG), - ("SecurityQos", SECURITY_QUALITY_OF_SERVICE), - ("MaxMessageLength", SIZE_T), - ("MemoryBandwidth", SIZE_T), - ("MaxPoolUsage", SIZE_T), - ("MaxSectionSize", SIZE_T), - ("MaxViewSize", SIZE_T), - ("MaxTotalSectionSize", SIZE_T), - ("DupObjectTypes", ULONG), - ] -PALPC_PORT_ATTRIBUTES32 = POINTER(_ALPC_PORT_ATTRIBUTES32) -ALPC_PORT_ATTRIBUTES32 = _ALPC_PORT_ATTRIBUTES32 - -class _ALPC_PORT_ATTRIBUTES64(Structure): - _fields_ = [ - ("Flags", ULONG), - ("SecurityQos", SECURITY_QUALITY_OF_SERVICE), - ("MaxMessageLength", SIZE_T), - ("MemoryBandwidth", SIZE_T), - ("MaxPoolUsage", SIZE_T), - ("MaxSectionSize", SIZE_T), - ("MaxViewSize", SIZE_T), - ("MaxTotalSectionSize", SIZE_T), - ("DupObjectTypes", ULONG), - ("Reserved", ULONG), - ] -ALPC_PORT_ATTRIBUTES64 = _ALPC_PORT_ATTRIBUTES64 -PALPC_PORT_ATTRIBUTES64 = POINTER(_ALPC_PORT_ATTRIBUTES64) - -class _ALPC_MESSAGE_ATTRIBUTES(Structure): - _fields_ = [ - ("AllocatedAttributes", ULONG), - ("ValidAttributes", ULONG), - ] -ALPC_MESSAGE_ATTRIBUTES = _ALPC_MESSAGE_ATTRIBUTES -PALPC_MESSAGE_ATTRIBUTES = POINTER(_ALPC_MESSAGE_ATTRIBUTES) - -class _PORT_MESSAGE32_TMP_UNION(Union): - _fields_ = [ - ("ClientViewSize", ULONG), - ("CallbackId", ULONG), - ] -PORT_MESSAGE_TMP_UNION = _PORT_MESSAGE32_TMP_UNION - -class _PORT_MESSAGE64_TMP_UNION(Union): - _fields_ = [ - ("ClientViewSize", ULONGLONG), - ("CallbackId", ULONG), - ] -PORT_MESSAGE_TMP_UNION = _PORT_MESSAGE64_TMP_UNION - -class _PORT_MESSAGE_TMP_SUBSTRUCT_S1(Structure): - _fields_ = [ - ("DataLength", CSHORT), - ("TotalLength", CSHORT), - ] -_PORT_MESSAGE_TMP_SUBSTRUCT_S1 = _PORT_MESSAGE_TMP_SUBSTRUCT_S1 - -class _PORT_MESSAGE_TMP_UNION_U1(Union): - _fields_ = [ - ("Length", ULONG), - ("s1", _PORT_MESSAGE_TMP_SUBSTRUCT_S1), - ] -_PORT_MESSAGE_TMP_UNION_U1 = _PORT_MESSAGE_TMP_UNION_U1 - -class _PORT_MESSAGE_TMP_SUBSTRUCT_S2(Structure): - _fields_ = [ - ("Type", CSHORT), - ("DataInfoOffset", CSHORT), - ] -_PORT_MESSAGE_TMP_SUBSTRUCT_S2 = _PORT_MESSAGE_TMP_SUBSTRUCT_S2 - -class _PORT_MESSAGE_TMP_UNION_U2(Union): - _fields_ = [ - ("ZeroInit", ULONG), - ("s2", _PORT_MESSAGE_TMP_SUBSTRUCT_S2), - ] -_PORT_MESSAGE_TMP_UNION_U2 = _PORT_MESSAGE_TMP_UNION_U2 - -class _PORT_MESSAGE32(Structure): - _fields_ = [ - ("u1", _PORT_MESSAGE_TMP_UNION_U1), - ("u2", _PORT_MESSAGE_TMP_UNION_U2), - ("ClientId", CLIENT_ID32), - ("MessageId", ULONG), - ("tmp_union", _PORT_MESSAGE32_TMP_UNION), - ] -PORT_MESSAGE32 = _PORT_MESSAGE32 -PPORT_MESSAGE32 = POINTER(_PORT_MESSAGE32) - -class _PORT_MESSAGE64(Structure): - _fields_ = [ - ("u1", _PORT_MESSAGE_TMP_UNION_U1), - ("u2", _PORT_MESSAGE_TMP_UNION_U2), - ("ClientId", CLIENT_ID64), - ("MessageId", ULONG), - ("tmp_union", _PORT_MESSAGE64_TMP_UNION), - ] -PPORT_MESSAGE64 = POINTER(_PORT_MESSAGE64) -PORT_MESSAGE64 = _PORT_MESSAGE64 - class _SERVICE_STATUS(Structure): _fields_ = [ ("dwServiceType", DWORD), @@ -3949,3 +3867,247 @@ class _BG_JOB_TIMES(Structure): ("TransferCompletionTime", FILETIME), ] BG_JOB_TIMES = _BG_JOB_TIMES + +class _ALPC_PORT_ATTRIBUTES32(Structure): + _fields_ = [ + ("Flags", ULONG), + ("SecurityQos", SECURITY_QUALITY_OF_SERVICE), + ("MaxMessageLength", SIZE_T), + ("MemoryBandwidth", SIZE_T), + ("MaxPoolUsage", SIZE_T), + ("MaxSectionSize", SIZE_T), + ("MaxViewSize", SIZE_T), + ("MaxTotalSectionSize", SIZE_T), + ("DupObjectTypes", ULONG), + ] +PALPC_PORT_ATTRIBUTES32 = POINTER(_ALPC_PORT_ATTRIBUTES32) +ALPC_PORT_ATTRIBUTES32 = _ALPC_PORT_ATTRIBUTES32 + +class _ALPC_PORT_ATTRIBUTES64(Structure): + _fields_ = [ + ("Flags", ULONG), + ("SecurityQos", SECURITY_QUALITY_OF_SERVICE), + ("MaxMessageLength", SIZE_T), + ("MemoryBandwidth", SIZE_T), + ("MaxPoolUsage", SIZE_T), + ("MaxSectionSize", SIZE_T), + ("MaxViewSize", SIZE_T), + ("MaxTotalSectionSize", SIZE_T), + ("DupObjectTypes", ULONG), + ("Reserved", ULONG), + ] +ALPC_PORT_ATTRIBUTES64 = _ALPC_PORT_ATTRIBUTES64 +PALPC_PORT_ATTRIBUTES64 = POINTER(_ALPC_PORT_ATTRIBUTES64) + +class _ALPC_MESSAGE_ATTRIBUTES(Structure): + _fields_ = [ + ("AllocatedAttributes", ULONG), + ("ValidAttributes", ULONG), + ] +ALPC_MESSAGE_ATTRIBUTES = _ALPC_MESSAGE_ATTRIBUTES +PALPC_MESSAGE_ATTRIBUTES = POINTER(_ALPC_MESSAGE_ATTRIBUTES) + +class _PORT_MESSAGE32_TMP_UNION(Union): + _fields_ = [ + ("ClientViewSize", ULONG), + ("CallbackId", ULONG), + ] +PORT_MESSAGE_TMP_UNION = _PORT_MESSAGE32_TMP_UNION + +class _PORT_MESSAGE64_TMP_UNION(Union): + _fields_ = [ + ("ClientViewSize", ULONGLONG), + ("CallbackId", ULONG), + ] +PORT_MESSAGE_TMP_UNION = _PORT_MESSAGE64_TMP_UNION + +class _PORT_MESSAGE_TMP_SUBSTRUCT_S1(Structure): + _fields_ = [ + ("DataLength", CSHORT), + ("TotalLength", CSHORT), + ] +_PORT_MESSAGE_TMP_SUBSTRUCT_S1 = _PORT_MESSAGE_TMP_SUBSTRUCT_S1 + +class _PORT_MESSAGE_TMP_UNION_U1(Union): + _fields_ = [ + ("Length", ULONG), + ("s1", _PORT_MESSAGE_TMP_SUBSTRUCT_S1), + ] +_PORT_MESSAGE_TMP_UNION_U1 = _PORT_MESSAGE_TMP_UNION_U1 + +class _PORT_MESSAGE_TMP_SUBSTRUCT_S2(Structure): + _fields_ = [ + ("Type", CSHORT), + ("DataInfoOffset", CSHORT), + ] +_PORT_MESSAGE_TMP_SUBSTRUCT_S2 = _PORT_MESSAGE_TMP_SUBSTRUCT_S2 + +class _PORT_MESSAGE_TMP_UNION_U2(Union): + _fields_ = [ + ("ZeroInit", ULONG), + ("s2", _PORT_MESSAGE_TMP_SUBSTRUCT_S2), + ] +_PORT_MESSAGE_TMP_UNION_U2 = _PORT_MESSAGE_TMP_UNION_U2 + +class _PORT_MESSAGE32(Structure): + _fields_ = [ + ("u1", _PORT_MESSAGE_TMP_UNION_U1), + ("u2", _PORT_MESSAGE_TMP_UNION_U2), + ("ClientId", CLIENT_ID32), + ("MessageId", ULONG), + ("tmp_union", _PORT_MESSAGE32_TMP_UNION), + ] +PORT_MESSAGE32 = _PORT_MESSAGE32 +PPORT_MESSAGE32 = POINTER(_PORT_MESSAGE32) + +class _PORT_MESSAGE64(Structure): + _fields_ = [ + ("u1", _PORT_MESSAGE_TMP_UNION_U1), + ("u2", _PORT_MESSAGE_TMP_UNION_U2), + ("ClientId", CLIENT_ID64), + ("MessageId", ULONG), + ("tmp_union", _PORT_MESSAGE64_TMP_UNION), + ] +PPORT_MESSAGE64 = POINTER(_PORT_MESSAGE64) +PORT_MESSAGE64 = _PORT_MESSAGE64 + +class _ALPC_SERVER_INFORMATION_TMP_IN(Structure): + _fields_ = [ + ("ThreadHandle", HANDLE), + ] +ALPC_SERVER_INFORMATION_TMP_IN = _ALPC_SERVER_INFORMATION_TMP_IN + +class _ALPC_SERVER_INFORMATION_TMP_OUT(Structure): + _fields_ = [ + ("ThreadBlocked", BOOLEAN), + ("ConnectedProcessId", HANDLE), + ("ConnectionPortName", UNICODE_STRING), + ] +ALPC_SERVER_INFORMATION_TMP_OUT = _ALPC_SERVER_INFORMATION_TMP_OUT + +class ALPC_SERVER_INFORMATION(Union): + _fields_ = [ + ("In", ALPC_SERVER_INFORMATION_TMP_IN), + ("Out", ALPC_SERVER_INFORMATION_TMP_OUT), + ] +ALPC_SERVER_INFORMATION = ALPC_SERVER_INFORMATION + +class _ALPC_CONTEXT_ATTR(Structure): + _fields_ = [ + ("PortContext", PVOID), + ("MessageContext", PVOID), + ("Sequence", ULONG), + ("MessageId", ULONG), + ("CallbackId", ULONG), + ] +PALPC_CONTEXT_ATTR = POINTER(_ALPC_CONTEXT_ATTR) +ALPC_CONTEXT_ATTR = _ALPC_CONTEXT_ATTR + +class _ALPC_CONTEXT_ATTR32(Structure): + _fields_ = [ + ("PortContext", ULONG), + ("MessageContext", ULONG), + ("Sequence", ULONG), + ("MessageId", ULONG), + ("CallbackId", ULONG), + ] +ALPC_CONTEXT_ATTR32 = _ALPC_CONTEXT_ATTR32 +PALPC_CONTEXT_ATTR32 = POINTER(_ALPC_CONTEXT_ATTR32) + +class _ALPC_CONTEXT_ATTR64(Structure): + _fields_ = [ + ("PortContext", ULONGLONG), + ("MessageContext", ULONGLONG), + ("Sequence", ULONG), + ("MessageId", ULONG), + ("CallbackId", ULONG), + ] +ALPC_CONTEXT_ATTR64 = _ALPC_CONTEXT_ATTR64 +PALPC_CONTEXT_ATTR64 = POINTER(_ALPC_CONTEXT_ATTR64) + +class _ALPC_HANDLE_ATTR(Structure): + _fields_ = [ + ("Flags", ULONG), + ("Handle", HANDLE), + ("ObjectType", ULONG), + ("DesiredAccess", ACCESS_MASK), + ] +PALPC_HANDLE_ATTR = POINTER(_ALPC_HANDLE_ATTR) +ALPC_HANDLE_ATTR = _ALPC_HANDLE_ATTR + +class _ALPC_HANDLE_ATTR32(Structure): + _fields_ = [ + ("Flags", ULONG), + ("Handle", ULONG), + ("ObjectType", ULONG), + ("DesiredAccess", ACCESS_MASK), + ] +ALPC_HANDLE_ATTR32 = _ALPC_HANDLE_ATTR32 +PALPC_HANDLE_ATTR32 = POINTER(_ALPC_HANDLE_ATTR32) + +class _ALPC_HANDLE_ATTR64(Structure): + _fields_ = [ + ("Flags", ULONG), + ("Handle", ULONGLONG), + ("ObjectType", ULONG), + ("DesiredAccess", ACCESS_MASK), + ] +PALPC_HANDLE_ATTR64 = POINTER(_ALPC_HANDLE_ATTR64) +ALPC_HANDLE_ATTR64 = _ALPC_HANDLE_ATTR64 + +class _ALPC_SECURITY_ATTR(Structure): + _fields_ = [ + ("Flags", ULONG), + ("QoS", PSECURITY_QUALITY_OF_SERVICE), + ("ContextHandle", ALPC_HANDLE), + ] +PALPC_SECURITY_ATTR = POINTER(_ALPC_SECURITY_ATTR) +ALPC_SECURITY_ATTR = _ALPC_SECURITY_ATTR + +class _ALPC_SECURITY_ATTR32(Structure): + _fields_ = [ + ("Flags", ULONG), + ("QoS", ULONG), + ("ContextHandle", ULONG), + ] +ALPC_SECURITY_ATTR32 = _ALPC_SECURITY_ATTR32 +PALPC_SECURITY_ATTR32 = POINTER(_ALPC_SECURITY_ATTR32) + +class _ALPC_SECURITY_ATTR64(Structure): + _fields_ = [ + ("Flags", ULONGLONG), + ("QoS", ULONGLONG), + ("ContextHandle", ULONGLONG), + ] +PALPC_SECURITY_ATTR64 = POINTER(_ALPC_SECURITY_ATTR64) +ALPC_SECURITY_ATTR64 = _ALPC_SECURITY_ATTR64 + +class _ALPC_DATA_VIEW_ATTR(Structure): + _fields_ = [ + ("Flags", ULONG), + ("SectionHandle", ALPC_HANDLE), + ("ViewBase", PVOID), + ("ViewSize", PVOID), + ] +PALPC_DATA_VIEW_ATTR = POINTER(_ALPC_DATA_VIEW_ATTR) +ALPC_DATA_VIEW_ATTR = _ALPC_DATA_VIEW_ATTR + +class _ALPC_DATA_VIEW_ATTR32(Structure): + _fields_ = [ + ("Flags", ULONG), + ("SectionHandle", ULONG), + ("ViewBase", ULONG), + ("ViewSize", ULONG), + ] +PALPC_DATA_VIEW_ATTR32 = POINTER(_ALPC_DATA_VIEW_ATTR32) +ALPC_DATA_VIEW_ATTR32 = _ALPC_DATA_VIEW_ATTR32 + +class _ALPC_DATA_VIEW_ATTR64(Structure): + _fields_ = [ + ("Flags", ULONG), + ("SectionHandle", ULONGLONG), + ("ViewBase", ULONGLONG), + ("ViewSize", ULONGLONG), + ] +PALPC_DATA_VIEW_ATTR64 = POINTER(_ALPC_DATA_VIEW_ATTR64) +ALPC_DATA_VIEW_ATTR64 = _ALPC_DATA_VIEW_ATTR64 diff --git a/windows/winproxy.py b/windows/winproxy.py index cad8b40..ed8a78e 100644 --- a/windows/winproxy.py +++ b/windows/winproxy.py @@ -823,6 +823,12 @@ def NtAlpcConnectPortEx(PortHandle, ConnectionPortObjectAttributes, ClientPortOb def NtAlpcAcceptConnectPort(PortHandle, ConnectionPortHandle, Flags, ObjectAttributes, PortAttributes, PortContext, ConnectionRequest, ConnectionMessageAttributes, AcceptConnection): return NtAlpcAcceptConnectPort.ctypes_function(PortHandle, ConnectionPortHandle, Flags, ObjectAttributes, PortAttributes, PortContext, ConnectionRequest, ConnectionMessageAttributes, AcceptConnection) + +@NtdllProxy("NtAlpcQueryInformation", error_ntstatus) +def NtAlpcQueryInformation(PortHandle, PortInformationClass, PortInformation, Length, ReturnLength): + return NtAlpcQueryInformation.ctypes_function(PortHandle, PortInformationClass, PortInformation, Length, ReturnLength) + + @NtdllProxy("NtAlpcSendWaitReceivePort", error_ntstatus) def NtAlpcSendWaitReceivePort(PortHandle, Flags, SendMessage, SendMessageAttributes, ReceiveMessage, BufferLength, ReceiveMessageAttributes, Timeout): return NtAlpcSendWaitReceivePort.ctypes_function(PortHandle, Flags, SendMessage, SendMessageAttributes, ReceiveMessage, BufferLength, ReceiveMessageAttributes, Timeout) @@ -838,6 +844,26 @@ def AlpcGetMessageAttribute(Buffer, AttributeFlag): return AlpcGetMessageAttribute.ctypes_function(Buffer, AttributeFlag) +@NtdllProxy("NtAlpcCreatePortSection", error_ntstatus) +def NtAlpcCreatePortSection(PortHandle, Flags, SectionHandle, SectionSize, AlpcSectionHandle, ActualSectionSize): + return NtAlpcCreatePortSection.ctypes_function(PortHandle, Flags, SectionHandle, SectionSize, AlpcSectionHandle, ActualSectionSize) + + +@NtdllProxy("NtAlpcDeletePortSection", error_ntstatus) +def NtAlpcDeletePortSection(PortHandle, Flags, SectionHandle): + return NtAlpcDeletePortSection.ctypes_function(PortHandle, Flags, SectionHandle) + + +@NtdllProxy("NtAlpcCreateSectionView", error_ntstatus) +def NtAlpcCreateSectionView(PortHandle, Flags, ViewAttributes): + return NtAlpcCreateSectionView.ctypes_function(PortHandle, Flags, ViewAttributes) + + +@NtdllProxy("NtAlpcDeleteSectionView", error_ntstatus) +def NtAlpcDeleteSectionView(PortHandle, Flags, ViewBase): + return NtAlpcDeleteSectionView.ctypes_function(PortHandle, Flags, ViewBase) + + @NtdllProxy("NtOpenDirectoryObject", error_ntstatus) def NtOpenDirectoryObject(DirectoryHandle, DesiredAccess, ObjectAttributes): return NtOpenDirectoryObject.ctypes_function(DirectoryHandle, DesiredAccess, ObjectAttributes)