ReactOS 0.4.15-dev-8393-g61b7fb9
apphelp.h File Reference
#include <appcompat/sdbtypes.h>
#include "sdbpapi.h"
#include <appcompat/sdbtagid.h>
Include dependency graph for apphelp.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  _SDB
 
struct  tagATTRINFO
 
struct  tagSDBQUERYRESULT
 
struct  _DB_INFORMATION
 

Macros

#define HID_DOS_PATHS   0x1
 
#define HID_DATABASE_FULLPATH   0x2
 
#define HID_NO_DATABASE   0x4
 
#define HID_DATABASE_TYPE_MASK   0xF00F0000
 
#define SDB_DATABASE_MAIN_MSI   0x80020000
 
#define SDB_DATABASE_MAIN_SHIM   0x80030000
 
#define SDB_DATABASE_MAIN_DRIVERS   0x80040000
 
#define SDB_DATABASE_SHIM   0x00010000
 
#define SDB_MAX_SDBS   16
 
#define SDB_MAX_EXES   16
 
#define SDB_MAX_LAYERS   8
 
#define SHIMREG_DISABLE_SHIM   (0x00000001)
 
#define SHIMREG_DISABLE_APPHELP   (0x00000002)
 
#define SHIMREG_APPHELP_NOUI   (0x00000004)
 
#define SHIMREG_APPHELP_CANCEL   (0x10000000)
 
#define SHIMREG_DISABLE_SXS   (0x00000010)
 
#define SHIMREG_DISABLE_LAYER   (0x00000020)
 
#define SHIMREG_DISABLE_DRIVER   (0x00000040)
 
#define SHIMREG_HAS_ENVIRONMENT   (0x1)
 
#define SDBGMEF_IGNORE_ENVIRONMENT   (0x1)
 
#define DB_INFO_FLAGS_VALID_GUID   1
 
#define ATTRIBUTE_AVAILABLE   0x1
 
#define ATTRIBUTE_FAILED   0x2
 

Typedefs

typedef struct _SDB SDB
 
typedef struct _SDBHSDB
 
typedef struct tagATTRINFO ATTRINFO
 
typedef struct tagATTRINFOPATTRINFO
 
typedef struct tagSDBQUERYRESULT SDBQUERYRESULT
 
typedef struct tagSDBQUERYRESULTPSDBQUERYRESULT
 
typedef struct _DB_INFORMATION DB_INFORMATION
 
typedef struct _DB_INFORMATIONPDB_INFORMATION
 

Functions

PWSTR SdbpStrDup (LPCWSTR string)
 
DWORD SdbpStrsize (PCWSTR string)
 
HSDB WINAPI SdbInitDatabase (DWORD, LPCWSTR)
 
void WINAPI SdbReleaseDatabase (HSDB)
 
BOOL WINAPI SdbGUIDToString (CONST GUID *Guid, PWSTR GuidString, SIZE_T Length)
 
LPCWSTR WINAPI SdbTagToString (TAG tag)
 
PDB WINAPI SdbOpenDatabase (LPCWSTR path, PATH_TYPE type)
 
void WINAPI SdbCloseDatabase (PDB)
 
BOOL WINAPI SdbIsNullGUID (CONST GUID *Guid)
 
HRESULT WINAPI SdbGetAppPatchDir (HSDB db, LPWSTR path, DWORD size)
 
LPWSTR WINAPI SdbGetStringTagPtr (PDB pdb, TAGID tagid)
 
TAGID WINAPI SdbFindFirstNamedTag (PDB pdb, TAGID root, TAGID find, TAGID nametag, LPCWSTR find_name)
 
DWORD WINAPI SdbQueryDataExTagID (PDB pdb, TAGID tiExe, LPCWSTR lpszDataName, LPDWORD lpdwDataType, LPVOID lpBuffer, LPDWORD lpcbBufferSize, TAGID *ptiData)
 
BOOL WINAPI SdbGetDatabaseInformation (PDB pdb, PDB_INFORMATION information)
 
VOID WINAPI SdbFreeDatabaseInformation (PDB_INFORMATION information)
 
BOOL WINAPI SdbRegisterDatabaseEx (_In_ LPCWSTR pszDatabasePath, _In_ DWORD dwDatabaseType, _In_opt_ const PULONGLONG pTimeStamp)
 
BOOL WINAPI SdbUnregisterDatabase (_In_ const GUID *pguidDB)
 
BOOL WINAPI SdbpReadData (PDB pdb, PVOID dest, DWORD offset, DWORD num)
 
TAG WINAPI SdbGetTagFromTagID (PDB pdb, TAGID tagid)
 
TAGID WINAPI SdbFindFirstTag (PDB pdb, TAGID parent, TAG tag)
 
TAGID WINAPI SdbFindNextTag (PDB pdb, TAGID parent, TAGID prev_child)
 
BOOL WINAPI SdbGetDatabaseID (PDB pdb, GUID *Guid)
 
DWORD WINAPI SdbReadDWORDTag (PDB pdb, TAGID tagid, DWORD ret)
 
QWORD WINAPI SdbReadQWORDTag (PDB pdb, TAGID tagid, QWORD ret)
 
TAGID WINAPI SdbGetFirstChild (PDB pdb, TAGID parent)
 
TAGID WINAPI SdbGetNextChild (PDB pdb, TAGID parent, TAGID prev_child)
 
DWORD WINAPI SdbGetTagDataSize (PDB pdb, TAGID tagid)
 
LPWSTR WINAPI SdbpGetString (PDB pdb, TAGID tagid, PDWORD size)
 
BOOL WINAPI SdbReadBinaryTag (PDB pdb, TAGID tagid, PBYTE buffer, DWORD size)
 
BOOL WINAPI SdbGetFileAttributes (LPCWSTR path, PATTRINFO *attr_info_ret, LPDWORD attr_count)
 
BOOL WINAPI SdbFreeFileAttributes (PATTRINFO attr_info)
 
BOOL WINAPI AllowPermLayer (PCWSTR path)
 
BOOL WINAPI SdbGetPermLayerKeys (PCWSTR wszPath, PWSTR pwszLayers, PDWORD pdwBytes, DWORD dwFlags)
 
BOOL WINAPI SetPermLayerState (PCWSTR wszPath, PCWSTR wszLayer, DWORD dwFlags, BOOL bMachine, BOOL bEnable)
 
BOOL WINAPI SdbGetMatchingExe (HSDB hsdb, LPCWSTR path, LPCWSTR module_name, LPCWSTR env, DWORD flags, PSDBQUERYRESULT result)
 
BOOL WINAPI SdbTagIDToTagRef (HSDB hsdb, PDB pdb, TAGID tiWhich, TAGREF *ptrWhich)
 
BOOL WINAPI SdbTagRefToTagID (HSDB hsdb, TAGREF trWhich, PDB *ppdb, TAGID *ptiWhich)
 
BOOL WINAPI SdbUnpackAppCompatData (HSDB hsdb, LPCWSTR pszImageName, PVOID pData, PSDBQUERYRESULT pQueryResult)
 
DWORD WINAPI SdbQueryData (HSDB hsdb, TAGREF trWhich, LPCWSTR lpszDataName, LPDWORD lpdwDataType, LPVOID lpBuffer, LPDWORD lpcbBufferSize)
 

Macro Definition Documentation

◆ ATTRIBUTE_AVAILABLE

#define ATTRIBUTE_AVAILABLE   0x1

Definition at line 146 of file apphelp.h.

◆ ATTRIBUTE_FAILED

#define ATTRIBUTE_FAILED   0x2

Definition at line 147 of file apphelp.h.

◆ DB_INFO_FLAGS_VALID_GUID

#define DB_INFO_FLAGS_VALID_GUID   1

Definition at line 79 of file apphelp.h.

◆ HID_DATABASE_FULLPATH

#define HID_DATABASE_FULLPATH   0x2

Definition at line 20 of file apphelp.h.

◆ HID_DATABASE_TYPE_MASK

#define HID_DATABASE_TYPE_MASK   0xF00F0000

Definition at line 22 of file apphelp.h.

◆ HID_DOS_PATHS

#define HID_DOS_PATHS   0x1

Definition at line 19 of file apphelp.h.

◆ HID_NO_DATABASE

#define HID_NO_DATABASE   0x4

Definition at line 21 of file apphelp.h.

◆ SDB_DATABASE_MAIN_DRIVERS

#define SDB_DATABASE_MAIN_DRIVERS   0x80040000

Definition at line 25 of file apphelp.h.

◆ SDB_DATABASE_MAIN_MSI

#define SDB_DATABASE_MAIN_MSI   0x80020000

Definition at line 23 of file apphelp.h.

◆ SDB_DATABASE_MAIN_SHIM

#define SDB_DATABASE_MAIN_SHIM   0x80030000

Definition at line 24 of file apphelp.h.

◆ SDB_DATABASE_SHIM

#define SDB_DATABASE_SHIM   0x00010000

Definition at line 28 of file apphelp.h.

◆ SDB_MAX_EXES

#define SDB_MAX_EXES   16

Definition at line 46 of file apphelp.h.

◆ SDB_MAX_LAYERS

#define SDB_MAX_LAYERS   8

Definition at line 47 of file apphelp.h.

◆ SDB_MAX_SDBS

#define SDB_MAX_SDBS   16

Definition at line 45 of file apphelp.h.

◆ SDBGMEF_IGNORE_ENVIRONMENT

#define SDBGMEF_IGNORE_ENVIRONMENT   (0x1)

Definition at line 62 of file apphelp.h.

◆ SHIMREG_APPHELP_CANCEL

#define SHIMREG_APPHELP_CANCEL   (0x10000000)

Definition at line 53 of file apphelp.h.

◆ SHIMREG_APPHELP_NOUI

#define SHIMREG_APPHELP_NOUI   (0x00000004)

Definition at line 52 of file apphelp.h.

◆ SHIMREG_DISABLE_APPHELP

#define SHIMREG_DISABLE_APPHELP   (0x00000002)

Definition at line 51 of file apphelp.h.

◆ SHIMREG_DISABLE_DRIVER

#define SHIMREG_DISABLE_DRIVER   (0x00000040)

Definition at line 56 of file apphelp.h.

◆ SHIMREG_DISABLE_LAYER

#define SHIMREG_DISABLE_LAYER   (0x00000020)

Definition at line 55 of file apphelp.h.

◆ SHIMREG_DISABLE_SHIM

#define SHIMREG_DISABLE_SHIM   (0x00000001)

Definition at line 50 of file apphelp.h.

◆ SHIMREG_DISABLE_SXS

#define SHIMREG_DISABLE_SXS   (0x00000010)

Definition at line 54 of file apphelp.h.

◆ SHIMREG_HAS_ENVIRONMENT

#define SHIMREG_HAS_ENVIRONMENT   (0x1)

Definition at line 59 of file apphelp.h.

Typedef Documentation

◆ ATTRINFO

◆ DB_INFORMATION

◆ HSDB

typedef struct _SDB * HSDB

◆ PATTRINFO

◆ PDB_INFORMATION

◆ PSDBQUERYRESULT

◆ SDB

typedef struct _SDB SDB

◆ SDBQUERYRESULT

Function Documentation

◆ AllowPermLayer()

BOOL WINAPI AllowPermLayer ( PCWSTR  Path)

Determine if we allow permission layers to apply on this file.

Parameters
[in]PathFull pathname of the file, only the drive part is used.
Returns
TRUE if we allow permission layer, FALSE if not.

Definition at line 320 of file layer.c.

321{
322 WCHAR tmp[] = { 'A',':','\\', 0 };
323 ULONG type;
324 if (!Path)
325 {
326 SHIM_ERR("Invalid argument\n");
327 return FALSE;
328 }
329 switch (Path[1])
330 {
331 case L':':
332 break;
333 case L'\\':
334 SHIM_INFO("\"%S\" is a network path.\n", Path);
335 return FALSE;
336 default:
337 SHIM_INFO("\"%S\" not a full path we can operate on.\n", Path);
338 return FALSE;
339 }
340 tmp[0] = Path[0];
341 type = GetDriveTypeW(tmp);
342 if (type == DRIVE_REMOTE)
343 {
344 /* The logging here indicates that it does not like a CDROM or removable media, but it only
345 seems to bail out on a media that reports it is remote...
346 I have included correct logging, I doubt anyone would parse the logging, so this shouldnt break anything. */
347 SHIM_INFO("\"%S\" is on a remote drive.\n", Path);
348 return FALSE;
349 }
350 return TRUE;
351}
PRTL_UNICODE_STRING_BUFFER Path
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
UINT WINAPI GetDriveTypeW(IN LPCWSTR lpRootPathName)
Definition: disk.c:497
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
#define L(x)
Definition: ntvdm.h:50
#define SHIM_INFO(fmt,...)
Definition: sdbpapi.h:78
#define SHIM_ERR(fmt,...)
Definition: sdbpapi.h:76
uint32_t ULONG
Definition: typedefs.h:59
#define DRIVE_REMOTE
Definition: winbase.h:253
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by CLayerUIPropPage::InitFile().

◆ SdbCloseDatabase()

void WINAPI SdbCloseDatabase ( PDB  pdb)

Closes specified database and frees its memory.

Parameters
[in]pdbHandle to the shim database.

Definition at line 373 of file sdbapi.c.

374{
375 if (!pdb)
376 return;
377
378 if (pdb->file)
379 NtClose(pdb->file);
380 if (pdb->string_buffer)
381 SdbCloseDatabase(pdb->string_buffer);
382 if (pdb->string_lookup)
383 SdbpTableDestroy(&pdb->string_lookup);
384 SdbFree(pdb->data);
385 SdbFree(pdb);
386}
static PDB pdb
Definition: db.cpp:172
NTSTATUS NTAPI NtClose(IN HANDLE Handle)
Definition: obhandle.c:3402
void WINAPI SdbCloseDatabase(PDB pdb)
Definition: sdbapi.c:373
#define SdbFree(mem)
Definition: sdbpapi.h:37
void SdbpTableDestroy(struct SdbStringHashTable **pTable)

Referenced by SdbInstall(), SdbRegisterDatabaseEx(), SdbReleaseDatabase(), SdbUninstall(), and CLayerStringList::~CLayerStringList().

◆ SdbFindFirstNamedTag()

TAGID WINAPI SdbFindFirstNamedTag ( PDB  pdb,
TAGID  root,
TAGID  find,
TAGID  nametag,
LPCWSTR  find_name 
)

Find the first named child tag.

Parameters
[in]pdbThe database.
[in]rootThe tag to start at
[in]findThe tag type to find
[in]nametagThe child of 'find' that contains the name
[in]find_nameThe name to find
Returns
The found tag, or TAGID_NULL on failure

Definition at line 544 of file sdbapi.c.

545{
546 TAGID iter;
547
548 iter = SdbFindFirstTag(pdb, root, find);
549
550 while (iter != TAGID_NULL)
551 {
552 TAGID tmp = SdbFindFirstTag(pdb, iter, nametag);
553 if (tmp != TAGID_NULL)
554 {
556 if (name && !wcsicmp(name, find_name))
557 return iter;
558 }
559 iter = SdbFindNextTag(pdb, root, iter);
560 }
561 return TAGID_NULL;
562}
TAGID WINAPI SdbFindFirstTag(PDB pdb, TAGID parent, TAG tag)
Definition: sdbread.c:208
TAGID WINAPI SdbFindNextTag(PDB pdb, TAGID parent, TAGID prev_child)
Definition: sdbread.c:231
LPWSTR WINAPI SdbGetStringTagPtr(PDB pdb, TAGID tagid)
Definition: sdbread.c:375
DWORD TAGID
#define TAGID_NULL
Definition: db.cpp:38
static TAGID TAGID TAGID LPCWSTR find_name
Definition: db.cpp:155
static TAGID TAGID find
Definition: db.cpp:155
static TAGID TAGID TAGID nametag
Definition: db.cpp:155
#define wcsicmp
Definition: compat.h:15
Definition: name.c:39
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185

Referenced by SdbGetLayerTagRef(), SdbpAddNamedLayerMatch(), and SdbQueryDataExTagID().

◆ SdbFindFirstTag()

TAGID WINAPI SdbFindFirstTag ( PDB  pdb,
TAGID  parent,
TAG  tag 
)

Searches shim database for a tag within specified domain.

Parameters
[in]pdbHandle to the shim database.
[in]parentTAGID of parent.
[in]tagTAG to be located.
Returns
Success: TAGID of first matching tag, Failure: TAGID_NULL.

Definition at line 208 of file sdbread.c.

209{
210 TAGID iter;
211
212 iter = SdbGetFirstChild(pdb, parent);
213 while (iter != TAGID_NULL)
214 {
215 if (SdbGetTagFromTagID(pdb, iter) == tag)
216 return iter;
217 iter = SdbGetNextChild(pdb, parent, iter);
218 }
219 return TAGID_NULL;
220}
r parent
Definition: btrfs.c:3010
TAG WINAPI SdbGetTagFromTagID(PDB pdb, TAGID tagid)
Definition: sdbread.c:93
TAGID WINAPI SdbGetFirstChild(PDB pdb, TAGID parent)
Definition: sdbread.c:142
TAGID WINAPI SdbGetNextChild(PDB pdb, TAGID parent, TAGID prev_child)
Definition: sdbread.c:171
Definition: ecma_167.h:138

Referenced by GetSdbGuid(), CLayerStringList::Next(), ProcessExe(), ProcessLayers(), CLayerStringList::Reset(), SdbFindFirstNamedTag(), SdbGetDatabaseID(), SdbGetLayerTagRef(), SdbGetMatchingExe(), SdbInstall(), SdbOpenDatabase(), SdbpAddExeLayers(), SdbpAddNamedLayerMatch(), SdbpMatchExe(), SdbQueryDataExTagID(), SdbUninstall(), SeiBuildGlobalInclExclList(), SeiBuildShimRefArray(), SeiGetDWORD(), SeiGetQWORD(), SeiGetStringPtr(), and SeiReadInExclude().

◆ SdbFindNextTag()

TAGID WINAPI SdbFindNextTag ( PDB  pdb,
TAGID  parent,
TAGID  prev_child 
)

Searches shim database for a next tag which matches prev_child within parent's domain.

Parameters
[in]pdbHandle to the shim database.
[in]parentTAGID of parent.
[in]prev_childTAGID of previous match.
Returns
Success: TAGID of next match, Failure: TAGID_NULL.

Definition at line 231 of file sdbread.c.

232{
233 TAG tag;
234 TAGID iter;
235
236 tag = SdbGetTagFromTagID(pdb, prev_child);
237 iter = SdbGetNextChild(pdb, parent, prev_child);
238
239 while (iter != TAGID_NULL)
240 {
241 if (SdbGetTagFromTagID(pdb, iter) == tag)
242 return iter;
243 iter = SdbGetNextChild(pdb, parent, iter);
244 }
245 return TAGID_NULL;
246}
Definition: fs_rec.h:143

Referenced by CLayerStringList::Next(), ProcessExe(), ProcessLayers(), SdbFindFirstNamedTag(), SdbGetMatchingExe(), SdbpAddExeLayers(), SdbpMatchExe(), SeiBuildShimRefArray(), SeiReadInExclude(), and CLayerStringList::Skip().

◆ SdbFreeDatabaseInformation()

VOID WINAPI SdbFreeDatabaseInformation ( PDB_INFORMATION  information)

Definition at line 527 of file sdbapi.c.

528{
529 // No-op
530}

Referenced by SdbRegisterDatabaseEx().

◆ SdbFreeFileAttributes()

BOOL WINAPI SdbFreeFileAttributes ( PATTRINFO  attr_info)

Frees attribute data allocated by SdbGetFileAttributes.

Note
Unlike Windows, this implementation will not crash if attr_info is NULL.
Parameters
[in]attr_infoPointer to array of ATTRINFO which will be freed.
Returns
TRUE if it succeeds, FALSE if it fails.

Definition at line 214 of file sdbfileattr.c.

215{
216 WORD i;
217
218 if (!attr_info)
219 return FALSE;
220
221 for (i = 0; i < NUM_ATTRIBUTES; i++)
222 if ((attr_info[i].type & TAG_TYPE_MASK) == TAG_TYPE_STRINGREF)
223 SdbFree(attr_info[i].lpattr);
224 SdbFree(attr_info);
225 return TRUE;
226}
unsigned short WORD
Definition: ntddk_ex.h:93
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define NUM_ATTRIBUTES
Definition: sdbfileattr.c:18
#define TAG_TYPE_STRINGREF
Definition: shimdbg.c:109
#define TAG_TYPE_MASK
Definition: shimdbg.c:106

Referenced by InitApphelp(), SdbGetMatchingExe(), SdbpMatchExe(), and START_TEST().

◆ SdbGetAppPatchDir()

HRESULT WINAPI SdbGetAppPatchDir ( HSDB  hsdb,
LPWSTR  path,
DWORD  size 
)

Retrieves AppPatch directory.

Parameters
[in]pdbHandle to the shim database.
[out]pathPointer to memory in which path shall be written.
[in]sizeSize of the buffer in characters.

Definition at line 579 of file hsdb.c.

580{
581 static WCHAR* default_dir = NULL;
582 static CONST WCHAR szAppPatch[] = {'\\','A','p','p','P','a','t','c','h',0};
583
584 /* In case function fails, path holds empty string */
585 if (size > 0)
586 *path = 0;
587
588 if (!default_dir)
589 {
590 WCHAR* tmp;
591 HRESULT hr = E_FAIL;
593 tmp = SdbAlloc((len + 1)* sizeof(WCHAR));
594 if (tmp)
595 {
597 if (r && r < len)
598 {
599 hr = StringCchCatW(tmp, len+1, szAppPatch);
600 if (SUCCEEDED(hr))
601 {
602 if (InterlockedCompareExchangePointer((void**)&default_dir, tmp, NULL) == NULL)
603 tmp = NULL;
604 }
605 }
606 if (tmp)
607 SdbFree(tmp);
608 }
609 if (!default_dir)
610 {
611 SHIM_ERR("Unable to obtain default AppPatch directory (0x%x)\n", hr);
612 return hr;
613 }
614 }
615
616 if (!hsdb)
617 {
618 return StringCchCopyW(path, size, default_dir);
619 }
620 else
621 {
622 SHIM_ERR("Unimplemented for hsdb != NULL\n");
623 return E_NOTIMPL;
624 }
625}
#define E_NOTIMPL
Definition: ddrawi.h:99
#define E_FAIL
Definition: ddrawi.h:102
#define NULL
Definition: types.h:112
UINT WINAPI GetSystemWindowsDirectoryW(OUT LPWSTR lpBuffer, IN UINT uSize)
Definition: path.c:2397
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
GLsizeiptr size
Definition: glext.h:5919
GLenum GLsizei len
Definition: glext.h:6722
#define InterlockedCompareExchangePointer
Definition: interlocked.h:129
#define SUCCEEDED(hr)
Definition: intsafe.h:50
unsigned int UINT
Definition: ndis.h:50
#define CONST
Definition: pedump.c:81
DWORD SdbpStrlen(PCWSTR string)
Definition: sdbapi.c:152
#define SdbAlloc(size)
Definition: sdbpapi.h:35
HRESULT hr
Definition: shlfolder.c:183
STRSAFEAPI StringCchCatW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:325
STRSAFEAPI StringCchCopyW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:149

Referenced by CLayerStringList::CLayerStringList(), SdbInitDatabase(), SeiInit(), and START_TEST().

◆ SdbGetDatabaseID()

BOOL WINAPI SdbGetDatabaseID ( PDB  pdb,
GUID Guid 
)

Reads binary data at specified tagid.

Parameters
[in]pdbHandle to the shim database.
[out]GuidDatabase ID.
Returns
true if the ID was found FALSE otherwise.

Definition at line 388 of file sdbread.c.

389{
390 if(SdbIsNullGUID(&pdb->database_id))
391 {
393 if(root != TAGID_NULL)
394 {
396 if(id != TAGID_NULL)
397 {
398 if(!SdbReadBinaryTag(pdb, id, (PBYTE)&pdb->database_id, sizeof(pdb->database_id)))
399 {
400 memset(&pdb->database_id, 0, sizeof(pdb->database_id));
401 }
402 }
403 else
404 {
405 /* Should we silence this if we are opening a system db? */
406 SHIM_ERR("Failed to get the database id\n");
407 }
408 }
409 else
410 {
411 /* Should we silence this if we are opening a system db? */
412 SHIM_ERR("Failed to get root tag\n");
413 }
414 }
415 if(!SdbIsNullGUID(&pdb->database_id))
416 {
417 memcpy(Guid, &pdb->database_id, sizeof(pdb->database_id));
418 return TRUE;
419 }
420 return FALSE;
421}
BOOL WINAPI SdbIsNullGUID(CONST GUID *Guid)
Definition: sdbapi.c:431
#define TAG_DATABASE_ID
Definition: db.cpp:122
#define TAGID_ROOT
Definition: db.cpp:39
#define TAG_DATABASE
Definition: db.cpp:85
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
BYTE * PBYTE
Definition: pedump.c:66
TAGID WINAPI SdbFindFirstTag(PDB pdb, TAGID parent, TAG tag)
Definition: sdbread.c:208
BOOL WINAPI SdbReadBinaryTag(PDB pdb, TAGID tagid, PBYTE buffer, DWORD size)
Definition: sdbread.c:338
#define memset(x, y, z)
Definition: compat.h:39
_Must_inspect_result_ _In_ WDFOBJECT _In_ CONST GUID * Guid
Definition: wdfobject.h:762

Referenced by SdbOpenDatabase().

◆ SdbGetDatabaseInformation()

BOOL WINAPI SdbGetDatabaseInformation ( PDB  pdb,
PDB_INFORMATION  information 
)

Definition at line 502 of file sdbapi.c.

503{
504 if (pdb && information)
505 {
506 information->dwFlags = 0;
507 information->dwMajor = pdb->major;
508 information->dwMinor = pdb->minor;
509 information->Description = pdb->database_name;
510 if (!SdbIsNullGUID(&pdb->database_id))
511 {
513 information->Id = pdb->database_id;
514 }
515 return TRUE;
516 }
517
518 return FALSE;
519}
#define DB_INFO_FLAGS_VALID_GUID
Definition: apphelp.h:79
static PDB_INFORMATION information
Definition: db.cpp:178
BOOL WINAPI SdbIsNullGUID(CONST GUID *Guid)
Definition: sdbapi.c:431
DWORD dwFlags
Definition: apphelp.h:83
DWORD dwMajor
Definition: apphelp.h:84
LPCWSTR Description
Definition: apphelp.h:86
DWORD dwMinor
Definition: apphelp.h:85

Referenced by SdbRegisterDatabaseEx().

◆ SdbGetFileAttributes()

BOOL WINAPI SdbGetFileAttributes ( LPCWSTR  path,
PATTRINFO attr_info_ret,
LPDWORD  attr_count 
)

Retrieves attribute data shim database requires to match a file with database entry

Note
You must free the attr_info allocated by this function by calling SdbFreeFileAttributes.
Parameters
[in]pathPath to the file.
[out]attr_info_retPointer to array of ATTRINFO. Contains attribute data.
[out]attr_countNumber of attributes in attr_info.
Returns
TRUE if it succeeds, FALSE if it fails.

Definition at line 239 of file sdbfileattr.c.

240{
241 static const WCHAR str_tinfo[] = {'\\','V','a','r','F','i','l','e','I','n','f','o','\\','T','r','a','n','s','l','a','t','i','o','n',0};
242 static const WCHAR str_trans[] = {'\\','S','t','r','i','n','g','F','i','l','e','I','n','f','o','\\','%','0','4','x','%','0','4','x','\\','%','%','s',0};
243 static const WCHAR str_CompanyName[] = {'C','o','m','p','a','n','y','N','a','m','e',0};
244 static const WCHAR str_FileDescription[] = {'F','i','l','e','D','e','s','c','r','i','p','t','i','o','n',0};
245 static const WCHAR str_FileVersion[] = {'F','i','l','e','V','e','r','s','i','o','n',0};
246 static const WCHAR str_InternalName[] = {'I','n','t','e','r','n','a','l','N','a','m','e',0};
247 static const WCHAR str_LegalCopyright[] = {'L','e','g','a','l','C','o','p','y','r','i','g','h','t',0};
248 static const WCHAR str_OriginalFilename[] = {'O','r','i','g','i','n','a','l','F','i','l','e','n','a','m','e',0};
249 static const WCHAR str_ProductName[] = {'P','r','o','d','u','c','t','N','a','m','e',0};
250 static const WCHAR str_ProductVersion[] = {'P','r','o','d','u','c','t','V','e','r','s','i','o','n',0};
251
253 MEMMAPPED mapped;
254 PBYTE mapping_end;
255 PVOID file_info = 0;
257 WCHAR translation[128] = {0};
258 PATTRINFO attr_info;
259
260 struct LANGANDCODEPAGE {
261 WORD language;
262 WORD code_page;
263 } *lang_page;
264
265 if (!SdbpOpenMemMappedFile(path, &mapped))
266 {
267 SHIM_ERR("Error retrieving FILEINFO structure\n");
268 return FALSE;
269 }
270 mapping_end = mapped.view + mapped.size;
271
272 attr_info = (PATTRINFO)SdbAlloc(NUM_ATTRIBUTES * sizeof(ATTRINFO));
273
274 SdbpSetDWORDAttr(&attr_info[0], TAG_SIZE, mapped.size);
275 if (mapped.size)
277 else
278 SdbpSetAttrFail(&attr_info[1]);
280
283 else
284 SdbpSetAttrFail(&attr_info[16]); /* TAG_MODULE_TYPE */
285
286 if (headers && module_type == MODTYPE_PE && ((PBYTE)(headers+1) <= mapping_end))
287 {
288 DWORD info_size;
289 ULONG export_dir_size;
291
292 info_size = GetFileVersionInfoSizeW(path, NULL);
293 if (info_size != 0)
294 {
295 UINT page_size = 0;
296 file_info = SdbAlloc(info_size);
297 GetFileVersionInfoW(path, 0, info_size, file_info);
298 VerQueryValueW(file_info, str_tinfo, (LPVOID)&lang_page, &page_size);
299 StringCchPrintfW(translation, ARRAYSIZE(translation), str_trans, lang_page->language, lang_page->code_page);
300 }
301
302 /* Handles 2, 3, 12, 13, 14, 15, 21, 22 */
303 SdbpReadFileVersion(attr_info, file_info);
304
305 SdbpSetStringAttr(&attr_info[4], TAG_PRODUCT_VERSION, SdbpGetStringAttr(translation, str_ProductVersion, file_info));
306 SdbpSetStringAttr(&attr_info[5], TAG_FILE_DESCRIPTION, SdbpGetStringAttr(translation, str_FileDescription, file_info));
307 SdbpSetStringAttr(&attr_info[6], TAG_COMPANY_NAME, SdbpGetStringAttr(translation, str_CompanyName, file_info));
308 SdbpSetStringAttr(&attr_info[7], TAG_PRODUCT_NAME, SdbpGetStringAttr(translation, str_ProductName, file_info));
309 SdbpSetStringAttr(&attr_info[8], TAG_FILE_VERSION, SdbpGetStringAttr(translation, str_FileVersion, file_info));
310 SdbpSetStringAttr(&attr_info[9], TAG_ORIGINAL_FILENAME, SdbpGetStringAttr(translation, str_OriginalFilename, file_info));
311 SdbpSetStringAttr(&attr_info[10], TAG_INTERNAL_NAME, SdbpGetStringAttr(translation, str_InternalName, file_info));
312 SdbpSetStringAttr(&attr_info[11], TAG_LEGAL_COPYRIGHT, SdbpGetStringAttr(translation, str_LegalCopyright, file_info));
313
314 /* http://msdn.microsoft.com/en-us/library/windows/desktop/ms680339(v=vs.85).aspx */
315
316 SdbpSetDWORDAttr(&attr_info[17], TAG_PE_CHECKSUM, headers->OptionalHeader.CheckSum);
317
318 SdbpSetDWORDAttr(&attr_info[18], TAG_LINKER_VERSION, /* mislabeled! */
319 ((DWORD)headers->OptionalHeader.MajorImageVersion) << 16 | headers->OptionalHeader.MinorImageVersion);
320 SdbpSetAttrFail(&attr_info[19]); /* TAG_16BIT_DESCRIPTION */
321 SdbpSetAttrFail(&attr_info[20]); /* TAG_16BIT_MODULE_NAME */
322
323 SdbpSetDWORDAttr(&attr_info[23], TAG_LINK_DATE, headers->FileHeader.TimeDateStamp);
324 SdbpSetDWORDAttr(&attr_info[24], TAG_UPTO_LINK_DATE, headers->FileHeader.TimeDateStamp);
325
327 if (export_dir && ((PBYTE)(export_dir+1) <= mapping_end))
328 {
330 PBYTE export_name = RtlImageRvaToVa(headers, mapped.view, export_dir->Name, &section);
331 if (export_name)
332 SdbpSetStringAttrFromAnsiString(&attr_info[25], TAG_EXPORT_NAME, export_name, strlen((char*)export_name));
333 else
334 SdbpSetAttrFail(&attr_info[25]); /* TAG_EXPORT_NAME */
335 }
336 else
337 {
338 SdbpSetAttrFail(&attr_info[25]); /* TAG_EXPORT_NAME */
339 }
340
341 if (info_size)
342 SdbpSetDWORDAttr(&attr_info[26], TAG_VER_LANGUAGE, lang_page->language);
343
344 SdbpSetDWORDAttr(&attr_info[27], TAG_EXE_WRAPPER, 0); /* boolean */
345 }
346 else
347 {
348 int n;
349 for (n = 2; n < NUM_ATTRIBUTES; ++n)
350 {
351 if (n != 16 && n != 26)
352 SdbpSetAttrFail(&attr_info[n]);
353 }
354 if (module_type == MODTYPE_NE)
355 {
356 PBYTE ptr;
358 if ((PBYTE)(os2 + 1) <= mapping_end)
359 {
360 ptr = mapped.view + os2->ne_nrestab;
361 if (ptr <= mapping_end && (ptr + 1 + *ptr) <= mapping_end)
363 ptr = (PBYTE)os2 + os2->ne_restab;
364 if (ptr <= mapping_end && (ptr + 1 + *ptr) <= mapping_end)
366 }
367 }
368 }
369
370 *attr_info_ret = attr_info;
371 *attr_count = NUM_ATTRIBUTES; /* As far as I know, this one is always 28 */
372
374 SdbpCloseMemMappedFile(&mapped);
375 return TRUE;
376}
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
struct tagATTRINFO * PATTRINFO
module_type
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
#define IMAGE_DIRECTORY_ENTRY_EXPORT
Definition: compat.h:151
struct _IMAGE_EXPORT_DIRECTORY * PIMAGE_EXPORT_DIRECTORY
#define RtlImageDirectoryEntryToData
Definition: compat.h:809
#define RtlImageRvaToVa
Definition: compat.h:807
BOOL WINAPI GetFileVersionInfoW(LPCWSTR filename, DWORD handle, DWORD datasize, LPVOID data)
Definition: version.c:845
BOOL WINAPI VerQueryValueW(LPCVOID pBlock, LPCWSTR lpSubBlock, LPVOID *lplpBuffer, PUINT puLen)
Definition: version.c:1049
DWORD WINAPI GetFileVersionInfoSizeW(LPCWSTR filename, LPDWORD handle)
Definition: version.c:611
unsigned long DWORD
Definition: ntddk_ex.h:95
GLdouble n
Definition: glext.h:7729
if(dx< 0)
Definition: linetemp.h:194
#define TAG_ORIGINAL_FILENAME
Definition: apphelp.c:69
#define TAG_LINKER_VERSION
Definition: apphelp.c:55
#define TAG_16BIT_DESCRIPTION
Definition: apphelp.c:72
#define TAG_UPTO_LINK_DATE
Definition: apphelp.c:57
#define TAG_SIZE
Definition: apphelp.c:46
#define TAG_FILE_DESCRIPTION
Definition: apphelp.c:67
#define TAG_EXE_WRAPPER
Definition: apphelp.c:58
#define TAG_VER_LANGUAGE
Definition: apphelp.c:54
#define TAG_FILE_VERSION
Definition: apphelp.c:68
#define TAG_LEGAL_COPYRIGHT
Definition: apphelp.c:71
#define TAG_PRODUCT_NAME
Definition: apphelp.c:65
#define TAG_EXPORT_NAME
Definition: apphelp.c:74
#define TAG_CHECKSUM
Definition: apphelp.c:47
#define TAG_PE_CHECKSUM
Definition: apphelp.c:53
#define TAG_COMPANY_NAME
Definition: apphelp.c:64
#define TAG_LINK_DATE
Definition: apphelp.c:56
#define TAG_16BIT_MODULE_NAME
Definition: apphelp.c:73
#define TAG_INTERNAL_NAME
Definition: apphelp.c:70
#define TAG_MODULE_TYPE
Definition: apphelp.c:48
#define TAG_PRODUCT_VERSION
Definition: apphelp.c:66
static export_section_t export_dir
Definition: data.c:448
static PVOID ptr
Definition: dispmode.c:27
static DWORD page_size
Definition: loader.c:53
void WINAPI SdbpCloseMemMappedFile(PMEMMAPPED mapping)
Definition: sdbapi.c:244
BOOL WINAPI SdbpOpenMemMappedFile(LPCWSTR path, PMEMMAPPED mapping)
Definition: sdbapi.c:170
static void SdbpReadFileVersion(PATTRINFO attr_info, PVOID file_info)
Definition: sdbfileattr.c:104
static DWORD WINAPI SdbpGetModuleType(PMEMMAPPED mapping, PIMAGE_NT_HEADERS *nt_headers)
Definition: sdbfileattr.c:176
static DWORD WINAPI SdbpCalculateFileChecksum(PMEMMAPPED mapping)
Definition: sdbfileattr.c:142
static void WINAPI SdbpSetAttrFail(PATTRINFO attr)
Definition: sdbfileattr.c:55
static WCHAR *WINAPI SdbpGetStringAttr(LPWSTR translation, LPCWSTR attr, PVOID file_info)
Definition: sdbfileattr.c:60
static void WINAPI SdbpSetStringAttr(PATTRINFO attr, TAG tag, WCHAR *string)
Definition: sdbfileattr.c:42
static void WINAPI SdbpSetStringAttrFromAnsiString(PATTRINFO attr, TAG tag, PBYTE string, size_t len)
Definition: sdbfileattr.c:76
static void WINAPI SdbpSetDWORDAttr(PATTRINFO attr, TAG tag, DWORD value)
Definition: sdbfileattr.c:28
@ MODTYPE_PE
Definition: sdbfileattr.c:24
@ MODTYPE_NE
Definition: sdbfileattr.c:23
@ MODTYPE_UNKNOWN
Definition: sdbfileattr.c:21
static void WINAPI SdbpSetStringAttrFromPascalString(PATTRINFO attr, TAG tag, PBYTE string)
Definition: sdbfileattr.c:93
vector< Header * > headers
Definition: sdkparse.cpp:39
STRSAFEAPI StringCchPrintfW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszFormat,...)
Definition: strsafe.h:530
Definition: parser.c:56
SIZE_T size
Definition: sdbpapi.h:46
PBYTE view
Definition: sdbpapi.h:45
struct _IMAGE_OS2_HEADER * PIMAGE_OS2_HEADER

Referenced by InitApphelp(), SdbGetMatchingExe(), SdbpMatchExe(), and START_TEST().

◆ SdbGetFirstChild()

TAGID WINAPI SdbGetFirstChild ( PDB  pdb,
TAGID  parent 
)

Searches shim database for a child of specified parent tag.

Parameters
[in]pdbHandle to the shim database.
[in]parentTAGID of parent.
Returns
Success: TAGID of child tag, Failure: TAGID_NULL.

Definition at line 142 of file sdbread.c.

143{
144 /* if we are at beginning of database */
145 if (parent == TAGID_ROOT)
146 {
147 /* header only database: no tags */
148 if (pdb->size <= _TAGID_ROOT)
149 return TAGID_NULL;
150 /* return *real* root tagid */
151 else return _TAGID_ROOT;
152 }
153
154 /* only list tag can have children */
156 return TAGID_NULL;
157
158 /* first child is sizeof(TAG) + sizeof(DWORD) bytes after beginning of list */
159 return parent + sizeof(TAG) + sizeof(DWORD);
160}
#define TAG(x)
Definition: ObTypes.c:145
#define _TAGID_ROOT
Definition: db.cpp:40
#define TAG_TYPE_LIST
Definition: apphelp.c:42

Referenced by SdbFindFirstTag(), and SdbpMatchFileAttributes().

◆ SdbGetMatchingExe()

BOOL WINAPI SdbGetMatchingExe ( HSDB  hsdb,
LPCWSTR  path,
LPCWSTR  module_name,
LPCWSTR  env,
DWORD  flags,
PSDBQUERYRESULT  result 
)

Queries database for a specified exe If hsdb is NULL default database shall be loaded and searched.

Parameters
[in]hsdbHandle to the shim database.
[in]pathPath to executable for which we query database.
[in]module_nameUnused.
[in]envThe environment block to use
[in]flags0 or SDBGMEF_IGNORE_ENVIRONMENT.
[out]resultPointer to structure in which query result shall be stored.
Returns
TRUE if it succeeds, FALSE if it fails.

Definition at line 439 of file hsdb.c.

441{
442 BOOL ret = FALSE;
443 TAGID database, iter, name;
445 DWORD attr_count;
446 RTL_UNICODE_STRING_BUFFER DosApplicationName = { { 0 } };
447 WCHAR DosPathBuffer[MAX_PATH];
448 ULONG PathType = 0;
452 PDB pdb;
453
454 /* Load default database if one is not specified */
455 if (!hsdb)
456 {
457 /* To reproduce windows behaviour HID_DOS_PATHS needs
458 * to be specified when loading default database */
460 if (hsdb)
461 hsdb->auto_loaded = TRUE;
462 }
463
464 ZeroMemory(result, sizeof(*result));
465
466 /* No database could be loaded */
467 if (!hsdb || !path)
468 return FALSE;
469
470 /* We do not support multiple db's yet! */
471 pdb = hsdb->pdb;
472
473 RtlInitUnicodeString(&DosApplicationName.String, path);
474 RtlInitBuffer(&DosApplicationName.ByteBuffer, (PUCHAR)DosPathBuffer, sizeof(DosPathBuffer));
475 if (!NT_SUCCESS(RtlEnsureBufferSize(RTL_SKIP_BUFFER_COPY, &DosApplicationName.ByteBuffer, DosApplicationName.String.MaximumLength)))
476 {
477 SHIM_ERR("Failed to convert allocate buffer.\n");
478 goto Cleanup;
479 }
480 /* Update the internal buffer to contain the string */
481 memcpy(DosApplicationName.ByteBuffer.Buffer, path, DosApplicationName.String.MaximumLength);
482 /* Make sure the string uses our internal buffer (we want to modify the buffer,
483 and RtlNtPathNameToDosPathName does not always modify the String to point to the Buffer)! */
484 DosApplicationName.String.Buffer = (PWSTR)DosApplicationName.ByteBuffer.Buffer;
485
486 if (!NT_SUCCESS(RtlNtPathNameToDosPathName(0, &DosApplicationName, &PathType, NULL)))
487 {
488 SHIM_ERR("Failed to convert %S to DOS Path.\n", path);
489 goto Cleanup;
490 }
491
492
493 /* Extract file name */
494 file_name = wcsrchr(DosApplicationName.String.Buffer, '\\');
495 if (!file_name)
496 {
497 SHIM_ERR("Failed to find Exe name in %wZ.\n", &DosApplicationName.String);
498 goto Cleanup;
499 }
500
501 /* We will use the buffer for exe name and directory. */
502 *(file_name++) = UNICODE_NULL;
503
504 /* DATABASE is list TAG which contains all executables */
506 if (database == TAGID_NULL)
507 {
508 goto Cleanup;
509 }
510
511 /* EXE is list TAG which contains data required to match executable */
512 iter = SdbFindFirstTag(pdb, database, TAG_EXE);
513
514 /* Search for entry in database, we should look into indexing tags! */
515 while (iter != TAGID_NULL)
516 {
517 LPWSTR foundName;
518 /* Check if exe name matches */
520 /* If this is a malformed DB, (no TAG_NAME), we should not crash. */
521 foundName = SdbGetStringTagPtr(pdb, name);
522 if (foundName && !wcsicmp(foundName, file_name))
523 {
524 /* Get information about executable required to match it with database entry */
525 if (!attribs)
526 {
527 if (!SdbGetFileAttributes(path, &attribs, &attr_count))
528 goto Cleanup;
529 }
530
531
532 /* We have a null terminator before the application name, so DosApplicationName only contains the path. */
533 if (SdbpMatchExe(pdb, iter, DosApplicationName.String.Buffer, attribs, attr_count))
534 {
535 ret = TRUE;
536 SdbpAddExeMatch(hsdb, pdb, iter, result);
537 }
538 }
539
540 /* Continue iterating */
541 iter = SdbFindNextTag(pdb, database, iter);
542 }
543
544 /* Restore the full path. */
545 *(--file_name) = L'\\';
546
547 dwSize = sizeof(wszLayers);
549 {
551 ret = TRUE;
552 }
553
555 {
557 {
558 ret = TRUE;
560 }
561 }
562
563Cleanup:
564 RtlFreeBuffer(&DosApplicationName.ByteBuffer);
565 if (attribs)
567 if (hsdb->auto_loaded)
568 SdbReleaseDatabase(hsdb);
569 return ret;
570}
static IN ULONG IN PWSTR OUT PCWSTR OUT PBOOLEAN OUT PATH_TYPE_AND_UNKNOWN * PathType
BOOL WINAPI SdbFreeFileAttributes(PATTRINFO attr_info)
Definition: sdbfileattr.c:214
#define SDB_DATABASE_MAIN_SHIM
Definition: apphelp.h:24
#define HID_DOS_PATHS
Definition: apphelp.h:19
#define SDBGMEF_IGNORE_ENVIRONMENT
Definition: apphelp.h:62
BOOL WINAPI SdbGetPermLayerKeys(PCWSTR wszPath, PWSTR pwszLayers, PDWORD pdwBytes, DWORD dwFlags)
Definition: layer.c:364
BOOL WINAPI SdbGetFileAttributes(LPCWSTR path, PATTRINFO *attr_info_ret, LPDWORD attr_count)
Definition: sdbfileattr.c:239
#define SHIMREG_HAS_ENVIRONMENT
Definition: apphelp.h:59
#define TAG_EXE
Definition: db.cpp:87
static LPCWSTR LPCWSTR LPCWSTR env
Definition: db.cpp:170
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
#define wcsrchr
Definition: compat.h:16
#define MAX_PATH
Definition: compat.h:34
static const WCHAR Cleanup[]
Definition: register.c:80
unsigned int BOOL
Definition: ntddk_ex.h:94
GLbitfield flags
Definition: glext.h:7161
GLuint64EXT * result
Definition: glext.h:11304
const GLint * attribs
Definition: glext.h:10538
#define GPLK_USER
Definition: hsdb.c:18
static void SdbpAddExeMatch(HSDB hsdb, PDB pdb, TAGID tagExe, PSDBQUERYRESULT result)
Definition: hsdb.c:282
HSDB WINAPI SdbInitDatabase(DWORD flags, LPCWSTR path)
Definition: hsdb.c:369
#define GPLK_MACHINE
Definition: hsdb.c:19
static BOOL SdbpPropagateEnvLayers(HSDB hsdb, LPWSTR Environment, PSDBQUERYRESULT Result)
Definition: hsdb.c:341
void WINAPI SdbReleaseDatabase(HSDB hsdb)
Definition: hsdb.c:417
#define MAX_LAYER_LENGTH
Definition: hsdb.c:17
static BOOL WINAPI SdbpMatchExe(PDB pdb, TAGID exe, const WCHAR *dir, PATTRINFO main_attribs, DWORD main_attr_count)
Definition: hsdb.c:109
static ULONG SdbpAddLayerMatches(HSDB hsdb, PWSTR pwszLayers, DWORD pdwBytes, PSDBQUERYRESULT result)
Definition: hsdb.c:308
static PCWSTR wszLayers
Definition: layerapi.c:34
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:56
static LPCWSTR file_name
Definition: protocol.c:147
#define RTL_SKIP_BUFFER_COPY
Definition: rtlfuncs.h:2463
NTSYSAPI NTSTATUS NTAPI RtlNtPathNameToDosPathName(_In_ ULONG Flags, _Inout_ PRTL_UNICODE_STRING_BUFFER Path, _Out_opt_ PULONG PathType, _Out_opt_ PULONG Unknown)
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define UNICODE_NULL
PUCHAR Buffer
Definition: rtltypes.h:1875
UNICODE_STRING String
Definition: rtltypes.h:1885
BOOL auto_loaded
Definition: apphelp.h:32
PDB pdb
Definition: apphelp.h:31
USHORT MaximumLength
Definition: env_spec_w32.h:370
uint16_t * PWSTR
Definition: typedefs.h:56
unsigned char * PUCHAR
Definition: typedefs.h:53
#define TAG_NAME
Definition: vfat.h:553
int ret
#define ZeroMemory
Definition: winbase.h:1712
WCHAR * LPWSTR
Definition: xmlstorage.h:184

Referenced by ApphelpCheckRunAppEx().

◆ SdbGetNextChild()

TAGID WINAPI SdbGetNextChild ( PDB  pdb,
TAGID  parent,
TAGID  prev_child 
)

Searches shim database for next child of specified parent tag.

Parameters
[in]pdbHandle to the shim database.
[in]parentTAGID of parent.
[in]prev_childTAGID of previous child.
Returns
Success: TAGID of next child tag, Failure: TAGID_NULL.

Definition at line 171 of file sdbread.c.

172{
173 TAGID next_child;
174 DWORD prev_child_size, parent_size;
175
176 prev_child_size = SdbpGetTagSize(pdb, prev_child);
177 if (prev_child_size == 0)
178 return TAGID_NULL;
179
180 /* Bound check */
181 next_child = prev_child + prev_child_size;
182 if (next_child >= pdb->size)
183 return TAGID_NULL;
184
185 if (parent == TAGID_ROOT)
186 return next_child;
187
188 parent_size = SdbpGetTagSize(pdb, parent);
189 if (parent_size == 0)
190 return TAGID_NULL;
191
192 /* Specified parent has no more children */
193 if (next_child >= parent + parent_size)
194 return TAGID_NULL;
195
196 return next_child;
197}
static DWORD WINAPI SdbpGetTagSize(PDB pdb, TAGID tagid)
Definition: sdbread.c:30

Referenced by SdbFindFirstTag(), SdbFindNextTag(), and SdbpMatchFileAttributes().

◆ SdbGetPermLayerKeys()

BOOL WINAPI SdbGetPermLayerKeys ( PCWSTR  wszPath,
PWSTR  pwszLayers,
PDWORD  pdwBytes,
DWORD  dwFlags 
)

Read the layers specified for the application.

Parameters
[in]wszPathFull pathname of the file.
[out]pwszLayersOn return, the layers set on the file.
pdwBytesThe size of the pwszLayers buffer in bytes, and on return the size of the data written (in bytes)
[in]dwFlagsThe flags, [GPLK_USER | GPLK_MACHINE].
Returns
TRUE if it succeeds, FALSE if it fails.

Definition at line 364 of file layer.c.

365{
366 BOOL Result = FALSE;
367 SDB_TMP_STR LongPath;
368 DWORD dwBytes, dwTotal = 0;
369 if (!wszPath || !pdwBytes)
370 {
371 SHIM_ERR("NULL parameter passed for wszPath or pdwBytes.\n");
372 return FALSE;
373 }
374
375 if (!SdbpResolvePath(&LongPath, wszPath))
376 return FALSE;
377 dwBytes = *pdwBytes;
378 if (dwFlags & GPLK_MACHINE)
379 {
380 if (SdbpGetPermLayersInternal(&LongPath.Str, pwszLayers, &dwBytes, TRUE))
381 {
382 Result = TRUE;
383 dwTotal = dwBytes - sizeof(WCHAR); /* Compensate for the nullterm. */
384 pwszLayers += dwTotal / sizeof(WCHAR);
385 dwBytes = *pdwBytes - dwBytes;
386 if (dwFlags & GPLK_USER)
387 {
388 *(pwszLayers++) = L' ';
389 *pwszLayers = L'\0';
390 dwBytes -= sizeof(WCHAR);
391 dwTotal += sizeof(WCHAR);
392 }
393 }
394 }
395 if (dwFlags & GPLK_USER)
396 {
397 if (SdbpGetPermLayersInternal(&LongPath.Str, pwszLayers, &dwBytes, FALSE))
398 {
399 Result = TRUE;
400 dwTotal += dwBytes - sizeof(WCHAR); /* Compensate for the nullterm. */
401 }
402 else if (dwTotal > 0 && pwszLayers[-1] == L' ')
403 {
404 pwszLayers[-1] = '\0';
405 dwTotal -= sizeof(WCHAR);
406 }
407 }
408 if (dwTotal)
409 dwTotal += sizeof(WCHAR);
410 *pdwBytes = dwTotal;
411 SdbpFreeTempStr(&LongPath);
412 return Result;
413}
BOOL SdbpGetPermLayersInternal(PUNICODE_STRING FullPath, PWSTR pwszLayers, PDWORD pdwBytes, BOOL bMachine)
Definition: layer.c:230
#define GPLK_USER
Definition: layer.c:15
#define GPLK_MACHINE
Definition: layer.c:16
void SdbpFreeTempStr(PSDB_TMP_STR String)
Definition: layer.c:56
BOOL SdbpResolvePath(PSDB_TMP_STR LongPath, PCWSTR wszPath)
Definition: layer.c:163
static PWSTR PDWORD pdwBytes
Definition: layerapi.c:35
static PWSTR pwszLayers
Definition: layerapi.c:35
UNICODE_STRING Str
Definition: layer.c:45
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1176
_At_(*)(_In_ PWSK_CLIENT Client, _In_opt_ PUNICODE_STRING NodeName, _In_opt_ PUNICODE_STRING ServiceName, _In_opt_ ULONG NameSpace, _In_opt_ GUID *Provider, _In_opt_ PADDRINFOEXW Hints, _Outptr_ PADDRINFOEXW *Result, _In_opt_ PEPROCESS OwningProcess, _In_opt_ PETHREAD OwningThread, _Inout_ PIRP Irp Result)(Mem)) NTSTATUS(WSKAPI *PFN_WSK_GET_ADDRESS_INFO
Definition: wsk.h:409

Referenced by GetLayerInfo(), SdbGetMatchingExe(), and SetPermLayerState().

◆ SdbGetStringTagPtr()

LPWSTR WINAPI SdbGetStringTagPtr ( PDB  pdb,
TAGID  tagid 
)

Searches shim database for string associated with specified tagid.

Parameters
[in]pdbHandle to the shim database.
[in]tagidTAGID of string or stringref associated with the string.
Returns
the LPWSTR associated with specified tagid, or NULL on failure.

Definition at line 375 of file sdbread.c.

376{
377 return SdbpGetString(pdb, tagid, NULL);
378}
LPWSTR WINAPI SdbpGetString(PDB pdb, TAGID tagid, PDWORD size)
Definition: sdbread.c:47

Referenced by CLayerStringList::Next(), ProcessExe(), ProcessLayers(), SdbFindFirstNamedTag(), SdbGetMatchingExe(), SdbInstall(), SdbOpenDatabase(), SdbpAddExeLayers(), SdbpMatchExe(), SdbpMatchFileAttributes(), SeiGetStringPtr(), and SeiReadInExclude().

◆ SdbGetTagDataSize()

DWORD WINAPI SdbGetTagDataSize ( PDB  pdb,
TAGID  tagid 
)

Retrieves size of data at specified tagid.

Parameters
[in]pdbHandle to the shim database.
[in]tagidTagid of tag whose size is queried.
Returns
Success: Size of data at specified tagid, Failure: 0.

Definition at line 109 of file sdbread.c.

110{
111 /* sizes of data types with fixed size */
112 static const SIZE_T sizes[6] = {
113 0, /* NULL */ 1, /* BYTE */
114 2, /* WORD */ 4, /* DWORD */
115 8, /* QWORD */ 4 /* STRINGREF */
116 };
117 WORD type;
118 DWORD size;
119
121 if (type == TAG_NULL)
122 return 0;
123
125 return sizes[(type >> 12) - 1];
126
127 /* tag with dynamic size (e.g. list): must read size */
128 if (!SdbpReadData(pdb, &size, tagid + sizeof(TAG), sizeof(size)))
129 return 0;
130
131 return size;
132}
#define TAG_NULL
Definition: apphelp.c:45
static const struct @539 sizes[]
BOOL WINAPI SdbpReadData(PDB pdb, PVOID dest, DWORD offset, DWORD num)
Definition: sdbread.c:14
ULONG_PTR SIZE_T
Definition: typedefs.h:80

Referenced by SdbpGetTagSize(), and SdbQueryDataExTagID().

◆ SdbGetTagFromTagID()

TAG WINAPI SdbGetTagFromTagID ( PDB  pdb,
TAGID  tagid 
)

Searches shim database for the tag associated with specified tagid.

Parameters
[in]pdbHandle to the shim database.
[in]tagidThe TAGID of the tag.
Returns
Success: The tag associated with specified tagid, Failure: TAG_NULL.

Definition at line 93 of file sdbread.c.

94{
95 TAG data;
96 if (!SdbpReadData(pdb, &data, tagid, sizeof(data)))
97 return TAG_NULL;
98 return data;
99}
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950

Referenced by SdbFindFirstTag(), SdbFindNextTag(), SdbGetFirstChild(), SdbGetTagDataSize(), SdbpCheckTagIDType(), SdbpGetString(), SdbpGetTagSize(), and SdbpMatchFileAttributes().

◆ SdbGUIDToString()

BOOL WINAPI SdbGUIDToString ( CONST GUID Guid,
PWSTR  GuidString,
SIZE_T  Length 
)

Converts a GUID to a string.

Parameters
[in]GuidThe GUID to convert.
[out]GuidStringThe resulting string representation of Guid.
[in]LengthThe length of GuidString.
Returns
TRUE if it succeeds, FALSE if it fails.

Definition at line 412 of file sdbapi.c.

413{
414 UNICODE_STRING GuidString_u;
415 if (NT_SUCCESS(RtlStringFromGUID(Guid, &GuidString_u)))
416 {
417 HRESULT hr = StringCchCopyNW(GuidString, Length, GuidString_u.Buffer, GuidString_u.Length / sizeof(WCHAR));
418 RtlFreeUnicodeString(&GuidString_u);
419 return SUCCEEDED(hr);
420 }
421 return FALSE;
422}
NTSYSAPI NTSTATUS WINAPI RtlStringFromGUID(REFGUID, PUNICODE_STRING)
static PWSTR GuidString
Definition: apphelp.c:93
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102
STRSAFEAPI StringCchCopyNW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszSrc, size_t cchToCopy)
Definition: strsafe.h:236

Referenced by ApphelpCheckShellObject(), SdbRegisterDatabaseEx(), SdbUnregisterDatabase(), and START_TEST().

◆ SdbInitDatabase()

HSDB WINAPI SdbInitDatabase ( DWORD  flags,
LPCWSTR  path 
)

Opens specified shim database file. Handle returned by this function may only be used by functions which take HSDB param thus differing it from SdbOpenDatabase.

Parameters
[in]flagsSpecifies type of path or predefined database.
[in]pathPath to the shim database file.
Returns
Success: Handle to the opened shim database, NULL otherwise.

Definition at line 369 of file hsdb.c.

370{
371 static const WCHAR shim[] = {'\\','s','y','s','m','a','i','n','.','s','d','b',0};
372 static const WCHAR msi[] = {'\\','m','s','i','m','a','i','n','.','s','d','b',0};
373 static const WCHAR drivers[] = {'\\','d','r','v','m','a','i','n','.','s','d','b',0};
375 WCHAR buffer[128];
376 HSDB hsdb;
377
378 hsdb = SdbAlloc(sizeof(SDB));
379 if (!hsdb)
380 return NULL;
381 hsdb->auto_loaded = 0;
382
383 /* Check for predefined databases */
385 {
387 {
388 case SDB_DATABASE_MAIN_SHIM: name = shim; break;
389 case SDB_DATABASE_MAIN_MSI: name = msi; break;
390 case SDB_DATABASE_MAIN_DRIVERS: name = drivers; break;
391 default:
392 SdbReleaseDatabase(hsdb);
393 return NULL;
394 }
398 }
399
400 hsdb->pdb = SdbOpenDatabase(path ? path : buffer, (flags & 0xF) - 1);
401
402 /* If database could not be loaded, a handle doesn't make sense either */
403 if (!hsdb->pdb)
404 {
405 SdbReleaseDatabase(hsdb);
406 return NULL;
407 }
408
409 return hsdb;
410}
#define SDB_DATABASE_MAIN_MSI
Definition: apphelp.h:23
#define HID_DATABASE_TYPE_MASK
Definition: apphelp.h:22
PDB WINAPI SdbOpenDatabase(LPCWSTR path, PATH_TYPE type)
Definition: sdbapi.c:329
#define SDB_DATABASE_MAIN_DRIVERS
Definition: apphelp.h:25
GLuint buffer
Definition: glext.h:5915
HRESULT WINAPI SdbGetAppPatchDir(HSDB hsdb, LPWSTR path, DWORD size)
Definition: hsdb.c:579
#define _countof(array)
Definition: sndvol32.h:70
Definition: apphelp.h:30

Referenced by ApphelpCheckRunAppEx(), SdbGetMatchingExe(), SdbPackAppCompatData(), and SeiGetShimData().

◆ SdbIsNullGUID()

BOOL WINAPI SdbIsNullGUID ( CONST GUID Guid)

Checks if the specified GUID is a NULL GUID

Parameters
[in]GuidThe GUID to check.
Returns
TRUE if it is a NULL GUID.

Definition at line 431 of file sdbapi.c.

432{
433 static GUID NullGuid = { 0 };
434 return !Guid || IsEqualGUID(&NullGuid, Guid);
435}
#define IsEqualGUID(rguid1, rguid2)
Definition: guiddef.h:147

Referenced by SdbGetDatabaseID(), SdbGetDatabaseInformation(), and START_TEST().

◆ SdbOpenDatabase()

PDB WINAPI SdbOpenDatabase ( LPCWSTR  path,
PATH_TYPE  type 
)

Opens specified shim database file.

Parameters
[in]pathPath to the shim database.
[in]typeType of path. Either DOS_PATH or NT_PATH.
Returns
Success: Handle to the shim database, NULL otherwise.

Definition at line 329 of file sdbapi.c.

330{
331 PDB pdb;
332 TAGID root, name;
333
335 if (!pdb)
336 return NULL;
337
338 if (pdb->major != 2 && pdb->major != 3)
339 {
341 SHIM_ERR("Invalid shim database version\n");
342 return NULL;
343 }
344
346 if (!SdbGetDatabaseID(pdb, &pdb->database_id))
347 {
348 SHIM_INFO("Failed to get the database id\n");
349 }
350
352 if (root != TAGID_NULL)
353 {
355 if (name != TAGID_NULL)
356 {
357 pdb->database_name = SdbGetStringTagPtr(pdb, name);
358 }
359 }
360 if (!pdb->database_name)
361 {
362 SHIM_INFO("Failed to get the database name\n");
363 }
364
365 return pdb;
366}
BOOL WINAPI SdbGetDatabaseID(PDB pdb, GUID *Guid)
Definition: sdbread.c:388
struct _root root
#define TAG_STRINGTABLE
Definition: db.cpp:94
PDB SdbpOpenDatabase(LPCWSTR path, PATH_TYPE type)
Definition: sdbapi.c:269

Referenced by CLayerStringList::CLayerStringList(), SdbInitDatabase(), SdbInstall(), SdbRegisterDatabaseEx(), and SdbUninstall().

◆ SdbpGetString()

LPWSTR WINAPI SdbpGetString ( PDB  pdb,
TAGID  tagid,
PDWORD  size 
)

Definition at line 47 of file sdbread.c.

48{
49 TAG tag;
51
52 tag = SdbGetTagFromTagID(pdb, tagid);
53 if (tag == TAG_NULL)
54 return NULL;
55
57 {
58 /* No stringtable; all references are invalid */
59 if (pdb->stringtable == TAGID_NULL)
60 return NULL;
61
62 /* TAG_TYPE_STRINGREF contains offset of string relative to stringtable */
63 if (!SdbpReadData(pdb, &tagid, tagid + sizeof(TAG), sizeof(TAGID)))
64 return NULL;
65
66 offset = pdb->stringtable + tagid + sizeof(TAG) + sizeof(TAGID);
67 }
68 else if ((tag & TAG_TYPE_MASK) == TAG_TYPE_STRING)
69 {
70 offset = tagid + sizeof(TAG) + sizeof(TAGID);
71 }
72 else
73 {
74 SHIM_ERR("Tag 0x%u at tagid %u is neither a string or reference to string\n", tag, tagid);
75 return NULL;
76 }
77
78 /* Optionally read string size */
79 if (size && !SdbpReadData(pdb, size, offset - sizeof(TAGID), sizeof(*size)))
80 return FALSE;
81
82 return (LPWSTR)(&pdb->data[offset]);
83}
GLintptr offset
Definition: glext.h:5920
#define TAG_TYPE_STRING
Definition: apphelp.c:43

Referenced by SdbGetStringTagPtr(), SdbQueryDataExTagID(), and SdbReadStringTag().

◆ SdbpReadData()

BOOL WINAPI SdbpReadData ( PDB  pdb,
PVOID  dest,
DWORD  offset,
DWORD  num 
)

Definition at line 14 of file sdbread.c.

15{
16 DWORD size = offset + num;
17
18 /* Either overflow or no data to read */
19 if (size <= offset)
20 return FALSE;
21
22 /* Overflow */
23 if (pdb->size < size)
24 return FALSE;
25
26 memcpy(dest, pdb->data + offset, num);
27 return TRUE;
28}
GLuint GLuint num
Definition: glext.h:9618
static char * dest
Definition: rtl.c:135

Referenced by SdbGetTagDataSize(), SdbGetTagFromTagID(), SdbpGetString(), SdbpOpenDatabase(), SdbQueryDataExTagID(), SdbReadBinaryTag(), SdbReadDWORDTag(), SdbReadQWORDTag(), and SdbReadWORDTag().

◆ SdbpStrDup()

PWSTR SdbpStrDup ( LPCWSTR  string)

Definition at line 162 of file sdbapi.c.

163{
164 PWSTR ret = SdbAlloc(SdbpStrsize(string));
165 wcscpy(ret, string);
166 return ret;
167}
DWORD SdbpStrsize(PCWSTR string)
Definition: sdbapi.c:157
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)

Referenced by SdbpSetStringAttr(), SeiAppendHookInfo(), SeiAppendInExclude(), and SeiInitPaths().

◆ SdbpStrsize()

DWORD SdbpStrsize ( PCWSTR  string)

Definition at line 157 of file sdbapi.c.

158{
159 return (SdbpStrlen(string) + 1) * sizeof(WCHAR);
160}

Referenced by SdbpOpenKey(), SdbSetPermLayerKeys(), SdbWriteStringTag(), and SeiInitPaths().

◆ SdbQueryData()

DWORD WINAPI SdbQueryData ( HSDB  hsdb,
TAGREF  trWhich,
LPCWSTR  lpszDataName,
LPDWORD  lpdwDataType,
LPVOID  lpBuffer,
LPDWORD  lpcbBufferSize 
)

Retrieve a Data entry

Parameters
[in]hsdbThe multi-database.
[in]trExeThe tagRef to start at
[in,opt]lpszDataName The name of the Data entry to find, or NULL to return all.
[out,opt]lpdwDataType Any of REG_SZ, REG_QWORD, REG_DWORD, ...
[out]lpBufferThe output buffer
[in,out,opt]lpcbBufferSize The size of lpBuffer in bytes
Returns
ERROR_SUCCESS

Definition at line 832 of file hsdb.c.

833{
835}
static TAGREF LPCWSTR LPDWORD LPVOID lpBuffer
Definition: db.cpp:175
static TAGREF LPCWSTR lpszDataName
Definition: db.cpp:175
static TAGREF trWhich
Definition: db.cpp:171
static TAGREF LPCWSTR LPDWORD lpdwDataType
Definition: db.cpp:175
static TAGREF LPCWSTR LPDWORD LPVOID LPDWORD lpcbBufferSize
Definition: db.cpp:175
DWORD WINAPI SdbQueryDataEx(HSDB hsdb, TAGREF trWhich, LPCWSTR lpszDataName, LPDWORD lpdwDataType, LPVOID lpBuffer, LPDWORD lpcbBufferSize, TAGREF *ptrData)
Definition: hsdb.c:799

Referenced by SdbPackAppCompatData().

◆ SdbQueryDataExTagID()

DWORD WINAPI SdbQueryDataExTagID ( PDB  pdb,
TAGID  tiExe,
LPCWSTR  lpszDataName,
LPDWORD  lpdwDataType,
LPVOID  lpBuffer,
LPDWORD  lpcbBufferSize,
TAGID ptiData 
)

Retrieve a Data entry

Parameters
[in]pdbThe database.
[in]tiExeThe tagID to start at
[in,opt]lpszDataName The name of the Data entry to find, or NULL to return all.
[out,opt]lpdwDataType Any of REG_SZ, REG_QWORD, REG_DWORD, ...
[out]lpBufferThe output buffer
[in,out,opt]lpcbBufferSize The size of lpBuffer in bytes
[out,opt]ptiData The tagID of the data
Returns
ERROR_SUCCESS

Definition at line 614 of file sdbapi.c.

615{
616 TAGID tiData, tiValueType, tiValue;
617 DWORD dwDataType, dwSizeRequired, dwInputSize;
618 LPCWSTR lpStringData;
619 /* Not supported yet */
620 if (!lpszDataName)
622
624 if (tiData == TAGID_NULL)
625 {
626 SHIM_INFO("No data tag found\n");
627 return ERROR_NOT_FOUND;
628 }
629
630 if (ptiData)
631 *ptiData = tiData;
632
633 tiValueType = SdbFindFirstTag(pdb, tiData, TAG_DATA_VALUETYPE);
634 if (tiValueType == TAGID_NULL)
635 {
636 SHIM_WARN("Data tag (0x%x) without valuetype\n", tiData);
638 }
639
640 dwDataType = SdbReadDWORDTag(pdb, tiValueType, 0);
641 switch (dwDataType)
642 {
643 case REG_SZ:
644 tiValue = SdbFindFirstTag(pdb, tiData, TAG_DATA_STRING);
645 break;
646 case REG_DWORD:
647 tiValue = SdbFindFirstTag(pdb, tiData, TAG_DATA_DWORD);
648 break;
649 case REG_QWORD:
650 tiValue = SdbFindFirstTag(pdb, tiData, TAG_DATA_QWORD);
651 break;
652 default:
653 /* Not supported (yet) */
654 SHIM_WARN("Unsupported dwDataType=0x%x\n", dwDataType);
656 }
657
658 if (lpdwDataType)
659 *lpdwDataType = dwDataType;
660
661 if (tiValue == TAGID_NULL)
662 {
663 SHIM_WARN("Data tag (0x%x) without data\n", tiData);
665 }
666
667 if (dwDataType != REG_SZ)
668 {
669 dwSizeRequired = SdbGetTagDataSize(pdb, tiValue);
670 }
671 else
672 {
673 lpStringData = SdbpGetString(pdb, tiValue, &dwSizeRequired);
674 if (lpStringData == NULL)
675 {
677 }
678 }
679 if (!lpcbBufferSize)
681
682 dwInputSize = *lpcbBufferSize;
683 *lpcbBufferSize = dwSizeRequired;
684
685 if (dwInputSize < dwSizeRequired || lpBuffer == NULL)
686 {
687 SHIM_WARN("dwInputSize %u not sufficient to hold %u bytes\n", dwInputSize, dwSizeRequired);
689 }
690
691 if (dwDataType != REG_SZ)
692 {
693 SdbpReadData(pdb, lpBuffer, tiValue + sizeof(TAG), dwSizeRequired);
694 }
695 else
696 {
697 StringCbCopyNW(lpBuffer, dwInputSize, lpStringData, dwSizeRequired);
698 }
699
700 return ERROR_SUCCESS;
701}
DWORD WINAPI SdbGetTagDataSize(PDB pdb, TAGID tagid)
Definition: sdbread.c:109
LPWSTR WINAPI SdbpGetString(PDB pdb, TAGID tagid, PDWORD size)
Definition: sdbread.c:47
BOOL WINAPI SdbpReadData(PDB pdb, PVOID dest, DWORD offset, DWORD num)
Definition: sdbread.c:14
DWORD WINAPI SdbReadDWORDTag(PDB pdb, TAGID tagid, DWORD ret)
Definition: sdbread.c:305
static TAGID tiExe
Definition: db.cpp:177
#define TAG_DATA
Definition: db.cpp:93
static TAGID LPCWSTR LPDWORD LPVOID LPDWORD TAGID * ptiData
Definition: db.cpp:177
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10
#define ERROR_SUCCESS
Definition: deptool.c:10
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
TAGID WINAPI SdbFindFirstNamedTag(PDB pdb, TAGID root, TAGID find, TAGID nametag, LPCWSTR find_name)
Definition: sdbapi.c:544
#define REG_QWORD
Definition: sdbapi.c:597
#define REG_DWORD
Definition: sdbapi.c:596
#define REG_SZ
Definition: sdbapi.c:595
#define SHIM_WARN(fmt,...)
Definition: sdbpapi.h:77
#define TAG_DATA_VALUETYPE
Definition: sdbtagid.h:86
#define TAG_DATA_QWORD
Definition: sdbtagid.h:116
#define TAG_DATA_STRING
Definition: sdbtagid.h:153
#define TAG_DATA_DWORD
Definition: sdbtagid.h:87
STRSAFEAPI StringCbCopyNW(STRSAFE_LPWSTR pszDest, size_t cbDest, STRSAFE_LPCWSTR pszSrc, size_t cbToCopy)
Definition: strsafe.h:255
#define ERROR_INTERNAL_DB_CORRUPTION
Definition: winerror.h:839
#define ERROR_NOT_FOUND
Definition: winerror.h:690

