Make use of/handle the first parameter of the function Extract.
This commit is contained in:
parent
1a620f29d2
commit
a0d658aeed
|
@ -29,6 +29,7 @@
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
#include "windef.h"
|
#include "windef.h"
|
||||||
|
@ -2553,12 +2554,13 @@ void print_fileinfo(struct cab_file *fi) {
|
||||||
* dir [I] directory to extract to
|
* dir [I] directory to extract to
|
||||||
* fix [I] attempt to process broken cabinets
|
* fix [I] attempt to process broken cabinets
|
||||||
* lower [I] ? (lower case something or other?)
|
* lower [I] ? (lower case something or other?)
|
||||||
|
* dest [O]
|
||||||
*
|
*
|
||||||
* RETURNS
|
* RETURNS
|
||||||
* Success: TRUE
|
* Success: TRUE
|
||||||
* Failure: FALSE
|
* Failure: FALSE
|
||||||
*/
|
*/
|
||||||
BOOL process_cabinet(LPCSTR cabname, LPCSTR dir, BOOL fix, BOOL lower)
|
BOOL process_cabinet(LPCSTR cabname, LPCSTR dir, BOOL fix, BOOL lower, EXTRACTdest *dest)
|
||||||
{
|
{
|
||||||
struct cabinet *basecab, *cab, *cab1, *cab2;
|
struct cabinet *basecab, *cab, *cab1, *cab2;
|
||||||
struct cab_file *filelist, *fi;
|
struct cab_file *filelist, *fi;
|
||||||
|
@ -2618,12 +2620,18 @@ BOOL process_cabinet(LPCSTR cabname, LPCSTR dir, BOOL fix, BOOL lower)
|
||||||
TRACE("----------+---------------------+-------------\n");
|
TRACE("----------+---------------------+-------------\n");
|
||||||
viewhdr = 1;
|
viewhdr = 1;
|
||||||
}
|
}
|
||||||
for (fi = filelist; fi; fi = fi->next)
|
for (fi = filelist; fi; fi = fi->next) {
|
||||||
print_fileinfo(fi);
|
print_fileinfo(fi);
|
||||||
|
dest->filecount++;
|
||||||
|
}
|
||||||
TRACE("Beginning Extraction...\n");
|
TRACE("Beginning Extraction...\n");
|
||||||
for (fi = filelist; fi; fi = fi->next) {
|
for (fi = filelist; fi; fi = fi->next) {
|
||||||
TRACE(" extracting: %s\n", debugstr_a(fi->filename));
|
TRACE(" extracting: %s\n", debugstr_a(fi->filename));
|
||||||
extract_file(fi, lower, fix, dir, decomp_state);
|
extract_file(fi, lower, fix, dir, decomp_state);
|
||||||
|
sprintf(dest->lastfile, "%s%s%s",
|
||||||
|
strlen(dest->directory) ? dest->directory : "",
|
||||||
|
strlen(dest->directory) ? "\\": "",
|
||||||
|
fi->filename);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -553,8 +553,20 @@ static const cab_UWORD Zipmask[17] = {
|
||||||
0x01ff, 0x03ff, 0x07ff, 0x0fff, 0x1fff, 0x3fff, 0x7fff, 0xffff \
|
0x01ff, 0x03ff, 0x07ff, 0x0fff, 0x1fff, 0x3fff, 0x7fff, 0xffff \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* the first parameter of the function extract */
|
||||||
|
typedef struct {
|
||||||
|
long result1; /* 0x000 */
|
||||||
|
long unknown1[3]; /* 0x004 */
|
||||||
|
long result2; /* 0x010 */
|
||||||
|
long filecount; /* 0x014 */
|
||||||
|
long unknown2; /* 0x018 */
|
||||||
|
char directory[0x104]; /* 0x01c */
|
||||||
|
char lastfile[0x20c]; /* 0x120 */
|
||||||
|
} EXTRACTdest;
|
||||||
|
|
||||||
|
|
||||||
/* from cabextract.c */
|
/* from cabextract.c */
|
||||||
BOOL process_cabinet(LPCSTR cabname, LPCSTR dir, BOOL fix, BOOL lower);
|
BOOL process_cabinet(LPCSTR cabname, LPCSTR dir, BOOL fix, BOOL lower, EXTRACTdest *dest);
|
||||||
void QTMupdatemodel(struct QTMmodel *model, int sym);
|
void QTMupdatemodel(struct QTMmodel *model, int sym);
|
||||||
int make_decode_table(cab_ULONG nsyms, cab_ULONG nbits, cab_UBYTE *length, cab_UWORD *table);
|
int make_decode_table(cab_ULONG nsyms, cab_ULONG nbits, cab_UBYTE *length, cab_UWORD *table);
|
||||||
cab_ULONG checksum(cab_UBYTE *data, cab_UWORD bytes, cab_ULONG csum);
|
cab_ULONG checksum(cab_UBYTE *data, cab_UWORD bytes, cab_ULONG csum);
|
||||||
|
|
|
@ -73,60 +73,66 @@ HRESULT WINAPI CABINET_DllGetVersion (DLLVERSIONINFO *pdvi)
|
||||||
* to somewhere...
|
* to somewhere...
|
||||||
*
|
*
|
||||||
* PARAMS
|
* PARAMS
|
||||||
* unknown [IO] unknown pointer
|
* dest pointer to a buffer of 0x32c bytes containing
|
||||||
|
* [I] - number with value 1 at index 0x18
|
||||||
|
* - the dest path starting at index 0x1c
|
||||||
|
* [O] - the number of files inside the CAB file at index 0x14
|
||||||
|
* - the name of the last file with dest path at idx 0x12
|
||||||
* what [I] char* describing what to uncompress, I guess.
|
* what [I] char* describing what to uncompress, I guess.
|
||||||
*
|
*
|
||||||
* RETURNS
|
* RETURNS
|
||||||
* Success: S_OK
|
* Success: S_OK
|
||||||
* Failure: E_OUTOFMEMORY (?)
|
* Failure: E_OUTOFMEMORY (?)
|
||||||
*/
|
*/
|
||||||
HRESULT WINAPI Extract(DWORD unknown, LPCSTR what)
|
HRESULT WINAPI Extract(EXTRACTdest *dest, LPCSTR what)
|
||||||
{
|
{
|
||||||
LPCSTR whatx;
|
#define DUMPC(idx) idx >= sizeof(EXTRACTdest) ? ' ' : \
|
||||||
LPSTR dir, dirx, lastoption, x;
|
ptr[idx] >= 0x20 ? ptr[idx] : '.'
|
||||||
BOOL updatelastoption;
|
|
||||||
|
|
||||||
TRACE("(unknown == %0lx, what == %s)\n", unknown, debugstr_a(what));
|
#define DUMPH(idx) idx >= sizeof(EXTRACTdest) ? 0x55 : ptr[idx]
|
||||||
|
|
||||||
dir = LocalAlloc(LPTR, strlen(what));
|
LPSTR dir;
|
||||||
|
unsigned char *ptr = (unsigned char*) dest;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
TRACE("(dest == %0lx, what == %s)\n", (long) dest, debugstr_a(what));
|
||||||
|
|
||||||
|
if (!dest) {
|
||||||
|
/* win2k will crash here */
|
||||||
|
FIXME("called without valid parameter dest!\n");
|
||||||
|
return E_OUTOFMEMORY;
|
||||||
|
}
|
||||||
|
for (i=0; i < sizeof(EXTRACTdest); i+=8)
|
||||||
|
TRACE( "dest[%04x]:%02x %02x %02x %02x %02x %02x %02x %02x %c%c%c%c%c%c%c%c\n",
|
||||||
|
i,
|
||||||
|
DUMPH(i+0), DUMPH(i+1), DUMPH(i+2), DUMPH(i+3),
|
||||||
|
DUMPH(i+4), DUMPH(i+5), DUMPH(i+6), DUMPH(i+7),
|
||||||
|
DUMPC(i+0), DUMPC(i+1), DUMPC(i+2), DUMPC(i+3),
|
||||||
|
DUMPC(i+4), DUMPC(i+5), DUMPC(i+6), DUMPC(i+7));
|
||||||
|
|
||||||
|
dir = LocalAlloc(LPTR, strlen(dest->directory)+1);
|
||||||
if (!dir) return E_OUTOFMEMORY;
|
if (!dir) return E_OUTOFMEMORY;
|
||||||
|
lstrcpyA(dir, dest->directory);
|
||||||
/* copy the filename up to the last pathsep to construct the dirname */
|
dest->filecount=0;
|
||||||
whatx = what;
|
|
||||||
dirx = dir;
|
|
||||||
lastoption = NULL;
|
|
||||||
while (*whatx) {
|
|
||||||
if ((*whatx == '\\') || (*whatx == '/')) {
|
|
||||||
/* unless all chars between *dirx and lastoption are pathsep's, we
|
|
||||||
remember our location in dir as lastoption */
|
|
||||||
if (lastoption) {
|
|
||||||
updatelastoption = FALSE;
|
|
||||||
for (x = lastoption; x < dirx; x++)
|
|
||||||
if ((*dirx != '\\') && (*dirx != '/')) {
|
|
||||||
updatelastoption = TRUE;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (updatelastoption) lastoption = dirx;
|
|
||||||
} else
|
|
||||||
lastoption = dirx;
|
|
||||||
}
|
|
||||||
*dirx++ = *whatx++;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!lastoption) {
|
|
||||||
/* FIXME: I guess use the cwd or something? */
|
|
||||||
assert(FALSE);
|
|
||||||
} else {
|
|
||||||
*lastoption = '\0';
|
|
||||||
}
|
|
||||||
|
|
||||||
TRACE("extracting to dir: %s\n", debugstr_a(dir));
|
TRACE("extracting to dir: %s\n", debugstr_a(dir));
|
||||||
|
|
||||||
/* FIXME: what to do on failure? */
|
/* FIXME: what to do on failure? */
|
||||||
if (!process_cabinet(what, dir, FALSE, FALSE))
|
if (!process_cabinet(what, dir, FALSE, FALSE, dest))
|
||||||
return E_OUTOFMEMORY;
|
return E_OUTOFMEMORY;
|
||||||
|
|
||||||
|
/* the magic 13 is returned by all cab files tested so far:
|
||||||
|
* DXDDEX.CAB, DXMINI.CAB, SWFLASH.CAB on win2k
|
||||||
|
* but it crashes the ie5.5 installer :-( . The native dll does not return
|
||||||
|
* the four zeros. The value depends on the combination of the cab file and
|
||||||
|
* the destination path
|
||||||
|
*/
|
||||||
|
dest->result2=0x130000;
|
||||||
|
|
||||||
LocalFree(dir);
|
LocalFree(dir);
|
||||||
|
|
||||||
|
TRACE("filecount %08lx,lastfile %s\n",
|
||||||
|
dest->filecount, debugstr_a(dest->lastfile));
|
||||||
|
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue