mirror of
https://github.com/reactos/reactos.git
synced 2025-02-23 08:55:19 +00:00
[APPHELP][APPHELP_APITEST] Update db apitests to succeed from 2k3 to 10, paving the way for the next set of tests.
- Support 2k3 and Vista+ versions of the SDBQUERYRESULT structure. - Add tests for SdbFindFirstNamedTag, SdbTagIDToTagRef, SdbGetLayerTagRef - Implement SdbFindFirstNamedTag, SdbTagIDToTagRef, SdbGetLayerTagRef - Add a version resource to apphelp, so that we can use it to identify which tests to use. svn path=/trunk/; revision=73083
This commit is contained in:
parent
705f7ce49e
commit
22ba0b5aa5
10 changed files with 538 additions and 196 deletions
|
@ -1,4 +1,9 @@
|
|||
|
||||
include_directories(${SHIMLIB_DIR})
|
||||
|
||||
remove_definitions(-D_WIN32_WINNT=0x502 -DWINVER=0x502)
|
||||
add_definitions(-D_WIN32_WINNT=0x600 -DWINVER=0x600)
|
||||
|
||||
spec2def(apphelp.dll apphelp.spec ADD_IMPORTLIB)
|
||||
|
||||
list(APPEND SOURCE
|
||||
|
@ -16,6 +21,7 @@ list(APPEND SOURCE
|
|||
|
||||
add_library(apphelp SHARED
|
||||
${SOURCE}
|
||||
apphelp.rc
|
||||
${CMAKE_CURRENT_BINARY_DIR}/apphelp.def)
|
||||
|
||||
set_module_type(apphelp win32dll)
|
||||
|
|
|
@ -79,10 +79,9 @@ typedef struct tagSDBQUERYRESULT {
|
|||
GUID rgGuidDB[SDB_MAX_SDBS];
|
||||
} SDBQUERYRESULT, *PSDBQUERYRESULT;
|
||||
|
||||
/* apphelp.c */
|
||||
|
||||
#include "sdbpapi.h"
|
||||
|
||||
/* sdbapi.c */
|
||||
PWSTR SdbpStrDup(LPCWSTR string);
|
||||
HSDB WINAPI SdbInitDatabase(DWORD, LPCWSTR);
|
||||
void WINAPI SdbReleaseDatabase(HSDB);
|
||||
|
@ -92,6 +91,7 @@ void WINAPI SdbCloseDatabase(PDB);
|
|||
BOOL WINAPI SdbIsNullGUID(CONST GUID *Guid);
|
||||
BOOL WINAPI SdbGetAppPatchDir(HSDB db, LPWSTR path, DWORD size);
|
||||
LPWSTR WINAPI SdbGetStringTagPtr(PDB db, TAGID tagid);
|
||||
TAGID WINAPI SdbFindFirstNamedTag(PDB db, TAGID root, TAGID find, TAGID nametag, LPCWSTR find_name);
|
||||
|
||||
/* sdbread.c */
|
||||
BOOL WINAPI SdbpReadData(PDB db, PVOID dest, DWORD offset, DWORD num);
|
||||
|
@ -108,6 +108,9 @@ 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);
|
||||
|
||||
/* hsdb.c */
|
||||
BOOL WINAPI SdbTagIDToTagRef(HSDB hsdb, PDB pdb, TAGID tiWhich, TAGREF* ptrWhich);
|
||||
|
||||
|
||||
#define ATTRIBUTE_AVAILABLE 0x1
|
||||
#define ATTRIBUTE_FAILED 0x2
|
||||
|
|
11
reactos/dll/appcompat/apphelp/apphelp.rc
Normal file
11
reactos/dll/appcompat/apphelp/apphelp.rc
Normal file
|
@ -0,0 +1,11 @@
|
|||
#include <windef.h>
|
||||
|
||||
#define REACTOS_FILEVERSION 6,0,6000,0
|
||||
#define REACTOS_STR_FILE_VERSION "6.0.6000.0"
|
||||
#define REACTOS_PRODUCTVERSION 6,0,6000,0
|
||||
#define REACTOS_STR_PRODUCT_VERSION "6.0"
|
||||
|
||||
#define REACTOS_STR_FILE_DESCRIPTION "Application compatibility module"
|
||||
#define REACTOS_STR_INTERNAL_NAME "apphelp"
|
||||
#define REACTOS_STR_ORIGINAL_FILENAME "apphelp.dll"
|
||||
#include <reactos/version.rc>
|
|
@ -38,7 +38,7 @@
|
|||
@ stub SdbFindFirstDWORDIndexedTag
|
||||
@ stub SdbFindFirstMsiPackage
|
||||
@ stub SdbFindFirstMsiPackage_Str
|
||||
@ stub SdbFindFirstNamedTag
|
||||
@ stdcall SdbFindFirstNamedTag(ptr long long long wstr)
|
||||
@ stub SdbFindFirstStringIndexedTag
|
||||
@ stdcall SdbFindFirstTag(ptr long long)
|
||||
@ stub SdbFindFirstTagRef
|
||||
|
@ -69,7 +69,7 @@
|
|||
@ stub SdbGetIndex
|
||||
@ stub SdbGetItemFromItemRef
|
||||
@ stub SdbGetLayerName
|
||||
@ stub SdbGetLayerTagRef
|
||||
@ stdcall SdbGetLayerTagRef(ptr wstr)
|
||||
@ stub SdbGetLocalPDB
|
||||
@ stdcall SdbGetMatchingExe(ptr wstr wstr wstr long ptr)
|
||||
@ stub SdbGetMsiPackageInformation
|
||||
|
@ -143,7 +143,7 @@
|
|||
@ stub SdbStringDuplicate
|
||||
@ stub SdbStringReplace
|
||||
@ stub SdbStringReplaceArray
|
||||
@ stub SdbTagIDToTagRef
|
||||
@ stdcall SdbTagIDToTagRef(ptr ptr long ptr)
|
||||
@ stdcall SdbTagRefToTagID(ptr long ptr ptr)
|
||||
@ stdcall SdbTagToString(long)
|
||||
@ stub SdbUnregisterDatabase
|
||||
|
|
|
@ -23,7 +23,6 @@
|
|||
#include "ntndk.h"
|
||||
#include "strsafe.h"
|
||||
#include "apphelp.h"
|
||||
//#include "sdbstringtable.h"
|
||||
|
||||
#include "wine/unicode.h"
|
||||
|
||||
|
@ -256,26 +255,58 @@ BOOL WINAPI SdbGetAppPatchDir(HSDB db, LPWSTR path, DWORD size)
|
|||
* Translates the given trWhich to a specific database / tagid
|
||||
*
|
||||
* @param [in] hsdb Handle to the database.
|
||||
* @param [in] trWhich Path to executable for which we query database.
|
||||
* @param [in] trWhich Tagref to find
|
||||
* @param [out,opt] ppdb The Shim database that trWhich belongs to.
|
||||
* @param [out,opt] ptiWhich The tagid that trWhich corresponds to.
|
||||
*
|
||||
* @return TRUE if it succeeds, FALSE if it fails.
|
||||
*/
|
||||
BOOL WINAPI SdbTagRefToTagID(HSDB hSDB, TAGREF trWhich, PDB* ppdb, TAGID* ptiWhich)
|
||||
BOOL WINAPI SdbTagRefToTagID(HSDB hsdb, TAGREF trWhich, PDB* ppdb, TAGID* ptiWhich)
|
||||
{
|
||||
if (trWhich & 0xf0000000)
|
||||
{
|
||||
SHIM_ERR("Multiple shim databases not yet implemented!\n");
|
||||
if (ppdb)
|
||||
*ppdb = NULL;
|
||||
if (ptiWhich)
|
||||
*ptiWhich = TAG_NULL;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* There seems to be no range checking on trWhich.. */
|
||||
if (ppdb)
|
||||
*ppdb = hSDB->db;
|
||||
*ppdb = hsdb->db;
|
||||
if (ptiWhich)
|
||||
*ptiWhich = trWhich & 0x0fffffff;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Translates the given trWhich to a specific database / tagid
|
||||
*
|
||||
* @param [in] hsdb Handle to the database.
|
||||
* @param [in] pdb The Shim database that tiWhich belongs to.
|
||||
* @param [in] tiWhich Path to executable for which we query database.
|
||||
* @param [out,opt] ptrWhich The tagid that tiWhich corresponds to.
|
||||
*
|
||||
* @return TRUE if it succeeds, FALSE if it fails.
|
||||
*/
|
||||
BOOL WINAPI SdbTagIDToTagRef(HSDB hsdb, PDB pdb, TAGID tiWhich, TAGREF* ptrWhich)
|
||||
{
|
||||
if (pdb != hsdb->db)
|
||||
{
|
||||
SHIM_ERR("Multiple shim databases not yet implemented!\n");
|
||||
if (ptrWhich)
|
||||
*ptrWhich = TAGREF_NULL;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (ptrWhich)
|
||||
*ptrWhich = tiWhich & 0x0fffffff;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -425,7 +425,7 @@ PDB WINAPI SdbOpenDatabase(LPCWSTR path, PATH_TYPE type)
|
|||
if (!db)
|
||||
return NULL;
|
||||
|
||||
if (major != 2)
|
||||
if (major != 2 && major != 3)
|
||||
{
|
||||
SdbCloseDatabase(db);
|
||||
SHIM_ERR("Invalid shim database version\n");
|
||||
|
@ -563,6 +563,67 @@ BOOL WINAPI SdbGetDatabaseVersion(LPCWSTR database, PDWORD VersionHi, PDWORD Ver
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* Find the first named child tag.
|
||||
*
|
||||
* @param [in] database The database.
|
||||
* @param [in] root The tag to start at
|
||||
* @param [in] find The tag type to find
|
||||
* @param [in] nametag The child of 'find' that contains the name
|
||||
* @param [in] find_name The name to find
|
||||
*
|
||||
* @return The found tag, or TAGID_NULL on failure
|
||||
*/
|
||||
TAGID WINAPI SdbFindFirstNamedTag(PDB db, TAGID root, TAGID find, TAGID nametag, LPCWSTR find_name)
|
||||
{
|
||||
TAGID iter;
|
||||
|
||||
iter = SdbFindFirstTag(db, root, find);
|
||||
|
||||
while (iter != TAGID_NULL)
|
||||
{
|
||||
TAGID tmp = SdbFindFirstTag(db, iter, nametag);
|
||||
if (tmp != TAGID_NULL)
|
||||
{
|
||||
LPCWSTR name = SdbGetStringTagPtr(db, tmp);
|
||||
if (name && !lstrcmpiW(name, find_name))
|
||||
return iter;
|
||||
}
|
||||
iter = SdbFindNextTag(db, root, iter);
|
||||
}
|
||||
return TAGID_NULL;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Find a named layer in a multi-db.
|
||||
*
|
||||
* @param [in] hsdb The multi-database.
|
||||
* @param [in] layerName The named tag to find.
|
||||
*
|
||||
* @return The layer, or TAGREF_NULL on failure
|
||||
*/
|
||||
TAGREF WINAPI SdbGetLayerTagRef(HSDB hsdb, LPCWSTR layerName)
|
||||
{
|
||||
PDB db = hsdb->db;
|
||||
|
||||
TAGID database = SdbFindFirstTag(db, TAGID_ROOT, TAG_DATABASE);
|
||||
if (database != TAGID_NULL)
|
||||
{
|
||||
TAGID layer = SdbFindFirstNamedTag(db, database, TAG_LAYER, TAG_NAME, layerName);
|
||||
if (layer != TAGID_NULL)
|
||||
{
|
||||
TAGREF tr;
|
||||
if (SdbTagIDToTagRef(hsdb, db, layer, &tr))
|
||||
{
|
||||
return tr;
|
||||
}
|
||||
}
|
||||
}
|
||||
return TAGREF_NULL;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Converts the specified string to an index key.
|
||||
*
|
||||
|
|
|
@ -4,11 +4,11 @@ add_definitions(-D__ROS_LONG64__ -DWINETEST_USE_DBGSTR_LONGLONG)
|
|||
list(APPEND SOURCE
|
||||
apphelp.c
|
||||
data.c
|
||||
db.c
|
||||
db.cpp
|
||||
layerapi.c
|
||||
testlist.c)
|
||||
|
||||
add_executable(apphelp_apitest ${SOURCE})
|
||||
set_module_type(apphelp_apitest win32cui)
|
||||
add_importlibs(apphelp_apitest advapi32 shlwapi msvcrt kernel32 ntdll)
|
||||
add_importlibs(apphelp_apitest advapi32 userenv version shlwapi msvcrt kernel32 ntdll)
|
||||
add_cd_file(TARGET apphelp_apitest DESTINATION reactos/bin FOR all)
|
||||
|
|
|
@ -1,14 +1,19 @@
|
|||
#ifndef APPHELP_APITEST_H
|
||||
#define APPHELP_APITEST_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/* data.c */
|
||||
void test_create_db_imp(const char* name);
|
||||
void test_create_db_imp(const char* name, int win10);
|
||||
DWORD test_get_db_size();
|
||||
void test_create_exe_imp(const char* name, int skip_rsrc_exports);
|
||||
void test_create_file_imp(const char* name, const char* contents, size_t len);
|
||||
void test_create_ne_imp(const char* name, int skip_names);
|
||||
DWORD get_host_winver(void);
|
||||
DWORD get_module_version(HMODULE mod);
|
||||
void silence_debug_output(void); // Silence output if the environment variable is not set.
|
||||
|
||||
#define test_create_db (winetest_set_location(__FILE__, __LINE__), 0) ? (void)0 : test_create_db_imp
|
||||
|
@ -27,5 +32,8 @@ static DWORD g_WinVersion;
|
|||
#define WINVER_WIN8 0x0602
|
||||
#define WINVER_WIN10 0x0a00
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
#endif // APPHELP_APITEST_H
|
||||
|
|
|
@ -569,6 +569,9 @@ void test_create_file_imp(const char* name, const char* contents, size_t len)
|
|||
}
|
||||
}
|
||||
|
||||
static unsigned char win10Header[8] = {
|
||||
0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||
};
|
||||
static unsigned char rawData[2356] = {
|
||||
0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x73, 0x64, 0x62, 0x66,
|
||||
0x02, 0x78, 0x3E, 0x01, 0x00, 0x00, 0x03, 0x78, 0x44, 0x00, 0x00, 0x00,
|
||||
|
@ -774,7 +777,7 @@ DWORD test_get_db_size()
|
|||
return sizeof(rawData);
|
||||
}
|
||||
|
||||
void test_create_db_imp(const char* name)
|
||||
void test_create_db_imp(const char* name, int win10)
|
||||
{
|
||||
HANDLE file = CreateFileA(name, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
|
||||
winetest_ok(file != INVALID_HANDLE_VALUE, "can't create file '%s'\n", name);
|
||||
|
@ -782,6 +785,11 @@ void test_create_db_imp(const char* name)
|
|||
{
|
||||
DWORD size;
|
||||
WriteFile(file, rawData, sizeof(rawData), &size, NULL);
|
||||
if (win10)
|
||||
{
|
||||
SetFilePointer(file, 0, NULL, FILE_BEGIN);
|
||||
WriteFile(file, win10Header, sizeof(win10Header), &size, NULL);
|
||||
}
|
||||
CloseHandle(file);
|
||||
}
|
||||
}
|
||||
|
@ -802,6 +810,36 @@ DWORD get_host_winver(void)
|
|||
return g_WinVersion;
|
||||
}
|
||||
|
||||
DWORD get_module_version(HMODULE mod)
|
||||
{
|
||||
DWORD dwVersion = 0;
|
||||
HRSRC hResInfo = FindResource(mod, MAKEINTRESOURCE(VS_VERSION_INFO), RT_VERSION);
|
||||
DWORD dwSize = SizeofResource(mod, hResInfo);
|
||||
if (hResInfo && dwSize)
|
||||
{
|
||||
VS_FIXEDFILEINFO *lpFfi;
|
||||
UINT uLen;
|
||||
|
||||
HGLOBAL hResData = LoadResource(mod, hResInfo);
|
||||
LPVOID pRes = LockResource(hResData);
|
||||
HLOCAL pResCopy = LocalAlloc(LMEM_FIXED, dwSize);
|
||||
|
||||
CopyMemory(pResCopy, pRes, dwSize);
|
||||
FreeResource(hResData);
|
||||
|
||||
if (VerQueryValueW(pResCopy, L"\\", (LPVOID*)&lpFfi, &uLen))
|
||||
{
|
||||
dwVersion = (HIWORD(lpFfi->dwProductVersionMS) << 8) | LOWORD(lpFfi->dwProductVersionMS);
|
||||
if (!dwVersion)
|
||||
dwVersion = (HIWORD(lpFfi->dwFileVersionMS) << 8) | LOWORD(lpFfi->dwFileVersionMS);
|
||||
}
|
||||
|
||||
LocalFree(pResCopy);
|
||||
}
|
||||
|
||||
return dwVersion;
|
||||
}
|
||||
|
||||
void silence_debug_output(void)
|
||||
{
|
||||
if (GetEnvironmentVariableA("SHIM_DEBUG_LEVEL", NULL, 0) == ERROR_ENVVAR_NOT_FOUND)
|
||||
|
|
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue