ReactOS 0.4.15-dev-5669-g09dde2c
shdocvw.c File Reference
#include <stdarg.h>
#include "windef.h"
#include "winbase.h"
#include "winreg.h"
#include "wininet.h"
#include "winnls.h"
#include "wine/test.h"
Include dependency graph for shdocvw.c:

Go to the source code of this file.

Functions

static HRESULT (WINAPI *pURLSubRegQueryA)(LPCSTR
 
static DWORD (WINAPI *pParseURLFromOutsideSourceA)(LPCSTR
 
static void init_functions (void)
 
static void test_URLSubRegQueryA (void)
 
static void test_ParseURLFromOutsideSourceA (void)
 
static void test_ParseURLFromOutsideSourceW (void)
 
 START_TEST (shdocvw)
 

Variables

static HMODULE hshdocvw
 
static LPCSTR
 
static DWORD
 
static LPVOID
 
static LPSTR
 
static LPDWORD
 
static LPWSTR
 
static const char appdata [] = "AppData"
 
static const char common_appdata [] = "Common AppData"
 
static const char default_page_url [] = "Default_Page_URL"
 
static const char does_not_exist [] = "does_not_exist"
 
static const char regpath_iemain [] = "Software\\Microsoft\\Internet Explorer\\Main"
 
static const char regpath_shellfolders [] = "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders"
 
static const char start_page [] = "Start Page"
 
struct {
   const char *   url
 
   const char *   newurl
 
   DWORD   len
 
ParseURL_table []
 

Function Documentation

◆ DWORD()

static DWORD ( WINAPI pParseURLFromOutsideSourceA)
static

◆ HRESULT()

static HRESULT ( WINAPI pURLSubRegQueryA)
static

◆ init_functions()

static void init_functions ( void  )
static

Definition at line 73 of file shdocvw.c.

74{
75 hshdocvw = LoadLibraryA("shdocvw.dll");
76 pURLSubRegQueryA = (void *) GetProcAddress(hshdocvw, (LPSTR) 151);
77 pParseURLFromOutsideSourceA = (void *) GetProcAddress(hshdocvw, (LPSTR) 169);
78 pParseURLFromOutsideSourceW = (void *) GetProcAddress(hshdocvw, (LPSTR) 170);
79}
#define GetProcAddress(x, y)
Definition: compat.h:753
HINSTANCE WINAPI DECLSPEC_HOTPATCH LoadLibraryA(LPCSTR lpLibFileName)
Definition: loader.c:111
static HMODULE hshdocvw
Definition: shdocvw.c:34
char * LPSTR
Definition: xmlstorage.h:182

Referenced by START_TEST().

◆ START_TEST()

START_TEST ( shdocvw  )

Definition at line 355 of file shdocvw.c.

356{
362}
#define FreeLibrary(x)
Definition: compat.h:748
static void test_ParseURLFromOutsideSourceA(void)
Definition: shdocvw.c:196
static void test_URLSubRegQueryA(void)
Definition: shdocvw.c:83
static void test_ParseURLFromOutsideSourceW(void)
Definition: shdocvw.c:288
static void init_functions(void)
Definition: shdocvw.c:73

◆ test_ParseURLFromOutsideSourceA()

static void test_ParseURLFromOutsideSourceA ( void  )
static

Definition at line 196 of file shdocvw.c.

197{
199 DWORD dummy;
200 DWORD maxlen;
201 DWORD len;
202 DWORD res;
203 int i;
204
205 if (!pParseURLFromOutsideSourceA) {
206 skip("ParseURLFromOutsideSourceA not found\n");
207 return;
208 }
209
210 for(i = 0; i < ARRAY_SIZE(ParseURL_table); i++) {
211 memset(buffer, '#', sizeof(buffer)-1);
212 buffer[sizeof(buffer)-1] = '\0';
213 len = sizeof(buffer);
214 dummy = 0;
215 /* on success, string size including terminating 0 is returned for ansi version */
216 res = pParseURLFromOutsideSourceA(ParseURL_table[i].url, buffer, &len, &dummy);
217 /* len does not include the terminating 0, when buffer is large enough */
218 ok( res == (ParseURL_table[i].len+1) && len == ParseURL_table[i].len &&
220 "#%d: got %d and %d with '%s' (expected %d and %d with '%s')\n",
222
223
224 /* use the size test only for the first examples */
225 if (i > 4) continue;
226
227 maxlen = len;
228
229 memset(buffer, '#', sizeof(buffer)-1);
230 buffer[sizeof(buffer)-1] = '\0';
231 len = maxlen + 1;
232 dummy = 0;
233 res = pParseURLFromOutsideSourceA(ParseURL_table[i].url, buffer, &len, &dummy);
234 ok( res != 0 && len == ParseURL_table[i].len &&
236 "#%d (+1): got %d and %d with '%s' (expected '!=0' and %d with '%s')\n",
238
239 memset(buffer, '#', sizeof(buffer)-1);
240 buffer[sizeof(buffer)-1] = '\0';
241 len = maxlen;
242 dummy = 0;
243 res = pParseURLFromOutsideSourceA(ParseURL_table[i].url, buffer, &len, &dummy);
244 /* len includes the terminating 0, when the buffer is too small */
245 ok( res == 0 && len == ParseURL_table[i].len + 1,
246 "#%d (==): got %d and %d (expected '0' and %d)\n",
247 i, res, len, ParseURL_table[i].len + 1);
248
249 memset(buffer, '#', sizeof(buffer)-1);
250 buffer[sizeof(buffer)-1] = '\0';
251 len = maxlen-1;
252 dummy = 0;
253 res = pParseURLFromOutsideSourceA(ParseURL_table[i].url, buffer, &len, &dummy);
254 /* len includes the terminating 0 on XP SP1 and before, when the buffer is too small */
255 ok( res == 0 && (len == ParseURL_table[i].len || len == ParseURL_table[i].len + 1),
256 "#%d (-1): got %d and %d (expected '0' and %d or %d)\n",
258
259 memset(buffer, '#', sizeof(buffer)-1);
260 buffer[sizeof(buffer)-1] = '\0';
261 len = maxlen+1;
262 dummy = 0;
263 res = pParseURLFromOutsideSourceA(ParseURL_table[i].url, NULL, &len, &dummy);
264 /* len does not include the terminating 0, when buffer is NULL */
265 ok( res == 0 && len == ParseURL_table[i].len,
266 "#%d (buffer): got %d and %d (expected '0' and %d)\n",
268
269 if (0) {
270 /* that test crash on native shdocvw */
271 pParseURLFromOutsideSourceA(ParseURL_table[i].url, buffer, NULL, &dummy);
272 }
273
274 memset(buffer, '#', sizeof(buffer)-1);
275 buffer[sizeof(buffer)-1] = '\0';
276 len = maxlen+1;
277 dummy = 0;
278 res = pParseURLFromOutsideSourceA(ParseURL_table[i].url, buffer, &len, NULL);
279 ok( res != 0 && len == ParseURL_table[i].len &&
281 "#%d (unknown): got %d and %d with '%s' (expected '!=0' and %d with '%s')\n",
283 }
284}
#define ok(value,...)
Definition: atltest.h:57
#define skip(...)
Definition: atltest.h:64
#define ARRAY_SIZE(a)
Definition: main.h:24
#define NULL
Definition: types.h:112
#define INTERNET_MAX_URL_LENGTH
Definition: session.c:1418
unsigned long DWORD
Definition: ntddk_ex.h:95
GLuint res
Definition: glext.h:9613
GLuint buffer
Definition: glext.h:5915
GLenum GLsizei len
Definition: glext.h:6722
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
int WINAPI lstrcmpA(LPCSTR lpString1, LPCSTR lpString2)
Definition: lstring.c:18
#define memset(x, y, z)
Definition: compat.h:39
static const struct @1676 ParseURL_table[]
DWORD len
Definition: shdocvw.c:52
const char * newurl
Definition: shdocvw.c:51
const char * url
Definition: shdocvw.c:50
char CHAR
Definition: xmlstorage.h:175

Referenced by START_TEST().

◆ test_ParseURLFromOutsideSourceW()

static void test_ParseURLFromOutsideSourceW ( void  )
static

Definition at line 288 of file shdocvw.c.

289{
293 DWORD maxlen;
294 DWORD dummy;
295 DWORD len;
296 DWORD res;
297
298 if (!pParseURLFromOutsideSourceW) {
299 skip("ParseURLFromOutsideSourceW not found\n");
300 return;
301 }
303
304 memset(bufferA, '#', sizeof(bufferA)-1);
305 bufferA[sizeof(bufferA) - 1] = '\0';
306 MultiByteToWideChar(CP_ACP, 0, bufferA, -1, bufferW, INTERNET_MAX_URL_LENGTH);
307
308 /* len is in characters */
309 len = ARRAY_SIZE(bufferW);
310 dummy = 0;
311 /* on success, 1 is returned for unicode version */
312 res = pParseURLFromOutsideSourceW(urlW, bufferW, &len, &dummy);
313 WideCharToMultiByte(CP_ACP, 0, bufferW, -1, bufferA, sizeof(bufferA), NULL, NULL);
314 ok( res == 1 && len == ParseURL_table[0].len &&
315 !lstrcmpA(bufferA, ParseURL_table[0].newurl),
316 "got %d and %d with '%s' (expected 1 and %d with '%s')\n",
317 res, len, bufferA, ParseURL_table[0].len, ParseURL_table[0].newurl);
318
319
320 maxlen = len;
321
322 memset(bufferA, '#', sizeof(bufferA)-1);
323 bufferA[sizeof(bufferA) - 1] = '\0';
324 MultiByteToWideChar(CP_ACP, 0, bufferA, -1, bufferW, INTERNET_MAX_URL_LENGTH);
325 len = maxlen+1;
326 dummy = 0;
327 res = pParseURLFromOutsideSourceW(urlW, bufferW, &len, &dummy);
328 WideCharToMultiByte(CP_ACP, 0, bufferW, -1, bufferA, sizeof(bufferA), NULL, NULL);
329 /* len does not include the terminating 0, when buffer is large enough */
330 ok( res != 0 && len == ParseURL_table[0].len &&
331 !lstrcmpA(bufferA, ParseURL_table[0].newurl),
332 "+1: got %d and %d with '%s' (expected '!=0' and %d with '%s')\n",
333 res, len, bufferA, ParseURL_table[0].len, ParseURL_table[0].newurl);
334
335 len = maxlen;
336 dummy = 0;
337 res = pParseURLFromOutsideSourceW(urlW, bufferW, &len, &dummy);
338 /* len includes the terminating 0, when the buffer is too small */
339 ok( res == 0 && len == ParseURL_table[0].len + 1,
340 "==: got %d and %d (expected '0' and %d)\n",
341 res, len, ParseURL_table[0].len + 1);
342
343 len = maxlen - 1;
344 dummy = 0;
345 res = pParseURLFromOutsideSourceW(urlW, bufferW, &len, &dummy);
346 /* len includes the terminating 0 on XP SP1 and before, when the buffer is too small */
347 ok( res == 0 && (len == ParseURL_table[0].len || len == ParseURL_table[0].len + 1),
348 "-1: got %d and %d (expected '0' and %d or %d)\n",
350
351}
#define CP_ACP
Definition: compat.h:109
#define WideCharToMultiByte
Definition: compat.h:111
#define MultiByteToWideChar
Definition: compat.h:110
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by START_TEST().

◆ test_URLSubRegQueryA()

static void test_URLSubRegQueryA ( void  )
static

Definition at line 83 of file shdocvw.c.

84{
86 HRESULT hr;
87 DWORD used;
88 DWORD len;
89
90 if (!pURLSubRegQueryA) {
91 skip("URLSubRegQueryA not found\n");
92 return;
93 }
94
95 memset(buffer, '#', sizeof(buffer)-1);
96 buffer[sizeof(buffer)-1] = '\0';
97 /* called by inetcpl.cpl */
99 ok(hr == E_FAIL || hr == S_OK, "got 0x%x (expected E_FAIL or S_OK)\n", hr);
100
101 memset(buffer, '#', sizeof(buffer)-1);
102 buffer[sizeof(buffer)-1] = '\0';
103 /* called by inetcpl.cpl */
106 /* respect privacy: do not dump the url */
107 ok(hr == S_OK, "got 0x%x and %d (expected S_OK)\n", hr, len);
108
109 /* test buffer length: just large enough */
110 memset(buffer, '#', sizeof(buffer)-1);
111 buffer[sizeof(buffer)-1] = '\0';
112 hr = pURLSubRegQueryA(regpath_iemain, start_page, REG_SZ, buffer, len+1, -1);
114 /* respect privacy: do not dump the url */
115 ok((hr == S_OK) && (used == len),
116 "got 0x%x and %d (expected S_OK and %d)\n", hr, used, len);
117
118 /* no space for terminating 0: result is truncated */
119 memset(buffer, '#', sizeof(buffer)-1);
120 buffer[sizeof(buffer)-1] = '\0';
121 hr = pURLSubRegQueryA(regpath_iemain, start_page, REG_SZ, buffer, len, -1);
123 ok((hr == S_OK) && (used == len - 1),
124 "got 0x%x and %d (expected S_OK and %d)\n", hr, used, len - 1);
125
126 /* no space for the complete result: truncate another char */
127 if (len > 1) {
128 memset(buffer, '#', sizeof(buffer)-1);
129 buffer[sizeof(buffer)-1] = '\0';
130 hr = pURLSubRegQueryA(regpath_iemain, start_page, REG_SZ, buffer, len-1, -1);
132 ok((hr == S_OK) && (used == (len - 2)),
133 "got 0x%x and %d (expected S_OK and %d)\n", hr, used, len - 2);
134 }
135
136 /* only space for the terminating 0: function still succeeded */
137 memset(buffer, '#', sizeof(buffer)-1);
138 buffer[sizeof(buffer)-1] = '\0';
139 hr = pURLSubRegQueryA(regpath_iemain, start_page, REG_SZ, buffer, 1, -1);
141 ok((hr == S_OK) && !used,
142 "got 0x%x and %d (expected S_OK and 0)\n", hr, used);
143
144 /* size of buffer is 0, but the function still succeed.
145 buffer[0] is cleared in IE 5.01 and IE 5.5 (Buffer Overflow) */
146 memset(buffer, '#', sizeof(buffer)-1);
147 buffer[sizeof(buffer)-1] = '\0';
148 hr = pURLSubRegQueryA(regpath_iemain, start_page, REG_SZ, buffer, 0, -1);
150 ok( (hr == S_OK) &&
151 ((used == INTERNET_MAX_URL_LENGTH - 1) || broken(used == 0)) ,
152 "got 0x%x and %d (expected S_OK and INTERNET_MAX_URL_LENGTH - 1)\n",
153 hr, used);
154
155 /* still succeed without a buffer for the result */
156 hr = pURLSubRegQueryA(regpath_iemain, start_page, REG_SZ, NULL, 0, -1);
157 ok(hr == S_OK, "got 0x%x (expected S_OK)\n", hr);
158
159 /* still succeed, when a length is given without a buffer */
161 ok(hr == S_OK, "got 0x%x (expected S_OK)\n", hr);
162
163 /* this value does not exist */
164 memset(buffer, '#', sizeof(buffer)-1);
165 buffer[sizeof(buffer)-1] = '\0';
167 /* random bytes are copied to the buffer */
168 ok((hr == E_FAIL), "got 0x%x (expected E_FAIL)\n", hr);
169
170 /* the third parameter is ignored. Is it really a type? (data is REG_SZ) */
171 memset(buffer, '#', sizeof(buffer)-1);
172 buffer[sizeof(buffer)-1] = '\0';
175 ok((hr == S_OK) && (used == len),
176 "got 0x%x and %d (expected S_OK and %d)\n", hr, used, len);
177
178 /* the function works for HKCU and HKLM */
179 memset(buffer, '#', sizeof(buffer)-1);
180 buffer[sizeof(buffer)-1] = '\0';
183 ok(hr == S_OK, "got 0x%x and %d (expected S_OK)\n", hr, used);
184
185 memset(buffer, '#', sizeof(buffer)-1);
186 buffer[sizeof(buffer)-1] = '\0';
189 ok(hr == S_OK, "got 0x%x and %d (expected S_OK)\n", hr, used);
190
191 /* todo: what does the last parameter mean? */
192}
#define broken(x)
Definition: _sntprintf.h:21
static int used
Definition: adh-main.c:39
#define E_FAIL
Definition: ddrawi.h:102
#define S_OK
Definition: intsafe.h:52
#define REG_SZ
Definition: layer.c:22
int WINAPI lstrlenA(LPCSTR lpString)
Definition: lstring.c:145
#define REG_DWORD
Definition: sdbapi.c:596
HRESULT hr
Definition: shlfolder.c:183
static const char common_appdata[]
Definition: shdocvw.c:40
static const char start_page[]
Definition: shdocvw.c:45
static const char default_page_url[]
Definition: shdocvw.c:41
static const char appdata[]
Definition: shdocvw.c:39
static const char regpath_shellfolders[]
Definition: shdocvw.c:44
static const char does_not_exist[]
Definition: shdocvw.c:42
static const char regpath_iemain[]
Definition: shdocvw.c:43

Referenced by START_TEST().

Variable Documentation

◆ appdata

◆ common_appdata

const char common_appdata[] = "Common AppData"
static

Definition at line 40 of file shdocvw.c.

Referenced by test_URLSubRegQueryA().

◆ default_page_url

const char default_page_url[] = "Default_Page_URL"
static

Definition at line 41 of file shdocvw.c.

Referenced by test_URLSubRegQueryA().

◆ does_not_exist

const char does_not_exist[] = "does_not_exist"
static

Definition at line 42 of file shdocvw.c.

Referenced by test_URLSubRegQueryA().

◆ DWORD

Definition at line 35 of file shdocvw.c.

◆ hshdocvw

HMODULE hshdocvw
static

Definition at line 34 of file shdocvw.c.

Referenced by init_functions(), and START_TEST().

◆ len

◆ LPCSTR

Definition at line 35 of file shdocvw.c.

◆ LPDWORD

Definition at line 36 of file shdocvw.c.

◆ LPSTR

Definition at line 36 of file shdocvw.c.

◆ LPVOID

Definition at line 35 of file shdocvw.c.

◆ LPWSTR

Definition at line 37 of file shdocvw.c.

◆ newurl

◆ 

const struct { ... } ParseURL_table[]
Initial value:
= {
{"http://www.winehq.org", "http://www.winehq.org/", 22},
{"www.winehq.org", "http://www.winehq.org/", 22},
{"winehq.org", "http://winehq.org/", 18},
{"ftp.winehq.org", "ftp://ftp.winehq.org/", 21},
{"http://winehq.org", "http://winehq.org/", 18},
{"https://winehq.org", "https://winehq.org/", 19},
{"https://www.winehq.org", "https://www.winehq.org/", 23},
{"ftp://winehq.org", "ftp://winehq.org/", 17},
{"ftp://ftp.winehq.org", "ftp://ftp.winehq.org/", 21},
{"about:blank", "about:blank", 11},
{"about:home", "about:home", 10},
{"about:mozilla", "about:mozilla", 13},
{" http://www.winehq.org", "http://%20http://www.winehq.org", 31}
}

Referenced by test_ParseURLFromOutsideSourceA(), and test_ParseURLFromOutsideSourceW().

◆ regpath_iemain

const char regpath_iemain[] = "Software\\Microsoft\\Internet Explorer\\Main"
static

Definition at line 43 of file shdocvw.c.

Referenced by test_URLSubRegQueryA().

◆ regpath_shellfolders

const char regpath_shellfolders[] = "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders"
static

Definition at line 44 of file shdocvw.c.

Referenced by test_URLSubRegQueryA().

◆ start_page

const char start_page[] = "Start Page"
static

Definition at line 45 of file shdocvw.c.

Referenced by test_URLSubRegQueryA().

◆ url

const char* url

Definition at line 50 of file shdocvw.c.

Referenced by test_ParseURLFromOutsideSourceA(), and test_ParseURLFromOutsideSourceW().