29 #define MEDIA_SIZE 999999999 30 #define FOLDER_THRESHOLD 900000 36 # define _O_BINARY 0x8000 40 # define _S_IREAD 0x0100 41 # define _S_IWRITE 0x0080 117 { {
'M',
'S',
'C',
'F'}, 0, 0x59, 0,
sizeof(
struct CFHEADER) +
sizeof(
struct CFFOLDER), 0, 3,1, 1, 1, 0, 0x1225, 0x2013 },
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',
'!' }
195 ok(0,
"FDIIsCabinet shouldn't call pfnopen\n");
201 ok(hf == 0,
"unexpected hf %lx\n", hf);
207 ok(0,
"FDIIsCabinet shouldn't call pfnwrite\n");
213 ok(0,
"FDIIsCabinet shouldn't call pfnclose\n");
219 ok(hf == 0,
"unexpected hf %lx\n", hf);
236 erf.erfOper = 0x1abe11ed;
237 erf.erfType = 0x5eed1e55;
238 erf.fError = 0x1ead1e55;
242 ok(hfdi !=
NULL,
"Expected non-NULL context\n");
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);
253 erf.erfOper = 0x1abe11ed;
254 erf.erfType = 0x5eed1e55;
255 erf.fError = 0x1ead1e55;
259 ok(hfdi !=
NULL,
"Expected non-NULL context\n");
262 ok((
erf.erfOper == 0x1abe11ed ||
erf.erfOper == 0 ),
"Expected 0x1abe11ed or 0, got %d\n",
erf.erfOper);
263 ok((
erf.erfType == 0x5eed1e55 ||
erf.erfType == 0 ),
"Expected 0x5eed1e55 or 0, got %d\n",
erf.erfType);
264 ok((
erf.fError == 0x1ead1e55 ||
erf.fError == 0 ),
"Expected 0x1ead1e55 or 0, got %d\n",
erf.fError);
269 erf.erfOper = 0x1abe11ed;
270 erf.erfType = 0x5eed1e55;
271 erf.fError = 0x1ead1e55;
275 ok(hfdi !=
NULL,
"Expected non-NULL context\n");
278 ok((
erf.erfOper == 0x1abe11ed ||
erf.erfOper == 0 ),
"Expected 0x1abe11ed or 0, got %d\n",
erf.erfOper);
279 ok((
erf.erfType == 0x5eed1e55 ||
erf.erfType == 0 ),
"Expected 0x5eed1e55 or 0, got %d\n",
erf.erfType);
280 ok((
erf.fError == 0x1ead1e55 ||
erf.fError == 0 ),
"Expected 0x1ead1e55 or 0, got %d\n",
erf.fError);
285 erf.erfOper = 0x1abe11ed;
286 erf.erfType = 0x5eed1e55;
287 erf.fError = 0x1ead1e55;
291 ok(hfdi !=
NULL,
"Expected non-NULL context\n");
294 ok((
erf.erfOper == 0x1abe11ed ||
erf.erfOper == 0 ),
"Expected 0x1abe11ed or 0, got %d\n",
erf.erfOper);
295 ok((
erf.erfType == 0x5eed1e55 ||
erf.erfType == 0 ),
"Expected 0x5eed1e55 or 0, got %d\n",
erf.erfType);
296 ok((
erf.fError == 0x1ead1e55 ||
erf.fError == 0 ),
"Expected 0x1ead1e55 or 0, got %d\n",
erf.fError);
301 erf.erfOper = 0x1abe11ed;
302 erf.erfType = 0x5eed1e55;
303 erf.fError = 0x1ead1e55;
307 ok(hfdi !=
NULL,
"Expected non-NULL context\n");
310 ok((
erf.erfOper == 0x1abe11ed ||
erf.erfOper == 0 ),
"Expected 0x1abe11ed or 0, got %d\n",
erf.erfOper);
311 ok((
erf.erfType == 0x5eed1e55 ||
erf.erfType == 0 ),
"Expected 0x5eed1e55 or 0, got %d\n",
erf.erfType);
312 ok((
erf.fError == 0x1ead1e55 ||
erf.fError == 0 ),
"Expected 0x1ead1e55 or 0, got %d\n",
erf.fError);
317 erf.erfOper = 0x1abe11ed;
318 erf.erfType = 0x5eed1e55;
319 erf.fError = 0x1ead1e55;
323 ok(hfdi !=
NULL,
"Expected non-NULL context\n");
326 ok((
erf.erfOper == 0x1abe11ed ||
erf.erfOper == 0 ),
"Expected 0x1abe11ed or 0, got %d\n",
erf.erfOper);
327 ok((
erf.erfType == 0x5eed1e55 ||
erf.erfType == 0 ),
"Expected 0x5eed1e55 or 0, got %d\n",
erf.erfType);
328 ok((
erf.fError == 0x1ead1e55 ||
erf.fError == 0 ),
"Expected 0x1ead1e55 or 0, got %d\n",
erf.fError);
333 erf.erfOper = 0x1abe11ed;
334 erf.erfType = 0x5eed1e55;
335 erf.fError = 0x1ead1e55;
348 erf.erfOper = 0x1abe11ed;
349 erf.erfType = 0x5eed1e55;
350 erf.fError = 0x1ead1e55;
354 ok(hfdi !=
NULL,
"Expected non-NULL context\n");
357 ok((
erf.erfOper == 0x1abe11ed ||
erf.erfOper == 0 ),
"Expected 0x1abe11ed or 0, got %d\n",
erf.erfOper);
358 ok((
erf.erfType == 0x5eed1e55 ||
erf.erfType == 0 ),
"Expected 0x5eed1e55 or 0, got %d\n",
erf.erfType);
359 ok((
erf.fError == 0x1ead1e55 ||
erf.fError == 0 ),
"Expected 0x1ead1e55 or 0, got %d\n",
erf.fError);
365 erf.erfOper = 0x1abe11ed;
366 erf.erfType = 0x5eed1e55;
367 erf.fError = 0x1ead1e55;
371 ok(hfdi ==
NULL,
"Expected NULL context, got %p\n", hfdi);
373 "Expected FDIERROR_ALLOC_FAIL, got %d\n",
erf.erfOper);
374 ok(
erf.fError ==
TRUE,
"Expected TRUE, got %d\n",
erf.fError);
377 ok(
erf.erfType == 0,
"Expected 0, got %d\n",
erf.erfType);
391 ok(hfdi !=
NULL,
"Expected non-NULL context\n");
468 BOOL fContinuation,
void *
pv)
477 DWORD dwShareMode = 0;
490 dwCreateDisposition, 0,
NULL);
504 ok(
res,
"Failed to ReadFile\n");
516 ok(
res,
"Failed to WriteFile\n");
543 ok(
ret,
"Failed to DeleteFile %s\n", pszFile);
555 if (tempname && (
strlen(tempname) < (
unsigned)cbTempName))
582 ok(
res,
"Expected GetFileInformationByHandle to succeed\n");
607 ok(
res,
"Expected FCIAddFile to succeed\n");
616 pCabParams->
setID = 0xbeef;
627 static CHAR a_txt[] =
"a.txt",
629 testdir_c_txt[] =
"testdir\\c.txt",
630 testdir_d_txt[] =
"testdir\\d.txt";
639 ok(hfci !=
NULL,
"Failed to create an FCI context\n");
647 ok(
res,
"Failed to flush the cabinet\n");
650 ok(
res,
"Failed to destroy the cabinet\n");
660 char temp[] =
"temp.txt";
661 char extract[] =
"extract.cab";
669 ok(hfdi !=
NULL,
"Expected non-NULL context\n");
679 "Expected ERROR_INVALID_HANDLE, got %d\n",
GetLastError());
684 ok(cabinfo.
setID == 0,
"Expected 0, got %d\n", cabinfo.
setID);
699 ok(cabinfo.
setID == 0,
"Expected 0, got %d\n", cabinfo.
setID);
713 ok(cabinfo.
setID == 0xbeef,
"Expected 0xbeef, got %d\n", cabinfo.
setID);
723 ok(hfdi !=
NULL,
"Expected non-NULL context\n");
734 ok(cabinfo.
setID == 0xbeef,
"Expected 0xbeef, got %d\n", cabinfo.
setID);
752 static const char expected[] =
"memory\\block";
756 ok(oflag ==
_O_BINARY,
"expected _O_BINARY, got %x\n", oflag);
760 if (!
data)
return -1;
766 trace(
"mem_open(%s,%x,%x) => %p\n",
name, oflag, pmode,
data);
779 data->pos += cb_read;
787 static const char expected[12] =
"Hello World!";
789 trace(
"mem_write(%#lx,%p,%u)\n", hf,
pv,
cb);
791 ok(hf == 0x12345678,
"expected 0x12345678, got %#lx\n", hf);
792 ok(
cb == 12,
"expected 12, got %u\n",
cb);
820 ok(0,
"seek: not expected type %d\n", seektype);
833 static const char expected[9] =
"file.dat\0";
838 trace(
"mem_notify: CLOSE_FILE_INFO %s, handle %#lx\n",
info->psz1,
info->hf);
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);
849 trace(
"mem_notify: COPY_FILE %s, %d bytes\n",
info->psz1,
info->cb);
851 ok(
info->cb == 12,
"expected 12, got %u\n",
info->cb);
853 ok(
info->iFolder == 0x1234,
"expected 0x1234, got %#x\n",
info->iFolder);
858 trace(
"mem_notify(%d,%p)\n", fdint,
info);
872 char name[] =
"extract.cab";
874 char memory_block[] =
"memory\\block";
875 char memory[] =
"memory\\";
876 char block[] =
"block";
887 ok(
ret,
"Failed to flush the cabinet\n");
904 "Expected ERROR_INVALID_HANDLE, got %d\n",
GetLastError());
909 skip(
"Running on a root drive directory.\n");
930 ok(hfdi !=
NULL,
"FDICreate error %d\n",
erf.erfOper);
933 ok(
fd != -1,
"fdi_open failed\n");
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);
947 ok(
ret,
"FDICopy error %d\n",
erf.erfOper);
static unsigned int block
static INT_PTR CDECL fdi_open_static(char *pszFile, int oflag, int pmode)
BOOL WINAPI WriteFile(IN HANDLE hFile, IN LPCVOID lpBuffer, IN DWORD nNumberOfBytesToWrite OPTIONAL, OUT LPDWORD lpNumberOfBytesWritten, IN LPOVERLAPPED lpOverlapped OPTIONAL)
BOOL __cdecl FDIDestroy(HFDI hfdi)
static UINT CDECL fdi_write(INT_PTR hf, void *pv, UINT cb)
static BOOL CDECL get_temp_file(char *pszTempName, int cbTempName, void *pv)
namespace GUID const ADDRINFOEXW ADDRINFOEXW struct timeval OVERLAPPED LPLOOKUPSERVICE_COMPLETION_ROUTINE HANDLE * handle
#define INVALID_SET_FILE_POINTER
static void test_FDIIsCabinet(void)
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
BOOL __cdecl FCIFlushCabinet(HFCI hfci, BOOL fGetNextCab, PFNFCIGETNEXTCABINET pfnfcignc, PFNFCISTATUS pfnfcis)
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)
static CHAR CURR_DIR[MAX_PATH]
ActualNumberDriverObjects * sizeof(PDRIVER_OBJECT)) PDRIVER_OBJECT *DriverObjectList
static INT_PTR __cdecl CopyProgress(FDINOTIFICATIONTYPE fdint, PFDINOTIFICATION pfdin)
static void CDECL fdi_free(void *pv)
ACPI_SIZE strlen(const char *String)
static UINT CDECL fci_read(INT_PTR hf, void *memory, UINT cb, int *err, void *pv)
static INT_PTR CDECL fdi_open(char *pszFile, int oflag, int pmode)
static INT_PTR CDECL fdi_mem_notify(FDINOTIFICATIONTYPE fdint, FDINOTIFICATION *info)
#define ERROR_INVALID_HANDLE
BOOL __cdecl FCIDestroy(HFCI hfci)
static void add_file(HFCI hfci, char *file)
#define INVALID_HANDLE_VALUE
DWORD WINAPI GetLastError(VOID)
static void test_FDICreate(void)
static UINT CDECL fdi_read_static(INT_PTR hf, void *pv, UINT cb)
UCHAR szName[sizeof("file.dat")]
static UINT CDECL fdi_mem_write(INT_PTR hf, void *pv, UINT cb)
BOOL WINAPI FileTimeToLocalFileTime(IN CONST FILETIME *lpFileTime, OUT LPFILETIME lpLocalFileTime)
static char memory[1024 *256]
BOOL extract(char *filename, const bin_file *bin)
static void test_FDICopy(void)
static void create_cab_file(void)
DWORD WINAPI DECLSPEC_HOTPATCH SetFilePointer(HANDLE hFile, LONG lDistanceToMove, PLONG lpDistanceToMoveHigh, DWORD dwMoveMethod)
static int CDECL fci_delete(char *pszFile, int *err, void *pv)
DWORD WINAPI GetFileAttributesA(LPCSTR lpFileName)
BOOL __cdecl FDICopy(HFDI hfdi, char *pszCabinet, char *pszCabPath, int flags, PFNFDINOTIFY pfnfdin, PFNFDIDECRYPT pfnfdid, void *pvUser)
char szCab[CB_MAX_CABINET_NAME]
static LONG CDECL fdi_seek_static(INT_PTR hf, LONG dist, int seektype)
static UINT CDECL fci_write(INT_PTR hf, void *memory, UINT cb, int *err, void *pv)
BOOL WINAPI CreateDirectoryA(IN LPCSTR lpPathName, IN LPSECURITY_ATTRIBUTES lpSecurityAttributes)
static WCHAR available[MAX_STRING_RESOURCE_LEN]
static void test_FDIDestroy(void)
BOOL WINAPI DeleteFileA(IN LPCSTR lpFileName)
HFDI __cdecl FDICreate(PFNALLOC pfnalloc, PFNFREE pfnfree, PFNOPEN pfnopen, PFNREAD pfnread, PFNWRITE pfnwrite, PFNCLOSE pfnclose, PFNSEEK pfnseek, int cpuType, PERF perf)
static BOOL CDECL get_next_cabinet(PCCAB pccab, ULONG cbPrevCab, void *pv)
UCHAR ab[sizeof("Hello World!") -1]
static void createTestFile(const CHAR *name)
static int CDECL fdi_mem_close(INT_PTR hf)
LPSTR WINAPI lstrcatA(LPSTR lpString1, LPCSTR lpString2)
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
static UINT CDECL fdi_mem_read(INT_PTR hf, void *pv, UINT cb)
BOOL WINAPI GetFileInformationByHandle(HANDLE hFile, LPBY_HANDLE_FILE_INFORMATION lpFileInformation)
static UINT CDECL fdi_write_static(INT_PTR hf, void *pv, UINT cb)
static int CDECL fdi_close(INT_PTR hf)
double __cdecl erf(double)
static LONG CDECL progress(UINT typeStatus, ULONG cb1, ULONG cb2, void *pv)
#define INVALID_FILE_ATTRIBUTES
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
LPSTR WINAPI lstrcpyA(LPSTR lpString1, LPCSTR lpString2)
static INT_PTR CDECL fdi_mem_open(char *name, int oflag, int pmode)
#define FILE_ATTRIBUTE_NORMAL
#define memcpy(s1, s2, n)
static LONG CDECL fdi_mem_seek(INT_PTR hf, LONG dist, int seektype)
static UINT CDECL fdi_read(INT_PTR hf, void *pv, UINT cb)
static void delete_test_files(void)
static void *CDECL mem_alloc(ULONG cb)
BOOL WINAPI FileTimeToDosDateTime(IN CONST FILETIME *lpFileTime, OUT LPWORD lpFatDate, OUT LPWORD lpFatTime)
int WINAPI lstrlenA(LPCSTR lpString)
static LONG CDECL fci_seek(INT_PTR hf, LONG dist, int seektype, int *err, void *pv)
#define FILE_FLAG_SEQUENTIAL_SCAN
DWORD WINAPI GetCurrentDirectoryA(IN DWORD nBufferLength, OUT LPSTR lpBuffer)
BOOL WINAPI RemoveDirectoryA(IN LPCSTR lpPathName)
static void CDECL mem_free(void *memory)
BOOL __cdecl FCIAddFile(HFCI hfci, char *pszSourceFile, char *pszFileName, BOOL fExecute, PFNFCIGETNEXTCABINET pfnfcignc, PFNFCISTATUS pfnfcis, PFNFCIGETOPENINFO pfnfcigoi, TCOMP typeCompress)
static void create_test_files(void)
static int CDECL file_placed(PCCAB pccab, char *pszFile, LONG cbFile, BOOL fContinuation, void *pv)
static INT_PTR static_fdi_handle
char szCabPath[CB_MAX_CAB_PATH]
int strcmp(const char *String1, const char *String2)
BOOL __cdecl FDIIsCabinet(HFDI hfdi, INT_PTR hf, PFDICABINETINFO pfdici)
static INT_PTR CDECL fci_open(char *pszFile, int oflag, int pmode, int *err, void *pv)
static LONG CDECL fdi_seek(INT_PTR hf, LONG dist, int seektype)
static int CDECL fci_close(INT_PTR hf, int *err, void *pv)
static int CDECL fdi_close_static(INT_PTR hf)
#define CreateFileA(a, b, c, d, e, f, g)
static INT_PTR CDECL get_open_info(char *pszName, USHORT *pdate, USHORT *ptime, USHORT *pattribs, int *err, void *pv)
static const struct @1574 cab_data
static void *CDECL fdi_alloc_bad(ULONG cb)
BOOL WINAPI ReadFile(IN HANDLE hFile, IN LPVOID lpBuffer, IN DWORD nNumberOfBytesToRead, OUT LPDWORD lpNumberOfBytesRead OPTIONAL, IN LPOVERLAPPED lpOverlapped OPTIONAL)
UINT WINAPI GetTempFileNameA(IN LPCSTR lpPathName, IN LPCSTR lpPrefixString, IN UINT uUnique, OUT LPSTR lpTempFileName)
#define HeapFree(x, y, z)
static void set_cab_parameters(PCCAB pCabParams)
static void *CDECL fdi_alloc(ULONG cb)