ReactOS 0.4.15-dev-8222-g9164419
MRUList.cpp File Reference
#include <apitest.h>
#include <winreg.h>
#include <shlwapi.h>
#include <shlobj.h>
#include <shlobj_undoc.h>
#include <shlguid_undoc.h>
#include <stdio.h>
#include <shlwapi_undoc.h>
#include <versionhelpers.h>
#include <strsafe.h>
#include <wine/test.h>
#include <pseh/pseh2.h>
Include dependency graph for MRUList.cpp:

Go to the source code of this file.

Macros

#define SUBKEY0   L"Software\\MRUListTest"
 
#define SUBSUBKEY0   L"Software\\MRUListTest\\0"
 
#define TEXT0   L"This is a test."
 
#define TEXT1   L"ReactOS rocks!"
 

Functions

static void MRUList_DataList_0 (void)
 
static INT MRUList_Check (LPCWSTR pszSubKey, LPCWSTR pszValueName, LPCVOID pvData, DWORD cbData)
 
static void MRUList_DataList_1 (void)
 
static void MRUList_DataList_2 (void)
 
static void MRUList_DataList (void)
 
static void MRUList_PidlList_0 (void)
 
static void MRUList_PidlList (void)
 
 START_TEST (MRUList)
 

Macro Definition Documentation

◆ SUBKEY0

#define SUBKEY0   L"Software\\MRUListTest"

Definition at line 21 of file MRUList.cpp.

◆ SUBSUBKEY0

#define SUBSUBKEY0   L"Software\\MRUListTest\\0"

Definition at line 22 of file MRUList.cpp.

◆ TEXT0

#define TEXT0   L"This is a test."

Definition at line 23 of file MRUList.cpp.

◆ TEXT1

#define TEXT1   L"ReactOS rocks!"

Definition at line 24 of file MRUList.cpp.

Function Documentation

◆ MRUList_Check()

static INT MRUList_Check ( LPCWSTR  pszSubKey,
LPCWSTR  pszValueName,
LPCVOID  pvData,
DWORD  cbData 
)
static

Definition at line 68 of file MRUList.cpp.

69{
70 BYTE abData[512];
71 LONG error;
72 DWORD dwSize = cbData;
73
74 error = SHGetValueW(HKEY_CURRENT_USER, pszSubKey, pszValueName, NULL, abData, &dwSize);
75 if (error != ERROR_SUCCESS)
76 return -999;
77
78#if 0
79 printf("dwSize: %ld\n", dwSize);
80 for (DWORD i = 0; i < dwSize; ++i)
81 {
82 printf("%02X ", abData[i]);
83 }
84 printf("\n");
85#endif
86
87 if (dwSize != cbData)
88 return +999;
89
90 if (!pvData)
91 return TRUE;
92
93 return memcmp(abData, pvData, cbData) == 0;
94}
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
#define ERROR_SUCCESS
Definition: deptool.c:10
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
DWORD WINAPI SHGetValueW(HKEY hKey, LPCWSTR lpszSubKey, LPCWSTR lpszValue, LPDWORD pwType, LPVOID pvData, LPDWORD pcbData)
Definition: reg.c:1236
unsigned long DWORD
Definition: ntddk_ex.h:95
#define printf
Definition: freeldr.h:97
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define error(str)
Definition: mkdosfs.c:1605
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:56
long LONG
Definition: pedump.c:60
_In_ ULONG _In_opt_ PVOID pvData
Definition: winddi.h:3749
#define HKEY_CURRENT_USER
Definition: winreg.h:11
unsigned char BYTE
Definition: xxhash.c:193

Referenced by MRUList_DataList(), and MRUList_PidlList_0().

◆ MRUList_DataList()

static void MRUList_DataList ( void  )
static

Definition at line 164 of file MRUList.cpp.

165{
167 {
168 skip("Vista+ doesn't support CLSID_MruLongList\n");
169 return;
170 }
171
173
174 LONG error;
177
180
182 ok_int(MRUList_Check(SUBKEY0, L"MRUListEx", "\x01\x00\x00\x00\x00\x00\x00\x00\xFF\xFF\xFF\xFF", 12), TRUE);
183
185 ok_int(MRUList_Check(SUBKEY0, L"MRUListEx", "\x01\x00\x00\x00\xFF\xFF\xFF\xFF", 8), TRUE);
186
191
192 error = SHSetValueW(HKEY_CURRENT_USER, SUBKEY0, L"MRUList", REG_SZ, L"ab", 3 * sizeof(WCHAR));
194 error = SHSetValueW(HKEY_CURRENT_USER, SUBKEY0, L"a", REG_BINARY, L"ABC", 4 * sizeof(WCHAR));
196 error = SHSetValueW(HKEY_CURRENT_USER, SUBKEY0, L"b", REG_BINARY, L"XYZ", 4 * sizeof(WCHAR));
198
200 ok_int(MRUList_Check(SUBKEY0, L"MRUListEx", "\x00\x00\x00\x00\x01\x00\x00\x00\xFF\xFF\xFF\xFF", 12), TRUE);
201
206
208}
static void MRUList_DataList_1(void)
Definition: MRUList.cpp:96
static void MRUList_DataList_0(void)
Definition: MRUList.cpp:26
static void MRUList_DataList_2(void)
Definition: MRUList.cpp:131
static INT MRUList_Check(LPCWSTR pszSubKey, LPCWSTR pszValueName, LPCVOID pvData, DWORD cbData)
Definition: MRUList.cpp:68
#define SUBKEY0
Definition: MRUList.cpp:21
#define ok_long(expression, result)
Definition: atltest.h:133
#define skip(...)
Definition: atltest.h:64
#define ok_int(expression, result)
Definition: atltest.h:134
DWORD WINAPI SHDeleteValueW(HKEY hKey, LPCWSTR lpszSubKey, LPCWSTR lpszValue)
Definition: reg.c:1762
DWORD WINAPI SHDeleteKeyW(HKEY hKey, LPCWSTR lpszSubKey)
Definition: reg.c:1546
DWORD WINAPI SHSetValueW(HKEY hKey, LPCWSTR lpszSubKey, LPCWSTR lpszValue, DWORD dwType, LPCVOID pvData, DWORD cbData)
Definition: reg.c:1306
#define REG_SZ
Definition: layer.c:22
#define ERROR_FILE_NOT_FOUND
Definition: disk.h:79
#define REG_BINARY
Definition: nt_native.h:1496
#define UNICODE_NULL
#define L(x)
Definition: ntvdm.h:50
VERSIONHELPERAPI IsWindowsVistaOrGreater()
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by START_TEST().

◆ MRUList_DataList_0()

static void MRUList_DataList_0 ( void  )
static

Definition at line 26 of file MRUList.cpp.

27{
28 HRESULT hr;
29 IMruDataList *pList = NULL;
30 UINT iSlot1, iSlot2, iSlot3;
31 DWORD cbText;
32 WCHAR szText[MAX_PATH];
33
34 hr = CoCreateInstance(CLSID_MruLongList, NULL, CLSCTX_INPROC_SERVER,
35 IID_IMruDataList, (LPVOID*)&pList);
36 ok_hex(hr, S_OK);
37 if (pList == NULL)
38 {
39 skip("pList was NULL\n");
40 return;
41 }
42
43 hr = pList->InitData(26, 0, HKEY_CURRENT_USER, SUBKEY0, NULL);
44 ok_hex(hr, S_OK);
45
46 cbText = (wcslen(TEXT0) + 1) * sizeof(WCHAR);
47 hr = pList->AddData((BYTE*)TEXT0, cbText, &iSlot1);
48 ok_hex(hr, S_OK);
49 ok_int(iSlot1, 0);
50
51 hr = pList->FindData((BYTE*)TEXT0, cbText, &iSlot2);
52 ok_hex(hr, S_OK);
53 ok_int(iSlot1, iSlot2);
54
55 cbText = sizeof(szText);
56 hr = pList->GetData(iSlot1, (BYTE*)szText, cbText);
57 ok_hex(hr, S_OK);
58 ok_wstr(szText, TEXT0);
59
60 cbText = (wcslen(TEXT1) + 1) * sizeof(WCHAR);
61 hr = pList->AddData((BYTE*)TEXT1, cbText, &iSlot3);
62 ok_hex(hr, S_OK);
63 ok_int(iSlot3, 1);
64
65 pList->Release();
66}
#define TEXT1
Definition: MRUList.cpp:24
#define TEXT0
Definition: MRUList.cpp:23
#define ok_hex(expression, result)
Definition: atltest.h:94
#define ok_wstr(x, y)
Definition: atltest.h:130
virtual ULONG Release(__in_opt PVOID Tag=NULL, __in LONG Line=0, __in_opt PSTR File=NULL)
Definition: fxobject.hpp:853
#define MAX_PATH
Definition: compat.h:34
HRESULT WINAPI DECLSPEC_HOTPATCH CoCreateInstance(REFCLSID rclsid, LPUNKNOWN pUnkOuter, DWORD dwClsContext, REFIID iid, LPVOID *ppv)
Definition: compobj.c:3325
FxChildList * pList
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define S_OK
Definition: intsafe.h:52
unsigned int UINT
Definition: ndis.h:50
HRESULT hr
Definition: shlfolder.c:183

Referenced by MRUList_DataList().

◆ MRUList_DataList_1()

static void MRUList_DataList_1 ( void  )
static

Definition at line 96 of file MRUList.cpp.

97{
98 HRESULT hr;
99 IMruDataList *pList = NULL;
100 UINT iSlot;
101
102 hr = CoCreateInstance(CLSID_MruLongList, NULL, CLSCTX_INPROC_SERVER,
103 IID_IMruDataList, (LPVOID*)&pList);
104 ok_hex(hr, S_OK);
105 if (pList == NULL)
106 {
107 skip("pList was NULL\n");
108 return;
109 }
110
111 hr = pList->InitData(26, 0, HKEY_CURRENT_USER, SUBKEY0, NULL);
112 ok_hex(hr, S_OK);
113
114 DWORD cbText = (wcslen(TEXT0) + 1) * sizeof(WCHAR);
115 hr = pList->FindData((BYTE*)TEXT0, cbText, &iSlot);
116 ok_hex(hr, S_OK);
117 ok_int(iSlot, 1);
118
119 hr = pList->Delete(iSlot);
120 ok_hex(hr, S_OK);
121
122 iSlot = 0xCAFE;
123 cbText = (wcslen(TEXT0) + 1) * sizeof(WCHAR);
124 hr = pList->FindData((BYTE*)TEXT0, cbText, &iSlot);
125 ok_hex(hr, E_FAIL);
126 ok_int(iSlot, 0xCAFE);
127
128 pList->Release();
129}
#define E_FAIL
Definition: ddrawi.h:102

Referenced by MRUList_DataList().

◆ MRUList_DataList_2()

static void MRUList_DataList_2 ( void  )
static

Definition at line 131 of file MRUList.cpp.

132{
133 HRESULT hr;
134 IMruDataList *pList = NULL;
135
136 hr = CoCreateInstance(CLSID_MruLongList, NULL, CLSCTX_INPROC_SERVER,
137 IID_IMruDataList, (LPVOID*)&pList);
138 ok_hex(hr, S_OK);
139 if (pList == NULL)
140 {
141 skip("pList was NULL\n");
142 return;
143 }
144
145 hr = pList->InitData(26, 0, HKEY_CURRENT_USER, SUBKEY0, NULL);
146 ok_hex(hr, S_OK);
147
148 WCHAR szText[MAX_PATH];
149 DWORD cbText = sizeof(szText);
150 StringCchCopyW(szText, _countof(szText), L"====");
151 hr = pList->GetData(0, (BYTE*)szText, cbText);
152 ok_hex(hr, S_OK);
153 ok_wstr(szText, L"ABC");
154
155 StringCchCopyW(szText, _countof(szText), L"====");
156 cbText = sizeof(szText);
157 hr = pList->GetData(1, (BYTE*)szText, cbText);
158 ok_hex(hr, S_OK);
159 ok_wstr(szText, L"XYZ");
160
161 pList->Release();
162}
#define _countof(array)
Definition: sndvol32.h:70
STRSAFEAPI StringCchCopyW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:149

Referenced by MRUList_DataList().

◆ MRUList_PidlList()

static void MRUList_PidlList ( void  )
static

Definition at line 321 of file MRUList.cpp.

322{
324 {
325 skip("Vista+ doesn't support CLSID_MruPidlList\n");
326 return;
327 }
328
330
332
334}
static void MRUList_PidlList_0(void)
Definition: MRUList.cpp:210

Referenced by START_TEST().

◆ MRUList_PidlList_0()

static void MRUList_PidlList_0 ( void  )
static

Definition at line 210 of file MRUList.cpp.

