ReactOS  0.4.14-dev-342-gdc047f9
query.c File Reference
#include <stdio.h>
#include <windows.h>
#include <setupapi.h>
#include "wine/test.h"
Include dependency graph for query.c:

Go to the source code of this file.

Functions

static void get_directories (void)
 
static BOOL create_inf_file (LPSTR filename, const char *data, DWORD size)
 
static BOOL check_info_filename (PSP_INF_INFORMATION info, LPSTR test)
 
static PSP_INF_INFORMATION alloc_inf_info (LPCSTR filename, DWORD search, PDWORD size)
 
static void test_SetupGetInfInformation (void)
 
static void test_SetupGetSourceFileLocation (void)
 
static void test_SetupGetSourceInfo (void)
 
static void test_SetupGetTargetPath (void)
 
 START_TEST (query)
 

Variables

static CHAR CURR_DIR [MAX_PATH]
 
static CHAR WIN_DIR [MAX_PATH]
 
static const char inf_data1 []
 
static const char inf_data2 []
 
static const char inf_data3 []
 
static const char inf_data4 []
 
static const char inf_data5 []
 
static const char inf_data6 []
 

Function Documentation

◆ alloc_inf_info()

static PSP_INF_INFORMATION alloc_inf_info ( LPCSTR  filename,
DWORD  search,
PDWORD  size 
)
static

Definition at line 136 of file query.c.

137 {
139  BOOL ret;
140 
142  if (!ret)
143  return NULL;
144 
145  info = HeapAlloc(GetProcessHeap(), 0, *size);
146  return info;
147 }
static short search(int val, const short *table, int size)
Definition: msg711.c:255
BOOL WINAPI SetupGetInfInformationA(LPCVOID InfSpec, DWORD SearchControl, PSP_INF_INFORMATION ReturnBuffer, DWORD ReturnBufferSize, PDWORD RequiredSize)
Definition: query.c:89
const char * filename
Definition: ioapi.h:135
struct _test_info info[]
Definition: SetCursorPos.c:19
unsigned int BOOL
Definition: ntddk_ex.h:94
smooth NULL
Definition: ftsmooth.c:416
GLsizeiptr size
Definition: glext.h:5919
#define GetProcessHeap()
Definition: compat.h:403
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
int ret

Referenced by test_SetupGetInfInformation().

◆ check_info_filename()

static BOOL check_info_filename ( PSP_INF_INFORMATION  info,
LPSTR  test 
)
static

Definition at line 114 of file query.c.

115 {
116  LPSTR filename;
117  DWORD size;
118  BOOL ret = FALSE;
119 
121  return FALSE;
122 
124  if (!filename)
125  return FALSE;
126 
128 
129  if (!lstrcmpiA(test, filename))
130  ret = TRUE;
131 
133  return ret;
134 }
#define TRUE
Definition: types.h:120
int WINAPI lstrcmpiA(LPCSTR lpString1, LPCSTR lpString2)
Definition: lstring.c:42
#define test
Definition: rosglue.h:37
char * LPSTR
Definition: xmlstorage.h:182
const char * filename
Definition: ioapi.h:135
unsigned int BOOL
Definition: ntddk_ex.h:94
smooth NULL
Definition: ftsmooth.c:416
GLsizeiptr size
Definition: glext.h:5919
#define GetProcessHeap()
Definition: compat.h:403
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
unsigned long DWORD
Definition: ntddk_ex.h:95
int ret
BOOL WINAPI SetupQueryInfFileInformationA(PSP_INF_INFORMATION InfInformation, UINT InfIndex, PSTR ReturnBuffer, DWORD ReturnBufferSize, PDWORD RequiredSize)
Definition: query.c:193
#define HeapFree(x, y, z)
Definition: compat.h:402

Referenced by test_SetupGetInfInformation().

◆ create_inf_file()

static BOOL create_inf_file ( LPSTR  filename,
const char data,
DWORD  size 
)
static

Definition at line 102 of file query.c.

103 {
104  BOOL ret;
105  DWORD dwNumberOfBytesWritten;
108  if (hf == INVALID_HANDLE_VALUE) return FALSE;
109  ret = WriteFile(hf, data, size, &dwNumberOfBytesWritten, NULL);
110  CloseHandle(hf);
111  return ret;
112 }
BOOL WINAPI WriteFile(IN HANDLE hFile, IN LPCVOID lpBuffer, IN DWORD nNumberOfBytesToWrite OPTIONAL, OUT LPDWORD lpNumberOfBytesWritten, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: rw.c:24
#define CloseHandle
Definition: compat.h:406
#define INVALID_HANDLE_VALUE
Definition: compat.h:399
const char * filename
Definition: ioapi.h:135
unsigned int BOOL
Definition: ntddk_ex.h:94
#define GENERIC_WRITE
Definition: nt_native.h:90
smooth NULL
Definition: ftsmooth.c:416
GLsizeiptr size
Definition: glext.h:5919
unsigned long DWORD
Definition: ntddk_ex.h:95
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
int ret
#define FILE_ATTRIBUTE_NORMAL
Definition: compat.h:126
#define CREATE_ALWAYS
Definition: disk.h:72
#define CreateFileA(a, b, c, d, e, f, g)
Definition: compat.h:407

Referenced by test_SetupGetInfInformation(), test_SetupGetSourceFileLocation(), test_SetupGetSourceInfo(), and test_SetupGetTargetPath().

◆ get_directories()

static void get_directories ( void  )
static

Definition at line 29 of file query.c.

30 {
31  int len;
32 
35 
36  if(len && (CURR_DIR[len-1] == '\\'))
37  CURR_DIR[len-1] = 0;
38 
40  len = lstrlenA(WIN_DIR);
41 
42  if (len && (WIN_DIR[len-1] == '\\'))
43  WIN_DIR[len-1] = 0;
44 }
static CHAR WIN_DIR[MAX_PATH]
Definition: query.c:27
#define MAX_PATH
Definition: compat.h:26
GLenum GLsizei len
Definition: glext.h:6722
int WINAPI lstrlenA(LPCSTR lpString)
Definition: lstring.c:145
DWORD WINAPI GetCurrentDirectoryA(IN DWORD nBufferLength, OUT LPSTR lpBuffer)
Definition: path.c:2145
UINT WINAPI GetWindowsDirectoryA(OUT LPSTR lpBuffer, IN UINT uSize)
Definition: path.c:2336
static CHAR CURR_DIR[MAX_PATH]
Definition: query.c:26

Referenced by START_TEST().

◆ START_TEST()

START_TEST ( query  )

Definition at line 516 of file query.c.

517 {
518  get_directories();
519 
524 }
static void get_directories(void)
Definition: query.c:29
static void test_SetupGetInfInformation(void)
Definition: query.c:149
static void test_SetupGetTargetPath(void)
Definition: query.c:404
static void test_SetupGetSourceInfo(void)
Definition: query.c:358
static void test_SetupGetSourceFileLocation(void)
Definition: query.c:310

◆ test_SetupGetInfInformation()

static void test_SetupGetInfInformation ( void  )
static

Definition at line 149 of file query.c.

150 {
152  CHAR inf_filename[MAX_PATH];
153  CHAR inf_one[MAX_PATH], inf_two[MAX_PATH];
154  LPSTR revfile;
155  DWORD size;
156  HINF hinf;
157  BOOL ret;
158 
159  lstrcpyA(inf_filename, CURR_DIR);
160  lstrcatA(inf_filename, "\\");
161  lstrcatA(inf_filename, "test.inf");
162 
163  /* try an invalid inf handle */
164  size = 0xdeadbeef;
165  SetLastError(0xbeefcafe);
167  ok(ret == FALSE, "Expected SetupGetInfInformation to fail\n");
169  broken(GetLastError() == ERROR_BAD_PATHNAME) || /* win95 */
170  broken(GetLastError() == ERROR_FILE_NOT_FOUND) || /* win98 */
171  broken(GetLastError() == ERROR_PATH_NOT_FOUND) || /* NT4 */
172  broken(GetLastError() == ERROR_INVALID_NAME) || /* win2k */
173  broken(GetLastError() == ERROR_GENERAL_SYNTAX), /* another win2k / winMe */
174  "Expected ERROR_INVALID_HANDLE, got %d\n", GetLastError());
175  ok(size == 0xdeadbeef, "Expected size to remain unchanged\n");
176 
177  /* try an invalid inf filename */
178  /* do not use NULL as absolute inf filename on win9x/winMe (crash) */
179  if ((GetLastError() != ERROR_BAD_PATHNAME) && /* win95 */
180  (GetLastError() != ERROR_FILE_NOT_FOUND) && /* win98 */
181  (GetLastError() != ERROR_GENERAL_SYNTAX)) /* winMe */
182  {
183  size = 0xdeadbeef;
184  SetLastError(0xbeefcafe);
186  ok(ret == FALSE, "Expected SetupGetInfInformation to fail\n");
188  "Expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
189  ok(size == 0xdeadbeef, "Expected size to remain unchanged\n");
190  }
191 
192  create_inf_file(inf_filename, inf_data1, sizeof(inf_data1) - 1);
193 
194  /* try an invalid search flag */
195  size = 0xdeadbeef;
196  SetLastError(0xbeefcafe);
197  ret = SetupGetInfInformationA(inf_filename, -1, NULL, 0, &size);
198  ok(ret == FALSE, "Expected SetupGetInfInformation to fail\n");
200  "Expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
201  ok(size == 0xdeadbeef, "Expected size to remain unchanged\n");
202 
203  /* try a nonexistent inf file */
204  size = 0xdeadbeef;
205  SetLastError(0xbeefcafe);
207  ok(ret == FALSE, "Expected SetupGetInfInformation to fail\n");
209  "Expected ERROR_FILE_NOT_FOUND, got %d\n", GetLastError());
210  ok(size == 0xdeadbeef, "Expected size to remain unchanged\n");
211 
212  /* successfully open the inf file */
213  size = 0xdeadbeef;
215  ok(ret == TRUE, "Expected SetupGetInfInformation to succeed\n");
216  ok(size != 0xdeadbeef, "Expected a valid size on return\n");
217 
218  /* set ReturnBuffer to NULL and ReturnBufferSize to non-zero value 'size' */
219  SetLastError(0xbeefcafe);
221  ok(ret == FALSE, "Expected SetupGetInfInformation to fail\n");
223  "Expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
224 
225  /* set ReturnBuffer to NULL and ReturnBufferSize to non-zero value 'size-1' */
227  ok(ret == TRUE, "Expected SetupGetInfInformation to succeed\n");
228 
229  /* some tests for behaviour with a NULL RequiredSize pointer */
231  ok(ret == TRUE, "Expected SetupGetInfInformation to succeed\n");
233  ok(ret == TRUE, "Expected SetupGetInfInformation to succeed\n");
235  ok(ret == FALSE, "Expected SetupGetInfInformation to fail\n");
236 
238 
239  /* try valid ReturnBuffer but too small size */
240  SetLastError(0xbeefcafe);
242  ok(ret == FALSE, "Expected SetupGetInfInformation to fail\n");
244  "Expected ERROR_INSUFFICIENT_BUFFER, got %d\n", GetLastError());
245 
246  /* successfully get the inf information */
248  ok(ret == TRUE, "Expected SetupGetInfInformation to succeed\n");
249  ok(check_info_filename(info, inf_filename), "Expected returned filename to be equal\n");
250 
252 
253  /* try the INFINFO_INF_SPEC_IS_HINF search flag */
254  hinf = SetupOpenInfFileA(inf_filename, NULL, INF_STYLE_WIN4, NULL);
257  ok(ret == TRUE, "Expected SetupGetInfInformation to succeed\n");
258  ok(check_info_filename(info, inf_filename), "Expected returned filename to be equal\n");
259  SetupCloseInfFile(hinf);
260 
261  lstrcpyA(inf_two, WIN_DIR);
262  lstrcatA(inf_two, "\\system32\\");
263  lstrcatA(inf_two, "test.inf");
264  ret = create_inf_file(inf_two, inf_data1, sizeof(inf_data1) - 1);
265  if (!ret && GetLastError() == ERROR_ACCESS_DENIED)
266  {
267  skip("need admin rights\n");
268  goto done;
269  }
270  ok(ret, "can't create inf file %u\n", GetLastError());
271 
274 
275  /* check if system32 is searched for inf */
278  revfile = inf_one; /* Vista */
279  else
280  revfile = inf_two;
281 
282  lstrcpyA(inf_one, WIN_DIR);
283  lstrcatA(inf_one, "\\inf\\");
284  lstrcatA(inf_one, "test.inf");
285  create_inf_file(inf_one, inf_data1, sizeof(inf_data1) - 1);
286 
289 
290  /* test the INFINFO_DEFAULT_SEARCH search flag */
292  ok(ret == TRUE, "Expected SetupGetInfInformation to succeed: %d\n", GetLastError());
293  ok(check_info_filename(info, inf_one), "Expected returned filename to be equal\n");
294 
297 
298  /* test the INFINFO_REVERSE_DEFAULT_SEARCH search flag */
300  ok(ret == TRUE, "Expected SetupGetInfInformation to succeed\n");
301  ok(check_info_filename(info, revfile), "Expected returned filename to be equal\n");
302 
303 done:
305  DeleteFileA(inf_filename);
306  DeleteFileA(inf_one);
307  DeleteFileA(inf_two);
308 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#define TRUE
Definition: types.h:120
#define INFINFO_INF_SPEC_IS_HINF
Definition: setupapi.h:443
#define INF_STYLE_WIN4
Definition: infsupp.h:41
static BOOL create_inf_file(LPSTR filename, const char *data, DWORD size)
Definition: query.c:102
#define INFINFO_INF_NAME_IS_ABSOLUTE
Definition: setupapi.h:444
BOOL WINAPI SetupGetInfInformationA(LPCVOID InfSpec, DWORD SearchControl, PSP_INF_INFORMATION ReturnBuffer, DWORD ReturnBufferSize, PDWORD RequiredSize)
Definition: query.c:89
char CHAR
Definition: xmlstorage.h:175
static CHAR WIN_DIR[MAX_PATH]
Definition: query.c:27
#define ERROR_INVALID_HANDLE
Definition: compat.h:88
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
char * LPSTR
Definition: xmlstorage.h:182
#define ERROR_GENERAL_SYNTAX
Definition: setupapi.h:285
#define INFINFO_REVERSE_DEFAULT_SEARCH
Definition: setupapi.h:446
VOID WINAPI SetupCloseInfFile(IN HINF InfHandle)
Definition: infsupp.c:43
struct _test_info info[]
Definition: SetCursorPos.c:19
#define ERROR_ACCESS_DENIED
Definition: compat.h:87
unsigned int BOOL
Definition: ntddk_ex.h:94
#define INFINFO_DEFAULT_SEARCH
Definition: setupapi.h:445
smooth NULL
Definition: ftsmooth.c:416
BOOL WINAPI DeleteFileA(IN LPCSTR lpFileName)
Definition: delete.c:24
#define ERROR_FILE_NOT_FOUND
Definition: disk.h:79
LPSTR WINAPI lstrcatA(LPSTR lpString1, LPCSTR lpString2)
Definition: lstring.c:123
GLsizeiptr size
Definition: glext.h:5919
#define GetProcessHeap()
Definition: compat.h:403
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
#define MAX_PATH
Definition: compat.h:26
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:417
LPSTR WINAPI lstrcpyA(LPSTR lpString1, LPCSTR lpString2)
Definition: lstring.c:100
int ret
#define broken(x)
Definition: _sntprintf.h:21
HINF WINAPI SetupOpenInfFileA(PCSTR name, PCSTR class, DWORD style, UINT *error)
Definition: parser.c:1139
#define ok(value,...)
Definition: atltest.h:57
static PSP_INF_INFORMATION alloc_inf_info(LPCSTR filename, DWORD search, PDWORD size)
Definition: query.c:136
#define skip(...)
Definition: atltest.h:64
static BOOL check_info_filename(PSP_INF_INFORMATION info, LPSTR test)
Definition: query.c:114
static CHAR CURR_DIR[MAX_PATH]
Definition: query.c:26
#define ERROR_INVALID_NAME
Definition: compat.h:93
#define ERROR_PATH_NOT_FOUND
Definition: winerror.h:106
#define ERROR_BAD_PATHNAME
Definition: winerror.h:233
#define HeapFree(x, y, z)
Definition: compat.h:402
static const char inf_data1[]
Definition: query.c:46
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10

Referenced by START_TEST().

◆ test_SetupGetSourceFileLocation()

static void test_SetupGetSourceFileLocation ( void  )
static

Definition at line 310 of file query.c.

311 {
312  char buffer[MAX_PATH] = "not empty", inf_filename[MAX_PATH];
313  UINT source_id;
314  DWORD required, error;
315  HINF hinf;
316  BOOL ret;
317 
318  lstrcpyA(inf_filename, CURR_DIR);
319  lstrcatA(inf_filename, "\\");
320  lstrcatA(inf_filename, "test.inf");
321 
322  create_inf_file(inf_filename, inf_data1, sizeof(inf_data1) - 1);
323 
324  hinf = SetupOpenInfFileA(inf_filename, NULL, INF_STYLE_WIN4, NULL);
325  ok(hinf != INVALID_HANDLE_VALUE, "could not open inf file\n");
326 
327  required = 0;
328  source_id = 0;
329 
330  ret = SetupGetSourceFileLocationA(hinf, NULL, "lanconf.exe", &source_id, buffer, sizeof(buffer), &required);
331  ok(ret, "SetupGetSourceFileLocation failed\n");
332 
333  ok(required == 1, "unexpected required size: %d\n", required);
334  ok(source_id == 2, "unexpected source id: %d\n", source_id);
335  ok(!lstrcmpA("", buffer), "unexpected result string: %s\n", buffer);
336 
337  SetupCloseInfFile(hinf);
338  DeleteFileA(inf_filename);
339 
340  create_inf_file(inf_filename, inf_data2, sizeof(inf_data2) - 1);
341 
342  SetLastError(0xdeadbeef);
343  hinf = SetupOpenInfFileA(inf_filename, NULL, INF_STYLE_WIN4, NULL);
344  error = GetLastError();
345  ok(hinf == INVALID_HANDLE_VALUE, "could open inf file\n");
346  ok(error == ERROR_WRONG_INF_STYLE, "got wrong error: %d\n", error);
347 
348  hinf = SetupOpenInfFileA(inf_filename, NULL, INF_STYLE_OLDNT, NULL);
349  ok(hinf != INVALID_HANDLE_VALUE, "could not open inf file\n");
350 
351  ret = SetupGetSourceFileLocationA(hinf, NULL, "", &source_id, buffer, sizeof(buffer), &required);
352  ok(!ret, "SetupGetSourceFileLocation succeeded\n");
353 
354  SetupCloseInfFile(hinf);
355  DeleteFileA(inf_filename);
356 }
BOOL WINAPI SetupGetSourceFileLocationA(HINF hinf, PINFCONTEXT context, PCSTR filename, PUINT source_id, PSTR buffer, DWORD buffer_size, PDWORD required_size)
Definition: query.c:288
#define INF_STYLE_WIN4
Definition: infsupp.h:41
static BOOL create_inf_file(LPSTR filename, const char *data, DWORD size)
Definition: query.c:102
#define error(str)
Definition: mkdosfs.c:1605
#define INF_STYLE_OLDNT
Definition: infsupp.h:37
#define INVALID_HANDLE_VALUE
Definition: compat.h:399
int WINAPI lstrcmpA(LPCSTR lpString1, LPCSTR lpString2)
Definition: lstring.c:18
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
GLuint buffer
Definition: glext.h:5915
VOID WINAPI SetupCloseInfFile(IN HINF InfHandle)
Definition: infsupp.c:43
unsigned int BOOL
Definition: ntddk_ex.h:94
smooth NULL
Definition: ftsmooth.c:416
BOOL WINAPI DeleteFileA(IN LPCSTR lpFileName)
Definition: delete.c:24
LPSTR WINAPI lstrcatA(LPSTR lpString1, LPCSTR lpString2)
Definition: lstring.c:123
#define MAX_PATH
Definition: compat.h:26
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:417
LPSTR WINAPI lstrcpyA(LPSTR lpString1, LPCSTR lpString2)
Definition: lstring.c:100
int ret
HINF WINAPI SetupOpenInfFileA(PCSTR name, PCSTR class, DWORD style, UINT *error)
Definition: parser.c:1139
#define ok(value,...)
Definition: atltest.h:57
unsigned int UINT
Definition: ndis.h:50
#define ERROR_WRONG_INF_STYLE
Definition: setupapi.h:286
static CHAR CURR_DIR[MAX_PATH]
Definition: query.c:26
static const char inf_data2[]
Definition: query.c:61
static const char inf_data1[]
Definition: query.c:46

Referenced by START_TEST().

◆ test_SetupGetSourceInfo()

static void test_SetupGetSourceInfo ( void  )
static

Definition at line 358 of file query.c.

359 {
360  char buffer[MAX_PATH], inf_filename[MAX_PATH];
361  DWORD required;
362  HINF hinf;
363  BOOL ret;
364 
365  lstrcpyA(inf_filename, CURR_DIR);
366  lstrcatA(inf_filename, "\\");
367  lstrcatA(inf_filename, "test.inf");
368 
369  create_inf_file(inf_filename, inf_data1, sizeof(inf_data1) - 1);
370 
371  hinf = SetupOpenInfFileA(inf_filename, NULL, INF_STYLE_WIN4, NULL);
372  ok(hinf != INVALID_HANDLE_VALUE, "could not open inf file\n");
373 
374  required = 0;
375 
376  ret = SetupGetSourceInfoA(hinf, 2, SRCINFO_PATH, buffer, sizeof(buffer), &required);
377  ok(ret, "SetupGetSourceInfoA failed\n");
378 
379  ok(required == 1, "unexpected required size: %d\n", required);
380  ok(!lstrcmpA("", buffer), "unexpected result string: %s\n", buffer);
381 
382  required = 0;
383  buffer[0] = 0;
384 
385  ret = SetupGetSourceInfoA(hinf, 2, SRCINFO_TAGFILE, buffer, sizeof(buffer), &required);
386  ok(ret, "SetupGetSourceInfoA failed\n");
387 
388  ok(required == 28, "unexpected required size: %d\n", required);
389  ok(!lstrcmpA("LANCOM\\LANtools\\lanconf.cab", buffer), "unexpected result string: %s\n", buffer);
390 
391  required = 0;
392  buffer[0] = 0;
393 
394  ret = SetupGetSourceInfoA(hinf, 2, SRCINFO_DESCRIPTION, buffer, sizeof(buffer), &required);
395  ok(ret, "SetupGetSourceInfoA failed\n");
396 
397  ok(required == 19, "unexpected required size: %d\n", required);
398  ok(!lstrcmpA("LANCOM Software CD", buffer), "unexpected result string: %s\n", buffer);
399 
400  SetupCloseInfFile(hinf);
401  DeleteFileA(inf_filename);
402 }
#define INF_STYLE_WIN4
Definition: infsupp.h:41
static BOOL create_inf_file(LPSTR filename, const char *data, DWORD size)
Definition: query.c:102
#define SRCINFO_TAGFILE
Definition: setupapi.h:636
#define INVALID_HANDLE_VALUE
Definition: compat.h:399
int WINAPI lstrcmpA(LPCSTR lpString1, LPCSTR lpString2)
Definition: lstring.c:18
GLuint buffer
Definition: glext.h:5915
VOID WINAPI SetupCloseInfFile(IN HINF InfHandle)
Definition: infsupp.c:43
unsigned int BOOL
Definition: ntddk_ex.h:94
smooth NULL
Definition: ftsmooth.c:416
BOOL WINAPI DeleteFileA(IN LPCSTR lpFileName)
Definition: delete.c:24
LPSTR WINAPI lstrcatA(LPSTR lpString1, LPCSTR lpString2)
Definition: lstring.c:123
#define SRCINFO_DESCRIPTION
Definition: setupapi.h:637
#define MAX_PATH
Definition: compat.h:26
unsigned long DWORD
Definition: ntddk_ex.h:95
LPSTR WINAPI lstrcpyA(LPSTR lpString1, LPCSTR lpString2)
Definition: lstring.c:100
int ret
BOOL WINAPI SetupGetSourceInfoA(HINF hinf, UINT source_id, UINT info, PSTR buffer, DWORD buffer_size, LPDWORD required_size)
Definition: query.c:420
HINF WINAPI SetupOpenInfFileA(PCSTR name, PCSTR class, DWORD style, UINT *error)
Definition: parser.c:1139
#define SRCINFO_PATH
Definition: setupapi.h:635
#define ok(value,...)
Definition: atltest.h:57
static CHAR CURR_DIR[MAX_PATH]
Definition: query.c:26
static const char inf_data1[]
Definition: query.c:46

