1 /* 2 * PROJECT: ReactOS Application compatibility module 3 * LICENSE: GPL-2.0-or-later (https://spdx.org/licenses/GPL-2.0-or-later) 4 * PURPOSE: common structures / functions 5 * COPYRIGHT: Copyright 2013 Mislav Blažević 6 * Copyright 2017-2019 Mark Jansen (mark.jansen@reactos.org) 7 */ 8 9 #ifndef APPHELP_H 10 #define APPHELP_H 11 12 #ifdef __cplusplus 13 extern "C" { 14 #endif 15 16 #include <appcompat/sdbtypes.h> 17 18 /* Flags for SdbInitDatabase */ 19 #define HID_DOS_PATHS 0x1 20 #define HID_DATABASE_FULLPATH 0x2 21 #define HID_NO_DATABASE 0x4 22 #define HID_DATABASE_TYPE_MASK 0xF00F0000 23 #define SDB_DATABASE_MAIN_MSI 0x80020000 24 #define SDB_DATABASE_MAIN_SHIM 0x80030000 25 #define SDB_DATABASE_MAIN_DRIVERS 0x80040000 26 27 typedef struct _SDB { 28 PDB pdb; 29 BOOL auto_loaded; 30 } SDB, *HSDB; 31 32 typedef struct tagATTRINFO { 33 TAG type; 34 DWORD flags; 35 union { 36 QWORD qwattr; 37 DWORD dwattr; 38 WCHAR *lpattr; 39 }; 40 } ATTRINFO, *PATTRINFO; 41 42 #define SDB_MAX_SDBS 16 43 #define SDB_MAX_EXES 16 44 #define SDB_MAX_LAYERS 8 45 46 /* Flags for adwExeFlags */ 47 #define SHIMREG_DISABLE_SHIM (0x00000001) 48 #define SHIMREG_DISABLE_APPHELP (0x00000002) 49 #define SHIMREG_APPHELP_NOUI (0x00000004) 50 #define SHIMREG_APPHELP_CANCEL (0x10000000) 51 #define SHIMREG_DISABLE_SXS (0x00000010) 52 #define SHIMREG_DISABLE_LAYER (0x00000020) 53 #define SHIMREG_DISABLE_DRIVER (0x00000040) 54 55 /* Flags for dwFlags */ 56 #define SHIMREG_HAS_ENVIRONMENT (0x1) 57 58 /* Flags for SdbGetMatchingExe */ 59 #define SDBGMEF_IGNORE_ENVIRONMENT (0x1) 60 61 typedef struct tagSDBQUERYRESULT { 62 TAGREF atrExes[SDB_MAX_EXES]; 63 DWORD adwExeFlags[SDB_MAX_EXES]; 64 TAGREF atrLayers[SDB_MAX_LAYERS]; 65 DWORD dwLayerFlags; 66 TAGREF trApphelp; 67 DWORD dwExeCount; 68 DWORD dwLayerCount; 69 GUID guidID; 70 DWORD dwFlags; 71 DWORD dwCustomSDBMap; 72 GUID rgGuidDB[SDB_MAX_SDBS]; 73 } SDBQUERYRESULT, *PSDBQUERYRESULT; 74 75 76 #define DB_INFO_FLAGS_VALID_GUID 1 77 78 typedef struct _DB_INFORMATION 79 { 80 DWORD dwFlags; 81 DWORD dwMajor; 82 DWORD dwMinor; 83 LPCWSTR Description; 84 GUID Id; 85 /* Win10+ has an extra field here */ 86 } DB_INFORMATION, *PDB_INFORMATION; 87 88 89 #ifndef APPHELP_NOSDBPAPI 90 #include "sdbpapi.h" 91 #endif 92 93 /* sdbapi.c */ 94 PWSTR SdbpStrDup(LPCWSTR string); 95 DWORD SdbpStrsize(PCWSTR string); 96 HSDB WINAPI SdbInitDatabase(DWORD, LPCWSTR); 97 void WINAPI SdbReleaseDatabase(HSDB); 98 BOOL WINAPI SdbGUIDToString(CONST GUID *Guid, PWSTR GuidString, SIZE_T Length); 99 LPCWSTR WINAPI SdbTagToString(TAG tag); 100 101 PDB WINAPI SdbOpenDatabase(LPCWSTR path, PATH_TYPE type); 102 void WINAPI SdbCloseDatabase(PDB); 103 BOOL WINAPI SdbIsNullGUID(CONST GUID *Guid); 104 HRESULT WINAPI SdbGetAppPatchDir(HSDB db, LPWSTR path, DWORD size); 105 LPWSTR WINAPI SdbGetStringTagPtr(PDB pdb, TAGID tagid); 106 TAGID WINAPI SdbFindFirstNamedTag(PDB pdb, TAGID root, TAGID find, TAGID nametag, LPCWSTR find_name); 107 DWORD WINAPI SdbQueryDataExTagID(PDB pdb, TAGID tiExe, LPCWSTR lpszDataName, LPDWORD lpdwDataType, LPVOID lpBuffer, LPDWORD lpcbBufferSize, TAGID *ptiData); 108 BOOL WINAPI SdbGetDatabaseInformation(PDB pdb, PDB_INFORMATION information); 109 VOID WINAPI SdbFreeDatabaseInformation(PDB_INFORMATION information); 110 111 112 /* sdbread.c */ 113 BOOL WINAPI SdbpReadData(PDB pdb, PVOID dest, DWORD offset, DWORD num); 114 TAG WINAPI SdbGetTagFromTagID(PDB pdb, TAGID tagid); 115 TAGID WINAPI SdbFindFirstTag(PDB pdb, TAGID parent, TAG tag); 116 TAGID WINAPI SdbFindNextTag(PDB pdb, TAGID parent, TAGID prev_child); 117 BOOL WINAPI SdbGetDatabaseID(PDB pdb, GUID* Guid); 118 DWORD WINAPI SdbReadDWORDTag(PDB pdb, TAGID tagid, DWORD ret); 119 QWORD WINAPI SdbReadQWORDTag(PDB pdb, TAGID tagid, QWORD ret); 120 TAGID WINAPI SdbGetFirstChild(PDB pdb, TAGID parent); 121 TAGID WINAPI SdbGetNextChild(PDB pdb, TAGID parent, TAGID prev_child); 122 DWORD WINAPI SdbGetTagDataSize(PDB pdb, TAGID tagid); 123 LPWSTR WINAPI SdbpGetString(PDB pdb, TAGID tagid, PDWORD size); 124 125 126 /* sdbfileattr.c*/ 127 BOOL WINAPI SdbGetFileAttributes(LPCWSTR path, PATTRINFO *attr_info_ret, LPDWORD attr_count); 128 BOOL WINAPI SdbFreeFileAttributes(PATTRINFO attr_info); 129 130 /* layer.c */ 131 BOOL WINAPI AllowPermLayer(PCWSTR path); 132 BOOL WINAPI SdbGetPermLayerKeys(PCWSTR wszPath, PWSTR pwszLayers, PDWORD pdwBytes, DWORD dwFlags); 133 BOOL WINAPI SetPermLayerState(PCWSTR wszPath, PCWSTR wszLayer, DWORD dwFlags, BOOL bMachine, BOOL bEnable); 134 135 /* hsdb.c */ 136 BOOL WINAPI SdbGetMatchingExe(HSDB hsdb, LPCWSTR path, LPCWSTR module_name, LPCWSTR env, DWORD flags, PSDBQUERYRESULT result); 137 BOOL WINAPI SdbTagIDToTagRef(HSDB hsdb, PDB pdb, TAGID tiWhich, TAGREF* ptrWhich); 138 BOOL WINAPI SdbTagRefToTagID(HSDB hsdb, TAGREF trWhich, PDB* ppdb, TAGID* ptiWhich); 139 BOOL WINAPI SdbUnpackAppCompatData(HSDB hsdb, LPCWSTR pszImageName, PVOID pData, PSDBQUERYRESULT pQueryResult); 140 DWORD WINAPI SdbQueryData(HSDB hsdb, TAGREF trWhich, LPCWSTR lpszDataName, LPDWORD lpdwDataType, LPVOID lpBuffer, LPDWORD lpcbBufferSize); 141 142 #define ATTRIBUTE_AVAILABLE 0x1 143 #define ATTRIBUTE_FAILED 0x2 144 145 #include <appcompat/sdbtagid.h> 146 147 #ifdef __cplusplus 148 } // extern "C" 149 #endif 150 151 #endif // APPHELP_H 152