211{
212 HRESULT hr;
213 IMruPidlList *pList = NULL;
214
215 hr = CoCreateInstance(CLSID_MruPidlList, NULL, CLSCTX_INPROC_SERVER,
216 IID_IMruPidlList, (LPVOID*)&pList);
217 ok_hex(hr, S_OK);
218 if (pList == NULL)
219 {
220 skip("pList was NULL\n");
221 return;
222 }
223
224 LONG error;
225
228
229 hr = pList->InitList(32, HKEY_CURRENT_USER, SUBKEY0);
230 ok_hex(hr, S_OK);
231
234
235 LPITEMIDLIST pidl1, pidl2;
238
239 UINT uNodeSlot1 = 0xDEADFACE;
240 hr = pList->UsePidl(pidl1, &uNodeSlot1);
241 ok_hex(uNodeSlot1, 1);
242
243 // "NodeSlot" value
244 ok_int(MRUList_Check(SUBKEY0, L"NodeSlot", "\x01\x00\x00\x00", 4), TRUE);
245
246 // "NodeSlots" value (Not "NodeSlot")
247 ok_int(MRUList_Check(SUBKEY0, L"NodeSlots", "\x02", 1), TRUE);
248
249 UINT uNodeSlot2 = 0xDEADFACE;
250 hr = pList->UsePidl(pidl2, &uNodeSlot2);
251 ok_hex(uNodeSlot2, 2);
252
253 // "0" value
255
256 // "MRUListEx" value
257 ok_int(MRUList_Check(SUBKEY0, L"MRUListEx", "\x00\x00\x00\x00\xFF\xFF\xFF\xFF", 8), TRUE);
258
259 // "NodeSlot" value
260 ok_int(MRUList_Check(SUBKEY0, L"NodeSlot", "\x01\x00\x00\x00", 4), TRUE);
261
262 // "NodeSlots" value
263 ok_int(MRUList_Check(SUBKEY0, L"NodeSlots", "\x02\x02", 2), TRUE);
264
265 // SUBSUBKEY0: "MRUListEx" value
266 ok_int(MRUList_Check(SUBSUBKEY0, L"MRUListEx", "\xFF\xFF\xFF\xFF", 4), TRUE);
267
268 // SUBSUBKEY0: "NodeSlot" value
269 ok_int(MRUList_Check(SUBSUBKEY0, L"NodeSlot", "\x02\x00\x00\x00", 4), TRUE);
270
271 // QueryPidl
272 UINT anNodeSlot[2], cNodeSlots;
273 FillMemory(anNodeSlot, sizeof(anNodeSlot), 0xCC);
274 cNodeSlots = 0xDEAD;
275 hr = pList->QueryPidl(pidl1, _countof(anNodeSlot), anNodeSlot, &cNodeSlots);
276 ok_long(hr, S_OK);
277 ok_int(anNodeSlot[0], 1);
278 ok_int(anNodeSlot[1], 0xCCCCCCCC);
279 ok_int(cNodeSlots, 1);
280
281 hr = pList->PruneKids(pidl1);
282
283 // "MRUListEx" value
284 ok_int(MRUList_Check(SUBKEY0, L"MRUListEx", "\x00\x00\x00\x00\xFF\xFF\xFF\xFF", 8), TRUE);
285
286 // "NodeSlot" value
287 ok_int(MRUList_Check(SUBKEY0, L"NodeSlot", "\x01\x00\x00\x00", 4), TRUE);
288
289 // "NodeSlots" value
290 ok_int(MRUList_Check(SUBKEY0, L"NodeSlots", "\x02\x00", 2), TRUE);
291
292 FillMemory(anNodeSlot, sizeof(anNodeSlot), 0xCC);
293 cNodeSlots = 0xBEEF;
294 hr = pList->QueryPidl(pidl1, 0, anNodeSlot, &cNodeSlots);
295 ok_long(hr, E_FAIL);
296 ok_int(anNodeSlot[0], 0xCCCCCCCC);
297 ok_int(anNodeSlot[1], 0xCCCCCCCC);
298 ok_int(cNodeSlots, 0);
299
300 FillMemory(anNodeSlot, sizeof(anNodeSlot), 0xCC);
301 cNodeSlots = 0xDEAD;
302 hr = pList->QueryPidl(pidl1, _countof(anNodeSlot), anNodeSlot, &cNodeSlots);
303 ok_long(hr, S_OK);
304 ok_int(anNodeSlot[0], 1);
305 ok_int(anNodeSlot[1], 0xCCCCCCCC);
306 ok_int(cNodeSlots, 1);
307
308 FillMemory(anNodeSlot, sizeof(anNodeSlot), 0xCC);
309 cNodeSlots = 0xDEAD;
310 hr = pList->QueryPidl(pidl2, _countof(anNodeSlot), anNodeSlot, &cNodeSlots);
312 ok_int(anNodeSlot[0], 1);
313 ok_int(anNodeSlot[1], 0xCCCCCCCC);
314 ok_int(cNodeSlots, 1);
315
316 pList->Release();
317 ILFree(pidl1);
318 ILFree(pidl2);
319}
#define SUBSUBKEY0
Definition: MRUList.cpp:22
HRESULT WINAPI SHGetSpecialFolderLocation(HWND hwndOwner, INT nFolder, LPITEMIDLIST *ppidl)
Definition: shellpath.c:3260
#define FillMemory(BUF, SIZ, MASK)
Definition: strucsup.c:31
void WINAPI ILFree(LPITEMIDLIST pidl)
Definition: pidl.c:940
#define CSIDL_PERSONAL
Definition: shlobj.h:2171
#define CSIDL_DESKTOP
Definition: shlobj.h:2166
ITEMIDLIST UNALIGNED * LPITEMIDLIST
Definition: shtypes.idl:41
#define S_FALSE
Definition: winerror.h:2357

Referenced by MRUList_PidlList().

◆ START_TEST()

START_TEST ( MRUList  )

Definition at line 336 of file MRUList.cpp.

337{
339 ok_hex(hr, S_OK);
340
343
344 if (SUCCEEDED(hr))
346}
static void MRUList_DataList(void)
Definition: MRUList.cpp:164
static void MRUList_PidlList(void)
Definition: MRUList.cpp:321
HRESULT WINAPI CoInitialize(LPVOID lpReserved)
Definition: compobj.c:1964
void WINAPI DECLSPEC_HOTPATCH CoUninitialize(void)
Definition: compobj.c:2067
#define SUCCEEDED(hr)
Definition: intsafe.h:50