31 #define MEDIA_SIZE 999999999 32 #define FOLDER_THRESHOLD 900000 109 { {
'M',
'S',
'C',
'F'}, 0, 0x59, 0,
sizeof(
struct CFHEADER) +
sizeof(
struct CFFOLDER), 0, 3,1, 1, 1, 0, 0x1225, 0x2013 },
111 {
sizeof(
"Hello World!")-1, 0, 0x1234, 0x1225, 0x2013, 0xa114 },
112 {
'f',
'i',
'l',
'e',
'.',
'd',
'a',
't',0 },
113 { 0,
sizeof(
"Hello World!")-1,
sizeof(
"Hello World!")-1 },
114 {
'H',
'e',
'l',
'l',
'o',
' ',
'W',
'o',
'r',
'l',
'd',
'!' }
187 ok(0,
"FDIIsCabinet shouldn't call pfnopen\n");
193 ok(hf == 0,
"unexpected hf %lx\n", hf);
199 ok(0,
"FDIIsCabinet shouldn't call pfnwrite\n");
205 ok(0,
"FDIIsCabinet shouldn't call pfnclose\n");
211 ok(hf == 0,
"unexpected hf %lx\n", hf);
228 erf.erfOper = 0x1abe11ed;
229 erf.erfType = 0x5eed1e55;
230 erf.fError = 0x1ead1e55;
234 ok(hfdi !=
NULL,
"Expected non-NULL context\n");
237 ok(
erf.erfOper == 0x1abe11ed,
"Expected 0x1abe11ed, got %d\n",
erf.erfOper);
238 ok(
erf.erfType == 0x5eed1e55,
"Expected 0x5eed1e55, got %d\n",
erf.erfType);
239 ok(
erf.fError == 0x1ead1e55,
"Expected 0x1ead1e55, got %d\n",
erf.fError);
245 erf.erfOper = 0x1abe11ed;
246 erf.erfType = 0x5eed1e55;
247 erf.fError = 0x1ead1e55;
251 ok(hfdi !=
NULL,
"Expected non-NULL context\n");
254 ok((
erf.erfOper == 0x1abe11ed ||
erf.erfOper == 0 ),
"Expected 0x1abe11ed or 0, got %d\n",
erf.erfOper);
255 ok((
erf.erfType == 0x5eed1e55 ||
erf.erfType == 0 ),
"Expected 0x5eed1e55 or 0, got %d\n",
erf.erfType);
256 ok((
erf.fError == 0x1ead1e55 ||
erf.fError == 0 ),
"Expected 0x1ead1e55 or 0, got %d\n",
erf.fError);
261 erf.erfOper = 0x1abe11ed;
262 erf.erfType = 0x5eed1e55;
263 erf.fError = 0x1ead1e55;
267 ok(hfdi !=
NULL,
"Expected non-NULL context\n");
270 ok((
erf.erfOper == 0x1abe11ed ||
erf.erfOper == 0 ),
"Expected 0x1abe11ed or 0, got %d\n",
erf.erfOper);
271 ok((
erf.erfType == 0x5eed1e55 ||
erf.erfType == 0 ),
"Expected 0x5eed1e55 or 0, got %d\n",
erf.erfType);
272 ok((
erf.fError == 0x1ead1e55 ||
erf.fError == 0 ),
"Expected 0x1ead1e55 or 0, got %d\n",
erf.fError);
277 erf.erfOper = 0x1abe11ed;
278 erf.erfType = 0x5eed1e55;
279 erf.fError = 0x1ead1e55;
283 ok(hfdi !=
NULL,
"Expected non-NULL context\n");
286 ok((
erf.erfOper == 0x1abe11ed ||
erf.erfOper == 0 ),
"Expected 0x1abe11ed or 0, got %d\n",
erf.erfOper);
287 ok((
erf.erfType == 0x5eed1e55 ||
erf.erfType == 0 ),
"Expected 0x5eed1e55 or 0, got %d\n",
erf.erfType);
288 ok((
erf.fError == 0x1ead1e55 ||
erf.fError == 0 ),
"Expected 0x1ead1e55 or 0, got %d\n",
erf.fError);
293 erf.erfOper = 0x1abe11ed;
294 erf.erfType = 0x5eed1e55;
295 erf.fError = 0x1ead1e55;
299 ok(hfdi !=
NULL,
"Expected non-NULL context\n");
302 ok((
erf.erfOper == 0x1abe11ed ||
erf.erfOper == 0 ),
"Expected 0x1abe11ed or 0, got %d\n",
erf.erfOper);
303 ok((
erf.erfType == 0x5eed1e55 ||
erf.erfType == 0 ),
"Expected 0x5eed1e55 or 0, got %d\n",
erf.erfType);
304 ok((
erf.fError == 0x1ead1e55 ||
erf.fError == 0 ),
"Expected 0x1ead1e55 or 0, got %d\n",
erf.fError);
309 erf.erfOper = 0x1abe11ed;
310 erf.erfType = 0x5eed1e55;
311 erf.fError = 0x1ead1e55;
315 ok(hfdi !=
NULL,
"Expected non-NULL context\n");
318 ok((
erf.erfOper == 0x1abe11ed ||
erf.erfOper == 0 ),
"Expected 0x1abe11ed or 0, got %d\n",
erf.erfOper);
319 ok((
erf.erfType == 0x5eed1e55 ||
erf.erfType == 0 ),
"Expected 0x5eed1e55 or 0, got %d\n",
erf.erfType);
320 ok((
erf.fError == 0x1ead1e55 ||
erf.fError == 0 ),
"Expected 0x1ead1e55 or 0, got %d\n",
erf.fError);
325 erf.erfOper = 0x1abe11ed;
326 erf.erfType = 0x5eed1e55;
327 erf.fError = 0x1ead1e55;
340 erf.erfOper = 0x1abe11ed;
341 erf.erfType = 0x5eed1e55;
342 erf.fError = 0x1ead1e55;
346 ok(hfdi !=
NULL,
"Expected non-NULL context\n");
349 ok((
erf.erfOper == 0x1abe11ed ||
erf.erfOper == 0 ),
"Expected 0x1abe11ed or 0, got %d\n",
erf.erfOper);
350 ok((
erf.erfType == 0x5eed1e55 ||
erf.erfType == 0 ),
"Expected 0x5eed1e55 or 0, got %d\n",
erf.erfType);
351 ok((
erf.fError == 0x1ead1e55 ||
erf.fError == 0 ),
"Expected 0x1ead1e55 or 0, got %d\n",
erf.fError);
357 erf.erfOper = 0x1abe11ed;
358 erf.erfType = 0x5eed1e55;
359 erf.fError = 0x1ead1e55;
363 ok(hfdi ==
NULL,
"Expected NULL context, got %p\n", hfdi);
365 "Expected FDIERROR_ALLOC_FAIL, got %d\n",
erf.erfOper);
366 ok(
erf.fError ==
TRUE,
"Expected TRUE, got %d\n",
erf.fError);
369 ok(
erf.erfType == 0,
"Expected 0, got %d\n",
erf.erfType);
383 ok(hfdi !=
NULL,
"Expected non-NULL context\n");
460 BOOL fContinuation,
void *pv)
469 DWORD dwShareMode = 0;
482 dwCreateDisposition, 0,
NULL);
496 ok(
res,
"Failed to ReadFile\n");
508 ok(
res,
"Failed to WriteFile\n");
535 ok(
ret,
"Failed to DeleteFile %s\n", pszFile);
547 if (tempname && (
strlen(tempname) < (
unsigned)cbTempName))
574 ok(
res,
"Expected GetFileInformationByHandle to succeed\n");
599 ok(
res,
"Expected FCIAddFile to succeed\n");
608 pCabParams->
setID = 0xbeef;
619 static CHAR a_txt[] =
"a.txt",
621 testdir_c_txt[] =
"testdir\\c.txt",
622 testdir_d_txt[] =
"testdir\\d.txt";
631 ok(hfci !=
NULL,
"Failed to create an FCI context\n");
639 ok(
res,
"Failed to flush the cabinet\n");
642 ok(
res,
"Failed to destroy the cabinet\n");
652 char temp[] =
"temp.txt";
653 char extract[] =
"extract.cab";
661 ok(hfdi !=
NULL,
"Expected non-NULL context\n");
671 "Expected ERROR_INVALID_HANDLE, got %d\n",
GetLastError());
676 ok(cabinfo.
setID == 0,
"Expected 0, got %d\n", cabinfo.
setID);
691 ok(cabinfo.
setID == 0,
"Expected 0, got %d\n", cabinfo.
setID);
705 ok(cabinfo.
setID == 0xbeef,
"Expected 0xbeef, got %d\n", cabinfo.
setID);
715 ok(hfdi !=
NULL,
"Expected non-NULL context\n");
726 ok(cabinfo.
setID == 0xbeef,
"Expected 0xbeef, got %d\n", cabinfo.
setID);
744 static const char expected[] =
"memory\\block";
748 ok(oflag ==
_O_BINARY,
"expected _O_BINARY, got %x\n", oflag);
752 if (!
data)
return -1;
758 trace(
"mem_open(%s,%x,%x) => %p\n",
name, oflag, pmode,
data);
771 data->pos += cb_read;
779 static const char expected[] =
"Hello World!";
781 trace(
"mem_write(%#lx,%p,%u)\n", hf, pv,
cb);
783 ok(hf == 0x12345678,
"expected 0x12345678, got %#lx\n", hf);
784 ok(
cb == 12,
"expected 12, got %u\n",
cb);
812 ok(0,
"seek: not expected type %d\n", seektype);
825 static const char expected[9] =
"file.dat\0";
830 trace(
"mem_notify: CLOSE_FILE_INFO %s, handle %#lx\n",
info->psz1,
info->hf);
833 ok(
info->date == 0x1225,
"expected 0x1225, got %#x\n",
info->date);
834 ok(
info->time == 0x2013,
"expected 0x2013, got %#x\n",
info->time);
835 ok(
info->attribs == 0xa114,
"expected 0xa114, got %#x\n",
info->attribs);
836 ok(
info->iFolder == 0x1234,
"expected 0x1234, got %#x\n",
info->iFolder);
841 trace(
"mem_notify: COPY_FILE %s, %d bytes\n",
info->psz1,
info->cb);
843 ok(
info->cb == 12,
"expected 12, got %u\n",
info->cb);
845 ok(
info->iFolder == 0x1234,
"expected 0x1234, got %#x\n",
info->iFolder);
850 trace(
"mem_notify(%d,%p)\n", fdint,
info);
864 char name[] =
"extract.cab";
866 char memory_block[] =
"memory\\block";
867 char memory[] =
"memory\\";
868 char block[] =
"block";
879 ok(
ret,
"Failed to flush the cabinet\n");
896 "Expected ERROR_INVALID_HANDLE, got %d\n",
GetLastError());
901 skip(
"Running on a root drive directory.\n");
922 ok(hfdi !=
NULL,
"FDICreate error %d\n",
erf.erfOper);
925 ok(
fd != -1,
"fdi_open failed\n");
929 ok(
ret,
"FDIIsCabinet error %d\n",
erf.erfOper);
930 ok(
info.cbCabinet == 0x59,
"expected 0x59, got %#x\n",
info.cbCabinet);
931 ok(
info.cFiles == 1,
"expected 1, got %d\n",
info.cFiles);
932 ok(
info.cFolders == 1,
"expected 1, got %d\n",
info.cFolders);
933 ok(
info.setID == 0x1225,
"expected 0x1225, got %#x\n",
info.setID);
934 ok(
info.iCabinet == 0x2013,
"expected 0x2013, got %#x\n",
info.iCabinet);
939 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)
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)
static int CDECL fci_delete(char *pszFile, int *err, void *pv)
namespace GUID const ADDRINFOEXW ADDRINFOEXW struct timeval OVERLAPPED LPLOOKUPSERVICE_COMPLETION_ROUTINE HANDLE * handle
DWORD WINAPI GetFileAttributesA(LPCSTR lpFileName)
BOOL __cdecl FDICopy(HFDI hfdi, char *pszCabinet, char *pszCabPath, int flags, PFNFDINOTIFY pfnfdin, PFNFDIDECRYPT pfnfdid, void *pvUser)
static struct _test_info info[]
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)
static const struct @1600 cab_data
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)
#define INVALID_SET_FILE_POINTER
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)
#define ReadFile(a, b, c, d, e)
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 HMODULE MODULEINFO DWORD cb
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 void *CDECL fdi_alloc_bad(ULONG cb)
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)