ReactOS  0.4.12-dev-708-g95ed44e
fdi.c
Go to the documentation of this file.
1 /*
2  * Unit tests for the File Decompression Interface
3  *
4  * Copyright (C) 2006 James Hawkins
5  * Copyright (C) 2013 Dmitry Timoshkov
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with this library; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20  */
21 
22 #include <stdio.h>
23 #include <windows.h>
24 #include "fci.h"
25 #include "fdi.h"
26 #include "wine/test.h"
27 
28 /* make the max size large so there is only one cab file */
29 #define MEDIA_SIZE 999999999
30 #define FOLDER_THRESHOLD 900000
31 
33 
34 /* avoid including CRT headers */
35 #ifndef _O_BINARY
36 # define _O_BINARY 0x8000
37 #endif
38 
39 #ifndef _S_IREAD
40 # define _S_IREAD 0x0100
41 # define _S_IWRITE 0x0080
42 #endif
43 
44 #include <pshpack1.h>
45 
46 struct CFHEADER
47 {
48  UCHAR signature[4]; /* file signature */
49  ULONG reserved1; /* reserved */
50  ULONG cbCabinet; /* size of this cabinet file in bytes */
51  ULONG reserved2; /* reserved */
52  ULONG coffFiles; /* offset of the first CFFILE entry */
53  ULONG reserved3; /* reserved */
54  UCHAR versionMinor; /* cabinet file format version, minor */
55  UCHAR versionMajor; /* cabinet file format version, major */
56  USHORT cFolders; /* number of CFFOLDER entries in this cabinet */
57  USHORT cFiles; /* number of CFFILE entries in this cabinet */
58  USHORT flags; /* cabinet file option indicators */
59  USHORT setID; /* must be the same for all cabinets in a set */
60  USHORT iCabinet; /* number of this cabinet file in a set */
61 #if 0
62  USHORT cbCFHeader; /* (optional) size of per-cabinet reserved area */
63  UCHAR cbCFFolder; /* (optional) size of per-folder reserved area */
64  UCHAR cbCFData; /* (optional) size of per-datablock reserved area */
65  UCHAR abReserve; /* (optional) per-cabinet reserved area */
66  UCHAR szCabinetPrev; /* (optional) name of previous cabinet file */
67  UCHAR szDiskPrev; /* (optional) name of previous disk */
68  UCHAR szCabinetNext; /* (optional) name of next cabinet file */
69  UCHAR szDiskNext; /* (optional) name of next disk */
70 #endif
71 };
72 
73 struct CFFOLDER
74 {
75  ULONG coffCabStart; /* offset of the first CFDATA block in this folder */
76  USHORT cCFData; /* number of CFDATA blocks in this folder */
77  USHORT typeCompress; /* compression type indicator */
78 #if 0
79  UCHAR abReserve[]; /* (optional) per-folder reserved area */
80 #endif
81 };
82 
83 struct CFFILE
84 {
85  ULONG cbFile; /* uncompressed size of this file in bytes */
86  ULONG uoffFolderStart; /* uncompressed offset of this file in the folder */
87  USHORT iFolder; /* index into the CFFOLDER area */
88  USHORT date; /* date stamp for this file */
89  USHORT time; /* time stamp for this file */
90  USHORT attribs; /* attribute flags for this file */
91 #if 0
92  UCHAR szName[]; /* name of this file */
93 #endif
94 };
95 
96 struct CFDATA
97 {
98  ULONG csum; /* checksum of this CFDATA entry */
99  USHORT cbData; /* number of compressed bytes in this block */
100  USHORT cbUncomp; /* number of uncompressed bytes in this block */
101 #if 0
102  UCHAR abReserve[]; /* (optional) per-datablock reserved area */
103  UCHAR ab[cbData]; /* compressed data bytes */
104 #endif
105 };
106 
107 static const struct
108 {
109  struct CFHEADER header;
110  struct CFFOLDER folder;
111  struct CFFILE file;
112  UCHAR szName[sizeof("file.dat")];
113  struct CFDATA data;
114  UCHAR ab[sizeof("Hello World!")-1];
115 } cab_data =
116 {
117  { {'M','S','C','F'}, 0, 0x59, 0, sizeof(struct CFHEADER) + sizeof(struct CFFOLDER), 0, 3,1, 1, 1, 0, 0x1225, 0x2013 },
118  { sizeof(struct CFHEADER) + sizeof(struct CFFOLDER) + sizeof(struct CFFILE) + sizeof("file.dat"), 1, tcompTYPE_NONE },
119  { sizeof("Hello World!")-1, 0, 0x1234, 0x1225, 0x2013, 0xa114 },
120  { 'f','i','l','e','.','d','a','t',0 },
121  { 0, sizeof("Hello World!")-1, sizeof("Hello World!")-1 },
122  { 'H','e','l','l','o',' ','W','o','r','l','d','!' }
123 };
124 
125 #include <poppack.h>
126 
127 struct mem_data
128 {
129  const char *base;
131 };
132 
133 /* FDI callbacks */
134 
135 static void * CDECL fdi_alloc(ULONG cb)
136 {
137  return HeapAlloc(GetProcessHeap(), 0, cb);
138 }
139 
140 static void * CDECL fdi_alloc_bad(ULONG cb)
141 {
142  return NULL;
143 }
144 
145 static void CDECL fdi_free(void *pv)
146 {
147  HeapFree(GetProcessHeap(), 0, pv);
148 }
149 
150 static INT_PTR CDECL fdi_open(char *pszFile, int oflag, int pmode)
151 {
152  HANDLE handle;
154  OPEN_EXISTING, 0, NULL );
156  return 0;
157  return (INT_PTR) handle;
158 }
159 
160 static UINT CDECL fdi_read(INT_PTR hf, void *pv, UINT cb)
161 {
162  HANDLE handle = (HANDLE) hf;
163  DWORD dwRead;
164  if (ReadFile(handle, pv, cb, &dwRead, NULL))
165  return dwRead;
166  return 0;
167 }
168 
169 static UINT CDECL fdi_write(INT_PTR hf, void *pv, UINT cb)
170 {
171  HANDLE handle = (HANDLE) hf;
172  DWORD dwWritten;
173  if (WriteFile(handle, pv, cb, &dwWritten, NULL))
174  return dwWritten;
175  return 0;
176 }
177 
178 static int CDECL fdi_close(INT_PTR hf)
179 {
180  HANDLE handle = (HANDLE) hf;
181  return CloseHandle(handle) ? 0 : -1;
182 }
183 
184 static LONG CDECL fdi_seek(INT_PTR hf, LONG dist, int seektype)
185 {
186  HANDLE handle = (HANDLE) hf;
187  return SetFilePointer(handle, dist, NULL, seektype);
188 }
189 
190 /* Callbacks for testing FDIIsCabinet with hf == 0 */
192 
193 static INT_PTR CDECL fdi_open_static(char *pszFile, int oflag, int pmode)
194 {
195  ok(0, "FDIIsCabinet shouldn't call pfnopen\n");
196  return 1;
197 }
198 
200 {
201  ok(hf == 0, "unexpected hf %lx\n", hf);
202  return fdi_read(static_fdi_handle, pv, cb);
203 }
204 
206 {
207  ok(0, "FDIIsCabinet shouldn't call pfnwrite\n");
208  return 0;
209 }
210 
212 {
213  ok(0, "FDIIsCabinet shouldn't call pfnclose\n");
214  return 0;
215 }
216 
217 static LONG CDECL fdi_seek_static(INT_PTR hf, LONG dist, int seektype)
218 {
219  ok(hf == 0, "unexpected hf %lx\n", hf);
220  return fdi_seek(static_fdi_handle, dist, seektype);
221 }
222 
223 static void test_FDICreate(void)
224 {
225  HFDI hfdi;
226  ERF erf;
227 
228  /* native crashes if pfnalloc is NULL */
229 
230  /* FDICreate does not crash with a NULL pfnfree,
231  * but FDIDestroy will crash when it tries to access it.
232  */
233  if (0)
234  {
235  SetLastError(0xdeadbeef);
236  erf.erfOper = 0x1abe11ed;
237  erf.erfType = 0x5eed1e55;
238  erf.fError = 0x1ead1e55;
241  cpuUNKNOWN, &erf);
242  ok(hfdi != NULL, "Expected non-NULL context\n");
243  ok(GetLastError() == 0xdeadbeef,
244  "Expected 0xdeadbeef, got %d\n", GetLastError());
245  ok(erf.erfOper == 0x1abe11ed, "Expected 0x1abe11ed, got %d\n", erf.erfOper);
246  ok(erf.erfType == 0x5eed1e55, "Expected 0x5eed1e55, got %d\n", erf.erfType);
247  ok(erf.fError == 0x1ead1e55, "Expected 0x1ead1e55, got %d\n", erf.fError);
248 
249  FDIDestroy(hfdi);
250  }
251 
252  SetLastError(0xdeadbeef);
253  erf.erfOper = 0x1abe11ed;
254  erf.erfType = 0x5eed1e55;
255  erf.fError = 0x1ead1e55;
258  cpuUNKNOWN, &erf);
259  ok(hfdi != NULL, "Expected non-NULL context\n");
260  ok(GetLastError() == 0xdeadbeef,
261  "Expected 0xdeadbeef, got %d\n", GetLastError());
262  ok((erf.erfOper == 0x1abe11ed || erf.erfOper == 0 /* Vista */), "Expected 0x1abe11ed or 0, got %d\n", erf.erfOper);
263  ok((erf.erfType == 0x5eed1e55 || erf.erfType == 0 /* Vista */), "Expected 0x5eed1e55 or 0, got %d\n", erf.erfType);
264  ok((erf.fError == 0x1ead1e55 || erf.fError == 0 /* Vista */), "Expected 0x1ead1e55 or 0, got %d\n", erf.fError);
265 
266  FDIDestroy(hfdi);
267 
268  SetLastError(0xdeadbeef);
269  erf.erfOper = 0x1abe11ed;
270  erf.erfType = 0x5eed1e55;
271  erf.fError = 0x1ead1e55;
274  cpuUNKNOWN, &erf);
275  ok(hfdi != NULL, "Expected non-NULL context\n");
276  ok(GetLastError() == 0xdeadbeef,
277  "Expected 0xdeadbeef, got %d\n", GetLastError());
278  ok((erf.erfOper == 0x1abe11ed || erf.erfOper == 0 /* Vista */), "Expected 0x1abe11ed or 0, got %d\n", erf.erfOper);
279  ok((erf.erfType == 0x5eed1e55 || erf.erfType == 0 /* Vista */), "Expected 0x5eed1e55 or 0, got %d\n", erf.erfType);
280  ok((erf.fError == 0x1ead1e55 || erf.fError == 0 /* Vista */), "Expected 0x1ead1e55 or 0, got %d\n", erf.fError);
281 
282  FDIDestroy(hfdi);
283 
284  SetLastError(0xdeadbeef);
285  erf.erfOper = 0x1abe11ed;
286  erf.erfType = 0x5eed1e55;
287  erf.fError = 0x1ead1e55;
290  cpuUNKNOWN, &erf);
291  ok(hfdi != NULL, "Expected non-NULL context\n");
292  ok(GetLastError() == 0xdeadbeef,
293  "Expected 0xdeadbeef, got %d\n", GetLastError());
294  ok((erf.erfOper == 0x1abe11ed || erf.erfOper == 0 /* Vista */), "Expected 0x1abe11ed or 0, got %d\n", erf.erfOper);
295  ok((erf.erfType == 0x5eed1e55 || erf.erfType == 0 /* Vista */), "Expected 0x5eed1e55 or 0, got %d\n", erf.erfType);
296  ok((erf.fError == 0x1ead1e55 || erf.fError == 0 /* Vista */), "Expected 0x1ead1e55 or 0, got %d\n", erf.fError);
297 
298  FDIDestroy(hfdi);
299 
300  SetLastError(0xdeadbeef);
301  erf.erfOper = 0x1abe11ed;
302  erf.erfType = 0x5eed1e55;
303  erf.fError = 0x1ead1e55;
306  cpuUNKNOWN, &erf);
307  ok(hfdi != NULL, "Expected non-NULL context\n");
308  ok(GetLastError() == 0xdeadbeef,
309  "Expected 0xdeadbeef, got %d\n", GetLastError());
310  ok((erf.erfOper == 0x1abe11ed || erf.erfOper == 0 /* Vista */), "Expected 0x1abe11ed or 0, got %d\n", erf.erfOper);
311  ok((erf.erfType == 0x5eed1e55 || erf.erfType == 0 /* Vista */), "Expected 0x5eed1e55 or 0, got %d\n", erf.erfType);
312  ok((erf.fError == 0x1ead1e55 || erf.fError == 0 /* Vista */), "Expected 0x1ead1e55 or 0, got %d\n", erf.fError);
313 
314  FDIDestroy(hfdi);
315 
316  SetLastError(0xdeadbeef);
317  erf.erfOper = 0x1abe11ed;
318  erf.erfType = 0x5eed1e55;
319  erf.fError = 0x1ead1e55;
322  cpuUNKNOWN, &erf);
323  ok(hfdi != NULL, "Expected non-NULL context\n");
324  ok(GetLastError() == 0xdeadbeef,
325  "Expected 0xdeadbeef, got %d\n", GetLastError());
326  ok((erf.erfOper == 0x1abe11ed || erf.erfOper == 0 /* Vista */), "Expected 0x1abe11ed or 0, got %d\n", erf.erfOper);
327  ok((erf.erfType == 0x5eed1e55 || erf.erfType == 0 /* Vista */), "Expected 0x5eed1e55 or 0, got %d\n", erf.erfType);
328  ok((erf.fError == 0x1ead1e55 || erf.fError == 0 /* Vista */), "Expected 0x1ead1e55 or 0, got %d\n", erf.fError);
329 
330  FDIDestroy(hfdi);
331 
332  SetLastError(0xdeadbeef);
333  erf.erfOper = 0x1abe11ed;
334  erf.erfType = 0x5eed1e55;
335  erf.fError = 0x1ead1e55;
338  cpuUNKNOWN, NULL);
339  /* XP sets hfdi to a non-NULL value, but Vista sets it to NULL! */
340  ok(GetLastError() == 0xdeadbeef,
341  "Expected 0xdeadbeef, got %d\n", GetLastError());
342  /* NULL is passed to FDICreate instead of &erf, so don't retest the erf member values. */
343 
344  FDIDestroy(hfdi);
345 
346  /* bad cpu type */
347  SetLastError(0xdeadbeef);
348  erf.erfOper = 0x1abe11ed;
349  erf.erfType = 0x5eed1e55;
350  erf.fError = 0x1ead1e55;
353  0xcafebabe, &erf);
354  ok(hfdi != NULL, "Expected non-NULL context\n");
355  ok(GetLastError() == 0xdeadbeef,
356  "Expected 0xdeadbeef, got %d\n", GetLastError());
357  ok((erf.erfOper == 0x1abe11ed || erf.erfOper == 0 /* Vista */), "Expected 0x1abe11ed or 0, got %d\n", erf.erfOper);
358  ok((erf.erfType == 0x5eed1e55 || erf.erfType == 0 /* Vista */), "Expected 0x5eed1e55 or 0, got %d\n", erf.erfType);
359  ok((erf.fError == 0x1ead1e55 || erf.fError == 0 /* Vista */), "Expected 0x1ead1e55 or 0, got %d\n", erf.fError);
360 
361  FDIDestroy(hfdi);
362 
363  /* pfnalloc fails */
364  SetLastError(0xdeadbeef);
365  erf.erfOper = 0x1abe11ed;
366  erf.erfType = 0x5eed1e55;
367  erf.fError = 0x1ead1e55;
370  cpuUNKNOWN, &erf);
371  ok(hfdi == NULL, "Expected NULL context, got %p\n", hfdi);
372  ok(erf.erfOper == FDIERROR_ALLOC_FAIL,
373  "Expected FDIERROR_ALLOC_FAIL, got %d\n", erf.erfOper);
374  ok(erf.fError == TRUE, "Expected TRUE, got %d\n", erf.fError);
375  ok(GetLastError() == 0xdeadbeef,
376  "Expected 0xdeadbeef, got %d\n", GetLastError());
377  ok(erf.erfType == 0, "Expected 0, got %d\n", erf.erfType);
378 }
379 
380 static void test_FDIDestroy(void)
381 {
382  HFDI hfdi;
383  ERF erf;
384  BOOL ret;
385 
386  /* native crashes if hfdi is NULL or invalid */
387 
390  cpuUNKNOWN, &erf);
391  ok(hfdi != NULL, "Expected non-NULL context\n");
392 
393  /* successfully destroy hfdi */
394  ret = FDIDestroy(hfdi);
395  ok(ret == TRUE, "Expected TRUE, got %d\n", ret);
396 
397  /* native crashes if you try to destroy hfdi twice */
398  if (0)
399  {
400  /* try to destroy hfdi again */
401  ret = FDIDestroy(hfdi);
402  ok(ret == TRUE, "Expected TRUE, got %d\n", ret);
403  }
404 }
405 
406 static void createTestFile(const CHAR *name)
407 {
408  HANDLE file;
409  DWORD written;
410 
412  ok(file != INVALID_HANDLE_VALUE, "Failure to open file %s\n", name);
413  WriteFile(file, name, strlen(name), &written, NULL);
414  WriteFile(file, "\n", strlen("\n"), &written, NULL);
415  CloseHandle(file);
416 }
417 
418 static void create_test_files(void)
419 {
420  DWORD len;
421 
423 
424  if(len && (CURR_DIR[len-1] == '\\'))
425  CURR_DIR[len-1] = 0;
426 
427  createTestFile("a.txt");
428  createTestFile("b.txt");
429  CreateDirectoryA("testdir", NULL);
430  createTestFile("testdir\\c.txt");
431  createTestFile("testdir\\d.txt");
432 }
433 
434 static void delete_test_files(void)
435 {
436  DeleteFileA("a.txt");
437  DeleteFileA("b.txt");
438  DeleteFileA("testdir\\c.txt");
439  DeleteFileA("testdir\\d.txt");
440  RemoveDirectoryA("testdir");
441 
442  DeleteFileA("extract.cab");
443 }
444 
445 /* FCI callbacks */
446 
447 static void * CDECL mem_alloc(ULONG cb)
448 {
449  return HeapAlloc(GetProcessHeap(), 0, cb);
450 }
451 
452 static void CDECL mem_free(void *memory)
453 {
455 }
456 
457 static BOOL CDECL get_next_cabinet(PCCAB pccab, ULONG cbPrevCab, void *pv)
458 {
459  return TRUE;
460 }
461 
462 static LONG CDECL progress(UINT typeStatus, ULONG cb1, ULONG cb2, void *pv)
463 {
464  return 0;
465 }
466 
467 static int CDECL file_placed(PCCAB pccab, char *pszFile, LONG cbFile,
468  BOOL fContinuation, void *pv)
469 {
470  return 0;
471 }
472 
473 static INT_PTR CDECL fci_open(char *pszFile, int oflag, int pmode, int *err, void *pv)
474 {
475  HANDLE handle;
476  DWORD dwAccess = 0;
477  DWORD dwShareMode = 0;
478  DWORD dwCreateDisposition = OPEN_EXISTING;
479 
480  dwAccess = GENERIC_READ | GENERIC_WRITE;
481  /* FILE_SHARE_DELETE is not supported by Windows Me/98/95 */
482  dwShareMode = FILE_SHARE_READ | FILE_SHARE_WRITE;
483 
485  dwCreateDisposition = OPEN_EXISTING;
486  else
487  dwCreateDisposition = CREATE_NEW;
488 
489  handle = CreateFileA(pszFile, dwAccess, dwShareMode, NULL,
490  dwCreateDisposition, 0, NULL);
491 
492  ok(handle != INVALID_HANDLE_VALUE, "Failed to CreateFile %s\n", pszFile);
493 
494  return (INT_PTR)handle;
495 }
496 
497 static UINT CDECL fci_read(INT_PTR hf, void *memory, UINT cb, int *err, void *pv)
498 {
499  HANDLE handle = (HANDLE)hf;
500  DWORD dwRead;
501  BOOL res;
502 
503  res = ReadFile(handle, memory, cb, &dwRead, NULL);
504  ok(res, "Failed to ReadFile\n");
505 
506  return dwRead;
507 }
508 
509 static UINT CDECL fci_write(INT_PTR hf, void *memory, UINT cb, int *err, void *pv)
510 {
511  HANDLE handle = (HANDLE)hf;
512  DWORD dwWritten;
513  BOOL res;
514 
515  res = WriteFile(handle, memory, cb, &dwWritten, NULL);
516  ok(res, "Failed to WriteFile\n");
517 
518  return dwWritten;
519 }
520 
521 static int CDECL fci_close(INT_PTR hf, int *err, void *pv)
522 {
523  HANDLE handle = (HANDLE)hf;
524  ok(CloseHandle(handle), "Failed to CloseHandle\n");
525 
526  return 0;
527 }
528 
529 static LONG CDECL fci_seek(INT_PTR hf, LONG dist, int seektype, int *err, void *pv)
530 {
531  HANDLE handle = (HANDLE)hf;
532  DWORD ret;
533 
534  ret = SetFilePointer(handle, dist, NULL, seektype);
535  ok(ret != INVALID_SET_FILE_POINTER, "Failed to SetFilePointer\n");
536 
537  return ret;
538 }
539 
540 static int CDECL fci_delete(char *pszFile, int *err, void *pv)
541 {
542  BOOL ret = DeleteFileA(pszFile);
543  ok(ret, "Failed to DeleteFile %s\n", pszFile);
544 
545  return 0;
546 }
547 
548 static BOOL CDECL get_temp_file(char *pszTempName, int cbTempName, void *pv)
549 {
550  LPSTR tempname;
551 
552  tempname = HeapAlloc(GetProcessHeap(), 0, MAX_PATH);
553  GetTempFileNameA(".", "xx", 0, tempname);
554 
555  if (tempname && (strlen(tempname) < (unsigned)cbTempName))
556  {
557  lstrcpyA(pszTempName, tempname);
558  HeapFree(GetProcessHeap(), 0, tempname);
559  return TRUE;
560  }
561 
562  HeapFree(GetProcessHeap(), 0, tempname);
563 
564  return FALSE;
565 }
566 
567 static INT_PTR CDECL get_open_info(char *pszName, USHORT *pdate, USHORT *ptime,
568  USHORT *pattribs, int *err, void *pv)
569 {
572  HANDLE handle;
573  DWORD attrs;
574  BOOL res;
575 
578 
579  ok(handle != INVALID_HANDLE_VALUE, "Failed to CreateFile %s\n", pszName);
580 
582  ok(res, "Expected GetFileInformationByHandle to succeed\n");
583 
585  FileTimeToDosDateTime(&filetime, pdate, ptime);
586 
587  attrs = GetFileAttributesA(pszName);
588  ok(attrs != INVALID_FILE_ATTRIBUTES, "Failed to GetFileAttributes\n");
589  /* fixme: should convert attrs to *pattribs, make sure
590  * have a test that catches the fact that we don't?
591  */
592 
593  return (INT_PTR)handle;
594 }
595 
596 static void add_file(HFCI hfci, char *file)
597 {
598  char path[MAX_PATH];
599  BOOL res;
600 
602  lstrcatA(path, "\\");
603  lstrcatA(path, file);
604 
607  ok(res, "Expected FCIAddFile to succeed\n");
608 }
609 
610 static void set_cab_parameters(PCCAB pCabParams)
611 {
612  ZeroMemory(pCabParams, sizeof(CCAB));
613 
614  pCabParams->cb = MEDIA_SIZE;
615  pCabParams->cbFolderThresh = FOLDER_THRESHOLD;
616  pCabParams->setID = 0xbeef;
617  lstrcpyA(pCabParams->szCabPath, CURR_DIR);
618  lstrcatA(pCabParams->szCabPath, "\\");
619  lstrcpyA(pCabParams->szCab, "extract.cab");
620 }
621 
622 static void create_cab_file(void)
623 {
624  CCAB cabParams;
625  HFCI hfci;
626  ERF erf;
627  static CHAR a_txt[] = "a.txt",
628  b_txt[] = "b.txt",
629  testdir_c_txt[] = "testdir\\c.txt",
630  testdir_d_txt[] = "testdir\\d.txt";
631  BOOL res;
632 
633  set_cab_parameters(&cabParams);
634 
637  get_temp_file, &cabParams, NULL);
638 
639  ok(hfci != NULL, "Failed to create an FCI context\n");
640 
641  add_file(hfci, a_txt);
642  add_file(hfci, b_txt);
643  add_file(hfci, testdir_c_txt);
644  add_file(hfci, testdir_d_txt);
645 
647  ok(res, "Failed to flush the cabinet\n");
648 
649  res = FCIDestroy(hfci);
650  ok(res, "Failed to destroy the cabinet\n");
651 }
652 
653 static void test_FDIIsCabinet(void)
654 {
655  ERF erf;
656  BOOL ret;
657  HFDI hfdi;
658  INT_PTR fd;
659  FDICABINETINFO cabinfo;
660  char temp[] = "temp.txt";
661  char extract[] = "extract.cab";
662 
664  create_cab_file();
665 
668  cpuUNKNOWN, &erf);
669  ok(hfdi != NULL, "Expected non-NULL context\n");
670 
671  /* native crashes if hfdi or cabinfo are NULL or invalid */
672 
673  /* invalid file handle */
674  ZeroMemory(&cabinfo, sizeof(FDICABINETINFO));
675  SetLastError(0xdeadbeef);
676  ret = FDIIsCabinet(hfdi, -1, &cabinfo);
677  ok(ret == FALSE, "Expected FALSE, got %d\n", ret);
679  "Expected ERROR_INVALID_HANDLE, got %d\n", GetLastError());
680  ok(cabinfo.cbCabinet == 0, "Expected 0, got %d\n", cabinfo.cbCabinet);
681  ok(cabinfo.cFiles == 0, "Expected 0, got %d\n", cabinfo.cFiles);
682  ok(cabinfo.cFolders == 0, "Expected 0, got %d\n", cabinfo.cFolders);
683  ok(cabinfo.iCabinet == 0, "Expected 0, got %d\n", cabinfo.iCabinet);
684  ok(cabinfo.setID == 0, "Expected 0, got %d\n", cabinfo.setID);
685 
686  createTestFile("temp.txt");
687  fd = fdi_open(temp, 0, 0);
688 
689  /* file handle doesn't point to a cabinet */
690  ZeroMemory(&cabinfo, sizeof(FDICABINETINFO));
691  SetLastError(0xdeadbeef);
692  ret = FDIIsCabinet(hfdi, fd, &cabinfo);
693  ok(ret == FALSE, "Expected FALSE, got %d\n", ret);
694  ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", GetLastError());
695  ok(cabinfo.cbCabinet == 0, "Expected 0, got %d\n", cabinfo.cbCabinet);
696  ok(cabinfo.cFiles == 0, "Expected 0, got %d\n", cabinfo.cFiles);
697  ok(cabinfo.cFolders == 0, "Expected 0, got %d\n", cabinfo.cFolders);
698  ok(cabinfo.iCabinet == 0, "Expected 0, got %d\n", cabinfo.iCabinet);
699  ok(cabinfo.setID == 0, "Expected 0, got %d\n", cabinfo.setID);
700 
701  fdi_close(fd);
702  DeleteFileA("temp.txt");
703 
704  /* try a real cab */
705  fd = fdi_open(extract, 0, 0);
706  ZeroMemory(&cabinfo, sizeof(FDICABINETINFO));
707  SetLastError(0xdeadbeef);
708  ret = FDIIsCabinet(hfdi, fd, &cabinfo);
709  ok(ret == TRUE, "Expected TRUE, got %d\n", ret);
710  ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", GetLastError());
711  ok(cabinfo.cFiles == 4, "Expected 4, got %d\n", cabinfo.cFiles);
712  ok(cabinfo.cFolders == 1, "Expected 1, got %d\n", cabinfo.cFolders);
713  ok(cabinfo.setID == 0xbeef, "Expected 0xbeef, got %d\n", cabinfo.setID);
714  ok(cabinfo.cbCabinet == 182, "Expected 182, got %d\n", cabinfo.cbCabinet);
715  ok(cabinfo.iCabinet == 0, "Expected 0, got %d\n", cabinfo.iCabinet);
716 
717  fdi_close(fd);
718  FDIDestroy(hfdi);
719 
722  cpuUNKNOWN, &erf);
723  ok(hfdi != NULL, "Expected non-NULL context\n");
724 
725  /* FDIIsCabinet accepts hf == 0 even though it's not a valid result of pfnopen */
727  ZeroMemory(&cabinfo, sizeof(FDICABINETINFO));
728  SetLastError(0xdeadbeef);
729  ret = FDIIsCabinet(hfdi, 0, &cabinfo);
730  ok(ret == TRUE, "Expected TRUE, got %d\n", ret);
731  ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", GetLastError());
732  ok(cabinfo.cFiles == 4, "Expected 4, got %d\n", cabinfo.cFiles);
733  ok(cabinfo.cFolders == 1, "Expected 1, got %d\n", cabinfo.cFolders);
734  ok(cabinfo.setID == 0xbeef, "Expected 0xbeef, got %d\n", cabinfo.setID);
735  ok(cabinfo.cbCabinet == 182, "Expected 182, got %d\n", cabinfo.cbCabinet);
736  ok(cabinfo.iCabinet == 0, "Expected 0, got %d\n", cabinfo.iCabinet);
737 
739  FDIDestroy(hfdi);
740 
742 }
743 
744 
746 {
747  return 37; /* doc says 0, but anything != -1 apparently means success as well */
748 }
749 
750 static INT_PTR CDECL fdi_mem_open(char *name, int oflag, int pmode)
751 {
752  static const char expected[] = "memory\\block";
753  struct mem_data *data;
754 
755  ok(!strcmp(name, expected), "expected %s, got %s\n", expected, name);
756  ok(oflag == _O_BINARY, "expected _O_BINARY, got %x\n", oflag);
757  ok(pmode == (_S_IREAD | _S_IWRITE), "expected _S_IREAD | _S_IWRITE, got %x\n", pmode);
758 
759  data = HeapAlloc(GetProcessHeap(), 0, sizeof(*data));
760  if (!data) return -1;
761 
762  data->base = (const char *)&cab_data;
763  data->size = sizeof(cab_data);
764  data->pos = 0;
765 
766  trace("mem_open(%s,%x,%x) => %p\n", name, oflag, pmode, data);
767  return (INT_PTR)data;
768 }
769 
770 static UINT CDECL fdi_mem_read(INT_PTR hf, void *pv, UINT cb)
771 {
772  struct mem_data *data = (struct mem_data *)hf;
773  UINT available, cb_read;
774 
775  available = data->size - data->pos;
776  cb_read = (available >= cb) ? cb : available;
777 
778  memcpy(pv, data->base + data->pos, cb_read);
779  data->pos += cb_read;
780 
781  /*trace("mem_read(%p,%p,%u) => %u\n", hf, pv, cb, cb_read);*/
782  return cb_read;
783 }
784 
786 {
787  static const char expected[12] = "Hello World!";
788 
789  trace("mem_write(%#lx,%p,%u)\n", hf, pv, cb);
790 
791  ok(hf == 0x12345678, "expected 0x12345678, got %#lx\n", hf);
792  ok(cb == 12, "expected 12, got %u\n", cb);
793  ok(!memcmp(pv, expected, 12), "expected %s, got %s\n", expected, (const char *)pv);
794 
795  return cb;
796 }
797 
799 {
800  HeapFree(GetProcessHeap(), 0, (void *)hf);
801  return 0;
802 }
803 
804 static LONG CDECL fdi_mem_seek(INT_PTR hf, LONG dist, int seektype)
805 {
806  struct mem_data *data = (struct mem_data *)hf;
807 
808  switch (seektype)
809  {
810  case SEEK_SET:
811  data->pos = dist;
812  break;
813 
814  case SEEK_CUR:
815  data->pos += dist;
816  break;
817 
818  case SEEK_END:
819  default:
820  ok(0, "seek: not expected type %d\n", seektype);
821  return -1;
822  }
823 
824  if (data->pos < 0) data->pos = 0;
825  if (data->pos > data->size) data->pos = data->size;
826 
827  /*mem_seek(%p,%d,%d) => %u\n", hf, dist, seektype, data->pos);*/
828  return data->pos;
829 }
830 
832 {
833  static const char expected[9] = "file.dat\0";
834 
835  switch (fdint)
836  {
838  trace("mem_notify: CLOSE_FILE_INFO %s, handle %#lx\n", info->psz1, info->hf);
839 
840  ok(!strcmp(info->psz1, expected), "expected %s, got %s\n", expected, info->psz1);
841  ok(info->date == 0x1225, "expected 0x1225, got %#x\n", info->date);
842  ok(info->time == 0x2013, "expected 0x2013, got %#x\n", info->time);
843  ok(info->attribs == 0xa114, "expected 0xa114, got %#x\n", info->attribs);
844  ok(info->iFolder == 0x1234, "expected 0x1234, got %#x\n", info->iFolder);
845  return 1;
846 
847  case fdintCOPY_FILE:
848  {
849  trace("mem_notify: COPY_FILE %s, %d bytes\n", info->psz1, info->cb);
850 
851  ok(info->cb == 12, "expected 12, got %u\n", info->cb);
852  ok(!strcmp(info->psz1, expected), "expected %s, got %s\n", expected, info->psz1);
853  ok(info->iFolder == 0x1234, "expected 0x1234, got %#x\n", info->iFolder);
854  return 0x12345678; /* call write() callback */
855  }
856 
857  default:
858  trace("mem_notify(%d,%p)\n", fdint, info);
859  return 0;
860  }
861 
862  return 0;
863 }
864 
865 static void test_FDICopy(void)
866 {
867  CCAB cabParams;
868  HFDI hfdi;
869  HFCI hfci;
870  ERF erf;
871  BOOL ret;
872  char name[] = "extract.cab";
873  char path[MAX_PATH + 1];
874  char memory_block[] = "memory\\block";
875  char memory[] = "memory\\";
876  char block[] = "block";
878  INT_PTR fd;
879 
880  set_cab_parameters(&cabParams);
881 
884  fci_delete, get_temp_file, &cabParams, NULL);
885 
887  ok(ret, "Failed to flush the cabinet\n");
888 
889  FCIDestroy(hfci);
890 
892 
893  /* path doesn't have a trailing backslash */
894  if (lstrlenA(path) > 2)
895  {
898  cpuUNKNOWN, &erf);
899 
900  SetLastError(0xdeadbeef);
901  ret = FDICopy(hfdi, name, path, 0, CopyProgress, NULL, 0);
902  ok(ret == FALSE, "Expected FALSE, got %d\n", ret);
904  "Expected ERROR_INVALID_HANDLE, got %d\n", GetLastError());
905 
906  FDIDestroy(hfdi);
907  }
908  else
909  skip("Running on a root drive directory.\n");
910 
911  lstrcatA(path, "\\");
912 
915  cpuUNKNOWN, &erf);
916 
917  /* cabinet with no files or folders */
918  SetLastError(0xdeadbeef);
919  ret = FDICopy(hfdi, name, path, 0, CopyProgress, NULL, 0);
920  ok(ret == TRUE, "Expected TRUE, got %d\n", ret);
921  ok(GetLastError() == 0, "Expected 0f, got %d\n", GetLastError());
922 
923  FDIDestroy(hfdi);
924 
925  DeleteFileA(name);
926 
927  /* test extracting from a memory block */
930  ok(hfdi != NULL, "FDICreate error %d\n", erf.erfOper);
931 
932  fd = fdi_mem_open(memory_block, _O_BINARY, _S_IREAD | _S_IWRITE);
933  ok(fd != -1, "fdi_open failed\n");
934 
935  memset(&info, 0, sizeof(info));
936  ret = FDIIsCabinet(hfdi, fd, &info);
937  ok(ret, "FDIIsCabinet error %d\n", erf.erfOper);
938  ok(info.cbCabinet == 0x59, "expected 0x59, got %#x\n", info.cbCabinet);
939  ok(info.cFiles == 1, "expected 1, got %d\n", info.cFiles);
940  ok(info.cFolders == 1, "expected 1, got %d\n", info.cFolders);
941  ok(info.setID == 0x1225, "expected 0x1225, got %#x\n", info.setID);
942  ok(info.iCabinet == 0x2013, "expected 0x2013, got %#x\n", info.iCabinet);
943 
944  fdi_mem_close(fd);
945 
946  ret = FDICopy(hfdi, block, memory, 0, fdi_mem_notify, NULL, 0);
947  ok(ret, "FDICopy error %d\n", erf.erfOper);
948 
949  FDIDestroy(hfdi);
950 }
951 
952 
954 {
955  test_FDICreate();
956  test_FDIDestroy();
958  test_FDICopy();
959 }
static unsigned int block
Definition: xmlmemory.c:118
ULONG cbFolderThresh
Definition: fci.h:146
static INT_PTR CDECL fdi_open_static(char *pszFile, int oflag, int pmode)
Definition: fdi.c:193
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 SEEK_CUR
Definition: util.h:63
#define trace(...)
Definition: kmt_test.h:217
LONG size
Definition: fdi.c:130
BOOL __cdecl FDIDestroy(HFDI hfdi)
Definition: fdi.c:2831
static UINT CDECL fdi_write(INT_PTR hf, void *pv, UINT cb)
Definition: fdi.c:169
static BOOL CDECL get_temp_file(char *pszTempName, int cbTempName, void *pv)
Definition: fdi.c:548
namespace GUID const ADDRINFOEXW ADDRINFOEXW struct timeval OVERLAPPED LPLOOKUPSERVICE_COMPLETION_ROUTINE HANDLE * handle
Definition: sock.c:82
#define TRUE
Definition: types.h:120
USHORT cFolders
Definition: fdi.c:56
#define CloseHandle
Definition: compat.h:398
#define INVALID_SET_FILE_POINTER
Definition: winbase.h:115
cab_UBYTE signature[4]
Definition: fci.c:66
const char * base
Definition: fdi.c:129
Definition: fci.c:115
static void test_FDIIsCabinet(void)
Definition: fdi.c:653
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
struct CFFILE file
Definition: fdi.c:111
#define _S_IWRITE
Definition: fdi.c:41
BOOL __cdecl FCIFlushCabinet(HFCI hfci, BOOL fGetNextCab, PFNFCIGETNEXTCABINET pfnfcignc, PFNFCISTATUS pfnfcis)
Definition: fci.c:1675
ULONG reserved1
Definition: fdi.c:49
HFCI __cdecl FCICreate(PERF perf, PFNFCIFILEPLACED pfnfiledest, PFNFCIALLOC pfnalloc, PFNFCIFREE pfnfree, PFNFCIOPEN pfnopen, PFNFCIREAD pfnread, PFNFCIWRITE pfnwrite, PFNFCICLOSE pfnclose, PFNFCISEEK pfnseek, PFNFCIDELETE pfndelete, PFNFCIGETTEMPFILE pfnfcigtf, PCCAB pccab, void *pv)
Definition: fci.c:998
static CHAR CURR_DIR[MAX_PATH]
Definition: fdi.c:32
#define __cdecl
Definition: accygwin.h:79
ActualNumberDriverObjects * sizeof(PDRIVER_OBJECT)) PDRIVER_OBJECT *DriverObjectList
static INT_PTR __cdecl CopyProgress(FDINOTIFICATIONTYPE fdint, PFDINOTIFICATION pfdin)
Definition: fdi.c:745
static void CDECL fdi_free(void *pv)
Definition: fdi.c:145
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
static UINT CDECL fci_read(INT_PTR hf, void *memory, UINT cb, int *err, void *pv)
Definition: fdi.c:497
USHORT cCFData
Definition: fdi.c:76
USHORT setID
Definition: fdi.h:149
UCHAR versionMajor
Definition: fdi.c:55
char CHAR
Definition: xmlstorage.h:175
static INT_PTR CDECL fdi_open(char *pszFile, int oflag, int pmode)
Definition: fdi.c:150
USHORT date
Definition: fdi.c:88
cab_UWORD cbData
Definition: fci.c:103
static INT_PTR CDECL fdi_mem_notify(FDINOTIFICATIONTYPE fdint, FDINOTIFICATION *info)
Definition: fdi.c:831
USHORT cFolders
Definition: fdi.h:147
#define ERROR_INVALID_HANDLE
Definition: compat.h:88
BOOL __cdecl FCIDestroy(HFCI hfci)
Definition: fci.c:1709
static void add_file(HFCI hfci, char *file)
Definition: fdi.c:596
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
#define ZeroMemory
Definition: winbase.h:1635
static int fd
Definition: io.c:51
static void test_FDICreate(void)
Definition: fdi.c:223
static UINT CDECL fdi_read_static(INT_PTR hf, void *pv, UINT cb)
Definition: fdi.c:199
ULONG cbFile
Definition: fdi.c:85
#define FILE_SHARE_WRITE
Definition: nt_native.h:681
Definition: fci.h:144
int32_t INT_PTR
Definition: typedefs.h:62
UCHAR szName[sizeof("file.dat")]
Definition: fdi.c:112
char * LPSTR
Definition: xmlstorage.h:182
static UINT CDECL fdi_mem_write(INT_PTR hf, void *pv, UINT cb)
Definition: fdi.c:785
BOOL WINAPI FileTimeToLocalFileTime(IN CONST FILETIME *lpFileTime, OUT LPFILETIME lpLocalFileTime)
Definition: time.c:211
static char memory[1024 *256]
Definition: process.c:116
#define FILE_SHARE_READ
Definition: compat.h:125
BOOL extract(char *filename, const bin_file *bin)
Definition: mspatcha.c:158
#define tcompTYPE_MSZIP
Definition: fci.h:65
static void test_FDICopy(void)
Definition: fdi.c:865
static void create_cab_file(void)
Definition: fdi.c:622
DWORD WINAPI DECLSPEC_HOTPATCH SetFilePointer(HANDLE hFile, LONG lDistanceToMove, PLONG lpDistanceToMoveHigh, DWORD dwMoveMethod)
Definition: fileinfo.c:204
struct _test_info info[]
Definition: SetCursorPos.c:19
static int CDECL fci_delete(char *pszFile, int *err, void *pv)
Definition: fdi.c:540
UCHAR versionMinor
Definition: fdi.c:54
ULONG coffFiles
Definition: fdi.c:52
USHORT cFiles
Definition: fdi.h:148
#define cpuUNKNOWN
Definition: fdi.h:269
long LONG
Definition: pedump.c:60
FDINOTIFICATIONTYPE
Definition: fdi.h:246
Definition: fci.c:82
USHORT typeCompress
Definition: fdi.c:77
DWORD WINAPI GetFileAttributesA(LPCSTR lpFileName)
Definition: fileinfo.c:786
Definition: fci.h:44
struct CFDATA data
Definition: fdi.c:113
BOOL __cdecl FDICopy(HFDI hfdi, char *pszCabinet, char *pszCabPath, int flags, PFNFDINOTIFY pfnfdin, PFNFDIDECRYPT pfnfdid, void *pvUser)
Definition: fdi.c:2431
#define GENERIC_WRITE
Definition: nt_native.h:90
DWORD void * pv
Definition: msvc.h:87
char szCab[CB_MAX_CABINET_NAME]
Definition: fci.h:160
static LONG CDECL fdi_seek_static(INT_PTR hf, LONG dist, int seektype)
Definition: fdi.c:217
static UINT CDECL fci_write(INT_PTR hf, void *memory, UINT cb, int *err, void *pv)
Definition: fdi.c:509
USHORT cFiles
Definition: fdi.c:57
Definition: fci.c:101
ULONG cb
Definition: fci.h:145
BOOL WINAPI CreateDirectoryA(IN LPCSTR lpPathName, IN LPSECURITY_ATTRIBUTES lpSecurityAttributes)
Definition: dir.c:37
smooth NULL
Definition: ftsmooth.c:416
static WCHAR available[MAX_STRING_RESOURCE_LEN]
Definition: object.c:2336
static void test_FDIDestroy(void)
Definition: fdi.c:380
BOOL WINAPI DeleteFileA(IN LPCSTR lpFileName)
Definition: delete.c:24
HFDI __cdecl FDICreate(PFNALLOC pfnalloc, PFNFREE pfnfree, PFNOPEN pfnopen, PFNREAD pfnread, PFNWRITE pfnwrite, PFNCLOSE pfnclose, PFNSEEK pfnseek, int cpuType, PERF perf)
Definition: fdi.c:412
static BOOL CDECL get_next_cabinet(PCCAB pccab, ULONG cbPrevCab, void *pv)
Definition: fdi.c:457
LONG cbCabinet
Definition: fdi.h:146
UCHAR ab[sizeof("Hello World!") -1]
Definition: fdi.c:114
static void createTestFile(const CHAR *name)
Definition: fdi.c:406
#define OPEN_EXISTING
Definition: compat.h:426
#define ok(value,...)
Definition: CComObject.cpp:34
static int CDECL fdi_mem_close(INT_PTR hf)
Definition: fdi.c:798
USHORT iCabinet
Definition: fdi.c:60
#define SEEK_SET
Definition: jmemansi.c:26
LPSTR WINAPI lstrcatA(LPSTR lpString1, LPCSTR lpString2)
Definition: lstring.c:123
unsigned int BOOL
Definition: ntddk_ex.h:94
#define GetProcessHeap()
Definition: compat.h:395
ULONG csum
Definition: fdi.c:98
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
#define tcompTYPE_NONE
Definition: fci.h:64
static UINT CDECL fdi_mem_read(INT_PTR hf, void *pv, UINT cb)
Definition: fdi.c:770
BOOL WINAPI GetFileInformationByHandle(HANDLE hFile, LPBY_HANDLE_FILE_INFORMATION lpFileInformation)
Definition: fileinfo.c:608
static UINT CDECL fdi_write_static(INT_PTR hf, void *pv, UINT cb)
Definition: fdi.c:205
static int CDECL fdi_close(INT_PTR hf)
Definition: fdi.c:178
double __cdecl erf(double)
#define MAX_PATH
Definition: compat.h:26
static LONG CDECL progress(UINT typeStatus, ULONG cb1, ULONG cb2, void *pv)
Definition: fdi.c:462
unsigned int UINT
Definition: ndis.h:50
#define MEDIA_SIZE
Definition: fdi.c:29
unsigned long DWORD
Definition: ntddk_ex.h:95
PVOID HANDLE
Definition: typedefs.h:71
Definition: fci.c:89
Definition: fdi.c:127
#define SetLastError(x)
Definition: compat.h:409
#define INVALID_FILE_ATTRIBUTES
Definition: vfdcmd.c:23
static DWORD cb
Definition: integrity.c:41
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
LPSTR WINAPI lstrcpyA(LPSTR lpString1, LPCSTR lpString2)
Definition: lstring.c:100
static INT_PTR CDECL fdi_mem_open(char *name, int oflag, int pmode)
Definition: fdi.c:750
unsigned char UCHAR
Definition: xmlstorage.h:181
int ret
#define FILE_ATTRIBUTE_NORMAL
Definition: compat.h:126
USHORT time
Definition: fdi.c:89
ULONG cbCabinet
Definition: fdi.c:50
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
GLenum GLsizei len
Definition: glext.h:6722
#define GENERIC_READ
Definition: compat.h:124
static LONG CDECL fdi_mem_seek(INT_PTR hf, LONG dist, int seektype)
Definition: fdi.c:804
static stack_node_t temp
Definition: rpn.c:18
#define err(...)
static UINT CDECL fdi_read(INT_PTR hf, void *pv, UINT cb)
Definition: fdi.c:160
static void delete_test_files(void)
Definition: fdi.c:434
#define _S_IREAD
Definition: fdi.c:40
static void *CDECL mem_alloc(ULONG cb)
Definition: fdi.c:447
BOOL WINAPI FileTimeToDosDateTime(IN CONST FILETIME *lpFileTime, OUT LPWORD lpFatDate, OUT LPWORD lpFatTime)
Definition: time.c:37
#define CREATE_ALWAYS
Definition: disk.h:72
int WINAPI lstrlenA(LPCSTR lpString)
Definition: lstring.c:145
#define FOLDER_THRESHOLD
Definition: fdi.c:30
#define CDECL
Definition: compat.h:21
USHORT cbData
Definition: fdi.c:99
unsigned short USHORT
Definition: pedump.c:61
static LONG CDECL fci_seek(INT_PTR hf, LONG dist, int seektype, int *err, void *pv)
Definition: fdi.c:529
#define FILE_FLAG_SEQUENTIAL_SCAN
Definition: disk.h:43
USHORT attribs
Definition: fdi.c:90
DWORD WINAPI GetCurrentDirectoryA(IN DWORD nBufferLength, OUT LPSTR lpBuffer)
Definition: path.c:2145
#define skip(...)
Definition: CString.cpp:57
USHORT flags
Definition: fdi.c:58
Definition: services.c:325
BOOL WINAPI RemoveDirectoryA(IN LPCSTR lpPathName)
Definition: dir.c:714
USHORT setID
Definition: fci.h:157
ULONG reserved2
Definition: fdi.c:51
static void CDECL mem_free(void *memory)
Definition: fdi.c:452
START_TEST(fdi)
Definition: fdi.c:953
Definition: fci.c:65
BOOL __cdecl FCIAddFile(HFCI hfci, char *pszSourceFile, char *pszFileName, BOOL fExecute, PFNFCIGETNEXTCABINET pfnfcignc, PFNFCISTATUS pfnfcis, PFNFCIGETOPENINFO pfnfcigoi, TCOMP typeCompress)
Definition: fci.c:1397
static void create_test_files(void)
Definition: fdi.c:418
static int CDECL file_placed(PCCAB pccab, char *pszFile, LONG cbFile, BOOL fContinuation, void *pv)
Definition: fdi.c:467
static INT_PTR static_fdi_handle
Definition: fdi.c:191
USHORT iCabinet
Definition: fdi.h:150
Definition: name.c:36
GLuint res
Definition: glext.h:9613
USHORT iFolder
Definition: fdi.c:87
USHORT cbUncomp
Definition: fdi.c:100
char szCabPath[CB_MAX_CAB_PATH]
Definition: fci.h:161
ULONG uoffFolderStart
Definition: fdi.c:86
unsigned int ULONG
Definition: retypes.h:1
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
#define SEEK_END
Definition: cabinet.c:27
BOOL __cdecl FDIIsCabinet(HFDI hfdi, INT_PTR hf, PFDICABINETINFO pfdici)
Definition: fdi.c:696
#define _O_BINARY
Definition: fdi.c:36
static INT_PTR CDECL fci_open(char *pszFile, int oflag, int pmode, int *err, void *pv)
Definition: fdi.c:473
ULONG coffCabStart
Definition: fdi.c:75
static LONG CDECL fdi_seek(INT_PTR hf, LONG dist, int seektype)
Definition: fdi.c:184
static int CDECL fci_close(INT_PTR hf, int *err, void *pv)
Definition: fdi.c:521
#define CREATE_NEW
Definition: disk.h:69
static int CDECL fdi_close_static(INT_PTR hf)
Definition: fdi.c:211
ULONG reserved3
Definition: fdi.c:53
#define CreateFileA(a, b, c, d, e, f, g)
Definition: compat.h:399
static INT_PTR CDECL get_open_info(char *pszName, USHORT *pdate, USHORT *ptime, USHORT *pattribs, int *err, void *pv)
Definition: fdi.c:567
LONG pos
Definition: fdi.c:130
static const struct @1574 cab_data
static void *CDECL fdi_alloc_bad(ULONG cb)
Definition: fdi.c:140
USHORT setID
Definition: fdi.c:59
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 memset(x, y, z)
Definition: compat.h:39
UINT WINAPI GetTempFileNameA(IN LPCSTR lpPathName, IN LPCSTR lpPrefixString, IN UINT uUnique, OUT LPSTR lpTempFileName)
Definition: filename.c:26
#define HeapFree(x, y, z)
Definition: compat.h:394
struct CFHEADER header
Definition: fdi.c:109
BOOL expected
Definition: store.c:2063
static void set_cab_parameters(PCCAB pCabParams)
Definition: fdi.c:610
Definition: fci.c:126
static void *CDECL fdi_alloc(ULONG cb)
Definition: fdi.c:135