ReactOS  0.4.15-dev-425-gc40b086
db.cpp File Reference
#include <ntstatus.h>
#include <windows.h>
#include <shlwapi.h>
#include <winnt.h>
#include <winternl.h>
#include <winerror.h>
#include <stdio.h>
#include <initguid.h>
#include "wine/test.h"
#include "apphelp_apitest.h"
Include dependency graph for db.cpp:

Go to the source code of this file.

Classes

struct  _DB_INFORMATION
 

Macros

#define WIN32_NO_STATUS
 
#define DOS_PATH   0
 
#define HID_DATABASE_FULLPATH   2
 
#define SDB_DATABASE_MAIN_SHIM   0x80030000
 
#define TAGID_NULL   0x0
 
#define TAGID_ROOT   0x0
 
#define _TAGID_ROOT   12
 
#define TAG_TYPE_MASK   0xF000
 
#define TAG_TYPE_NULL   0x1000
 
#define TAG_TYPE_BYTE   0x2000
 
#define TAG_TYPE_WORD   0x3000
 
#define TAG_TYPE_DWORD   0x4000
 
#define TAG_TYPE_QWORD   0x5000
 
#define TAG_TYPE_STRINGREF   0x6000
 
#define TAG_TYPE_LIST   0x7000
 
#define TAG_TYPE_STRING   0x8000
 
#define TAG_TYPE_BINARY   0x9000
 
#define TAG_NULL   0x0
 
#define TAG_INCLUDE   (0x1 | TAG_TYPE_NULL)
 
#define TAG_MATCH_MODE   (0x1 | TAG_TYPE_WORD)
 
#define TAG_SIZE   (0x1 | TAG_TYPE_DWORD)
 
#define TAG_CHECKSUM   (0x3 | TAG_TYPE_DWORD)
 
#define TAG_MODULE_TYPE   (0x6 | TAG_TYPE_DWORD)
 
#define TAG_VERFILEOS   (0x9 | TAG_TYPE_DWORD)
 
#define TAG_VERFILETYPE   (0xA | TAG_TYPE_DWORD)
 
#define TAG_PE_CHECKSUM   (0xB | TAG_TYPE_DWORD)
 
#define TAG_PROBLEMSEVERITY   (0x10 | TAG_TYPE_DWORD)
 
#define TAG_HTMLHELPID   (0x15 | TAG_TYPE_DWORD)
 
#define TAG_FLAGS   (0x17 | TAG_TYPE_DWORD)
 
#define TAG_LAYER_TAGID   (0x1A | TAG_TYPE_DWORD)
 
#define TAG_LINKER_VERSION   (0x1C | TAG_TYPE_DWORD)
 
#define TAG_LINK_DATE   (0x1D | TAG_TYPE_DWORD)
 
#define TAG_UPTO_LINK_DATE   (0x1E | TAG_TYPE_DWORD)
 
#define TAG_APP_NAME_RC_ID   (0x24 | TAG_TYPE_DWORD)
 
#define TAG_VENDOR_NAME_RC_ID   (0x25 | TAG_TYPE_DWORD)
 
#define TAG_SUMMARY_MSG_RC_ID   (0x26 | TAG_TYPE_DWORD)
 
#define TAG_OS_PLATFORM   (0x23 | TAG_TYPE_DWORD)
 
#define TAG_TIME   (0x1 | TAG_TYPE_QWORD)
 
#define TAG_BIN_FILE_VERSION   (0x2 | TAG_TYPE_QWORD)
 
#define TAG_BIN_PRODUCT_VERSION   (0x3 | TAG_TYPE_QWORD)
 
#define TAG_UPTO_BIN_PRODUCT_VERSION   (0x6 | TAG_TYPE_QWORD)
 
#define TAG_UPTO_BIN_FILE_VERSION   (0xD | TAG_TYPE_QWORD)
 
#define TAG_FLAG_LUA   (0x10 | TAG_TYPE_QWORD)
 
#define TAG_DATABASE   (0x1 | TAG_TYPE_LIST)
 
#define TAG_INEXCLUD   (0x3 | TAG_TYPE_LIST)
 
#define TAG_EXE   (0x7 | TAG_TYPE_LIST)
 
#define TAG_MATCHING_FILE   (0x8 | TAG_TYPE_LIST)
 
#define TAG_SHIM_REF   (0x9| TAG_TYPE_LIST)
 
#define TAG_LAYER   (0xB | TAG_TYPE_LIST)
 
#define TAG_APPHELP   (0xD | TAG_TYPE_LIST)
 
#define TAG_LINK   (0xE | TAG_TYPE_LIST)
 
#define TAG_DATA   (0xF | TAG_TYPE_LIST)
 
#define TAG_STRINGTABLE   (0x801 | TAG_TYPE_LIST)
 
#define TAG_STRINGTABLE_ITEM   (0x801 | TAG_TYPE_STRING)
 
#define TAG_NAME   (0x1 | TAG_TYPE_STRINGREF)
 
#define TAG_MODULE   (0x3 | TAG_TYPE_STRINGREF)
 
#define TAG_VENDOR   (0x5 | TAG_TYPE_STRINGREF)
 
#define TAG_APP_NAME   (0x6 | TAG_TYPE_STRINGREF)
 
#define TAG_COMMAND_LINE   (0x8 | TAG_TYPE_STRINGREF)
 
#define TAG_COMPANY_NAME   (0x9 | TAG_TYPE_STRINGREF)
 
#define TAG_WILDCARD_NAME   (0xB | TAG_TYPE_STRINGREF)
 
#define TAG_PRODUCT_NAME   (0x10 | TAG_TYPE_STRINGREF)
 
#define TAG_PRODUCT_VERSION   (0x11 | TAG_TYPE_STRINGREF)
 
#define TAG_FILE_DESCRIPTION   (0x12 | TAG_TYPE_STRINGREF)
 
#define TAG_FILE_VERSION   (0x13 | TAG_TYPE_STRINGREF)
 
#define TAG_ORIGINAL_FILENAME   (0x14 | TAG_TYPE_STRINGREF)
 
#define TAG_INTERNAL_NAME   (0x15 | TAG_TYPE_STRINGREF)
 
#define TAG_LEGAL_COPYRIGHT   (0x16 | TAG_TYPE_STRINGREF)
 
#define TAG_APPHELP_DETAILS   (0x18 | TAG_TYPE_STRINGREF)
 
#define TAG_LINK_URL   (0x19 | TAG_TYPE_STRINGREF)
 
#define TAG_APPHELP_TITLE   (0x1B | TAG_TYPE_STRINGREF)
 
#define TAG_COMPILER_VERSION   (0x22 | TAG_TYPE_STRINGREF)
 
#define TAG_GENERAL   (0x2 | TAG_TYPE_NULL)
 
#define TAG_EXE_ID   (0x4 | TAG_TYPE_BINARY)
 
#define TAG_DATA_BITS   (0x5 | TAG_TYPE_BINARY)
 
#define TAG_DATABASE_ID   (0x7 | TAG_TYPE_BINARY)
 
#define match_strw_attr   (winetest_set_location(__FILE__, __LINE__), 0) ? (void)0 : match_strw_attr_imp
 
#define match_dw_attr   (winetest_set_location(__FILE__, __LINE__), 0) ? (void)0 : match_dw_attr_imp
 
#define match_qw_attr   (winetest_set_location(__FILE__, __LINE__), 0) ? (void)0 : match_qw_attr_imp
 
#define match_guid_attr   (winetest_set_location(__FILE__, __LINE__), 0) ? (void)0 : match_guid_attr_imp
 
#define expect_indexA   (winetest_set_location(__FILE__, __LINE__), 0) ? (void)0 : expect_indexA_imp
 

Typedefs

typedef struct _DB_INFORMATION DB_INFORMATION
 
typedef struct _DB_INFORMATIONPDB_INFORMATION
 

Functions

static LPCWSTR (WINAPI *pSdbTagToString)(TAG)
 
static PDB (WINAPI *pSdbOpenDatabase)(LPCWSTR
 
static BOOL (WINAPI *pSdbGetDatabaseVersion)(LPCWSTR
 
static void (WINAPI *pSdbCloseDatabase)(PDB)
 
static TAG (WINAPI *pSdbGetTagFromTagID)(PDB
 
static TAGID (WINAPI *pSdbBeginWriteListTag)(PDB
 
static WORD (WINAPI *pSdbReadWORDTag)(PDB
 
static DWORD (WINAPI *pSdbReadDWORDTag)(PDB
 
static QWORD (WINAPI *pSdbReadQWORDTag)(PDB
 
static PVOID (WINAPI *pSdbGetBinaryTagData)(PDB
 
static LPWSTR (WINAPI *pSdbGetStringTagPtr)(PDB
 
static HSDB (WINAPI *pSdbInitDatabase)(DWORD
 
static TAGREF (WINAPI *pSdbGetLayerTagRef)(HSDB hsdb
 
static LONGLONG (WINAPI *pSdbMakeIndexKeyFromString)(LPCWSTR)
 
static VOID (WINAPI *pSdbFreeDatabaseInformation)(PDB_INFORMATION information)
 
 DEFINE_GUID (GUID_DATABASE_TEST, 0xe39b0eb0, 0x55db, 0x450b, 0x9b, 0xd4, 0xd2, 0x0c, 0x94, 0x84, 0x26, 0x0f)
 
 DEFINE_GUID (GUID_MAIN_DATABASE, 0x11111111, 0x1111, 0x1111, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11)
 
static void Write (HANDLE file, LPCVOID buffer, DWORD size)
 
static void test_GetDatabaseInformationEmpty (PDB pdb)
 
static void test_Sdb (void)
 
static void test_write_ex (void)
 
static void write_db_strings (const WCHAR *name, const WCHAR *data[], size_t count)
 
static void test_stringtable ()
 
static void match_strw_attr_imp (PDB pdb, TAGID parent, TAG find, const WCHAR *compare)
 
static void match_dw_attr_imp (PDB pdb, TAGID parent, TAG find, DWORD compare)
 
static void match_qw_attr_imp (PDB pdb, TAGID parent, TAG find, QWORD compare)
 
static void match_guid_attr_imp (PDB pdb, TAGID parent, TAG find, const GUID *compare)
 
static void check_db_properties (PDB pdb, TAGID root)
 
static void check_db_layer (PDB pdb, TAGID layer)
 
static void check_matching_file (PDB pdb, TAGID exe, TAGID matching_file, int num)
 
static void check_matching_apphelp (PDB pdb, TAGID apphelp, int num)
 
static void check_matching_layer (PDB pdb, TAGID layer, int num)
 
static void check_db_exes (PDB pdb, TAGID root)
 
static void check_db_apphelp (PDB pdb, TAGID root)
 
static void test_GetDatabaseInformation (PDB pdb)
 
static void test_CheckDatabaseManually (void)
 
static void test_is_testdb (PDB pdb)
 
static BOOL IsUserAdmin ()
 
template<typename SDBQUERYRESULT_T >
static void check_adwExeFlags (DWORD adwExeFlags_0, SDBQUERYRESULT_T &query, const char *file, int line, size_t cur)
 
template<>
void check_adwExeFlags (DWORD, SDBQUERYRESULT_2k3 &, const char *, int, size_t)
 
template<typename SDBQUERYRESULT_T >
static void test_mode_generic (const WCHAR *workdir, HSDB hsdb, size_t cur)
 
template<typename SDBQUERYRESULT_T >
static void test_MatchApplications (void)
 
static BOOL write_raw_file (const WCHAR *FileName, const void *Data, DWORD Size)
 
static bool extract_resource (const WCHAR *Filename, LPCWSTR ResourceName)
 
template<typename SDBQUERYRESULT_T >
static void test_match_ex (const WCHAR *workdir, HSDB hsdb)
 
template<typename SDBQUERYRESULT_T >
static void test_MatchApplicationsEx (void)
 
static void test_TagRef (void)
 
static void test_DataTags (HSDB hsdb)
 
static void test_Data (void)
 
static void expect_indexA_imp (const char *text, LONGLONG expected)
 
static void test_IndexKeyFromString (void)
 
static int validate_SDBQUERYRESULT_size ()
 
 START_TEST (db)
 

Variables

static HMODULE hdll
 
static PATH_TYPE
 
static PDWORD
 
static TAGID
 
static TAG
 
static WORD
 
static DWORD
 
static QWORD
 
static LPCWSTR
 
static TAGID root
 
static TAGID TAGID find
 
static TAGID TAGID TAGID nametag
 
static TAGID TAGID TAGID LPCWSTR find_name
 
static PBYTE
 
static LPWSTR
 
static GUID *static PCWSTR
 
static GUID *static SIZE_T
 
static LPCWSTR path
 
static LPCWSTR LPCWSTR module_name
 
static LPCWSTR LPCWSTR LPCWSTR env
 
static LPCWSTR LPCWSTR LPCWSTR DWORD flags
 
static LPCWSTR LPCWSTR LPCWSTR DWORD PSDBQUERYRESULT_VISTA result
 
static TAGREF trWhich
 
static TAGREF PDBppdb
 
static TAGREF PDB TAGIDptiWhich
 
static PDB pdb
 
static PDB TAGID tiWhich
 
static PDB TAGID TAGREFptrWhich
 
static LPCWSTR layerName
 
static TAGREF LPCWSTR lpszDataName
 
static TAGREF LPCWSTR LPDWORD lpdwDataType
 
static TAGREF LPCWSTR LPDWORD LPVOID lpBuffer
 
static TAGREF LPCWSTR LPDWORD LPVOID LPDWORD lpcbBufferSize
 
static TAGREF LPCWSTR LPDWORD LPVOID LPDWORD TAGREFptrData
 
static TAGID tiExe
 
static TAGID LPCWSTR LPDWORD LPVOID LPDWORD TAGIDptiData
 
static PDB_INFORMATION information
 
struct {
   const WCHAR *   name
 
   const WCHAR *   app_name
 
   const WCHAR *   vendor
 
   GUID   exe_id
 
   const WCHAR *   extra_file
 
   DWORD   dwLayerCount
 
   TAGREF   atrExes_0
 
   DWORD   adwExeFlags_0
 
   TAGREF   atrLayers_0
 
   TAGREF   trApphelp
 
   const char *   env_var
 
test_exedata [5]
 
struct {
   DWORD   htmlhelpid
 
   const WCHAR *   link
 
   const WCHAR *   apphelp_title
 
   const WCHAR *   apphelp_details
 
test_layerdata [2]
 

Macro Definition Documentation

◆ _TAGID_ROOT

#define _TAGID_ROOT   12

Definition at line 38 of file db.cpp.

◆ DOS_PATH

#define DOS_PATH   0

Definition at line 30 of file db.cpp.

◆ expect_indexA

#define expect_indexA   (winetest_set_location(__FILE__, __LINE__), 0) ? (void)0 : expect_indexA_imp

Definition at line 1970 of file db.cpp.

◆ HID_DATABASE_FULLPATH

#define HID_DATABASE_FULLPATH   2

Definition at line 31 of file db.cpp.

◆ match_dw_attr

#define match_dw_attr   (winetest_set_location(__FILE__, __LINE__), 0) ? (void)0 : match_dw_attr_imp

Definition at line 658 of file db.cpp.

◆ match_guid_attr

#define match_guid_attr   (winetest_set_location(__FILE__, __LINE__), 0) ? (void)0 : match_guid_attr_imp

Definition at line 660 of file db.cpp.

◆ match_qw_attr

#define match_qw_attr   (winetest_set_location(__FILE__, __LINE__), 0) ? (void)0 : match_qw_attr_imp

Definition at line 659 of file db.cpp.

◆ match_strw_attr

#define match_strw_attr   (winetest_set_location(__FILE__, __LINE__), 0) ? (void)0 : match_strw_attr_imp

Definition at line 657 of file db.cpp.

◆ SDB_DATABASE_MAIN_SHIM

#define SDB_DATABASE_MAIN_SHIM   0x80030000

Definition at line 33 of file db.cpp.

◆ TAG_APP_NAME

#define TAG_APP_NAME   (0x6 | TAG_TYPE_STRINGREF)

Definition at line 99 of file db.cpp.

◆ TAG_APP_NAME_RC_ID

#define TAG_APP_NAME_RC_ID   (0x24 | TAG_TYPE_DWORD)

Definition at line 71 of file db.cpp.

◆ TAG_APPHELP

#define TAG_APPHELP   (0xD | TAG_TYPE_LIST)

Definition at line 89 of file db.cpp.

◆ TAG_APPHELP_DETAILS

#define TAG_APPHELP_DETAILS   (0x18 | TAG_TYPE_STRINGREF)

Definition at line 110 of file db.cpp.

◆ TAG_APPHELP_TITLE

#define TAG_APPHELP_TITLE   (0x1B | TAG_TYPE_STRINGREF)

Definition at line 112 of file db.cpp.

◆ TAG_BIN_FILE_VERSION

#define TAG_BIN_FILE_VERSION   (0x2 | TAG_TYPE_QWORD)

Definition at line 77 of file db.cpp.

◆ TAG_BIN_PRODUCT_VERSION

#define TAG_BIN_PRODUCT_VERSION   (0x3 | TAG_TYPE_QWORD)

Definition at line 78 of file db.cpp.

◆ TAG_CHECKSUM

#define TAG_CHECKSUM   (0x3 | TAG_TYPE_DWORD)

Definition at line 59 of file db.cpp.

◆ TAG_COMMAND_LINE

#define TAG_COMMAND_LINE   (0x8 | TAG_TYPE_STRINGREF)

Definition at line 100 of file db.cpp.

◆ TAG_COMPANY_NAME

#define TAG_COMPANY_NAME   (0x9 | TAG_TYPE_STRINGREF)

Definition at line 101 of file db.cpp.

◆ TAG_COMPILER_VERSION

#define TAG_COMPILER_VERSION   (0x22 | TAG_TYPE_STRINGREF)

Definition at line 114 of file db.cpp.

◆ TAG_DATA

#define TAG_DATA   (0xF | TAG_TYPE_LIST)

Definition at line 91 of file db.cpp.

◆ TAG_DATA_BITS

#define TAG_DATA_BITS   (0x5 | TAG_TYPE_BINARY)

Definition at line 119 of file db.cpp.

◆ TAG_DATABASE

#define TAG_DATABASE   (0x1 | TAG_TYPE_LIST)

Definition at line 83 of file db.cpp.

◆ TAG_DATABASE_ID

#define TAG_DATABASE_ID   (0x7 | TAG_TYPE_BINARY)

Definition at line 120 of file db.cpp.

◆ TAG_EXE

#define TAG_EXE   (0x7 | TAG_TYPE_LIST)

Definition at line 85 of file db.cpp.

◆ TAG_EXE_ID

#define TAG_EXE_ID   (0x4 | TAG_TYPE_BINARY)

Definition at line 118 of file db.cpp.

◆ TAG_FILE_DESCRIPTION

#define TAG_FILE_DESCRIPTION   (0x12 | TAG_TYPE_STRINGREF)

Definition at line 105 of file db.cpp.

◆ TAG_FILE_VERSION

#define TAG_FILE_VERSION   (0x13 | TAG_TYPE_STRINGREF)

Definition at line 106 of file db.cpp.

◆ TAG_FLAG_LUA

#define TAG_FLAG_LUA   (0x10 | TAG_TYPE_QWORD)

Definition at line 81 of file db.cpp.

◆ TAG_FLAGS

#define TAG_FLAGS   (0x17 | TAG_TYPE_DWORD)

Definition at line 66 of file db.cpp.

◆ TAG_GENERAL

#define TAG_GENERAL   (0x2 | TAG_TYPE_NULL)

Definition at line 116 of file db.cpp.

◆ TAG_HTMLHELPID

#define TAG_HTMLHELPID   (0x15 | TAG_TYPE_DWORD)

Definition at line 65 of file db.cpp.

◆ TAG_INCLUDE

#define TAG_INCLUDE   (0x1 | TAG_TYPE_NULL)

Definition at line 54 of file db.cpp.

◆ TAG_INEXCLUD

#define TAG_INEXCLUD   (0x3 | TAG_TYPE_LIST)

Definition at line 84 of file db.cpp.

◆ TAG_INTERNAL_NAME

#define TAG_INTERNAL_NAME   (0x15 | TAG_TYPE_STRINGREF)

Definition at line 108 of file db.cpp.

◆ TAG_LAYER

#define TAG_LAYER   (0xB | TAG_TYPE_LIST)

Definition at line 88 of file db.cpp.

◆ TAG_LAYER_TAGID

#define TAG_LAYER_TAGID   (0x1A | TAG_TYPE_DWORD)

Definition at line 67 of file db.cpp.

◆ TAG_LEGAL_COPYRIGHT

#define TAG_LEGAL_COPYRIGHT   (0x16 | TAG_TYPE_STRINGREF)

Definition at line 109 of file db.cpp.

◆ TAG_LINK

#define TAG_LINK   (0xE | TAG_TYPE_LIST)

Definition at line 90 of file db.cpp.

◆ TAG_LINK_DATE

#define TAG_LINK_DATE   (0x1D | TAG_TYPE_DWORD)

Definition at line 69 of file db.cpp.

◆ TAG_LINK_URL

#define TAG_LINK_URL   (0x19 | TAG_TYPE_STRINGREF)

Definition at line 111 of file db.cpp.

◆ TAG_LINKER_VERSION

#define TAG_LINKER_VERSION   (0x1C | TAG_TYPE_DWORD)

Definition at line 68 of file db.cpp.

◆ TAG_MATCH_MODE

#define TAG_MATCH_MODE   (0x1 | TAG_TYPE_WORD)

Definition at line 56 of file db.cpp.

◆ TAG_MATCHING_FILE

#define TAG_MATCHING_FILE   (0x8 | TAG_TYPE_LIST)

Definition at line 86 of file db.cpp.

◆ TAG_MODULE

#define TAG_MODULE   (0x3 | TAG_TYPE_STRINGREF)

Definition at line 97 of file db.cpp.

◆ TAG_MODULE_TYPE

#define TAG_MODULE_TYPE   (0x6 | TAG_TYPE_DWORD)

Definition at line 60 of file db.cpp.

◆ TAG_NAME

#define TAG_NAME   (0x1 | TAG_TYPE_STRINGREF)

Definition at line 96 of file db.cpp.

◆ TAG_NULL

#define TAG_NULL   0x0

Definition at line 52 of file db.cpp.

◆ TAG_ORIGINAL_FILENAME

#define TAG_ORIGINAL_FILENAME   (0x14 | TAG_TYPE_STRINGREF)

Definition at line 107 of file db.cpp.

◆ TAG_OS_PLATFORM

#define TAG_OS_PLATFORM   (0x23 | TAG_TYPE_DWORD)

Definition at line 74 of file db.cpp.

◆ TAG_PE_CHECKSUM

#define TAG_PE_CHECKSUM   (0xB | TAG_TYPE_DWORD)

Definition at line 63 of file db.cpp.

◆ TAG_PROBLEMSEVERITY

#define TAG_PROBLEMSEVERITY   (0x10 | TAG_TYPE_DWORD)

Definition at line 64 of file db.cpp.

◆ TAG_PRODUCT_NAME

#define TAG_PRODUCT_NAME   (0x10 | TAG_TYPE_STRINGREF)

Definition at line 103 of file db.cpp.

◆ TAG_PRODUCT_VERSION

#define TAG_PRODUCT_VERSION   (0x11 | TAG_TYPE_STRINGREF)

Definition at line 104 of file db.cpp.

◆ TAG_SHIM_REF

#define TAG_SHIM_REF   (0x9| TAG_TYPE_LIST)

Definition at line 87 of file db.cpp.

◆ TAG_SIZE

#define TAG_SIZE   (0x1 | TAG_TYPE_DWORD)

Definition at line 58 of file db.cpp.

◆ TAG_STRINGTABLE

#define TAG_STRINGTABLE   (0x801 | TAG_TYPE_LIST)

Definition at line 92 of file db.cpp.

◆ TAG_STRINGTABLE_ITEM

#define TAG_STRINGTABLE_ITEM   (0x801 | TAG_TYPE_STRING)

Definition at line 94 of file db.cpp.

◆ TAG_SUMMARY_MSG_RC_ID

#define TAG_SUMMARY_MSG_RC_ID   (0x26 | TAG_TYPE_DWORD)

Definition at line 73 of file db.cpp.

◆ TAG_TIME

#define TAG_TIME   (0x1 | TAG_TYPE_QWORD)

Definition at line 76 of file db.cpp.

◆ TAG_TYPE_BINARY

#define TAG_TYPE_BINARY   0x9000

Definition at line 51 of file db.cpp.

◆ TAG_TYPE_BYTE

#define TAG_TYPE_BYTE   0x2000

Definition at line 44 of file db.cpp.

◆ TAG_TYPE_DWORD

#define TAG_TYPE_DWORD   0x4000

Definition at line 46 of file db.cpp.

◆ TAG_TYPE_LIST

#define TAG_TYPE_LIST   0x7000

Definition at line 49 of file db.cpp.

◆ TAG_TYPE_MASK

#define TAG_TYPE_MASK   0xF000

Definition at line 41 of file db.cpp.

◆ TAG_TYPE_NULL

#define TAG_TYPE_NULL   0x1000

Definition at line 43 of file db.cpp.

◆ TAG_TYPE_QWORD

#define TAG_TYPE_QWORD   0x5000

Definition at line 47 of file db.cpp.

◆ TAG_TYPE_STRING

#define TAG_TYPE_STRING   0x8000

Definition at line 50 of file db.cpp.

◆ TAG_TYPE_STRINGREF

#define TAG_TYPE_STRINGREF   0x6000

Definition at line 48 of file db.cpp.

◆ TAG_TYPE_WORD

#define TAG_TYPE_WORD   0x3000

Definition at line 45 of file db.cpp.

◆ TAG_UPTO_BIN_FILE_VERSION

#define TAG_UPTO_BIN_FILE_VERSION   (0xD | TAG_TYPE_QWORD)

Definition at line 80 of file db.cpp.

◆ TAG_UPTO_BIN_PRODUCT_VERSION

#define TAG_UPTO_BIN_PRODUCT_VERSION   (0x6 | TAG_TYPE_QWORD)

Definition at line 79 of file db.cpp.

◆ TAG_UPTO_LINK_DATE

#define TAG_UPTO_LINK_DATE   (0x1E | TAG_TYPE_DWORD)

Definition at line 70 of file db.cpp.

◆ TAG_VENDOR

#define TAG_VENDOR   (0x5 | TAG_TYPE_STRINGREF)

Definition at line 98 of file db.cpp.

◆ TAG_VENDOR_NAME_RC_ID

#define TAG_VENDOR_NAME_RC_ID   (0x25 | TAG_TYPE_DWORD)

Definition at line 72 of file db.cpp.

◆ TAG_VERFILEOS

#define TAG_VERFILEOS   (0x9 | TAG_TYPE_DWORD)

Definition at line 61 of file db.cpp.

◆ TAG_VERFILETYPE

#define TAG_VERFILETYPE   (0xA | TAG_TYPE_DWORD)

Definition at line 62 of file db.cpp.

◆ TAG_WILDCARD_NAME

#define TAG_WILDCARD_NAME   (0xB | TAG_TYPE_STRINGREF)

Definition at line 102 of file db.cpp.

◆ TAGID_NULL

#define TAGID_NULL   0x0

Definition at line 36 of file db.cpp.

◆ TAGID_ROOT

#define TAGID_ROOT   0x0

Definition at line 37 of file db.cpp.

◆ WIN32_NO_STATUS

#define WIN32_NO_STATUS

Definition at line 11 of file db.cpp.

Typedef Documentation

◆ DB_INFORMATION

◆ PDB_INFORMATION

Function Documentation

◆ BOOL()

static BOOL ( WINAPI pSdbGetDatabaseVersion)
static

◆ check_adwExeFlags() [1/2]

template<typename SDBQUERYRESULT_T >
static void check_adwExeFlags ( DWORD  adwExeFlags_0,
SDBQUERYRESULT_T &  query,
const char file,
int  line,
size_t  cur 
)
static

Definition at line 1207 of file db.cpp.

1208 {
1209  ok_(file, line)(query.adwExeFlags[0] == adwExeFlags_0, "Expected adwExeFlags[0] to be 0x%x, was: 0x%x for %d\n", adwExeFlags_0, query.adwExeFlags[0], cur);
1210  for (size_t n = 1; n < _countof(query.atrExes); ++n)
1211  ok_(file, line)(query.adwExeFlags[n] == 0, "Expected adwExeFlags[%d] to be 0, was: %x for %d\n", n, query.adwExeFlags[0], cur);
1212 }
GLdouble n
Definition: glext.h:7729
DWORD adwExeFlags_0
Definition: db.cpp:869
Definition: parser.c:48
#define _countof(array)
Definition: sndvol32.h:68
#define ok_(x1, x2)
Definition: atltest.h:61
Definition: fci.c:126

Referenced by test_mode_generic().

◆ check_adwExeFlags() [2/2]

template<>
void check_adwExeFlags ( DWORD  ,
SDBQUERYRESULT_2k3 ,
const char ,
int  ,
size_t   
)

Definition at line 1215 of file db.cpp.

1216 {
1217 }

◆ check_db_apphelp()

static void check_db_apphelp ( PDB  pdb,
TAGID  root 
)
static

Definition at line 1007 of file db.cpp.

1008 {
1009  int num = 0;
1010  TAGID apphelp = pSdbFindFirstTag(pdb, root, TAG_APPHELP);
1011  while (apphelp != TAGID_NULL)
1012  {
1013  TAGID link;
1014  ok(num < 2, "Too many matches, expected only 4!\n");
1015  if (num >= 2)
1016  break;
1018  link = pSdbFindFirstTag(pdb, apphelp, TAG_LINK);
1019  ok(link != TAGID_NULL, "expected to find a link tag\n");
1020  if (link != TAGID_NULL)
1021  {
1023  }
1026  apphelp = pSdbFindNextTag(pdb, root, apphelp);
1027  num++;
1028  }
1029  ok(num == 2, "Expected to find 2 layer tags, found: %d\n", num);
1030 }
#define TAG_HTMLHELPID
Definition: db.cpp:65
static PDB pdb
Definition: db.cpp:170
#define TAG_LINK
Definition: db.cpp:90
const WCHAR * apphelp_details
Definition: db.cpp:991
#define TAG_LINK_URL
Definition: db.cpp:111
const WCHAR * apphelp_title
Definition: db.cpp:990
DWORD htmlhelpid
Definition: db.cpp:988
#define TAG_APPHELP_DETAILS
Definition: db.cpp:110
#define match_strw_attr
Definition: db.cpp:657
GLuint GLuint num
Definition: glext.h:9618
#define TAGID_NULL
Definition: db.cpp:36
#define TAG_APPHELP_TITLE
Definition: db.cpp:112
static struct @1581 test_layerdata[2]
#define ok(value,...)
Definition: atltest.h:57
#define TAG_APPHELP
Definition: db.cpp:89
const WCHAR * link
Definition: db.cpp:989
DWORD TAGID
#define match_dw_attr
Definition: db.cpp:658

Referenced by test_CheckDatabaseManually().

◆ check_db_exes()

static void check_db_exes ( PDB  pdb,
TAGID  root 
)
static

Definition at line 941 of file db.cpp.

942 {
943  int num = 0;
944  TAGID exe = pSdbFindFirstTag(pdb, root, TAG_EXE);
945  TAGID altExe = pSdbFindFirstNamedTag(pdb, root, TAG_EXE, TAG_NAME, L"test_allow.exe");
946  ok_hex(altExe, (int)exe);
947  while (exe != TAGID_NULL)
948  {
949  TAGID apphelp, layer;
950  ok(num < 4, "Too many matches, expected only 4!\n");
951  if (num >= 4)
952  break;
957  check_matching_file(pdb, exe, pSdbFindFirstTag(pdb, exe, TAG_MATCHING_FILE), num);
958  apphelp = pSdbFindFirstTag(pdb, exe, TAG_APPHELP);
959  if (num == 0 || num == 1)
960  {
961  ok(apphelp != TAGID_NULL, "Expected to find a valid apphelp match on %d.\n", num);
962  if (apphelp)
963  check_matching_apphelp(pdb, apphelp, num);
964  }
965  else
966  {
967  ok(apphelp == TAGID_NULL, "Did not expect an apphelp match on %d\n", num);
968  }
969  layer = pSdbFindFirstTag(pdb, exe, TAG_LAYER);
970  if (num == 2 || num == 3)
971  {
972  ok(layer != TAGID_NULL, "Expected to find a valid layer match on %d.\n", num);
973  if (layer)
975  }
976  else
977  {
978  ok(layer == TAGID_NULL, "Did not expect a layer match on %d\n", num);
979  }
980  ++num;
981  exe = pSdbFindNextTag(pdb, root, exe);
982  }
983  ok(num == 4, "Expected to find 4 exe tags, found: %d\n", num);
984 }
static PDB pdb
Definition: db.cpp:170
#define TAG_EXE_ID
Definition: db.cpp:118
static void check_matching_apphelp(PDB pdb, TAGID apphelp, int num)
Definition: db.cpp:797
const WCHAR * app_name
Definition: db.cpp:863
#define TAG_APP_NAME
Definition: db.cpp:99
static void check_matching_layer(PDB pdb, TAGID layer, int num)
Definition: db.cpp:845
#define ok_hex(expression, result)
Definition: atltest.h:94
#define TAG_MATCHING_FILE
Definition: db.cpp:86
#define TAG_VENDOR
Definition: db.cpp:98
#define TAG_EXE
Definition: db.cpp:85
static void check_matching_file(PDB pdb, TAGID exe, TAGID matching_file, int num)
Definition: db.cpp:730
#define match_strw_attr
Definition: db.cpp:657
GLenum GLuint GLint GLint layer
Definition: glext.h:7007
const WCHAR * vendor
Definition: db.cpp:864
GLuint GLuint num
Definition: glext.h:9618
static const WCHAR L[]
Definition: oid.c:1250
static struct @1580 test_exedata[5]
#define TAGID_NULL
Definition: db.cpp:36
#define ok(value,...)
Definition: atltest.h:57
#define TAG_LAYER
Definition: db.cpp:88
#define TAG_NAME
Definition: db.cpp:96
#define TAG_APPHELP
Definition: db.cpp:89
Definition: name.c:38
#define match_guid_attr
Definition: db.cpp:660
DWORD TAGID
GUID exe_id
Definition: db.cpp:865

Referenced by test_CheckDatabaseManually().

◆ check_db_layer()

static void check_db_layer ( PDB  pdb,
TAGID  layer 
)
static

Definition at line 696 of file db.cpp.

697 {
698  TAGID shimref, inexclude, is_include;
699  ok(layer != TAGID_NULL, "Expected a valid layer, got NULL\n");
700  if (!layer)
701  return;
702 
703  match_strw_attr(pdb, layer, TAG_NAME, L"TestNewMode");
704  shimref = pSdbFindFirstTag(pdb, layer, TAG_SHIM_REF);
705  ok(shimref != TAGID_NULL, "Expected a valid shim ref, got NULL\n");
706  if (!shimref)
707  return;
708 
709  match_strw_attr(pdb, shimref, TAG_NAME, L"VirtualRegistry");
710  match_strw_attr(pdb, shimref, TAG_COMMAND_LINE, L"ThemeActive");
711  inexclude = pSdbFindFirstTag(pdb, shimref, TAG_INEXCLUD);
712  ok(inexclude != TAGID_NULL, "Expected a valid in/exclude ref, got NULL\n");
713  if (!inexclude)
714  return;
715 
716  is_include = pSdbFindFirstTag(pdb, inexclude, TAG_INCLUDE);
717  ok(is_include == TAGID_NULL, "Expected a NULL include ref, but got one anyway.\n");
718  match_strw_attr(pdb, inexclude, TAG_MODULE, L"exclude.dll");
719 
720  inexclude = pSdbFindNextTag(pdb, shimref, inexclude);
721  ok(inexclude != TAGID_NULL, "Expected a valid in/exclude ref, got NULL\n");
722  if (!inexclude)
723  return;
724 
725  is_include = pSdbFindFirstTag(pdb, inexclude, TAG_INCLUDE);
726  ok(is_include != TAGID_NULL, "Expected a valid include ref, got NULL\n");
727  match_strw_attr(pdb, inexclude, TAG_MODULE, L"include.dll");
728 }
#define TAG_INCLUDE
Definition: db.cpp:54
static PDB pdb
Definition: db.cpp:170
#define TAG_COMMAND_LINE
Definition: db.cpp:100
#define TAG_INEXCLUD
Definition: db.cpp:84
#define TAG_MODULE
Definition: db.cpp:97
#define match_strw_attr
Definition: db.cpp:657
GLenum GLuint GLint GLint layer
Definition: glext.h:7007
static const WCHAR L[]
Definition: oid.c:1250
#define TAG_SHIM_REF
Definition: db.cpp:87
#define TAGID_NULL
Definition: db.cpp:36
#define ok(value,...)
Definition: atltest.h:57
#define TAG_NAME
Definition: db.cpp:96
DWORD TAGID

Referenced by test_CheckDatabaseManually().

◆ check_db_properties()

static void check_db_properties ( PDB  pdb,
TAGID  root 
)
static

Definition at line 666 of file db.cpp.

667 {
668  TAGID iter = pSdbFindFirstTag(pdb, root, TAG_DATABASE_ID);
669  ok(iter != TAGID_NULL, "expected a result, got TAGID_NULL\n");
670  if (iter != TAGID_NULL)
671  {
672  GUID guid = { 0 }, guid2 = { 0 };
673  BOOL result = pSdbReadBinaryTag(pdb, iter, (PBYTE)&guid, sizeof(guid));
674  ok(result, "expected SdbReadBinaryTag not to fail.\n");
675  if (result)
676  {
677  WCHAR guid_wstr[50];
678  result = pSdbGUIDToString(&guid, guid_wstr, 50);
679  ok(result, "expected SdbGUIDToString not to fail.\n");
680  if (result)
681  {
682  char guid_str[50];
683  WideCharToMultiByte(CP_ACP, 0, guid_wstr, -1, guid_str, sizeof(guid_str), NULL, NULL);
684  ok_str(guid_str, "{e39b0eb0-55db-450b-9bd4-d20c9484260f}");
685  }
686  ok(pSdbGetDatabaseID(pdb, &guid2), "expected SdbGetDatabaseID not to fail.\n");
687  ok(IsEqualGUID(guid, guid2), "expected guids to be equal(%s:%s)\n", wine_dbgstr_guid(&guid), wine_dbgstr_guid(&guid2));
688  }
689  }
690  match_qw_attr(pdb, root, TAG_TIME, 0x1d1b91a02c0d63e);
692  match_strw_attr(pdb, root, TAG_NAME, L"apphelp_test1");
694 }
#define TAG_OS_PLATFORM
Definition: db.cpp:74
static PDB pdb
Definition: db.cpp:170
#define ok_str(x, y)
Definition: atltest.h:127
#define WideCharToMultiByte
Definition: compat.h:101
#define CP_ACP
Definition: compat.h:99
const char * wine_dbgstr_guid(const GUID *guid)
#define match_qw_attr
Definition: db.cpp:659
static GUID guid2
Definition: devinst.c:42
const GUID * guid
unsigned int BOOL
Definition: ntddk_ex.h:94
smooth NULL
Definition: ftsmooth.c:416
#define match_strw_attr
Definition: db.cpp:657
__wchar_t WCHAR
Definition: xmlstorage.h:180
static const WCHAR L[]
Definition: oid.c:1250
#define TAGID_NULL
Definition: db.cpp:36
#define ok(value,...)
Definition: atltest.h:57
#define TAG_NAME
Definition: db.cpp:96
#define TAG_TIME
Definition: db.cpp:76
BOOL WINAPI IsEqualGUID(REFGUID rguid1, REFGUID rguid2)
Definition: compobj.c:4112
#define TAG_COMPILER_VERSION
Definition: db.cpp:114
#define TAG_DATABASE_ID
Definition: db.cpp:120
DWORD TAGID
#define match_dw_attr
Definition: db.cpp:658
GLuint64EXT * result
Definition: glext.h:11304
BYTE * PBYTE
Definition: pedump.c:66

Referenced by test_CheckDatabaseManually().

◆ check_matching_apphelp()

static void check_matching_apphelp ( PDB  pdb,
TAGID  apphelp,
int  num 
)
static

Definition at line 797 of file db.cpp.

798 {
799  if (num == 0)
800  {
801 /*
802 [Window Title]
803 Program Compatibility Assistant
804 
805 [Main Instruction]
806 This program has known compatibility issues
807 
808 [Expanded Information]
809 Allow it!
810 
811 [^] Hide details [ ] Don't show this message again [Check for solutions online] [Run program] [Cancel]
812 */
813  match_dw_attr(pdb, apphelp, TAG_FLAGS, 1);
814  match_dw_attr(pdb, apphelp, TAG_PROBLEMSEVERITY, 1);
815  match_dw_attr(pdb, apphelp, TAG_HTMLHELPID, 1);
816  match_dw_attr(pdb, apphelp, TAG_APP_NAME_RC_ID, 0x6f0072);
817  match_dw_attr(pdb, apphelp, TAG_VENDOR_NAME_RC_ID, 0x720067);
819  }
820  else
821  {
822 /*
823 [Window Title]
824 Program Compatibility Assistant
825 
826 [Main Instruction]
827 This program is blocked due to compatibility issues
828 
829 [Expanded Information]
830 Not allowed!
831 
832 [^] Hide details [Check for solutions online] [Cancel]
833 */
834  match_dw_attr(pdb, apphelp, TAG_FLAGS, 1);
835  match_dw_attr(pdb, apphelp, TAG_PROBLEMSEVERITY, 2);
836  match_dw_attr(pdb, apphelp, TAG_HTMLHELPID, 2);
837  match_dw_attr(pdb, apphelp, TAG_APP_NAME_RC_ID, 0x320020);
838  match_dw_attr(pdb, apphelp, TAG_VENDOR_NAME_RC_ID, 0x38002e);
840  }
841  apphelp = pSdbFindNextTag(pdb, apphelp, apphelp);
842  ok(apphelp == TAGID_NULL, "Did not expect a secondary match on %d\n", num);
843 }
#define TAG_HTMLHELPID
Definition: db.cpp:65
static PDB pdb
Definition: db.cpp:170
#define TAG_PROBLEMSEVERITY
Definition: db.cpp:64
#define TAG_APP_NAME_RC_ID
Definition: db.cpp:71
GLuint GLuint num
Definition: glext.h:9618
#define TAG_VENDOR_NAME_RC_ID
Definition: db.cpp:72
#define TAG_FLAGS
Definition: db.cpp:66
#define TAG_SUMMARY_MSG_RC_ID
Definition: db.cpp:73
#define TAGID_NULL
Definition: db.cpp:36
#define ok(value,...)
Definition: atltest.h:57
#define match_dw_attr
Definition: db.cpp:658

Referenced by check_db_exes().

◆ check_matching_file()

static void check_matching_file ( PDB  pdb,
TAGID  exe,
TAGID  matching_file,
int  num 
)
static

Definition at line 730 of file db.cpp.

731 {
732  ok(matching_file != TAGID_NULL, "Expected to find atleast 1 matching file.\n");
733  if (matching_file == TAGID_NULL)
734  return;
735 
736  ok(num < 4, "Too many matches, expected only 4!\n");
737  if (num >= 4)
738  return;
739 
740 
741  match_strw_attr(pdb, matching_file, TAG_NAME, L"*");
742  match_strw_attr(pdb, matching_file, TAG_COMPANY_NAME, L"CompanyName");
743  match_strw_attr(pdb, matching_file, TAG_PRODUCT_NAME, L"ProductName");
744  match_strw_attr(pdb, matching_file, TAG_PRODUCT_VERSION, L"1.0.0.1");
745  match_strw_attr(pdb, matching_file, TAG_FILE_VERSION, L"1.0.0.0");
746 
747  if (num == 0 || num == 3)
748  {
749  match_qw_attr(pdb, matching_file, TAG_UPTO_BIN_PRODUCT_VERSION, 0x1000000000001);
750  match_qw_attr(pdb, matching_file, TAG_UPTO_BIN_FILE_VERSION, 0x1000000000000);
751  }
752  if (num == 1 || num == 3)
753  {
754  match_dw_attr(pdb, matching_file, TAG_PE_CHECKSUM, 0xbaad);
755  }
756  if (num != 0)
757  {
758  match_qw_attr(pdb, matching_file, TAG_BIN_PRODUCT_VERSION, 0x1000000000001);
759  match_qw_attr(pdb, matching_file, TAG_BIN_FILE_VERSION, 0x1000000000000);
760  }
761  if (num == 3)
762  {
763  match_dw_attr(pdb, matching_file, TAG_SIZE, 0x800);
764  match_dw_attr(pdb, matching_file, TAG_CHECKSUM, 0x178bd629);
765  match_strw_attr(pdb, matching_file, TAG_FILE_DESCRIPTION, L"FileDescription");
766  match_dw_attr(pdb, matching_file, TAG_MODULE_TYPE, 3);
767  match_dw_attr(pdb, matching_file, TAG_VERFILEOS, 4);
768  match_dw_attr(pdb, matching_file, TAG_VERFILETYPE, 1);
769  match_dw_attr(pdb, matching_file, TAG_LINKER_VERSION, 0x40002);
770  match_strw_attr(pdb, matching_file, TAG_ORIGINAL_FILENAME, L"OriginalFilename");
771  match_strw_attr(pdb, matching_file, TAG_INTERNAL_NAME, L"InternalName");
772  match_strw_attr(pdb, matching_file, TAG_LEGAL_COPYRIGHT, L"LegalCopyright");
773  match_dw_attr(pdb, matching_file, TAG_LINK_DATE, 0x12345);
774  match_dw_attr(pdb, matching_file, TAG_UPTO_LINK_DATE, 0x12345);
775  }
776  if (num > 3)
777  {
778  ok(0, "unknown case: %d\n", num);
779  }
780  matching_file = pSdbFindNextTag(pdb, exe, matching_file);
781  if (num == 2)
782  {
783  ok(matching_file != TAGID_NULL, "Did expect a secondary match on %d\n", num);
784  match_strw_attr(pdb, matching_file, TAG_NAME, L"test_checkfile.txt");
785  match_dw_attr(pdb, matching_file, TAG_SIZE, 0x4);
786  match_dw_attr(pdb, matching_file, TAG_CHECKSUM, 0xb0b0b0b0);
787  }
788  else
789  {
790  ok(matching_file == TAGID_NULL, "Did not expect a secondary match on %d\n", num);
791  }
792 }
#define TAG_BIN_FILE_VERSION
Definition: db.cpp:77
#define TAG_INTERNAL_NAME
Definition: db.cpp:108
#define TAG_UPTO_BIN_PRODUCT_VERSION
Definition: db.cpp:79
static PDB pdb
Definition: db.cpp:170
#define TAG_PE_CHECKSUM
Definition: db.cpp:63
#define TAG_MODULE_TYPE
Definition: db.cpp:60
#define TAG_CHECKSUM
Definition: db.cpp:59
#define TAG_PRODUCT_NAME
Definition: db.cpp:103
#define TAG_BIN_PRODUCT_VERSION
Definition: db.cpp:78
#define TAG_UPTO_LINK_DATE
Definition: db.cpp:70
#define match_qw_attr
Definition: db.cpp:659
#define TAG_LINKER_VERSION
Definition: db.cpp:68
#define TAG_ORIGINAL_FILENAME
Definition: db.cpp:107
#define TAG_SIZE
Definition: db.cpp:58
#define TAG_LINK_DATE
Definition: db.cpp:69
#define match_strw_attr
Definition: db.cpp:657
#define TAG_FILE_DESCRIPTION
Definition: db.cpp:105
#define TAG_VERFILEOS
Definition: db.cpp:61
GLuint GLuint num
Definition: glext.h:9618
static const WCHAR L[]
Definition: oid.c:1250
#define TAGID_NULL
Definition: db.cpp:36
#define TAG_COMPANY_NAME
Definition: db.cpp:101
#define ok(value,...)
Definition: atltest.h:57
#define TAG_NAME
Definition: db.cpp:96
#define TAG_UPTO_BIN_FILE_VERSION
Definition: db.cpp:80
#define TAG_VERFILETYPE
Definition: db.cpp:62
#define match_dw_attr
Definition: db.cpp:658
#define TAG_PRODUCT_VERSION
Definition: db.cpp:104
#define TAG_LEGAL_COPYRIGHT
Definition: db.cpp:109
#define TAG_FILE_VERSION
Definition: db.cpp:106

Referenced by check_db_exes().

◆ check_matching_layer()

static void check_matching_layer ( PDB  pdb,
TAGID  layer,
int  num 
)
static

Definition at line 845 of file db.cpp.

846 {
847  if (num == 2)
848  {
850  match_strw_attr(pdb, layer, TAG_NAME, L"TestNewMode");
851  }
852  else
853  {
854  TAGID layer_tagid = pSdbFindFirstTag(pdb, layer, TAG_LAYER_TAGID);
855  ok(layer_tagid == TAGID_NULL, "expected not to find a layer tagid, got %x\n", layer_tagid);
856  match_strw_attr(pdb, layer, TAG_NAME, L"WinSrv03");
857  }
858 }
static PDB pdb
Definition: db.cpp:170
#define TAG_LAYER_TAGID
Definition: db.cpp:67
#define match_strw_attr
Definition: db.cpp:657
GLenum GLuint GLint GLint layer
Definition: glext.h:7007
GLuint GLuint num
Definition: glext.h:9618
static const WCHAR L[]
Definition: oid.c:1250
#define TAGID_NULL
Definition: db.cpp:36
#define ok(value,...)
Definition: atltest.h:57
#define TAG_NAME
Definition: db.cpp:96
DWORD TAGID
#define match_dw_attr
Definition: db.cpp:658

Referenced by check_db_exes().

◆ DEFINE_GUID() [1/2]

DEFINE_GUID ( GUID_DATABASE_TEST  ,
0xe39b0eb0  ,
0x55db  ,
0x450b  ,
0x9b  ,
0xd4  ,
0xd2  ,
0x0c  ,
0x94  ,
0x84  ,
0x26  ,
0x0f   
)

◆ DEFINE_GUID() [2/2]

DEFINE_GUID ( GUID_MAIN_DATABASE  ,
0x11111111  ,
0x1111  ,
0x1111  ,
0x11  ,
0x11  ,
0x11  ,
0x11  ,
0x11  ,
0x11  ,
0x11  ,
0x11   
)

◆ DWORD()

static DWORD ( WINAPI pSdbReadDWORDTag)
static

◆ expect_indexA_imp()

static void expect_indexA_imp ( const char text,
LONGLONG  expected 
)
static

Definition at line 1960 of file db.cpp.

1961 {
1962  static WCHAR wide_string[100] = { 0 };
1963  LONGLONG result;
1964  MultiByteToWideChar(CP_ACP, 0, text, -1, wide_string, 100);
1965 
1966  result = pSdbMakeIndexKeyFromString(wide_string);
1967  winetest_ok(result == expected, "Expected %s to result in %s, was: %s\n", text, wine_dbgstr_longlong(expected), wine_dbgstr_longlong(result));
1968 }
const WCHAR * text
Definition: package.c:1827
#define CP_ACP
Definition: compat.h:99
int64_t LONGLONG
Definition: typedefs.h:67
__wchar_t WCHAR
Definition: xmlstorage.h:180
void __winetest_cdecl winetest_ok(int condition, const char *msg,...)
#define MultiByteToWideChar
Definition: compat.h:100
static LPCWSTR LPCWSTR LPCWSTR DWORD PSDBQUERYRESULT_VISTA result
Definition: db.cpp:168
static __inline const char * wine_dbgstr_longlong(ULONGLONG ll)
Definition: compat.h:41
GLuint64EXT * result
Definition: glext.h:11304
BOOL expected
Definition: store.c:2063

◆ extract_resource()

static bool extract_resource ( const WCHAR Filename,
LPCWSTR  ResourceName 
)
static

Definition at line 1460 of file db.cpp.

1461 {
1462  HMODULE hMod = GetModuleHandleW(NULL);
1463  HRSRC hRsrc = FindResourceW(hMod, ResourceName, MAKEINTRESOURCEW(RT_RCDATA));
1464  ok(!!hRsrc, "Unable to find %s\n", wine_dbgstr_w(ResourceName));
1465  if (!hRsrc)
1466  return false;
1467 
1468  HGLOBAL hGlobal = LoadResource(hMod, hRsrc);
1469  DWORD Size = SizeofResource(hMod, hRsrc);
1470  LPVOID pData = LockResource(hGlobal);
1471 
1472  ok(Size && !!pData, "Unable to load %s\n", wine_dbgstr_w(ResourceName));
1473  if (!Size || !pData)
1474  return false;
1475 
1476  BOOL Written = write_raw_file(Filename, pData, Size);
1478  return Written;
1479 }
char * wine_dbgstr_w(const wchar_t *wstr)
Definition: atltest.h:87
LPVOID WINAPI LockResource(HGLOBAL handle)
Definition: res.c:550
HRSRC WINAPI FindResourceW(HINSTANCE hModule, LPCWSTR name, LPCWSTR type)
Definition: res.c:176
IN PVCB IN PBCB OUT PDIRENT IN USHORT IN POEM_STRING Filename
Definition: fatprocs.h:934
#define UnlockResource(h)
Definition: winbase.h:3212
unsigned int BOOL
Definition: ntddk_ex.h:94
HGLOBAL WINAPI LoadResource(HINSTANCE hModule, HRSRC hRsrc)
Definition: res.c:532
smooth NULL
Definition: ftsmooth.c:416
unsigned long DWORD
Definition: ntddk_ex.h:95
#define RT_RCDATA
Definition: pedump.c:372
static BOOL write_raw_file(const WCHAR *FileName, const void *Data, DWORD Size)
Definition: db.cpp:1442
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:361
#define ok(value,...)
Definition: atltest.h:57
DWORD WINAPI SizeofResource(HINSTANCE hModule, HRSRC hRsrc)
Definition: res.c:568
HMODULE WINAPI GetModuleHandleW(LPCWSTR lpModuleName)
Definition: loader.c:838
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
TW_UINT32 TW_UINT16 TW_UINT16 TW_MEMREF pData
Definition: twain.h:1827

Referenced by START_TEST(), test_Data(), and test_MatchApplicationsEx().

◆ HSDB()

static HSDB ( WINAPI pSdbInitDatabase)
static

◆ IsUserAdmin()

static BOOL IsUserAdmin ( )
static

Definition at line 1184 of file db.cpp.

1185 {
1186  BOOL Result;
1188  PSID AdministratorsGroup;
1189 
1193  0, 0, 0, 0, 0, 0,
1194  &AdministratorsGroup);
1195  if (Result)
1196  {
1197  if (!CheckTokenMembership( NULL, AdministratorsGroup, &Result))
1198  Result = FALSE;
1199  FreeSid(AdministratorsGroup);
1200  }
1201 
1202  return Result;
1203 }
BOOL WINAPI CheckTokenMembership(IN HANDLE ExistingTokenHandle, IN PSID SidToCheck, OUT PBOOL IsMember)
Definition: token.c:21
unsigned int BOOL
Definition: ntddk_ex.h:94
PVOID WINAPI FreeSid(PSID pSid)
Definition: security.c:577
smooth NULL
Definition: ftsmooth.c:416
_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:426
#define SECURITY_NT_AUTHORITY
Definition: setypes.h:526
#define SECURITY_BUILTIN_DOMAIN_RID
Definition: setypes.h:553
#define DOMAIN_ALIAS_RID_ADMINS
Definition: setypes.h:624
SID_IDENTIFIER_AUTHORITY NtAuthority
Definition: database.c:19
BOOL WINAPI AllocateAndInitializeSid(PSID_IDENTIFIER_AUTHORITY pIdentifierAuthority, BYTE nSubAuthorityCount, DWORD nSubAuthority0, DWORD nSubAuthority1, DWORD nSubAuthority2, DWORD nSubAuthority3, DWORD nSubAuthority4, DWORD nSubAuthority5, DWORD nSubAuthority6, DWORD nSubAuthority7, PSID *pSid)
Definition: security.c:553

Referenced by test_mode_generic().

◆ LONGLONG()

static LONGLONG ( WINAPI pSdbMakeIndexKeyFromString)
static

◆ LPCWSTR()

static LPCWSTR ( WINAPI pSdbTagToString)
static

◆ LPWSTR()

static LPWSTR ( WINAPI pSdbGetStringTagPtr)
static

◆ match_dw_attr_imp()

static void match_dw_attr_imp ( PDB  pdb,
TAGID  parent,
TAG  find,
DWORD  compare 
)
static

Definition at line 622 of file db.cpp.

623 {
624  TAGID attr = pSdbFindFirstTag(pdb, parent, find);
625  winetest_ok(attr != TAG_NULL, "Could not find: %x\n", find);
626  if (attr != TAG_NULL)
627  {
628  DWORD val = pSdbReadDWORDTag(pdb, attr, 0x1234567);
629  winetest_ok(val == compare, "Expected tagid %x to be 0x%x, was 0x%x\n", attr, compare, val);
630  }
631 }
Definition: bug.cpp:7
static PDB pdb
Definition: db.cpp:170
GLuint GLfloat * val
Definition: glext.h:7180
r parent
Definition: btrfs.c:2944
void __winetest_cdecl winetest_ok(int condition, const char *msg,...)
unsigned long DWORD
Definition: ntddk_ex.h:95
Definition: cookie.c:201
static TAGID TAGID find
Definition: db.cpp:153
#define TAG_NULL
Definition: db.cpp:52
DWORD TAGID

◆ match_guid_attr_imp()

static void match_guid_attr_imp ( PDB  pdb,
TAGID  parent,
TAG  find,
const GUID compare 
)
static

Definition at line 644 of file db.cpp.

645 {
646  TAGID attr = pSdbFindFirstTag(pdb, parent, find);
647  winetest_ok(attr != TAG_NULL, "Could not find: %x\n", find);
648  if (attr != TAG_NULL)
649  {
650  GUID guid = { 0 };
651  BOOL result = pSdbReadBinaryTag(pdb, attr, (PBYTE)&guid, sizeof(guid));
652  winetest_ok(result, "expected pSdbReadBinaryTag not to fail.\n");
653  winetest_ok(IsEqualGUID(guid, *compare), "expected guids to be equal(%s:%s)\n", wine_dbgstr_guid(&guid), wine_dbgstr_guid(compare));
654  }
655 }
Definition: bug.cpp:7
static PDB pdb
Definition: db.cpp:170
const char * wine_dbgstr_guid(const GUID *guid)
const GUID * guid
unsigned int BOOL
Definition: ntddk_ex.h:94
r parent
Definition: btrfs.c:2944
void __winetest_cdecl winetest_ok(int condition, const char *msg,...)
Definition: cookie.c:201
BOOL WINAPI IsEqualGUID(REFGUID rguid1, REFGUID rguid2)
Definition: compobj.c:4112
static TAGID TAGID find
Definition: db.cpp:153
#define TAG_NULL
Definition: db.cpp:52
DWORD TAGID
GLuint64EXT * result
Definition: glext.h:11304
BYTE * PBYTE
Definition: pedump.c:66

◆ match_qw_attr_imp()

static void match_qw_attr_imp ( PDB  pdb,
TAGID  parent,
TAG  find,
QWORD  compare 
)
static

Definition at line 633 of file db.cpp.

634 {
635  TAGID attr = pSdbFindFirstTag(pdb, parent, find);
636  winetest_ok(attr != TAG_NULL, "Could not find: %x\n", find);
637  if (attr != TAG_NULL)
638  {
639  QWORD val = pSdbReadQWORDTag(pdb, attr, 0x123456789abcdef);
640  winetest_ok(val == compare, "Expected tagid %x to be 0x%I64x, was 0x%I64x\n", attr, compare, val);
641  }
642 }
Definition: bug.cpp:7
static PDB pdb
Definition: db.cpp:170
GLuint GLfloat * val
Definition: glext.h:7180
r parent
Definition: btrfs.c:2944
void __winetest_cdecl winetest_ok(int condition, const char *msg,...)
UINT64 QWORD
Definition: shimdbg.c:104
Definition: cookie.c:201
static TAGID TAGID find
Definition: db.cpp:153
#define TAG_NULL
Definition: db.cpp:52
DWORD TAGID

◆ match_strw_attr_imp()

static void match_strw_attr_imp ( PDB  pdb,
TAGID  parent,
TAG  find,
const WCHAR compare 
)
static

Definition at line 607 of file db.cpp.

608 {
609  TAGID attr = pSdbFindFirstTag(pdb, parent, find);
610  winetest_ok(attr != TAG_NULL, "Could not find: %x\n", find);
611  if (attr != TAG_NULL)
612  {
613  LPWSTR name = pSdbGetStringTagPtr(pdb, attr);
614  winetest_ok(name != NULL, "Could not convert attr to str.\n");
615  if (name)
616  {
617  winetest_ok(wcscmp(name, compare) == 0, "Expected tagid %x to be %s, was %s\n", attr, wine_dbgstr_w(compare), wine_dbgstr_w(name));
618  }
619  }
620 }
Definition: bug.cpp:7
static PDB pdb
Definition: db.cpp:170
char * wine_dbgstr_w(const wchar_t *wstr)
Definition: atltest.h:87
smooth NULL
Definition: ftsmooth.c:416
r parent
Definition: btrfs.c:2944
void __winetest_cdecl winetest_ok(int condition, const char *msg,...)
Definition: cookie.c:201
_Check_return_ _CRTIMP int __cdecl wcscmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
static TAGID TAGID find
Definition: db.cpp:153
Definition: name.c:38
#define TAG_NULL
Definition: db.cpp:52
DWORD TAGID
WCHAR * LPWSTR
Definition: xmlstorage.h:184

◆ PDB()

static PDB ( WINAPI pSdbOpenDatabase)
static

Referenced by test_mode_generic(), and test_TagRef().

◆ PVOID()

static PVOID ( WINAPI pSdbGetBinaryTagData)
static

◆ QWORD()

static QWORD ( WINAPI pSdbReadQWORDTag)
static

◆ START_TEST()

START_TEST ( db  )

Definition at line 2085 of file db.cpp.

2086 {
2087  //SetEnvironmentVariableA("SHIM_DEBUG_LEVEL", "4");
2088  //SetEnvironmentVariableA("SHIMENG_DEBUG_LEVEL", "4");
2089  //SetEnvironmentVariableA("DEBUGCHANNEL", "+apphelp");
2090 
2092  hdll = LoadLibraryA("apphelp.dll");
2093 
2094  /* We detect the apphelp version that is loaded, instead of the os we are running on.
2095  This allows for easier testing multiple versions of the dll */
2097  trace("Apphelp version: 0x%x\n", g_WinVersion);
2098 
2099  *(void**)&pSdbTagToString = (void *)GetProcAddress(hdll, "SdbTagToString");
2100  *(void**)&pSdbOpenDatabase = (void *)GetProcAddress(hdll, "SdbOpenDatabase");
2101  *(void**)&pSdbCreateDatabase = (void *)GetProcAddress(hdll, "SdbCreateDatabase");
2102  *(void**)&pSdbGetDatabaseVersion = (void *)GetProcAddress(hdll, "SdbGetDatabaseVersion");
2103  *(void**)&pSdbCloseDatabase = (void *)GetProcAddress(hdll, "SdbCloseDatabase");
2104  *(void**)&pSdbCloseDatabaseWrite = (void *)GetProcAddress(hdll, "SdbCloseDatabaseWrite");
2105  *(void**)&pSdbGetTagFromTagID = (void *)GetProcAddress(hdll, "SdbGetTagFromTagID");
2106  *(void**)&pSdbWriteNULLTag = (void *)GetProcAddress(hdll, "SdbWriteNULLTag");
2107  *(void**)&pSdbWriteWORDTag = (void *)GetProcAddress(hdll, "SdbWriteWORDTag");
2108  *(void**)&pSdbWriteDWORDTag = (void *)GetProcAddress(hdll, "SdbWriteDWORDTag");
2109  *(void**)&pSdbWriteQWORDTag = (void *)GetProcAddress(hdll, "SdbWriteQWORDTag");
2110  *(void**)&pSdbWriteBinaryTagFromFile = (void *)GetProcAddress(hdll, "SdbWriteBinaryTagFromFile");
2111  *(void**)&pSdbWriteStringTag = (void *)GetProcAddress(hdll, "SdbWriteStringTag");
2112  *(void**)&pSdbWriteStringRefTag = (void *)GetProcAddress(hdll, "SdbWriteStringRefTag");
2113  *(void**)&pSdbBeginWriteListTag = (void *)GetProcAddress(hdll, "SdbBeginWriteListTag");
2114  *(void**)&pSdbEndWriteListTag = (void *)GetProcAddress(hdll, "SdbEndWriteListTag");
2115  *(void**)&pSdbFindFirstTag = (void *)GetProcAddress(hdll, "SdbFindFirstTag");
2116  *(void**)&pSdbFindNextTag = (void *)GetProcAddress(hdll, "SdbFindNextTag");
2117  *(void**)&pSdbFindFirstNamedTag = (void *)GetProcAddress(hdll, "SdbFindFirstNamedTag");
2118  *(void**)&pSdbReadWORDTag = (void *)GetProcAddress(hdll, "SdbReadWORDTag");
2119  *(void**)&pSdbReadDWORDTag = (void *)GetProcAddress(hdll, "SdbReadDWORDTag");
2120  *(void**)&pSdbReadQWORDTag = (void *)GetProcAddress(hdll, "SdbReadQWORDTag");
2121  *(void**)&pSdbReadBinaryTag = (void *)GetProcAddress(hdll, "SdbReadBinaryTag");
2122  *(void**)&pSdbReadStringTag = (void *)GetProcAddress(hdll, "SdbReadStringTag");
2123  *(void**)&pSdbGetTagDataSize = (void *)GetProcAddress(hdll, "SdbGetTagDataSize");
2124  *(void**)&pSdbGetBinaryTagData = (void *)GetProcAddress(hdll, "SdbGetBinaryTagData");
2125  *(void**)&pSdbGetStringTagPtr = (void *)GetProcAddress(hdll, "SdbGetStringTagPtr");
2126  *(void**)&pSdbGetFirstChild = (void *)GetProcAddress(hdll, "SdbGetFirstChild");
2127  *(void**)&pSdbGetNextChild = (void *)GetProcAddress(hdll, "SdbGetNextChild");
2128  *(void**)&pSdbGetDatabaseID = (void *)GetProcAddress(hdll, "SdbGetDatabaseID");
2129  *(void**)&pSdbGUIDToString = (void *)GetProcAddress(hdll, "SdbGUIDToString");
2130  *(void**)&pSdbInitDatabase = (void *)GetProcAddress(hdll, "SdbInitDatabase");
2131  *(void**)&pSdbReleaseDatabase = (void *)GetProcAddress(hdll, "SdbReleaseDatabase");
2132  *(void**)&pSdbGetMatchingExe = (void *)GetProcAddress(hdll, "SdbGetMatchingExe");
2133  *(void**)&pSdbTagRefToTagID = (void *)GetProcAddress(hdll, "SdbTagRefToTagID");
2134  *(void**)&pSdbTagIDToTagRef = (void *)GetProcAddress(hdll, "SdbTagIDToTagRef");
2135  *(void**)&pSdbMakeIndexKeyFromString = (void *)GetProcAddress(hdll, "SdbMakeIndexKeyFromString");
2136  *(void**)&pSdbQueryData = (void *)GetProcAddress(hdll, "SdbQueryData");
2137  *(void**)&pSdbQueryDataEx = (void *)GetProcAddress(hdll, "SdbQueryDataEx");
2138  *(void**)&pSdbQueryDataExTagID = (void *)GetProcAddress(hdll, "SdbQueryDataExTagID");
2139  *(void**)&pSdbGetLayerTagRef = (void *)GetProcAddress(hdll, "SdbGetLayerTagRef");
2140  *(void**)&pSdbGetDatabaseInformation = (void *)GetProcAddress(hdll, "SdbGetDatabaseInformation");
2141  *(void**)&pSdbFreeDatabaseInformation = (void *)GetProcAddress(hdll, "SdbFreeDatabaseInformation");
2142 
2143  test_Sdb();
2144  test_write_ex();
2145  test_stringtable();
2147  switch (validate_SDBQUERYRESULT_size())
2148  {
2149  case 1:
2150  test_MatchApplications<SDBQUERYRESULT_2k3>();
2151  test_MatchApplicationsEx<SDBQUERYRESULT_2k3>();
2152  break;
2153  case 2:
2154  test_MatchApplications<SDBQUERYRESULT_VISTA>();
2155  test_MatchApplicationsEx<SDBQUERYRESULT_VISTA>();
2156  break;
2157  default:
2158  skip("Skipping tests with SDBQUERYRESULT due to a wrong size reported\n");
2159  break;
2160  }
2161  test_TagRef();
2162  test_Data();
2163  skip("test_SecondaryDB()\n");
2165 }
static void test_IndexKeyFromString(void)
Definition: db.cpp:1972
DWORD get_module_version(HMODULE mod)
Definition: data.c:811
static void test_TagRef(void)
Definition: db.cpp:1596
HINSTANCE WINAPI DECLSPEC_HOTPATCH LoadLibraryA(LPCSTR lpLibFileName)
Definition: loader.c:111
static DWORD g_WinVersion
#define trace
Definition: atltest.h:70
static void test_write_ex(void)
Definition: db.cpp:399
void silence_debug_output(void)
Definition: data.c:841
static void test_Sdb(void)
Definition: db.cpp:238
static void test_Data(void)
Definition: db.cpp:1916
static int validate_SDBQUERYRESULT_size()
Definition: db.cpp:2046
#define skip(...)
Definition: atltest.h:64
#define GetProcAddress(x, y)
Definition: compat.h:419
static HMODULE hdll
Definition: db.cpp:134
static void test_stringtable()
Definition: db.cpp:525
static void test_CheckDatabaseManually(void)
Definition: db.cpp:1089

◆ TAG()

static TAG ( WINAPI pSdbGetTagFromTagID)
static

◆ TAGID()

static TAGID ( WINAPI pSdbBeginWriteListTag)
static

◆ TAGREF()

static TAGREF ( WINAPI pSdbGetLayerTagRef)
static

◆ test_CheckDatabaseManually()

static void test_CheckDatabaseManually ( void  )
static

Definition at line 1089 of file db.cpp.

1090 {
1091  static const WCHAR path[] = {'t','e','s','t','_','d','b','.','s','d','b',0};
1092  TAGID root;
1093  PDB pdb;
1094  BOOL ret;
1095  DWORD ver_hi, ver_lo;
1096 
1097  test_create_db(L"test_db.sdb", g_WinVersion >= WINVER_WIN10);
1098 
1099  /* both ver_hi and ver_lo cannot be null, it'll crash. */
1100  ver_hi = ver_lo = 0x12345678;
1101  ret = pSdbGetDatabaseVersion(path, &ver_hi, &ver_lo);
1102  ok(ret, "Expected SdbGetDatabaseVersion to succeed\n");
1103  if (g_WinVersion >= WINVER_WIN10)
1104  {
1105  ok(ver_hi == 3, "Expected ver_hi to be 3, was: %d\n", ver_hi);
1106  ok(ver_lo == 0, "Expected ver_lo to be 0, was: %d\n", ver_lo);
1107  }
1108  else
1109  {
1110  ok(ver_hi == 2, "Expected ver_hi to be 2, was: %d\n", ver_hi);
1111  ok(ver_lo == 1, "Expected ver_lo to be 1, was: %d\n", ver_lo);
1112  }
1113 
1114  ver_hi = ver_lo = 0x12345678;
1115  ret = pSdbGetDatabaseVersion(NULL, &ver_hi, &ver_lo);
1116  if (g_WinVersion >= WINVER_WIN10)
1117  {
1118  ok(!ret, "Expected SdbGetDatabaseVersion to fail\n");
1119  ok(ver_hi == 0, "Expected ver_hi to be 0, was: 0x%x\n", ver_hi);
1120  ok(ver_lo == 0, "Expected ver_lo to be 0, was: 0x%x\n", ver_lo);
1121  }
1122  else
1123  {
1124  ok(ret, "Expected SdbGetDatabaseVersion to succeed\n");
1125  ok(ver_hi == 0x12345678, "Expected ver_hi to be 0x12345678, was: 0x%x\n", ver_hi);
1126  ok(ver_lo == 0x12345678, "Expected ver_lo to be 0x12345678, was: 0x%x\n", ver_lo);
1127  }
1128 
1129  ver_hi = ver_lo = 0x12345678;
1130  ret = pSdbGetDatabaseVersion(path + 1, &ver_hi, &ver_lo);
1131  if (g_WinVersion >= WINVER_WIN10)
1132  {
1133  ok(!ret, "Expected SdbGetDatabaseVersion to fail\n");
1134  ok(ver_hi == 0, "Expected ver_hi to be 0, was: 0x%x\n", ver_hi);
1135  ok(ver_lo == 0, "Expected ver_lo to be 0, was: 0x%x\n", ver_lo);
1136  }
1137  else
1138  {
1139  ok(ret, "Expected SdbGetDatabaseVersion to succeed\n");
1140  ok(ver_hi == 0x12345678, "Expected ver_hi to be 0x12345678, was: 0x%x\n", ver_hi);
1141  ok(ver_lo == 0x12345678, "Expected ver_lo to be 0x12345678, was: 0x%x\n", ver_lo);
1142  }
1143 
1144  pdb = pSdbOpenDatabase(path, DOS_PATH);
1145  ok(pdb != NULL, "unexpected NULL handle\n");
1146 
1147  root = pSdbFindFirstTag(pdb, TAGID_ROOT, TAG_DATABASE);
1148  ok(root != TAGID_NULL, "expected to find a root tag\n");
1149  if (root != TAGID_NULL)
1150  {
1151  TAGID tagLayer = pSdbFindFirstTag(pdb, root, TAG_LAYER);
1152  TAGID tagAlt = pSdbFindFirstNamedTag(pdb, root, TAG_LAYER, TAG_NAME, L"TestNewMode");
1153  TAGID tagAlt2 = pSdbFindFirstNamedTag(pdb, root, TAG_LAYER, TAG_NAME, L"TESTNEWMODE");
1154  TAGID tagAlt3 = pSdbFindFirstNamedTag(pdb, root, TAG_LAYER, TAG_NAME, L"testnewmode");
1155  ok_hex(tagLayer, (int)tagAlt);
1156  ok_hex(tagLayer, (int)tagAlt2);
1157  ok_hex(tagLayer, (int)tagAlt3);
1159  check_db_layer(pdb, tagLayer);
1162  }
1164 
1165  pSdbCloseDatabase(pdb);
1166  DeleteFileA("test_db.sdb");
1167 }
static PDB pdb
Definition: db.cpp:170
#define test_create_db
#define TAG_DATABASE
Definition: db.cpp:83
static void check_db_exes(PDB pdb, TAGID root)
Definition: db.cpp:941
static void check_db_properties(PDB pdb, TAGID root)
Definition: db.cpp:666
#define ok_hex(expression, result)
Definition: atltest.h:94
unsigned int BOOL
Definition: ntddk_ex.h:94
#define WINVER_WIN10
static void check_db_layer(PDB pdb, TAGID layer)
Definition: db.cpp:696
smooth NULL
Definition: ftsmooth.c:416
BOOL WINAPI DeleteFileA(IN LPCSTR lpFileName)
Definition: delete.c:24
static DWORD g_WinVersion
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define DOS_PATH
Definition: db.cpp:30
unsigned long DWORD
Definition: ntddk_ex.h:95
int ret
static void check_db_apphelp(PDB pdb, TAGID root)
Definition: db.cpp:1007
static const WCHAR L[]
Definition: oid.c:1250
static void test_GetDatabaseInformation(PDB pdb)
Definition: db.cpp:1032
#define TAGID_NULL
Definition: db.cpp:36
#define ok(value,...)
Definition: atltest.h:57
#define TAG_LAYER
Definition: db.cpp:88
#define TAG_NAME
Definition: db.cpp:96
#define TAGID_ROOT
Definition: db.cpp:37
DWORD TAGID
static TAGID root
Definition: db.cpp:153

Referenced by START_TEST().

◆ test_Data()

static void test_Data ( void  )
static

Definition at line 1916 of file db.cpp.

1917 {
1918  WCHAR workdir[MAX_PATH], dbpath[MAX_PATH];
1919  BOOL ret;
1920  HSDB hsdb;
1921 
1923  ok(ret, "GetTempPathW error: %d\n", GetLastError());
1924  lstrcatW(workdir, L"apphelp_test");
1925 
1927  ok(ret, "CreateDirectoryW error: %d\n", GetLastError());
1928 
1929  /* SdbInitDatabase needs an nt-path */
1930  swprintf(dbpath, L"\\??\\%s\\test.sdb", workdir);
1931 
1932  if (extract_resource(dbpath + 4, MAKEINTRESOURCEW(101)))
1933  {
1934  hsdb = pSdbInitDatabase(HID_DATABASE_FULLPATH, dbpath);
1935 
1936  ok(hsdb != NULL, "Expected a valid database handle\n");
1937 
1938  if (!hsdb)
1939  {
1940  skip("SdbInitDatabase not implemented?\n");
1941  }
1942  else
1943  {
1944  test_DataTags(hsdb);
1945  pSdbReleaseDatabase(hsdb);
1946  }
1947  }
1948  else
1949  {
1950  ok(0, "Unable to extract database\n");
1951  }
1952 
1953  DeleteFileW(dbpath + 4);
1954 
1956  ok(ret, "RemoveDirectoryW error: %d\n", GetLastError());
1957 }
BOOL WINAPI CreateDirectoryW(IN LPCWSTR lpPathName, IN LPSECURITY_ATTRIBUTES lpSecurityAttributes)
Definition: dir.c:90
static bool extract_resource(const WCHAR *Filename, LPCWSTR ResourceName)
Definition: db.cpp:1460
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
#define HID_DATABASE_FULLPATH
Definition: db.cpp:31
Definition: apphelp.h:27
DWORD WINAPI GetTempPathW(IN DWORD count, OUT LPWSTR path)
Definition: path.c:2079
unsigned int BOOL
Definition: ntddk_ex.h:94
BOOL WINAPI DeleteFileW(IN LPCWSTR lpFileName)
Definition: delete.c:39
smooth NULL
Definition: ftsmooth.c:416
BOOL WINAPI RemoveDirectoryW(IN LPCWSTR lpPathName)
Definition: dir.c:732
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define _countof(array)
Definition: sndvol32.h:68
static char workdir[MAX_PATH]
Definition: batch.c:26
#define MAX_PATH
Definition: compat.h:26
#define swprintf(buf, format,...)
Definition: sprintf.c:56
int ret
static const WCHAR L[]
Definition: oid.c:1250
static void test_DataTags(HSDB hsdb)
Definition: db.cpp:1737
#define ok(value,...)
Definition: atltest.h:57
#define skip(...)
Definition: atltest.h:64
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
LPWSTR WINAPI lstrcatW(LPWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:274

Referenced by START_TEST().

◆ test_DataTags()

static void test_DataTags ( HSDB  hsdb)
static

Definition at line 1737 of file db.cpp.

1738 {
1739  PDB pdb = NULL;
1740  TAGID db = TAGID_NULL, layer, exe;
1741  TAGREF trData;
1742  BYTE Buffer[1024];
1743  DWORD dwBufferSize, dwDataType, dwRet;
1744  TAGID tiData;
1745 
1746  BOOL ret = pSdbTagRefToTagID(hsdb, TAGID_ROOT, &pdb, NULL);
1747 
1748  ok(ret != FALSE, "Expected ret to be TRUE, was: %d\n", ret);
1749  ok(pdb != NULL, "Expected pdb to be valid\n");
1750 
1751  if (pdb == NULL)
1752  {
1753  skip("Cannot run tests without pdb\n");
1754  return;
1755  }
1756 
1757  db = pSdbFindFirstTag(pdb, TAGID_ROOT, TAG_DATABASE);
1758  ok(db != NULL, "Expected db to be valid\n");
1759  if (db == TAGID_NULL)
1760  {
1761  skip("Cannot run tests without db\n");
1762  return;
1763  }
1764 
1765  layer = pSdbFindFirstNamedTag(pdb, db, TAG_LAYER, TAG_NAME, L"DATA_LAYER");
1766  ok(layer != NULL, "Expected layer to be valid\n");
1767  if (layer == TAGID_NULL)
1768  {
1769  skip("Cannot run tests without layer\n");
1770  return;
1771  }
1772 
1773  memset(Buffer, 0xaa, sizeof(Buffer));
1774  dwBufferSize = sizeof(Buffer);
1775  dwDataType = 0x12345;
1776  tiData = 0x111111;
1777  dwRet = pSdbQueryDataExTagID(pdb, layer, L"TESTDATA1", &dwDataType, Buffer, &dwBufferSize, &tiData);
1778  ok_hex(dwRet, ERROR_SUCCESS);
1779  ok_hex(dwDataType, REG_DWORD);
1780  ok_hex(dwBufferSize, sizeof(DWORD));
1781  ok_hex(*(DWORD*)Buffer, 3333);
1782  ok(tiData != NULL && tiData != 0x111111, "Expected tiData, got NULL\n");
1783  ok_hex(pSdbGetTagFromTagID(pdb, tiData), TAG_DATA);
1784 
1785  memset(Buffer, 0xaa, sizeof(Buffer));
1786  dwBufferSize = sizeof(Buffer);
1787  dwRet = pSdbQueryDataExTagID(pdb, layer, L"TESTDATA1", NULL, Buffer, &dwBufferSize, NULL);
1788  ok_hex(dwRet, ERROR_SUCCESS);
1789  ok_hex(dwBufferSize, sizeof(DWORD));
1790  ok_hex(*(DWORD*)Buffer, 3333);
1791 
1793  {
1794  memset(Buffer, 0xaa, sizeof(Buffer));
1795  dwBufferSize = sizeof(Buffer);
1796  dwRet = pSdbQueryDataExTagID(pdb, layer, L"TESTDATA1", NULL, Buffer, NULL, NULL);
1798  ok_hex(*(DWORD*)Buffer, (int)0xaaaaaaaa);
1799  }
1800 
1801  memset(Buffer, 0xaa, sizeof(Buffer));
1802  dwBufferSize = 1;
1803  dwRet = pSdbQueryDataExTagID(pdb, layer, L"TESTDATA1", NULL, Buffer, &dwBufferSize, NULL);
1805  ok_hex(dwBufferSize, sizeof(DWORD));
1806  ok_hex(*(DWORD*)Buffer, (int)0xaaaaaaaa);
1807 
1808  memset(Buffer, 0xaa, sizeof(Buffer));
1809  dwBufferSize = sizeof(Buffer);
1810  dwRet = pSdbQueryDataExTagID(pdb, layer, L"TESTDATA1", NULL, NULL, &dwBufferSize, NULL);
1812  ok_hex(dwBufferSize, sizeof(DWORD));
1813  ok_hex(*(DWORD*)Buffer, (int)0xaaaaaaaa);
1814 
1815  memset(Buffer, 0xaa, sizeof(Buffer));
1816  dwBufferSize = sizeof(Buffer);
1817  dwRet = pSdbQueryDataExTagID(pdb, TAGID_NULL, L"TESTDATA1", NULL, Buffer, &dwBufferSize, NULL);
1818  ok_hex(dwRet, ERROR_NOT_FOUND);
1819  ok_hex(dwBufferSize, sizeof(Buffer));
1820  ok_hex(*(DWORD*)Buffer, (int)0xaaaaaaaa);
1821 
1822  memset(Buffer, 0xaa, sizeof(Buffer));
1823  dwBufferSize = sizeof(Buffer);
1824  dwDataType = 0x12345;
1825  tiData = 0x111111;
1826  dwRet = pSdbQueryDataExTagID(pdb, layer, L"TESTDATA2", &dwDataType, Buffer, &dwBufferSize, &tiData);
1827  ok_hex(dwRet, ERROR_SUCCESS);
1828  ok_hex(dwDataType, REG_QWORD);
1829  ok_hex(dwBufferSize, sizeof(QWORD));
1830  ok(*(QWORD*)Buffer == 4294967295ull, "unexpected value 0x%I64x, expected 4294967295\n", *(QWORD*)Buffer);
1831  ok(tiData != NULL && tiData != 0x111111, "Expected tiData, got NULL\n");
1832  ok_hex(pSdbGetTagFromTagID(pdb, tiData), TAG_DATA);
1833 
1834  /* Not case sensitive */
1835  memset(Buffer, 0xaa, sizeof(Buffer));
1836  dwBufferSize = sizeof(Buffer);
1837  dwDataType = 0x12345;
1838  tiData = 0x111111;
1839  dwRet = pSdbQueryDataExTagID(pdb, layer, L"TESTDATA3", &dwDataType, Buffer, &dwBufferSize, &tiData);
1840  ok_hex(dwRet, ERROR_SUCCESS);
1841  ok_hex(dwDataType, REG_SZ);
1842  ok_hex(dwBufferSize, (int)((wcslen(L"Test string")+1) * sizeof(WCHAR)));
1843  Buffer[_countof(Buffer)-1] = L'\0';
1844  ok_wstr(((WCHAR*)Buffer), L"Test string");
1845  ok(tiData != NULL && tiData != 0x111111, "Expected tiData, got NULL\n");
1846  ok_hex(pSdbGetTagFromTagID(pdb, tiData), TAG_DATA);
1847 
1848  /* Show that SdbQueryDataEx behaves the same */
1849  memset(Buffer, 0xaa, sizeof(Buffer));
1850  dwBufferSize = sizeof(Buffer);
1851  dwDataType = 0x12345;
1852  trData = 0x111111;
1853  dwRet = pSdbQueryDataEx(hsdb, layer, L"TESTDATA1", &dwDataType, Buffer, &dwBufferSize, &trData);
1854  ok_hex(dwRet, ERROR_SUCCESS);
1855  ok_hex(dwDataType, REG_DWORD);
1856  ok_hex(dwBufferSize, sizeof(DWORD));
1857  ok_hex(*(DWORD*)Buffer, 3333);
1858  ok(trData != NULL && trData != 0x111111, "Expected trData, got NULL\n");
1859 
1860  /* And SdbQueryData as well */
1861  memset(Buffer, 0xaa, sizeof(Buffer));
1862  dwBufferSize = sizeof(Buffer);
1863  dwDataType = 0x12345;
1864  dwRet = pSdbQueryData(hsdb, layer, L"TESTDATA1", &dwDataType, Buffer, &dwBufferSize);
1865  ok_hex(dwRet, ERROR_SUCCESS);
1866  ok_hex(dwDataType, REG_DWORD);
1867  ok_hex(dwBufferSize, sizeof(DWORD));
1868  ok_hex(*(DWORD*)Buffer, 3333);
1869 
1870  exe = pSdbFindFirstNamedTag(pdb, db, TAG_EXE, TAG_NAME, L"test_match0.exe");
1871  ok(exe != NULL, "Expected exe to be valid\n");
1872  if (exe == TAGID_NULL)
1873  {
1874  skip("Cannot run tests without exe\n");
1875  return;
1876  }
1877 
1878  memset(Buffer, 0xaa, sizeof(Buffer));
1879  dwBufferSize = sizeof(Buffer);
1880  dwDataType = 0x12345;
1881  tiData = 0x111111;
1882  dwRet = pSdbQueryDataExTagID(pdb, exe, L"TESTDATA1", &dwDataType, Buffer, &dwBufferSize, &tiData);
1883  ok_hex(dwRet, ERROR_NOT_FOUND);
1884  ok_hex(dwDataType, 0x12345);
1885  ok_hex(dwBufferSize, sizeof(Buffer));
1886  ok_hex(*(DWORD*)Buffer, (int)0xaaaaaaaa);
1887  ok(tiData == 0x111111, "Expected 0x111111, got 0x%x\n", tiData);
1888 
1889  /* Show that SdbQueryDataEx behaves the same */
1890  memset(Buffer, 0xaa, sizeof(Buffer));
1891  dwBufferSize = sizeof(Buffer);
1892  dwDataType = 0x12345;
1893  trData = 0x111111;
1894  dwRet = pSdbQueryDataEx(hsdb, exe, L"TESTDATA1", &dwDataType, Buffer, &dwBufferSize, &trData);
1895  ok_hex(dwRet, ERROR_NOT_FOUND);
1896  ok_hex(dwDataType, 0x12345);
1897  ok_hex(dwBufferSize, sizeof(Buffer));
1898  ok_hex(*(DWORD*)Buffer, (int)0xaaaaaaaa);
1900  ok(trData == 0, "Expected 0, got 0x%x\n", trData);
1901  else
1902  ok(trData == 0x111111, "Expected 0x111111, got 0x%x\n", trData);
1903 
1904  /* And SdbQueryData as well */
1905  memset(Buffer, 0xaa, sizeof(Buffer));
1906  dwBufferSize = sizeof(Buffer);
1907  dwDataType = 0x12345;
1908  dwRet = pSdbQueryData(hsdb, exe, L"TESTDATA1", &dwDataType, Buffer, &dwBufferSize);
1909  ok_hex(dwRet, ERROR_NOT_FOUND);
1910  ok_hex(dwDataType, 0x12345);
1911  ok_hex(dwBufferSize, sizeof(Buffer));
1912  ok_hex(*(DWORD*)Buffer, (int)0xaaaaaaaa);
1913 }
DWORD TAGREF
static PDB pdb
Definition: db.cpp:170
#define ERROR_SUCCESS
Definition: deptool.c:10
#define _WIN32_WINNT_WS03
Definition: sdkddkver.h:23
#define TAG_DATABASE
Definition: db.cpp:83
#define ok_hex(expression, result)
Definition: atltest.h:94
#define TAG_EXE
Definition: db.cpp:85
unsigned int BOOL
Definition: ntddk_ex.h:94
smooth NULL
Definition: ftsmooth.c:416
Definition: bufpool.h:45
static DWORD g_WinVersion
GLenum GLuint GLint GLint layer
Definition: glext.h:7007
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define _countof(array)
Definition: sndvol32.h:68
UINT64 QWORD
Definition: shimdbg.c:104
unsigned long DWORD
Definition: ntddk_ex.h:95
#define TAG_DATA
Definition: db.cpp:91
int ret
static const WCHAR L[]
Definition: oid.c:1250
#define ok_wstr(x, y)
Definition: atltest.h:130
unsigned char BYTE
Definition: xxhash.c:193
#define TAGID_NULL
Definition: db.cpp:36
#define ok(value,...)
Definition: atltest.h:57
#define TAG_LAYER
Definition: db.cpp:88
#define TAG_NAME
Definition: db.cpp:96
#define TAGID_ROOT
Definition: db.cpp:37
#define ERROR_NOT_FOUND
Definition: winerror.h:690
#define skip(...)
Definition: atltest.h:64
#define REG_QWORD
Definition: sdbapi.c:597
DWORD TAGID
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34
#define memset(x, y, z)
Definition: compat.h:39
#define REG_DWORD
Definition: sdbapi.c:596
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10
#define REG_SZ
Definition: layer.c:22

Referenced by test_Data().

◆ test_GetDatabaseInformation()

static void test_GetDatabaseInformation ( PDB  pdb)
static

Definition at line 1032 of file db.cpp.

1033 {
1034  PDB_INFORMATION pInfo;
1035  BOOL fResult;
1036 
1037  if (!pSdbGetDatabaseInformation || !pSdbFreeDatabaseInformation)
1038  {
1039  skip("GetDatabaseInformation or SdbFreeDatabaseInformation not found\n");
1040  return;
1041  }
1042 
1043  _SEH2_TRY
1044  {
1045  pSdbFreeDatabaseInformation(NULL);
1046  }
1048  {
1049  ok(0, "SdbFreeDatabaseInformation did not handle a NULL pointer very gracefully.\n");
1050  }
1051  _SEH2_END;
1052 
1053 
1054  pInfo = (PDB_INFORMATION)malloc(sizeof(*pInfo) * 4);
1055  memset(pInfo, 0xDE, sizeof(*pInfo) * 2);
1056 
1057  fResult = pSdbGetDatabaseInformation(pdb, pInfo);
1058  ok(fResult, "SdbGetDatabaseInformation failed\n");
1059  if (fResult)
1060  {
1061  ok_int(pInfo->dwSomething, 1);
1062  ok(IsEqualGUID(GUID_DATABASE_TEST, pInfo->Id), "expected guids to be equal(%s:%s)\n",
1063  wine_dbgstr_guid(&GUID_DATABASE_TEST), wine_dbgstr_guid(&pInfo->Id));
1064  ok(wcscmp(pInfo->Description, L"apphelp_test1") == 0,
1065  "Expected pInfo->Description to be 'apphelp_test1', was %s\n", wine_dbgstr_w(pInfo->Description));
1066 
1067  /* Struct is slightly bigger on some Win10, and the DB version nr is different on all */
1068  if (g_WinVersion >= WINVER_WIN10)
1069  {
1070  ok(pInfo->dwMajor == 3, "Expected pInfo->dwMajor to be 3, was: %d\n", pInfo->dwMajor);
1071  ok(pInfo->dwMinor == 0, "Expected pInfo->dwMinor to be 0, was: %d\n", pInfo->dwMinor);
1072 
1073  ok(pInfo[1].dwSomething == 4 || pInfo[1].dwSomething == 0xdededede, "Something amiss: 0x%x\n", pInfo[1].dwSomething);
1074  ok(pInfo[1].dwMajor == 0xdededede, "Cookie2 corrupt: 0x%x\n", pInfo[1].dwMajor);
1075  }
1076  else
1077  {
1078  ok(pInfo->dwMajor == 2, "Expected pInfo->dwMajor to be 2, was: %d\n", pInfo->dwMajor);
1079  ok(pInfo->dwMinor == 1, "Expected pInfo->dwMinor to be 1, was: %d\n", pInfo->dwMinor);
1080 
1081  ok(pInfo[1].dwSomething == 0xdededede, "Cookie1 corrupt: 0x%x\n", pInfo[1].dwSomething);
1082  ok(pInfo[1].dwMajor == 0xdededede, "Cookie2 corrupt: 0x%x\n", pInfo[1].dwMajor);
1083  }
1084 
1085  }
1086  free(pInfo);
1087 }
struct _DB_INFORMATION * PDB_INFORMATION
static PDB pdb
Definition: db.cpp:170
char * wine_dbgstr_w(const wchar_t *wstr)
Definition: atltest.h:87
#define free
Definition: debug_ros.c:5
const char * wine_dbgstr_guid(const GUID *guid)
LPCWSTR Description
Definition: apphelp.h:83
DWORD dwSomething
Definition: db.cpp:125
DWORD dwMajor
Definition: apphelp.h:81
_SEH2_TRY
Definition: create.c:4226
unsigned int BOOL
Definition: ntddk_ex.h:94
#define WINVER_WIN10
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
smooth NULL
Definition: ftsmooth.c:416
#define ok_int(expression, result)
Definition: atltest.h:134
static DWORD g_WinVersion
static const WCHAR L[]
Definition: oid.c:1250
_Check_return_ _CRTIMP int __cdecl wcscmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
_SEH2_END
Definition: create.c:4400
DWORD dwMinor
Definition: apphelp.h:82
#define ok(value,...)
Definition: atltest.h:57
BOOL WINAPI IsEqualGUID(REFGUID rguid1, REFGUID rguid2)
Definition: compobj.c:4112
#define skip(...)
Definition: atltest.h:64
#define malloc
Definition: debug_ros.c:4
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:6
#define memset(x, y, z)
Definition: compat.h:39

Referenced by test_CheckDatabaseManually().

◆ test_GetDatabaseInformationEmpty()

static void test_GetDatabaseInformationEmpty ( PDB  pdb)
static

Definition at line 189 of file db.cpp.

190 {
191  PDB_INFORMATION pInfo;
192  BOOL fResult;
193 
194  if (!pSdbGetDatabaseInformation || !pSdbFreeDatabaseInformation)
195  {
196  skip("GetDatabaseInformation or SdbFreeDatabaseInformation not found\n");
197  return;
198  }
199 
200  pInfo = (PDB_INFORMATION)malloc(sizeof(*pInfo) * 4);
201  memset(pInfo, 0xDE, sizeof(*pInfo) * 2);
202 
203  fResult = pSdbGetDatabaseInformation(pdb, pInfo);
204  ok(fResult, "SdbGetDatabaseInformation failed\n");
205  if (fResult)
206  {
207  ok_int(pInfo->dwSomething, 0);
208  ok(IsEqualGUID(GUID_NULL, pInfo->Id), "expected guid to be empty(%s)\n", wine_dbgstr_guid(&pInfo->Id));
209  ok(pInfo->Description == NULL, "Expected pInfo->Description to be NULL, was %s\n", wine_dbgstr_w(pInfo->Description));
210 
211  /* Struct is slightly bigger on some Win10, and the DB version nr is different on all */
212  if (g_WinVersion >= WINVER_WIN10)
213  {
214  ok(pInfo->dwMajor == 3, "Expected pInfo->dwMajor to be 3, was: %d\n", pInfo->dwMajor);
215  ok(pInfo->dwMinor == 0, "Expected pInfo->dwMinor to be 0, was: %d\n", pInfo->dwMinor);
216 
217  ok(pInfo[1].dwSomething == 0 || pInfo[1].dwSomething == 0xdededede, "Something amiss: 0x%x\n", pInfo[1].dwSomething);
218  ok(pInfo[1].dwMajor == 0xdededede, "Cookie2 corrupt: 0x%x\n", pInfo[1].dwMajor);
219  }
220  else
221  {
222  ok(pInfo->dwMajor == 2, "Expected pInfo->dwMajor to be 2, was: %d\n", pInfo->dwMajor);
224  ok(pInfo->dwMinor == 1, "Expected pInfo->dwMinor to be 1, was: %d\n", pInfo->dwMinor);
225  else
226  ok(pInfo->dwMinor >= 190915 && pInfo->dwMinor <= 191300,
227  "Expected pInfo->dwMinor to be between 190915 and 191300, was: %d\n", pInfo->dwMinor);
228 
229  ok(pInfo[1].dwSomething == 0xdededede, "Cookie1 corrupt: 0x%x\n", pInfo[1].dwSomething);
230  ok(pInfo[1].dwMajor == 0xdededede, "Cookie2 corrupt: 0x%x\n", pInfo[1].dwMajor);
231  }
232 
233  }
234  free(pInfo);
235 }
struct _DB_INFORMATION * PDB_INFORMATION
static PDB pdb
Definition: db.cpp:170
char * wine_dbgstr_w(const wchar_t *wstr)
Definition: atltest.h:87
#define free
Definition: debug_ros.c:5
const char * wine_dbgstr_guid(const GUID *guid)
LPCWSTR Description
Definition: apphelp.h:83
DWORD dwSomething
Definition: db.cpp:125
DWORD dwMajor
Definition: apphelp.h:81
#define _WIN32_WINNT_VISTA
Definition: sdkddkver.h:25
unsigned int BOOL
Definition: ntddk_ex.h:94
#define WINVER_WIN10
smooth NULL
Definition: ftsmooth.c:416
#define ok_int(expression, result)
Definition: atltest.h:134
static DWORD g_WinVersion
#define GUID_NULL
Definition: ks.h:106
DWORD dwMinor
Definition: apphelp.h:82
#define ok(value,...)
Definition: atltest.h:57
BOOL WINAPI IsEqualGUID(REFGUID rguid1, REFGUID rguid2)
Definition: compobj.c:4112
#define skip(...)
Definition: atltest.h:64
#define malloc
Definition: debug_ros.c:4
#define memset(x, y, z)
Definition: compat.h:39

Referenced by test_Sdb().

◆ test_IndexKeyFromString()

static void test_IndexKeyFromString ( void  )
static

Definition at line 1972 of file db.cpp.

1973 {
1974 #if 0
1975  static WCHAR tmp[] = { 0xabba, 0xbcde, 0x2020, 0x20, 0x4444, 0 };
1976  static WCHAR tmp2[] = { 0xabba, 0xbcde, 0x20, 0x4444, 0 };
1977  static WCHAR tmp3[] = { 0x20, 0xbcde, 0x4041, 0x4444, 0 };
1978  static WCHAR tmp4[] = { 0x20, 0xbcde, 0x4041, 0x4444, 0x4444, 0 };
1979  static WCHAR tmp5[] = { 0x2020, 0xbcde, 0x4041, 0x4444, 0x4444, 0 };
1980  static WCHAR tmp6 [] = { 0x20, 0xbcde, 0x4041, 0x4444, 0x4444, 0x4444, 0};
1981  static WCHAR tmp7 [] = { 0xbcde, 0x4041, 0x4444, 0x4444, 0x4444, 0x4444, 0x4444, 0x4444, 0x4444, 0};
1982  static WCHAR tmp8 [] = { 0xbc00, 0x4041, 0x4444, 0x4444, 0x4444, 0x4444, 0x4444, 0x4444, 0x4444, 0};
1983 #endif
1984 
1985 #if 0
1986  /* This crashes. */
1987  pSdbMakeIndexKeyFromString(NULL);
1988 #endif
1989 
1990  expect_indexA("", 0x0000000000000000);
1991  expect_indexA("a", 0x4100000000000000);
1992  expect_indexA("aa", 0x4141000000000000);
1993  expect_indexA("aaa", 0x4141410000000000);
1994  expect_indexA("aaaa", 0x4141414100000000);
1995  expect_indexA("aaaaa", 0x4141414141000000);
1996  expect_indexA("aaaaaa", 0x4141414141410000);
1997  expect_indexA("aaaaaaa", 0x4141414141414100);
1998  expect_indexA("aaaaaaaa", 0x4141414141414141);
1999  expect_indexA("aaa aaaaa", 0x4141412041414141);
2000  /* Does not change */
2001  expect_indexA("aaaaaaaaa", 0x4141414141414141);
2002  expect_indexA("aaaaaaaab", 0x4141414141414141);
2003  expect_indexA("aaaaaaaac", 0x4141414141414141);
2004  expect_indexA("aaaaaaaaF", 0x4141414141414141);
2005  /* Upcase */
2006  expect_indexA("AAAAAAAA", 0x4141414141414141);
2007  expect_indexA("ABABABAB", 0x4142414241424142);
2008  expect_indexA("ABABABABZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ", 0x4142414241424142);
2009 
2010 #if 0
2011  /* These fail, but is that because the codepoints are too weird, or because the func is not correct? */
2012  result = pSdbMakeIndexKeyFromString(tmp);
2013  ok(result == 0xbaabdebc20200000, "Expected %s to result in %s, was: %s\n", wine_dbgstr_w(tmp),
2014  wine_dbgstr_longlong(0xbaabdebc20200000), wine_dbgstr_longlong(result));
2015 
2016  result = pSdbMakeIndexKeyFromString(tmp2);
2017  ok(result == 0xbaabdebc00000000, "Expected %s to result in %s, was: %s\n", wine_dbgstr_w(tmp2),
2018  wine_dbgstr_longlong(0xbaabdebc00000000), wine_dbgstr_longlong(result));
2019 
2020  result = pSdbMakeIndexKeyFromString(tmp3);
2021  ok(result == 0x20debc4140000000, "Expected %s to result in %s, was: %s\n", wine_dbgstr_w(tmp3),
2022  wine_dbgstr_longlong(0x20debc4140000000), wine_dbgstr_longlong(result));
2023 
2024  result = pSdbMakeIndexKeyFromString(tmp4);
2025  ok(result == 0x20debc4140000000, "Expected %s to result in %s, was: %s\n", wine_dbgstr_w(tmp4),
2026  wine_dbgstr_longlong(0x20debc4140000000), wine_dbgstr_longlong(result));
2027 
2028  result = pSdbMakeIndexKeyFromString(tmp5);
2029  ok(result == 0x2020debc41400000, "Expected %s to result in %s, was: %s\n", wine_dbgstr_w(tmp5),
2030  wine_dbgstr_longlong(0x2020debc41400000), wine_dbgstr_longlong(result));
2031 
2032  result = pSdbMakeIndexKeyFromString(tmp6);
2033  ok(result == 0x20debc4140444400, "Expected %s to result in %s, was: %s\n", wine_dbgstr_w(tmp6),
2034  wine_dbgstr_longlong(0x20debc4140444400), wine_dbgstr_longlong(result));
2035 
2036  result = pSdbMakeIndexKeyFromString(tmp7);
2037  ok(result == 0xdebc414044444444, "Expected %s to result in %s, was: %s\n", wine_dbgstr_w(tmp7),
2038  wine_dbgstr_longlong(0xdebc414044444444), wine_dbgstr_longlong(result));
2039 
2040  result = pSdbMakeIndexKeyFromString(tmp8);
2041  ok(result == 0xbc414044444444, "Expected %s to result in %s, was: %s\n", wine_dbgstr_w(tmp8),
2042  wine_dbgstr_longlong(0xbc414044444444), wine_dbgstr_longlong(result));
2043 #endif
2044 }
#define expect_indexA
Definition: db.cpp:1970
char * wine_dbgstr_w(const wchar_t *wstr)
Definition: atltest.h:87
smooth NULL
Definition: ftsmooth.c:416
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define ok(value,...)
Definition: atltest.h:57
static __inline const char * wine_dbgstr_longlong(ULONGLONG ll)
Definition: compat.h:41
GLuint64EXT * result
Definition: glext.h:11304

Referenced by START_TEST().

◆ test_is_testdb()

static void test_is_testdb ( PDB  pdb)
static

Definition at line 1169 of file db.cpp.

1170 {
1171  if (pdb)
1172  {
1173  GUID guid;
1174  memset(&guid, 0, sizeof(guid));
1175  ok(pSdbGetDatabaseID(pdb, &guid), "expected SdbGetDatabaseID not to fail.\n");
1176  ok(IsEqualGUID(guid, GUID_DATABASE_TEST), "Expected SdbGetDatabaseID to return the test db GUID, was: %s\n", wine_dbgstr_guid(&guid));
1177  }
1178  else
1179  {
1180  skip("Not checking DB GUID, received a null pdb\n");
1181  }
1182 }
static PDB pdb
Definition: db.cpp:170
const char * wine_dbgstr_guid(const GUID *guid)
const GUID * guid
#define ok(value,...)
Definition: atltest.h:57
BOOL WINAPI IsEqualGUID(REFGUID rguid1, REFGUID rguid2)
Definition: compobj.c:4112
#define skip(...)
Definition: atltest.h:64
#define memset(x, y, z)
Definition: compat.h:39

Referenced by test_mode_generic().

◆ test_match_ex()

template<typename SDBQUERYRESULT_T >
static void test_match_ex ( const WCHAR workdir,
HSDB  hsdb 
)
static

Definition at line 1482 of file db.cpp.

1483 {
1485  PWCHAR Vendor, AppName, TestName;
1486  SDBQUERYRESULT_T query;
1487  TAGID dbtag, exetag, tagid;
1488  BOOL ret, Succeed;
1489  PDB pdb;
1490 
1491  memset(&query, 0xab, sizeof(query));
1492 
1493  ret = pSdbTagRefToTagID(hsdb, 0, &pdb, &tagid);
1494  ok(pdb != NULL && pdb != (PDB)0x12345678, "Expected pdb to be set to a valid pdb, was: %p\n", pdb);
1495 
1496  dbtag = pSdbFindFirstTag(pdb, TAGID_ROOT, TAG_DATABASE);
1497  ok(dbtag != TAGID_NULL, "Expected to get a valid TAG_DATABASE\n");
1498 
1499  for (exetag = pSdbFindFirstTag(pdb, dbtag, TAG_EXE); exetag; exetag = pSdbFindNextTag(pdb, dbtag, exetag))
1500  {
1501  tagid = pSdbFindFirstTag(pdb, exetag, TAG_VENDOR);
1502  Vendor = pSdbGetStringTagPtr(pdb, tagid);
1503  if (!Vendor)
1504  continue;
1505  Succeed = !wcsicmp(Vendor, L"Succeed");
1506  if (!Succeed && wcsicmp(Vendor, L"Fail"))
1507  continue;
1508  tagid = pSdbFindFirstTag(pdb, exetag, TAG_APP_NAME);
1509  AppName = pSdbGetStringTagPtr(pdb, tagid);
1510  if (!AppName)
1511  continue;
1512 
1513  tagid = pSdbFindFirstTag(pdb, exetag, TAG_NAME);
1514  TestName = pSdbGetStringTagPtr(pdb, tagid);
1515  if (!TestName)
1516  continue;
1517 
1518  swprintf(exename, L"%s\\%s", workdir, AppName);
1520 
1521  ret = pSdbGetMatchingExe(hsdb, exename, NULL, NULL, 0, (SDBQUERYRESULT_VISTA*)&query);
1522  DWORD exe_count = Succeed ? 1 : 0;
1523 
1524  if (Succeed && !ret && g_WinVersion == _WIN32_WINNT_WS03)
1525  {
1526  skip("As long as we do not have indexes, we will hit a bug in W2k3\n");
1527 #if 0
1528 [Info][SdbGetIndex ] index 0x7007(0x600b) was not found in the index table
1529 [Info][SdbGetIndex ] index 0x7007(0x6001) was not found in the index table
1530 [Info][SdbpSearchDB ] Searching database with no index.
1531 [Err ][SdbpSearchDB ] No DATABASE tag found.
1532 #endif
1533  }
1534  else
1535  {
1536  if (Succeed)
1537  ok(ret, "SdbGetMatchingExe should not fail for %s.\n", wine_dbgstr_w(TestName));
1538  else
1539  ok(!ret, "SdbGetMatchingExe should not succeed for %s.\n", wine_dbgstr_w(TestName));
1540 
1541  ok(query.dwExeCount == exe_count, "Expected dwExeCount to be %d, was %d for %s\n", exe_count, query.dwExeCount, wine_dbgstr_w(TestName));
1542  }
1544  }
1545 }
static PDB pdb
Definition: db.cpp:170
#define _WIN32_WINNT_WS03
Definition: sdkddkver.h:23
char * wine_dbgstr_w(const wchar_t *wstr)
Definition: atltest.h:87
#define TAG_DATABASE
Definition: db.cpp:83
static CHAR AppName[MAX_PATH]
Definition: dem.c:252
Definition: ecma_167.h:138
#define TAG_APP_NAME
Definition: db.cpp:99
uint16_t * PWCHAR
Definition: typedefs.h:55
struct TraceInfo Info
#define TAG_VENDOR
Definition: db.cpp:98
#define TAG_EXE
Definition: db.cpp:85
unsigned int BOOL
Definition: ntddk_ex.h:94
BOOL WINAPI DeleteFileW(IN LPCWSTR lpFileName)
Definition: delete.c:39
smooth NULL
Definition: ftsmooth.c:416
GLuint index
Definition: glext.h:6031
static DWORD g_WinVersion
static WCHAR no[MAX_STRING_RESOURCE_LEN]
Definition: object.c:2340
__wchar_t WCHAR
Definition: xmlstorage.h:180
static char workdir[MAX_PATH]
Definition: batch.c:26
#define MAX_PATH
Definition: compat.h:26
#define swprintf(buf, format,...)
Definition: sprintf.c:56
unsigned long DWORD
Definition: ntddk_ex.h:95
int ret
static const WCHAR L[]
Definition: oid.c:1250
#define test_create_exe
#define wcsicmp
Definition: string.h:1152
#define TAGID_NULL
Definition: db.cpp:36
GLuint in
Definition: glext.h:9616
#define ok(value,...)
Definition: atltest.h:57
#define TAG_NAME
Definition: db.cpp:96
#define TAGID_ROOT
Definition: db.cpp:37
#define skip(...)
Definition: atltest.h:64
DWORD TAGID
static char * exename
Definition: process.c:101
#define memset(x, y, z)
Definition: compat.h:39
GLenum query
Definition: glext.h:7781

◆ test_MatchApplications()

template<typename SDBQUERYRESULT_T >
static void test_MatchApplications ( void  )
static

Definition at line 1401 of file db.cpp.

1402 {
1403  WCHAR workdir[MAX_PATH], dbpath[MAX_PATH];
1404  BOOL ret;
1405  HSDB hsdb;
1406 
1408  ok(ret, "GetTempPathW error: %d\n", GetLastError());
1409  wcscat(workdir, L"apphelp_test");
1410 
1412  ok(ret, "CreateDirectoryW error: %d\n", GetLastError());
1413 
1414  /* SdbInitDatabase needs an nt-path */
1415  swprintf(dbpath, L"\\??\\%s\\test.sdb", workdir);
1416 
1417  test_create_db(dbpath + 4, g_WinVersion >= WINVER_WIN10);
1418 
1419  hsdb = pSdbInitDatabase(HID_DATABASE_FULLPATH, dbpath);
1420 
1421  ok(hsdb != NULL, "Expected a valid database handle\n");
1422 
1423  if (!hsdb)
1424  {
1425  skip("SdbInitDatabase not implemented?\n");
1426  }
1427  else
1428  {
1429  /* now that our enviroment is setup, let's go ahead and run the actual tests.. */
1430  size_t n;
1431  for (n = 0; n < _countof(test_exedata); ++n)
1432  test_mode_generic<SDBQUERYRESULT_T>(workdir, hsdb, n);
1433  pSdbReleaseDatabase(hsdb);
1434  }
1435 
1436  DeleteFileW(dbpath + 4);
1437 
1439  ok(ret, "RemoveDirectoryW error: %d\n", GetLastError());
1440 }
BOOL WINAPI CreateDirectoryW(IN LPCWSTR lpPathName, IN LPSECURITY_ATTRIBUTES lpSecurityAttributes)
Definition: dir.c:90
#define test_create_db
GLdouble n
Definition: glext.h:7729
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
#define HID_DATABASE_FULLPATH
Definition: db.cpp:31
Definition: apphelp.h:27
DWORD WINAPI GetTempPathW(IN DWORD count, OUT LPWSTR path)
Definition: path.c:2079
unsigned int BOOL
Definition: ntddk_ex.h:94
#define WINVER_WIN10
BOOL WINAPI DeleteFileW(IN LPCWSTR lpFileName)
Definition: delete.c:39
smooth NULL
Definition: ftsmooth.c:416
BOOL WINAPI RemoveDirectoryW(IN LPCWSTR lpPathName)
Definition: dir.c:732
static DWORD g_WinVersion
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define _countof(array)
Definition: sndvol32.h:68
static char workdir[MAX_PATH]
Definition: batch.c:26
#define MAX_PATH
Definition: compat.h:26
#define swprintf(buf, format,...)
Definition: sprintf.c:56
int ret
static const WCHAR L[]
Definition: oid.c:1250
static struct @1580 test_exedata[5]
#define ok(value,...)
Definition: atltest.h:57
_CRTIMP wchar_t *__cdecl wcscat(_Inout_updates_z_(_String_length_(_Dest)+_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
#define skip(...)
Definition: atltest.h:64

◆ test_MatchApplicationsEx()

template<typename SDBQUERYRESULT_T >
static void test_MatchApplicationsEx ( void  )
static

Definition at line 1549 of file db.cpp.

1550 {
1551  WCHAR workdir[MAX_PATH], dbpath[MAX_PATH];
1552  BOOL ret;
1553  HSDB hsdb;
1554 
1556  ok(ret, "GetTempPathW error: %d\n", GetLastError());
1557  lstrcatW(workdir, L"apphelp_test");
1558 
1560  ok(ret, "CreateDirectoryW error: %d\n", GetLastError());
1561 
1562  /* SdbInitDatabase needs an nt-path */
1563  swprintf(dbpath, L"\\??\\%s\\test.sdb", workdir);
1564 
1565  if (extract_resource(dbpath + 4, MAKEINTRESOURCEW(101)))
1566  {
1567  hsdb = pSdbInitDatabase(HID_DATABASE_FULLPATH, dbpath);
1568 
1569  ok(hsdb != NULL, "Expected a valid database handle\n");
1570 
1571  if (!hsdb)
1572  {
1573  skip("SdbInitDatabase not implemented?\n");
1574  }
1575  else
1576  {
1577  /* now that our enviroment is setup, let's go ahead and run the actual tests.. */
1578  test_match_ex<SDBQUERYRESULT_T>(workdir, hsdb);
1579  pSdbReleaseDatabase(hsdb);
1580  }
1581  }
1582  else
1583  {
1584  ok(0, "Unable to extract database\n");
1585  }
1586 
1587  DeleteFileW(dbpath + 4);
1588 
1590  ok(ret, "RemoveDirectoryW error: %d\n", GetLastError());
1591 }
BOOL WINAPI CreateDirectoryW(IN LPCWSTR lpPathName, IN LPSECURITY_ATTRIBUTES lpSecurityAttributes)
Definition: dir.c:90
static bool extract_resource(const WCHAR *Filename, LPCWSTR ResourceName)
Definition: db.cpp:1460
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
#define HID_DATABASE_FULLPATH
Definition: db.cpp:31
Definition: apphelp.h:27
DWORD WINAPI GetTempPathW(IN DWORD count, OUT LPWSTR path)
Definition: path.c:2079
unsigned int BOOL
Definition: ntddk_ex.h:94
BOOL WINAPI DeleteFileW(IN LPCWSTR lpFileName)
Definition: delete.c:39
smooth NULL
Definition: ftsmooth.c:416
BOOL WINAPI RemoveDirectoryW(IN LPCWSTR lpPathName)
Definition: dir.c:732
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define _countof(array)
Definition: sndvol32.h:68
static char workdir[MAX_PATH]
Definition: batch.c:26
#define MAX_PATH
Definition: compat.h:26
#define swprintf(buf, format,...)
Definition: sprintf.c:56
int ret
static const WCHAR L[]
Definition: oid.c:1250
#define ok(value,...)
Definition: atltest.h:57
#define skip(...)
Definition: atltest.h:64
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
LPWSTR WINAPI lstrcatW(LPWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:274

◆ test_mode_generic()

template<typename SDBQUERYRESULT_T >
static void test_mode_generic ( const WCHAR workdir,
HSDB  hsdb,
size_t  cur 
)
static

Definition at line 1221 of file db.cpp.

1222 {
1223  WCHAR exename[MAX_PATH], testfile[MAX_PATH];
1224  BOOL ret;
1225  SDBQUERYRESULT_T query;
1226  PDB pdb;
1227  TAGID tagid;
1228  TAGREF trApphelp;
1229  DWORD expect_flags = 0, adwExeFlags_0, exe_count;
1230  UNICODE_STRING exenameNT;
1231 
1232  memset(&query, 0xab, sizeof(query));
1233 
1234  swprintf(exename, L"%s\\%s", workdir, test_exedata[cur].name);
1235  if (test_exedata[cur].extra_file)
1236  swprintf(testfile, L"%s\\%s", workdir, test_exedata[cur].extra_file);
1238 
1239  if (test_exedata[cur].extra_file)
1240  {
1241  /* First we try without the file at all. */
1242  DeleteFileW(testfile);
1243  ret = pSdbGetMatchingExe(hsdb, exename, NULL, NULL, 0, (SDBQUERYRESULT_VISTA*)&query);
1244  ok(ret == 0, "SdbGetMatchingExe should have failed for %d.\n", cur);
1245  /* Now re-try with the correct file */
1246  test_create_file(testfile, "aaaa", 4);
1247  }
1248 
1249 #if 0
1250  // Results seem to be cached based on filename, until we can invalidate this, do not test the same filename twice!
1252  // skip exports
1254  ret = pSdbGetMatchingExe(hsdb, exenameW, NULL, NULL, 0, &query);
1255  ok(ret == 0, "SdbGetMatchingExe should have failed for %d.\n", cur);
1256 
1259 #endif
1260 
1261  if (test_exedata[cur].env_var)
1262  {
1263  SetEnvironmentVariableA("__COMPAT_LAYER", test_exedata[cur].env_var);
1264  }
1265 
1266  ret = pSdbGetMatchingExe(hsdb, exename, NULL, NULL, 0, (SDBQUERYRESULT_VISTA*)&query);
1267  ok(ret, "SdbGetMatchingExe should not fail for %d.\n", cur);
1268 
1269  exe_count = (test_exedata[cur].env_var == NULL) ? 1 : 0;
1270 
1271  ok(query.dwExeCount == exe_count, "Expected dwExeCount to be %d, was %d for %d\n", exe_count, query.dwExeCount, cur);
1272  ok(query.dwLayerCount == test_exedata[cur].dwLayerCount, "Expected dwLayerCount to be %d, was %d for %d\n", test_exedata[cur].dwLayerCount, query.dwLayerCount, cur);
1273  ok(query.dwCustomSDBMap == 1, "Expected dwCustomSDBMap to be 1, was %d for %d\n", query.dwCustomSDBMap, cur);
1274  ok(query.dwLayerFlags == 0, "Expected dwLayerFlags to be 0, was 0x%x for %d\n", query.dwLayerFlags, cur);
1276  ok(query.trApphelp == trApphelp, "Expected trApphelp to be 0x%x, was 0x%x for %d\n", trApphelp, query.trApphelp, cur);
1277 
1278  if (g_WinVersion < WINVER_WIN7)
1279  expect_flags = 0;
1280  else if (g_WinVersion < WINVER_WIN8)
1281  expect_flags = 1;
1282  else if (g_WinVersion < WINVER_WIN10)
1283  expect_flags = 0x101;
1284  else
1285  {
1286  expect_flags = 0x121; /* for 2 and 3, this becomes 101 when not elevated. */
1287  if ((cur == 2 || cur == 3) && !IsUserAdmin())
1288  expect_flags &= ~0x20;
1289  }
1290 
1291  if (test_exedata[cur].env_var)
1292  expect_flags &= ~0x100;
1293 
1294  ok(query.dwFlags == expect_flags, "Expected dwFlags to be 0x%x, was 0x%x for %d\n", expect_flags, query.dwFlags, cur);
1295 
1296  ok(query.atrExes[0] == test_exedata[cur].atrExes_0, "Expected atrExes[0] to be 0x%x, was: 0x%x for %d\n", test_exedata[cur].atrExes_0, query.atrExes[0], cur);
1297  for (size_t n = 1; n < _countof(query.atrExes); ++n)
1298  ok(query.atrExes[n] == 0, "Expected atrExes[%d] to be 0, was: %x for %d\n", n, query.atrExes[n], cur);
1299 
1301  check_adwExeFlags(adwExeFlags_0, query, __FILE__, __LINE__, cur);
1302 
1303  ok(query.atrLayers[0] == test_exedata[cur].atrLayers_0, "Expected atrLayers[0] to be 0x%x, was: %x for %d\n", test_exedata[cur].atrLayers_0, query.atrLayers[0], cur);
1304  for (size_t n = 1; n < _countof(query.atrLayers); ++n)
1305  ok(query.atrLayers[n] == 0, "Expected atrLayers[%d] to be 0, was: %x for %d\n", n, query.atrLayers[0], cur);
1306 
1307  if (g_WinVersion >= WINVER_VISTA)
1308  ok(IsEqualGUID(query.rgGuidDB[0], GUID_DATABASE_TEST), "Expected rgGuidDB[0] to be the test db GUID, was: %s for %d\n", wine_dbgstr_guid(&query.rgGuidDB[0]), cur);
1309  else
1310  ok(IsEqualGUID(query.rgGuidDB[0], GUID_MAIN_DATABASE), "Expected rgGuidDB[0] to be the main db GUID, was: %s for %d\n", wine_dbgstr_guid(&query.rgGuidDB[0]), cur);
1311  for (size_t n = 1; n < _countof(query.rgGuidDB); ++n)
1312  ok(IsEqualGUID(query.rgGuidDB[n], GUID_NULL), "Expected rgGuidDB[%d] to be GUID_NULL, was: %s for %d\n", n, wine_dbgstr_guid(&query.rgGuidDB[n]), cur);
1313 
1314  if (query.atrExes[0])
1315  {
1316  pdb = (PDB)0x12345678;
1317  tagid = 0x76543210;
1318  ret = pSdbTagRefToTagID(hsdb, query.atrExes[0], &pdb, &tagid);
1319  ok(ret, "SdbTagRefToTagID failed for %d.\n", cur);
1320  ok(pdb != NULL && pdb != (PDB)0x12345678, "SdbTagRefToTagID failed to return a pdb for %d.\n", cur);
1321  ok(tagid != 0 && tagid != 0x76543210, "SdbTagRefToTagID failed to return a tagid for %d.\n", cur);
1322 
1323  if (pdb && pdb != (PDB)0x12345678)
1324  {
1325  TAGREF tr = 0x12345678;
1326  TAG tag = pSdbGetTagFromTagID(pdb, tagid);
1328  ok(tag == TAG_EXE, "Expected tag to be TAG_EXE, was 0x%x for %d.\n", tag, cur);
1329  match_strw_attr(pdb, tagid, TAG_NAME, test_exedata[cur].name);
1330 
1331  /* And back again */
1332  ret = pSdbTagIDToTagRef(hsdb, pdb, tagid, &tr);
1333  ok(ret, "SdbTagIDToTagRef failed for %d.\n", cur);
1334  ok(tr == query.atrExes[0], "Expected tr to be 0x%x, was 0x%x for %d.\n", query.atrExes[0], tr, cur);
1335  }
1336  else
1337  {
1338  skip("Skipping a bunch of tests because of an invalid pointer\n");
1339  }
1340  }
1341 
1342  if (test_exedata[cur].atrLayers_0)
1343  {
1344  pdb = (PDB)0x12345678;
1345  tagid = 0x76543210;
1346  ret = pSdbTagRefToTagID(hsdb, query.atrLayers[0], &pdb, &tagid);
1347  ok(ret, "SdbTagRefToTagID failed for %d.\n", cur);
1348  ok(pdb != NULL && pdb != (PDB)0x12345678, "SdbTagRefToTagID failed to return a pdb for %d.\n", cur);
1349  ok(tagid != 0 && tagid != 0x76543210, "SdbTagRefToTagID failed to return a tagid for %d.\n", cur);
1350 
1351  if (pdb && pdb != (PDB)0x12345678)
1352  {
1353  TAGREF tr = 0x12345678;
1354  TAG tag = pSdbGetTagFromTagID(pdb, tagid);
1356  ok(tag == TAG_LAYER, "Expected tag to be TAG_LAYER, was 0x%x for %d.\n", tag, cur);
1357  match_strw_attr(pdb, tagid, TAG_NAME, L"TestNewMode");
1358 
1359  /* And back again */
1360  ret = pSdbTagIDToTagRef(hsdb, pdb, tagid, &tr);
1361  ok(ret, "SdbTagIDToTagRef failed for %d.\n", cur);
1362  ok(tr == test_exedata[cur].atrLayers_0, "Expected tr to be 0x%x, was 0x%x for %d.\n", test_exedata[cur].atrLayers_0, tr, cur);
1363  }
1364  else
1365  {
1366  skip("Skipping a bunch of tests because of an invalid pointer\n");
1367  }
1368  }
1369 
1370  pdb = (PDB)0x12345678;
1371  tagid = 0x76543210;
1372  ret = pSdbTagRefToTagID(hsdb, 0, &pdb, &tagid);
1373  ok(pdb != NULL && pdb != (PDB)0x12345678, "Expected pdb to be set to a valid pdb, was: %p\n", pdb);
1374  ok(tagid == 0, "Expected tagid to be set to 0, was: 0x%x\n", tagid);
1375 
1376 
1377 
1378  if (RtlDosPathNameToNtPathName_U(exename, &exenameNT, NULL, NULL))
1379  {
1380  /*
1381  ERROR,AslPathGetLongFileNameLongpath,110,Long path conversion failed 123 [c0000001]
1382  ERROR,AslPathBuildSignatureLongpath,1086,AslPathGetLongFileNameLongpath failed for \??\C:\Users\MARK~1.DEV\AppData\Local\Temp\apphelp_test\test_allow.exe [c0000001]
1383  */
1384  ret = pSdbGetMatchingExe(hsdb, exenameNT.Buffer, NULL, NULL, 0, (SDBQUERYRESULT_VISTA*)&query);
1385  ok(!ret, "SdbGetMatchingExe should not succeed for %d.\n", cur);
1386 
1387  RtlFreeUnicodeString(&exenameNT);
1388  }
1389 
1390  if (test_exedata[cur].extra_file)
1391  DeleteFileW(testfile);
1393 
1394  if (test_exedata[cur].env_var)
1395  {
1396  SetEnvironmentVariableA("__COMPAT_LAYER", NULL);
1397  }
1398 }
DWORD TAGREF
static PDB pdb
Definition: db.cpp:170
GLdouble n
Definition: glext.h:7729
const char * wine_dbgstr_guid(const GUID *guid)
Definition: ecma_167.h:138
DWORD adwExeFlags_0
Definition: db.cpp:869
static void check_adwExeFlags(DWORD adwExeFlags_0, SDBQUERYRESULT_T &query, const char *file, int line, size_t cur)
Definition: db.cpp:1207
const char * env_var
Definition: db.cpp:872
#define TAG_EXE
Definition: db.cpp:85
static BOOL IsUserAdmin()
Definition: db.cpp:1184
unsigned int BOOL
Definition: ntddk_ex.h:94
#define WINVER_WIN10
static void test_is_testdb(PDB pdb)
Definition: db.cpp:1169
BOOL WINAPI DeleteFileW(IN LPCWSTR lpFileName)
Definition: delete.c:39
smooth NULL
Definition: ftsmooth.c:416
static LPWSTR exenameW
Definition: FindFiles.c:28
const WCHAR * extra_file
Definition: db.cpp:866
static DWORD g_WinVersion
#define match_strw_attr
Definition: db.cpp:657
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define _countof(array)
Definition: sndvol32.h:68
BOOL WINAPI DECLSPEC_HOTPATCH SetEnvironmentVariableA(IN LPCSTR lpName, IN LPCSTR lpValue)
Definition: environ.c:218
static char workdir[MAX_PATH]
Definition: batch.c:26
TAGREF trApphelp
Definition: db.cpp:871
#define MAX_PATH
Definition: compat.h:26
#define swprintf(buf, format,...)
Definition: sprintf.c:56
unsigned long DWORD
Definition: ntddk_ex.h:95
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
int ret
#define WINVER_WIN7
static const WCHAR L[]
Definition: oid.c:1250
#define test_create_exe
#define GUID_NULL
Definition: ks.h:106
static struct @1580 test_exedata[5]
#define WINVER_WIN8
#define WINVER_VISTA
TAGREF atrLayers_0
Definition: db.cpp:870
#define ok(value,...)
Definition: atltest.h:57
#define TAG_LAYER
Definition: db.cpp:88
#define TAG_NAME
Definition: db.cpp:96
#define test_create_file
BOOL WINAPI IsEqualGUID(REFGUID rguid1, REFGUID rguid2)
Definition: compobj.c:4112
Definition: fs_rec.h:142
#define skip(...)
Definition: atltest.h:64
Definition: name.c:38
static PDB(WINAPI *pSdbOpenDatabase)(LPCWSTR
DWORD TAGID
static char * exename
Definition: process.c:101
#define memset(x, y, z)
Definition: compat.h:39
GLenum query
Definition: glext.h:7781
NTSYSAPI BOOLEAN NTAPI RtlDosPathNameToNtPathName_U(_In_opt_z_ PCWSTR DosPathName, _Out_ PUNICODE_STRING NtPathName, _Out_opt_ PCWSTR *NtFileNamePart, _Out_opt_ PRTL_RELATIVE_NAME_U DirectoryInfo)

◆ test_Sdb()

static void test_Sdb ( void  )
static

Definition at line 238 of file db.cpp.

239 {
240  static const WCHAR temp[] = L"temp";
241  static const WCHAR path1[] = L"temp.sdb";
242  static const WCHAR path2[] = L"temp2.bin";
243  static const WCHAR tag_size_string[] = L"SIZE";
244  static const WCHAR tag_flag_lua_string[] = L"FLAG_LUA";
245  static const WCHAR invalid_tag[] = L"InvalidTag";
246  static const TAG tags[5] = {
249  };
250  WCHAR buffer[6] = { 0 };
251  PDB pdb;
252  QWORD qword;
253  DWORD dword;
254  WORD word;
255  BOOL ret;
256  HANDLE file; /* temp file created for testing purpose */
257  TAG tag;
258  TAGID tagid, ptagid, stringref = 6;
259  LPCWSTR string;
260  PBYTE binary;
261 
262  pdb = pSdbCreateDatabase(path1, DOS_PATH);
263  ok(pdb != NULL, "failed to create database\n");
264  if (pdb != NULL)
265  {
266  ret = pSdbWriteDWORDTag(pdb, tags[0], 0xDEADBEEF);
267  ok(ret, "failed to write DWORD tag\n");
268  ret = pSdbWriteQWORDTag(pdb, tags[1], 0xDEADBEEFBABE);
269  ok(ret, "failed to write QWORD tag\n");
270  ret = pSdbWriteStringRefTag(pdb, tags[2], stringref);
271  ok(ret, "failed to write stringref tag\n");
272  tagid = pSdbBeginWriteListTag(pdb, tags[3]);
273  ok(tagid != TAGID_NULL, "unexpected NULL tagid\n");
274  ret = pSdbWriteStringTag(pdb, tags[4], temp);
275  ok(ret, "failed to write string tag\n");
276  ret = pSdbWriteNULLTag(pdb, TAG_GENERAL);
277  ok(ret, "failed to write NULL tag\n");
278  ret = pSdbWriteWORDTag(pdb, TAG_MATCH_MODE, 0xACE);
279  ok(ret, "failed to write WORD tag\n");
280  ret = pSdbEndWriteListTag(pdb, tagid);
281  ok(ret, "failed to update list size\n");
282  /* [Err ][SdbCloseDatabase ] Failed to close the file. */
283  pSdbCloseDatabaseWrite(pdb);
284  }
285 
286  /* [Err ][SdbGetDatabaseID ] Failed to get root tag */
287  pdb = pSdbOpenDatabase(path1, DOS_PATH);
288  ok(pdb != NULL, "unexpected NULL handle\n");
289 
290  if (pdb)
291  {
292  tagid = pSdbGetFirstChild(pdb, TAGID_ROOT);
293  ok(tagid == _TAGID_ROOT, "unexpected tagid %u, expected %u\n", tagid, _TAGID_ROOT);
294 
295  tag = pSdbGetTagFromTagID(pdb, tagid);
296  ok(tag == TAG_SIZE, "unexpected tag 0x%x, expected 0x%x\n", tag, TAG_SIZE);
297 
298  string = pSdbTagToString(tag);
299  ok(lstrcmpW(string, tag_size_string) == 0, "unexpected string %s, expected %s\n",
300  wine_dbgstr_w(string), wine_dbgstr_w(tag_size_string));
301 
302  dword = pSdbReadDWORDTag(pdb, tagid, 0);
303  ok(dword == 0xDEADBEEF, "unexpected value %u, expected 0xDEADBEEF\n", dword);
304 
305  tagid = pSdbGetNextChild(pdb, TAGID_ROOT, tagid);
306  ok(tagid == _TAGID_ROOT + sizeof(TAG) + sizeof(DWORD), "unexpected tagid %u, expected %u\n",
307  tagid, _TAGID_ROOT + sizeof(TAG) + sizeof(DWORD));
308 
309  tag = pSdbGetTagFromTagID(pdb, tagid);
310  ok(tag == TAG_FLAG_LUA, "unexpected tag 0x%x, expected 0x%x\n", tag, TAG_FLAG_LUA);
311 
312  string = pSdbTagToString(tag);
313  if (g_WinVersion >= WINVER_VISTA)
314  {
315  ok(lstrcmpW(string, tag_flag_lua_string) == 0, "unexpected string %s, expected %s\n",
316  wine_dbgstr_w(string), wine_dbgstr_w(tag_flag_lua_string));
317  }
318  else
319  {
320  ok(lstrcmpW(string, invalid_tag) == 0, "unexpected string %s, expected %s\n",
321  wine_dbgstr_w(string), wine_dbgstr_w(invalid_tag));
322  }
323 
324  qword = pSdbReadQWORDTag(pdb, tagid, 0);
325  ok(qword == 0xDEADBEEFBABE, "unexpected value 0x%I64x, expected 0xDEADBEEFBABE\n", qword);
326 
327  tagid = pSdbGetNextChild(pdb, TAGID_ROOT, tagid);
328  string = pSdbGetStringTagPtr(pdb, tagid);
329  ok(string && (lstrcmpW(string, temp) == 0), "unexpected string %s, expected %s\n",
330  wine_dbgstr_w(string), wine_dbgstr_w(temp));
331 
332  ptagid = pSdbGetNextChild(pdb, TAGID_ROOT, tagid);
333  tagid = pSdbGetFirstChild(pdb, ptagid);
334 
335  string = pSdbGetStringTagPtr(pdb, tagid);
336  ok(string && (lstrcmpW(string, temp) == 0), "unexpected string %s, expected %s\n",
337  wine_dbgstr_w(string), wine_dbgstr_w(temp));
338 
339  ok(pSdbReadStringTag(pdb, tagid, buffer, 6), "failed to write string to buffer\n");
340  /* [Err ][SdbpReadTagData ] Buffer too small. Avail: 6, Need: 10. */
341  ok(!pSdbReadStringTag(pdb, tagid, buffer, 3), "string was written to buffer, but failure was expected");
342  ok(pSdbGetTagDataSize(pdb, tagid) == 5 * sizeof(WCHAR), "string has unexpected size\n");
343 
344  tagid = pSdbGetNextChild(pdb, ptagid, tagid);
345  tag = pSdbGetTagFromTagID(pdb, tagid);
346  ok(tag == TAG_GENERAL, "unexpected tag 0x%x, expected 0x%x\n", tag, TAG_GENERAL);
347  ok(pSdbGetTagDataSize(pdb, tagid) == 0, "null tag with size > 0\n");
348 
349  tagid = pSdbGetNextChild(pdb, ptagid, tagid);
350  word = pSdbReadWORDTag(pdb, tagid, 0);
351  ok(word == 0xACE, "unexpected value 0x%x, expected 0x%x\n", word, 0xACE);
352 
354 
355  pSdbCloseDatabase(pdb);
356  }
358 
360  ok(file != INVALID_HANDLE_VALUE, "failed to open file\n");
361  Write(file, &qword, 8);
362  CloseHandle(file);
363 
364  pdb = pSdbCreateDatabase(path1, DOS_PATH);
365  ok(pdb != NULL, "unexpected NULL handle\n");
366 
367  if (pdb)
368  {
369  ret = pSdbWriteBinaryTagFromFile(pdb, TAG_DATA_BITS, path2);
370  ok(ret, "failed to write tag from binary file\n");
371  pSdbCloseDatabaseWrite(pdb); /* [Err ][SdbCloseDatabase ] Failed to close the file. */
373 
374  /* FIXME: doesnt work on win10?! */
375  pdb = pSdbOpenDatabase(path1, DOS_PATH);
377  {
378  /* ERROR,SdbOpenDatabaseEx,845,Failed to open SDB - File size too large or small. */
379  ok(pdb != NULL, "unexpected NULL handle\n");
380  }
381  if (pdb)
382  {
383  binary = (PBYTE)pSdbGetBinaryTagData(pdb, _TAGID_ROOT);
384  ok(memcmp(binary, &qword, 8) == 0, "binary data is corrupt\n");
385  ret = pSdbReadBinaryTag(pdb, _TAGID_ROOT, (PBYTE)buffer, 12);
386  ok(ret, "failed to read binary tag\n");
387  ok(memcmp(buffer, &qword, 8) == 0, "binary data is corrupt\n");
388  pSdbCloseDatabase(pdb);
389  }
390  }
392 }
static const WCHAR path2[]
Definition: path.c:29
const char * tags[7 *8]
Definition: apphelp.c:214
#define CloseHandle
Definition: compat.h:407
static PDB pdb
Definition: db.cpp:170
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
char * wine_dbgstr_w(const wchar_t *wstr)
Definition: atltest.h:87
int WINAPI lstrcmpW(LPCWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:170
#define TAG_GENERAL
Definition: db.cpp:116
#define INVALID_HANDLE_VALUE
Definition: compat.h:400
Definition: ecma_167.h:138
GLuint buffer
Definition: glext.h:5915
static PBYTE
Definition: db.cpp:157
#define TAG_SIZE
Definition: db.cpp:58
#define TAG_STRINGTABLE
Definition: db.cpp:92
unsigned int BOOL
Definition: ntddk_ex.h:94
#define _TAGID_ROOT
Definition: db.cpp:38
#define WINVER_WIN10
#define GENERIC_WRITE
Definition: nt_native.h:90
BOOL WINAPI DeleteFileW(IN LPCWSTR lpFileName)
Definition: delete.c:39
static void Write(HANDLE file, LPCVOID buffer, DWORD size)
Definition: db.cpp:183
smooth NULL
Definition: ftsmooth.c:416
#define TAG_FLAG_LUA
Definition: db.cpp:81
static void test_GetDatabaseInformationEmpty(PDB pdb)
Definition: db.cpp:189
static DWORD g_WinVersion
static const WCHAR path1[]
Definition: path.c:28
__wchar_t WCHAR
Definition: xmlstorage.h:180
UINT64 QWORD
Definition: shimdbg.c:104
#define DOS_PATH
Definition: db.cpp:30
#define TAG_DATA_BITS
Definition: db.cpp:119
const char file[]
Definition: icontest.c:11
unsigned short WORD
Definition: ntddk_ex.h:93
unsigned long DWORD
Definition: ntddk_ex.h:95
#define OPEN_ALWAYS
Definition: disk.h:70
const GLuint GLenum const GLvoid * binary
Definition: glext.h:7538
int ret
#define FILE_ATTRIBUTE_NORMAL
Definition: compat.h:126
static const WCHAR L[]
Definition: oid.c:1250
#define TAG_STRINGTABLE_ITEM
Definition: db.cpp:94
char string[160]
Definition: util.h:11
#define TAGID_NULL
Definition: db.cpp:36
#define WINVER_VISTA
static calc_node_t temp
Definition: rpn_ieee.c:38
#define ok(value,...)
Definition: atltest.h:57
#define TAG_NAME
Definition: db.cpp:96
#define TAGID_ROOT
Definition: db.cpp:37
Definition: fs_rec.h:142
const WCHAR * word
Definition: lex.c:36
#define CreateFileW
Definition: compat.h:409
DWORD TAGID
#define TAG_MATCH_MODE
Definition: db.cpp:56
BYTE * PBYTE
Definition: pedump.c:66
Definition: fci.c:126
char * tag
Definition: main.c:59

Referenced by START_TEST().

◆ test_stringtable()

static void test_stringtable ( void  )
static

Definition at line 525 of file db.cpp.

526 {
527  static const WCHAR path1[] = {'t','e','s','t','.','s','d','b',0};
528  static const WCHAR test1[] = {'t','e','s','t','1',0};
529  static const WCHAR test2[] = {'T','e','s','t','1',0};
530  static const WCHAR test3[] = {'T','E','s','t','1',0};
531  static const WCHAR test4[] = {'T','E','S','T','1',0};
532  static const WCHAR test5[] = {'T','E','S','T','2',0};
533  static const WCHAR lipsum[] = {'L','o','r','e','m',' ','i','p','s','u','m',' ','d','o','l','o','r',' ','s','i','t',' ','a','m','e','t',',',' ','c','o','n','s','e','c','t','e','t','u','r',' ','a','d','i','p','i','s','c','i','n','g',' ','e','l','i','t','.',' ','N','u','l','l','a',' ','a','n','t','e',' ','r','i','s','u','s',',',' ','m','a','l','e','s','u','a','d','a',' ','s','e','d',' ','i','a','c','u','l','i','s',' ','l','u','c','t','u','s',',',' ','o','r','n','a','r','e',' ','p','u','l','v','i','n','a','r',' ','v','e','l','i','t','.',' ','L','o','r','e','m',' ','i','p','s','u','m',' ','d','o','l','o','r',' ','s','i','t',' ','a','m','e','t',',',' ','c','o','n','s','e','c','t','e','t','u','r',' ','a','d','i','p','i','s','c','i','n','g',' ','e','l','i','t','.',' ','I','n','t','e','g','e','r',' ','q','u','i','s',' ','f','e','l','i','s',' ','u','t',' ','l','e','o',' ','e','l','e','i','f','e','n','d',' ','u','l','t','r','i','c','e','s',' ','f','i','n','i','b','u','s',' ','e','u',' ','d','o','l','o','r','.',' ','I','n',' ','b','i','b','e','n','d','u','m',',',' ','e','r','o','s',' ','e','u',' ','f','a','u','c','i','b','u','s',' ','c','o','n','s','e','q','u','a','t',',',' ','n','i','s','i',' ','m','a','g','n','a',' ','v','e','n','e','n','a','t','i','s',' ','j','u','s','t','o',',',' ','a','t',' ','t','r','i','s','t','i','q','u','e',' ','m','e','t','u','s',' ','d','o','l','o','r',' ','u','t',' ','r','i','s','u','s','.',' ','N','u','n','c',' ','e','u',' ','o','d','i','o',' ','d','i','g','n','i','s','s','i','m',',',' ','o','r','n','a','r','e',' ','a','n','t','e',' ','g','r','a','v','i','d','a',',',' ','l','o','b','o','r','t','i','s',' ','e','r','o','s','.',' ','C','r','a','s',' ','s','e','m',' ','e','x',',',' ','c','o','n','s','e','c','t','e','t','u','r',' ','p','u','l','v','i','n','a','r',' ','t','i','n','c','i','d','u','n','t',' ','e','u',',',' ','c','o','n','g','u','e',' ','a',' ','e','r','o','s','.',' ','C','u','r','a','b','i','t','u','r',' ','e','r','o','s',' ','e','r','a','t',',',' ','p','e','l','l','e','n','t','e','s','q','u','e',' ','e','t',' ','n','i','b','h',' ','q','u','i','s',',',' ','i','n','t','e','r','d','u','m',' ','t','e','m','p','o','r',' ','o','d','i','o','.',' ','E','t','i','a','m',' ','s','a','p','i','e','n',' ','s','a','p','i','e','n',',',' ','a','l','i','q','u','a','m',' ','u','t',' ','a','l','i','q','u','a','m',' ','a','t',',',' ','s','a','g','i','t','t','i','s',' ','e','u',' ','m','a','g','n','a','.',' ','M','a','e','c','e','n','a','s',' ','m','a','g','n','a',' ','m','a','g','n','a',',',' ','s','u','s','c','i','p','i','t',' ','u','t',' ','l','o','r','e','m',' ','u','t',',',' ','v','a','r','i','u','s',' ','p','r','e','t','i','u','m',' ','f','e','l','i','s','.',' ','I','n','t','e','g','e','r',' ','t','i','n','c','i','d','u','n','t',',',' ','m','e','t','u','s',' ','v','e','l',' ','s','o','l','l','i','c','i','t','u','d','i','n',' ','f','i','n','i','b','u','s',',',' ','f','e','l','i','s',' ','e','r','a','t',' ','m','o','l','e','s','t','i','e',' ','u','r','n','a',',',' ','a',' ','c','o','n','d','i','m','e','n','t','u','m',' ','a','u','g','u','e',' ','a','r','c','u',' ','v','i','t','a','e',' ','r','i','s','u','s','.',' ','E','t','i','a','m',' ','i','d',' ','s','a','g','i','t','t','i','s',' ','q','u','a','m','.',' ','M','o','r','b','i',' ','a',' ','u','l','t','r','i','c','i','e','s',' ','n','u','n','c','.',' ','P','h','a','s','e','l','l','u','s',' ','e','r','o','s',' ','r','i','s','u','s',',',' ','c','u','r','s','u','s',' ','u','l','l','a','m','c','o','r','p','e','r',' ','m','a','s','s','a',' ','s','e','d',',',' ','d','i','g','n','i','s','s','i','m',' ','c','o','n','s','e','q','u','a','t',' ','l','i','g','u','l','a','.',' ','A','l','i','q','u','a','m',' ','t','u','r','p','i','s',' ','a','r','c','u',',',' ','a','c','c','u','m','s','a','n',' ','q','u','i','s',' ','s','a','p','i','e','n',' ','v','i','t','a','e',',',' ','l','a','c','i','n','i','a',' ','e','u','i','s','m','o','d',' ','n','i','s','l','.',' ','M','a','u','r','i','s',' ','i','d',' ','f','e','l','i','s',' ','s','e','m','.',0};
534  /* Last char changed from '.' to '!' */
535  static const WCHAR lipsum2[] = {'L','o','r','e','m',' ','i','p','s','u','m',' ','d','o','l','o','r',' ','s','i','t',' ','a','m','e','t',',',' ','c','o','n','s','e','c','t','e','t','u','r',' ','a','d','i','p','i','s','c','i','n','g',' ','e','l','i','t','.',' ','N','u','l','l','a',' ','a','n','t','e',' ','r','i','s','u','s',',',' ','m','a','l','e','s','u','a','d','a',' ','s','e','d',' ','i','a','c','u','l','i','s',' ','l','u','c','t','u','s',',',' ','o','r','n','a','r','e',' ','p','u','l','v','i','n','a','r',' ','v','e','l','i','t','.',' ','L','o','r','e','m',' ','i','p','s','u','m',' ','d','o','l','o','r',' ','s','i','t',' ','a','m','e','t',',',' ','c','o','n','s','e','c','t','e','t','u','r',' ','a','d','i','p','i','s','c','i','n','g',' ','e','l','i','t','.',' ','I','n','t','e','g','e','r',' ','q','u','i','s',' ','f','e','l','i','s',' ','u','t',' ','l','e','o',' ','e','l','e','i','f','e','n','d',' ','u','l','t','r','i','c','e','s',' ','f','i','n','i','b','u','s',' ','e','u',' ','d','o','l','o','r','.',' ','I','n',' ','b','i','b','e','n','d','u','m',',',' ','e','r','o','s',' ','e','u',' ','f','a','u','c','i','b','u','s',' ','c','o','n','s','e','q','u','a','t',',',' ','n','i','s','i',' ','m','a','g','n','a',' ','v','e','n','e','n','a','t','i','s',' ','j','u','s','t','o',',',' ','a','t',' ','t','r','i','s','t','i','q','u','e',' ','m','e','t','u','s',' ','d','o','l','o','r',' ','u','t',' ','r','i','s','u','s','.',' ','N','u','n','c',' ','e','u',' ','o','d','i','o',' ','d','i','g','n','i','s','s','i','m',',',' ','o','r','n','a','r','e',' ','a','n','t','e',' ','g','r','a','v','i','d','a',',',' ','l','o','b','o','r','t','i','s',' ','e','r','o','s','.',' ','C','r','a','s',' ','s','e','m',' ','e','x',',',' ','c','o','n','s','e','c','t','e','t','u','r',' ','p','u','l','v','i','n','a','r',' ','t','i','n','c','i','d','u','n','t',' ','e','u',',',' ','c','o','n','g','u','e',' ','a',' ','e','r','o','s','.',' ','C','u','r','a','b','i','t','u','r',' ','e','r','o','s',' ','e','r','a','t',',',' ','p','e','l','l','e','n','t','e','s','q','u','e',' ','e','t',' ','n','i','b','h',' ','q','u','i','s',',',' ','i','n','t','e','r','d','u','m',' ','t','e','m','p','o','r',' ','o','d','i','o','.',' ','E','t','i','a','m',' ','s','a','p','i','e','n',' ','s','a','p','i','e','n',',',' ','a','l','i','q','u','a','m',' ','u','t',' ','a','l','i','q','u','a','m',' ','a','t',',',' ','s','a','g','i','t','t','i','s',' ','e','u',' ','m','a','g','n','a','.',' ','M','a','e','c','e','n','a','s',' ','m','a','g','n','a',' ','m','a','g','n','a',',',' ','s','u','s','c','i','p','i','t',' ','u','t',' ','l','o','r','e','m',' ','u','t',',',' ','v','a','r','i','u','s',' ','p','r','e','t','i','u','m',' ','f','e','l','i','s','.',' ','I','n','t','e','g','e','r',' ','t','i','n','c','i','d','u','n','t',',',' ','m','e','t','u','s',' ','v','e','l',' ','s','o','l','l','i','c','i','t','u','d','i','n',' ','f','i','n','i','b','u','s',',',' ','f','e','l','i','s',' ','e','r','a','t',' ','m','o','l','e','s','t','i','e',' ','u','r','n','a',',',' ','a',' ','c','o','n','d','i','m','e','n','t','u','m',' ','a','u','g','u','e',' ','a','r','c','u',' ','v','i','t','a','e',' ','r','i','s','u','s','.',' ','E','t','i','a','m',' ','i','d',' ','s','a','g','i','t','t','i','s',' ','q','u','a','m','.',' ','M','o','r','b','i',' ','a',' ','u','l','t','r','i','c','i','e','s',' ','n','u','n','c','.',' ','P','h','a','s','e','l','l','u','s',' ','e','r','o','s',' ','r','i','s','u','s',',',' ','c','u','r','s','u','s',' ','u','l','l','a','m','c','o','r','p','e','r',' ','m','a','s','s','a',' ','s','e','d',',',' ','d','i','g','n','i','s','s','i','m',' ','c','o','n','s','e','q','u','a','t',' ','l','i','g','u','l','a','.',' ','A','l','i','q','u','a','m',' ','t','u','r','p','i','s',' ','a','r','c','u',',',' ','a','c','c','u','m','s','a','n',' ','q','u','i','s',' ','s','a','p','i','e','n',' ','v','i','t','a','e',',',' ','l','a','c','i','n','i','a',' ','e','u','i','s','m','o','d',' ','n','i','s','l','.',' ','M','a','u','r','i','s',' ','i','d',' ','f','e','l','i','s',' ','s','e','m','!',0};
536  static const WCHAR empty[] = {0};
537  static const WCHAR* all[] = { test1, test2, test3, test4, test5, lipsum, lipsum2, empty };
538  static const TAGID expected_str[] = { 0xc, 0x12, 0x18, 0x1e, 0x24, 0x2a, 0x30, 0x36 };
539  static const TAGID expected_tab[] = { 6, 0x18, 0x2a, 0x3c, 0x4e, 0x60, 0x846, 0x102c };
540  DWORD n, j;
541 
542  for (n = 0; n < (sizeof(all) / sizeof(all[0])); ++n)
543  {
544  PDB pdb;
545  TAGID tagstr, table, expected_table;
546 
547  write_db_strings(path1, all, n+1);
548 
549  pdb = pSdbOpenDatabase(path1, DOS_PATH);
550  ok(pdb != NULL, "Expected a valid database\n");
551  if (!pdb)
552  {
554  continue;
555  }
556  tagstr = pSdbFindFirstTag(pdb, TAGID_ROOT, TAG_NAME);
557  for (j = 0; j <= n; ++j)
558  {
559  ok(tagstr == expected_str[j], "Expected tagstr to be 0x%x, was 0x%x for %u/%u\n", expected_str[j], tagstr, j, n);
560  if (tagstr)
561  {
562  LPWSTR data;
563  DWORD size;
564  TAG tag = pSdbGetTagFromTagID(pdb, tagstr);
565  ok(tag == TAG_NAME, "Expected tag to be TAG_NAME, was 0x%x for %u/%u\n", tag, j, n);
566  size = pSdbGetTagDataSize(pdb, tagstr);
567  ok(size == 4, "Expected datasize to be 4, was %u for %u/%u\n", size, j, n);
568  data = pSdbGetStringTagPtr(pdb, tagstr);
569  ok(data && !wcsicmp(data, all[j]), "Expected data to be %s was %s for %u/%u\n", wine_dbgstr_w(all[j]), wine_dbgstr_w(data), j, n);
570  }
571  tagstr = pSdbFindNextTag(pdb, TAGID_ROOT, tagstr);
572  }
573  ok(tagstr == TAGID_NULL, "Expected to be at the end for %u\n", n);
574 
575 
576  table = pSdbFindFirstTag(pdb, TAGID_ROOT, TAG_STRINGTABLE);
577  expected_table = 0xc + (n+1)*6;
578  ok(table == expected_table, "Expected to find a stringtable at 0x%x instead of 0x%x for %u\n", expected_table, table, n);
579  if (table)
580  {
581  tagstr = pSdbFindFirstTag(pdb, table, TAG_STRINGTABLE_ITEM);
582  for (j = 0; j <= n; ++j)
583  {
584  ok(tagstr == (expected_tab[j] + expected_table), "Expected tagstr to be 0x%x, was 0x%x for %u/%u\n", (expected_tab[j] + expected_table), tagstr, j, n);
585  if (tagstr)
586  {
587  LPWSTR data;
588  DWORD size, expected_size;
589  TAG tag = pSdbGetTagFromTagID(pdb, tagstr);
590  ok(tag == TAG_STRINGTABLE_ITEM, "Expected tag to be TAG_NAME, was 0x%x for %u/%u\n", tag, j, n);
591  size = pSdbGetTagDataSize(pdb, tagstr);
592  expected_size = (lstrlenW(all[j])+1) * 2;
593  ok(size == expected_size, "Expected datasize to be %u, was %u for %u/%u\n", expected_size, size, j, n);
594  data = pSdbGetStringTagPtr(pdb, tagstr);
595  ok(data && !wcsicmp(data, all[j]), "Expected data to be %s was %s for %u/%u\n", wine_dbgstr_w(all[j]), wine_dbgstr_w(data), j, n);
596  }
597  tagstr = pSdbFindNextTag(pdb, TAGID_ROOT, tagstr);
598  }
599  ok(tagstr == TAGID_NULL, "Expected to be at the end for %u\n", n);
600  }
601 
602  pSdbCloseDatabase(pdb);
604  }
605 }
static PDB pdb
Definition: db.cpp:170
void test3(void)
Definition: hivetest.c:423
char * wine_dbgstr_w(const wchar_t *wstr)
Definition: atltest.h:87
GLdouble n
Definition: glext.h:7729
Definition: ecma_167.h:138
GLenum GLsizei GLenum GLenum const GLvoid * table
Definition: glext.h:5644
#define lstrlenW
Definition: compat.h:416
static void write_db_strings(const WCHAR *name, const WCHAR *data[], size_t count)
Definition: db.cpp:509
#define TAG_STRINGTABLE
Definition: db.cpp:92
BOOL WINAPI DeleteFileW(IN LPCWSTR lpFileName)
Definition: delete.c:39
smooth NULL
Definition: ftsmooth.c:416
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 GLint GLint j
Definition: glfuncs.h:250
static const WCHAR path1[]
Definition: path.c:28
GLsizeiptr size
Definition: glext.h:5919
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define DOS_PATH
Definition: db.cpp:30
void test1(void)
Definition: hivetest.c:366
unsigned long DWORD
Definition: ntddk_ex.h:95
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
#define TAG_STRINGTABLE_ITEM
Definition: db.cpp:94
#define wcsicmp
Definition: string.h:1152
#define TAGID_NULL
Definition: db.cpp:36
void test2(void)
Definition: regtest.c:173
#define ok(value,...)
Definition: atltest.h:57
#define TAG_NAME
Definition: db.cpp:96
BOOL empty
Definition: button.c:170
#define TAGID_ROOT
Definition: db.cpp:37
Definition: fs_rec.h:142
DWORD TAGID
WCHAR * LPWSTR
Definition: xmlstorage.h:184
void test5(void)
Definition: hivetest.c:623
void test4(void)
Definition: hivetest.c:461

Referenced by START_TEST().

◆ test_TagRef()

static void test_TagRef ( void  )
static

Definition at line 1596 of file db.cpp.

1597 {
1598  WCHAR tmpdir[MAX_PATH], dbpath[MAX_PATH];
1599  BOOL ret;
1600  HSDB hsdb;
1601  PDB pdb;
1602  TAGID db;
1603  DWORD size;
1604  TAGREF tr;
1605 
1607  ok(ret, "GetTempPathA error: %d\n", GetLastError());
1608 
1609  /* SdbInitDatabase needs an nt-path */
1610  swprintf(dbpath, L"\\??\\%stest.sdb", tmpdir);
1611 
1612  test_create_db(dbpath + 4, g_WinVersion >= WINVER_WIN10);
1613 
1614  hsdb = pSdbInitDatabase(HID_DATABASE_FULLPATH, dbpath);
1615 
1616  /* HSDB is the only arg that can't be null */
1617  ret = pSdbTagRefToTagID(hsdb, 0, NULL, NULL);
1618  ok(ret == TRUE, "Expected ret to be TRUE, was: %d\n", ret);
1619 
1620  size = test_get_db_size();
1621 
1622  pdb = (PDB)&db;
1623  db = 12345;
1624  ret = pSdbTagRefToTagID(hsdb, size - 1, &pdb, &db);
1625  ok(ret == TRUE, "Expected ret to be TRUE, was: %d\n", ret);
1626  ok(pdb != NULL, "Expected a result, got: %p\n", pdb);
1627  ok(db == (size - 1), "Expected %u, got: %u\n", size - 1, db);
1628 
1629  /* Convert it back. */
1630  tr = 0x12345678;
1631  ret = pSdbTagIDToTagRef(hsdb, pdb, db, &tr);
1632  ok(ret == TRUE, "Expected ret to be TRUE, was: %d\n", ret);
1633  ok(tr == (size - 1), "Expected %u, got: %u\n", size - 1, tr);
1634 
1635  pdb = (PDB)&db;
1636  db = 12345;
1637  ret = pSdbTagRefToTagID(hsdb, size, &pdb, &db);
1638  ok(ret == TRUE, "Expected ret to be TRUE, was: %d\n", ret);
1639  ok(pdb != NULL, "Expected a result, got: %p\n", pdb);
1640  ok(db == size, "Expected %u, got: %u\n", size, db);
1641 
1642  tr = 0x12345678;
1643  ret = pSdbTagIDToTagRef(hsdb, pdb, db, &tr);
1644  ok(ret == TRUE, "Expected ret to be TRUE, was: %d\n", ret);
1645  ok(tr == size, "Expected %u, got: %u\n", size, tr);
1646 
1647  pdb = (PDB)&db;
1648  db = 12345;
1649  ret = pSdbTagRefToTagID(hsdb, size + 1, &pdb, &db);
1650  ok(ret == TRUE, "Expected ret to be TRUE, was: %d\n", ret);
1651  ok(pdb != NULL, "Expected a result, got: %p\n", pdb);
1652  ok(db == (size + 1), "Expected %u, got: %u\n", size + 1, db);
1653 
1654  tr = 0x12345678;
1655  ret = pSdbTagIDToTagRef(hsdb, pdb, db, &tr);
1656  ok(ret == TRUE, "Expected ret to be TRUE, was: %d\n", ret);
1657  ok(tr == (size + 1), "Expected %u, got: %u\n", (size + 1), tr);
1658 
1659  pdb = (PDB)&db;
1660  db = 12345;
1661  ret = pSdbTagRefToTagID(hsdb, 0x0fffffff, &pdb, &db);
1662  ok(ret == TRUE, "Expected ret to be TRUE, was: %d\n", ret);
1663  ok(pdb != NULL, "Expected a result, got: %p\n", pdb);
1664  ok(db == 0x0fffffff, "Expected %u, got: %u\n", 0x0fffffff, db);
1665 
1666  tr = 0x12345678;
1667  ret = pSdbTagIDToTagRef(hsdb, pdb, db, &tr);
1668  ok(ret == TRUE, "Expected ret to be TRUE, was: %d\n", ret);
1669  ok(tr == 0x0fffffff, "Expected %u, got: %u\n", 0x0fffffff, tr);
1670 
1671  pdb = (PDB)&db;
1672  db = 12345;
1673  ret = pSdbTagRefToTagID(hsdb, 0x10000000, &pdb, &db);
1674  ok(ret == FALSE, "Expected ret to be FALSE, was: %d\n", ret);
1675  ok(pdb == NULL, "Expected no result, got: %p\n", pdb);
1676  ok(db == 0, "Expected no result, got: 0x%x\n", db);
1677 
1678  tr = 0x12345678;
1679  ret = pSdbTagIDToTagRef(hsdb, pdb, 0x10000000, &tr);
1680  ok(ret == FALSE, "Expected ret to be TRUE, was: %d\n", ret);
1681  ok(tr == 0, "Expected %u, got: %u\n", 0, tr);
1682 
1683  pdb = NULL;
1684  db = TAGID_NULL;
1685  ret = pSdbTagRefToTagID(hsdb, TAGID_ROOT, &pdb, NULL);
1686  ok(ret != FALSE, "Expected ret to be TRUE, was: %d\n", ret);
1687  ok(pdb != NULL, "Expected pdb to be valid\n");
1688 
1689  if (pdb == NULL)
1690  {
1691  skip("Cannot run tests without pdb\n");
1692  }
1693  else
1694  {
1695  db = pSdbFindFirstTag(pdb, TAGID_ROOT, TAG_DATABASE);
1696  if (db != TAGID_NULL)
1697  {
1698  TAGID child;
1699  child = pSdbGetFirstChild(pdb, db);
1700  while (child != TAGID_NULL)
1701  {
1702  PDB pdb_res;
1703  TAGID tagid_res;
1704  /* We are using a TAGID as a TAGREF here. */
1705  ret = pSdbTagRefToTagID(hsdb, child, &pdb_res, &tagid_res);
1706  ok(ret, "Expected SdbTagRefToTagID to succeed\n");
1707 
1708  /* For simple cases (primary DB) TAGREF == TAGID */
1709  tr = 0x12345678;
1710  ret = pSdbTagIDToTagRef(hsdb, pdb_res, tagid_res, &tr);
1711  ok(ret, "Expected SdbTagIDToTagRef to succeed\n");
1712  ok_hex(tr, (int)tagid_res);
1713 
1714  child = pSdbGetNextChild(pdb, db, child);
1715  }
1716  }
1717  else
1718  {
1719  skip("Cannot run tests without valid db tag\n");
1720  }
1721  }
1722 
1723  /* Get a tagref for our own layer */
1724  tr = pSdbGetLayerTagRef(hsdb, L"TestNewMode");
1725  ok_hex(tr, 0x18e);
1726 
1727  /* We cannot find a tagref from the main database. */
1728  tr = pSdbGetLayerTagRef(hsdb, L"256Color");
1729  ok_hex(tr, 0);
1730 
1731  pSdbReleaseDatabase(hsdb);
1732 
1733  DeleteFileW(dbpath + 4);
1734 }
DWORD TAGREF
#define TRUE
Definition: types.h:120
static PDB pdb
Definition: db.cpp:170
#define test_create_db
#define TAG_DATABASE
Definition: db.cpp:83
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
#define ok_hex(expression, result)
Definition: atltest.h:94
static HWND child
Definition: cursoricon.c:298
#define HID_DATABASE_FULLPATH
Definition: db.cpp:31
Definition: apphelp.h:27
DWORD WINAPI GetTempPathW(IN DWORD count, OUT LPWSTR path)
Definition: path.c:2079
unsigned int BOOL
Definition: ntddk_ex.h:94
#define WINVER_WIN10
BOOL WINAPI DeleteFileW(IN LPCWSTR lpFileName)
Definition: delete.c:39
smooth NULL
Definition: ftsmooth.c:416
static DWORD g_WinVersion
GLsizeiptr size
Definition: glext.h:5919
static char tmpdir[MAX_PATH]
Definition: shlexec.c:52
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define _countof(array)
Definition: sndvol32.h:68
#define MAX_PATH
Definition: compat.h:26
#define swprintf(buf, format,...)
Definition: sprintf.c:56
unsigned long DWORD
Definition: ntddk_ex.h:95
int ret
static const WCHAR L[]
Definition: oid.c:1250
#define TAGID_NULL
Definition: db.cpp:36
#define ok(value,...)
Definition: atltest.h:57
#define TAGID_ROOT
Definition: db.cpp:37
#define skip(...)
Definition: atltest.h:64
static PDB(WINAPI *pSdbOpenDatabase)(LPCWSTR
DWORD TAGID
DWORD test_get_db_size()
Definition: data.c:773

Referenced by START_TEST().

◆ test_write_ex()

static void test_write_ex ( void  )
static

Definition at line 399 of file db.cpp.

400 {
401  WCHAR path1[] = {'t','e','s','t','.','s','d','b',0};
402  WCHAR test1[] = {'T','E','S','T',0};
403  WCHAR test2[] = {'t','e','s','t',0};
404  PDB pdb;
405  TAGID tagdb, tagstr;
406  TAG tag;
407  DWORD size;
408  BOOL ret;
409  LPWSTR ptr;
410 
411  /* Write a small database */
412  pdb = pSdbCreateDatabase(path1, DOS_PATH);
413  ok(pdb != NULL, "Expected a valid database\n");
414  if (!pdb)
415  return;
416  tagdb = pSdbBeginWriteListTag(pdb, TAG_DATABASE);
417  ok(tagdb == 12, "Expected tag to be 12, was %u\n", tagdb);
418  ret = pSdbWriteStringTag(pdb, TAG_NAME, test1);
419  ret = pSdbWriteStringTag(pdb, TAG_NAME, test2);
420  ok(ret, "Expected SdbWriteStringTag to succeed\n");
421  ret = pSdbEndWriteListTag(pdb, tagdb);
422  ok(ret, "Expected SdbEndWriteListTag to succeed\n");
423 
424  tagdb = pSdbBeginWriteListTag(pdb, TAG_DATABASE);
425  ok(tagdb == 30, "Expected tag to be 24, was %u\n", tagdb);
426  ret = pSdbWriteStringTag(pdb, TAG_NAME, test1);
427  ret = pSdbWriteStringTag(pdb, TAG_NAME, test2);
428  ok(ret, "Expected SdbWriteStringTag to succeed\n");
429  ret = pSdbEndWriteListTag(pdb, tagdb);
430  ok(ret, "Expected SdbEndWriteListTag to succeed\n");
431 
432  pSdbCloseDatabaseWrite(pdb);
433 
434  /* Now validate it's contents */
435  pdb = pSdbOpenDatabase(path1, DOS_PATH);
436  ok(pdb != NULL, "Expected a valid database\n");
437  if (!pdb)
438  return;
439 
440  tagdb = pSdbFindFirstTag(pdb, TAGID_ROOT, TAG_DATABASE);
441  ok(tagdb == 12, "Expected tag to be 12, was %u\n", tagdb);
442  size = pSdbGetTagDataSize(pdb, tagdb);
443  ok(size == 12, "Expected size to be 12, was %u\n", size);
444 
445  tagstr = pSdbFindFirstTag(pdb, tagdb, TAG_NAME);
446  ok(tagstr == 18, "Expected string tag to be 18, was %u\n", tagstr);
447  tag = pSdbGetTagFromTagID(pdb, tagstr);
448  ok(tag == TAG_NAME, "Expected tag to be TAG_NAME, was 0x%x\n", (DWORD)tag);
449  size = pSdbGetTagDataSize(pdb, tagstr);
450  ok(size == 4, "Expected size to be 4, was 0x%x\n", size);
451 
452  tagstr = pSdbFindNextTag(pdb, tagdb, tagstr);
453