Referenced by SdbQueryDataEx().

◆ SdbReadBinaryTag()

BOOL WINAPI SdbReadBinaryTag ( PDB  pdb,
TAGID  tagid,
PBYTE  buffer,
DWORD  size 
)

Reads binary data at specified tagid.

Parameters
[in]pdbHandle to the shim database.
[in]tagidTAGID of binary data.
[out]bufferBuffer in which data will be copied.
[in]sizeSize of the buffer.
Returns
TRUE if data was successfully written, or FALSE otherwise.

Definition at line 338 of file sdbread.c.

339{
340 DWORD data_size = 0;
341
343 {
344 SdbpReadData(pdb, &data_size, tagid + sizeof(TAG), sizeof(data_size));
345 if (size >= data_size)
346 return SdbpReadData(pdb, buffer, tagid + sizeof(TAG) + sizeof(data_size), data_size);
347 }
348
349 return FALSE;
350}
#define TAG_TYPE_BINARY
Definition: apphelp.c:44
BOOL WINAPI SdbpCheckTagIDType(PDB pdb, TAGID tagid, WORD type)
Definition: sdbapi.c:261

Referenced by GetSdbGuid(), and SdbGetDatabaseID().

◆ SdbReadDWORDTag()

DWORD WINAPI SdbReadDWORDTag ( PDB  pdb,
TAGID  tagid,
DWORD  ret 
)

Reads DWORD value at specified tagid.

Parameters
[in]pdbHandle to the shim database.
[in]tagidTAGID of DWORD value.
[in]retDefault return value in case function fails.
Returns
Success: DWORD value at specified tagid, otherwise ret.

Definition at line 305 of file sdbread.c.

306{
308 SdbpReadData(pdb, &ret, tagid + 2, sizeof(DWORD));
309 return ret;
310}
#define TAG_TYPE_DWORD
Definition: shimdbg.c:107

Referenced by SdbpAddExeLayers(), SdbpMatchFileAttributes(), SdbQueryDataExTagID(), and SeiGetDWORD().

◆ SdbReadQWORDTag()

QWORD WINAPI SdbReadQWORDTag ( PDB  pdb,
TAGID  tagid,
QWORD  ret 
)

Reads QWORD value at specified tagid.

Parameters
[in]pdbHandle to the shim database.
[in]tagidTAGID of QWORD value.
[in]retDefault return value in case function fails.
Returns
Success: QWORD value at specified tagid, otherwise ret.

Definition at line 321 of file sdbread.c.

322{
324 SdbpReadData(pdb, &ret, tagid + sizeof(TAG), sizeof(QWORD));
325 return ret;
326}
#define TAG_TYPE_QWORD
Definition: shimdbg.c:108
UINT64 QWORD
Definition: shimdbg.c:104

Referenced by SdbpMatchFileAttributes(), and SeiGetQWORD().

◆ SdbRegisterDatabaseEx()

BOOL WINAPI SdbRegisterDatabaseEx ( _In_ LPCWSTR  pszDatabasePath,
_In_ DWORD  dwDatabaseType,
_In_opt_ const PULONGLONG  pTimeStamp 
)

Definition at line 262 of file apphelp.c.

266{
267 PDB pdb;
269 WCHAR GuidBuffer[MAX_GUID_STRING_LEN];
271 ACCESS_MASK KeyAccess;
274 HANDLE InstalledSDBKey;
275
277 if (!pdb)
278 {
279 SHIM_ERR("Unable to open DB %S\n", pszDatabasePath);
280 return FALSE;
281 }
282
285 {
286 SHIM_ERR("Unable to retrieve DB info\n");
288 return FALSE;
289 }
290
291 if (!SdbGUIDToString(&Information.Id, GuidBuffer, RTL_NUMBER_OF(GuidBuffer)))
292 {
293 SHIM_ERR("Unable to Convert GUID to string\n");
296 return FALSE;
297 }
298
301 Status = NtCreateKey(&InstalledSDBKey, KeyAccess, &ObjectKey, 0, NULL, 0, NULL);
302 if (NT_SUCCESS(Status))
303 {
304 HANDLE DbKey;
305
306 RtlInitUnicodeString(&KeyName, GuidBuffer);
307 ObjectKey.RootDirectory = InstalledSDBKey;
308
309 Status = NtCreateKey(&DbKey, KeyAccess, &ObjectKey, 0, NULL, 0, NULL);
310 if (NT_SUCCESS(Status))
311 {
312 UNICODE_STRING DatabasePathKey = RTL_CONSTANT_STRING(L"DatabasePath");
313 UNICODE_STRING DatabaseInstallTimeStampKey = RTL_CONSTANT_STRING(L"DatabaseInstallTimeStamp");
314 UNICODE_STRING DatabaseTypeKey = RTL_CONSTANT_STRING(L"DatabaseType");
315 UNICODE_STRING DatabaseDescriptionKey = RTL_CONSTANT_STRING(L"DatabaseDescription");
316
317 Status = NtSetValueKey(DbKey, &DatabasePathKey, 0, REG_SZ,
319 if (!NT_SUCCESS(Status))
320 SHIM_ERR("Unable to write %wZ\n", &DatabasePathKey);
321
322 if (NT_SUCCESS(Status))
323 {
324 ULARGE_INTEGER ulTimeStamp;
325 if (pTimeStamp)
326 {
327 ulTimeStamp.QuadPart = *pTimeStamp;
328 }
329 else
330 {
331 FILETIME fi;
333 ulTimeStamp.LowPart = fi.dwLowDateTime;
334 ulTimeStamp.HighPart = fi.dwHighDateTime;
335 }
336 Status = NtSetValueKey(DbKey, &DatabaseInstallTimeStampKey, 0, REG_QWORD,
337 &ulTimeStamp.QuadPart, sizeof(ulTimeStamp));
338 if (!NT_SUCCESS(Status))
339 SHIM_ERR("Unable to write %wZ\n", &DatabaseInstallTimeStampKey);
340 }
341
342 if (NT_SUCCESS(Status))
343 {
344 Status = NtSetValueKey(DbKey, &DatabaseTypeKey, 0, REG_DWORD,
346 if (!NT_SUCCESS(Status))
347 SHIM_ERR("Unable to write %wZ\n", &DatabaseTypeKey);
348 }
349
350 if (NT_SUCCESS(Status) && Information.Description)
351 {
352 Status = NtSetValueKey(DbKey, &DatabaseDescriptionKey, 0, REG_SZ,
353 (PVOID)Information.Description, ((ULONG)wcslen(Information.Description) + 1) * sizeof(WCHAR));
354 if (!NT_SUCCESS(Status))
355 SHIM_ERR("Unable to write %wZ\n", &DatabaseDescriptionKey);
356 }
357
358 NtClose(DbKey);
359
360 if (NT_SUCCESS(Status))
361 {
362 SHIM_INFO("Installed %wS as %wZ\n", pszDatabasePath, &KeyName);
363 }
364 }
365 else
366 {
367 SHIM_ERR("Unable to create key %wZ\n", &KeyName);
368 }
369
370 NtClose(InstalledSDBKey);
371 }
372 else
373 {
374 SHIM_ERR("Unable to create key %wZ\n", &KeyName);
375 }
376
379
380 return NT_SUCCESS(Status);
381}
#define RTL_NUMBER_OF(x)
Definition: RtlRegistry.c:12
BOOL WINAPI SdbGetDatabaseInformation(PDB pdb, PDB_INFORMATION information)
Definition: sdbapi.c:502
BOOL WINAPI SdbGUIDToString(CONST GUID *Guid, PWSTR GuidString, SIZE_T Length)
Definition: sdbapi.c:412
VOID WINAPI SdbFreeDatabaseInformation(PDB_INFORMATION information)
Definition: sdbapi.c:527
void WINAPI SdbCloseDatabase(PDB)
Definition: sdbapi.c:373
LONG NTSTATUS
Definition: precomp.h:26
#define DOS_PATH
Definition: db.cpp:32
const UNICODE_STRING InstalledSDBKeyName
Definition: apphelp.c:24
#define MAX_GUID_STRING_LEN
Definition: apphelp.c:29
ACCESS_MASK Wow64QueryFlag(void)
Definition: layer.c:179
VOID WINAPI GetSystemTimeAsFileTime(OUT PFILETIME lpFileTime)
Definition: time.c:128
Status
Definition: gdiplustypes.h:25
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
#define REG_SZ
Definition: layer.c:22
LPCWSTR pszDatabasePath
Definition: env.c:38
NTSYSAPI NTSTATUS NTAPI NtSetValueKey(IN HANDLE KeyHandle, IN PUNICODE_STRING ValueName, IN ULONG TitleIndex OPTIONAL, IN ULONG Type, IN PVOID Data, IN ULONG DataSize)
Definition: ntapi.c:859
ULONG ACCESS_MASK
Definition: nt_native.h:40
#define KEY_QUERY_VALUE
Definition: nt_native.h:1016
#define KEY_ENUMERATE_SUB_KEYS
Definition: nt_native.h:1019
#define KEY_WRITE
Definition: nt_native.h:1031
NTSTATUS NTAPI NtCreateKey(OUT PHANDLE KeyHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes, IN ULONG TitleIndex, IN PUNICODE_STRING Class OPTIONAL, IN ULONG CreateOptions, OUT PULONG Disposition OPTIONAL)
Definition: ntapi.c:240
#define RTL_INIT_OBJECT_ATTRIBUTES(n, a)
DWORD dwDatabaseType
Definition: register.cpp:75
DWORD const PULONGLONG pTimeStamp
Definition: register.cpp:76
DWORD dwHighDateTime
Definition: mapidefs.h:66
DWORD dwLowDateTime
Definition: mapidefs.h:65
HANDLE RootDirectory
Definition: umtypes.h:184
$ULONG LowPart
Definition: ntbasedef.h:569
ULONGLONG QuadPart
Definition: ms-dtyp.idl:185
$ULONG HighPart
Definition: ntbasedef.h:570
#define RTL_CONSTANT_STRING(s)
Definition: tunneltest.c:14
_Must_inspect_result_ _In_ WDFDEVICE _In_ PCUNICODE_STRING KeyName
Definition: wdfdevice.h:2699
_In_ WDFREQUEST _In_ NTSTATUS _In_ ULONG_PTR Information
Definition: wdfrequest.h:1049

Referenced by SdbInstall(), and SdbRegisterDatabase().

◆ SdbReleaseDatabase()

void WINAPI SdbReleaseDatabase ( HSDB  hsdb)

Closes shim database opened by SdbInitDatabase.

Parameters
[in]hsdbHandle to the shim database.

Definition at line 417 of file hsdb.c.

418{
419 if (hsdb)
420 {
421 SdbCloseDatabase(hsdb->pdb);
422 SdbFree(hsdb);
423 }
424}

Referenced by ApphelpCheckRunAppEx(), SdbGetMatchingExe(), SdbInitDatabase(), SdbPackAppCompatData(), SE_InstallBeforeInit(), and SeiGetShimData().

◆ SdbTagIDToTagRef()

BOOL WINAPI SdbTagIDToTagRef ( HSDB  hsdb,
PDB  pdb,
TAGID  tiWhich,
TAGREF ptrWhich 
)

Translates the given trWhich to a specific database / tagid

Parameters
[in]hsdbHandle to the database.
[in]pdbThe Shim database that tiWhich belongs to.
[in]tiWhichPath to executable for which we query database.
[out,opt]ptrWhich The tagid that tiWhich corresponds to.
Returns
TRUE if it succeeds, FALSE if it fails.

Definition at line 669 of file hsdb.c.

670{
671 if (pdb != hsdb->pdb)
672 {
673 SHIM_ERR("Multiple shim databases not yet implemented!\n");
674 if (ptrWhich)
676 return FALSE;
677 }
678
679 if (ptrWhich)
680 *ptrWhich = tiWhich & 0x0fffffff;
681
682 return TRUE;
683}
static PDB TAGID tiWhich
Definition: db.cpp:172
static PDB TAGID TAGREF * ptrWhich
Definition: db.cpp:172
#define TAGREF_NULL
Definition: sdbtypes.h:21

Referenced by SdbGetLayerTagRef(), SdbpAddExeLayers(), SdbpAddExeMatch(), SdbpAddNamedLayerMatch(), SdbQueryDataEx(), and SeiBuildShimRefArray().

◆ SdbTagRefToTagID()

BOOL WINAPI SdbTagRefToTagID ( HSDB  hsdb,
TAGREF  trWhich,
PDB ppdb,
TAGID ptiWhich 
)

Translates the given trWhich to a specific database / tagid

Parameters
[in]hsdbHandle to the database.
[in]trWhichTagref to find
[out,opt]ppdb The Shim database that trWhich belongs to.
[out,opt]ptiWhich The tagid that trWhich corresponds to.
Returns
TRUE if it succeeds, FALSE if it fails.

Definition at line 638 of file hsdb.c.

639{
640 if (trWhich & 0xf0000000)
641 {
642 SHIM_ERR("Multiple shim databases not yet implemented!\n");
643 if (ppdb)
644 *ppdb = NULL;
645 if (ptiWhich)
647 return FALSE;
648 }
649
650 /* There seems to be no range checking on trWhich.. */
651 if (ppdb)
652 *ppdb = hsdb->pdb;
653 if (ptiWhich)
654 *ptiWhich = trWhich & 0x0fffffff;
655
656 return TRUE;
657}
static TAGREF PDB TAGID * ptiWhich
Definition: db.cpp:171
static TAGREF PDB * ppdb
Definition: db.cpp:171

Referenced by SdbQueryDataEx(), SeiBuildGlobalInclExclList(), SeiBuildShimRefArray(), and SeiInit().

◆ SdbTagToString()

LPCWSTR WINAPI SdbTagToString ( TAG  tag)

Converts specified tag into a string.

Parameters
[in]tagThe tag which will be converted to a string.
Returns
Success: Pointer to the string matching specified tag, or L"InvalidTag" on failure.

Definition at line 752 of file sdbapi.c.

753{
754 switch (tag)
755 {
756 case TAG_NULL: return L"NULL";
757
758 /* TAG_TYPE_NULL */
759 case TAG_INCLUDE: return L"INCLUDE";
760 case TAG_GENERAL: return L"GENERAL";
761 case TAG_MATCH_LOGIC_NOT: return L"MATCH_LOGIC_NOT";
762 case TAG_APPLY_ALL_SHIMS: return L"APPLY_ALL_SHIMS";
763 case TAG_USE_SERVICE_PACK_FILES: return L"USE_SERVICE_PACK_FILES";
764 case TAG_MITIGATION_OS: return L"MITIGATION_OS";
765 case TAG_BLOCK_UPGRADE: return L"BLOCK_UPGRADE";
766 case TAG_INCLUDEEXCLUDEDLL: return L"INCLUDEEXCLUDEDLL";
767 case TAG_RAC_EVENT_OFF: return L"RAC_EVENT_OFF";
768 case TAG_TELEMETRY_OFF: return L"TELEMETRY_OFF";
769 case TAG_SHIM_ENGINE_OFF: return L"SHIM_ENGINE_OFF";
770 case TAG_LAYER_PROPAGATION_OFF: return L"LAYER_PROPAGATION_OFF";
771 case TAG_REINSTALL_UPGRADE: return L"REINSTALL_UPGRADE";
772
773 /* TAG_TYPE_WORD */
774 case TAG_MATCH_MODE: return L"MATCH_MODE";
775 case TAG_TAG: return L"TAG";
776 case TAG_INDEX_TAG: return L"INDEX_TAG";
777 case TAG_INDEX_KEY: return L"INDEX_KEY";
778
779 /* TAG_TYPE_DWORD */
780 case TAG_SIZE: return L"SIZE";
781 case TAG_OFFSET: return L"OFFSET";
782 case TAG_CHECKSUM: return L"CHECKSUM";
783 case TAG_SHIM_TAGID: return L"SHIM_TAGID";
784 case TAG_PATCH_TAGID: return L"PATCH_TAGID";
785 case TAG_MODULE_TYPE: return L"MODULE_TYPE";
786 case TAG_VERDATEHI: return L"VERDATEHI";
787 case TAG_VERDATELO: return L"VERDATELO";
788 case TAG_VERFILEOS: return L"VERFILEOS";
789 case TAG_VERFILETYPE: return L"VERFILETYPE";
790 case TAG_PE_CHECKSUM: return L"PE_CHECKSUM";
791 case TAG_PREVOSMAJORVER: return L"PREVOSMAJORVER";
792 case TAG_PREVOSMINORVER: return L"PREVOSMINORVER";
793 case TAG_PREVOSPLATFORMID: return L"PREVOSPLATFORMID";
794 case TAG_PREVOSBUILDNO: return L"PREVOSBUILDNO";
795 case TAG_PROBLEMSEVERITY: return L"PROBLEMSEVERITY";
796 case TAG_LANGID: return L"LANGID";
797 case TAG_VER_LANGUAGE: return L"VER_LANGUAGE";
798 case TAG_ENGINE: return L"ENGINE";
799 case TAG_HTMLHELPID: return L"HTMLHELPID";
800 case TAG_INDEX_FLAGS: return L"INDEX_FLAGS";
801 case TAG_FLAGS: return L"FLAGS";
802 case TAG_DATA_VALUETYPE: return L"DATA_VALUETYPE";
803 case TAG_DATA_DWORD: return L"DATA_DWORD";
804 case TAG_LAYER_TAGID: return L"LAYER_TAGID";
805 case TAG_MSI_TRANSFORM_TAGID: return L"MSI_TRANSFORM_TAGID";
806 case TAG_LINKER_VERSION: return L"LINKER_VERSION";
807 case TAG_LINK_DATE: return L"LINK_DATE";
808 case TAG_UPTO_LINK_DATE: return L"UPTO_LINK_DATE";
809 case TAG_OS_SERVICE_PACK: return L"OS_SERVICE_PACK";
810 case TAG_FLAG_TAGID: return L"FLAG_TAGID";
811 case TAG_RUNTIME_PLATFORM: return L"RUNTIME_PLATFORM";
812 case TAG_OS_SKU: return L"OS_SKU";
813 case TAG_OS_PLATFORM: return L"OS_PLATFORM";
814 case TAG_APP_NAME_RC_ID: return L"APP_NAME_RC_ID";
815 case TAG_VENDOR_NAME_RC_ID: return L"VENDOR_NAME_RC_ID";
816 case TAG_SUMMARY_MSG_RC_ID: return L"SUMMARY_MSG_RC_ID";
817 case TAG_VISTA_SKU: return L"VISTA_SKU";
818 case TAG_DESCRIPTION_RC_ID: return L"DESCRIPTION_RC_ID";
819 case TAG_PARAMETER1_RC_ID: return L"PARAMETER1_RC_ID";
820 case TAG_CONTEXT_TAGID: return L"CONTEXT_TAGID";
821 case TAG_EXE_WRAPPER: return L"EXE_WRAPPER";
822 case TAG_URL_ID: return L"URL_ID";
823 case TAG_TAGID: return L"TAGID";
824
825 /* TAG_TYPE_QWORD */
826 case TAG_TIME: return L"TIME";
827 case TAG_BIN_FILE_VERSION: return L"BIN_FILE_VERSION";
828 case TAG_BIN_PRODUCT_VERSION: return L"BIN_PRODUCT_VERSION";
829 case TAG_MODTIME: return L"MODTIME";
830 case TAG_FLAG_MASK_KERNEL: return L"FLAG_MASK_KERNEL";
831 case TAG_UPTO_BIN_PRODUCT_VERSION: return L"UPTO_BIN_PRODUCT_VERSION";
832 case TAG_DATA_QWORD: return L"DATA_QWORD";
833 case TAG_FLAG_MASK_USER: return L"FLAG_MASK_USER";
834 case TAG_FLAGS_NTVDM1: return L"FLAGS_NTVDM1";
835 case TAG_FLAGS_NTVDM2: return L"FLAGS_NTVDM2";
836 case TAG_FLAGS_NTVDM3: return L"FLAGS_NTVDM3";
837 case TAG_FLAG_MASK_SHELL: return L"FLAG_MASK_SHELL";
838 case TAG_UPTO_BIN_FILE_VERSION: return L"UPTO_BIN_FILE_VERSION";
839 case TAG_FLAG_MASK_FUSION: return L"FLAG_MASK_FUSION";
840 case TAG_FLAG_PROCESSPARAM: return L"FLAG_PROCESSPARAM";
841 case TAG_FLAG_LUA: return L"FLAG_LUA";
842 case TAG_FLAG_INSTALL: return L"FLAG_INSTALL";
843
844 /* TAG_TYPE_STRINGREF */
845 case TAG_NAME: return L"NAME";
846 case TAG_DESCRIPTION: return L"DESCRIPTION";
847 case TAG_MODULE: return L"MODULE";
848 case TAG_API: return L"API";
849 case TAG_VENDOR: return L"VENDOR";
850 case TAG_APP_NAME: return L"APP_NAME";
851 case TAG_COMMAND_LINE: return L"COMMAND_LINE";
852 case TAG_COMPANY_NAME: return L"COMPANY_NAME";
853 case TAG_DLLFILE: return L"DLLFILE";
854 case TAG_WILDCARD_NAME: return L"WILDCARD_NAME";
855 case TAG_PRODUCT_NAME: return L"PRODUCT_NAME";
856 case TAG_PRODUCT_VERSION: return L"PRODUCT_VERSION";
857 case TAG_FILE_DESCRIPTION: return L"FILE_DESCRIPTION";
858 case TAG_FILE_VERSION: return L"FILE_VERSION";
859 case TAG_ORIGINAL_FILENAME: return L"ORIGINAL_FILENAME";
860 case TAG_INTERNAL_NAME: return L"INTERNAL_NAME";
861 case TAG_LEGAL_COPYRIGHT: return L"LEGAL_COPYRIGHT";
862 case TAG_16BIT_DESCRIPTION: return L"16BIT_DESCRIPTION";
863 case TAG_APPHELP_DETAILS: return L"APPHELP_DETAILS";
864 case TAG_LINK_URL: return L"LINK_URL";
865 case TAG_LINK_TEXT: return L"LINK_TEXT";
866 case TAG_APPHELP_TITLE: return L"APPHELP_TITLE";
867 case TAG_APPHELP_CONTACT: return L"APPHELP_CONTACT";
868 case TAG_SXS_MANIFEST: return L"SXS_MANIFEST";
869 case TAG_DATA_STRING: return L"DATA_STRING";
870 case TAG_MSI_TRANSFORM_FILE: return L"MSI_TRANSFORM_FILE";
871 case TAG_16BIT_MODULE_NAME: return L"16BIT_MODULE_NAME";
872 case TAG_LAYER_DISPLAYNAME: return L"LAYER_DISPLAYNAME";
873 case TAG_COMPILER_VERSION: return L"COMPILER_VERSION";
874 case TAG_ACTION_TYPE: return L"ACTION_TYPE";
875 case TAG_EXPORT_NAME: return L"EXPORT_NAME";
876 case TAG_URL: return L"URL";
877
878 /* TAG_TYPE_LIST */
879 case TAG_DATABASE: return L"DATABASE";
880 case TAG_LIBRARY: return L"LIBRARY";
881 case TAG_INEXCLUD: return L"INEXCLUDE";
882 case TAG_SHIM: return L"SHIM";
883 case TAG_PATCH: return L"PATCH";
884 case TAG_APP: return L"APP";
885 case TAG_EXE: return L"EXE";
886 case TAG_MATCHING_FILE: return L"MATCHING_FILE";
887 case TAG_SHIM_REF: return L"SHIM_REF";
888 case TAG_PATCH_REF: return L"PATCH_REF";
889 case TAG_LAYER: return L"LAYER";
890 case TAG_FILE: return L"FILE";
891 case TAG_APPHELP: return L"APPHELP";
892 case TAG_LINK: return L"LINK";
893 case TAG_DATA: return L"DATA";
894 case TAG_MSI_TRANSFORM: return L"MSI_TRANSFORM";
895 case TAG_MSI_TRANSFORM_REF: return L"MSI_TRANSFORM_REF";
896 case TAG_MSI_PACKAGE: return L"MSI_PACKAGE";
897 case TAG_FLAG: return L"FLAG";
898 case TAG_MSI_CUSTOM_ACTION: return L"MSI_CUSTOM_ACTION";
899 case TAG_FLAG_REF: return L"FLAG_REF";
900 case TAG_ACTION: return L"ACTION";
901 case TAG_LOOKUP: return L"LOOKUP";
902 case TAG_CONTEXT: return L"CONTEXT";
903 case TAG_CONTEXT_REF: return L"CONTEXT_REF";
904 case TAG_SPC: return L"SPC";
905 case TAG_STRINGTABLE: return L"STRINGTABLE";
906 case TAG_INDEXES: return L"INDEXES";
907 case TAG_INDEX: return L"INDEX";
908
909 /* TAG_TYPE_STRING */
910 case TAG_STRINGTABLE_ITEM: return L"STRINGTABLE_ITEM";
911
912 /* TAG_TYPE_BINARY */
913 case TAG_PATCH_BITS: return L"PATCH_BITS";
914 case TAG_FILE_BITS: return L"FILE_BITS";
915 case TAG_EXE_ID: return L"EXE_ID";
916 case TAG_DATA_BITS: return L"DATA_BITS";
917 case TAG_MSI_PACKAGE_ID: return L"MSI_PACKAGE_ID";
918 case TAG_DATABASE_ID: return L"DATABASE_ID";
919 case TAG_CONTEXT_PLATFORM_ID: return L"CONTEXT_PLATFORM_ID";
920 case TAG_CONTEXT_BRANCH_ID: return L"CONTEXT_BRANCH_ID";
921 case TAG_FIX_ID: return L"FIX_ID";
922 case TAG_APP_ID: return L"APP_ID";
923 case TAG_INDEX_BITS: return L"INDEX_BITS";
924
925 break;
926 }
927 return L"InvalidTag";
928}
#define TAG_MODULE
Definition: db.cpp:99
#define TAG_LAYER
Definition: db.cpp:90
#define TAG_INEXCLUD
Definition: db.cpp:86
#define TAG_APP_NAME_RC_ID
Definition: db.cpp:73
#define TAG_APP_NAME
Definition: db.cpp:101
#define TAG_HTMLHELPID
Definition: db.cpp:67
#define TAG_SUMMARY_MSG_RC_ID
Definition: db.cpp:75
#define TAG_WILDCARD_NAME
Definition: db.cpp:104
#define TAG_VENDOR
Definition: db.cpp:100
#define TAG_COMMAND_LINE
Definition: db.cpp:102
#define TAG_MATCHING_FILE
Definition: db.cpp:88
#define TAG_PROBLEMSEVERITY
Definition: db.cpp:66
#define TAG_LAYER_TAGID
Definition: db.cpp:69
#define TAG_FLAG_LUA
Definition: db.cpp:83
#define TAG_COMPILER_VERSION
Definition: db.cpp:116
#define TAG_APPHELP_DETAILS
Definition: db.cpp:112
#define TAG_INCLUDE
Definition: db.cpp:56
#define TAG_OS_PLATFORM
Definition: db.cpp:76
#define TAG_MATCH_MODE
Definition: db.cpp:58
#define TAG_APPHELP
Definition: db.cpp:91
#define TAG_LINK
Definition: db.cpp:92
#define TAG_VENDOR_NAME_RC_ID
Definition: db.cpp:74
#define TAG_APPHELP_TITLE
Definition: db.cpp:114
#define TAG_EXE_ID
Definition: db.cpp:120
#define TAG_SHIM_REF
Definition: db.cpp:89
#define TAG_LINK_URL
Definition: db.cpp:113
#define TAG_FLAGS
Definition: db.cpp:68
#define TAG_GENERAL
Definition: db.cpp:118
#define TAG_STRINGTABLE_ITEM
Definition: db.cpp:96
#define TAG_DATA_BITS
Definition: db.cpp:121
#define TAG_TIME
Definition: db.cpp:78
#define TAG_UPTO_BIN_FILE_VERSION
Definition: apphelp.c:62
#define TAG_VERFILETYPE
Definition: apphelp.c:52
#define TAG_BIN_FILE_VERSION
Definition: apphelp.c:59
#define TAG_VERFILEOS
Definition: apphelp.c:51
#define TAG_VERDATEHI
Definition: apphelp.c:49
#define TAG_UPTO_BIN_PRODUCT_VERSION
Definition: apphelp.c:61
#define TAG_VERDATELO
Definition: apphelp.c:50
#define TAG_BIN_PRODUCT_VERSION
Definition: apphelp.c:60
#define TAG_LOOKUP
Definition: sdbtagid.h:185
#define TAG_FLAG_REF
Definition: sdbtagid.h:183
#define TAG_SXS_MANIFEST
Definition: sdbtagid.h:152
#define TAG_INDEX_TAG
Definition: sdbtagid.h:60
#define TAG_FIX_ID
Definition: sdbtagid.h:205
#define TAG_VISTA_SKU
Definition: sdbtagid.h:101
#define TAG_PATCH_BITS
Definition: sdbtagid.h:197
#define TAG_LANGID
Definition: sdbtagid.h:80
#define TAG_MSI_TRANSFORM_REF
Definition: sdbtagid.h:179
#define TAG_OS_SKU
Definition: sdbtagid.h:96
#define TAG_DESCRIPTION_RC_ID
Definition: sdbtagid.h:102
#define TAG_MODTIME
Definition: sdbtagid.h:113
#define TAG_INDEXES
Definition: sdbtagid.h:190
#define TAG_TAGID
Definition: sdbtagid.h:107
#define TAG_INDEX
Definition: sdbtagid.h:191
#define TAG_MSI_PACKAGE
Definition: sdbtagid.h:180
#define TAG_FLAG_MASK_SHELL
Definition: sdbtagid.h:121
#define TAG_SHIM_ENGINE_OFF
Definition: sdbtagid.h:51
#define TAG_CONTEXT_PLATFORM_ID
Definition: sdbtagid.h:203
#define TAG_FLAG_PROCESSPARAM
Definition: sdbtagid.h:124
#define TAG_FLAG_INSTALL
Definition: sdbtagid.h:126
#define TAG_SHIM_TAGID
Definition: sdbtagid.h:67
#define TAG_TELEMETRY_OFF
Definition: sdbtagid.h:50
#define TAG_API
Definition: sdbtagid.h:132
#define TAG_APPLY_ALL_SHIMS
Definition: sdbtagid.h:44
#define TAG_PREVOSMINORVER
Definition: sdbtagid.h:76
#define TAG_USE_SERVICE_PACK_FILES
Definition: sdbtagid.h:45
#define TAG_LIBRARY
Definition: sdbtagid.h:164
#define TAG_APP_ID
Definition: sdbtagid.h:206
#define TAG_DESCRIPTION
Definition: sdbtagid.h:130
#define TAG_ACTION
Definition: sdbtagid.h:184
#define TAG_INDEX_KEY
Definition: sdbtagid.h:61
#define TAG_URL_ID
Definition: sdbtagid.h:106
#define TAG_CONTEXT_BRANCH_ID
Definition: sdbtagid.h:204
#define TAG_LAYER_PROPAGATION_OFF
Definition: sdbtagid.h:52
#define TAG_INCLUDEEXCLUDEDLL
Definition: sdbtagid.h:48
#define TAG_MATCH_LOGIC_NOT
Definition: sdbtagid.h:43
#define TAG_MITIGATION_OS
Definition: sdbtagid.h:46
#define TAG_OFFSET
Definition: sdbtagid.h:65
#define TAG_OS_SERVICE_PACK
Definition: sdbtagid.h:93
#define TAG_TAG
Definition: sdbtagid.h:59
#define TAG_PATCH_TAGID
Definition: sdbtagid.h:68
#define TAG_FILE_BITS
Definition: sdbtagid.h:198
#define TAG_RUNTIME_PLATFORM
Definition: sdbtagid.h:95
#define TAG_CONTEXT_TAGID
Definition: sdbtagid.h:104
#define TAG_INDEX_FLAGS
Definition: sdbtagid.h:84
#define TAG_FLAG_MASK_KERNEL
Definition: sdbtagid.h:114
#define TAG_PATCH_REF
Definition: sdbtagid.h:172
#define TAG_PARAMETER1_RC_ID
Definition: sdbtagid.h:103
#define TAG_APP
Definition: sdbtagid.h:168
#define TAG_PREVOSMAJORVER
Definition: sdbtagid.h:75
#define TAG_PATCH
Definition: sdbtagid.h:167
#define TAG_FLAG_MASK_USER
Definition: sdbtagid.h:117
#define TAG_FLAGS_NTVDM3
Definition: sdbtagid.h:120
#define TAG_MSI_TRANSFORM
Definition: sdbtagid.h:178
#define TAG_FLAGS_NTVDM1
Definition: sdbtagid.h:118
#define TAG_PREVOSBUILDNO
Definition: sdbtagid.h:78
#define TAG_PREVOSPLATFORMID
Definition: sdbtagid.h:77
#define TAG_REINSTALL_UPGRADE
Definition: sdbtagid.h:53
#define TAG_FLAGS_NTVDM2
Definition: sdbtagid.h:119
#define TAG_MSI_TRANSFORM_TAGID
Definition: sdbtagid.h:89
#define TAG_CONTEXT_REF
Definition: sdbtagid.h:187
#define TAG_INDEX_BITS
Definition: sdbtagid.h:207
#define TAG_FLAG_TAGID
Definition: sdbtagid.h:94
#define TAG_MSI_CUSTOM_ACTION
Definition: sdbtagid.h:182
#define TAG_RAC_EVENT_OFF
Definition: sdbtagid.h:49
#define TAG_FLAG_MASK_FUSION
Definition: sdbtagid.h:123
#define TAG_MSI_PACKAGE_ID
Definition: sdbtagid.h:201
#define TAG_URL
Definition: sdbtagid.h:160
#define TAG_SPC
Definition: sdbtagid.h:188
#define TAG_CONTEXT
Definition: sdbtagid.h:186
#define TAG_ACTION_TYPE
Definition: sdbtagid.h:158
#define TAG_FLAG
Definition: sdbtagid.h:181
#define TAG_APPHELP_CONTACT
Definition: sdbtagid.h:151
#define TAG_ENGINE
Definition: sdbtagid.h:82
#define TAG_LAYER_DISPLAYNAME
Definition: sdbtagid.h:156
#define TAG_BLOCK_UPGRADE
Definition: sdbtagid.h:47
#define TAG_MSI_TRANSFORM_FILE
Definition: sdbtagid.h:154
#define TAG_FILE
Definition: sdbtagid.h:174
#define TAG_DLLFILE
Definition: sdbtagid.h:137
#define TAG_LINK_TEXT
Definition: sdbtagid.h:149
#define TAG_SHIM
Definition: tag.h:138

Referenced by InitApphelp(), SdbpMatchFileAttributes(), and START_TEST().

◆ SdbUnpackAppCompatData()

BOOL WINAPI SdbUnpackAppCompatData ( HSDB  hsdb,
LPCWSTR  pszImageName,
PVOID  pData,
PSDBQUERYRESULT  pQueryResult 
)

Definition at line 761 of file hsdb.c.

762{
763 ShimData* pShimData = pData;
764
765 if (!pShimData || pShimData->dwMagic != SHIMDATA_MAGIC || pShimData->dwSize < sizeof(ShimData))
766 return FALSE;
767
768 if (!pQueryResult)
769 return FALSE;
770
771 /* szLayer? */
772
773 *pQueryResult = pShimData->Query;
774 return TRUE;
775}
#define SHIMDATA_MAGIC
Definition: hsdb.c:31
LPCWSTR LPCWSTR LPCWSTR DWORD PSDBQUERYRESULT_VISTA pQueryResult
Definition: env.c:37
Definition: hsdb.c:22
SDBQUERYRESULT Query
Definition: hsdb.c:26
DWORD dwSize
Definition: hsdb.c:24
DWORD dwMagic
Definition: hsdb.c:25
TW_UINT32 TW_UINT16 TW_UINT16 TW_MEMREF pData
Definition: twain.h:1830

Referenced by SeiGetShimData().

◆ SdbUnregisterDatabase()

BOOL WINAPI SdbUnregisterDatabase ( _In_ const GUID pguidDB)

Definition at line 407 of file apphelp.c.

408{
409 WCHAR KeyBuffer[MAX_PATH], GuidBuffer[MAX_GUID_STRING_LEN];
411 ACCESS_MASK KeyAccess;
414 HANDLE DbKey;
415
416 if (!SdbGUIDToString(pguidDB, GuidBuffer, RTL_NUMBER_OF(GuidBuffer)))
417 {
418 SHIM_ERR("Unable to Convert GUID to string\n");
419 return FALSE;
420 }
421
422 RtlInitEmptyUnicodeString(&KeyName, KeyBuffer, sizeof(KeyBuffer));
425 RtlAppendUnicodeToString(&KeyName, GuidBuffer);
426
427 KeyAccess = Wow64QueryFlag() | DELETE;
428 Status = NtCreateKey(&DbKey, KeyAccess, &ObjectKey, 0, NULL, 0, NULL);
429 if (!NT_SUCCESS(Status))
430 {
431 SHIM_ERR("Unable to open %wZ\n", &KeyName);
432 return FALSE;
433 }
434
435 Status = NtDeleteKey(DbKey);
436 if (!NT_SUCCESS(Status))
437 SHIM_ERR("Unable to delete %wZ\n", &KeyName);
438
439 NtClose(DbKey);
440 return NT_SUCCESS(Status);
441}
NTSTATUS RtlAppendUnicodeToString(IN PUNICODE_STRING Str1, IN PWSTR Str2)
Definition: string_lib.cpp:62
NTSYSAPI NTSTATUS NTAPI RtlAppendUnicodeStringToString(PUNICODE_STRING Destination, PUNICODE_STRING Source)
#define DELETE
Definition: nt_native.h:57
NTSTATUS NTAPI NtDeleteKey(IN HANDLE KeyHandle)
Definition: ntapi.c:408

Referenced by SdbUninstall().

◆ SetPermLayerState()

BOOL WINAPI SetPermLayerState ( PCWSTR  wszPath,
PCWSTR  wszLayer,
DWORD  dwFlags,
BOOL  bMachine,
BOOL  bEnable 
)

Adds or removes a single layer entry.

Parameters
[in]wszPathFull pathname of the file.
[in]wszLayerThe layer to add or remove.
[in]dwFlagsAdditional flags to add / remove [LAYER_APPLY_TO_SYSTEM_EXES | ???].
[in]bMachineWhen TRUE, the setting applies to all users, when FALSE only applies to the current user.
[in]bEnableTRUE to enable, FALSE to disable a layer / flag specified.
Returns
TRUE if it succeeds, FALSE if it fails.

Definition at line 467 of file layer.c.

468{
469 WCHAR fullLayer[MAX_LAYER_LENGTH] = { 0 };
470 WCHAR newLayer[MAX_LAYER_LENGTH] = { 0 };
471 DWORD dwBytes = sizeof(fullLayer), dwWriteFlags = 0;
472 PWSTR start, p;
473
474 if (!wszLayer)
475 {
476 SHIM_ERR("Invalid argument\n");
477 return FALSE;
478 }
480 {
481 SHIM_ERR("Invalid flags\n");
482 return FALSE;
483 }
485 if (p)
486 {
487 switch (*p)
488 {
489 case ' ':
490 SHIM_ERR("Only one layer can be passed in at a time.\n");
491 return FALSE;
492 case '#':
493 case '!':
494 SHIM_ERR("Flags cannot be passed in with the layer name.\n");
495 return FALSE;
496 }
497 }
498 if (!SdbGetPermLayerKeys(wszPath, fullLayer, &dwBytes, bMachine ? GPLK_MACHINE : GPLK_USER))
499 {
500 fullLayer[0] = '\0';
501 dwBytes = sizeof(fullLayer);
502 }
503
504 start = fullLayer;
505 while (*start == '!' || *start == '#' || *start == ' ' || *start == '\t')
506 {
507 if (*start == '#')
508 dwWriteFlags |= LAYER_APPLY_TO_SYSTEM_EXES;
509 else if (*start == '!')
510 dwWriteFlags |= LAYER_UNK_FLAG2;
511 start++;
512 }
513 if (bEnable)
514 dwWriteFlags |= dwFlags;
515 else
516 dwWriteFlags &= ~dwFlags;
517
518 p = newLayer;
519 if (dwWriteFlags & LAYER_UNK_FLAG2)
520 *(p++) = '!';
521 if (dwWriteFlags & LAYER_APPLY_TO_SYSTEM_EXES)
522 *(p++) = '#';
523
524 do
525 {
526 while (*start == ' ' || *start == '\t')
527 ++start;
528
529 if (*start == '\0')
530 break;
533 {
534 SdbpAppendLayer(newLayer, sizeof(newLayer), start, p);
535 }
536 start = p + 1;
537 } while (p);
538
539 if (bEnable && wszLayer[0])
540 {
541 SdbpAppendLayer(newLayer, sizeof(newLayer), wszLayer, NULL);
542 }
543
544 return SdbSetPermLayerKeys(wszPath, newLayer, bMachine);
545}
GLuint start
Definition: gl.h:1545
GLfloat GLfloat p
Definition: glext.h:8902
BOOL WINAPI SdbSetPermLayerKeys(PCWSTR wszPath, PCWSTR wszLayers, BOOL bMachine)
Definition: layer.c:425
#define LAYER_UNK_FLAG2
Definition: layer.c:19
#define LAYER_APPLY_TO_SYSTEM_EXES
Definition: layer.c:18
BOOL SdbpMatchLayer(PCWSTR start, PCWSTR end, PCWSTR compare)
Definition: layer.c:286
#define LAYER_SEPARATORS
Definition: layer.c:38
BOOL SdbpAppendLayer(PWSTR target, DWORD len, PCWSTR layer, PCWSTR end)
Definition: layer.c:295
#define MAX_LAYER_LENGTH
Definition: layer.c:17
BOOL WINAPI SdbGetPermLayerKeys(PCWSTR wszPath, PWSTR pwszLayers, PDWORD pdwBytes, DWORD dwFlags)
Definition: layer.c:364
#define DISALLOWED_LAYER_CHARS
Definition: layer.c:37
static PCWSTR BOOL bMachine
Definition: layerapi.c:34
static PCWSTR wszLayer
Definition: layerapi.c:36
_Check_return_ _CRTIMP _CONST_RETURN wchar_t *__cdecl wcspbrk(_In_z_ const wchar_t *_Str, _In_z_ const wchar_t *_Control)
_In_ BOOL bEnable
Definition: winddi.h:3426

Referenced by CLayerUIPropPage::OnApply().