2002-12-19 22:16:56 +01:00
|
|
|
/*
|
|
|
|
* cabinet.dll main
|
|
|
|
*
|
|
|
|
* Copyright 2002 Patrik Stridvall
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
*/
|
2003-09-06 01:08:26 +02:00
|
|
|
|
2002-12-19 22:16:56 +01:00
|
|
|
#include "config.h"
|
|
|
|
|
2003-09-06 01:08:26 +02:00
|
|
|
#include <assert.h>
|
|
|
|
#include <stdarg.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
2002-12-19 22:16:56 +01:00
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
|
|
|
#include "winerror.h"
|
|
|
|
#define NO_SHLWAPI_REG
|
|
|
|
#include "shlwapi.h"
|
|
|
|
#undef NO_SHLWAPI_REG
|
|
|
|
|
|
|
|
#include "cabinet.h"
|
|
|
|
|
|
|
|
#include "wine/debug.h"
|
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(cabinet);
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* DllGetVersion (CABINET.2)
|
|
|
|
*
|
|
|
|
* Retrieves version information of the 'CABINET.DLL'
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* pdvi [O] pointer to version information structure.
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Success: S_OK
|
|
|
|
* Failure: E_INVALIDARG
|
|
|
|
*
|
|
|
|
* NOTES
|
|
|
|
* Supposedly returns version from IE6SP1RP1
|
|
|
|
*/
|
2005-08-08 19:35:28 +02:00
|
|
|
HRESULT WINAPI DllGetVersion (DLLVERSIONINFO *pdvi)
|
2002-12-19 22:16:56 +01:00
|
|
|
{
|
|
|
|
WARN("hmmm... not right version number \"5.1.1106.1\"?\n");
|
|
|
|
|
|
|
|
if (pdvi->cbSize != sizeof(DLLVERSIONINFO)) return E_INVALIDARG;
|
|
|
|
|
|
|
|
pdvi->dwMajorVersion = 5;
|
|
|
|
pdvi->dwMinorVersion = 1;
|
|
|
|
pdvi->dwBuildNumber = 1106;
|
|
|
|
pdvi->dwPlatformID = 1;
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* Extract (CABINET.3)
|
|
|
|
*
|
|
|
|
* Apparently an undocumented function, presumably to extract a CAB file
|
|
|
|
* to somewhere...
|
|
|
|
*
|
|
|
|
* PARAMS
|
2003-12-30 22:55:52 +01:00
|
|
|
* dest pointer to a buffer of 0x32c bytes containing
|
|
|
|
* [I] - number with value 1 at index 0x18
|
|
|
|
* - the dest path starting at index 0x1c
|
2004-01-08 01:42:36 +01:00
|
|
|
* [O] - a linked list with the filename existing inside the
|
|
|
|
* CAB file at idx 0x10
|
|
|
|
* - the number of files inside the CAB file at index 0x14
|
|
|
|
* - the name of the last file with dest path at idx 0x120
|
2002-12-19 22:16:56 +01:00
|
|
|
* what [I] char* describing what to uncompress, I guess.
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Success: S_OK
|
|
|
|
* Failure: E_OUTOFMEMORY (?)
|
|
|
|
*/
|
2003-12-30 22:55:52 +01:00
|
|
|
HRESULT WINAPI Extract(EXTRACTdest *dest, LPCSTR what)
|
2002-12-19 22:16:56 +01:00
|
|
|
{
|
2003-12-30 22:55:52 +01:00
|
|
|
#define DUMPC(idx) idx >= sizeof(EXTRACTdest) ? ' ' : \
|
2005-06-07 22:06:39 +02:00
|
|
|
((unsigned char*) dest)[idx] >= 0x20 ? \
|
|
|
|
((unsigned char*) dest)[idx] : '.'
|
2002-12-19 22:16:56 +01:00
|
|
|
|
2005-06-07 22:06:39 +02:00
|
|
|
#define DUMPH(idx) idx >= sizeof(EXTRACTdest) ? 0x55 : ((unsigned char*) dest)[idx]
|
2002-12-19 22:16:56 +01:00
|
|
|
|
2003-12-30 22:55:52 +01:00
|
|
|
LPSTR dir;
|
2004-09-03 01:00:53 +02:00
|
|
|
unsigned int i;
|
2002-12-19 22:16:56 +01:00
|
|
|
|
2003-12-30 22:55:52 +01:00
|
|
|
TRACE("(dest == %0lx, what == %s)\n", (long) dest, debugstr_a(what));
|
2002-12-19 22:16:56 +01:00
|
|
|
|
2003-12-30 22:55:52 +01:00
|
|
|
if (!dest) {
|
|
|
|
/* win2k will crash here */
|
|
|
|
FIXME("called without valid parameter dest!\n");
|
|
|
|
return E_OUTOFMEMORY;
|
2002-12-19 22:16:56 +01:00
|
|
|
}
|
2003-12-30 22:55:52 +01:00
|
|
|
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;
|
|
|
|
lstrcpyA(dir, dest->directory);
|
|
|
|
dest->filecount=0;
|
2004-01-08 01:42:36 +01:00
|
|
|
dest->filelist = NULL;
|
2002-12-19 22:16:56 +01:00
|
|
|
|
|
|
|
TRACE("extracting to dir: %s\n", debugstr_a(dir));
|
|
|
|
|
|
|
|
/* FIXME: what to do on failure? */
|
2004-12-14 12:38:50 +01:00
|
|
|
if (!process_cabinet(what, dir, FALSE, FALSE, dest)) {
|
|
|
|
LocalFree(dir);
|
2002-12-19 22:16:56 +01:00
|
|
|
return E_OUTOFMEMORY;
|
2004-12-14 12:38:50 +01:00
|
|
|
}
|
2002-12-19 22:16:56 +01:00
|
|
|
|
|
|
|
LocalFree(dir);
|
|
|
|
|
2003-12-30 22:55:52 +01:00
|
|
|
TRACE("filecount %08lx,lastfile %s\n",
|
|
|
|
dest->filecount, debugstr_a(dest->lastfile));
|
|
|
|
|
2002-12-19 22:16:56 +01:00
|
|
|
return S_OK;
|
|
|
|
}
|