| 1 | /** |
| 2 | * This file has no copyright assigned and is placed in the Public Domain. |
| 3 | * This file is part of the mingw-w64 runtime package. |
| 4 | * No warranty is given; refer to the file DISCLAIMER.PD within this package. |
| 5 | */ |
| 6 | |
| 7 | #ifndef _TBS_H_ |
| 8 | #define _TBS_H_ |
| 9 | |
| 10 | #include <winapifamily.h> |
| 11 | |
| 12 | #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) |
| 13 | |
| 14 | #if defined(__cplusplus) |
| 15 | extern "C" { |
| 16 | #endif |
| 17 | |
| 18 | #if (NTDDI_VERSION >= NTDDI_VISTA) |
| 19 | |
| 20 | #ifndef WINAPI |
| 21 | #define WINAPI __stdcall |
| 22 | #endif |
| 23 | |
| 24 | #define CONST const |
| 25 | |
| 26 | typedef signed int INT32, *PINT32; |
| 27 | typedef const INT32 *PCINT32; |
| 28 | typedef unsigned int UINT32, *PUINT32; |
| 29 | typedef const UINT32 *PCUINT32; |
| 30 | |
| 31 | #define VOID void |
| 32 | typedef VOID *PVOID; |
| 33 | typedef const VOID *PCVOID; |
| 34 | |
| 35 | typedef INT32 WINBOOL, *PBOOL; |
| 36 | typedef const WINBOOL *PCBOOL; |
| 37 | |
| 38 | typedef UINT8 BYTE, *PBYTE; |
| 39 | typedef const BYTE *PCBYTE; |
| 40 | |
| 41 | typedef WINBOOL TBS_BOOL; |
| 42 | typedef UINT32 TBS_RESULT; |
| 43 | typedef PVOID TBS_HCONTEXT, *PTBS_HCONTEXT; |
| 44 | typedef UINT32 TBS_COMMAND_PRIORITY; |
| 45 | typedef UINT32 TBS_COMMAND_LOCALITY; |
| 46 | typedef UINT32 TBS_OWNERAUTH_TYPE; |
| 47 | typedef UINT32 TBS_HANDLE; |
| 48 | |
| 49 | #define TBS_CONTEXT_VERSION_ONE 1 |
| 50 | |
| 51 | #define TBS_COMMAND_PRIORITY_LOW 100 |
| 52 | #define TBS_COMMAND_PRIORITY_NORMAL 200 |
| 53 | #define TBS_COMMAND_PRIORITY_HIGH 300 |
| 54 | #define TBS_COMMAND_PRIORITY_SYSTEM 400 |
| 55 | #define TBS_COMMAND_PRIORITY_MAX 0x80000000 |
| 56 | |
| 57 | #define TBS_COMMAND_LOCALITY_ZERO 0 |
| 58 | #define TBS_COMMAND_LOCALITY_ONE 1 |
| 59 | #define TBS_COMMAND_LOCALITY_TWO 2 |
| 60 | #define TBS_COMMAND_LOCALITY_THREE 3 |
| 61 | #define TBS_COMMAND_LOCALITY_FOUR 4 |
| 62 | |
| 63 | #define TBS_SUCCESS 0 |
| 64 | |
| 65 | #define TBS_IN_OUT_BUF_SIZE_MAX (256 * 1024) |
| 66 | |
| 67 | #define TBS_OWNERAUTH_TYPE_FULL 1 |
| 68 | #define TBS_OWNERAUTH_TYPE_ADMIN 2 |
| 69 | #define TBS_OWNERAUTH_TYPE_USER 3 |
| 70 | #define TBS_OWNERAUTH_TYPE_ENDORSEMENT 4 |
| 71 | |
| 72 | #define TBS_OWNERAUTH_TYPE_ENDORSEMENT_20 12 |
| 73 | #define TBS_OWNERAUTH_TYPE_STORAGE_20 13 |
| 74 | |
| 75 | typedef struct tdTBS_CONTEXT_PARAMS { |
| 76 | UINT32 version; |
| 77 | } TBS_CONTEXT_PARAMS, *PTBS_CONTEXT_PARAMS; |
| 78 | typedef const TBS_CONTEXT_PARAMS *PCTBS_CONTEXT_PARAMS; |
| 79 | |
| 80 | TBS_RESULT WINAPI Tbsi_Context_Create(PCTBS_CONTEXT_PARAMS pContextParams, PTBS_HCONTEXT phContext); |
| 81 | TBS_RESULT WINAPI Tbsip_Context_Close(TBS_HCONTEXT hContext); |
| 82 | TBS_RESULT WINAPI Tbsip_Submit_Command(TBS_HCONTEXT hContext, TBS_COMMAND_LOCALITY Locality, TBS_COMMAND_PRIORITY Priority, PCBYTE pabCommand, UINT32 cbCommand, PBYTE pabResult, PUINT32 pcbResult); |
| 83 | TBS_RESULT WINAPI Tbsip_Cancel_Commands(TBS_HCONTEXT hContext); |
| 84 | TBS_RESULT WINAPI Tbsi_Physical_Presence_Command(TBS_HCONTEXT hContext, PCBYTE pabInput, UINT32 cbInput, PBYTE pabOutput, PUINT32 pcbOutput); |
| 85 | |
| 86 | #endif /* (NTDDI_VERSION >= NTDDI_VISTA) */ |
| 87 | |
| 88 | #if (NTDDI_VERSION >= NTDDI_VISTASP1) |
| 89 | |
| 90 | TBS_RESULT WINAPI Tbsi_Get_TCG_Log(TBS_HCONTEXT hContext, PBYTE pOutputBuf, PUINT32 pOutputBufLen); |
| 91 | |
| 92 | #endif /* _WIN32_WINNT_VISTASP1 */ |
| 93 | |
| 94 | #if (NTDDI_VERSION >= NTDDI_WIN8) |
| 95 | |
| 96 | #define TBS_CONTEXT_VERSION_TWO 2 |
| 97 | |
| 98 | typedef struct tdTBS_CONTEXT_PARAMS2 { |
| 99 | UINT32 version; |
| 100 | __C89_NAMELESS union { |
| 101 | __C89_NAMELESS struct { |
| 102 | UINT32 requestRaw : 1; |
| 103 | UINT32 includeTpm12 : 1; |
| 104 | UINT32 includeTpm20 : 1; |
| 105 | }; |
| 106 | UINT32 asUINT32; |
| 107 | }; |
| 108 | } TBS_CONTEXT_PARAMS2, *PTBS_CONTEXT_PARAMS2; |
| 109 | typedef const TBS_CONTEXT_PARAMS2 *PCTBS_CONTEXT_PARAMS2; |
| 110 | |
| 111 | typedef struct tdTPM_WNF_PROVISIONING { |
| 112 | UINT32 status; |
| 113 | BYTE message[28]; |
| 114 | } TPM_WNF_PROVISIONING; |
| 115 | |
| 116 | #define TPM_WNF_INFO_CLEAR_SUCCESSFUL 0x00000001 |
| 117 | #define TPM_WNF_INFO_OWNERSHIP_SUCCESSFUL 0x00000002 |
| 118 | |
| 119 | #define TPM_WNF_INFO_NO_REBOOT_REQUIRED 1 |
| 120 | |
| 121 | #ifndef TPM_VERSION_UNKNOWN |
| 122 | |
| 123 | #define TPM_VERSION_UNKNOWN 0 |
| 124 | #define TPM_VERSION_12 1 |
| 125 | #define TPM_VERSION_20 2 |
| 126 | |
| 127 | #define TPM_IFTYPE_UNKNOWN 0 |
| 128 | #define TPM_IFTYPE_1 1 |
| 129 | #define TPM_IFTYPE_TRUSTZONE 2 |
| 130 | #define TPM_IFTYPE_HW 3 |
| 131 | #define TPM_IFTYPE_EMULATOR 4 |
| 132 | #define TPM_IFTYPE_SPB 5 |
| 133 | |
| 134 | typedef struct _TPM_DEVICE_INFO { |
| 135 | UINT32 structVersion; |
| 136 | UINT32 tpmVersion; |
| 137 | UINT32 tpmInterfaceType; |
| 138 | UINT32 tpmImpRevision; |
| 139 | } TPM_DEVICE_INFO, *PTPM_DEVICE_INFO; |
| 140 | typedef const TPM_DEVICE_INFO *PCTPM_DEVICE_INFO; |
| 141 | |
| 142 | #endif /* TPM_VERSION_UNKNOWN */ |
| 143 | |
| 144 | TBS_RESULT WINAPI Tbsi_GetDeviceInfo(UINT32 Size, PVOID Info); |
| 145 | TBS_RESULT WINAPI Tbsi_Get_OwnerAuth(TBS_HCONTEXT hContext, TBS_OWNERAUTH_TYPE ownerauthType, PBYTE pOutputBuf, PUINT32 pOutputBufLen); |
| 146 | TBS_RESULT WINAPI Tbsi_Revoke_Attestation(void); |
| 147 | |
| 148 | #endif /* (NTDDI_VERSION >= NTDDI_WIN8) */ |
| 149 | |
| 150 | #if (NTDDI_VERSION >= NTDDI_WINBLUE) |
| 151 | |
| 152 | #ifndef _NTDDK_ |
| 153 | |
| 154 | HRESULT GetDeviceID(PBYTE pbWindowsAIK, UINT32 cbWindowsAIK, PUINT32 pcbResult, WINBOOL *pfProtectedByTPM); |
| 155 | HRESULT GetDeviceIDString(PWSTR pszWindowsAIK, UINT32 cchWindowsAIK, PUINT32 pcchResult, WINBOOL *pfProtectedByTPM); |
| 156 | |
| 157 | #endif /* ifndef _NTDDK_ */ |
| 158 | |
| 159 | #endif /* (NTDDI_VERSION >= NTDDI_WINBLUE) */ |
| 160 | |
| 161 | #if (NTDDI_VERSION >= NTDDI_WINTHRESHOLD) |
| 162 | |
| 163 | TBS_RESULT WINAPI Tbsi_Create_Windows_Key(TBS_HANDLE keyHandle); |
| 164 | |
| 165 | #endif /* (NTDDI_VERSION >= NTDDI_WINTHRESHOLD) */ |
| 166 | |
| 167 | #if (NTDDI_VERSION >= NTDDI_WIN10_RS4) |
| 168 | |
| 169 | #define TBS_TCGLOG_SRTM_CURRENT 0 |
| 170 | #define TBS_TCGLOG_DRTM_CURRENT 1 |
| 171 | #define TBS_TCGLOG_SRTM_BOOT 2 |
| 172 | #define TBS_TCGLOG_SRTM_RESUME 3 |
| 173 | #define TBS_TCGLOG_DRTM_BOOT 4 |
| 174 | #define TBS_TCGLOG_DRTM_RESUME 5 |
| 175 | |
| 176 | TBS_RESULT WINAPI Tbsi_Get_TCG_Log_Ex(UINT32 logType, PBYTE pbOutput, PUINT32 pcbOutput); |
| 177 | |
| 178 | #endif /* (NTDDI_VERSION >= NTDDI_WIN10_RS4) */ |
| 179 | |
| 180 | #if (NTDDI_VERSION >= NTDDI_WIN10_NI) |
| 181 | |
| 182 | WINBOOL WINAPI Tbsi_Is_Tpm_Present(void); |
| 183 | |
| 184 | #endif /* (NTDDI_VERSION >= NTDDI_WIN10_NI) */ |
| 185 | |
| 186 | #if defined(__cplusplus) |
| 187 | } |
| 188 | #endif |
| 189 | |
| 190 | #endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) */ |
| 191 | |
| 192 | #endif /* _TBS_H_ */ |