ReactOS  0.4.13-dev-242-g611e6d7
misc.c File Reference
#include <stdarg.h>
#include <stdio.h>
#include <string.h>
#include "windef.h"
#include "winbase.h"
#include "winnls.h"
#include "winuser.h"
#include "winreg.h"
#include "setupapi.h"
#include "cfgmgr32.h"
#include "wine/test.h"
Include dependency graph for misc.c:

Go to the source code of this file.

Classes

struct  default_callback_context
 

Functions

static BOOL (WINAPI *pSetupGetFileCompressionInfoExA)(PCSTR
 
static void create_inf_file (LPCSTR filename)
 
static void get_temp_filename (LPSTR path)
 
static BOOL file_exists (LPSTR path)
 
static BOOL check_format (LPSTR path, LPSTR inf)
 
static void test_original_file_name (LPCSTR original, LPCSTR dest)
 
static void test_SetupCopyOEMInf (void)
 
static void create_source_file (LPSTR filename, const BYTE *data, DWORD size)
 
static BOOL compare_file_data (LPSTR file, const BYTE *data, DWORD size)
 
static void test_SetupGetFileCompressionInfo (void)
 
static void test_SetupGetFileCompressionInfoEx (void)
 
static void test_SetupDecompressOrCopyFile (void)
 
static void test_SetupUninstallOEMInf (void)
 
static void test_defaultcallback (void)
 
static void test_SetupLogError (void)
 
static void test_CM_Get_Version (void)
 
 START_TEST (misc)
 

Variables

static CHAR CURR_DIR [MAX_PATH]
 
static PSTR
 
static DWORD
 
static PDWORD
 
static PUINT
 
static PCSTR
 
static PSTR *static UINT
 
static PSTR *static PSP_ALTPLATFORM_INFO
 
static PSTR *static PSP_ORIGINAL_FILE_INFO_A
 
static PVOID
 
static const BYTE uncompressed []
 
static const BYTE laurence []
 
static const BYTE comp_lzx []
 
static const BYTE comp_zip []
 
static const BYTE comp_cab_lzx []
 
static const BYTE comp_cab_zip []
 
static const BYTE comp_cab_zip_multi []
 

Function Documentation

◆ BOOL()

static BOOL ( WINAPI pSetupGetFileCompressionInfoExA)
static

◆ check_format()

static BOOL check_format ( LPSTR  path,
LPSTR  inf 
)
static

Definition at line 87 of file misc.c.

88 {
90  BOOL res;
91 
92  static const CHAR format[] = "\\INF\\oem";
93 
97  path[strlen(check)] != '\\';
98 
99  return (!inf) ? res : res && (inf == path + strlen(check) - 3);
100 }
char * strcat(char *DstString, const char *SrcString)
Definition: utclib.c:568
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
char CHAR
Definition: xmlstorage.h:175
#define NORM_IGNORECASE
Definition: winnls.h:173
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: gl.h:1546
unsigned int BOOL
Definition: ntddk_ex.h:94
INT WINAPI CompareStringA(LCID lcid, DWORD flags, LPCSTR str1, INT len1, LPCSTR str2, INT len2)
Definition: lang.c:2299
#define MAX_PATH
Definition: compat.h:26
#define LOCALE_SYSTEM_DEFAULT
void check(CONTEXT *pContext)
Definition: NtContinue.c:61
#define CSTR_EQUAL
Definition: winnls.h:453
Definition: services.c:325
UINT WINAPI GetWindowsDirectoryA(OUT LPSTR lpBuffer, IN UINT uSize)
Definition: path.c:2336
GLuint res
Definition: glext.h:9613

Referenced by CheckRenderTargetCapability(), and test_SetupCopyOEMInf().

◆ compare_file_data()

static BOOL compare_file_data ( LPSTR  file,
const BYTE data,
DWORD  size 
)
static

Definition at line 373 of file misc.c.

374 {
375  DWORD read;
376  HANDLE handle;
377  BOOL ret = FALSE;
378  LPBYTE buffer;
379 
382  if (buffer)
383  {
385  if (read == size && !memcmp(data, buffer, size)) ret = TRUE;
387  }
389  return ret;
390 }
namespace GUID const ADDRINFOEXW ADDRINFOEXW struct timeval OVERLAPPED LPLOOKUPSERVICE_COMPLETION_ROUTINE HANDLE * handle
Definition: sock.c:82
#define TRUE
Definition: types.h:120
#define CloseHandle
Definition: compat.h:398
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
GLuint buffer
Definition: glext.h:5915
unsigned char * LPBYTE
Definition: typedefs.h:52
unsigned int BOOL
Definition: ntddk_ex.h:94
smooth NULL
Definition: ftsmooth.c:416
#define OPEN_EXISTING
Definition: compat.h:426
GLsizeiptr size
Definition: glext.h:5919
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
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 GENERIC_READ
Definition: compat.h:124
#define CreateFileA(a, b, c, d, e, f, g)
Definition: compat.h:399
BOOL WINAPI ReadFile(IN HANDLE hFile, IN LPVOID lpBuffer, IN DWORD nNumberOfBytesToRead, OUT LPDWORD lpNumberOfBytesRead OPTIONAL, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: rw.c:123
#define HeapFree(x, y, z)
Definition: compat.h:394
_CRTIMP int __cdecl read(_In_ int _FileHandle, _Out_writes_bytes_(_MaxCharCount) void *_DstBuf, _In_ unsigned int _MaxCharCount)
Definition: fci.c:126

Referenced by test_SetupDecompressOrCopyFile().

◆ create_inf_file()

static void create_inf_file ( LPCSTR  filename)
static

Definition at line 52 of file misc.c.

53 {
54  DWORD dwNumberOfBytesWritten;
57 
58  static const char data[] =
59  "[Version]\n"
60  "Signature=\"$Chicago$\"\n"
61  "AdvancedINF=2.5\n"
62  "[DefaultInstall]\n"
63  "RegisterOCXs=RegisterOCXsSection\n"
64  "[RegisterOCXsSection]\n"
65  "%%11%%\\ole32.dll\n";
66 
67  WriteFile(hf, data, sizeof(data) - 1, &dwNumberOfBytesWritten, NULL);
68  CloseHandle(hf);
69 }
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:398
const char * filename
Definition: ioapi.h:135
#define GENERIC_WRITE
Definition: nt_native.h:90
smooth NULL
Definition: ftsmooth.c:416
unsigned long DWORD
Definition: ntddk_ex.h:95
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
#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:399

Referenced by test_SetupCopyOEMInf().

◆ create_source_file()

static void create_source_file ( LPSTR  filename,
const BYTE data,
DWORD  size 
)
static

Definition at line 363 of file misc.c.

364 {
365  HANDLE handle;
366  DWORD written;
367 
369  WriteFile(handle, data, size, &written, NULL);
371 }
BOOL WINAPI WriteFile(IN HANDLE hFile, IN LPCVOID lpBuffer, IN DWORD nNumberOfBytesToWrite OPTIONAL, OUT LPDWORD lpNumberOfBytesWritten, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: rw.c:24
namespace GUID const ADDRINFOEXW ADDRINFOEXW struct timeval OVERLAPPED LPLOOKUPSERVICE_COMPLETION_ROUTINE HANDLE * handle
Definition: sock.c:82
#define CloseHandle
Definition: compat.h:398
const char * filename
Definition: ioapi.h:135
#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
#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:399

Referenced by test_SetupDecompressOrCopyFile(), test_SetupGetFileCompressionInfo(), and test_SetupGetFileCompressionInfoEx().

◆ file_exists()

static BOOL file_exists ( LPSTR  path)
static

Definition at line 82 of file misc.c.

83 {
85 }
DWORD WINAPI GetFileAttributesA(LPCSTR lpFileName)
Definition: fileinfo.c:786
#define INVALID_FILE_ATTRIBUTES
Definition: vfdcmd.c:23
Definition: services.c:325

Referenced by test_SetupCopyOEMInf().

◆ get_temp_filename()

static void get_temp_filename ( LPSTR  path)
static

Definition at line 71 of file misc.c.

72 {
74  LPSTR ptr;
75 
76  GetTempFileNameA(CURR_DIR, "set", 0, temp);
77  ptr = strrchr(temp, '\\');
78 
79  strcpy(path, ptr + 1);
80 }
char CHAR
Definition: xmlstorage.h:175
_Check_return_ _CRTIMP _CONST_RETURN char *__cdecl strrchr(_In_z_ const char *_Str, _In_ int _Ch)
static CHAR CURR_DIR[MAX_PATH]
Definition: misc.c:36
char * LPSTR
Definition: xmlstorage.h:182
static PVOID ptr
Definition: dispmode.c:27
#define MAX_PATH
Definition: compat.h:26
static calc_node_t temp
Definition: rpn_ieee.c:38
Definition: services.c:325
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
UINT WINAPI GetTempFileNameA(IN LPCSTR lpPathName, IN LPCSTR lpPrefixString, IN UINT uUnique, OUT LPSTR lpTempFileName)
Definition: filename.c:26

Referenced by test_SetupCopyOEMInf().

◆ START_TEST()

START_TEST ( misc  )

Definition at line 833 of file misc.c.

834 {
835  HMODULE hsetupapi = GetModuleHandleA("setupapi.dll");
836 
837  pSetupGetFileCompressionInfoExA = (void*)GetProcAddress(hsetupapi, "SetupGetFileCompressionInfoExA");
838  pSetupCopyOEMInfA = (void*)GetProcAddress(hsetupapi, "SetupCopyOEMInfA");
839  pSetupQueryInfOriginalFileInformationA = (void*)GetProcAddress(hsetupapi, "SetupQueryInfOriginalFileInformationA");
840  pSetupUninstallOEMInfA = (void*)GetProcAddress(hsetupapi, "SetupUninstallOEMInfA");
841 
843 
844  if (pSetupCopyOEMInfA)
846  else
847  win_skip("SetupCopyOEMInfA is not available\n");
848 
850 
851  if (pSetupGetFileCompressionInfoExA)
853  else
854  win_skip("SetupGetFileCompressionInfoExA is not available\n");
855 
857 
858  if (pSetupUninstallOEMInfA)
860  else
861  win_skip("SetupUninstallOEMInfA is not available\n");
862 
864 
867 }
static CHAR CURR_DIR[MAX_PATH]
Definition: misc.c:36
static void test_SetupLogError(void)
Definition: misc.c:785
static void test_SetupGetFileCompressionInfo(void)
Definition: misc.c:444
static void test_defaultcallback(void)
Definition: misc.c:751
#define MAX_PATH
Definition: compat.h:26
static void test_SetupCopyOEMInf(void)
Definition: misc.c:144
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
Definition: loader.c:819
DWORD WINAPI GetCurrentDirectoryA(IN DWORD nBufferLength, OUT LPSTR lpBuffer)
Definition: path.c:2145
static void test_SetupGetFileCompressionInfoEx(void)
Definition: misc.c:485
static void test_SetupUninstallOEMInf(void)
Definition: misc.c:714
static void test_CM_Get_Version(void)
Definition: misc.c:825
#define GetProcAddress(x, y)
Definition: compat.h:410
#define win_skip
Definition: test.h:141
static void test_SetupDecompressOrCopyFile(void)
Definition: misc.c:550

◆ test_CM_Get_Version()

static void test_CM_Get_Version ( void  )
static

Definition at line 825 of file misc.c.

826 {
827  WORD ret;
828 
829  ret = CM_Get_Version();
830  ok(ret == 0x0400, "got version %#x\n", ret);
831 }
#define ok(value,...)
unsigned short WORD
Definition: ntddk_ex.h:93
int ret
WORD WINAPI CM_Get_Version(VOID)
Definition: cfgmgr.c:5377

Referenced by START_TEST().

◆ test_defaultcallback()

static void test_defaultcallback ( void  )
static

Definition at line 751 of file misc.c.

752 {
753  struct default_callback_context *ctxt;
754  static const DWORD magic = 0x43515053; /* "SPQC" */
756 
757  owner = (HWND)0x123;
758  progress = (HWND)0x456;
760  ok(ctxt != NULL, "got %p\n", ctxt);
761 
762  ok(ctxt->magic == magic || broken(ctxt->magic != magic) /* win2000 */, "got magic 0x%08x\n", ctxt->magic);
763  if (ctxt->magic == magic)
764  {
765  ok(ctxt->owner == owner, "got %p, expected %p\n", ctxt->owner, owner);
766  ok(ctxt->progress == progress, "got %p, expected %p\n", ctxt->progress, progress);
767  ok(ctxt->message == WM_USER, "got %d, expected %d\n", ctxt->message, WM_USER);
769  }
770  else
771  {
772  win_skip("Skipping tests on old systems.\n");
774  return;
775  }
776 
778  ok(ctxt->magic == magic, "got magic 0x%08x\n", ctxt->magic);
779  ok(ctxt->owner == owner, "got %p, expected %p\n", ctxt->owner, owner);
780  ok(ctxt->progress == NULL, "got %p, expected %p\n", ctxt->progress, progress);
781  ok(ctxt->message == 0, "got %d\n", ctxt->message);
783 }
HANDLE HWND
Definition: compat.h:13
u32_t magic(void)
#define ok(value,...)
smooth NULL
Definition: ftsmooth.c:416
unsigned long DWORD
Definition: ntddk_ex.h:95
void WINAPI SetupTermDefaultQueueCallback(PVOID context)
Definition: queue.c:1704
#define WM_USER
Definition: winuser.h:1856
PVOID WINAPI SetupInitDefaultQueueCallbackEx(HWND owner, HWND progress, UINT msg, DWORD reserved1, PVOID reserved2)
Definition: queue.c:1686
#define broken(x)
Definition: _sntprintf.h:21
PVOID WINAPI SetupInitDefaultQueueCallback(HWND owner)
Definition: queue.c:1677
cd_progress_ptr progress
Definition: cdjpeg.h:150
#define win_skip
Definition: test.h:141

Referenced by START_TEST().

◆ test_original_file_name()

static void test_original_file_name ( LPCSTR  original,
LPCSTR  dest 
)
static

Definition at line 102 of file misc.c.

103 {
104  HINF hinf;
105  PSP_INF_INFORMATION pspii;
107  BOOL res;
108  DWORD size;
109 
110  if (!pSetupQueryInfOriginalFileInformationA)
111  {
112  win_skip("SetupQueryInfOriginalFileInformationA is not available\n");
113  return;
114  }
115 
117  ok(hinf != NULL, "SetupOpenInfFileA failed with error %d\n", GetLastError());
118 
120  ok(res, "SetupGetInfInformation failed with error %d\n", GetLastError());
121 
122  pspii = HeapAlloc(GetProcessHeap(), 0, size);
123 
125  ok(res, "SetupGetInfInformation failed with error %d\n", GetLastError());
126 
127  spofi.cbSize = 0;
128  res = pSetupQueryInfOriginalFileInformationA(pspii, 0, NULL, &spofi);
130  "SetupQueryInfOriginalFileInformationA should have failed with ERROR_INVALID_USER_BUFFER instead of %d\n", GetLastError());
131 
132  spofi.cbSize = sizeof(spofi);
133  res = pSetupQueryInfOriginalFileInformationA(pspii, 0, NULL, &spofi);
134  ok(res, "SetupQueryInfOriginalFileInformationA failed with error %d\n", GetLastError());
135  ok(!spofi.OriginalCatalogName[0], "spofi.OriginalCatalogName should have been \"\" instead of \"%s\"\n", spofi.OriginalCatalogName);
136  todo_wine
137  ok(!strcmp(original, spofi.OriginalInfName), "spofi.OriginalInfName of %s didn't match real original name %s\n", spofi.OriginalInfName, original);
138 
139  HeapFree(GetProcessHeap(), 0, pspii);
140 
141  SetupCloseInfFile(hinf);
142 }
#define INFINFO_INF_SPEC_IS_HINF
Definition: setupapi.h:443
#define INF_STYLE_WIN4
Definition: infsupp.h:41
BOOL WINAPI SetupGetInfInformationA(LPCVOID InfSpec, DWORD SearchControl, PSP_INF_INFORMATION ReturnBuffer, DWORD ReturnBufferSize, PDWORD RequiredSize)
Definition: query.c:89
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
CHAR OriginalCatalogName[MAX_PATH]
Definition: setupapi.h:734
VOID WINAPI SetupCloseInfFile(IN HINF InfHandle)
Definition: infsupp.c:43
#define ERROR_INVALID_USER_BUFFER
Definition: winerror.h:1091
unsigned int BOOL
Definition: ntddk_ex.h:94
#define ok(value,...)
smooth NULL
Definition: ftsmooth.c:416
GLsizeiptr size
Definition: glext.h:5919
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
unsigned long DWORD
Definition: ntddk_ex.h:95
#define todo_wine
Definition: test.h:154
HINF WINAPI SetupOpenInfFileA(PCSTR name, PCSTR class, DWORD style, UINT *error)
Definition: parser.c:1139
CHAR OriginalInfName[MAX_PATH]
Definition: setupapi.h:733
GLuint res
Definition: glext.h:9613
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
DWORD size
Definition: misc.c:596
static char * dest
Definition: rtl.c:135
#define win_skip
Definition: test.h:141
#define HeapFree(x, y, z)
Definition: compat.h:394

Referenced by test_SetupCopyOEMInf().

◆ test_SetupCopyOEMInf()

static void test_SetupCopyOEMInf ( void  )
static

Definition at line 144 of file misc.c.

145 {
146  CHAR toolong[MAX_PATH * 2];
148  CHAR tmpfile[MAX_PATH], dest_save[MAX_PATH];
149  LPSTR inf = NULL;
150  DWORD size;
151  BOOL res;
152 
153  /* try NULL SourceInfFileName */
154  SetLastError(0xdeadbeef);
155  res = pSetupCopyOEMInfA(NULL, NULL, 0, SP_COPY_NOOVERWRITE, NULL, 0, NULL, NULL);
156  ok(res == FALSE, "Expected FALSE, got %d\n", res);
158  "Expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
159 
160  /* try empty SourceInfFileName */
161  SetLastError(0xdeadbeef);
162  res = pSetupCopyOEMInfA("", NULL, 0, SP_COPY_NOOVERWRITE, NULL, 0, NULL, NULL);
163  ok(res == FALSE, "Expected FALSE, got %d\n", res);
165  GetLastError() == ERROR_BAD_PATHNAME || /* Win98 */
166  GetLastError() == ERROR_INVALID_PARAMETER, /* Vista, W2K8 */
167  "Unexpected error : %d\n", GetLastError());
168 
169  /* try a relative nonexistent SourceInfFileName */
170  SetLastError(0xdeadbeef);
171  res = pSetupCopyOEMInfA("nonexistent", NULL, 0, SP_COPY_NOOVERWRITE, NULL, 0, NULL, NULL);
172  ok(res == FALSE, "Expected FALSE, got %d\n", res);
174  "Expected ERROR_FILE_NOT_FOUND, got %d\n", GetLastError());
175 
176  /* try an absolute nonexistent SourceInfFileName */
177  strcpy(path, CURR_DIR);
178  strcat(path, "\\nonexistent");
179  SetLastError(0xdeadbeef);
180  res = pSetupCopyOEMInfA(path, NULL, 0, SP_COPY_NOOVERWRITE, NULL, 0, NULL, NULL);
181  ok(res == FALSE, "Expected FALSE, got %d\n", res);
183  "Expected ERROR_FILE_NOT_FOUND, got %d\n", GetLastError());
184 
185  /* try a long SourceInfFileName */
186  memset(toolong, 'a', MAX_PATH * 2);
187  toolong[MAX_PATH * 2 - 1] = '\0';
188  SetLastError(0xdeadbeef);
189  res = pSetupCopyOEMInfA(toolong, NULL, 0, SP_COPY_NOOVERWRITE, NULL, 0, NULL, NULL);
190  ok(res == FALSE, "Expected FALSE, got %d\n", res);
192  GetLastError() == ERROR_FILENAME_EXCED_RANGE, /* Win98 */
193  "Expected ERROR_FILE_NOT_FOUND or ERROR_FILENAME_EXCED_RANGE, got %d\n", GetLastError());
194 
197 
198  /* try a relative SourceInfFileName */
199  SetLastError(0xdeadbeef);
200  res = pSetupCopyOEMInfA(tmpfile, NULL, 0, SP_COPY_NOOVERWRITE, NULL, 0, NULL, NULL);
201  ok(res == FALSE ||
202  broken(res == TRUE), /* Win98 */
203  "Expected FALSE, got %d\n", res);
205  {
206  /* FIXME:
207  * Vista needs a [Manufacturer] entry in the inf file. Doing this will give some
208  * popups during the installation though as it also needs a catalog file (signed?).
209  */
210  win_skip("Needs a different inf file on Vista+\n");
212  return;
213  }
214 
216  broken(GetLastError() == ERROR_SUCCESS), /* Win98 */
217  "Expected ERROR_FILE_NOT_FOUND, got %d\n", GetLastError());
218  ok(file_exists(tmpfile), "Expected tmpfile to exist\n");
219 
220  /* try SP_COPY_REPLACEONLY, dest does not exist */
221  SetLastError(0xdeadbeef);
222  res = pSetupCopyOEMInfA(path, NULL, SPOST_NONE, SP_COPY_REPLACEONLY, NULL, 0, NULL, NULL);
223  ok(res == FALSE, "Expected FALSE, got %d\n", res);
225  "Expected ERROR_FILE_NOT_FOUND, got %d\n", GetLastError());
226  ok(file_exists(tmpfile), "Expected source inf to exist\n");
227 
228  /* try an absolute SourceInfFileName, without DestinationInfFileName */
229  strcpy(path, CURR_DIR);
230  strcat(path, "\\");
231  strcat(path, tmpfile);
232  SetLastError(0xdeadbeef);
233  res = pSetupCopyOEMInfA(path, NULL, SPOST_NONE, 0, NULL, 0, NULL, NULL);
234  if (!res && GetLastError() == ERROR_ACCESS_DENIED)
235  {
236  skip("SetupCopyOEMInfA() failed on insufficient permissions\n");
237  return;
238  }
239  ok(res == TRUE, "Expected TRUE, got %d\n", res);
240  ok(GetLastError() == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", GetLastError());
241  ok(file_exists(path), "Expected source inf to exist\n");
242 
243  /* try SP_COPY_REPLACEONLY, dest exists */
244  SetLastError(0xdeadbeef);
245  res = pSetupCopyOEMInfA(path, NULL, SPOST_NONE, SP_COPY_REPLACEONLY, NULL, 0, NULL, NULL);
246  ok(res == TRUE, "Expected TRUE, got %d\n", res);
247  ok(GetLastError() == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", GetLastError());
248  ok(file_exists(path), "Expected source inf to exist\n");
249 
250  /* try SP_COPY_NOOVERWRITE */
251  SetLastError(0xdeadbeef);
252  res = pSetupCopyOEMInfA(path, NULL, SPOST_NONE, SP_COPY_NOOVERWRITE, NULL, 0, NULL, NULL);
253  ok(res == FALSE, "Expected FALSE, got %d\n", res);
255  "Expected ERROR_FILE_EXISTS, got %d\n", GetLastError());
256 
257  /* get the DestinationInfFileName */
258  SetLastError(0xdeadbeef);
259  res = pSetupCopyOEMInfA(path, NULL, SPOST_NONE, 0, dest, MAX_PATH, NULL, NULL);
260  ok(res == TRUE, "Expected TRUE, got %d\n", res);
261  ok(GetLastError() == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", GetLastError());
262  ok(strlen(dest) != 0, "Expected a non-zero length string\n");
263  ok(file_exists(dest), "Expected destination inf to exist\n");
264  ok(check_format(dest, NULL), "Expected %%windir%%\\inf\\OEMx.inf, got %s\n", dest);
265  ok(file_exists(path), "Expected source inf to exist\n");
266 
267  strcpy(dest_save, dest);
268  DeleteFileA(dest_save);
269 
270  /* get the DestinationInfFileName, DestinationInfFileNameSize is too small
271  * - inf is still copied
272  */
273  strcpy(dest, "aaa");
274  size = 0;
275  SetLastError(0xdeadbeef);
276  res = pSetupCopyOEMInfA(path, NULL, SPOST_NONE, 0, dest, 5, &size, NULL);
277  ok(res == FALSE, "Expected FALSE, got %d\n", res);
279  "Expected ERROR_INSUFFICIENT_BUFFER, got %d\n", GetLastError());
280  ok(file_exists(path), "Expected source inf to exist\n");
281  ok(file_exists(dest_save), "Expected dest inf to exist\n");
282  ok(!strcmp(dest, "aaa"), "Expected dest to be unchanged\n");
283  ok(size == strlen(dest_save) + 1, "Expected size to be lstrlen(dest_save) + 1\n");
284 
285  /* get the DestinationInfFileName and DestinationInfFileNameSize */
286  SetLastError(0xdeadbeef);
287  res = pSetupCopyOEMInfA(path, NULL, SPOST_NONE, 0, dest, MAX_PATH, &size, NULL);
288  ok(res == TRUE, "Expected TRUE, got %d\n", res);
289  ok(GetLastError() == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", GetLastError());
290  ok(lstrlenA(dest) + 1 == size, "Expected sizes to match, got (%d, %d)\n", lstrlenA(dest), size);
291  ok(file_exists(dest), "Expected destination inf to exist\n");
292  ok(check_format(dest, NULL), "Expected %%windir%%\\inf\\OEMx.inf, got %s\n", dest);
293  ok(file_exists(path), "Expected source inf to exist\n");
294  ok(size == lstrlenA(dest_save) + 1, "Expected size to be lstrlen(dest_save) + 1\n");
295 
297 
298  /* get the DestinationInfFileName, DestinationInfFileNameSize, and DestinationInfFileNameComponent */
299  SetLastError(0xdeadbeef);
300  res = pSetupCopyOEMInfA(path, NULL, SPOST_NONE, 0, dest, MAX_PATH, &size, &inf);
301  ok(res == TRUE, "Expected TRUE, got %d\n", res);
302  ok(GetLastError() == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", GetLastError());
303  ok(lstrlenA(dest) + 1 == size, "Expected sizes to match, got (%d, %d)\n", lstrlenA(dest), size);
304  ok(file_exists(dest), "Expected destination inf to exist\n");
305  ok((inf && inf[0] != 0) ||
306  broken(!inf), /* Win98 */
307  "Expected inf to point to the filename\n");
308  ok(check_format(dest, inf), "Expected %%windir%%\\inf\\OEMx.inf, got %s\n", dest);
309  ok(file_exists(path), "Expected source inf to exist\n");
310  ok(size == lstrlenA(dest_save) + 1, "Expected size to be lstrlen(dest_save) + 1\n");
311 
312  /* try SP_COPY_DELETESOURCE */
313  SetLastError(0xdeadbeef);
314  res = pSetupCopyOEMInfA(path, NULL, SPOST_NONE, SP_COPY_DELETESOURCE, NULL, 0, NULL, NULL);
315  ok(res == TRUE, "Expected TRUE, got %d\n", res);
316  ok(GetLastError() == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", GetLastError());
317  ok(!file_exists(path), "Expected source inf to not exist\n");
318 
319  if (pSetupUninstallOEMInfA)
320  {
321  char pnf[MAX_PATH];
322  char *pnffile;
323  char *destfile = strrchr(dest, '\\') + 1;
324 
325  strcpy(pnf, dest);
326  *(strrchr(pnf, '.') + 1) = 'p';
327  pnffile = strrchr(pnf, '\\') + 1;
328 
329  SetLastError(0xdeadbeef);
330  res = pSetupUninstallOEMInfA(destfile, 0, NULL);
331  if(!res)
332  res = pSetupUninstallOEMInfA(pnffile, 0, NULL);
333  ok(res, "Failed to uninstall '%s'/'%s' : %d\n", destfile,
334  pnffile, GetLastError());
335  todo_wine ok(!file_exists(dest), "Expected inf '%s' to not exist\n", dest);
336  if(file_exists(dest))
337  {
338  SetLastError(0xdeadbeef);
339  res = DeleteFileA(dest);
340  ok(res, "Failed to delete file '%s' : %d\n", dest, GetLastError());
341  }
342  ok(!file_exists(pnf), "Expected pnf '%s' to not exist\n", pnf);
343  if(file_exists(pnf))
344  {
345  SetLastError(0xdeadbeef);
346  res = DeleteFileA(pnf);
347  ok(res, "Failed to delete file '%s' : %d\n", pnf, GetLastError());
348  }
349  }
350  else
351  {
352  /* Win9x/WinMe */
353  SetLastError(0xdeadbeef);
354  res = DeleteFileA(dest);
355  ok(res, "Failed to delete file '%s' : %d\n", dest, GetLastError());
356 
357  /* On WinMe we also need to remove the .pnf file */
358  *(strrchr(dest, '.') + 1) = 'p';
359  DeleteFileA(dest);
360  }
361 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#define ERROR_FILE_EXISTS
Definition: winerror.h:165
#define TRUE
Definition: types.h:120
#define ERROR_SUCCESS
Definition: deptool.c:10
static void create_inf_file(LPCSTR filename)
Definition: misc.c:52
char * strcat(char *DstString, const char *SrcString)
Definition: utclib.c:568
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
static void get_temp_filename(LPSTR path)
Definition: misc.c:71
static BOOL file_exists(LPSTR path)
Definition: misc.c:82
char CHAR
Definition: xmlstorage.h:175
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
static void test_original_file_name(LPCSTR original, LPCSTR dest)
Definition: misc.c:102
_Check_return_ _CRTIMP _CONST_RETURN char *__cdecl strrchr(_In_z_ const char *_Str, _In_ int _Ch)
static CHAR CURR_DIR[MAX_PATH]
Definition: misc.c:36
char * LPSTR
Definition: xmlstorage.h:182
#define ERROR_ACCESS_DENIED
Definition: compat.h:87
unsigned int BOOL
Definition: ntddk_ex.h:94
static BOOL check_format(LPSTR path, LPSTR inf)
Definition: misc.c:87
#define ok(value,...)
smooth NULL
Definition: ftsmooth.c:416
BOOL WINAPI DeleteFileA(IN LPCSTR lpFileName)
Definition: delete.c:24
#define ERROR_UNSUPPORTED_TYPE
Definition: winerror.h:988
#define ERROR_FILE_NOT_FOUND
Definition: disk.h:79
#define SP_COPY_NOOVERWRITE
Definition: setupapi.h:475
_Check_return_ _CRTIMP FILE *__cdecl tmpfile(void)
Definition: file.c:3912
GLsizeiptr size
Definition: glext.h:5919
#define MAX_PATH
Definition: compat.h:26
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:409
#define todo_wine
Definition: test.h:154
#define SP_COPY_REPLACEONLY
Definition: setupapi.h:472
#define broken(x)
Definition: _sntprintf.h:21
int WINAPI lstrlenA(LPCSTR lpString)
Definition: lstring.c:145
#define ERROR_WRONG_INF_TYPE
Definition: setupapi.h:347
#define SP_COPY_DELETESOURCE
Definition: setupapi.h:471
Definition: services.c:325
#define SPOST_NONE
Definition: setupapi.h:604
#define skip(...)
GLuint res
Definition: glext.h:9613
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
DWORD size
Definition: misc.c:596
static char * dest
Definition: rtl.c:135
#define memset(x, y, z)
Definition: compat.h:39
#define ERROR_BAD_PATHNAME
Definition: winerror.h:233
#define win_skip
Definition: test.h:141
#define ERROR_FILENAME_EXCED_RANGE
Definition: winerror.h:263
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10

Referenced by START_TEST().

◆ test_SetupDecompressOrCopyFile()

static void test_SetupDecompressOrCopyFile ( void  )
static

Definition at line 550 of file misc.c.

551 {
552  DWORD ret;
554  UINT type;
555  int i;
556 
557  const struct
558  {
559  PCSTR source;
560  PCSTR target;
561  PUINT type;
562  } invalid_parameters[] =
563  {
564  {NULL, NULL, NULL},
565  {NULL, NULL, &type},
566  {NULL, target, NULL},
567  {NULL, target, &type},
568  {source, NULL, NULL},
569  {source, NULL, &type},
570  };
571 
572  const struct
573  {
574  const char *filename;
575  const BYTE *expected_buffer;
576  const size_t buffer_size;
577  } zip_multi_tests[] =
578  {
579  {"tristram", laurence, sizeof(laurence)},
580  {"tristram.txt", laurence, sizeof(laurence)},
581  {"wine", laurence, sizeof(laurence)},
582  {"wine.txt", laurence, sizeof(laurence)},
583  {"shandy", laurence, sizeof(laurence)},
584  {"shandy.txt", laurence, sizeof(laurence)},
585  {"deadbeef", laurence, sizeof(laurence)},
586  {"deadbeef.txt", laurence, sizeof(laurence)},
587  };
588 
589  GetTempPathA(sizeof(temp), temp);
590  GetTempFileNameA(temp, "doc", 0, source);
591  GetTempFileNameA(temp, "doc", 0, target);
592 
593  /* parameter tests */
594 
596 
597  for (i = 0; i < ARRAY_SIZE(invalid_parameters); i++)
598  {
600  ret = SetupDecompressOrCopyFileA(invalid_parameters[i].source,
601  invalid_parameters[i].target,
602  invalid_parameters[i].type);
604  "[%d] Expected SetupDecompressOrCopyFileA to return ERROR_INVALID_PARAMETER, got %u\n",
605  i, ret);
606 
607  /* try an invalid compression type */
608  type = 5;
609  ret = SetupDecompressOrCopyFileA(invalid_parameters[i].source,
610  invalid_parameters[i].target,
611  invalid_parameters[i].type);
613  "[%d] Expected SetupDecompressOrCopyFileA to return ERROR_INVALID_PARAMETER, got %u\n",
614  i, ret);
615  }
616 
617  type = 5; /* try an invalid compression type */
619  ok(ret == ERROR_INVALID_PARAMETER, "SetupDecompressOrCopyFile failed unexpectedly\n");
620 
622 
623  /* no compression tests */
624 
626  ok(!ret, "SetupDecompressOrCopyFile failed unexpectedly: %d\n", ret);
627  ok(compare_file_data(target, uncompressed, sizeof(uncompressed)), "incorrect target file\n");
628 
629  /* try overwriting existing file */
631  ok(!ret, "SetupDecompressOrCopyFile failed unexpectedly: %d\n", ret);
633 
636  ok(!ret, "SetupDecompressOrCopyFile failed unexpectedly: %d\n", ret);
637  ok(compare_file_data(target, uncompressed, sizeof(uncompressed)), "incorrect target file\n");
639 
642  ok(!ret, "SetupDecompressOrCopyFile failed unexpectedly: %d\n", ret);
643  ok(compare_file_data(target, uncompressed, sizeof(uncompressed)), "incorrect target file\n");
645 
646  /* lz compression tests */
647 
649 
651  ok(!ret, "SetupDecompressOrCopyFile failed unexpectedly: %d\n", ret);
653 
654  /* zip compression tests */
655 
657 
659  ok(!ret, "SetupDecompressOrCopyFile failed unexpectedly: %d\n", ret);
660  ok(compare_file_data(target, comp_zip, sizeof(comp_zip)), "incorrect target file\n");
662 
663  /* cabinet compression tests */
664 
666 
667  p = strrchr(target, '\\');
668  lstrcpyA(p + 1, "wine");
669 
671  ok(!ret, "SetupDecompressOrCopyFile failed unexpectedly: %d\n", ret);
672  ok(compare_file_data(target, uncompressed, sizeof(uncompressed)), "incorrect target file\n");
673 
674  /* try overwriting existing file */
676  ok(!ret, "SetupDecompressOrCopyFile failed unexpectedly: %d\n", ret);
677 
678  /* try zip compression */
681  ok(!ret, "SetupDecompressOrCopyFile failed unexpectedly: %d\n", ret);
682  ok(compare_file_data(target, uncompressed, sizeof(uncompressed)), "incorrect target file\n");
683 
684  /* try no compression */
687  ok(!ret, "SetupDecompressOrCopyFile failed unexpectedly: %d\n", ret);
688  ok(compare_file_data(target, comp_cab_zip, sizeof(comp_cab_zip)), "incorrect target file\n");
689 
690  /* Show that SetupDecompressOrCopyFileA simply extracts the first file it
691  * finds within the compressed cabinet. Contents are:
692  * tristram -> "laurence\r\n"
693  * wine -> "uncompressed\r\n"
694  * shandy -> "sterne\r\n" */
695 
697 
698  p = strrchr(target, '\\');
699 
700  for (i = 0; i < ARRAY_SIZE(zip_multi_tests); i++)
701  {
702  lstrcpyA(p + 1, zip_multi_tests[i].filename);
703 
705  ok(!ret, "[%d] SetupDecompressOrCopyFile failed unexpectedly: %d\n", i, ret);
706  ok(compare_file_data(target, zip_multi_tests[i].expected_buffer, zip_multi_tests[i].buffer_size),
707  "[%d] incorrect target file\n", i);
709  }
710 
712 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#define FILE_COMPRESSION_NONE
Definition: setupapi.h:351
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
_Check_return_ _CRTIMP _CONST_RETURN char *__cdecl strrchr(_In_z_ const char *_Str, _In_ int _Ch)
const char * filename
Definition: ioapi.h:135
static const BYTE uncompressed[]
Definition: misc.c:392
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
static const BYTE comp_zip[]
Definition: misc.c:402
#define ok(value,...)
static void buffer_size(GLcontext *ctx, GLuint *width, GLuint *height)
Definition: swimpl.c:927
smooth NULL
Definition: ftsmooth.c:416
BOOL WINAPI DeleteFileA(IN LPCSTR lpFileName)
Definition: delete.c:24
static void create_source_file(LPSTR filename, const BYTE *data, DWORD size)
Definition: misc.c:363
#define MAX_PATH
Definition: compat.h:26
unsigned long DWORD
Definition: ntddk_ex.h:95
static const BYTE comp_cab_zip_multi[]
Definition: misc.c:431
LPSTR WINAPI lstrcpyA(LPSTR lpString1, LPCSTR lpString2)
Definition: lstring.c:100
int ret
unsigned char BYTE
Definition: mem.h:68
static const BYTE laurence[]
Definition: misc.c:395
static BOOL compare_file_data(LPSTR file, const BYTE *data, DWORD size)
Definition: misc.c:373
static const BYTE comp_cab_zip[]
Definition: misc.c:423
DWORD WINAPI GetTempPathA(IN DWORD nBufferLength, OUT LPSTR lpBuffer)
Definition: path.c:2053
static calc_node_t temp
Definition: rpn_ieee.c:38
GLsizei GLsizei GLchar * source
Definition: glext.h:6048
#define ARRAY_SIZE(a)
Definition: main.h:24
#define FILE_COMPRESSION_WINLZA
Definition: setupapi.h:354
unsigned int UINT
Definition: ndis.h:50
DWORD WINAPI SetupDecompressOrCopyFileA(PCSTR source, PCSTR target, PUINT type)
Definition: misc.c:1656
GLenum target
Definition: glext.h:7315
const char * PCSTR
Definition: typedefs.h:51
GLfloat GLfloat p
Definition: glext.h:8902
static const BYTE comp_lzx[]
Definition: misc.c:398
UINT WINAPI GetTempFileNameA(IN LPCSTR lpPathName, IN LPCSTR lpPrefixString, IN UINT uUnique, OUT LPSTR lpTempFileName)
Definition: filename.c:26
unsigned int * PUINT
Definition: ndis.h:50
#define FILE_COMPRESSION_MSZIP
Definition: setupapi.h:357

Referenced by START_TEST().

◆ test_SetupGetFileCompressionInfo()

static void test_SetupGetFileCompressionInfo ( void  )
static

Definition at line 444 of file misc.c.

445 {
446  DWORD ret, source_size, target_size;
447  char source[MAX_PATH], temp[MAX_PATH], *name;
448  UINT type;
449 
450  GetTempPathA(sizeof(temp), temp);
451  GetTempFileNameA(temp, "fci", 0, source);
452 
454 
456  ok(ret == ERROR_INVALID_PARAMETER, "SetupGetFileCompressionInfo failed unexpectedly\n");
457 
459  ok(ret == ERROR_INVALID_PARAMETER, "SetupGetFileCompressionInfo failed unexpectedly\n");
460 
462  ok(ret == ERROR_INVALID_PARAMETER, "SetupGetFileCompressionInfo failed unexpectedly\n");
463 
464  ret = SetupGetFileCompressionInfoA(source, &name, &source_size, NULL, NULL);
465  ok(ret == ERROR_INVALID_PARAMETER, "SetupGetFileCompressionInfo failed unexpectedly\n");
466 
467  ret = SetupGetFileCompressionInfoA(source, &name, &source_size, &target_size, NULL);
468  ok(ret == ERROR_INVALID_PARAMETER, "SetupGetFileCompressionInfo failed unexpectedly\n");
469 
470  name = NULL;
471  source_size = target_size = 0;
472  type = 5;
473 
474  ret = SetupGetFileCompressionInfoA(source, &name, &source_size, &target_size, &type);
475  ok(!ret, "SetupGetFileCompressionInfo failed unexpectedly\n");
476  ok(name && !lstrcmpA(name, source), "got %s, expected %s\n", name, source);
477  ok(source_size == sizeof(uncompressed), "got %d\n", source_size);
478  ok(target_size == sizeof(uncompressed), "got %d\n", target_size);
479  ok(type == FILE_COMPRESSION_NONE, "got %d, expected FILE_COMPRESSION_NONE\n", type);
480 
481  MyFree(name);
483 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#define FILE_COMPRESSION_NONE
Definition: setupapi.h:351
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
int WINAPI lstrcmpA(LPCSTR lpString1, LPCSTR lpString2)
Definition: lstring.c:18
static const BYTE uncompressed[]
Definition: misc.c:392
#define ok(value,...)
smooth NULL
Definition: ftsmooth.c:416
BOOL WINAPI DeleteFileA(IN LPCSTR lpFileName)
Definition: delete.c:24
static void create_source_file(LPSTR filename, const BYTE *data, DWORD size)
Definition: misc.c:363
#define MAX_PATH
Definition: compat.h:26
unsigned long DWORD
Definition: ntddk_ex.h:95
int ret
DWORD WINAPI GetTempPathA(IN DWORD nBufferLength, OUT LPSTR lpBuffer)
Definition: path.c:2053
static calc_node_t temp
Definition: rpn_ieee.c:38
unsigned int UINT
Definition: ndis.h:50
Definition: name.c:36
VOID WINAPI MyFree(LPVOID lpMem)
Definition: misc.c:128
UINT WINAPI GetTempFileNameA(IN LPCSTR lpPathName, IN LPCSTR lpPrefixString, IN UINT uUnique, OUT LPSTR lpTempFileName)
Definition: filename.c:26
DWORD WINAPI SetupGetFileCompressionInfoA(PCSTR source, PSTR *name, PDWORD source_size, PDWORD target_size, PUINT type)
Definition: misc.c:1512
GLuint const GLchar * name
Definition: glext.h:6031

Referenced by START_TEST().

◆ test_SetupGetFileCompressionInfoEx()

static void test_SetupGetFileCompressionInfoEx ( void  )
static

Definition at line 485 of file misc.c.

486 {
487  BOOL ret;
488  DWORD required_len, source_size, target_size;
490  UINT type;
491 
492  GetTempPathA(sizeof(temp), temp);
493  GetTempFileNameA(temp, "doc", 0, source);
494 
495  ret = pSetupGetFileCompressionInfoExA(NULL, NULL, 0, NULL, NULL, NULL, NULL);
496  ok(!ret, "SetupGetFileCompressionInfoEx succeeded unexpectedly\n");
497 
498  ret = pSetupGetFileCompressionInfoExA(source, NULL, 0, NULL, NULL, NULL, NULL);
499  ok(!ret, "SetupGetFileCompressionInfoEx succeeded unexpectedly\n");
500 
501  ret = pSetupGetFileCompressionInfoExA(source, NULL, 0, &required_len, NULL, NULL, NULL);
502  ok(!ret, "SetupGetFileCompressionInfoEx succeeded unexpectedly\n");
503  ok(required_len == lstrlenA(source) + 1, "got %d, expected %d\n", required_len, lstrlenA(source) + 1);
504 
506 
507  ret = pSetupGetFileCompressionInfoExA(source, name, sizeof(name), &required_len, &source_size, &target_size, &type);
508  ok(ret, "SetupGetFileCompressionInfoEx failed unexpectedly: %d\n", ret);
509  ok(!lstrcmpA(name, source), "got %s, expected %s\n", name, source);
510  ok(required_len == lstrlenA(source) + 1, "got %d, expected %d\n", required_len, lstrlenA(source) + 1);
511  ok(source_size == sizeof(comp_lzx), "got %d\n", source_size);
512  ok(target_size == sizeof(uncompressed), "got %d\n", target_size);
513  ok(type == FILE_COMPRESSION_WINLZA, "got %d, expected FILE_COMPRESSION_WINLZA\n", type);
515 
517 
518  ret = pSetupGetFileCompressionInfoExA(source, name, sizeof(name), &required_len, &source_size, &target_size, &type);
519  ok(ret, "SetupGetFileCompressionInfoEx failed unexpectedly: %d\n", ret);
520  ok(!lstrcmpA(name, source), "got %s, expected %s\n", name, source);
521  ok(required_len == lstrlenA(source) + 1, "got %d, expected %d\n", required_len, lstrlenA(source) + 1);
522  ok(source_size == sizeof(comp_zip), "got %d\n", source_size);
523  ok(target_size == sizeof(comp_zip), "got %d\n", target_size);
524  ok(type == FILE_COMPRESSION_NONE, "got %d, expected FILE_COMPRESSION_NONE\n", type);
526 
528 
529  ret = pSetupGetFileCompressionInfoExA(source, name, sizeof(name), &required_len, &source_size, &target_size, &type);
530  ok(ret, "SetupGetFileCompressionInfoEx failed unexpectedly: %d\n", ret);
531  ok(!lstrcmpA(name, source), "got %s, expected %s\n", name, source);
532  ok(required_len == lstrlenA(source) + 1, "got %d, expected %d\n", required_len, lstrlenA(source) + 1);
533  ok(source_size == sizeof(comp_cab_lzx), "got %d\n", source_size);
534  ok(target_size == sizeof(uncompressed), "got %d\n", target_size);
535  ok(type == FILE_COMPRESSION_MSZIP, "got %d, expected FILE_COMPRESSION_MSZIP\n", type);
537 
539 
540  ret = pSetupGetFileCompressionInfoExA(source, name, sizeof(name), &required_len, &source_size, &target_size, &type);
541  ok(ret, "SetupGetFileCompressionInfoEx failed unexpectedly: %d\n", ret);
542  ok(!lstrcmpA(name, source), "got %s, expected %s\n", name, source);
543  ok(required_len == lstrlenA(source) + 1, "got %d, expected %d\n", required_len, lstrlenA(source) + 1);
544  ok(source_size == sizeof(comp_cab_zip), "got %d\n", source_size);
545  ok(target_size == sizeof(uncompressed), "got %d\n", target_size);
546  ok(type == FILE_COMPRESSION_MSZIP, "got %d, expected FILE_COMPRESSION_MSZIP\n", type);
548 }
static const BYTE comp_cab_lzx[]
Definition: misc.c:414
#define FILE_COMPRESSION_NONE
Definition: setupapi.h:351
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
int WINAPI lstrcmpA(LPCSTR lpString1, LPCSTR lpString2)
Definition: lstring.c:18
static const BYTE uncompressed[]
Definition: misc.c:392
unsigned int BOOL
Definition: ntddk_ex.h:94
static const BYTE comp_zip[]
Definition: misc.c:402
#define ok(value,...)
smooth NULL
Definition: ftsmooth.c:416
BOOL WINAPI DeleteFileA(IN LPCSTR lpFileName)
Definition: delete.c:24
static void create_source_file(LPSTR filename, const BYTE *data, DWORD size)
Definition: misc.c:363
#define MAX_PATH
Definition: compat.h:26
unsigned long DWORD
Definition: ntddk_ex.h:95
int ret
static const BYTE comp_cab_zip[]
Definition: misc.c:423
int WINAPI lstrlenA(LPCSTR lpString)
Definition: lstring.c:145
DWORD WINAPI GetTempPathA(IN DWORD nBufferLength, OUT LPSTR lpBuffer)
Definition: path.c:2053
static calc_node_t temp
Definition: rpn_ieee.c:38
#define FILE_COMPRESSION_WINLZA
Definition: setupapi.h:354
unsigned int UINT
Definition: ndis.h:50
Definition: name.c:36
static const BYTE comp_lzx[]
Definition: misc.c:398
UINT WINAPI GetTempFileNameA(IN LPCSTR lpPathName, IN LPCSTR lpPrefixString, IN UINT uUnique, OUT LPSTR lpTempFileName)
Definition: filename.c:26
#define FILE_COMPRESSION_MSZIP
Definition: setupapi.h:357

Referenced by START_TEST().

◆ test_SetupLogError()

static void test_SetupLogError ( void  )
static

Definition at line 785 of file misc.c.

786 {
787  BOOL ret;
788  DWORD error;
789 
790  SetLastError(0xdeadbeef);
791  ret = SetupLogErrorA("Test without opening\r\n", LogSevInformation);
792  error = GetLastError();
793  ok(!ret, "SetupLogError succeeded\n");
794  ok(error == ERROR_FILE_INVALID, "got wrong error: %d\n", error);
795 
796  SetLastError(0xdeadbeef);
798  if (!ret && GetLastError() == ERROR_ACCESS_DENIED)
799  {
800  skip("SetupOpenLog() failed on insufficient permissions\n");
801  return;
802  }
803  ok(ret, "SetupOpenLog failed, error %d\n", GetLastError());
804 
805  SetLastError(0xdeadbeef);
806  ret = SetupLogErrorA("Test with wrong log severity\r\n", LogSevMaximum);
807  error = GetLastError();
808  ok(!ret, "SetupLogError succeeded\n");
809  ok(error == 0xdeadbeef, "got wrong error: %d\n", error);
810  ret = SetupLogErrorA("Test without EOL", LogSevInformation);
811  ok(ret, "SetupLogError failed\n");
812 
813  SetLastError(0xdeadbeef);
815  ok(ret || broken(!ret && GetLastError() == ERROR_INVALID_PARAMETER /* Win Vista+ */),
816  "SetupLogError failed: %08x\n", GetLastError());
817 
818  SetLastError(0xdeadbeef);
820  ok(ret, "SetupOpenLog failed, error %d\n", GetLastError());
821 
822  SetupCloseLog();
823 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#define error(str)
Definition: mkdosfs.c:1605
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
#define ERROR_ACCESS_DENIED
Definition: compat.h:87
unsigned int BOOL
Definition: ntddk_ex.h:94
#define ok(value,...)
#define LogSevInformation
Definition: setupapi.h:448
smooth NULL
Definition: ftsmooth.c:416
void WINAPI SetupCloseLog(void)
Definition: misc.c:2017
BOOL WINAPI SetupLogErrorA(LPCSTR message, LogSeverity severity)
Definition: misc.c:2084
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:409
int ret
#define broken(x)
Definition: _sntprintf.h:21
BOOL WINAPI SetupOpenLog(BOOL reserved)
Definition: misc.c:2033
#define ERROR_FILE_INVALID
Definition: winerror.h:585
#define skip(...)
#define LogSevMaximum
Definition: setupapi.h:452

Referenced by START_TEST().

◆ test_SetupUninstallOEMInf()

static void test_SetupUninstallOEMInf ( void  )
static

Definition at line 714 of file misc.c.

715 {
716  BOOL ret;
717 
718  SetLastError(0xdeadbeef);
719  ret = pSetupUninstallOEMInfA(NULL, 0, NULL);
720  ok(!ret, "Expected failure\n");
721  ok(GetLastError() == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %08x\n", GetLastError());
722 
723  SetLastError(0xdeadbeef);
724  ret = pSetupUninstallOEMInfA("", 0, NULL);
725  todo_wine
726  {
727  ok(!ret, "Expected failure\n");
728  ok(GetLastError() == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %08x\n", GetLastError());
729  }
730 
731  SetLastError(0xdeadbeef);
732  ret = pSetupUninstallOEMInfA("nonexistent.inf", 0, NULL);
733  todo_wine
734  {
735  ok(!ret, "Expected failure\n");
736  ok(GetLastError() == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %08x\n", GetLastError());
737  }
738 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
unsigned int BOOL
Definition: ntddk_ex.h:94
#define ok(value,...)
smooth NULL
Definition: ftsmooth.c:416
#define ERROR_FILE_NOT_FOUND
Definition: disk.h:79
#define SetLastError(x)
Definition: compat.h:409
int ret
#define todo_wine
Definition: test.h:154

Referenced by START_TEST().

Variable Documentation

◆ comp_cab_lzx

const BYTE comp_cab_lzx[]
static
Initial value:
= {
0x4d, 0x53, 0x43, 0x46, 0x00, 0x00, 0x00, 0x00, 0x6b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x2c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x01, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x41, 0x00, 0x00, 0x00, 0x01, 0x00, 0x03, 0x0f, 0x0e, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x84, 0x36, 0x86, 0x72, 0x20, 0x00, 0x77, 0x69, 0x6e, 0x65,
0x00, 0x19, 0xd0, 0x1a, 0xe3, 0x22, 0x00, 0x0e, 0x00, 0x5b, 0x80, 0x80, 0x8d, 0x00, 0x30, 0xe0,
0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x75, 0x6e, 0x63,
0x6f, 0x6d, 0x70, 0x72, 0x65, 0x73, 0x73, 0x65, 0x64, 0x0d, 0x0a
}

Definition at line 414 of file misc.c.

Referenced by test_SetupGetFileCompressionInfoEx().

◆ comp_cab_zip

const BYTE comp_cab_zip[]
static
Initial value:
= {
0x4d, 0x53, 0x43, 0x46, 0x00, 0x00, 0x00, 0x00, 0x5b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x2c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x01, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x41, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x0e, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x81, 0x36, 0x2f, 0xa5, 0x20, 0x00, 0x77, 0x69, 0x6e, 0x65,
0x00, 0x7c, 0x80, 0x26, 0x2b, 0x12, 0x00, 0x0e, 0x00, 0x43, 0x4b, 0x2b, 0xcd, 0x4b, 0xce, 0xcf,
0x2d, 0x28, 0x4a, 0x2d, 0x2e, 0x4e, 0x4d, 0xe1, 0xe5, 0x02, 0x00
}

Definition at line 423 of file misc.c.

Referenced by test_SetupDecompressOrCopyFile(), and test_SetupGetFileCompressionInfoEx().

◆ comp_cab_zip_multi

const BYTE comp_cab_zip_multi[]
static
Initial value:
= {
0x4d, 0x53, 0x43, 0x46, 0x00, 0x00, 0x00, 0x00, 0x9c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x2c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x01, 0x01, 0x00, 0x03, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x71, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x0a, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xd1, 0x38, 0xf0, 0x48, 0x20, 0x00, 0x74, 0x72, 0x69, 0x73,
0x74, 0x72, 0x61, 0x6d, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0xd1,
0x38, 0xf0, 0x48, 0x20, 0x00, 0x77, 0x69, 0x6e, 0x65, 0x00, 0x08, 0x00, 0x00, 0x00, 0x18, 0x00,
0x00, 0x00, 0x00, 0x00, 0xd1, 0x38, 0xf0, 0x48, 0x20, 0x00, 0x73, 0x68, 0x61, 0x6e, 0x64, 0x79,
0x00, 0x67, 0x2c, 0x03, 0x85, 0x23, 0x00, 0x20, 0x00, 0x43, 0x4b, 0xcb, 0x49, 0x2c, 0x2d, 0x4a,
0xcd, 0x4b, 0x4e, 0xe5, 0xe5, 0x2a, 0xcd, 0x4b, 0xce, 0xcf, 0x2d, 0x28, 0x4a, 0x2d, 0x2e, 0x4e,
0x4d, 0xe1, 0xe5, 0x2a, 0x2e, 0x49, 0x2d, 0xca, 0x03, 0x8a, 0x02, 0x00
}

Definition at line 431 of file misc.c.

Referenced by test_SetupDecompressOrCopyFile().

◆ comp_lzx

const BYTE comp_lzx[]
static
Initial value:
= {
0x53, 0x5a, 0x44, 0x44, 0x88, 0xf0, 0x27, 0x33, 0x41, 0x00, 0x0e, 0x00, 0x00, 0x00, 0xff, 0x00,
0x00, 0x75, 0x6e, 0x63, 0x6f, 0x6d, 0x70, 0x3f, 0x72, 0x65, 0x73, 0x73, 0x65, 0x64
}

Definition at line 398 of file misc.c.

Referenced by test_SetupDecompressOrCopyFile(), and test_SetupGetFileCompressionInfoEx().

◆ comp_zip

const BYTE comp_zip[]
static
Initial value:
= {
0x50, 0x4b, 0x03, 0x04, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0xbd, 0xae, 0x81, 0x36, 0x75, 0x11,
0x2c, 0x1b, 0x0e, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x04, 0x00, 0x15, 0x00, 0x77, 0x69,
0x6e, 0x65, 0x55, 0x54, 0x09, 0x00, 0x03, 0xd6, 0x0d, 0x10, 0x46, 0xfd, 0x0d, 0x10, 0x46, 0x55,
0x78, 0x04, 0x00, 0xe8, 0x03, 0xe8, 0x03, 0x00, 0x00, 0x75, 0x6e, 0x63, 0x6f, 0x6d, 0x70, 0x72,
0x65, 0x73, 0x73, 0x65, 0x64, 0x50, 0x4b, 0x01, 0x02, 0x17, 0x03, 0x0a, 0x00, 0x00, 0x00, 0x00,
0x00, 0xbd, 0xae, 0x81, 0x36, 0x75, 0x11, 0x2c, 0x1b, 0x0e, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00,
0x00, 0x04, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xa4, 0x81, 0x00,
0x00, 0x00, 0x00, 0x77, 0x69, 0x6e, 0x65, 0x55, 0x54, 0x05, 0x00, 0x03, 0xd6, 0x0d, 0x10, 0x46,
0x55, 0x78, 0x00, 0x00, 0x50, 0x4b, 0x05, 0x06, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00,
0x3f, 0x00, 0x00, 0x00, 0x45, 0x00, 0x00, 0x00, 0x00, 0x00
}

Definition at line 402 of file misc.c.

Referenced by test_SetupDecompressOrCopyFile(), and test_SetupGetFileCompressionInfoEx().

◆ CURR_DIR

CHAR CURR_DIR[MAX_PATH]
static

Definition at line 36 of file misc.c.

Referenced by get_temp_filename(), START_TEST(), and test_SetupCopyOEMInf().

◆ DWORD

Definition at line 47 of file misc.c.

Referenced by GetStyleValue(), NtUserGetGuiResources(), and ToolbarUpdateControlSpaces().

◆ laurence

const BYTE laurence[]
static
Initial value:
= {
'l','a','u','r','e','n','c','e','\r','\n'
}

Definition at line 395 of file misc.c.

Referenced by test_SetupDecompressOrCopyFile().

◆ PCSTR

Definition at line 48 of file misc.c.

◆ PDWORD

Definition at line 47 of file misc.c.

◆ PSP_ALTPLATFORM_INFO

Definition at line 49 of file misc.c.

◆ PSP_ORIGINAL_FILE_INFO_A

Definition at line 49 of file misc.c.

◆ PSTR

Definition at line 47 of file misc.c.

◆ PUINT

Definition at line 47 of file misc.c.

◆ PVOID

Definition at line 50 of file misc.c.

Referenced by USBCCGP_SyncUrbRequest(), and USBSTOR_SyncUrbRequest().

◆ UINT

PSTR* static UINT

Definition at line 49 of file misc.c.

◆ uncompressed

const BYTE uncompressed[]
static
Initial value:
= {
'u','n','c','o','m','p','r','e','s','s','e','d','\r','\n'
}

Definition at line 392 of file misc.c.

Referenced by ExtractZipImage(), RtlDecompressFragment(), test_RtlDecompressBuffer(), test_SetupDecompressOrCopyFile(), test_SetupGetFileCompressionInfo(), test_SetupGetFileCompressionInfoEx(), and WrapCompressedRTFStream().