diff --git a/ctypes_generation/definitions/winfunc.txt b/ctypes_generation/definitions/winfunc.txt index 88bd015..036388d 100644 --- a/ctypes_generation/definitions/winfunc.txt +++ b/ctypes_generation/definitions/winfunc.txt @@ -1263,44 +1263,6 @@ UINT WINAPI GetWindowModuleFileNameW( __out LPWSTR pszFileName, __in UINT cchFileNameMax); - -BOOL WINAPI CryptCATAdminCalcHashFromFileHandle( - __in HANDLE hFile, - __inout DWORD *pcbHash, - _Out_opt_ BYTE *pbHash, - __in DWORD dwFlags); - -HCATINFO WINAPI CryptCATAdminEnumCatalogFromHash( - __in HCATADMIN hCatAdmin, - __in BYTE *pbHash, - __in DWORD cbHash, - __in DWORD dwFlags, - __inout HCATINFO *phPrevCatInfo); - -BOOL WINAPI CryptCATAdminAcquireContext( - _Out_ HCATADMIN *phCatAdmin, - _In_ GUID *pgSubsystem, - _In_ DWORD dwFlags -); - -BOOL WINAPI CryptCATCatalogInfoFromContext( - _In_ HCATINFO hCatInfo, - _Inout_ CATALOG_INFO *psCatInfo, - _In_ DWORD dwFlags -); - - -BOOL WINAPI CryptCATAdminReleaseCatalogContext( - _In_ HCATADMIN hCatAdmin, - _In_ HCATINFO hCatInfo, - _In_ DWORD dwFlags -); - -BOOL WINAPI CryptCATAdminReleaseContext( - _In_ HCATADMIN hCatAdmin, - _In_ DWORD dwFlags -); - DWORD WINAPI GetLogicalDriveStringsA( _In_ DWORD nBufferLength, _Out_ LPCSTR lpBuffer diff --git a/ctypes_generation/definitions/winfunc_crypto.txt b/ctypes_generation/definitions/winfunc_crypto.txt new file mode 100644 index 0000000..9bea6fa --- /dev/null +++ b/ctypes_generation/definitions/winfunc_crypto.txt @@ -0,0 +1,36 @@ +BOOL WINAPI CryptCATAdminCalcHashFromFileHandle( + __in HANDLE hFile, + __inout DWORD *pcbHash, + _Out_opt_ BYTE *pbHash, + __in DWORD dwFlags); + +HCATINFO WINAPI CryptCATAdminEnumCatalogFromHash( + __in HCATADMIN hCatAdmin, + __in BYTE *pbHash, + __in DWORD cbHash, + __in DWORD dwFlags, + __inout HCATINFO *phPrevCatInfo); + +BOOL WINAPI CryptCATAdminAcquireContext( + _Out_ HCATADMIN *phCatAdmin, + _In_ GUID *pgSubsystem, + _In_ DWORD dwFlags +); + +BOOL WINAPI CryptCATCatalogInfoFromContext( + _In_ HCATINFO hCatInfo, + _Inout_ CATALOG_INFO *psCatInfo, + _In_ DWORD dwFlags +); + + +BOOL WINAPI CryptCATAdminReleaseCatalogContext( + _In_ HCATADMIN hCatAdmin, + _In_ HCATINFO hCatInfo, + _In_ DWORD dwFlags +); + +BOOL WINAPI CryptCATAdminReleaseContext( + _In_ HCATADMIN hCatAdmin, + _In_ DWORD dwFlags +); \ No newline at end of file diff --git a/ctypes_generation/definitions/wintrust_crypt_func.txt b/ctypes_generation/definitions/winfunc_crypto_wintrust.txt similarity index 81% rename from ctypes_generation/definitions/wintrust_crypt_func.txt rename to ctypes_generation/definitions/winfunc_crypto_wintrust.txt index f8df654..10e82e4 100644 --- a/ctypes_generation/definitions/wintrust_crypt_func.txt +++ b/ctypes_generation/definitions/winfunc_crypto_wintrust.txt @@ -1,3 +1,73 @@ +BOOL WINAPI CryptCATAdminCalcHashFromFileHandle( + __in HANDLE hFile, + __inout DWORD *pcbHash, + _Out_opt_ BYTE *pbHash, + __in DWORD dwFlags); + +HCATINFO WINAPI CryptCATAdminEnumCatalogFromHash( + __in HCATADMIN hCatAdmin, + __in BYTE *pbHash, + __in DWORD cbHash, + __in DWORD dwFlags, + __inout HCATINFO *phPrevCatInfo); + +BOOL WINAPI CryptCATAdminAcquireContext( + _Out_ HCATADMIN *phCatAdmin, + _In_ GUID *pgSubsystem, + _In_ DWORD dwFlags +); + +BOOL WINAPI CryptCATCatalogInfoFromContext( + _In_ HCATINFO hCatInfo, + _Inout_ CATALOG_INFO *psCatInfo, + _In_ DWORD dwFlags +); + + +BOOL WINAPI CryptCATAdminReleaseCatalogContext( + _In_ HCATADMIN hCatAdmin, + _In_ HCATINFO hCatInfo, + _In_ DWORD dwFlags +); + +BOOL WINAPI CryptCATAdminReleaseContext( + _In_ HCATADMIN hCatAdmin, + _In_ DWORD dwFlags +); + +CRYPTCATATTRIBUTE* WINAPI CryptCATGetAttrInfo( + _In_ HANDLE hCatalog, + _In_ CRYPTCATMEMBER *pCatMember, + _In_ LPWSTR pwszReferenceTag +); + +CRYPTCATMEMBER* WINAPI CryptCATGetMemberInfo( + _In_ HANDLE hCatalog, + _In_ LPWSTR pwszReferenceTag +); + +CRYPTCATATTRIBUTE* WINAPI CryptCATGetAttrInfo( + _In_ HANDLE hCatalog, + _In_ CRYPTCATMEMBER *pCatMember, + _In_ LPWSTR pwszReferenceTag +); + +CRYPTCATATTRIBUTE* WINAPI CryptCATEnumerateCatAttr( + _In_ HANDLE hCatalog, + _In_ CRYPTCATATTRIBUTE *pPrevAttr +); + +CRYPTCATATTRIBUTE* WINAPI CryptCATEnumerateAttr( + _In_ HANDLE hCatalog, + _In_ CRYPTCATMEMBER *pCatMember, + _In_ CRYPTCATATTRIBUTE *pPrevAttr +); + +CRYPTCATMEMBER* WINAPI CryptCATEnumerateMember( + _In_ HANDLE hCatalog, + _In_ CRYPTCATMEMBER *pPrevMember +); + BOOL WINAPI CryptQueryObject( _In_ DWORD dwObjectType, _In_ VOID *pvObject, diff --git a/ctypes_generation/definitions/winstruct.txt b/ctypes_generation/definitions/winstruct.txt index 4a666b4..ba79763 100644 --- a/ctypes_generation/definitions/winstruct.txt +++ b/ctypes_generation/definitions/winstruct.txt @@ -2030,6 +2030,46 @@ CRYPT_DIGEST_BLOB, *PCRYPT_DIGEST_BLOB, CRYPT_DER_BLOB, *PCRYPT_DER_BLOB, CRYPT_ATTR_BLOB, *PCRYPT_ATTR_BLOB; +typedef struct CRYPTCATATTRIBUTE_ { + DWORD cbStruct; + LPWSTR pwszReferenceTag; + DWORD dwAttrTypeAndAction; + DWORD cbValue; + BYTE *pbValue; + DWORD dwReserved; +} CRYPTCATATTRIBUTE, *PCRYPTCATATTRIBUTE; + +typedef struct _CRYPT_ATTRIBUTE_TYPE_VALUE { + LPSTR pszObjId; + CRYPT_OBJID_BLOB Value; +} CRYPT_ATTRIBUTE_TYPE_VALUE, *PCRYPT_ATTRIBUTE_TYPE_VALUE; + +typedef struct _CRYPT_ALGORITHM_IDENTIFIER { + LPSTR pszObjId; + CRYPT_OBJID_BLOB Parameters; +} CRYPT_ALGORITHM_IDENTIFIER, *PCRYPT_ALGORITHM_IDENTIFIER; + +typedef struct SIP_INDIRECT_DATA_ +{ + CRYPT_ATTRIBUTE_TYPE_VALUE Data; + CRYPT_ALGORITHM_IDENTIFIER DigestAlgorithm; + CRYPT_HASH_BLOB Digest; +} SIP_INDIRECT_DATA, *PSIP_INDIRECT_DATA; + +typedef struct CRYPTCATMEMBER_ { + DWORD cbStruct; + LPWSTR pwszReferenceTag; + LPWSTR pwszFileName; + GUID gSubjectType; + DWORD fdwMemberFlags; + struct SIP_INDIRECT_DATA *pIndirectData; + DWORD dwCertVersion; + DWORD dwReserved; + HANDLE hReserved; + CRYPT_ATTR_BLOB sEncodedIndirectData; + CRYPT_ATTR_BLOB sEncodedMemberInfo; +} CRYPTCATMEMBER, *PCRYPTCATMEMBER; + typedef struct WINTRUST_FILE_INFO_ { DWORD cbStruct; @@ -2065,10 +2105,7 @@ typedef struct _CRYPT_ATTRIBUTES { } CRYPT_ATTRIBUTES, *PCRYPT_ATTRIBUTES; -typedef struct _CRYPT_ALGORITHM_IDENTIFIER { - LPSTR pszObjId; - CRYPT_OBJID_BLOB Parameters; -} CRYPT_ALGORITHM_IDENTIFIER, *PCRYPT_ALGORITHM_IDENTIFIER; + typedef struct _CMSG_SIGNER_INFO { DWORD dwVersion; diff --git a/ctypes_generation/func_parser.py b/ctypes_generation/func_parser.py index 96d0409..a692c9b 100644 --- a/ctypes_generation/func_parser.py +++ b/ctypes_generation/func_parser.py @@ -25,7 +25,10 @@ class WinFunc(object): def generate_prototype_ctypes(self): model = "{0} = WINFUNCTYPE({1})" - ctypes_param = [self.return_type] + if isinstance(self.return_type, tuple) and self.return_type[0] == "PTR": + ctypes_param = ["POINTER({0})".format(self.return_type[1])] + else: + ctypes_param = [self.return_type] for type, name in self.params: if type.upper() == "POINTER(VOID)": type = "PVOID" @@ -81,6 +84,10 @@ class WinFuncParser(Parser): except StopIteration: raise NormalParsingTerminaison() + if type(self.peek()) == StarToken: + self.assert_token_type(StarToken) + return_type = ("PTR", return_type) + func_name = self.assert_token_type(NameToken).value if func_name.upper() == "WINAPI": has_winapi = True diff --git a/ctypes_generation/generate.py b/ctypes_generation/generate.py index cc7e02b..5a486ec 100644 --- a/ctypes_generation/generate.py +++ b/ctypes_generation/generate.py @@ -404,7 +404,10 @@ class FuncGenerator(CtypesGenerator): def analyse(self, data): for func in data: - self.add_imports(func.return_type) + if isinstance(func.return_type, tuple) and func.return_type[0] == "PTR": + self.add_imports(func.return_type[1]) + else: + self.add_imports(func.return_type) for param_type, _ in func.params: if param_type.startswith("POINTER(") and param_type.endswith(")"): param_type = param_type[len("POINTER("): -1] @@ -741,7 +744,7 @@ 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")) +functions.append_input_file(from_here("definitions\\winfunc_crypto_wintrust.txt")) functions.append_input_file(from_here("definitions\\winfunc_notdoc.txt")) com = InitialCOMGenerator(from_here("definitions\\com\\*.txt"), DEFAULT_INTERFACE_TO_IID, from_here(r"..\windows\generated_def\\interfaces.py"), dependances=[structs, defs_with_ntstatus]) diff --git a/windows/generated_def/winfuncs.py b/windows/generated_def/winfuncs.py index 57cb510..329186d 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', 'NtCreateSection', 'NtOpenSection', 'NtMapViewOfSection', 'NtUnmapViewOfSection', 'OpenEventA', 'OpenEventW', 'NtOpenEvent', 'NtAlpcCreatePort', 'NtAlpcQueryInformation', 'NtAlpcConnectPort', 'NtAlpcConnectPortEx', 'NtAlpcAcceptConnectPort', 'AlpcInitializeMessageAttribute', 'AlpcGetMessageAttribute', 'NtAlpcSendWaitReceivePort', 'NtAlpcDisconnectPort', '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', 'GetWindowsDirectoryA', 'GetWindowsDirectoryW', 'RtlGetUnloadEventTraceEx', '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', 'TpCallbackSendAlpcMessageOnCompletion'] +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', 'NtCreateSection', 'NtOpenSection', 'NtMapViewOfSection', 'NtUnmapViewOfSection', 'OpenEventA', 'OpenEventW', 'NtOpenEvent', 'NtAlpcCreatePort', 'NtAlpcQueryInformation', 'NtAlpcConnectPort', 'NtAlpcConnectPortEx', 'NtAlpcAcceptConnectPort', 'AlpcInitializeMessageAttribute', 'AlpcGetMessageAttribute', 'NtAlpcSendWaitReceivePort', 'NtAlpcDisconnectPort', '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', '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', 'GetWindowsDirectoryA', 'GetWindowsDirectoryW', 'RtlGetUnloadEventTraceEx', 'CryptCATAdminCalcHashFromFileHandle', 'CryptCATAdminEnumCatalogFromHash', 'CryptCATAdminAcquireContext', 'CryptCATCatalogInfoFromContext', 'CryptCATAdminReleaseCatalogContext', 'CryptCATAdminReleaseContext', 'CryptCATGetAttrInfo', 'CryptCATGetMemberInfo', 'CryptCATGetAttrInfo', 'CryptCATEnumerateCatAttr', 'CryptCATEnumerateAttr', 'CryptCATEnumerateMember', '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', 'TpCallbackSendAlpcMessageOnCompletion'] #def ExitProcess(uExitCode): @@ -984,36 +984,6 @@ GetWindowModuleFileNameAParams = ((1, 'hwnd'), (1, 'pszFileName'), (1, 'cchFileN GetWindowModuleFileNameWPrototype = WINFUNCTYPE(UINT, HWND, LPWSTR, UINT) GetWindowModuleFileNameWParams = ((1, 'hwnd'), (1, 'pszFileName'), (1, 'cchFileNameMax')) -#def CryptCATAdminCalcHashFromFileHandle(hFile, pcbHash, pbHash, dwFlags): -# return CryptCATAdminCalcHashFromFileHandle.ctypes_function(hFile, pcbHash, pbHash, dwFlags) -CryptCATAdminCalcHashFromFileHandlePrototype = WINFUNCTYPE(BOOL, HANDLE, POINTER(DWORD), POINTER(BYTE), DWORD) -CryptCATAdminCalcHashFromFileHandleParams = ((1, 'hFile'), (1, 'pcbHash'), (1, 'pbHash'), (1, 'dwFlags')) - -#def CryptCATAdminEnumCatalogFromHash(hCatAdmin, pbHash, cbHash, dwFlags, phPrevCatInfo): -# return CryptCATAdminEnumCatalogFromHash.ctypes_function(hCatAdmin, pbHash, cbHash, dwFlags, phPrevCatInfo) -CryptCATAdminEnumCatalogFromHashPrototype = WINFUNCTYPE(HCATINFO, HCATADMIN, POINTER(BYTE), DWORD, DWORD, POINTER(HCATINFO)) -CryptCATAdminEnumCatalogFromHashParams = ((1, 'hCatAdmin'), (1, 'pbHash'), (1, 'cbHash'), (1, 'dwFlags'), (1, 'phPrevCatInfo')) - -#def CryptCATAdminAcquireContext(phCatAdmin, pgSubsystem, dwFlags): -# return CryptCATAdminAcquireContext.ctypes_function(phCatAdmin, pgSubsystem, dwFlags) -CryptCATAdminAcquireContextPrototype = WINFUNCTYPE(BOOL, POINTER(HCATADMIN), POINTER(GUID), DWORD) -CryptCATAdminAcquireContextParams = ((1, 'phCatAdmin'), (1, 'pgSubsystem'), (1, 'dwFlags')) - -#def CryptCATCatalogInfoFromContext(hCatInfo, psCatInfo, dwFlags): -# return CryptCATCatalogInfoFromContext.ctypes_function(hCatInfo, psCatInfo, dwFlags) -CryptCATCatalogInfoFromContextPrototype = WINFUNCTYPE(BOOL, HCATINFO, POINTER(CATALOG_INFO), DWORD) -CryptCATCatalogInfoFromContextParams = ((1, 'hCatInfo'), (1, 'psCatInfo'), (1, 'dwFlags')) - -#def CryptCATAdminReleaseCatalogContext(hCatAdmin, hCatInfo, dwFlags): -# return CryptCATAdminReleaseCatalogContext.ctypes_function(hCatAdmin, hCatInfo, dwFlags) -CryptCATAdminReleaseCatalogContextPrototype = WINFUNCTYPE(BOOL, HCATADMIN, HCATINFO, DWORD) -CryptCATAdminReleaseCatalogContextParams = ((1, 'hCatAdmin'), (1, 'hCatInfo'), (1, 'dwFlags')) - -#def CryptCATAdminReleaseContext(hCatAdmin, dwFlags): -# return CryptCATAdminReleaseContext.ctypes_function(hCatAdmin, dwFlags) -CryptCATAdminReleaseContextPrototype = WINFUNCTYPE(BOOL, HCATADMIN, DWORD) -CryptCATAdminReleaseContextParams = ((1, 'hCatAdmin'), (1, 'dwFlags')) - #def GetLogicalDriveStringsA(nBufferLength, lpBuffer): # return GetLogicalDriveStringsA.ctypes_function(nBufferLength, lpBuffer) GetLogicalDriveStringsAPrototype = WINFUNCTYPE(DWORD, DWORD, LPCSTR) @@ -1349,6 +1319,66 @@ GetWindowsDirectoryWParams = ((1, 'lpBuffer'), (1, 'uSize')) RtlGetUnloadEventTraceExPrototype = WINFUNCTYPE(VOID, POINTER(PULONG), POINTER(PULONG), POINTER(PVOID)) RtlGetUnloadEventTraceExParams = ((1, 'ElementSize'), (1, 'ElementCount'), (1, 'EventTrace')) +#def CryptCATAdminCalcHashFromFileHandle(hFile, pcbHash, pbHash, dwFlags): +# return CryptCATAdminCalcHashFromFileHandle.ctypes_function(hFile, pcbHash, pbHash, dwFlags) +CryptCATAdminCalcHashFromFileHandlePrototype = WINFUNCTYPE(BOOL, HANDLE, POINTER(DWORD), POINTER(BYTE), DWORD) +CryptCATAdminCalcHashFromFileHandleParams = ((1, 'hFile'), (1, 'pcbHash'), (1, 'pbHash'), (1, 'dwFlags')) + +#def CryptCATAdminEnumCatalogFromHash(hCatAdmin, pbHash, cbHash, dwFlags, phPrevCatInfo): +# return CryptCATAdminEnumCatalogFromHash.ctypes_function(hCatAdmin, pbHash, cbHash, dwFlags, phPrevCatInfo) +CryptCATAdminEnumCatalogFromHashPrototype = WINFUNCTYPE(HCATINFO, HCATADMIN, POINTER(BYTE), DWORD, DWORD, POINTER(HCATINFO)) +CryptCATAdminEnumCatalogFromHashParams = ((1, 'hCatAdmin'), (1, 'pbHash'), (1, 'cbHash'), (1, 'dwFlags'), (1, 'phPrevCatInfo')) + +#def CryptCATAdminAcquireContext(phCatAdmin, pgSubsystem, dwFlags): +# return CryptCATAdminAcquireContext.ctypes_function(phCatAdmin, pgSubsystem, dwFlags) +CryptCATAdminAcquireContextPrototype = WINFUNCTYPE(BOOL, POINTER(HCATADMIN), POINTER(GUID), DWORD) +CryptCATAdminAcquireContextParams = ((1, 'phCatAdmin'), (1, 'pgSubsystem'), (1, 'dwFlags')) + +#def CryptCATCatalogInfoFromContext(hCatInfo, psCatInfo, dwFlags): +# return CryptCATCatalogInfoFromContext.ctypes_function(hCatInfo, psCatInfo, dwFlags) +CryptCATCatalogInfoFromContextPrototype = WINFUNCTYPE(BOOL, HCATINFO, POINTER(CATALOG_INFO), DWORD) +CryptCATCatalogInfoFromContextParams = ((1, 'hCatInfo'), (1, 'psCatInfo'), (1, 'dwFlags')) + +#def CryptCATAdminReleaseCatalogContext(hCatAdmin, hCatInfo, dwFlags): +# return CryptCATAdminReleaseCatalogContext.ctypes_function(hCatAdmin, hCatInfo, dwFlags) +CryptCATAdminReleaseCatalogContextPrototype = WINFUNCTYPE(BOOL, HCATADMIN, HCATINFO, DWORD) +CryptCATAdminReleaseCatalogContextParams = ((1, 'hCatAdmin'), (1, 'hCatInfo'), (1, 'dwFlags')) + +#def CryptCATAdminReleaseContext(hCatAdmin, dwFlags): +# return CryptCATAdminReleaseContext.ctypes_function(hCatAdmin, dwFlags) +CryptCATAdminReleaseContextPrototype = WINFUNCTYPE(BOOL, HCATADMIN, DWORD) +CryptCATAdminReleaseContextParams = ((1, 'hCatAdmin'), (1, 'dwFlags')) + +#def CryptCATGetAttrInfo(hCatalog, pCatMember, pwszReferenceTag): +# return CryptCATGetAttrInfo.ctypes_function(hCatalog, pCatMember, pwszReferenceTag) +CryptCATGetAttrInfoPrototype = WINFUNCTYPE(POINTER(CRYPTCATATTRIBUTE), HANDLE, POINTER(CRYPTCATMEMBER), LPWSTR) +CryptCATGetAttrInfoParams = ((1, 'hCatalog'), (1, 'pCatMember'), (1, 'pwszReferenceTag')) + +#def CryptCATGetMemberInfo(hCatalog, pwszReferenceTag): +# return CryptCATGetMemberInfo.ctypes_function(hCatalog, pwszReferenceTag) +CryptCATGetMemberInfoPrototype = WINFUNCTYPE(POINTER(CRYPTCATMEMBER), HANDLE, LPWSTR) +CryptCATGetMemberInfoParams = ((1, 'hCatalog'), (1, 'pwszReferenceTag')) + +#def CryptCATGetAttrInfo(hCatalog, pCatMember, pwszReferenceTag): +# return CryptCATGetAttrInfo.ctypes_function(hCatalog, pCatMember, pwszReferenceTag) +CryptCATGetAttrInfoPrototype = WINFUNCTYPE(POINTER(CRYPTCATATTRIBUTE), HANDLE, POINTER(CRYPTCATMEMBER), LPWSTR) +CryptCATGetAttrInfoParams = ((1, 'hCatalog'), (1, 'pCatMember'), (1, 'pwszReferenceTag')) + +#def CryptCATEnumerateCatAttr(hCatalog, pPrevAttr): +# return CryptCATEnumerateCatAttr.ctypes_function(hCatalog, pPrevAttr) +CryptCATEnumerateCatAttrPrototype = WINFUNCTYPE(POINTER(CRYPTCATATTRIBUTE), HANDLE, POINTER(CRYPTCATATTRIBUTE)) +CryptCATEnumerateCatAttrParams = ((1, 'hCatalog'), (1, 'pPrevAttr')) + +#def CryptCATEnumerateAttr(hCatalog, pCatMember, pPrevAttr): +# return CryptCATEnumerateAttr.ctypes_function(hCatalog, pCatMember, pPrevAttr) +CryptCATEnumerateAttrPrototype = WINFUNCTYPE(POINTER(CRYPTCATATTRIBUTE), HANDLE, POINTER(CRYPTCATMEMBER), POINTER(CRYPTCATATTRIBUTE)) +CryptCATEnumerateAttrParams = ((1, 'hCatalog'), (1, 'pCatMember'), (1, 'pPrevAttr')) + +#def CryptCATEnumerateMember(hCatalog, pPrevMember): +# return CryptCATEnumerateMember.ctypes_function(hCatalog, pPrevMember) +CryptCATEnumerateMemberPrototype = WINFUNCTYPE(POINTER(CRYPTCATMEMBER), HANDLE, POINTER(CRYPTCATMEMBER)) +CryptCATEnumerateMemberParams = ((1, 'hCatalog'), (1, 'pPrevMember')) + #def CryptQueryObject(dwObjectType, pvObject, dwExpectedContentTypeFlags, dwExpectedFormatTypeFlags, dwFlags, pdwMsgAndCertEncodingType, pdwContentType, pdwFormatType, phCertStore, phMsg, ppvContext): # return CryptQueryObject.ctypes_function(dwObjectType, pvObject, dwExpectedContentTypeFlags, dwExpectedFormatTypeFlags, dwFlags, pdwMsgAndCertEncodingType, pdwContentType, pdwFormatType, phCertStore, phMsg, ppvContext) CryptQueryObjectPrototype = WINFUNCTYPE(BOOL, DWORD, PVOID, DWORD, DWORD, DWORD, POINTER(DWORD), POINTER(DWORD), POINTER(DWORD), POINTER(HCERTSTORE), POINTER(HCRYPTMSG), POINTER(PVOID)) diff --git a/windows/generated_def/winstructs.py b/windows/generated_def/winstructs.py index 029a32c..59bc982 100644 --- a/windows/generated_def/winstructs.py +++ b/windows/generated_def/winstructs.py @@ -2680,6 +2680,60 @@ PDATA_BLOB = POINTER(_CRYPTOAPI_BLOB) PCRYPT_ATTR_BLOB = POINTER(_CRYPTOAPI_BLOB) CRYPT_ATTR_BLOB = _CRYPTOAPI_BLOB +class CRYPTCATATTRIBUTE_(Structure): + _fields_ = [ + ("cbStruct", DWORD), + ("pwszReferenceTag", LPWSTR), + ("dwAttrTypeAndAction", DWORD), + ("cbValue", DWORD), + ("pbValue", POINTER(BYTE)), + ("dwReserved", DWORD), + ] +CRYPTCATATTRIBUTE = CRYPTCATATTRIBUTE_ +PCRYPTCATATTRIBUTE = POINTER(CRYPTCATATTRIBUTE_) + +class _CRYPT_ATTRIBUTE_TYPE_VALUE(Structure): + _fields_ = [ + ("pszObjId", LPSTR), + ("Value", CRYPT_OBJID_BLOB), + ] +CRYPT_ATTRIBUTE_TYPE_VALUE = _CRYPT_ATTRIBUTE_TYPE_VALUE +PCRYPT_ATTRIBUTE_TYPE_VALUE = POINTER(_CRYPT_ATTRIBUTE_TYPE_VALUE) + +class _CRYPT_ALGORITHM_IDENTIFIER(Structure): + _fields_ = [ + ("pszObjId", LPSTR), + ("Parameters", CRYPT_OBJID_BLOB), + ] +CRYPT_ALGORITHM_IDENTIFIER = _CRYPT_ALGORITHM_IDENTIFIER +PCRYPT_ALGORITHM_IDENTIFIER = POINTER(_CRYPT_ALGORITHM_IDENTIFIER) + +class SIP_INDIRECT_DATA_(Structure): + _fields_ = [ + ("Data", CRYPT_ATTRIBUTE_TYPE_VALUE), + ("DigestAlgorithm", CRYPT_ALGORITHM_IDENTIFIER), + ("Digest", CRYPT_HASH_BLOB), + ] +SIP_INDIRECT_DATA = SIP_INDIRECT_DATA_ +PSIP_INDIRECT_DATA = POINTER(SIP_INDIRECT_DATA_) + +class CRYPTCATMEMBER_(Structure): + _fields_ = [ + ("cbStruct", DWORD), + ("pwszReferenceTag", LPWSTR), + ("pwszFileName", LPWSTR), + ("gSubjectType", GUID), + ("fdwMemberFlags", DWORD), + ("pIndirectData", POINTER(SIP_INDIRECT_DATA)), + ("dwCertVersion", DWORD), + ("dwReserved", DWORD), + ("hReserved", HANDLE), + ("sEncodedIndirectData", CRYPT_ATTR_BLOB), + ("sEncodedMemberInfo", CRYPT_ATTR_BLOB), + ] +CRYPTCATMEMBER = CRYPTCATMEMBER_ +PCRYPTCATMEMBER = POINTER(CRYPTCATMEMBER_) + class WINTRUST_FILE_INFO_(Structure): _fields_ = [ ("cbStruct", DWORD), @@ -2725,14 +2779,6 @@ class _CRYPT_ATTRIBUTES(Structure): CRYPT_ATTRIBUTES = _CRYPT_ATTRIBUTES PCRYPT_ATTRIBUTES = POINTER(_CRYPT_ATTRIBUTES) -class _CRYPT_ALGORITHM_IDENTIFIER(Structure): - _fields_ = [ - ("pszObjId", LPSTR), - ("Parameters", CRYPT_OBJID_BLOB), - ] -CRYPT_ALGORITHM_IDENTIFIER = _CRYPT_ALGORITHM_IDENTIFIER -PCRYPT_ALGORITHM_IDENTIFIER = POINTER(_CRYPT_ALGORITHM_IDENTIFIER) - class _CMSG_SIGNER_INFO(Structure): _fields_ = [ ("dwVersion", DWORD), diff --git a/windows/winproxy.py b/windows/winproxy.py index 6c00b83..ebd485e 100644 --- a/windows/winproxy.py +++ b/windows/winproxy.py @@ -1234,6 +1234,20 @@ def CryptCATAdminReleaseContext(hCatAdmin, dwFlags): return CryptCATAdminReleaseContext.ctypes_function(hCatAdmin, dwFlags) +@WinTrustProxy('CryptCATEnumerateAttr') +def CryptCATEnumerateAttr(hCatalog, pCatMember, pPrevAttr): + return CryptCATEnumerateAttr.ctypes_function(hCatalog, pCatMember, pPrevAttr) + + +@WinTrustProxy('CryptCATEnumerateCatAttr') +def CryptCATEnumerateCatAttr(hCatalog, pPrevAttr): + return CryptCATEnumerateCatAttr.ctypes_function(hCatalog, pPrevAttr) + + +@WinTrustProxy('CryptCATEnumerateMember') +def CryptCATEnumerateMember(hCatalog, pPrevMember): + return CryptCATEnumerateMember.ctypes_function(hCatalog, pPrevMember) + ## Crypto API ## @Crypt32Proxy('CertStrToNameA') def CertStrToNameA(dwCertEncodingType, pszX500, dwStrType, pvReserved, pbEncoded, pcbEncoded, ppszError):