Referenced by START_TEST().

◆ test_SetupGetTargetPath()

static void test_SetupGetTargetPath ( void  )
static

Definition at line 404 of file query.c.

405 {
406  char buffer[MAX_PATH], inf_filename[MAX_PATH];
407  char destfile[MAX_PATH];
408  DWORD required;
409  HINF hinf;
410  INFCONTEXT ctx;
411  BOOL ret;
412 
413  lstrcpyA(inf_filename, CURR_DIR);
414  lstrcatA(inf_filename, "\\");
415  lstrcatA(inf_filename, "test.inf");
416 
417  create_inf_file(inf_filename, inf_data1, sizeof(inf_data1) - 1);
418 
419  hinf = SetupOpenInfFileA(inf_filename, NULL, INF_STYLE_WIN4, NULL);
420  ok(hinf != INVALID_HANDLE_VALUE, "could not open inf file\n");
421 
422  ctx.Inf = hinf;
423  ctx.CurrentInf = hinf;
424  ctx.Section = 7;
425  ctx.Line = 0;
426 
427  required = 0;
428 
429  ret = SetupGetTargetPathA(hinf, &ctx, NULL, buffer, sizeof(buffer), &required);
430  ok(ret, "SetupGetTargetPathA failed\n");
431  ok(required == 10, "unexpected required size: %d\n", required);
432  /* Retrieve the system drive from the windows directory.
433  * (%SystemDrive% is not available on Win9x)
434  */
435  lstrcpyA(destfile, WIN_DIR);
436  destfile[3] = '\0';
437  lstrcatA(destfile, "LANCOM");
438  ok(!lstrcmpiA(destfile, buffer), "unexpected result string: %s\n", buffer);
439 
440  SetupCloseInfFile(hinf);
441  DeleteFileA(inf_filename);
442 
443  create_inf_file(inf_filename, inf_data3, sizeof(inf_data3) - 1);
444 
445  hinf = SetupOpenInfFileA(inf_filename, NULL, INF_STYLE_WIN4, NULL);
446  ok(hinf != INVALID_HANDLE_VALUE, "could not open inf file\n");
447 
448  required = 0;
449 
450  ret = SetupGetTargetPathA(hinf, NULL, "CopyAlways.Windir.Files", buffer, sizeof(buffer), &required);
451  ok(ret, "SetupGetTargetPathA failed\n");
452 
453  lstrcpyA(destfile, WIN_DIR);
454 
455  ok(required == lstrlenA(destfile) + 1, "unexpected required size: %d\n", required);
456  ok(!lstrcmpiA(buffer, destfile), "unexpected path: %s\n", buffer);
457 
458  SetupCloseInfFile(hinf);
459  DeleteFileA(inf_filename);
460 
461  create_inf_file(inf_filename, inf_data4, sizeof(inf_data4) - 1);
462 
463  hinf = SetupOpenInfFileA(inf_filename, NULL, INF_STYLE_WIN4, NULL);
464  ok(hinf != INVALID_HANDLE_VALUE, "could not open inf file\n");
465 
466  required = 0;
467 
468  ret = SetupGetTargetPathA(hinf, NULL, "CopyAlways.System32.Files", buffer, sizeof(buffer), &required);
469  ok(ret, "SetupGetTargetPathA failed\n");
470 
471  GetSystemDirectoryA(destfile, MAX_PATH);
472 
473  ok(required == lstrlenA(destfile) + 1, "unexpected required size: %d\n", required);
474  ok(!lstrcmpiA(buffer, destfile), "unexpected path: %s\n", buffer);
475 
476  SetupCloseInfFile(hinf);
477  DeleteFileA(inf_filename);
478 
479  create_inf_file(inf_filename, inf_data5, sizeof(inf_data5) - 1);
480 
481  hinf = SetupOpenInfFileA(inf_filename, NULL, INF_STYLE_WIN4, NULL);
482  ok(hinf != INVALID_HANDLE_VALUE, "could not open inf file\n");
483 
484  required = 0;
485 
486  ret = SetupGetTargetPathA(hinf, NULL, "CopyAlways.Windir.Files", buffer, sizeof(buffer), &required);
487  ok(ret, "SetupGetTargetPathA failed\n");
488 
489  lstrcpyA(destfile, WIN_DIR);
490 
491  ok(required == lstrlenA(destfile) + 1, "unexpected required size: %d\n", required);
492  ok(!lstrcmpiA(buffer, destfile), "unexpected path: %s\n", buffer);
493 
494  SetupCloseInfFile(hinf);
495  DeleteFileA(inf_filename);
496 
497  create_inf_file(inf_filename, inf_data6, sizeof(inf_data6) - 1);
498 
499  hinf = SetupOpenInfFileA(inf_filename, NULL, INF_STYLE_WIN4, NULL);
500  ok(hinf != INVALID_HANDLE_VALUE, "could not open inf file\n");
501 
502  required = 0;
503 
504  ret = SetupGetTargetPathA(hinf, NULL, "CopyAlways.Windir.Files", buffer, sizeof(buffer), &required);
505  ok(ret, "SetupGetTargetPathA failed\n");
506 
507  lstrcpyA(destfile, WIN_DIR);
508 
509  ok(required == lstrlenA(destfile) + 1, "unexpected required size: %d\n", required);
510  ok(!lstrcmpiA(buffer, destfile), "unexpected path: %s\n", buffer);
511 
512  SetupCloseInfFile(hinf);
513  DeleteFileA(inf_filename);
514 }
#define INF_STYLE_WIN4
Definition: infsupp.h:41
static BOOL create_inf_file(LPSTR filename, const char *data, DWORD size)
Definition: query.c:102
int WINAPI lstrcmpiA(LPCSTR lpString1, LPCSTR lpString2)
Definition: lstring.c:42
static CHAR WIN_DIR[MAX_PATH]
Definition: query.c:27
static const char inf_data5[]
Definition: query.c:85
BOOL WINAPI SetupGetTargetPathA(HINF hinf, PINFCONTEXT context, PCSTR section, PSTR buffer, DWORD buffer_size, PDWORD required_size)
Definition: query.c:515
UINT WINAPI GetSystemDirectoryA(OUT LPSTR lpBuffer, IN UINT uSize)
Definition: path.c:2282
#define INVALID_HANDLE_VALUE
Definition: compat.h:399
GLuint buffer
Definition: glext.h:5915
HINF CurrentInf
Definition: infsupp.h:25
VOID WINAPI SetupCloseInfFile(IN HINF InfHandle)
Definition: infsupp.c:43
static const char inf_data6[]
Definition: query.c:94
unsigned int BOOL
Definition: ntddk_ex.h:94
smooth NULL
Definition: ftsmooth.c:416
BOOL WINAPI DeleteFileA(IN LPCSTR lpFileName)
Definition: delete.c:24
static const char inf_data4[]
Definition: query.c:79
LPSTR WINAPI lstrcatA(LPSTR lpString1, LPCSTR lpString2)
Definition: lstring.c:123
static const char inf_data3[]
Definition: query.c:71
#define MAX_PATH
Definition: compat.h:26
unsigned long DWORD
Definition: ntddk_ex.h:95
LPSTR WINAPI lstrcpyA(LPSTR lpString1, LPCSTR lpString2)
Definition: lstring.c:100
int ret
HINF WINAPI SetupOpenInfFileA(PCSTR name, PCSTR class, DWORD style, UINT *error)
Definition: parser.c:1139
int WINAPI lstrlenA(LPCSTR lpString)
Definition: lstring.c:145
#define ok(value,...)
Definition: atltest.h:57
UINT Section
Definition: infsupp.h:26
static CHAR CURR_DIR[MAX_PATH]
Definition: query.c:26
HINF Inf
Definition: infsupp.h:24
UINT Line
Definition: infsupp.h:27
static const char inf_data1[]
Definition: query.c:46

Referenced by START_TEST().

Variable Documentation

◆ CURR_DIR

◆ inf_data1

const char inf_data1[]
static
Initial value:
=
"[Version]\n"
"Signature=\"$Chicago$\"\n"
"AdvancedINF=2.5\n"
"[SourceDisksNames]\n"
"2 = %SrcDiskName%, LANCOM\\LANtools\\lanconf.cab\n"
"[SourceDisksFiles]\n"
"lanconf.exe = 2\n"
"[DestinationDirs]\n"
"DefaultDestDir = 24, %DefaultDest%\n"
"[Strings]\n"
"LangDir = english\n"
"DefaultDest = LANCOM\n"
"SrcDiskName = \"LANCOM Software CD\"\n"

Definition at line 46 of file query.c.

Referenced by test_SetupGetInfInformation(), test_SetupGetSourceFileLocation(), test_SetupGetSourceInfo(), and test_SetupGetTargetPath().

◆ inf_data2

const char inf_data2[]
static
Initial value:
=
"[SourceFileInfo]\n"
"sp1qfe\\bitsinst.exe=250B3702C7CCD7C2F9E4DAA1555C933E,000600060A28062C,27136,SP1QFE\n"
"sp1qfe\\bitsprx2.dll=4EBEA67F4BB4EB402E725CA7CA2857AE,000600060A280621,7680,SP1QFE\n"
"sp1qfe\\bitsprx3.dll=C788A1D9330DA011EF25E95D3BC7BDE5,000600060A280621,7168,SP1QFE\n"
"sp1qfe\\qmgr.dll=696AC82FB290A03F205901442E0E9589,000600060A280621,361984,SP1QFE\n"
"sp1qfe\\qmgrprxy.dll=8B5848144829E1BC985EA4C3D8CA7E3F,000600060A280621,17408,SP1QFE\n"
"sp1qfe\\winhttp.dll=3EC6F518114606CA59D4160322077437,000500010A280615,331776,SP1QFE\n"
"sp1qfe\\xpob2res.dll=DB83156B9F496F20D1EA70E4ABEC0166,000500010A280622,158720,SP1QFE\n"

Definition at line 61 of file query.c.

Referenced by test_SetupGetSourceFileLocation().

◆ inf_data3

const char inf_data3[]
static
Initial value:
=
"[Version]\n"
"Signature = \"$Windows NT$\"\n"
"[DestinationDirs]\n"
"CopyAlways.Windir.files = 10\n"
"[CopyAlways.Windir.Files]\n"
"WindowsCodecs.dll\n"

Definition at line 71 of file query.c.

Referenced by test_SetupGetTargetPath().

◆ inf_data4

const char inf_data4[]
static
Initial value:
=
"[Version]\n"
"Signature = \"$Windows NT$\"\n"
"[CopyAlways.System32.Files]\n"
"WindowsCodecs.dll\n"

Definition at line 79 of file query.c.

Referenced by test_SetupGetTargetPath().

◆ inf_data5

const char inf_data5[]
static
Initial value:
=
"[Version]\n"
"Signature = \"$Windows NT$\"\n"
"[DestinationDirs]\n"
"DefaultDestDir = 11\n"
"CopyAlways.Windir.files = 10\n"
"[CopyAlways.Windir.Files]\n"
"WindowsCodecs.dll\n"

Definition at line 85 of file query.c.

Referenced by test_SetupGetTargetPath().

◆ inf_data6

const char inf_data6[]
static
Initial value:
=
"[Version]\n"
"Signature = \"$Windows NT$\"\n"
"[DestinationDirs]\n"
"DefaultDestDir = 10\n"
"[CopyAlways.Windir.Files]\n"
"WindowsCodecs.dll\n"

Definition at line 94 of file query.c.

Referenced by test_SetupGetTargetPath().

◆ WIN_DIR

CHAR WIN_DIR[MAX_PATH]
static

Definition at line 27 of file query.c.

Referenced by get_directories(), test_SetupGetInfInformation(), and test_SetupGetTargetPath().