Microsoft company .CAB file format

zhaozj2021-02-08  207

Microsoft company .CAB file format

_INSIDE Windows Cabinet Files_Listing One // ============================================ ============================================================================================================================================================================================================ ===================================================== / * (1) CAB_HEADER structure (2) Reserved area, if CAB_HEADER.flags & CAB_FLAG_RESERVE (3) Previous cabinet name, if CAB_HEADER.flags & CAB_FLAG_HASPREV (4) Previous disk name, if CAB_HEADER.flags & CAB_FLAG_HASPREV (5) Next cabinet name, if CAB_HEADER.flags & CAB_FLAG_HASNEXT (6) Next disk name, if CAB_HEADER.flags & CAB_FLAG_HASNEXT (7) CAB_FOLDER structures (n = CAB_HEADER.cFolders) (8) CAB_ENTRY structures / file names (n = CAB_HEADER.cFiles) (9) File data (offset = Cab_folder.coffcabstart * /

/ / =========================================================================================================================================================================================== ================= // macros // =============================== ===================================== # Define swapword (x) ((Word) ((Word) x) << 8) | ((x) >> 8)) #DEFINE SWAPDWORD ((SwapWord (Word)) << 16) | / (SwapWord ((×) >> 16)))))))))))))) / / ============================================= ==================================================== ============================================ # define cab_signature swapdword (' MSCF ') # Define Cab_version 0x0103

#define cab_flag_haasprev 0x0001 # define cab_flag_hasnext 0x0002 # define cab_flag_reserve 0x0004

#define CAB_ATTRIB_READONLY 0x0001 # define CAB_ATTRIB_HIDDEN 0x0002 # define CAB_ATTRIB_SYSTEM 0x0004 # define CAB_ATTRIB_VOLUME 0x0008 # define CAB_ATTRIB_DIRECTORY 0x0010 # define CAB_ATTRIB_ARCHIVE 0x0020 # define CAB_FILE_FIRST 0x0000 # define CAB_FILE_NEXT 0x0001 # define CAB_FILE_SPLIT 0xFFFE # define CAB_FILE_CONTINUED 0xFFFD

#define cab_notify_ok 1 # define cab_notify_error 0 # define CAB_NOTIFY_SKIP 0 # Define Cab_notify_abort (-1)

/ / =========================================================================================================================================================================================== ================= // Cabinet structures // ================================================================================================================================= =============================================================== {dword Sig; // File Signature ' MSCF '(CAB_SIGNATURE) DWORD csumHeader; // header checksum (0 if not used) DWORD cbCabinet; // cabinet file size DWORD csumFolders; // folders checksum (0 if not used) DWORD coffFiles; // offset of first CAB_ENTRY DWORD csumFiles ; // files checksum (0 if not used) Word version; // Cabinet Version (CAB_VERSION) WORDERS; // Number of Folders Word cfiles; // Number of Files Word Flags; // Cabinet Flags (CAB_FLAG_ *) Word SETID ; // Cabinet set ID word iCabinet; // Zero-based Cabinet Number} Cab_header, * PCAB_HEADER; #define Cab_Header_ Sizeof (Cab_Header) / / ------------------- ---------------------------------------------- T YpedEf struct _cab_folder {dword CoffCabStart; // offset of folder data word ccfdata; // ??? word typecompress; // compression type (tcomp * in fdi.h)

} Cab_folder, * pcab_folder; #define cab_folder_ sizeof (cab_folder) // --------------------------------- --------------------------------------------------------------------------------------------------------------------------------------- Decompression Word Ifolder; // File Control ID (CAB_FILE_ *) Word Date; // File Date Stamp, As Used by Dos Word Time; // File Time Stamp, As Used by DOS Word Attribs; // File Attributes (CAB_ATTRIB_ *) }} CAB_ENTRY, * PCAB_ENTRY; #define CAB_ENTRY_ SIZEOF (CAB_ENTRY)

Listing TWO / / ================================================ =================== // file extraction callback // ======================== ================================================== int Diamondapi FDIEXTRACT (FDINOTIFICTIONTYPE FDINT, PFDINOTIFICATION PFDIN ) {Filetime ft, lft; byte abfile [max_path]; int hf, IRESULT;

Switch (fdint) {copy fdintcopy_file: if (PFDIN-> PSZ1, ((pEXTRACT_FILE) PFDIN-> PV) -> pBENTRY)) {IRESULT = CAB_NOTIFY_SKIP;} else {hf = fdiopen (((pextract_file) pfdin-> PV) -> pbfile, _o_rdwr | _o_creat | _o_trunc, _s_iread | _s_iWrite); if (hf! = -1) {IRESULT = HF;} else {printfMessage ((pextract_file) PFDIN-> PV) -> hWnd, MB_ICONERROR | MB_OK, "Cablib Error", "Unable to create file /"% s / ", ((pextract_file) pfdin-> pv) -> pbfile); IRESULT = CAB_NOTIFY_ABORT

}}}} Break; Case FDINTNEXT_CABINET: IF (lstrlen (pfdin-> psz3) lstrlen (pfdin-> psz1) psz3); lstrcat (abfile, pfdin-> psz1); HF = FDIOPEN (abfile, _o_rdonly, 0);} else {hf = -1;} if (hf! = -1) {fdiclose (hf); IRESULT = CAB_NOTIFY_OK;} else {printfMessage ((bextract_file) PFDIN-> PV) -> HWND, MB_ICONERROR | MB_OK, "Cablib Error", "Unable to open file /"% s% s / ", pfdin-> psz3, pfdin-> psz1); IRESULT = CAB_NOTIFY_ABORT;} Break; Case FdintClose_File_info: DosdateTimetOfiletime (pfdin-> date, pfdin-> time, & lft); LocalFileTimetofiletime (& lft, & ft); setFiletime ((Handle) PFDIN-> HF, & ft, & ft, & ft);

IF (FDICLOSE (PFDIN-> HF) == -1) {PrintFMessage ((pextract_file) pfdin-> pv) -> hWnd, MB_ICONEROR | MB_OK, "Cablib Error", "Unable to Close File /"% s / " ", ((PEXTRACT_FILE) pfdin-> pv) -> pbFile);} iResult = CAB_NOTIFY_OK; break; default: iResult = CAB_NOTIFY_OK; break;} return iResult;} Example 1: HFDI FAR DIAMONDAPI FDICreate (pFNALLOC pfnalloc, pFNFREE pfnfree, Pfnopen Pfnopen, PfnRead Pfnread, PfnWrite PfnWrite, PfnClose PfnClose, PfNSeek Pfnseek, Int CPutype, Perf Perf;

Example 2: Bool Far Diamondapi Fdicopy (HFDI HFDI, Char Far * Pszcabinet, Char Far * pszcabpath, int flags, pfnfdinotify pfnfdin, pfdidecrypt pfnfdid, void far * pvuser;

4

转载请注明原文地址:https://www.9cbs.com/read-3251.html

New Post(0)