2 * Setupapi cabinet routines
4 * Copyright 2003 Gregory M. Turner
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 * Many useful traces are commented in code, uncomment them if you have
22 * trouble and run with WINEDEBUG=+setupapi
37 #include "setupapi_private.h"
39 #include "wine/unicode.h"
40 #include "wine/debug.h"
46 #define _O_ACCMODE (_O_RDONLY|_O_WRONLY|_O_RDWR)
47 #define _O_APPEND 0x0008
48 #define _O_RANDOM 0x0010
49 #define _O_SEQUENTIAL 0x0020
50 #define _O_TEMPORARY 0x0040
51 #define _O_NOINHERIT 0x0080
52 #define _O_CREAT 0x0100
53 #define _O_TRUNC 0x0200
54 #define _O_EXCL 0x0400
55 #define _O_SHORT_LIVED 0x1000
56 #define _O_TEXT 0x4000
57 #define _O_BINARY 0x8000
59 #define _SH_COMPAT 0x00
60 #define _SH_DENYRW 0x10
61 #define _SH_DENYWR 0x20
62 #define _SH_DENYRD 0x30
63 #define _SH_DENYNO 0x40
65 OSVERSIONINFOW OsVersionInfo;
67 static HINSTANCE CABINET_hInstance = 0;
69 static HFDI (__cdecl *sc_FDICreate)(PFNALLOC, PFNFREE, PFNOPEN,
70 PFNREAD, PFNWRITE, PFNCLOSE, PFNSEEK, int, PERF);
72 static BOOL (__cdecl *sc_FDICopy)(HFDI, char *, char *, int,
73 PFNFDINOTIFY, PFNFDIDECRYPT, void *);
75 static BOOL (__cdecl *sc_FDIDestroy)(HFDI);
77 #define SC_HSC_A_MAGIC 0xACABFEED
81 PSP_FILE_CALLBACK_A msghandler;
83 CHAR most_recent_cabinet_name[MAX_PATH];
84 } SC_HSC_A, *PSC_HSC_A;
86 #define SC_HSC_W_MAGIC 0x0CABFEED
90 PSP_FILE_CALLBACK_W msghandler;
92 WCHAR most_recent_cabinet_name[MAX_PATH];
93 } SC_HSC_W, *PSC_HSC_W;
95 WINE_DEFAULT_DEBUG_CHANNEL(setupapi);
97 static BOOL LoadCABINETDll(void)
99 if (!CABINET_hInstance) {
100 CABINET_hInstance = LoadLibraryA("cabinet.dll");
101 if (CABINET_hInstance) {
102 sc_FDICreate = (void *)GetProcAddress(CABINET_hInstance, "FDICreate");
103 sc_FDICopy = (void *)GetProcAddress(CABINET_hInstance, "FDICopy");
104 sc_FDIDestroy = (void *)GetProcAddress(CABINET_hInstance, "FDIDestroy");
107 ERR("load cabinet dll failed.\n");
114 static void UnloadCABINETDll(void)
116 if (CABINET_hInstance) {
117 FreeLibrary(CABINET_hInstance);
118 CABINET_hInstance = 0;
122 /* FDICreate callbacks */
124 static void * CDECL sc_cb_alloc(ULONG cb)
126 return HeapAlloc(GetProcessHeap(), 0, cb);
129 static void CDECL sc_cb_free(void *pv)
131 HeapFree(GetProcessHeap(), 0, pv);
134 static INT_PTR CDECL sc_cb_open(char *pszFile, int oflag, int pmode)
136 DWORD creation = 0, sharing = 0;
139 SECURITY_ATTRIBUTES sa;
141 /* TRACE("(pszFile == %s, oflag == %d, pmode == %d)\n", debugstr_a(pszFile), oflag, pmode); */
143 switch(oflag & (_O_RDONLY | _O_WRONLY | _O_RDWR)) {
145 ioflag |= GENERIC_READ;
148 ioflag |= GENERIC_WRITE;
151 ioflag |= GENERIC_READ & GENERIC_WRITE;
153 case _O_WRONLY | _O_RDWR: /* hmmm.. */
154 ERR("_O_WRONLY & _O_RDWR in oflag?\n");
158 if (oflag & _O_CREAT) {
160 creation = CREATE_NEW;
161 else if (oflag & _O_TRUNC)
162 creation = CREATE_ALWAYS;
164 creation = OPEN_ALWAYS;
165 } else /* no _O_CREAT */ {
166 if (oflag & _O_TRUNC)
167 creation = TRUNCATE_EXISTING;
169 creation = OPEN_EXISTING;
172 switch( pmode & 0x70 ) {
177 sharing = FILE_SHARE_READ;
180 sharing = FILE_SHARE_WRITE;
184 sharing = FILE_SHARE_READ | FILE_SHARE_WRITE;
187 ERR("<-- -1 (Unhandled pmode 0x%x)\n", pmode);
191 if (oflag & ~(_O_BINARY | _O_TRUNC | _O_EXCL | _O_CREAT | _O_RDWR | _O_WRONLY | _O_NOINHERIT))
192 WARN("unsupported oflag 0x%04x\n",oflag);
194 sa.nLength = sizeof( SECURITY_ATTRIBUTES );
195 sa.lpSecurityDescriptor = NULL;
196 sa.bInheritHandle = (ioflag & _O_NOINHERIT) ? FALSE : TRUE;
198 ret = (INT_PTR) CreateFileA(pszFile, ioflag, sharing, &sa, creation, FILE_ATTRIBUTE_NORMAL, NULL);
200 /* TRACE("<-- %d\n", ret); */
205 static UINT CDECL sc_cb_read(INT_PTR hf, void *pv, UINT cb)
210 /* TRACE("(hf == %d, pv == ^%p, cb == %u)\n", hf, pv, cb); */
212 rslt = ReadFile((HANDLE) hf, pv, cb, &num_read, NULL);
215 /* eof and failure both give "-1" return */
216 if ((! rslt) || ((cb > 0) && (num_read == 0))) {
217 /* TRACE("<-- -1\n"); */
221 /* TRACE("<-- %lu\n", num_read); */
225 static UINT CDECL sc_cb_write(INT_PTR hf, void *pv, UINT cb)
230 /* TRACE("(hf == %d, pv == ^%p, cb == %u)\n", hf, pv, cb); */
232 if ( /* (rv = */ WriteFile((HANDLE) hf, pv, cb, &num_written, NULL) /* ) */
233 && (num_written == cb)) {
234 /* TRACE("<-- %lu\n", num_written); */
237 /* TRACE("rv == %d, num_written == %lu, cb == %u\n", rv, num_written,cb); */
238 /* TRACE("<-- -1\n"); */
243 static int CDECL sc_cb_close(INT_PTR hf)
245 /* TRACE("(hf == %d)\n", hf); */
247 if (CloseHandle((HANDLE) hf))
253 static LONG CDECL sc_cb_lseek(INT_PTR hf, LONG dist, int seektype)
257 /* TRACE("(hf == %d, dist == %ld, seektype == %d)\n", hf, dist, seektype); */
259 if (seektype < 0 || seektype > 2)
262 if (((ret = SetFilePointer((HANDLE) hf, dist, NULL, seektype)) != INVALID_SET_FILE_POINTER) || !GetLastError()) {
263 /* TRACE("<-- %lu\n", ret); */
266 /* TRACE("<-- -1\n"); */
271 #define SIZEOF_MYSTERIO (MAX_PATH*3)
273 /* FDICopy callbacks */
275 static INT_PTR CDECL sc_FNNOTIFY_A(FDINOTIFICATIONTYPE fdint, PFDINOTIFICATION pfdin)
277 FILE_IN_CABINET_INFO_A fici;
283 CHAR mysterio[SIZEOF_MYSTERIO]; /* how big? undocumented! probably 256... */
285 memset(&(mysterio[0]), 0, SIZEOF_MYSTERIO);
287 TRACE("(fdint == %d, pfdin == ^%p)\n", fdint, pfdin);
289 if (pfdin && pfdin->pv && (*((void **) pfdin->pv) == (void *)SC_HSC_A_MAGIC))
292 ERR("pv %p is not an SC_HSC_A.\n", (pfdin) ? pfdin->pv : NULL);
297 case fdintCABINET_INFO:
298 TRACE("Cabinet info notification\n");
299 /* TRACE(" Cabinet name: %s\n", debugstr_a(pfdin->psz1));
300 TRACE(" Cabinet disk: %s\n", debugstr_a(pfdin->psz2));
301 TRACE(" Cabinet path: %s\n", debugstr_a(pfdin->psz3));
302 TRACE(" Cabinet Set#: %d\n", pfdin->setID);
303 TRACE(" Cabinet Cab#: %d\n", pfdin->iCabinet); */
304 WARN("SPFILENOTIFY_CABINETINFO undocumented: guess implementation.\n");
305 ci.CabinetFile = &(phsc->most_recent_cabinet_name[0]);
306 ci.CabinetPath = pfdin->psz3;
307 ci.DiskName = pfdin->psz2;
308 ci.SetId = pfdin->setID;
309 ci.CabinetNumber = pfdin->iCabinet;
310 phsc->msghandler(phsc->context, SPFILENOTIFY_CABINETINFO, (UINT_PTR) &ci, 0);
312 case fdintPARTIAL_FILE:
313 TRACE("Partial file notification\n");
314 /* TRACE(" Partial file name: %s\n", debugstr_a(pfdin->psz1)); */
317 TRACE("Copy file notification\n");
318 TRACE(" File name: %s\n", debugstr_a(pfdin->psz1));
319 /* TRACE(" File size: %ld\n", pfdin->cb);
320 TRACE(" File date: %u\n", pfdin->date);
321 TRACE(" File time: %u\n", pfdin->time);
322 TRACE(" File attr: %u\n", pfdin->attribs); */
323 fici.NameInCabinet = pfdin->psz1;
324 fici.FileSize = pfdin->cb;
326 fici.DosDate = pfdin->date;
327 fici.DosTime = pfdin->time;
328 fici.DosAttribs = pfdin->attribs;
329 memset(&(fici.FullTargetName[0]), 0, MAX_PATH);
330 err = phsc->msghandler(phsc->context, SPFILENOTIFY_FILEINCABINET,
331 (UINT_PTR)&fici, (UINT_PTR)pfdin->psz1);
332 if (err == FILEOP_DOIT) {
333 TRACE(" Callback specified filename: %s\n", debugstr_a(&(fici.FullTargetName[0])));
334 if (!fici.FullTargetName[0]) {
335 WARN(" Empty return string causing abort.\n");
336 SetLastError(ERROR_PATH_NOT_FOUND);
339 return sc_cb_open(&(fici.FullTargetName[0]), _O_BINARY | _O_CREAT | _O_WRONLY, _S_IREAD | _S_IWRITE);
341 TRACE(" Callback skipped file.\n");
344 case fdintCLOSE_FILE_INFO:
345 TRACE("Close file notification\n");
346 /* TRACE(" File name: %s\n", debugstr_a(pfdin->psz1));
347 TRACE(" Exec file? %s\n", (pfdin->cb) ? "Yes" : "No");
348 TRACE(" File hndl: %d\n", pfdin->hf); */
349 fp.Source = &(phsc->most_recent_cabinet_name[0]);
350 fp.Target = pfdin->psz1;
353 /* the following should be a fixme -- but it occurs too many times */
354 WARN("Should set file date/time/attribs (and execute files?)\n");
355 err = phsc->msghandler(phsc->context, SPFILENOTIFY_FILEEXTRACTED, (UINT_PTR)&fp, 0);
356 if (sc_cb_close(pfdin->hf))
357 WARN("_close failed.\n");
363 case fdintNEXT_CABINET:
364 TRACE("Next cabinet notification\n");
365 /* TRACE(" Cabinet name: %s\n", debugstr_a(pfdin->psz1));
366 TRACE(" Cabinet disk: %s\n", debugstr_a(pfdin->psz2));
367 TRACE(" Cabinet path: %s\n", debugstr_a(pfdin->psz3));
368 TRACE(" Cabinet Set#: %d\n", pfdin->setID);
369 TRACE(" Cabinet Cab#: %d\n", pfdin->iCabinet); */
370 ci.CabinetFile = pfdin->psz1;
371 ci.CabinetPath = pfdin->psz3;
372 ci.DiskName = pfdin->psz2;
373 ci.SetId = pfdin->setID;
374 ci.CabinetNumber = pfdin->iCabinet;
375 /* remember the new cabinet name */
376 strcpy(&(phsc->most_recent_cabinet_name[0]), pfdin->psz1);
377 err = phsc->msghandler(phsc->context, SPFILENOTIFY_NEEDNEWCABINET, (UINT_PTR)&ci, (UINT_PTR)mysterio);
383 /* some easy paranoia. no such carefulness exists on the wide API IIRC */
384 lstrcpynA(pfdin->psz3, &(mysterio[0]), SIZEOF_MYSTERIO);
389 FIXME("Unknown notification type %d.\n", fdint);
394 static INT_PTR CDECL sc_FNNOTIFY_W(FDINOTIFICATIONTYPE fdint, PFDINOTIFICATION pfdin)
396 FILE_IN_CABINET_INFO_W fici;
403 WCHAR mysterio[SIZEOF_MYSTERIO]; /* how big? undocumented! */
404 WCHAR buf[MAX_PATH], buf2[MAX_PATH];
405 CHAR charbuf[MAX_PATH];
407 memset(&(mysterio[0]), 0, SIZEOF_MYSTERIO * sizeof(WCHAR));
408 memset(&(buf[0]), 0, MAX_PATH * sizeof(WCHAR));
409 memset(&(buf2[0]), 0, MAX_PATH * sizeof(WCHAR));
410 memset(&(charbuf[0]), 0, MAX_PATH);
412 TRACE("(fdint == %d, pfdin == ^%p)\n", fdint, pfdin);
414 if (pfdin && pfdin->pv && (*((void **) pfdin->pv) == (void *)SC_HSC_W_MAGIC))
417 ERR("pv %p is not an SC_HSC_W.\n", (pfdin) ? pfdin->pv : NULL);
422 case fdintCABINET_INFO:
423 TRACE("Cabinet info notification\n");
424 /* TRACE(" Cabinet name: %s\n", debugstr_a(pfdin->psz1));
425 TRACE(" Cabinet disk: %s\n", debugstr_a(pfdin->psz2));
426 TRACE(" Cabinet path: %s\n", debugstr_a(pfdin->psz3));
427 TRACE(" Cabinet Set#: %d\n", pfdin->setID);
428 TRACE(" Cabinet Cab#: %d\n", pfdin->iCabinet); */
429 WARN("SPFILENOTIFY_CABINETINFO undocumented: guess implementation.\n");
430 ci.CabinetFile = &(phsc->most_recent_cabinet_name[0]);
431 len = 1 + MultiByteToWideChar(CP_ACP, 0, pfdin->psz3, -1, &(buf[0]), MAX_PATH);
432 if ((len > MAX_PATH) || (len <= 1))
434 ci.CabinetPath = &(buf[0]);
435 len = 1 + MultiByteToWideChar(CP_ACP, 0, pfdin->psz2, -1, &(buf2[0]), MAX_PATH);
436 if ((len > MAX_PATH) || (len <= 1))
438 ci.DiskName = &(buf2[0]);
439 ci.SetId = pfdin->setID;
440 ci.CabinetNumber = pfdin->iCabinet;
441 phsc->msghandler(phsc->context, SPFILENOTIFY_CABINETINFO, (UINT_PTR)&ci, 0);
443 case fdintPARTIAL_FILE:
444 TRACE("Partial file notification\n");
445 /* TRACE(" Partial file name: %s\n", debugstr_a(pfdin->psz1)); */
448 TRACE("Copy file notification\n");
449 TRACE(" File name: %s\n", debugstr_a(pfdin->psz1));
450 /* TRACE(" File size: %ld\n", pfdin->cb);
451 TRACE(" File date: %u\n", pfdin->date);
452 TRACE(" File time: %u\n", pfdin->time);
453 TRACE(" File attr: %u\n", pfdin->attribs); */
454 len = 1 + MultiByteToWideChar(CP_ACP, 0, pfdin->psz1, -1, &(buf2[0]), MAX_PATH);
455 if ((len > MAX_PATH) || (len <= 1))
457 fici.NameInCabinet = &(buf2[0]);
458 fici.FileSize = pfdin->cb;
460 fici.DosDate = pfdin->date;
461 fici.DosTime = pfdin->time;
462 fici.DosAttribs = pfdin->attribs;
463 memset(&(fici.FullTargetName[0]), 0, MAX_PATH * sizeof(WCHAR));
464 err = phsc->msghandler(phsc->context, SPFILENOTIFY_FILEINCABINET,
465 (UINT_PTR)&fici, (UINT_PTR)pfdin->psz1);
466 if (err == FILEOP_DOIT) {
467 TRACE(" Callback specified filename: %s\n", debugstr_w(&(fici.FullTargetName[0])));
468 if (fici.FullTargetName[0]) {
469 len = strlenW(&(fici.FullTargetName[0])) + 1;
470 if ((len > MAX_PATH ) || (len <= 1))
472 if (!WideCharToMultiByte(CP_ACP, 0, &(fici.FullTargetName[0]), len, &(charbuf[0]), MAX_PATH, 0, 0))
475 WARN("Empty buffer string caused abort.\n");
476 SetLastError(ERROR_PATH_NOT_FOUND);
479 return sc_cb_open(&(charbuf[0]), _O_BINARY | _O_CREAT | _O_WRONLY, _S_IREAD | _S_IWRITE);
481 TRACE(" Callback skipped file.\n");
484 case fdintCLOSE_FILE_INFO:
485 TRACE("Close file notification\n");
486 /* TRACE(" File name: %s\n", debugstr_a(pfdin->psz1));
487 TRACE(" Exec file? %s\n", (pfdin->cb) ? "Yes" : "No");
488 TRACE(" File hndl: %d\n", pfdin->hf); */
489 fp.Source = &(phsc->most_recent_cabinet_name[0]);
490 len = 1 + MultiByteToWideChar(CP_ACP, 0, pfdin->psz1, -1, &(buf[0]), MAX_PATH);
491 if ((len > MAX_PATH) || (len <= 1))
493 fp.Target = &(buf[0]);
496 /* a valid fixme -- but occurs too many times */
497 /* FIXME("Should set file date/time/attribs (and execute files?)\n"); */
498 err = phsc->msghandler(phsc->context, SPFILENOTIFY_FILEEXTRACTED, (UINT_PTR)&fp, 0);
499 if (sc_cb_close(pfdin->hf))
500 WARN("_close failed.\n");
506 case fdintNEXT_CABINET:
507 TRACE("Next cabinet notification\n");
508 /* TRACE(" Cabinet name: %s\n", debugstr_a(pfdin->psz1));
509 TRACE(" Cabinet disk: %s\n", debugstr_a(pfdin->psz2));
510 TRACE(" Cabinet path: %s\n", debugstr_a(pfdin->psz3));
511 TRACE(" Cabinet Set#: %d\n", pfdin->setID);
512 TRACE(" Cabinet Cab#: %d\n", pfdin->iCabinet); */
513 /* remember the new cabinet name */
514 len = 1 + MultiByteToWideChar(CP_ACP, 0, pfdin->psz1, -1, &(phsc->most_recent_cabinet_name[0]), MAX_PATH);
515 if ((len > MAX_PATH) || (len <= 1))
516 phsc->most_recent_cabinet_name[0] = '\0';
517 ci.CabinetFile = &(phsc->most_recent_cabinet_name[0]);
518 len = 1 + MultiByteToWideChar(CP_ACP, 0, pfdin->psz3, -1, &(buf[0]), MAX_PATH);
519 if ((len > MAX_PATH) || (len <= 1))
521 ci.CabinetPath = &(buf[0]);
522 len = 1 + MultiByteToWideChar(CP_ACP, 0, pfdin->psz2, -1, &(buf2[0]), MAX_PATH);
523 if ((len > MAX_PATH) || (len <= 1))
525 ci.DiskName = &(buf2[0]);
526 ci.SetId = pfdin->setID;
527 ci.CabinetNumber = pfdin->iCabinet;
528 err = phsc->msghandler(phsc->context, SPFILENOTIFY_NEEDNEWCABINET, (UINT_PTR)&ci, (UINT_PTR)mysterio);
534 len = strlenW(&(mysterio[0])) + 1;
535 if ((len > 255) || (len <= 1))
537 if (!WideCharToMultiByte(CP_ACP, 0, &(mysterio[0]), len, pfdin->psz3, 255, 0, 0))
543 FIXME("Unknown notification type %d.\n", fdint);
548 /***********************************************************************
549 * SetupIterateCabinetA (SETUPAPI.@)
551 BOOL WINAPI SetupIterateCabinetA(PCSTR CabinetFile, DWORD Reserved,
552 PSP_FILE_CALLBACK_A MsgHandler, PVOID Context)
557 CHAR pszCabinet[MAX_PATH], pszCabPath[MAX_PATH], *p;
562 TRACE("(CabinetFile == %s, Reserved == %u, MsgHandler == ^%p, Context == ^%p)\n",
563 debugstr_a(CabinetFile), Reserved, MsgHandler, Context);
565 if (! LoadCABINETDll())
568 memset(&my_hsc, 0, sizeof(SC_HSC_A));
569 pszCabinet[0] = '\0';
570 pszCabPath[0] = '\0';
572 fpnsize = strlen(CabinetFile);
573 if (fpnsize >= MAX_PATH) {
574 SetLastError(ERROR_BAD_PATHNAME);
578 fpnsize = GetFullPathNameA(CabinetFile, MAX_PATH, &(pszCabPath[0]), &p);
579 if (fpnsize > MAX_PATH) {
580 SetLastError(ERROR_BAD_PATHNAME);
585 strcpy(pszCabinet, p);
588 strcpy(pszCabinet, CabinetFile);
589 pszCabPath[0] = '\0';
592 TRACE("path: %s, cabfile: %s\n", debugstr_a(pszCabPath), debugstr_a(pszCabinet));
594 /* remember the cabinet name */
595 strcpy(&(my_hsc.most_recent_cabinet_name[0]), pszCabinet);
597 my_hsc.magic = SC_HSC_A_MAGIC;
598 my_hsc.msghandler = MsgHandler;
599 my_hsc.context = Context;
600 my_hsc.hfdi = sc_FDICreate( sc_cb_alloc, sc_cb_free, sc_cb_open, sc_cb_read,
601 sc_cb_write, sc_cb_close, sc_cb_lseek, cpuUNKNOWN, &erf );
603 if (!my_hsc.hfdi) return FALSE;
605 ret = ( sc_FDICopy(my_hsc.hfdi, pszCabinet, pszCabPath,
606 0, sc_FNNOTIFY_A, NULL, &my_hsc) ) ? TRUE : FALSE;
608 sc_FDIDestroy(my_hsc.hfdi);
613 /***********************************************************************
614 * SetupIterateCabinetW (SETUPAPI.@)
616 BOOL WINAPI SetupIterateCabinetW(PCWSTR CabinetFile, DWORD Reserved,
617 PSP_FILE_CALLBACK_W MsgHandler, PVOID Context)
619 CHAR pszCabinet[MAX_PATH], pszCabPath[MAX_PATH];
623 WCHAR pszCabPathW[MAX_PATH], *p;
627 TRACE("(CabinetFile == %s, Reserved == %u, MsgHandler == ^%p, Context == ^%p)\n",
628 debugstr_w(CabinetFile), Reserved, MsgHandler, Context);
630 if (!LoadCABINETDll())
633 if (!CabinetFile) return FALSE;
635 memset(&my_hsc, 0, sizeof(SC_HSC_W));
637 fpnsize = GetFullPathNameW(CabinetFile, MAX_PATH, pszCabPathW, &p);
638 if (fpnsize > MAX_PATH) {
639 SetLastError(ERROR_BAD_PATHNAME);
644 strcpyW(my_hsc.most_recent_cabinet_name, p);
646 len = WideCharToMultiByte(CP_ACP, 0, pszCabPathW, -1, pszCabPath,
648 if (!len) return FALSE;
650 strcpyW(my_hsc.most_recent_cabinet_name, CabinetFile);
651 pszCabPath[0] = '\0';
654 len = WideCharToMultiByte(CP_ACP, 0, my_hsc.most_recent_cabinet_name, -1,
655 pszCabinet, MAX_PATH, 0, 0);
656 if (!len) return FALSE;
658 TRACE("path: %s, cabfile: %s\n",
659 debugstr_a(pszCabPath), debugstr_a(pszCabinet));
661 my_hsc.magic = SC_HSC_W_MAGIC;
662 my_hsc.msghandler = MsgHandler;
663 my_hsc.context = Context;
664 my_hsc.hfdi = sc_FDICreate( sc_cb_alloc, sc_cb_free, sc_cb_open, sc_cb_read,
665 sc_cb_write, sc_cb_close, sc_cb_lseek, cpuUNKNOWN, &erf );
667 if (!my_hsc.hfdi) return FALSE;
669 ret = ( sc_FDICopy(my_hsc.hfdi, pszCabinet, pszCabPath,
670 0, sc_FNNOTIFY_W, NULL, &my_hsc) ) ? TRUE : FALSE;
672 sc_FDIDestroy(my_hsc.hfdi);
677 /***********************************************************************
681 * hinstDLL [I] handle to the DLL's instance
683 * lpvReserved [I] reserved, must be NULL
690 BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
693 case DLL_PROCESS_ATTACH:
694 DisableThreadLibraryCalls(hinstDLL);
695 OsVersionInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFOW);
696 if (!GetVersionExW(&OsVersionInfo))
699 case DLL_PROCESS_DETACH: