mirror of
https://github.com/reactos/reactos.git
synced 2026-05-31 16:31:07 +08:00
[APPHELP] Add basic support for wildcard matching
CORE-20159
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
* PURPOSE: Shim matching / data (un)packing
|
||||
* COPYRIGHT: Copyright 2011 André Hentschel
|
||||
* Copyright 2013 Mislav Blaževic
|
||||
* Copyright 2015-2019 Mark Jansen (mark.jansen@reactos.org)
|
||||
* Copyright 2015-2025 Mark Jansen <mark.jansen@reactos.org>
|
||||
*/
|
||||
|
||||
#define WIN32_NO_STATUS
|
||||
@@ -508,18 +508,28 @@ BOOL WINAPI SdbGetMatchingExe(HSDB hsdb, LPCWSTR path, LPCWSTR module_name,
|
||||
goto Cleanup;
|
||||
}
|
||||
|
||||
/* EXE is list TAG which contains data required to match executable */
|
||||
iter = SdbFindFirstTag(pdb, database, TAG_EXE);
|
||||
/*
|
||||
* Instead of brute-force searching the 'entire' DB, we should:
|
||||
* 1. Iterate over the Index TAG_EXE.TAG_WILDCARD_NAME
|
||||
* 2. Search the index TAG_EXE.TAG_NAME (fallback to SdbFindFirstNamedTag)
|
||||
* 3. Search the index TAG_EXE.TAG_16BIT_MODULE_NAME (fallback to SdbFindFirstNamedTag)
|
||||
*/
|
||||
|
||||
/* Search for entry in database, we should look into indexing tags! */
|
||||
while (iter != TAGID_NULL)
|
||||
|
||||
/* EXE is list TAG which contains data required to match executable */
|
||||
for (iter = SdbFindFirstTag(pdb, database, TAG_EXE); iter != TAGID_NULL; iter = SdbFindNextTag(pdb, database, iter))
|
||||
{
|
||||
LPWSTR foundName;
|
||||
/* Check if exe name matches */
|
||||
name = SdbFindFirstTag(pdb, iter, TAG_NAME);
|
||||
LPWSTR foundName = SdbGetStringTagPtr(pdb, name);
|
||||
/* If this is a malformed DB, (no TAG_NAME), we should not crash. */
|
||||
foundName = SdbGetStringTagPtr(pdb, name);
|
||||
if (foundName && !_wcsicmp(foundName, file_name))
|
||||
if (!foundName)
|
||||
continue;
|
||||
|
||||
/* We only support full wildcard names for now */
|
||||
BOOL isWildcard = foundName[0] == '*' && foundName[1] == UNICODE_NULL;
|
||||
|
||||
/* Check if exe name matches */
|
||||
if (isWildcard || !_wcsicmp(foundName, file_name))
|
||||
{
|
||||
/* Get information about executable required to match it with database entry */
|
||||
if (!attribs)
|
||||
@@ -536,9 +546,6 @@ BOOL WINAPI SdbGetMatchingExe(HSDB hsdb, LPCWSTR path, LPCWSTR module_name,
|
||||
SdbpAddExeMatch(hsdb, pdb, iter, result);
|
||||
}
|
||||
}
|
||||
|
||||
/* Continue iterating */
|
||||
iter = SdbFindNextTag(pdb, database, iter);
|
||||
}
|
||||
|
||||
/* Restore the full path. */
|
||||
|
||||
Reference in New Issue
Block a user