Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

2463 lines
62 KiB

  1. /*--
  2. Copyright (c) Microsoft Corporation. All rights reserved.
  3. Module Name:
  4. shimdb.h
  5. Abstract:
  6. header for the database file access functions used by the App Compat shimming system
  7. Author:
  8. dmunsil 02/02/2000
  9. Revision History:
  10. Notes:
  11. This "database" is more of a tagged file, designed to mimic the structure of an XML
  12. file. An XML file can be converted into this packed data format easily, and all strings
  13. will by default be packed into a stringtable and referenced by a DWORD identifier, so files
  14. that contain a lot of common strings (like the XML used by the App Compat tema) will not
  15. bloat.
  16. To see the actual tags used by the shimdb, look in shimtags.h.
  17. For the high-level interface used by the loader in NTDLL, look at ntbaseapi.c
  18. --*/
  19. #ifndef _SHIMDB_H_
  20. #define _SHIMDB_H_
  21. /*++
  22. Supported configurations:
  23. UNICODE with NT apis
  24. ANSI with WIN32 apis
  25. By default the library is UNICODE
  26. To use (and link) Win32 library
  27. --*/
  28. #ifdef SDB_ANSI_LIB
  29. #define LPCTSTR LPCSTR
  30. #define LPTSTR LPSTR
  31. #define TCHAR CHAR
  32. #else
  33. #define LPCTSTR LPCWSTR
  34. #define LPTSTR LPWSTR
  35. #define TCHAR WCHAR
  36. #endif
  37. #define SDBAPI STDAPICALLTYPE
  38. typedef WORD TAG;
  39. typedef WORD TAG_TYPE;
  40. typedef DWORD TAGID;
  41. typedef DWORD TAG_OFFSET;
  42. typedef DWORD STRINGREF;
  43. typedef DWORD INDEXID;
  44. #define TAGID_NULL 0
  45. #define STRINGREF_NULL 0
  46. #define INDEXID_NULL ((INDEXID)-1)
  47. #define TAG_NULL 0
  48. #define TAGID_ROOT 0 // implied root list tag that can be passed in as a parent
  49. #define TAG_SIZE_UNFINISHED 0xFFFFFFFF
  50. //
  51. // define TAGREF so we can use tags accross databases
  52. //
  53. typedef DWORD TAGREF;
  54. ///////////////////////////////////////////////////////////////////////////////
  55. //
  56. // TAG TYPES
  57. //
  58. //
  59. // The most significant 4 bits tell you the basic type and size of data,
  60. // and the lower 12 are the specific tag.
  61. //
  62. // In this way, even if we add more tags to the db, older readers can read
  63. // the data because the type is either implied (for the first 5 types)
  64. // or supplied (for all other types).
  65. //
  66. // WARNING: it is important that only the first 5 types have implied sizes.
  67. // any future types should use a size or backwards compatibility will not be
  68. // maintained.
  69. //
  70. // The following tags have an implied size.
  71. //
  72. #define TAG_TYPE_NULL 0x1000 // implied size 0
  73. #define TAG_TYPE_BYTE 0x2000 // implied size 1
  74. #define TAG_TYPE_WORD 0x3000 // implied size 2
  75. #define TAG_TYPE_DWORD 0x4000 // implied size 4
  76. #define TAG_TYPE_QWORD 0x5000 // implied size 8
  77. #define TAG_TYPE_STRINGREF 0x6000 // implied size 4, for strings that should be tokenized
  78. //
  79. // These tags have a size after them (the size is type TAG_OFFSET)
  80. //
  81. #define TAG_TYPE_LIST 0x7000
  82. #define TAG_TYPE_STRING 0x8000
  83. #define TAG_TYPE_BINARY 0x9000
  84. #define TAGREF_NULL 0
  85. #define TAGREF_ROOT 0
  86. //
  87. // Special define for stripping out just the type from a tag.
  88. //
  89. #define TAG_STRIP_TYPE 0xF000
  90. //
  91. // This macro strips off the lower bits of the TAG and returns the upper bits, which
  92. // give the basic type of tag. All the tag types are defined above.
  93. //
  94. // The type info is purely used internally by the DB to tell whether the tag has
  95. // an implied size, or if the DB needs to do something special with the data before
  96. // handing it back to the caller.
  97. //
  98. #define GETTAGTYPE(tag) ((tag) & TAG_STRIP_TYPE)
  99. typedef PVOID HSDB;
  100. struct tagHOOKAPI;
  101. typedef struct tagHOOKAPIEX {
  102. DWORD dwShimID;
  103. struct tagHOOKAPI* pTopOfChain;
  104. struct tagHOOKAPI* pNext;
  105. } HOOKAPIEX, *PHOOKAPIEX;
  106. typedef struct tagHOOKAPI {
  107. char* pszModule; // the name of the module
  108. char* pszFunctionName; // the name of the API in the module
  109. PVOID pfnNew; // pointer to the new stub API
  110. PVOID pfnOld; // pointer to the old API
  111. DWORD dwFlags; // used internally - important info about status
  112. union {
  113. struct tagHOOKAPI* pNextHook; // used internally - (obsolete -- old mechanism)
  114. PHOOKAPIEX pHookEx; // used internally - pointer to an internal extended
  115. // info struct
  116. };
  117. } HOOKAPI, *PHOOKAPI;
  118. //
  119. // OBSOLETE !
  120. //
  121. // If the hook DLL ever patches LoadLibraryA/W it must call PatchNewModules
  122. // so that the shim knows to patch any new loaded DLLs
  123. //
  124. typedef VOID (*PFNPATCHNEWMODULES)(VOID);
  125. typedef PHOOKAPI (*PFNGETHOOKAPIS)(LPSTR pszCmdLine,
  126. LPWSTR pwszShim,
  127. DWORD* pdwHooksCount);
  128. //
  129. // These structures are part of the protocol between NTVDM and the shim engine
  130. // for patching task "import tables"
  131. //
  132. typedef struct tagAPIDESC {
  133. char* pszModule;
  134. char* pszApi;
  135. } APIDESC, *PAPIDESC;
  136. typedef struct tagVDMTABLE {
  137. int nApiCount;
  138. PVOID* ppfnOrig;
  139. APIDESC* pApiDesc;
  140. } VDMTABLE, *PVDMTABLE;
  141. //
  142. // Shim engine notification events
  143. //
  144. #define SN_STATIC_DLLS_INITIALIZED 1
  145. #define SN_PROCESS_DYING 2
  146. #define SN_DLL_LOADING 3
  147. //
  148. // This is the prototype for the notification function
  149. // that the shim engine calls into the shim DLLs for various
  150. // reasons (defined above).
  151. //
  152. typedef void (*PFNNOTIFYSHIMS)(int nReason, UINT_PTR extraInfo);
  153. #define SHIM_COMMAND_LINE_MAX_BUFFER 1024
  154. ///////////////////////////////////////////////////////////////////////////////
  155. //
  156. // PATCH STRUCTURES
  157. //
  158. typedef struct _PATCHOP {
  159. DWORD dwOpcode; // Opcode to be performed
  160. DWORD dwNextOpcode; // Relative offset to next opcode
  161. #pragma warning( disable : 4200 )
  162. BYTE data[]; // Data for this operation type is dependent
  163. // on the op-code.
  164. #pragma warning( default : 4200 )
  165. } PATCHOP, *PPATCHOP;
  166. typedef struct _RELATIVE_MODULE_ADDRESS {
  167. DWORD address; // Relative address from beginning of loaded module
  168. BYTE reserved[3]; // Reserved for system use
  169. WCHAR moduleName[32]; // Module name for this address.
  170. } RELATIVE_MODULE_ADDRESS, *PRELATIVE_MODULE_ADDRESS;
  171. typedef struct _PATCHWRITEDATA {
  172. DWORD dwSizeData; // Size of patch data in bytes
  173. RELATIVE_MODULE_ADDRESS rva; // Relative address where this patch data is
  174. // to be applied.
  175. #pragma warning( disable : 4200 )
  176. BYTE data[]; // Patch data bytes.
  177. #pragma warning( default : 4200 )
  178. } PATCHWRITEDATA, *PPATCHWRITEDATA;
  179. typedef struct _PATCHMATCHDATA {
  180. DWORD dwSizeData; // Size of matching data data in bytes
  181. RELATIVE_MODULE_ADDRESS rva; // Relative address where this patch data is
  182. // to be verified.
  183. #pragma warning( disable : 4200 )
  184. BYTE data[]; // Matching data bytes.
  185. #pragma warning( default : 4200 )
  186. } PATCHMATCHDATA, *PPATCHMATCHDATA;
  187. typedef enum _PATCHOPCODES {
  188. PEND = 0, // no more opcodes
  189. PSAA, // Set Activate Address, SETACTIVATEADDRESS
  190. PWD, // Patch Write Data, PATCHWRITEDATA
  191. PNOP, // No Operation
  192. PMAT, // Patch match the matching bytes but do not replace the bytes.
  193. } PATCHOPCODES;
  194. //
  195. // HEADER STRUCTURE
  196. //
  197. #define SHIMDB_MAGIC 0x66626473 // 'sdbf' (reversed because of little-endian ordering)
  198. #define SHIMDB_MAJOR_VERSION 2 // Don't change this unless fundamentals
  199. // change (like TAG size, etc.)
  200. #define SHIMDB_MINOR_VERSION 0 // This is for info only -- ignored on read
  201. typedef struct _DB_HEADER {
  202. DWORD dwMajorVersion;
  203. DWORD dwMinorVersion;
  204. DWORD dwMagic;
  205. } DB_HEADER, *PDB_HEADER;
  206. //
  207. // INDEX_RECORD STRUCTURE
  208. //
  209. #pragma pack (push, 4)
  210. typedef struct _INDEX_RECORD {
  211. ULONGLONG ullKey;
  212. TAGID tiRef;
  213. } INDEX_RECORD;
  214. typedef INDEX_RECORD UNALIGNED *PINDEX_RECORD;
  215. #pragma pack (pop)
  216. //
  217. // Forward declaration.
  218. //
  219. struct _DB;
  220. typedef struct _DB* PDB;
  221. //
  222. // This flag is used in apphelp entries.
  223. // When set, it denotes entries that only have apphelp information.
  224. //
  225. #define SHIMDB_APPHELP_ONLY 0x00000001
  226. typedef enum _PATH_TYPE {
  227. DOS_PATH,
  228. NT_PATH
  229. } PATH_TYPE;
  230. typedef struct _FIND_INFO {
  231. TAGID tiIndex;
  232. TAGID tiCurrent;
  233. TAGID tiEndIndex; // last record after FindFirst if index is UNIQUE
  234. TAG tName;
  235. DWORD dwIndexRec;
  236. DWORD dwFlags;
  237. ULONGLONG ullKey; // calculated key for this entry
  238. union {
  239. LPCTSTR szName;
  240. DWORD dwName; // for dword search
  241. GUID* pguidName;
  242. };
  243. } FIND_INFO, *PFIND_INFO;
  244. #define SDB_MAX_LAYERS 8
  245. #define SDB_MAX_EXES 4
  246. #define SDB_MAX_SDBS 16
  247. typedef struct tagSDBQUERYRESULT {
  248. TAGREF atrExes[SDB_MAX_EXES];
  249. TAGREF atrLayers[SDB_MAX_LAYERS];
  250. TAGREF trAppHelp; // If there is an apphelp to display, the EXE
  251. // entry will be here.
  252. DWORD dwExeCount; // number of elements in atrexes
  253. DWORD dwLayerCount; // number of elements in atrLayers
  254. GUID guidID; // last exe's GUID
  255. DWORD dwFlags; // last exe's flags
  256. //
  257. // New entries are here to preserve compatibility.
  258. // Only some entries will be valid in this map.
  259. //
  260. DWORD dwCustomSDBMap; // entry map, technically not needed
  261. GUID rgGuidDB[SDB_MAX_SDBS];
  262. } SDBQUERYRESULT, *PSDBQUERYRESULT;
  263. //
  264. // Information related to TAG_DRIVER tag in the db.
  265. // Use SdbReadDriverInformation to retrieve this struct.
  266. //
  267. typedef struct tagENTRYINFO {
  268. GUID guidID; // guid ID for this entry
  269. DWORD dwFlags; // registry flags for this exe
  270. TAGID tiData; // optional id for a TAG_DATA tag
  271. GUID guidDB; // optional guid for the database where
  272. // this entry is located
  273. } SDBENTRYINFO, *PSDBENTRYINFO;
  274. //
  275. // Flags used by SDBDATABASEINFO.dwFlags
  276. //
  277. #define DBINFO_GUID_VALID 0x00000001
  278. #define DBINFO_SDBALLOC 0x10000000
  279. typedef struct tagSDBDATABASEINFO {
  280. DWORD dwFlags; // flags -- which struct members are valid (and
  281. // perhaps flags relevant to db content in the future
  282. DWORD dwVersionMajor; // major version
  283. DWORD dwVersionMinor; // minor version (time stamp)
  284. LPTSTR pszDescription; // description, optional
  285. GUID guidDB; // database id
  286. } SDBDATABASEINFO, *PSDBDATABASEINFO;
  287. ///////////////////////////////////////////////////////////////////////////////
  288. //
  289. // APIs to read/write/access the shim database
  290. //
  291. //
  292. // READ functions
  293. //
  294. BYTE
  295. SDBAPI
  296. SdbReadBYTETag(
  297. IN PDB pdb,
  298. IN TAGID tiWhich,
  299. IN BYTE jDefault
  300. );
  301. WORD
  302. SDBAPI
  303. SdbReadWORDTag(
  304. IN PDB pdb,
  305. IN TAGID tiWhich,
  306. IN WORD wDefault
  307. );
  308. DWORD
  309. SDBAPI
  310. SdbReadDWORDTag(
  311. IN PDB pdb,
  312. IN TAGID tiWhich,
  313. IN DWORD dwDefault
  314. );
  315. ULONGLONG
  316. SDBAPI
  317. SdbReadQWORDTag(
  318. IN PDB pdb,
  319. IN TAGID tiWhich,
  320. IN ULONGLONG qwDefault
  321. );
  322. BOOL
  323. SDBAPI
  324. SdbReadBinaryTag(
  325. IN PDB pdb,
  326. IN TAGID tiWhich,
  327. OUT PBYTE pBuffer,
  328. IN DWORD dwBufferSize
  329. );
  330. BOOL
  331. SDBAPI
  332. SdbReadStringTag(
  333. IN PDB pdb,
  334. IN TAGID tiWhich,
  335. OUT LPTSTR pwszBuffer,
  336. IN DWORD dwBufferSize
  337. );
  338. LPTSTR
  339. SDBAPI
  340. SdbGetStringTagPtr(
  341. IN PDB pdb,
  342. IN TAGID tiWhich
  343. );
  344. BYTE
  345. SDBAPI
  346. SdbReadBYTETagRef(
  347. IN HSDB hSDB,
  348. IN TAGREF trWhich,
  349. IN BYTE jDefault
  350. );
  351. WORD
  352. SDBAPI
  353. SdbReadWORDTagRef(
  354. IN HSDB hSDB,
  355. IN TAGREF trWhich,
  356. IN WORD wDefault
  357. );
  358. DWORD
  359. SDBAPI
  360. SdbReadDWORDTagRef(
  361. IN HSDB hSDB,
  362. IN TAGREF trWhich,
  363. IN DWORD dwDefault
  364. );
  365. ULONGLONG
  366. SDBAPI
  367. SdbReadQWORDTagRef(
  368. IN HSDB hSDB,
  369. IN TAGREF trWhich,
  370. IN ULONGLONG qwDefault
  371. );
  372. BOOL
  373. SDBAPI
  374. SdbReadStringTagRef(
  375. IN HSDB hSDB,
  376. IN TAGREF trWhich,
  377. OUT LPTSTR pwszBuffer,
  378. IN DWORD dwBufferSize
  379. );
  380. //
  381. // GENERAL ACCESS FUNCTIONS
  382. //
  383. TAGID
  384. SDBAPI
  385. SdbGetFirstChild(
  386. IN PDB pdb,
  387. IN TAGID tiParent
  388. );
  389. TAGID
  390. SDBAPI
  391. SdbGetNextChild(
  392. IN PDB pdb,
  393. IN TAGID tiParent,
  394. IN TAGID tiPrev
  395. );
  396. TAG
  397. SDBAPI
  398. SdbGetTagFromTagID(
  399. IN PDB pdb,
  400. IN TAGID tiWhich
  401. );
  402. DWORD
  403. SDBAPI
  404. SdbGetTagDataSize(
  405. IN PDB pdb,
  406. IN TAGID tiWhich
  407. );
  408. PVOID
  409. SDBAPI
  410. SdbGetBinaryTagData(
  411. IN PDB pdb,
  412. IN TAGID tiWhich
  413. );
  414. BOOL
  415. SDBAPI
  416. SdbIsTagrefFromMainDB(
  417. TAGREF trWhich
  418. );
  419. BOOL
  420. SDBAPI
  421. SdbIsTagrefFromLocalDB(
  422. TAGREF trWhich
  423. );
  424. typedef struct tagATTRINFO *PATTRINFO;
  425. //////////////////////////////////////////////////////////////////////////
  426. // Grab Matching Information Function Declaration
  427. //
  428. //
  429. // Filters available for SdbGrabMatchingInfo
  430. //
  431. #define GRABMI_FILTER_NORMAL 0
  432. #define GRABMI_FILTER_PRIVACY 1
  433. #define GRABMI_FILTER_DRIVERS 2
  434. #define GRABMI_FILTER_VERBOSE 3
  435. #define GRABMI_FILTER_SYSTEM 4
  436. #define GRABMI_FILTER_THISFILEONLY 5
  437. #define GRABMI_FILTER_NOCLOSE 0x10000000
  438. #define GRABMI_FILTER_APPEND 0x20000000
  439. #define GRABMI_FILTER_LIMITFILES 0x40000000
  440. #define GRABMI_FILTER_NORECURSE 0x80000000
  441. #define GRABMI_IMPOSED_FILE_LIMIT 25
  442. typedef enum GMI_RESULT {
  443. GMI_FAILED = FALSE,
  444. GMI_SUCCESS = TRUE,
  445. GMI_CANCELLED = -1
  446. } GMI_RESULT;
  447. BOOL
  448. SDBAPI
  449. SdbGrabMatchingInfo(
  450. LPCTSTR szMatchingPath,
  451. DWORD dwFilter,
  452. LPCTSTR szFile
  453. );
  454. typedef BOOL (CALLBACK* PFNGMIProgressCallback)(
  455. LPVOID lpvCallbackParam, // application-defined parameter
  456. LPCTSTR lpszRoot, // root directory path
  457. LPCTSTR lpszRelative, // relative path
  458. PATTRINFO pAttrInfo, // attributes
  459. LPCWSTR pwszXML // resulting xml
  460. );
  461. GMI_RESULT
  462. SDBAPI
  463. SdbGrabMatchingInfoEx(
  464. LPCTSTR szMatchingPath,
  465. DWORD dwFilter,
  466. LPCTSTR szFile,
  467. PFNGMIProgressCallback pfnCallback,
  468. LPVOID lpvCallbackParam
  469. );
  470. //
  471. // Module-type constants
  472. //
  473. #define MT_UNKNOWN_MODULE 0
  474. #define MT_DOS_MODULE 1
  475. #define MT_W16_MODULE 2
  476. #define MT_W32_MODULE 3
  477. //////////////////////////////////////////////////////////////////////////
  478. //
  479. // TAGREF functions
  480. //
  481. //////////////////////////////////////////////////////////////////////////
  482. BOOL
  483. SDBAPI
  484. SdbTagIDToTagRef(
  485. IN HSDB hSDB,
  486. IN PDB pdb,
  487. IN TAGID tiWhich,
  488. OUT TAGREF* ptrWhich
  489. );
  490. BOOL
  491. SDBAPI
  492. SdbTagRefToTagID(
  493. IN HSDB hSDB,
  494. IN TAGREF trWhich,
  495. OUT PDB* ppdb,
  496. OUT TAGID* ptiWhich
  497. );
  498. //
  499. // SEARCH functions
  500. //
  501. TAGID
  502. SDBAPI
  503. SdbFindFirstTag(
  504. IN PDB pdb,
  505. IN TAGID tiParent,
  506. IN TAG tTag
  507. );
  508. TAGID
  509. SDBAPI
  510. SdbFindNextTag(
  511. IN PDB pdb,
  512. IN TAGID tiParent,
  513. IN TAGID tiPrev
  514. );
  515. TAGID
  516. SDBAPI
  517. SdbFindFirstNamedTag(
  518. IN PDB pdb,
  519. IN TAGID tiParent,
  520. IN TAG tToFind,
  521. IN TAG tName,
  522. IN LPCTSTR pszName
  523. );
  524. TAGREF
  525. SDBAPI
  526. SdbFindFirstTagRef(
  527. IN HSDB hSDB,
  528. IN TAGREF trParent,
  529. IN TAG tTag
  530. );
  531. TAGREF
  532. SDBAPI
  533. SdbFindNextTagRef(
  534. IN HSDB hSDB,
  535. IN TAGREF trParent,
  536. IN TAGREF trPrev
  537. );
  538. //
  539. // DB access APIs
  540. //
  541. //
  542. // Flags for SdbInitDatabase.
  543. //
  544. #define HID_DOS_PATHS 0x00000001 // use DOS paths
  545. #define HID_DATABASE_FULLPATH 0x00000002 // pszDatabasePath is a full path to the main db
  546. #define HID_NO_DATABASE 0x00000004 // do not open database at this time
  547. #define HID_DATABASE_TYPE_MASK 0xF00F0000 // mask that shows whether we have any
  548. // database type-related bits
  549. //
  550. // The flags could be OR'd with SDB_DATABASE_* bits
  551. //
  552. HSDB
  553. SDBAPI
  554. SdbInitDatabase(
  555. IN DWORD dwFlags,
  556. IN LPCTSTR pszDatabasePath
  557. );
  558. HSDB
  559. SDBAPI
  560. SdbInitDatabaseInMemory(
  561. IN LPVOID pDatabaseImage,
  562. IN DWORD dwImageSize
  563. );
  564. VOID
  565. SDBAPI
  566. SdbReleaseDatabase(
  567. IN HSDB hSDB
  568. );
  569. //
  570. // Information - retrieval functions
  571. //
  572. BOOL
  573. SDBAPI
  574. SdbGetDatabaseVersion(
  575. IN LPCTSTR pwszFileName,
  576. OUT LPDWORD lpdwMajor,
  577. OUT LPDWORD lpdwMinor
  578. );
  579. BOOL
  580. SDBAPI
  581. SdbGetDatabaseInformation(
  582. IN PDB pdb,
  583. OUT PSDBDATABASEINFO pSdbInfo
  584. );
  585. BOOL
  586. SDBAPI
  587. SdbGetDatabaseID(
  588. IN PDB pdb,
  589. OUT GUID* pguidDB
  590. );
  591. DWORD
  592. SDBAPI
  593. SdbGetDatabaseDescription(
  594. IN PDB pdb,
  595. OUT LPTSTR pszDatabaseDescription,
  596. IN DWORD BufferSize
  597. );
  598. VOID
  599. SDBAPI
  600. SdbFreeDatabaseInformation(
  601. IN PSDBDATABASEINFO pDBInfo
  602. );
  603. BOOL
  604. SDBAPI
  605. SdbGetDatabaseInformationByName(
  606. IN LPCTSTR pszDatabase,
  607. OUT PSDBDATABASEINFO* ppdbInfo
  608. );
  609. #define SDBTYPE_SYSMAIN 0x00000001
  610. #define SDBTYPE_SYSTEST 0x00000002
  611. #define SDBTYPE_MSI 0x00000003
  612. #define SDBTYPE_SHIM 0x00000004 // primarily shim db
  613. #define SDBTYPE_APPHELP 0x00000005 // primarily type apphelp
  614. #define SDBTYPE_CUSTOM 0x00010000 // this is an "OR" bit
  615. //
  616. // The function below exists only in user mode on win32 platform
  617. //
  618. BOOL
  619. SDBAPI
  620. SdbUnregisterDatabase(
  621. IN GUID* pguidDB
  622. );
  623. BOOL
  624. SDBAPI
  625. SdbGetDatabaseRegPath(
  626. IN GUID* pguidDB,
  627. OUT LPTSTR pszDatabasePath,
  628. IN DWORD dwBufferSize // size (in tchars) of the buffer
  629. );
  630. /////////////////////////////////////////////////////////////////
  631. //
  632. // Database types
  633. // for SdbResolveDatabase and SdbRegisterDatabase
  634. //
  635. //
  636. // flag that indicates that the database is the default one
  637. // WILL NOT be set for custom databases
  638. //
  639. #define SDB_DATABASE_MAIN 0x80000000
  640. #define SDB_DATABASE_TEST 0x40000000 // systest.sdb will have 0xc00000000
  641. //
  642. // types - one or more apply depending on the contents of the database
  643. // (see HID_DATABASE_TYPE values, they should match database types 1:1)
  644. #define SDB_DATABASE_SHIM 0x00010000 // set when database contains apps to be fixed by shimming
  645. #define SDB_DATABASE_MSI 0x00020000 // set when database contains msi entries
  646. #define SDB_DATABASE_DRIVERS 0x00040000 // set when database contains drivers to be blocked
  647. #define SDB_DATABASE_DETAILS 0x00080000 // set when the db contains apphelp details
  648. #define SDB_DATABASE_SP_DETAILS 0x00100000 // set when the db contains SP apphelp details
  649. #define SDB_DATABASE_TYPE_MASK 0xF01F0000
  650. //
  651. // These constants should be used when derefencing "main" databases
  652. //
  653. #define SDB_DATABASE_MAIN_SHIM (SDB_DATABASE_SHIM | SDB_DATABASE_MSI | SDB_DATABASE_MAIN)
  654. #define SDB_DATABASE_MAIN_MSI (SDB_DATABASE_MSI | SDB_DATABASE_MAIN)
  655. #define SDB_DATABASE_MAIN_DRIVERS (SDB_DATABASE_DRIVERS | SDB_DATABASE_MAIN)
  656. #define SDB_DATABASE_MAIN_TEST (SDB_DATABASE_TEST | SDB_DATABASE_MAIN | SDB_DATABASE_SHIM | SDB_DATABASE_MSI)
  657. #define SDB_DATABASE_MAIN_DETAILS (SDB_DATABASE_DETAILS | SDB_DATABASE_MAIN)
  658. #define SDB_DATABASE_MAIN_SP_DETAILS (SDB_DATABASE_SP_DETAILS | SDB_DATABASE_MAIN)
  659. //
  660. // These are internal GUIDs that always reference certain global databases
  661. //
  662. #define GUID_SZ_SYSMAIN_SDB _T("{11111111-1111-1111-1111-111111111111}");
  663. #define GUID_SZ_APPHELP_SDB _T("{22222222-2222-2222-2222-222222222222}");
  664. #define GUID_SZ_SYSTEST_SDB _T("{33333333-3333-3333-3333-333333333333}");
  665. #define GUID_SZ_DRVMAIN_SDB _T("{F9AB2228-3312-4A73-B6F9-936D70E112EF}"};
  666. //
  667. // the following GUIDs are actually declared in sdbapi.c
  668. //
  669. EXTERN_C const GUID FAR GUID_SYSMAIN_SDB;
  670. EXTERN_C const GUID FAR GUID_APPHELP_SDB;
  671. EXTERN_C const GUID FAR GUID_APPHELP_SP_SDB;
  672. EXTERN_C const GUID FAR GUID_SYSTEST_SDB;
  673. EXTERN_C const GUID FAR GUID_DRVMAIN_SDB;
  674. EXTERN_C const GUID FAR GUID_MSIMAIN_SDB;
  675. BOOL
  676. SDBAPI
  677. SdbGetStandardDatabaseGUID(
  678. IN DWORD dwDatabaseType,
  679. OUT GUID* pGuidDB
  680. );
  681. BOOL
  682. SDBAPI
  683. SdbRegisterDatabase(
  684. IN LPCTSTR pszDatabasePath,
  685. IN DWORD dwDatabaseType
  686. );
  687. BOOL
  688. SDBAPI
  689. SdbRegisterDatabaseEx(
  690. IN LPCTSTR pszDatabasePath,
  691. IN DWORD dwDatabaseType,
  692. IN PULONGLONG pTimeStamp
  693. );
  694. DWORD
  695. SDBAPI
  696. SdbResolveDatabase(
  697. IN GUID* pguidDB, // pointer to the database guid to resolve
  698. OUT LPDWORD lpdwDatabaseType, // optional pointer to the database type
  699. OUT LPTSTR pszDatabasePath, // optional pointer to the database path
  700. IN DWORD dwBufferSize // size of the buffer pszDatabasePath in tchars
  701. );
  702. PDB
  703. SdbGetPDBFromGUID(
  704. IN HSDB hSDB, // HSDB
  705. IN GUID* pguidDB // the guid of the DB
  706. );
  707. BOOL
  708. SdbGetDatabaseGUID(
  709. IN HSDB hSDB, // HSDB of the sdbContext (optional)
  710. IN PDB pdb, // PDB of the database in question
  711. OUT GUID* pguidDB // the guid of the DB
  712. );
  713. TAGREF
  714. SDBAPI
  715. SdbFindMsiPackageByID(
  716. IN HSDB hSDB,
  717. IN GUID* pguidID
  718. );
  719. void
  720. SdbpGetAppPatchDir(
  721. LPTSTR szAppPatchPath
  722. );
  723. //
  724. // GUID manipulation apis - not platform dependent
  725. //
  726. BOOL
  727. SDBAPI
  728. SdbGUIDFromString(
  729. IN LPCTSTR lpszGuid,
  730. OUT GUID* pGuid
  731. );
  732. BOOL
  733. SDBAPI
  734. SdbGUIDToString(
  735. IN GUID* pGuid,
  736. OUT LPTSTR pszGuid
  737. );
  738. BOOL
  739. SDBAPI
  740. SdbIsNullGUID(
  741. IN GUID* pGuid
  742. );
  743. //
  744. // open/create and close database.
  745. //
  746. PDB
  747. SDBAPI
  748. SdbOpenDatabase(
  749. IN LPCTSTR pwszPath,
  750. IN PATH_TYPE eType
  751. );
  752. BOOL
  753. SDBAPI
  754. SdbOpenLocalDatabase(
  755. IN HSDB hSDB,
  756. IN LPCTSTR pwszLocalDatabase
  757. );
  758. BOOL
  759. SDBAPI
  760. SdbCloseLocalDatabase(
  761. IN HSDB hSDB
  762. );
  763. PDB
  764. SDBAPI
  765. SdbCreateDatabase(
  766. IN LPCWSTR pwszPath,
  767. IN PATH_TYPE eType
  768. );
  769. void
  770. SDBAPI
  771. SdbCloseDatabase(
  772. IN PDB pdb
  773. );
  774. //
  775. // Search the database looking for an entry for the specified exe.
  776. //
  777. //
  778. // Flags for SdbGetMatchingExe dwFlags
  779. //
  780. #define SDBGMEF_IGNORE_ENVIRONMENT 0x00000001
  781. BOOL
  782. SdbGetMatchingExe(
  783. IN HSDB hSDB OPTIONAL,
  784. IN LPCTSTR pwszPath,
  785. IN LPCTSTR szModuleName,
  786. IN LPCTSTR pwszEnvironment,
  787. IN DWORD dwFlags,
  788. OUT PSDBQUERYRESULT pQueryResult
  789. );
  790. void
  791. SdbReleaseMatchingExe(
  792. IN HSDB hSDB,
  793. IN TAGREF trExe
  794. );
  795. TAGREF
  796. SDBAPI
  797. SdbGetDatabaseMatch(
  798. IN HSDB hSDB,
  799. IN LPCTSTR szPath,
  800. IN HANDLE FileHandle OPTIONAL,
  801. IN LPVOID pImageBase OPTIONAL,
  802. IN DWORD dwImageSize OPTIONAL
  803. );
  804. TAGREF
  805. SdbGetLayerTagReg(
  806. IN HSDB hSDB,
  807. IN LPCTSTR szLayer
  808. );
  809. PDB
  810. SDBAPI
  811. SdbGetLocalPDB(
  812. IN HSDB hSDB
  813. );
  814. LPTSTR
  815. SDBAPI
  816. SdbGetLayerName(
  817. IN HSDB hSDB,
  818. IN TAGREF trLayer
  819. );
  820. TAGREF
  821. SDBAPI
  822. SdbGetNamedLayer(
  823. IN HSDB hSDB, // database context
  824. IN TAGREF trLayerRef // tagref of a record referencing a layer
  825. );
  826. #define SBCE_ADDITIVE 0x00000001
  827. #define SBCE_INCLUDESYSTEMEXES 0x00000002
  828. #define SBCE_INHERITENV 0x00000004
  829. DWORD
  830. SdbBuildCompatEnvVariables(
  831. IN HSDB hSDB,
  832. IN SDBQUERYRESULT* psdbQuery,
  833. IN DWORD dwFlags,
  834. IN LPCWSTR pwszParentEnv OPTIONAL, // Environment which contains vars we
  835. // shall inherit from
  836. OUT LPWSTR pBuffer,
  837. IN DWORD cbSize, // size of the buffer in tchars
  838. OUT LPDWORD lpdwShimsCount OPTIONAL
  839. );
  840. //
  841. // MSI-specific functionality
  842. //
  843. typedef enum tagSDBMSILOOKUPSTATE {
  844. LOOKUP_NONE = 0, // this should be the first state
  845. LOOKUP_LOCAL,
  846. LOOKUP_CUSTOM,
  847. LOOKUP_TEST,
  848. LOOKUP_MAIN,
  849. LOOKUP_DONE // this should be the last state
  850. } SDBMSILOOKUPSTATE;
  851. typedef struct tagSDBMSIFINDINFO {
  852. TAGREF trMatch; // tagref of the matching package
  853. GUID guidID; // guid of this current package
  854. FIND_INFO sdbFindInfo; // standard sdb find info
  855. // this is used to persist the state of the current search
  856. //
  857. SDBMSILOOKUPSTATE sdbLookupState;
  858. DWORD dwCustomIndex;
  859. } SDBMSIFINDINFO, *PSDBMSIFINDINFO;
  860. typedef struct tagSDBMSITRANSFORMINFO {
  861. LPCTSTR lpszTransformName; // name of the transform
  862. TAGREF trTransform; // tagref of this transform
  863. TAGREF trFile; // tagref of file for this transform (bits)
  864. } SDBMSITRANSFORMINFO, *PSDBMSITRANSFORMINFO;
  865. //
  866. // Information for any individual MSI package
  867. //
  868. typedef struct tagMSIPACKAGEINFO {
  869. GUID guidID; // unique guid for this entry
  870. GUID guidMsiPackageID; // guid (non-unique, for this entry)
  871. GUID guidDatabaseID; // guid of the database where this had been found
  872. DWORD dwPackageFlags; // Package flags (see below)
  873. } MSIPACKAGEINFO, *PMSIPACKAGEINFO;
  874. #define MSI_PACKAGE_HAS_APPHELP 0x00000001
  875. #define MSI_PACKAGE_HAS_SHIMS 0x00000002
  876. TAGREF
  877. SDBAPI
  878. SdbFindFirstMsiPackage_Str(
  879. IN HSDB hSDB,
  880. IN LPCTSTR lpszGuid,
  881. IN LPCTSTR lpszLocalDB,
  882. OUT PSDBMSIFINDINFO pFindInfo
  883. );
  884. TAGREF
  885. SDBAPI
  886. SdbFindFirstMsiPackage(
  887. IN HSDB hSDB, // in HSDB context
  888. IN GUID* pGuidID, // in GUID that we're looking for
  889. IN LPCTSTR lpszLocalDB, // in optional path to local db, dos path style
  890. OUT PSDBMSIFINDINFO pFindInfo // pointer to our search context
  891. );
  892. TAGREF
  893. SDBAPI
  894. SdbFindNextMsiPackage(
  895. IN HSDB hSDB,
  896. IN OUT PSDBMSIFINDINFO pFindInfo
  897. );
  898. BOOL
  899. SDBAPI
  900. SdbGetMsiPackageInformation(
  901. IN HSDB hSDB,
  902. IN TAGREF trMatch,
  903. OUT PMSIPACKAGEINFO pPackageInfo
  904. );
  905. DWORD
  906. SDBAPI
  907. SdbEnumMsiTransforms(
  908. IN HSDB hSDB, // in HSDB context
  909. IN TAGREF trMatch, // matched entry
  910. OUT TAGREF* ptrBuffer, // array of tagrefs to fill with msi transform "fixes"
  911. IN OUT DWORD* pdwBufferSize // pointer to the buffer size, receives the number of
  912. // bytes written
  913. );
  914. BOOL
  915. SDBAPI
  916. SdbReadMsiTransformInfo(
  917. IN HSDB hSDB, // HSDB context
  918. IN TAGREF trTransformRef, // reference to a transform, returned
  919. // by SdbEnumMsiTransforms
  920. OUT PSDBMSITRANSFORMINFO pTransformInfo // information structure
  921. );
  922. BOOL
  923. SDBAPI
  924. SdbCreateMsiTransformFile(
  925. IN HSDB hSDB, // context
  926. IN LPCTSTR lpszFileName, // filename to write data to
  927. IN PSDBMSITRANSFORMINFO pTransformInfo // pointer to the transform structure
  928. );
  929. TAGREF
  930. SDBAPI
  931. SdbFindCustomActionForPackage(
  932. IN HSDB hSDB,
  933. IN TAGREF trPackage,
  934. IN LPCTSTR lpszCustomAction);
  935. #define SdbGetFirstMsiTransformForPackage(hSDB, trPackage) \
  936. (SdbFindFirstTagRef((hSDB), (trPackage), TAG_MSI_TRANSFORM_REF))
  937. #define SdbGetNextMsiTransformForPackage(hSDB, trPackage, trPrevMatch) \
  938. (SdbFindNextTagRef((hSDB), (trPackage), (trPrevMatch)))
  939. //
  940. // "disable" registry entry masks
  941. //
  942. #define SHIMREG_DISABLE_SHIM 0x00000001
  943. #define SHIMREG_DISABLE_APPHELP 0x00000002 // disables apphelp
  944. #define SHIMREG_APPHELP_NOUI 0x00000004 // suppress apphelp ui
  945. #define SHIMREG_APPHELP_CANCEL 0x10000000 // returns CANCEL as a default action
  946. #define SHIMREG_DISABLE_SXS 0x00000010
  947. #define SHIMREG_DISABLE_LAYER 0x00000020
  948. #define SHIMREG_DISABLE_DRIVER 0x00000040
  949. BOOL
  950. SDBAPI
  951. SdbSetEntryFlags(
  952. IN GUID* pGuidID,
  953. IN DWORD dwFlags
  954. );
  955. BOOL
  956. SDBAPI
  957. SdbGetEntryFlags(
  958. IN GUID* pGuid,
  959. OUT LPDWORD lpdwFlags
  960. );
  961. //
  962. // Flags used by Get/SetPermLayerKeys
  963. //
  964. #define GPLK_USER 0x00000001
  965. #define GPLK_MACHINE 0x00000002
  966. #define GPLK_ALL (GPLK_USER | GPLK_MACHINE)
  967. BOOL
  968. SDBAPI
  969. SdbGetPermLayerKeys(
  970. LPCTSTR szPath,
  971. LPTSTR szLayers,
  972. LPDWORD pdwBytes,
  973. DWORD dwFlags
  974. );
  975. BOOL
  976. SDBAPI
  977. SdbSetPermLayerKeys(
  978. LPCTSTR szPath,
  979. LPCTSTR szLayers,
  980. BOOL bMachine
  981. );
  982. BOOL
  983. SDBAPI
  984. SdbDeletePermLayerKeys(
  985. LPCTSTR szPath,
  986. BOOL bMachine
  987. );
  988. BOOL
  989. SdbGetNthUserSdb(
  990. IN HSDB hSDB, // context
  991. IN LPCTSTR wszItemName, // item name (foo.exe or layer name)
  992. IN BOOL bLayer, // true if layer name
  993. IN OUT LPDWORD pdwIndex, // (0-based)
  994. OUT GUID* pGuidDB // database guid
  995. );
  996. //
  997. // APIs to pack/unpack appcompat data package.
  998. //
  999. BOOL
  1000. SdbPackAppCompatData(
  1001. IN HSDB hSDB,
  1002. IN PSDBQUERYRESULT pSdbQuery,
  1003. OUT PVOID* ppData,
  1004. OUT LPDWORD pdwSize
  1005. );
  1006. BOOL
  1007. SdbUnpackAppCompatData(
  1008. IN HSDB hSDB,
  1009. IN LPCWSTR pwszExeName,
  1010. IN PVOID pAppCompatData,
  1011. OUT PSDBQUERYRESULT pSdbQuery
  1012. );
  1013. DWORD
  1014. SdbGetAppCompatDataSize(
  1015. IN PVOID pAppCompatData
  1016. );
  1017. //
  1018. // DLL functions
  1019. //
  1020. BOOL
  1021. SdbGetDllPath(
  1022. IN HSDB hSDB,
  1023. IN TAGREF trDllRef,
  1024. OUT LPTSTR pwszBuffer
  1025. );
  1026. //
  1027. // PATCH functions
  1028. //
  1029. BOOL
  1030. SdbReadPatchBits(
  1031. IN HSDB hSDB,
  1032. IN TAGREF trPatchRef,
  1033. OUT PVOID pBuffer,
  1034. OUT LPDWORD lpdwBufferSize
  1035. );
  1036. //
  1037. // SDBDRIVERINFO query function
  1038. //
  1039. BOOL
  1040. SDBAPI
  1041. SdbReadEntryInformation(
  1042. IN HSDB hSDB,
  1043. IN TAGREF trDriver,
  1044. OUT PSDBENTRYINFO pEntryInfo
  1045. );
  1046. DWORD
  1047. SDBAPI
  1048. SdbQueryData(
  1049. IN HSDB hSDB,
  1050. IN TAGREF trExe,
  1051. IN LPCTSTR lpszPolicyName, // if this is null, will try to return all the policy names
  1052. OUT LPDWORD lpdwDataType,
  1053. OUT LPVOID lpBuffer, // buffer to fill with information
  1054. IN OUT LPDWORD lpdwBufferSize
  1055. );
  1056. DWORD
  1057. SDBAPI
  1058. SdbQueryDataEx(
  1059. IN HSDB hSDB, // database handle
  1060. IN TAGREF trExe, // tagref of the matching exe
  1061. IN LPCTSTR lpszDataName, // if this is null, will try to return all the policy names
  1062. OUT LPDWORD lpdwDataType, // pointer to data type (REG_SZ, REG_BINARY, etc)
  1063. OUT LPVOID lpBuffer, // buffer to fill with information
  1064. IN OUT LPDWORD lpdwBufferSize, // pointer to buffer size
  1065. OUT TAGREF* ptrData // optional pointer to the retrieved data tag
  1066. );
  1067. DWORD
  1068. SdbQueryDataExTagID(
  1069. IN PDB pdb, // database handle
  1070. IN TAGID tiExe, // tagref of the matching exe
  1071. IN LPCTSTR lpszDataName, // if this is null, will try to return all the policy names
  1072. OUT LPDWORD lpdwDataType, // pointer to data type (REG_SZ, REG_BINARY, etc)
  1073. OUT LPVOID lpBuffer, // buffer to fill with information
  1074. IN OUT LPDWORD lpdwBufferSize, // pointer to buffer size
  1075. OUT TAGID* ptiData // optional pointer to the retrieved data tag
  1076. );
  1077. //
  1078. // Defines to keep kernel-mode code more readable
  1079. //
  1080. #define SdbQueryDriverInformation SdbQueryData
  1081. #define SdbReadDriverInformation SdbReadEntryInformation
  1082. #define SDBDRIVERINFO SDBENTRYINFO;
  1083. #define PSDBDRIVERINFO PSDBENTRYINFO;
  1084. //
  1085. // Query attribute APIs
  1086. //
  1087. PVOID
  1088. SdbGetFileInfo(
  1089. IN HSDB hSDB,
  1090. IN LPCTSTR pwszFilePath,
  1091. IN HANDLE hFile OPTIONAL,
  1092. IN LPVOID pImageBase OPTIONAL,
  1093. IN DWORD dwImageSize OPTIONAL,
  1094. IN BOOL bNoCache
  1095. );
  1096. VOID
  1097. SdbFreeFileInfo(
  1098. IN PVOID pFileInfo
  1099. );
  1100. //
  1101. // Get item from item ref
  1102. //
  1103. TAGREF
  1104. SdbGetItemFromItemRef(
  1105. IN HSDB hSDB,
  1106. IN TAGREF trItemRef,
  1107. IN TAG tagItemKey,
  1108. IN TAG tagItemTAGID,
  1109. IN TAG tagItem
  1110. );
  1111. #define SdbGetShimFromShimRef(hSDB, trShimRef) \
  1112. (SdbGetItemFromItemRef(hSDB, trShimRef, TAG_NAME, TAG_SHIM_TAGID, TAG_SHIM))
  1113. #define SdbGetPatchFromPatchRef(hSDB, trPatchRef) \
  1114. (SdbGetItemFromItemRef(hSDB, trPatchRef, TAG_NAME, TAG_PATCH_TAGID, TAG_PATCH))
  1115. #define SdbGetFlagFromFlagRef(hSDB, trFlagRef) \
  1116. (SdbGetItemFromItemRef(hSDB, trFlagRef, TAG_NAME, TAG_FLAG_TAGID, TAG_FLAG))
  1117. // INDEX functions
  1118. BOOL SdbDeclareIndex(
  1119. IN PDB pdb,
  1120. IN TAG tWhich,
  1121. IN TAG tKey,
  1122. IN DWORD dwEntries,
  1123. IN BOOL bUniqueKey,
  1124. OUT INDEXID* piiIndex
  1125. );
  1126. BOOL
  1127. SdbStartIndexing(
  1128. IN PDB pdb,
  1129. IN INDEXID iiWhich
  1130. );
  1131. BOOL
  1132. SdbStopIndexing(
  1133. IN PDB pdb,
  1134. IN INDEXID iiWhich
  1135. );
  1136. BOOL
  1137. SdbCommitIndexes(
  1138. IN PDB pdb
  1139. );
  1140. TAGID
  1141. SdbFindFirstDWORDIndexedTag(
  1142. IN PDB pdb,
  1143. IN TAG tWhich,
  1144. IN TAG tKey,
  1145. IN DWORD dwName,
  1146. OUT FIND_INFO* pFindInfo
  1147. );
  1148. TAGID
  1149. SdbFindNextDWORDIndexedTag(
  1150. IN PDB pdb,
  1151. OUT FIND_INFO* pFindInfo
  1152. );
  1153. TAGID
  1154. SdbFindFirstStringIndexedTag(
  1155. IN PDB pdb,
  1156. IN TAG tWhich,
  1157. IN TAG tKey,
  1158. IN LPCTSTR pwszName,
  1159. OUT FIND_INFO* pFindInfo
  1160. );
  1161. TAGID
  1162. SdbFindNextStringIndexedTag(
  1163. IN PDB pdb,
  1164. OUT FIND_INFO* pFindInfo
  1165. );
  1166. TAGID
  1167. SdbFindFirstGUIDIndexedTag(
  1168. IN PDB pdb,
  1169. IN TAG tWhich,
  1170. IN TAG tKey,
  1171. IN GUID* pGuidName,
  1172. OUT FIND_INFO* pFindInfo
  1173. );
  1174. TAGID
  1175. SdbFindNextGUIDIndexedTag(
  1176. IN PDB pdb,
  1177. OUT FIND_INFO* pFindInfo
  1178. );
  1179. ULONGLONG
  1180. SdbMakeIndexKeyFromString(
  1181. IN LPCTSTR pwszKey
  1182. );
  1183. //
  1184. // These macros allow to make a key from dword or a guid
  1185. //
  1186. #define MAKEKEYFROMDWORD(dwValue) \
  1187. ((ULONGLONG)(dwValue))
  1188. #if defined(_WIN64)
  1189. ULONGLONG
  1190. SdbMakeIndexKeyFromGUID(
  1191. IN GUID* pGuid
  1192. );
  1193. #define MAKEKEYFROMGUID(pGuid) SdbMakeIndexKeyFromGUID(pGuid)
  1194. #else /* ! WIN64 */
  1195. #define MAKEKEYFROMGUID(pGuid) \
  1196. ((ULONGLONG)((*(PULONGLONG)(pGuid)) ^ (*((PULONGLONG)(pGuid) + 1))))
  1197. #endif /* WIN64 */
  1198. TAGID
  1199. SdbGetIndex(
  1200. IN PDB pdb,
  1201. IN TAG tWhich,
  1202. IN TAG tKey,
  1203. OUT LPDWORD lpdwFlags OPTIONAL
  1204. );
  1205. #define SdbIsIndexAvailable(pdb, tWhich, tKey) \
  1206. (SdbGetIndex(pdb, tWhich, tKey, NULL))
  1207. //
  1208. // WRITE FUNCTIONS
  1209. //
  1210. TAGID
  1211. SdbBeginWriteListTag(
  1212. IN PDB pdb,
  1213. IN TAG tTag
  1214. );
  1215. BOOL
  1216. SdbEndWriteListTag(
  1217. IN PDB pdb,
  1218. IN TAGID tiList
  1219. );
  1220. BOOL
  1221. SdbWriteStringTagDirect(
  1222. IN PDB pdb,
  1223. IN TAG tTag,
  1224. IN LPCWSTR pwszData
  1225. );
  1226. BOOL
  1227. SdbWriteStringRefTag(
  1228. IN PDB pdb,
  1229. IN TAG tTag,
  1230. IN STRINGREF srData
  1231. );
  1232. BOOL
  1233. SdbWriteNULLTag(
  1234. IN PDB pdb,
  1235. IN TAG tTag
  1236. );
  1237. BOOL
  1238. SdbWriteBYTETag(
  1239. IN PDB pdb,
  1240. IN TAG tTag,
  1241. IN BYTE jData
  1242. );
  1243. BOOL
  1244. SdbWriteWORDTag(
  1245. IN PDB pdb,
  1246. IN TAG tTag,
  1247. IN WORD wData
  1248. );
  1249. BOOL
  1250. SdbWriteDWORDTag(
  1251. IN PDB pdb,
  1252. IN TAG tTag,
  1253. IN DWORD dwData
  1254. );
  1255. BOOL
  1256. SdbWriteQWORDTag(
  1257. IN PDB pdb,
  1258. IN TAG tTag,
  1259. IN ULONGLONG qwData
  1260. );
  1261. BOOL
  1262. SdbWriteStringTag(
  1263. IN PDB pdb,
  1264. IN TAG tTag,
  1265. IN LPCWSTR pwszData
  1266. );
  1267. BOOL
  1268. SdbWriteBinaryTag(
  1269. IN PDB pdb,
  1270. IN TAG tTag,
  1271. IN PBYTE pBuffer,
  1272. IN DWORD dwSize
  1273. );
  1274. BOOL
  1275. SdbWriteBinaryTagFromFile(
  1276. IN PDB pdb,
  1277. IN TAG tTag,
  1278. IN LPCWSTR pwszPath
  1279. );
  1280. ////////////////////////////////////////////////////////////////////////////////////////////
  1281. //
  1282. // Attribute retrieval
  1283. //
  1284. //
  1285. //
  1286. // Attribute Information
  1287. // identified by a tag
  1288. //
  1289. //
  1290. typedef struct tagATTRINFO {
  1291. TAG tAttrID; // tag for this attribute (includes type)
  1292. DWORD dwFlags; // flags : such as "not avail" or "not there yet"
  1293. union { // anonymous union with values
  1294. ULONGLONG ullAttr; // QWORD value (TAG_TYPE_QWORD)
  1295. DWORD dwAttr; // DWORD value (TAG_TYPE_DWORD)
  1296. TCHAR* lpAttr; // WCHAR* value (TAG_TYPE_STRINGREF)
  1297. };
  1298. } ATTRINFO, *PATTRINFO;
  1299. //
  1300. // Flags that go into ATTRINFO's dwFlags field
  1301. //
  1302. //
  1303. #define ATTRIBUTE_AVAILABLE 0x00000001 // this will be set if attribute was obtained
  1304. #define ATTRIBUTE_FAILED 0x00000002 // this will be set if we tried to get it
  1305. // and failed
  1306. BOOL
  1307. SDBAPI
  1308. SdbGetFileAttributes(
  1309. IN LPCTSTR lpwszFileName,
  1310. OUT PATTRINFO* ppAttrInfo,
  1311. OUT LPDWORD lpdwAttrCount);
  1312. BOOL
  1313. SDBAPI
  1314. SdbFreeFileAttributes(
  1315. IN PATTRINFO pFileAttributes);
  1316. BOOL
  1317. SDBAPI
  1318. SdbFormatAttribute(
  1319. IN PATTRINFO pAttrInfo,
  1320. OUT LPTSTR pchBuffer,
  1321. IN DWORD dwBufferSize);
  1322. ////////////////////////////////////////////////////////////////////////////////////////////
  1323. //
  1324. //
  1325. // High-level functions to extract information related to apphelp
  1326. //
  1327. //
  1328. typedef struct tagAPPHELP_DATA {
  1329. DWORD dwFlags; // flags (if any)
  1330. DWORD dwSeverity; // can be none APPTYPE_NONE (0)
  1331. DWORD dwHTMLHelpID; // help id
  1332. LPTSTR szAppName;
  1333. TAGREF trExe; // matched on this exe (in apphelp section)
  1334. LPTSTR szURL; // URL
  1335. LPTSTR szLink; // link text
  1336. LPTSTR szAppTitle; // title
  1337. LPTSTR szContact; // contact info
  1338. LPTSTR szDetails; // details
  1339. //
  1340. // non-apphelp data (this is managed by the host app
  1341. //
  1342. DWORD dwData;
  1343. BOOL bSPEntry; // TRUE if this entry is in apph_sp.sdb
  1344. } APPHELP_DATA, *PAPPHELP_DATA;
  1345. BOOL
  1346. SdbReadApphelpData(
  1347. IN HSDB hSDB,
  1348. IN TAGREF trExe,
  1349. OUT PAPPHELP_DATA pData
  1350. );
  1351. BOOL
  1352. SdbReadApphelpDetailsData(
  1353. IN PDB pdbDetails,
  1354. OUT PAPPHELP_DATA pData
  1355. );
  1356. ////////////////////////////////////////////////////////////////////////////////////////////
  1357. //
  1358. //
  1359. // A few functions from apphelp.dll
  1360. //
  1361. //
  1362. BOOL
  1363. SDBAPI
  1364. SetPermLayers(
  1365. IN LPCWSTR pwszPath, // path to the file to set a permanent layer on
  1366. IN LPCWSTR pwszLayers, // layers to apply to the file, separated by spaces
  1367. IN BOOL bMachine // TRUE if the layers should be persisted per machine
  1368. );
  1369. BOOL
  1370. SDBAPI
  1371. GetPermLayers(
  1372. IN LPCWSTR pwszPath, // path to the file to set a permanent layer on
  1373. OUT LPWSTR pwszLayers, // layers to apply to the file, separated by spaces
  1374. OUT DWORD* pdwBytes, // input: number of bytes available; output is number of bytes needed
  1375. IN DWORD dwFlags
  1376. );
  1377. BOOL
  1378. SDBAPI
  1379. AllowPermLayer(
  1380. IN LPCWSTR pwszPath // path to the file to check whether you can set a permanent layer on
  1381. );
  1382. typedef struct _NTVDM_FLAGS {
  1383. DWORD dwWOWCompatFlags;
  1384. DWORD dwWOWCompatFlagsEx;
  1385. DWORD dwUserWOWCompatFlags;
  1386. DWORD dwWOWCompatFlags2;
  1387. DWORD dwWOWCompatFlagsFE;
  1388. DWORD dwFlagsInfoSize; // size of the memory area pointed to by pFlagsInfo
  1389. PVOID pFlagsInfo; // pointer that is used to store flags-related information
  1390. } NTVDM_FLAGS, *PNTVDM_FLAGS;
  1391. //
  1392. // Macros we use to obtain flags command lines
  1393. //
  1394. #define MAKEQWORD(dwLow, dwHigh) \
  1395. ( ((ULONGLONG)(dwLow)) | ( ((ULONGLONG)(dwHigh)) << 32) )
  1396. #define GET_WOWCOMPATFLAGS_CMDLINE(pFlagInfo, dwFlag, ppCmdLine) \
  1397. SdbQueryFlagInfo(pFlagInfo, TAG_FLAGS_NTVDM1, MAKEQWORD(dwFlag, 0), ppCmdLine)
  1398. #define GET_WOWCOMPATFLAGSEX_CMDLINE(pFlagInfo, dwFlag, ppCmdLine) \
  1399. SdbQueryFlagInfo(pFlagInfo, TAG_FLAGS_NTVDM1, MAKEQWORD(0, dwFlag), ppCmdLine)
  1400. #define GET_USERWOWCOMPATFLAGS_CMDLINE(pFlagInfo, dwFlag, ppCmdLine) \
  1401. SdbQueryFlagInfo(pFlagInfo, TAG_FLAGS_NTVDM2, MAKEQWORD(dwFlag, 0), ppCmdLine)
  1402. #define GET_WOWCOMPATFLAGS2_CMDLINE(pFlagInfo, dwFlag, ppCmdLine) \
  1403. SdbQueryFlagInfo(pFlagInfo, TAG_FLAGS_NTVDM2, MAKEQWORD(0, dwFlag), ppCmdLine)
  1404. #define GET_WOWCOMPATFLAGSFE_CMDLINE(pFlagInfo, dwFlag, ppCmdLine) \
  1405. SdbQueryFlagInfo(pFlagInfo, TAG_FLAGS_NTVDM3, MAKEQWORD(dwFlag, 0), ppCmdLine)
  1406. typedef struct _APPHELP_INFO {
  1407. //
  1408. // html help id mode
  1409. //
  1410. DWORD dwHtmlHelpID; // html help id
  1411. DWORD dwSeverity; // must have
  1412. LPCTSTR lpszAppName;
  1413. GUID guidID; // entry guid
  1414. //
  1415. // Conventional mode
  1416. //
  1417. TAGID tiExe; // the TAGID of the exe entry within the DB
  1418. GUID guidDB; // the guid of the DB that has the EXE entry
  1419. BOOL bOfflineContent;
  1420. BOOL bUseHTMLHelp;
  1421. LPCTSTR lpszChmFile;
  1422. LPCTSTR lpszDetailsFile;
  1423. //
  1424. // preserve users choice on the dialog if user chooses to persist settings
  1425. //
  1426. BOOL bPreserveChoice;
  1427. } APPHELP_INFO, *PAPPHELP_INFO;
  1428. ////////////////////////////////////////////////////////////////////////////////////////////
  1429. //
  1430. //
  1431. // Functions to access apphelp functionality
  1432. //
  1433. //
  1434. BOOL
  1435. ApphelpGetNTVDMInfo(
  1436. IN LPCWSTR pwszPath, // path to the app in NT format
  1437. IN LPCWSTR pwszModule, // module name
  1438. IN LPCWSTR pEnvironment, // pointer to the environment of the task that is
  1439. // being created or NULL if we are to use the main NTVDM
  1440. // environment block.
  1441. OUT LPWSTR pszCompatLayer, // The new compat layer variable. with format:
  1442. // "Alpha Bravo Charlie" -- allow 256 chars for this.
  1443. OUT PNTVDM_FLAGS pFlags, // The flags
  1444. OUT PAPPHELP_INFO pAHInfo // If there is apphelp to display, this will be filled
  1445. // in with non-null values
  1446. );
  1447. BOOL
  1448. ApphelpShowDialog(
  1449. IN PAPPHELP_INFO pAHInfo, // the info necessary to find the apphelp data
  1450. IN PHANDLE phProcess // [optional] returns the process handle of
  1451. // the process displaying the apphelp.
  1452. // When the process completes, the return value
  1453. // (from GetExitCodeProcess()) will be zero
  1454. // if the app should not run, or non-zero
  1455. // if it should run.
  1456. );
  1457. typedef PVOID HAPPHELPINFOCONTEXT;
  1458. typedef enum tagAPPHELPINFORMATIONCLASS {
  1459. ApphelpFlags,
  1460. ApphelpExeName,
  1461. ApphelpAppName,
  1462. ApphelpVendorName,
  1463. ApphelpHtmlHelpID,
  1464. ApphelpProblemSeverity,
  1465. ApphelpLinkURL,
  1466. ApphelpLinkText,
  1467. ApphelpTitle,
  1468. ApphelpDetails,
  1469. ApphelpContact,
  1470. ApphelpHelpCenterURL,
  1471. ApphelpExeTagID,
  1472. ApphelpDatabaseGUID // this is guid of a database containing the match
  1473. } APPHELPINFORMATIONCLASS;
  1474. PDB
  1475. SDBAPI
  1476. SdbOpenApphelpDetailsDatabase(
  1477. IN LPCWSTR pwsDetailsDatabasePath OPTIONAL
  1478. );
  1479. PDB
  1480. SDBAPI
  1481. SdbOpenApphelpDetailsDatabaseSP(
  1482. void
  1483. );
  1484. HAPPHELPINFOCONTEXT
  1485. SDBAPI
  1486. SdbOpenApphelpInformation(
  1487. IN GUID* pguidDB,
  1488. IN GUID* pguidID
  1489. );
  1490. HAPPHELPINFOCONTEXT
  1491. SDBAPI
  1492. SdbOpenApphelpInformationByID(
  1493. IN HSDB hSDB,
  1494. IN TAGREF trEntry,
  1495. IN DWORD dwDatabaseType // pass the type of db you are using
  1496. );
  1497. BOOL
  1498. SDBAPI
  1499. SdbCloseApphelpInformation(
  1500. IN HAPPHELPINFOCONTEXT hctx
  1501. );
  1502. DWORD
  1503. SDBAPI
  1504. SdbQueryApphelpInformation(
  1505. IN HAPPHELPINFOCONTEXT hctx,
  1506. IN APPHELPINFORMATIONCLASS InfoClass,
  1507. OUT LPVOID pBuffer, // may be NULL
  1508. IN DWORD cbSize // may be 0 if pBuffer is NULL
  1509. );
  1510. BOOL
  1511. SDBAPI
  1512. SdbQueryFlagMask(
  1513. IN HSDB hSDB,
  1514. IN SDBQUERYRESULT* pQueryResult,
  1515. IN TAG tMaskType,
  1516. OUT ULONGLONG* pullFlags,
  1517. IN OUT PVOID* ppFlagInfo OPTIONAL
  1518. );
  1519. BOOL
  1520. SDBAPI
  1521. SdbEscapeApphelpURL(
  1522. OUT LPWSTR szResult, // escaped string (output)
  1523. IN OUT LPDWORD pdwCount, // count of tchars in the buffer pointed to by szResult
  1524. IN LPCWSTR szToEscape // string to escape
  1525. );
  1526. BOOL
  1527. SDBAPI
  1528. SdbSetApphelpDebugParameters(
  1529. IN HAPPHELPINFOCONTEXT hctx,
  1530. IN LPCWSTR pszDetailsDatabase OPTIONAL,
  1531. IN BOOL bOfflineContent OPTIONAL, // pass FALSE
  1532. IN BOOL bUseHtmlHelp OPTIONAL, // pass FALSE
  1533. IN LPCWSTR pszChmFile OPTIONAL // pass NULL
  1534. );
  1535. BOOL
  1536. SdbShowApphelpDialog( // returns TRUE if success, whether we should run the app is in pRunApp
  1537. IN PAPPHELP_INFO pAHInfo, // the info necessary to find the apphelp data
  1538. OUT PHANDLE phProcess, // [optional] returns the process handle of
  1539. // the process displaying the apphelp.
  1540. // When the process completes, the return value
  1541. // (from GetExitCodeProcess()) will be zero
  1542. // if the app should not run, or non-zero
  1543. // if it should run.
  1544. IN OUT BOOL* pRunApp
  1545. );
  1546. //
  1547. // WOW cmd line for flags interface
  1548. // instead of calling SdbQueryFlagInfo the macros above should be used
  1549. //
  1550. BOOL
  1551. SDBAPI
  1552. SdbQueryFlagInfo(
  1553. IN PVOID pvFlagInfo,
  1554. IN TAG tFlagType,
  1555. IN ULONGLONG ullFlagMask,
  1556. OUT LPCTSTR * ppCmdLine
  1557. );
  1558. BOOL
  1559. SDBAPI
  1560. SdbFreeFlagInfo(
  1561. IN PVOID pvFlagInfo
  1562. );
  1563. ////////////////////////////////////////////////////////////////////////////////////////////
  1564. //
  1565. // App Verifier macros/defs
  1566. //
  1567. //
  1568. typedef enum _VLOG_LEVEL {
  1569. VLOG_LEVEL_INFO,
  1570. VLOG_LEVEL_WARNING,
  1571. VLOG_LEVEL_ERROR
  1572. } VLOG_LEVEL, *PVLOG_LEVEL;
  1573. typedef enum _AVRF_INFO_ID {
  1574. // INFO ID type actually being passed in PVOID param
  1575. // ------- -----------------------------------------
  1576. AVRF_INFO_NUM_SHIMS, // LPDWORD (preallocated) (szName should be NULL)
  1577. AVRF_INFO_SHIM_NAMES, // LPWSTR * (array of same size as value of AVRF_INFO_NUM_SHIMS)
  1578. // (array is preallocated, strings are allocated by shim)
  1579. // (szName should be NULL)
  1580. AVRF_INFO_DESCRIPTION, // LPWSTR (allocated by shim)
  1581. AVRF_INFO_FRIENDLY_NAME, // LPWSTR (allocated by shim)
  1582. AVRF_INFO_INCLUDE_EXCLUDE, // LPWSTR (allocated by shim)
  1583. AVRF_INFO_FLAGS, // LPDWORD (preallocated)
  1584. AVRF_INFO_OPTIONS_PAGE, // LPPROPSHEETPAGE (preallocated)
  1585. AVRF_INFO_VERSION, // LPDWORD (preallocated), HIWORD=major version, LOWORD=minor version
  1586. AVRF_INFO_GROUPS // LPDWORD (preallocated)
  1587. } AVRF_INFO_ID, *PAVRF_INFO_ID;
  1588. //
  1589. // FLAGS for verifier shims (all flags default to FALSE)
  1590. //
  1591. #define AVRF_FLAG_NO_DEFAULT 0x00000001 // this shim should not be turned on by default
  1592. #define AVRF_FLAG_NO_WIN2K 0x00000002 // this shim should not be used on win2K
  1593. #define AVRF_FLAG_NO_SHIM 0x00000004 // this "shim" is a placeholder and shouldn't actually
  1594. // be applied to an app
  1595. #define AVRF_FLAG_NO_TEST 0x00000008 // this "shim" is not a test, and is purely for adding
  1596. // a page to the options dialog
  1597. #define AVRF_FLAG_NOT_SETUP 0x00000010 // this shim is not appropriate for setup apps
  1598. #define AVRF_FLAG_ONLY_SETUP 0x00000020 // this shim is only appropriate for setup apps
  1599. #define AVRF_FLAG_RUN_ALONE 0x00000040 // this shim should be run by itself with no other shims applied
  1600. //
  1601. // GROUPS for verifier shims (by default, shims are in no groups)
  1602. //
  1603. #define AVRF_GROUP_SETUP 0x00000001 // suitable for checking setup programs
  1604. #define AVRF_GROUP_NON_SETUP 0x00000002 // suitable for checking non-setup programs (can be both)
  1605. #define AVRF_GROUP_LOGO 0x00000004 // shims that are useful for logo testing
  1606. //
  1607. // magic number tells us if we're using the same shim interface
  1608. //
  1609. #define VERIFIER_SHIMS_MAGIC 'avfr'
  1610. typedef DWORD (*_pfnGetVerifierMagic)(void);
  1611. typedef BOOL (*_pfnQueryShimInfo)(LPCWSTR szName, AVRF_INFO_ID eInfo, PVOID pInfo);
  1612. //
  1613. // special callback, so a shim can be notified when it is activated or deactivated for a
  1614. // specific application.
  1615. //
  1616. typedef BOOL (*_pfnActivateCallback)(LPCWSTR szAppName, BOOL bActivate);
  1617. //
  1618. // Where we store default verifier shim settings
  1619. //
  1620. #define AVRF_DEFAULT_SETTINGS_NAME TEXT("{default}")
  1621. #define AVRF_DEFAULT_SETTINGS_NAME_W L"{default}"
  1622. #define AVRF_DEFAULT_SETTINGS_NAME_A "{default}"
  1623. typedef struct _SHIM_DESCRIPTION {
  1624. LPWSTR szName;
  1625. LPWSTR szDescription;
  1626. LPWSTR szExcludes; // comma separated module names
  1627. LPWSTR szIncludes; // comma separated module names
  1628. DWORD dwFlags;
  1629. } SHIM_DESCRIPTION, *PSHIM_DESCRIPTION;
  1630. #define ENUM_SHIMS_MAGIC 'enum'
  1631. typedef DWORD (*_pfnEnumShims)(PSHIM_DESCRIPTION pShims, DWORD dwMagic);
  1632. typedef BOOL (*_pfnIsVerifierDLL)(void);
  1633. ////////////////////////////////////////////////////////////////////////////////////////////
  1634. //
  1635. // Miscelaneous macros/defs
  1636. //
  1637. //
  1638. //
  1639. // Match modes for EXEs
  1640. //
  1641. #define MATCH_NORMAL 0
  1642. #define MATCH_EXCLUSIVE 1
  1643. #define MATCH_ADDITIVE 2
  1644. //
  1645. // the struct below packs into a WORD
  1646. // older compilers won't like this union
  1647. // (because of nameless members)
  1648. //
  1649. typedef union tagMATCHMODE {
  1650. struct {
  1651. USHORT Type : 4; // type of match
  1652. USHORT Flags: 4; // flags for matching
  1653. // future expansion here
  1654. };
  1655. WORD wMatchMode; // we use this to init from the database
  1656. DWORD dwMatchMode; // this is the "whole" match mode
  1657. } MATCHMODE, *PMATCHMODE;
  1658. //
  1659. // match modes:
  1660. //
  1661. // normal -- find a match, we're done
  1662. // additive -- keep the match, then keep matching according to flags
  1663. // exclusive -- keep the match, throw away all other matches
  1664. //
  1665. static const MATCHMODE MatchModeDefaultMain = { { MATCH_NORMAL, 0 } };
  1666. #define MATCHMODE_DEFAULT_MAIN (MatchModeDefaultMain.wMatchMode)
  1667. static const MATCHMODE MatchModeDefaultCustom = { { MATCH_ADDITIVE, 0 } };
  1668. #define MATCHMODE_DEFAULT_CUSTOM (MatchModeDefaultCustom.wMatchMode)
  1669. #define MAKE_MATCHMODE(dwMatchMode, Type, Flags) \
  1670. { \
  1671. ((PMATCHMODE)&(dwMatchMode))->Type = Type; \
  1672. ((PMATCHMODE)&(dwMatchMode))->Flags = Flags; \
  1673. }
  1674. //
  1675. // Pre-defined match modes for shimdbc
  1676. //
  1677. static const MATCHMODE MatchModeNormal = { { MATCH_NORMAL, 0 } };
  1678. static const MATCHMODE MatchModeAdditive = { { MATCH_ADDITIVE, 0 } };
  1679. static const MATCHMODE MatchModeExclusive = { { MATCH_EXCLUSIVE, 0 } };
  1680. #define MATCHMODE_NORMAL_SHIMDBC (MatchModeNormal.wMatchMode)
  1681. #define MATCHMODE_ADDITIVE_SHIMDBC (MatchModeAdditive.wMatchMode)
  1682. #define MATCHMODE_EXCLUSIVE_SHIMDBC (MatchModeExclusive.wMatchMode)
  1683. //
  1684. // Runtime platform flags
  1685. //
  1686. #define RUNTIME_PLATFORM_FLAG_NOT 0x80000000
  1687. #define RUNTIME_PLATFORM_FLAG_NOT_ELEMENT 0x00000080
  1688. #define RUNTIME_PLATFORM_FLAG_VALID 0x00000040
  1689. #define RUNTIME_PLATFORM_MASK_ELEMENT 0x000000FF
  1690. #define RUNTIME_PLATFORM_MASK_VALUE 0x0000003F
  1691. #define RUNTIME_PLATFORM_ANY 0xC0000000 // no valid bits + NOT + flag
  1692. //
  1693. // Shimdbc compile-time platform (OS_PLATFORM) flags
  1694. //
  1695. #define OS_PLATFORM_NONE 0x00000000
  1696. #define OS_PLATFORM_I386 0x00000001
  1697. #define OS_PLATFORM_IA64 0x00000002
  1698. #define OS_PLATFORM_ALL 0xFFFFFFFF
  1699. //
  1700. // These definitions are used for OS SKU attribute tags on EXE entries
  1701. //
  1702. #define OS_SKU_NONE 0x00000000 // None
  1703. #define OS_SKU_PER 0x00000001 // Personal
  1704. #define OS_SKU_PRO 0x00000002 // Professional
  1705. #define OS_SKU_SRV 0x00000004 // Server
  1706. #define OS_SKU_ADS 0x00000008 // Advanced Server
  1707. #define OS_SKU_DTC 0x00000010 // Datacenter
  1708. #define OS_SKU_BLA 0x00000020 // Blade Server
  1709. #define OS_SKU_TAB 0x00000040 // TabletPC
  1710. #define OS_SKU_MED 0x00000080 // eHome
  1711. #define OS_SKU_ALL 0xFFFFFFFF
  1712. #ifndef ARRAYSIZE
  1713. #define ARRAYSIZE(rg) (sizeof(rg)/sizeof((rg)[0]))
  1714. #endif
  1715. #ifndef OFFSETOF
  1716. #define OFFSETOF offsetof
  1717. #endif
  1718. #define CHARCOUNT(sz) (sizeof(sz) / sizeof(sz[0]))
  1719. //
  1720. // our reg key locations
  1721. //
  1722. #define APPCOMPAT_LOCATION TEXT("Software\\Microsoft\\Windows NT\\CurrentVersion\\AppCompatFlags")
  1723. #define APPCOMPAT_KEY_PATH APPCOMPAT_LOCATION
  1724. #define APPCOMPAT_KEY_PATH_CUSTOM APPCOMPAT_LOCATION TEXT("\\Custom")
  1725. #define APPCOMPAT_KEY_PATH_INSTALLEDSDB APPCOMPAT_LOCATION TEXT("\\InstalledSDB")
  1726. #define POLICY_KEY_APPCOMPAT TEXT("Software\\Policies\\Microsoft\\Windows\\AppCompat")
  1727. #define POLICY_VALUE_DISABLE_ENGINE TEXT("DisableEngine")
  1728. #define POLICY_VALUE_DISABLE_WIZARD TEXT("DisableWizard")
  1729. #define POLICY_VALUE_DISABLE_PROPPAGE TEXT("DisablePropPage")
  1730. #define POLICY_VALUE_APPHELP_LOG TEXT("LogAppHelpEvents")
  1731. // NT API versions
  1732. #define APPCOMPAT_KEY_PATH_MACHINE TEXT("\\Registry\\Machine\\") APPCOMPAT_LOCATION
  1733. #define APPCOMPAT_KEY_PATH_NT TEXT("\\") APPCOMPAT_LOCATION
  1734. #define APPCOMPAT_PERM_LAYER_PATH TEXT("\\") APPCOMPAT_LOCATION TEXT("\\Layers")
  1735. #define APPCOMPAT_KEY_PATH_MACHINE_CUSTOM APPCOMPAT_KEY_PATH_MACHINE TEXT("\\Custom")
  1736. #define APPCOMPAT_KEY_PATH_MACHINE_INSTALLEDSDB APPCOMPAT_KEY_PATH_MACHINE TEXT("\\InstalledSDB")
  1737. //
  1738. // our reg key locations
  1739. //
  1740. #define POLICY_VALUE_APPHELP_LOG_A "LogAppHelpEvents"
  1741. //
  1742. // our reg key locations
  1743. //
  1744. #define APPCOMPAT_LOCATION_W L"Software\\Microsoft\\Windows NT\\CurrentVersion\\AppCompatFlags"
  1745. #define APPCOMPAT_KEY_PATH_W APPCOMPAT_LOCATION_W
  1746. #define APPCOMPAT_KEY_PATH_CUSTOM_W APPCOMPAT_LOCATION_W L"\\Custom"
  1747. #define APPCOMPAT_KEY_PATH_INSTALLEDSDB_W APPCOMPAT_LOCATION_W L"\\InstalledSDB"
  1748. #define POLICY_KEY_APPCOMPAT_W L"Software\\Policies\\Microsoft\\Windows\\AppCompat"
  1749. #define POLICY_VALUE_DISABLE_ENGINE_W L"DisableEngine"
  1750. #define POLICY_VALUE_DISABLE_WIZARD_W L"DisableWizard"
  1751. #define POLICY_VALUE_DISABLE_PROPPAGE_W L"DisablePropPage"
  1752. #define POLICY_VALUE_APPHELP_LOG_W L"LogAppHelpEvents"
  1753. //
  1754. // LUA all-users redirection location
  1755. //
  1756. #define LUA_REDIR ("%ALLUSERSPROFILE%\\Application Data\\Redirected")
  1757. #define LUA_REDIR_W TEXT("%ALLUSERSPROFILE%\\Application Data\\Redirected")
  1758. //
  1759. // debug output support
  1760. //
  1761. typedef enum tagSHIMDBGLEVEL {
  1762. sdlError = 1,
  1763. sdlWarning = 2,
  1764. sdlFail = 1, // this means we have failed some api, not necessarily fatal
  1765. sdlInfo = 3,
  1766. sdlUser = 4
  1767. } SHIMDBGLEVEL;
  1768. //
  1769. // This flag marks the debug out for pipe
  1770. //
  1771. #define sdlLogPipe 0x00000080UL
  1772. #define sdlMask 0x0000007FUL
  1773. #define FILTER_DBG_LEVEL(level) ((int)((level) & sdlMask))
  1774. extern int __cdecl ShimDbgPrint(INT iDebugLevel, PCH FunctionName, PCH Format, ...);
  1775. #if DBG // Define _DEBUG_SPEW when compiling checked
  1776. #ifndef _DEBUG_SPEW
  1777. #define _DEBUG_SPEW
  1778. #endif
  1779. #endif // DBG
  1780. #ifdef _DEBUG_SPEW
  1781. //
  1782. // This value is a large number (initiallly)
  1783. // We will initialize it from the environment upon the first call
  1784. // to ShimDbgPrint
  1785. //
  1786. extern int g_iShimDebugLevel;
  1787. #define DBGPRINT( _x_ ) \
  1788. { \
  1789. if (g_iShimDebugLevel) { \
  1790. ShimDbgPrint _x_; \
  1791. } \
  1792. }
  1793. #else
  1794. #define DBGPRINT(_x_)
  1795. #endif // _DEBUG_SPEW
  1796. ///////////////////////////////////////////////////////////////////////////////
  1797. //
  1798. // SHIM TAGS
  1799. //
  1800. //
  1801. // Function to get the tag names given a tag ID.
  1802. //
  1803. // WARNING !!! : If you add new tags make sure you update SdbApi\attributes.c
  1804. // with the name of the tag in the global gaTagInfo.
  1805. //
  1806. LPCTSTR
  1807. SDBAPI
  1808. SdbTagToString(
  1809. TAG tag
  1810. );
  1811. //
  1812. // LIST types for shimdb
  1813. //
  1814. #define TAG_DATABASE (0x1 | TAG_TYPE_LIST)
  1815. #define TAG_LIBRARY (0x2 | TAG_TYPE_LIST)
  1816. #define TAG_INEXCLUDE (0x3 | TAG_TYPE_LIST)
  1817. #define TAG_SHIM (0x4 | TAG_TYPE_LIST)
  1818. #define TAG_PATCH (0x5 | TAG_TYPE_LIST)
  1819. #define TAG_APP (0x6 | TAG_TYPE_LIST)
  1820. #define TAG_EXE (0x7 | TAG_TYPE_LIST)
  1821. #define TAG_MATCHING_FILE (0x8 | TAG_TYPE_LIST)
  1822. #define TAG_SHIM_REF (0x9 | TAG_TYPE_LIST)
  1823. #define TAG_PATCH_REF (0xA | TAG_TYPE_LIST)
  1824. #define TAG_LAYER (0xB | TAG_TYPE_LIST)
  1825. #define TAG_FILE (0xC | TAG_TYPE_LIST)
  1826. #define TAG_APPHELP (0xD | TAG_TYPE_LIST)
  1827. #define TAG_LINK (0xE | TAG_TYPE_LIST) // Description list w/lang ids and urls
  1828. #define TAG_DATA (0xF | TAG_TYPE_LIST)
  1829. #define TAG_MSI_TRANSFORM (0x10| TAG_TYPE_LIST)
  1830. #define TAG_MSI_TRANSFORM_REF (0x11| TAG_TYPE_LIST)
  1831. #define TAG_MSI_PACKAGE (0x12| TAG_TYPE_LIST)
  1832. #define TAG_FLAG (0x13| TAG_TYPE_LIST)
  1833. #define TAG_MSI_CUSTOM_ACTION (0x14| TAG_TYPE_LIST)
  1834. #define TAG_FLAG_REF (0x15| TAG_TYPE_LIST)
  1835. #define TAG_ACTION (0x16| TAG_TYPE_LIST)
  1836. //
  1837. // STRINGREF types for shimdb
  1838. //
  1839. #define TAG_NAME (0x1 | TAG_TYPE_STRINGREF)
  1840. #define TAG_DESCRIPTION (0x2 | TAG_TYPE_STRINGREF)
  1841. #define TAG_MODULE (0x3 | TAG_TYPE_STRINGREF)
  1842. #define TAG_API (0x4 | TAG_TYPE_STRINGREF)
  1843. #define TAG_VENDOR (0x5 | TAG_TYPE_STRINGREF)
  1844. #define TAG_APP_NAME (0x6 | TAG_TYPE_STRINGREF)
  1845. #define TAG_COMMAND_LINE (0x8 | TAG_TYPE_STRINGREF)
  1846. #define TAG_COMPANY_NAME (0x9 | TAG_TYPE_STRINGREF)
  1847. #define TAG_DLLFILE (0xA | TAG_TYPE_STRINGREF)
  1848. #define TAG_WILDCARD_NAME (0xB | TAG_TYPE_STRINGREF)
  1849. #define TAG_PRODUCT_NAME (0x10 | TAG_TYPE_STRINGREF)
  1850. #define TAG_PRODUCT_VERSION (0x11 | TAG_TYPE_STRINGREF)
  1851. #define TAG_FILE_DESCRIPTION (0x12 | TAG_TYPE_STRINGREF)
  1852. #define TAG_FILE_VERSION (0x13 | TAG_TYPE_STRINGREF)
  1853. #define TAG_ORIGINAL_FILENAME (0x14 | TAG_TYPE_STRINGREF)
  1854. #define TAG_INTERNAL_NAME (0x15 | TAG_TYPE_STRINGREF)
  1855. #define TAG_LEGAL_COPYRIGHT (0x16 | TAG_TYPE_STRINGREF)
  1856. #define TAG_16BIT_DESCRIPTION (0x17 | TAG_TYPE_STRINGREF)
  1857. #define TAG_APPHELP_DETAILS (0x18 | TAG_TYPE_STRINGREF) // Details in single language
  1858. #define TAG_LINK_URL (0x19 | TAG_TYPE_STRINGREF)
  1859. #define TAG_LINK_TEXT (0x1A | TAG_TYPE_STRINGREF)
  1860. #define TAG_APPHELP_TITLE (0x1B | TAG_TYPE_STRINGREF)
  1861. #define TAG_APPHELP_CONTACT (0x1C | TAG_TYPE_STRINGREF)
  1862. #define TAG_SXS_MANIFEST (0x1D | TAG_TYPE_STRINGREF)
  1863. #define TAG_DATA_STRING (0x1E | TAG_TYPE_STRINGREF)
  1864. #define TAG_MSI_TRANSFORM_FILE (0x1F | TAG_TYPE_STRINGREF)
  1865. #define TAG_16BIT_MODULE_NAME (0x20 | TAG_TYPE_STRINGREF)
  1866. #define TAG_LAYER_DISPLAYNAME (0x21 | TAG_TYPE_STRINGREF)
  1867. #define TAG_COMPILER_VERSION (0x22 | TAG_TYPE_STRINGREF)
  1868. #define TAG_ACTION_TYPE (0x23 | TAG_TYPE_STRINGREF)
  1869. #define TAG_STRINGTABLE (0x801 | TAG_TYPE_LIST)
  1870. //
  1871. // DWORD types for shimdb
  1872. //
  1873. #define TAG_SIZE (0x1 | TAG_TYPE_DWORD)
  1874. #define TAG_OFFSET (0x2 | TAG_TYPE_DWORD)
  1875. #define TAG_CHECKSUM (0x3 | TAG_TYPE_DWORD)
  1876. #define TAG_SHIM_TAGID (0x4 | TAG_TYPE_DWORD)
  1877. #define TAG_PATCH_TAGID (0x5 | TAG_TYPE_DWORD)
  1878. #define TAG_MODULE_TYPE (0x6 | TAG_TYPE_DWORD)
  1879. #define TAG_VERDATEHI (0x7 | TAG_TYPE_DWORD)
  1880. #define TAG_VERDATELO (0x8 | TAG_TYPE_DWORD)
  1881. #define TAG_VERFILEOS (0x9 | TAG_TYPE_DWORD)
  1882. #define TAG_VERFILETYPE (0xA | TAG_TYPE_DWORD)
  1883. #define TAG_PE_CHECKSUM (0xB | TAG_TYPE_DWORD)
  1884. #define TAG_PREVOSMAJORVER (0xC | TAG_TYPE_DWORD)
  1885. #define TAG_PREVOSMINORVER (0xD | TAG_TYPE_DWORD)
  1886. #define TAG_PREVOSPLATFORMID (0xE | TAG_TYPE_DWORD)
  1887. #define TAG_PREVOSBUILDNO (0xF | TAG_TYPE_DWORD)
  1888. #define TAG_PROBLEMSEVERITY (0x10 | TAG_TYPE_DWORD)
  1889. #define TAG_LANGID (0x11 | TAG_TYPE_DWORD)
  1890. #define TAG_VER_LANGUAGE (0x12 | TAG_TYPE_DWORD)
  1891. #define TAG_ENGINE (0x14 | TAG_TYPE_DWORD)
  1892. #define TAG_HTMLHELPID (0x15 | TAG_TYPE_DWORD)
  1893. #define TAG_INDEX_FLAGS (0x16 | TAG_TYPE_DWORD)
  1894. #define TAG_FLAGS (0x17 | TAG_TYPE_DWORD)
  1895. #define TAG_DATA_VALUETYPE (0x18 | TAG_TYPE_DWORD)
  1896. #define TAG_DATA_DWORD (0x19 | TAG_TYPE_DWORD)
  1897. #define TAG_LAYER_TAGID (0x1A | TAG_TYPE_DWORD)
  1898. #define TAG_MSI_TRANSFORM_TAGID (0x1B | TAG_TYPE_DWORD)
  1899. #define TAG_LINKER_VERSION (0x1C | TAG_TYPE_DWORD)
  1900. #define TAG_LINK_DATE (0x1D | TAG_TYPE_DWORD)
  1901. #define TAG_UPTO_LINK_DATE (0x1E | TAG_TYPE_DWORD)
  1902. #define TAG_OS_SERVICE_PACK (0x1F | TAG_TYPE_DWORD)
  1903. #define TAG_FLAG_TAGID (0x20 | TAG_TYPE_DWORD)
  1904. #define TAG_RUNTIME_PLATFORM (0x21 | TAG_TYPE_DWORD)
  1905. #define TAG_OS_SKU (0x22 | TAG_TYPE_DWORD)
  1906. #define TAG_TAGID (0x801| TAG_TYPE_DWORD)
  1907. //
  1908. // STRING types
  1909. //
  1910. #define TAG_STRINGTABLE_ITEM (0x801 | TAG_TYPE_STRING)
  1911. //
  1912. // NULL types for shimdb (existence/nonexistence is treated like a BOOL)
  1913. //
  1914. #define TAG_INCLUDE (0x1 | TAG_TYPE_NULL)
  1915. #define TAG_GENERAL (0x2 | TAG_TYPE_NULL)
  1916. #define TAG_MATCH_LOGIC_NOT (0x3 | TAG_TYPE_NULL)
  1917. #define TAG_APPLY_ALL_SHIMS (0x4 | TAG_TYPE_NULL)
  1918. #define TAG_USE_SERVICE_PACK_FILES (0x5 | TAG_TYPE_NULL)
  1919. //
  1920. // QWORD types for shimdb
  1921. //
  1922. #define TAG_TIME (0x1 | TAG_TYPE_QWORD)
  1923. #define TAG_BIN_FILE_VERSION (0x2 | TAG_TYPE_QWORD)
  1924. #define TAG_BIN_PRODUCT_VERSION (0x3 | TAG_TYPE_QWORD)
  1925. #define TAG_MODTIME (0x4 | TAG_TYPE_QWORD)
  1926. #define TAG_FLAG_MASK_KERNEL (0x5 | TAG_TYPE_QWORD)
  1927. #define TAG_UPTO_BIN_PRODUCT_VERSION (0x6 | TAG_TYPE_QWORD)
  1928. #define TAG_DATA_QWORD (0x7 | TAG_TYPE_QWORD)
  1929. #define TAG_FLAG_MASK_USER (0x8 | TAG_TYPE_QWORD)
  1930. #define TAG_FLAGS_NTVDM1 (0x9 | TAG_TYPE_QWORD)
  1931. #define TAG_FLAGS_NTVDM2 (0xA | TAG_TYPE_QWORD)
  1932. #define TAG_FLAGS_NTVDM3 (0xB | TAG_TYPE_QWORD)
  1933. #define TAG_FLAG_MASK_SHELL (0xC | TAG_TYPE_QWORD)
  1934. #define TAG_UPTO_BIN_FILE_VERSION (0xD | TAG_TYPE_QWORD)
  1935. //
  1936. // BINARY types for shimdb
  1937. //
  1938. #define TAG_PATCH_BITS (0x2 | TAG_TYPE_BINARY)
  1939. #define TAG_FILE_BITS (0x3 | TAG_TYPE_BINARY)
  1940. #define TAG_EXE_ID (0x4 | TAG_TYPE_BINARY)
  1941. #define TAG_DATA_BITS (0x5 | TAG_TYPE_BINARY)
  1942. #define TAG_MSI_PACKAGE_ID (0x6 | TAG_TYPE_BINARY) // msi package id is a guid
  1943. #define TAG_DATABASE_ID (0x7 | TAG_TYPE_BINARY) // database guid
  1944. #define TAG_INDEX_BITS (0x801 | TAG_TYPE_BINARY)
  1945. //
  1946. // INDEX types for shimdb
  1947. //
  1948. #define TAG_INDEXES (0x802 | TAG_TYPE_LIST)
  1949. #define TAG_INDEX (0x803 | TAG_TYPE_LIST)
  1950. //
  1951. // WORD types
  1952. //
  1953. #define TAG_MATCH_MODE (0x1 | TAG_TYPE_WORD)
  1954. #define TAG_TAG (0x801 | TAG_TYPE_WORD)
  1955. #define TAG_INDEX_TAG (0x802 | TAG_TYPE_WORD)
  1956. #define TAG_INDEX_KEY (0x803 | TAG_TYPE_WORD)
  1957. //
  1958. // let the typedefs take the course..
  1959. //
  1960. #undef LPCTSTR
  1961. #undef LPTSTR
  1962. #undef TCHAR
  1963. #endif // _SHIMDB_H_