ReactOS 0.4.15-dev-7674-gc0b4db1
hsdb.c File Reference
#include "windows.h"
#include "ntndk.h"
#include "strsafe.h"
#include "apphelp.h"
#include "compat_undoc.h"
Include dependency graph for hsdb.c:

Go to the source code of this file.

Classes

struct  _ShimData
 

Macros

#define WIN32_NO_STATUS
 
#define MAX_LAYER_LENGTH   256
 
#define GPLK_USER   1
 
#define GPLK_MACHINE   2
 
#define SHIMDATA_MAGIC   0xAC0DEDAB
 
#define REACTOS_COMPATVERSION_IGNOREMANIFEST   0xffffffff
 

Typedefs

typedef struct _ShimData ShimData
 

Functions

 C_ASSERT (SHIMDATA_MAGIC==REACTOS_SHIMDATA_MAGIC)
 
 C_ASSERT (sizeof(ShimData)==sizeof(ReactOS_ShimData))
 
 C_ASSERT (offsetof(ShimData, dwMagic)==offsetof(ReactOS_ShimData, dwMagic))
 
 C_ASSERT (offsetof(ShimData, dwRosProcessCompatVersion)==offsetof(ReactOS_ShimData, dwRosProcessCompatVersion))
 
static BOOL WINAPI SdbpFileExists (LPCWSTR path)
 
static BOOL SdbpMatchFileAttributes (PDB pdb, TAGID matching_file, PATTRINFO attribs, DWORD attr_count)
 
static BOOL WINAPI SdbpMatchExe (PDB pdb, TAGID exe, const WCHAR *dir, PATTRINFO main_attribs, DWORD main_attr_count)
 
static void SdbpAddDatabaseGuid (PDB pdb, PSDBQUERYRESULT result)
 
static BOOL SdbpAddSingleLayerMatch (TAGREF layer, PSDBQUERYRESULT result)
 
static BOOL SdbpAddNamedLayerMatch (HSDB hsdb, PCWSTR layerName, PSDBQUERYRESULT result)
 
static void SdbpAddExeLayers (HSDB hsdb, PDB pdb, TAGID tagExe, PSDBQUERYRESULT result)
 
static void SdbpAddExeMatch (HSDB hsdb, PDB pdb, TAGID tagExe, PSDBQUERYRESULT result)
 
static ULONG SdbpAddLayerMatches (HSDB hsdb, PWSTR pwszLayers, DWORD pdwBytes, PSDBQUERYRESULT result)
 
static BOOL SdbpPropagateEnvLayers (HSDB hsdb, LPWSTR Environment, PSDBQUERYRESULT Result)
 
HSDB WINAPI SdbInitDatabase (DWORD flags, LPCWSTR path)
 
void WINAPI SdbReleaseDatabase (HSDB hsdb)
 
BOOL WINAPI SdbGetMatchingExe (HSDB hsdb, LPCWSTR path, LPCWSTR module_name, LPCWSTR env, DWORD flags, PSDBQUERYRESULT result)
 
HRESULT WINAPI SdbGetAppPatchDir (HSDB hsdb, LPWSTR path, DWORD size)
 
BOOL WINAPI SdbTagRefToTagID (HSDB hsdb, TAGREF trWhich, PDB *ppdb, TAGID *ptiWhich)
 
BOOL WINAPI SdbTagIDToTagRef (HSDB hsdb, PDB pdb, TAGID tiWhich, TAGREF *ptrWhich)
 
BOOL WINAPI SdbPackAppCompatData (HSDB hsdb, PSDBQUERYRESULT pQueryResult, PVOID *ppData, DWORD *pdwSize)
 
BOOL WINAPI SdbUnpackAppCompatData (HSDB hsdb, LPCWSTR pszImageName, PVOID pData, PSDBQUERYRESULT pQueryResult)
 
DWORD WINAPI SdbGetAppCompatDataSize (ShimData *pData)
 
DWORD WINAPI SdbQueryDataEx (HSDB hsdb, TAGREF trWhich, LPCWSTR lpszDataName, LPDWORD lpdwDataType, LPVOID lpBuffer, LPDWORD lpcbBufferSize, TAGREF *ptrData)
 
DWORD WINAPI SdbQueryData (HSDB hsdb, TAGREF trWhich, LPCWSTR lpszDataName, LPDWORD lpdwDataType, LPVOID lpBuffer, LPDWORD lpcbBufferSize)
 

Macro Definition Documentation

◆ GPLK_MACHINE

#define GPLK_MACHINE   2

Definition at line 19 of file hsdb.c.

◆ GPLK_USER

#define GPLK_USER   1

Definition at line 18 of file hsdb.c.

◆ MAX_LAYER_LENGTH

#define MAX_LAYER_LENGTH   256

Definition at line 17 of file hsdb.c.

◆ REACTOS_COMPATVERSION_IGNOREMANIFEST

#define REACTOS_COMPATVERSION_IGNOREMANIFEST   0xffffffff

Definition at line 32 of file hsdb.c.

◆ SHIMDATA_MAGIC

#define SHIMDATA_MAGIC   0xAC0DEDAB

Definition at line 31 of file hsdb.c.

◆ WIN32_NO_STATUS

#define WIN32_NO_STATUS

Definition at line 10 of file hsdb.c.

Typedef Documentation

◆ ShimData

Function Documentation

◆ C_ASSERT() [1/4]

C_ASSERT ( offsetof(ShimData, dwMagic)  = =offsetof(ReactOS_ShimData, dwMagic))

◆ C_ASSERT() [2/4]

C_ASSERT ( offsetof(ShimData, dwRosProcessCompatVersion)  = =offsetof(ReactOS_ShimData, dwRosProcessCompatVersion))

◆ C_ASSERT() [3/4]

◆ C_ASSERT() [4/4]

C_ASSERT ( sizeof(ShimData = =sizeof(ReactOS_ShimData))

◆ SdbGetAppCompatDataSize()

DWORD WINAPI SdbGetAppCompatDataSize ( ShimData pData)

Definition at line 777 of file hsdb.c.

778{
779 if (!pData || pData->dwMagic != SHIMDATA_MAGIC)
780 return 0;
781
782 return pData->dwSize;
783}
#define SHIMDATA_MAGIC
Definition: hsdb.c:31
TW_UINT32 TW_UINT16 TW_UINT16 TW_MEMREF pData
Definition: twain.h:1830

◆ 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
#define SdbFree(mem)
Definition: sdbpapi.h:37
#define SHIM_ERR(fmt,...)
Definition: sdbpapi.h:76
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
__wchar_t WCHAR
Definition: xmlstorage.h:180

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

◆ 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
TAGID WINAPI SdbFindFirstTag(PDB pdb, TAGID parent, TAG tag)
Definition: sdbread.c:208
#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
TAGID WINAPI SdbFindNextTag(PDB pdb, TAGID parent, TAGID prev_child)
Definition: sdbread.c:231
BOOL WINAPI SdbGetFileAttributes(LPCWSTR path, PATTRINFO *attr_info_ret, LPDWORD attr_count)
Definition: sdbfileattr.c:239
#define SHIMREG_HAS_ENVIRONMENT
Definition: apphelp.h:59
LPWSTR WINAPI SdbGetStringTagPtr(PDB pdb, TAGID tagid)
Definition: sdbread.c:375
DWORD TAGID
static PDB pdb
Definition: db.cpp:172
#define TAG_EXE
Definition: db.cpp:87
#define TAGID_NULL
Definition: db.cpp:38
#define TAGID_ROOT
Definition: db.cpp:39
static LPCWSTR LPCWSTR LPCWSTR env
Definition: db.cpp:170
#define TAG_DATABASE
Definition: db.cpp:85
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define wcsrchr
Definition: compat.h:16
#define MAX_PATH
Definition: compat.h:34
#define wcsicmp
Definition: compat.h:15
static const WCHAR Cleanup[]
Definition: register.c:80
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
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
if(dx< 0)
Definition: linetemp.h:194
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
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:2451
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
#define L(x)
Definition: ntvdm.h:50
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
Definition: name.c:39
uint16_t * PWSTR
Definition: typedefs.h:56
unsigned char * PUCHAR
Definition: typedefs.h:53
uint32_t ULONG
Definition: typedefs.h:59
#define TAG_NAME
Definition: vfat.h:553
int ret
#define ZeroMemory
Definition: winbase.h:1712
WCHAR * LPWSTR
Definition: xmlstorage.h:184

Referenced by ApphelpCheckRunAppEx().

◆ 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:68
Definition: apphelp.h:30
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185

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

◆ SdbPackAppCompatData()

BOOL WINAPI SdbPackAppCompatData ( HSDB  hsdb,
PSDBQUERYRESULT  pQueryResult,
PVOID ppData,
DWORD pdwSize 
)

Definition at line 687 of file hsdb.c.

688{
690 HRESULT hr;
691 DWORD n;
692 BOOL bCloseDatabase = FALSE;
693
694 if (!pQueryResult || !ppData || !pdwSize)
695 {
696 SHIM_WARN("Invalid params: %p, %p, %p\n", pQueryResult, ppData, pdwSize);
697 return FALSE;
698 }
699
700 pData = RtlAllocateHeap(RtlGetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(ShimData));
701 if (!pData)
702 {
703 SHIM_WARN("Unable to allocate %d bytes\n", sizeof(ShimData));
704 return FALSE;
705 }
706
707 GetSystemWindowsDirectoryW(pData->szModule, _countof(pData->szModule));
708 hr = StringCchCatW(pData->szModule, _countof(pData->szModule), L"\\system32\\apphelp.dll");
709 if (!SUCCEEDED(hr))
710 {
711 SHIM_ERR("Unable to append module name (0x%x)\n", hr);
712 RtlFreeHeap(RtlGetProcessHeap(), 0, pData);
713 return FALSE;
714 }
715
716 pData->dwSize = sizeof(*pData);
717 pData->dwMagic = SHIMDATA_MAGIC;
718 pData->Query = *pQueryResult;
719 pData->dwRosProcessCompatVersion = 0;
720 pData->szLayer[0] = UNICODE_NULL; /* TODO */
721
722 SHIM_INFO("\ndwFlags 0x%x\ndwMagic 0x%x\ntrExe 0x%x\ntrLayer 0x%x\n",
723 pData->Query.dwFlags, pData->dwMagic, pData->Query.atrExes[0], pData->Query.atrLayers[0]);
724
725 /* Database List */
726 /* 0x0 {GUID} NAME: Use to open HSDB */
727 if (hsdb == NULL)
728 {
730 bCloseDatabase = TRUE;
731 }
732
733 for (n = 0; n < pQueryResult->dwLayerCount; ++n)
734 {
735 DWORD dwValue = 0, dwType;
736 DWORD dwValueSize = sizeof(dwValue);
737 SHIM_INFO("Layer 0x%x\n", pQueryResult->atrLayers[n]);
738
739 if (SdbQueryData(hsdb, pQueryResult->atrLayers[n], L"SHIMVERSIONNT", &dwType, &dwValue, &dwValueSize) == ERROR_SUCCESS &&
740 dwType == REG_DWORD && dwValueSize == sizeof(dwValue))
741 {
743 dwValue = (dwValue % 100) | ((dwValue / 100) << 8);
744 if (dwValue > pData->dwRosProcessCompatVersion)
745 pData->dwRosProcessCompatVersion = dwValue;
746 }
747 }
748
749 if (pData->dwRosProcessCompatVersion)
750 SHIM_INFO("Setting ProcessCompatVersion 0x%x\n", pData->dwRosProcessCompatVersion);
751
752 if (bCloseDatabase)
753 SdbReleaseDatabase(hsdb);
754
755 *ppData = pData;
756 *pdwSize = pData->dwSize;
757
758 return TRUE;
759}
PVOID NTAPI RtlAllocateHeap(IN PVOID HeapHandle, IN ULONG Flags, IN SIZE_T Size)
Definition: heap.c:588
BOOLEAN NTAPI RtlFreeHeap(IN PVOID HeapHandle, IN ULONG Flags, IN PVOID HeapBase)
Definition: heap.c:606
#define ERROR_SUCCESS
Definition: deptool.c:10
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
GLdouble n
Definition: glext.h:7729
#define REACTOS_COMPATVERSION_IGNOREMANIFEST
Definition: hsdb.c:32
DWORD WINAPI SdbQueryData(HSDB hsdb, TAGREF trWhich, LPCWSTR lpszDataName, LPDWORD lpdwDataType, LPVOID lpBuffer, LPDWORD lpcbBufferSize)
Definition: hsdb.c:832
LPCWSTR LPCWSTR LPCWSTR DWORD PSDBQUERYRESULT_VISTA pQueryResult
Definition: env.c:37
PSDBQUERYRESULT_VISTA PVOID * ppData
Definition: env.c:56
#define REG_DWORD
Definition: sdbapi.c:596
#define SHIM_INFO(fmt,...)
Definition: sdbpapi.h:78
#define SHIM_WARN(fmt,...)
Definition: sdbpapi.h:77
Definition: hsdb.c:22
TAGREF atrLayers[SDB_MAX_LAYERS]

◆ SdbpAddDatabaseGuid()

static void SdbpAddDatabaseGuid ( PDB  pdb,
PSDBQUERYRESULT  result 
)
static

Definition at line 183 of file hsdb.c.

184{
185 size_t n;
186
187 for (n = 0; n < _countof(result->rgGuidDB); ++n)
188 {
189 if (!memcmp(&result->rgGuidDB[n], &pdb->database_id, sizeof(pdb->database_id)))
190 return;
191
192 if (result->dwCustomSDBMap & (1<<n))
193 continue;
194
195 memcpy(&result->rgGuidDB[n], &pdb->database_id, sizeof(result->rgGuidDB[n]));
196 result->dwCustomSDBMap |= (1<<n);
197 return;
198 }
199}
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112

Referenced by SdbpAddExeMatch(), and SdbpAddNamedLayerMatch().

◆ SdbpAddExeLayers()

static void SdbpAddExeLayers ( HSDB  hsdb,
PDB  pdb,
TAGID  tagExe,
PSDBQUERYRESULT  result 
)
static

Definition at line 247 of file hsdb.c.

248{
250
251 while (layer != TAGID_NULL)
252 {
253 TAGREF tr;
255 DWORD tagId = SdbReadDWORDTag(pdb, layerIdTag, TAGID_NULL);
256
257 if (layerIdTag != TAGID_NULL &&
258 tagId != TAGID_NULL &&
259 SdbTagIDToTagRef(hsdb, pdb, tagId, &tr))
260 {
262 }
263 else
264 {
265 /* Try a name lookup */
266 TAGID layerTag = SdbFindFirstTag(pdb, layer, TAG_NAME);
267 if (layerTag != TAGID_NULL)
268 {
270 if (layerName)
271 {
273 }
274 }
275 }
276
277 layer = SdbFindNextTag(pdb, tagExe, layer);
278 }
279}
DWORD WINAPI SdbReadDWORDTag(PDB pdb, TAGID tagid, DWORD ret)
Definition: sdbread.c:305
DWORD TAGREF
#define TAG_LAYER
Definition: db.cpp:90
static LPCWSTR layerName
Definition: db.cpp:173
#define TAG_LAYER_TAGID
Definition: db.cpp:69
GLenum GLuint GLint GLint layer
Definition: glext.h:7007
static BOOL SdbpAddNamedLayerMatch(HSDB hsdb, PCWSTR layerName, PSDBQUERYRESULT result)
Definition: hsdb.c:222
static BOOL SdbpAddSingleLayerMatch(TAGREF layer, PSDBQUERYRESULT result)
Definition: hsdb.c:202
BOOL WINAPI SdbTagIDToTagRef(HSDB hsdb, PDB pdb, TAGID tiWhich, TAGREF *ptrWhich)
Definition: hsdb.c:669

Referenced by SdbpAddExeMatch().

◆ SdbpAddExeMatch()

static void SdbpAddExeMatch ( HSDB  hsdb,
PDB  pdb,
TAGID  tagExe,
PSDBQUERYRESULT  result 
)
static

Definition at line 282 of file hsdb.c.

283{
284 size_t n;
285 TAGREF tr;
286
287 if (!SdbTagIDToTagRef(hsdb, pdb, tagExe, &tr))
288 return;
289
290 for (n = 0; n < result->dwExeCount; ++n)
291 {
292 if (result->atrExes[n] == tr)
293 return;
294 }
295
296 if (n >= _countof(result->atrExes))
297 return;
298
299 result->atrExes[n] = tr;
300 result->dwExeCount++;
301
302 SdbpAddExeLayers(hsdb, pdb, tagExe, result);
303
305}
static void SdbpAddDatabaseGuid(PDB pdb, PSDBQUERYRESULT result)
Definition: hsdb.c:183
static void SdbpAddExeLayers(HSDB hsdb, PDB pdb, TAGID tagExe, PSDBQUERYRESULT result)
Definition: hsdb.c:247

Referenced by SdbGetMatchingExe().

◆ SdbpAddLayerMatches()

static ULONG SdbpAddLayerMatches ( HSDB  hsdb,
PWSTR  pwszLayers,
DWORD  pdwBytes,
PSDBQUERYRESULT  result 
)
static

Definition at line 308 of file hsdb.c.

309{
311 ULONG Added = 0;
312
313 const PWSTR end = pwszLayers + (pdwBytes / sizeof(WCHAR));
314 while (start < end && (*start == L'!' || *start == L'#' || *start == L' ' || *start == L'\t'))
315 start++;
316
317 if (start == end)
318 return 0;
319
320 do
321 {
322 while (*start == L' ' || *start == L'\t')
323 ++start;
324
325 if (*start == UNICODE_NULL)
326 break;
327 p = wcspbrk(start, L" \t");
328
329 if (p)
330 *p = UNICODE_NULL;
331
333 Added++;
334
335 start = p + 1;
336 } while (start < end && p);
337
338 return Added;
339}
GLuint start
Definition: gl.h:1545
GLuint GLuint end
Definition: gl.h:1545
GLfloat GLfloat p
Definition: glext.h:8902
static PWSTR PDWORD pdwBytes
Definition: layerapi.c:35
static PWSTR pwszLayers
Definition: layerapi.c:35
_Check_return_ _CRTIMP _CONST_RETURN wchar_t *__cdecl wcspbrk(_In_z_ const wchar_t *_Str, _In_z_ const wchar_t *_Control)

Referenced by SdbGetMatchingExe(), and SdbpPropagateEnvLayers().

◆ SdbpAddNamedLayerMatch()

static BOOL SdbpAddNamedLayerMatch ( HSDB  hsdb,
PCWSTR  layerName,
PSDBQUERYRESULT  result 
)
static

Definition at line 222 of file hsdb.c.

223{
224 TAGID database, layer;
225 TAGREF tr;
226 PDB pdb = hsdb->pdb;
227
229 if (database == TAGID_NULL)
230 return FALSE;
231
233 if (layer == TAGID_NULL)
234 return FALSE;
235
236 if (!SdbTagIDToTagRef(hsdb, pdb, layer, &tr))
237 return FALSE;
238
240 return FALSE;
241
243 return TRUE;
244}
TAGID WINAPI SdbFindFirstNamedTag(PDB pdb, TAGID root, TAGID find, TAGID nametag, LPCWSTR find_name)
Definition: sdbapi.c:544

Referenced by SdbpAddExeLayers(), and SdbpAddLayerMatches().

◆ SdbpAddSingleLayerMatch()

static BOOL SdbpAddSingleLayerMatch ( TAGREF  layer,
PSDBQUERYRESULT  result 
)
static

Definition at line 202 of file hsdb.c.

203{
204 size_t n;
205
206 for (n = 0; n < result->dwLayerCount; ++n)
207 {
208 if (result->atrLayers[n] == layer)
209 return FALSE;
210 }
211
212 if (n >= _countof(result->atrLayers))
213 return FALSE;
214
215 result->atrLayers[n] = layer;
216 result->dwLayerCount++;
217
218 return TRUE;
219}

Referenced by SdbpAddExeLayers(), and SdbpAddNamedLayerMatch().

◆ SdbpFileExists()

static BOOL WINAPI SdbpFileExists ( LPCWSTR  path)
static

Definition at line 40 of file hsdb.c.

41{
44}
DWORD WINAPI GetFileAttributesW(LPCWSTR lpFileName)
Definition: fileinfo.c:652
#define FILE_ATTRIBUTE_DIRECTORY
Definition: nt_native.h:705
Definition: cookie.c:202
#define INVALID_FILE_ATTRIBUTES
Definition: vfdcmd.c:23

Referenced by SdbpMatchExe().

◆ SdbpMatchExe()

static BOOL WINAPI SdbpMatchExe ( PDB  pdb,
TAGID  exe,
const WCHAR dir,
PATTRINFO  main_attribs,
DWORD  main_attr_count 
)
static

Definition at line 109 of file hsdb.c.

110{
111 RTL_UNICODE_STRING_BUFFER FullPathName = { { 0 } };
112 WCHAR FullPathBuffer[MAX_PATH];
113 UNICODE_STRING UnicodeDir;
114 TAGID matching_file;
116 DWORD attr_count;
117 BOOL IsMatch = FALSE;
118
119 RtlInitUnicodeString(&UnicodeDir, dir);
120 RtlInitBuffer(&FullPathName.ByteBuffer, (PUCHAR)FullPathBuffer, sizeof(FullPathBuffer));
121
122 for (matching_file = SdbFindFirstTag(pdb, exe, TAG_MATCHING_FILE);
123 matching_file != TAGID_NULL; matching_file = SdbFindNextTag(pdb, exe, matching_file))
124 {
125 TAGID tagName = SdbFindFirstTag(pdb, matching_file, TAG_NAME);
127 USHORT Len;
128
130
131 if (!Name.Buffer)
132 goto Cleanup;
133
134 /* An '*' here means use the main executable' */
135 if (!wcscmp(Name.Buffer, L"*"))
136 {
137 /* We already have these attributes, so we do not need to retrieve them */
138 if (!SdbpMatchFileAttributes(pdb, matching_file, main_attribs, main_attr_count))
139 goto Cleanup;
140 continue;
141 }
142
143 /* Technically, one UNICODE_NULL and one path separator. */
144 Len = UnicodeDir.Length + Name.Length + sizeof(UNICODE_NULL) + sizeof(UNICODE_NULL);
145 if (!NT_SUCCESS(RtlEnsureBufferSize(RTL_SKIP_BUFFER_COPY, &FullPathName.ByteBuffer, Len)))
146 goto Cleanup;
147
148 if (Len > FullPathName.ByteBuffer.Size)
149 goto Cleanup;
150
151 RtlInitEmptyUnicodeString(&FullPathName.String, (PWCHAR)FullPathName.ByteBuffer.Buffer, FullPathName.ByteBuffer.Size);
152
153 RtlCopyUnicodeString(&FullPathName.String, &UnicodeDir);
154 RtlAppendUnicodeToString(&FullPathName.String, L"\\");
156
157 /* If the file does not exist, do not bother trying to read it's attributes */
158 if (!SdbpFileExists(FullPathName.String.Buffer))
159 goto Cleanup;
160
161 /* Do we have some attributes from the previous iteration? */
162 if (attribs)
164
165 if (!SdbGetFileAttributes(FullPathName.String.Buffer, &attribs, &attr_count))
166 goto Cleanup;
167
168 if (!SdbpMatchFileAttributes(pdb, matching_file, attribs, attr_count))
169 goto Cleanup;
170 }
171
172 IsMatch = TRUE;
173
174Cleanup:
175 RtlFreeBuffer(&FullPathName.ByteBuffer);
176 if (attribs)
178
179 return IsMatch;
180}
struct NameRec_ * Name
Definition: cdprocs.h:460
unsigned int dir
Definition: maze.c:112
#define TAG_MATCHING_FILE
Definition: db.cpp:88
#define Len
Definition: deflate.h:82
NTSTATUS RtlAppendUnicodeToString(IN PUNICODE_STRING Str1, IN PWSTR Str2)
Definition: string_lib.cpp:62
static BOOL SdbpMatchFileAttributes(PDB pdb, TAGID matching_file, PATTRINFO attribs, DWORD attr_count)
Definition: hsdb.c:48
static BOOL WINAPI SdbpFileExists(LPCWSTR path)
Definition: hsdb.c:40
NTSYSAPI VOID NTAPI RtlCopyUnicodeString(PUNICODE_STRING DestinationString, PUNICODE_STRING SourceString)
NTSYSAPI NTSTATUS NTAPI RtlAppendUnicodeStringToString(PUNICODE_STRING Destination, PUNICODE_STRING Source)
unsigned short USHORT
Definition: pedump.c:61
_Check_return_ _CRTIMP int __cdecl wcscmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
SIZE_T Size
Definition: rtltypes.h:1877
uint16_t * PWCHAR
Definition: typedefs.h:56

Referenced by SdbGetMatchingExe().

◆ SdbpMatchFileAttributes()

static BOOL SdbpMatchFileAttributes ( PDB  pdb,
TAGID  matching_file,
PATTRINFO  attribs,
DWORD  attr_count 
)
static

Definition at line 48 of file hsdb.c.

49{
51
52 for (child = SdbGetFirstChild(pdb, matching_file);
53 child != TAGID_NULL; child = SdbGetNextChild(pdb, matching_file, child))
54 {
56 DWORD n;
57
58 /* Already handled! */
59 if (tag == TAG_NAME)
60 continue;
61
65 {
66 SHIM_WARN("Unimplemented TAG_UPTO_XXXXX\n");
67 continue;
68 }
69
70 for (n = 0; n < attr_count; ++n)
71 {
73 if (attr->flags == ATTRIBUTE_AVAILABLE && attr->type == tag)
74 {
75 DWORD dwval;
76 WCHAR* lpval;
77 QWORD qwval;
78 switch (tag & TAG_TYPE_MASK)
79 {
80 case TAG_TYPE_DWORD:
81 dwval = SdbReadDWORDTag(pdb, child, 0);
82 if (dwval != attr->dwattr)
83 return FALSE;
84 break;
87 if (!lpval || wcsicmp(attr->lpattr, lpval))
88 return FALSE;
89 break;
90 case TAG_TYPE_QWORD:
91 qwval = SdbReadQWORDTag(pdb, child, 0);
92 if (qwval != attr->qwattr)
93 return FALSE;
94 break;
95 default:
96 SHIM_WARN("Unhandled type 0x%x MATCHING_FILE\n", (tag & TAG_TYPE_MASK));
97 return FALSE;
98 }
99 }
100 }
101 if (n == attr_count)
102 SHIM_WARN("Unhandled tag %ws in MATCHING_FILE\n", SdbTagToString(tag));
103 }
104 return TRUE;
105}
TAG WINAPI SdbGetTagFromTagID(PDB pdb, TAGID tagid)
Definition: sdbread.c:93
LPCWSTR WINAPI SdbTagToString(TAG tag)
Definition: sdbapi.c:752
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
#define ATTRIBUTE_AVAILABLE
Definition: apphelp.h:146
QWORD WINAPI SdbReadQWORDTag(PDB pdb, TAGID tagid, QWORD ret)
Definition: sdbread.c:321
#define TAG_UPTO_BIN_FILE_VERSION
Definition: apphelp.c:62
#define TAG_UPTO_LINK_DATE
Definition: apphelp.c:57
#define TAG_UPTO_BIN_PRODUCT_VERSION
Definition: apphelp.c:61
static HWND child
Definition: cursoricon.c:298
#define TAG_TYPE_DWORD
Definition: shimdbg.c:107
#define TAG_TYPE_QWORD
Definition: shimdbg.c:108
#define TAG_TYPE_STRINGREF
Definition: shimdbg.c:109
UINT64 QWORD
Definition: shimdbg.c:104
#define TAG_TYPE_MASK
Definition: shimdbg.c:106
Definition: fs_rec.h:143
Definition: ecma_167.h:138

Referenced by SdbpMatchExe().

◆ SdbpPropagateEnvLayers()

static BOOL SdbpPropagateEnvLayers ( HSDB  hsdb,
LPWSTR  Environment,
PSDBQUERYRESULT  Result 
)
static

Definition at line 341 of file hsdb.c.

342{
343 static const UNICODE_STRING EnvKey = RTL_CONSTANT_STRING(L"__COMPAT_LAYER");
344 UNICODE_STRING EnvValue;
347
348 RtlInitEmptyUnicodeString(&EnvValue, Buffer, sizeof(Buffer));
349
350 Status = RtlQueryEnvironmentVariable_U(Environment, &EnvKey, &EnvValue);
351
352 if (!NT_SUCCESS(Status))
353 return FALSE;
354
355 return SdbpAddLayerMatches(hsdb, Buffer, EnvValue.Length, Result) > 0;
356}
LONG NTSTATUS
Definition: precomp.h:26
Definition: bufpool.h:45
Status
Definition: gdiplustypes.h:25
PVOID PVOID PWCHAR PVOID Environment
Definition: env.c:47
NTSYSAPI NTSTATUS NTAPI RtlQueryEnvironmentVariable_U(_In_opt_ PWSTR Environment, _In_ PCUNICODE_STRING Name, _Out_ PUNICODE_STRING Value)
#define RTL_CONSTANT_STRING(s)
Definition: tunneltest.c:14
_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 SdbGetMatchingExe().

◆ 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().

◆ SdbQueryDataEx()

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

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
[out,opt]ptrData The tagRef of the data
Returns
ERROR_SUCCESS

Definition at line 799 of file hsdb.c.

800{
801 PDB pdb;
802 TAGID tiWhich, tiData;
803 DWORD dwResult;
804
805 if (!SdbTagRefToTagID(hsdb, trWhich, &pdb, &tiWhich))
806 {
807 SHIM_WARN("Unable to translate trWhich=0x%x\n", trWhich);
808 return ERROR_NOT_FOUND;
809 }
810
812
813 if (dwResult == ERROR_SUCCESS && ptrData)
814 SdbTagIDToTagRef(hsdb, pdb, tiData, ptrData);
815
816 return dwResult;
817}
DWORD WINAPI SdbQueryDataExTagID(PDB pdb, TAGID tiExe, LPCWSTR lpszDataName, LPDWORD lpdwDataType, LPVOID lpBuffer, LPDWORD lpcbBufferSize, TAGID *ptiData)
Definition: sdbapi.c:614
static PDB TAGID tiWhich
Definition: db.cpp:172
static TAGREF LPCWSTR LPDWORD LPVOID LPDWORD TAGREF * ptrData
Definition: db.cpp:176
BOOL WINAPI SdbTagRefToTagID(HSDB hsdb, TAGREF trWhich, PDB *ppdb, TAGID *ptiWhich)
Definition: hsdb.c:638
#define ERROR_NOT_FOUND
Definition: winerror.h:690

Referenced by SdbQueryData().

◆ 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}
void WINAPI SdbCloseDatabase(PDB)
Definition: sdbapi.c:373

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 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
#define TAG_NULL
Definition: apphelp.c:45

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

◆ 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}
SDBQUERYRESULT Query
Definition: hsdb.c:26
DWORD dwSize
Definition: hsdb.c:24
DWORD dwMagic
Definition: hsdb.c:25

Referenced by SeiGetShimData().