1 /* 2 * PROJECT: ReactOS Application compatibility module 3 * LICENSE: GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+) 4 * PURPOSE: common structures / functions 5 * COPYRIGHT: Copyright 2013 Mislav Blažević 6 * Copyright 2017 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 "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 #ifndef APPHELP_NOSDBPAPI 76 #include "sdbpapi.h" 77 #endif 78 79 /* sdbapi.c */ 80 PWSTR SdbpStrDup(LPCWSTR string); 81 DWORD SdbpStrsize(PCWSTR string); 82 HSDB WINAPI SdbInitDatabase(DWORD, LPCWSTR); 83 void WINAPI SdbReleaseDatabase(HSDB); 84 BOOL WINAPI SdbGUIDToString(CONST GUID *Guid, PWSTR GuidString, SIZE_T Length); 85 LPCWSTR WINAPI SdbTagToString(TAG tag); 86 87 PDB WINAPI SdbOpenDatabase(LPCWSTR path, PATH_TYPE type); 88 void WINAPI SdbCloseDatabase(PDB); 89 BOOL WINAPI SdbIsNullGUID(CONST GUID *Guid); 90 HRESULT WINAPI SdbGetAppPatchDir(HSDB db, LPWSTR path, DWORD size); 91 LPWSTR WINAPI SdbGetStringTagPtr(PDB pdb, TAGID tagid); 92 TAGID WINAPI SdbFindFirstNamedTag(PDB pdb, TAGID root, TAGID find, TAGID nametag, LPCWSTR find_name); 93 DWORD WINAPI SdbQueryDataExTagID(PDB pdb, TAGID tiExe, LPCWSTR lpszDataName, LPDWORD lpdwDataType, LPVOID lpBuffer, LPDWORD lpcbBufferSize, TAGID *ptiData); 94 95 96 /* sdbread.c */ 97 BOOL WINAPI SdbpReadData(PDB pdb, PVOID dest, DWORD offset, DWORD num); 98 TAG WINAPI SdbGetTagFromTagID(PDB pdb, TAGID tagid); 99 TAGID WINAPI SdbFindFirstTag(PDB pdb, TAGID parent, TAG tag); 100 TAGID WINAPI SdbFindNextTag(PDB pdb, TAGID parent, TAGID prev_child); 101 BOOL WINAPI SdbGetDatabaseID(PDB pdb, GUID* Guid); 102 DWORD WINAPI SdbReadDWORDTag(PDB pdb, TAGID tagid, DWORD ret); 103 QWORD WINAPI SdbReadQWORDTag(PDB pdb, TAGID tagid, QWORD ret); 104 TAGID WINAPI SdbGetFirstChild(PDB pdb, TAGID parent); 105 TAGID WINAPI SdbGetNextChild(PDB pdb, TAGID parent, TAGID prev_child); 106 DWORD WINAPI SdbGetTagDataSize(PDB pdb, TAGID tagid); 107 LPWSTR WINAPI SdbpGetString(PDB pdb, TAGID tagid, PDWORD size); 108 109 110 /* sdbfileattr.c*/ 111 BOOL WINAPI SdbGetFileAttributes(LPCWSTR path, PATTRINFO *attr_info_ret, LPDWORD attr_count); 112 BOOL WINAPI SdbFreeFileAttributes(PATTRINFO attr_info); 113 114 /* layer.c */ 115 BOOL WINAPI AllowPermLayer(PCWSTR path); 116 BOOL WINAPI SdbGetPermLayerKeys(PCWSTR wszPath, PWSTR pwszLayers, PDWORD pdwBytes, DWORD dwFlags); 117 BOOL WINAPI SetPermLayerState(PCWSTR wszPath, PCWSTR wszLayer, DWORD dwFlags, BOOL bMachine, BOOL bEnable); 118 119 /* hsdb.c */ 120 BOOL WINAPI SdbGetMatchingExe(HSDB hsdb, LPCWSTR path, LPCWSTR module_name, LPCWSTR env, DWORD flags, PSDBQUERYRESULT result); 121 BOOL WINAPI SdbTagIDToTagRef(HSDB hsdb, PDB pdb, TAGID tiWhich, TAGREF* ptrWhich); 122 BOOL WINAPI SdbTagRefToTagID(HSDB hsdb, TAGREF trWhich, PDB* ppdb, TAGID* ptiWhich); 123 BOOL WINAPI SdbUnpackAppCompatData(HSDB hsdb, LPCWSTR pszImageName, PVOID pData, PSDBQUERYRESULT pQueryResult); 124 DWORD WINAPI SdbQueryData(HSDB hsdb, TAGREF trWhich, LPCWSTR lpszDataName, LPDWORD lpdwDataType, LPVOID lpBuffer, LPDWORD lpcbBufferSize); 125 126 #define ATTRIBUTE_AVAILABLE 0x1 127 #define ATTRIBUTE_FAILED 0x2 128 129 #include "sdbtagid.h" 130 131 #ifdef __cplusplus 132 } // extern "C" 133 #endif 134 135 #endif // APPHELP_H 136