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
26 #include "setupapi_private.h"
32 HINSTANCE hInstance
= 0;
33 OSVERSIONINFOW OsVersionInfo
;
35 static HINSTANCE CABINET_hInstance
= 0;
37 static HFDI (__cdecl
*sc_FDICreate
)(PFNALLOC
, PFNFREE
, PFNOPEN
,
38 PFNREAD
, PFNWRITE
, PFNCLOSE
, PFNSEEK
, int, PERF
);
40 static BOOL (__cdecl
*sc_FDICopy
)(HFDI
, char *, char *, int,
41 PFNFDINOTIFY
, PFNFDIDECRYPT
, void *);
43 static BOOL (__cdecl
*sc_FDIDestroy
)(HFDI
);
45 #define SC_HSC_A_MAGIC 0xACABFEED
49 PSP_FILE_CALLBACK_A msghandler
;
51 CHAR most_recent_cabinet_name
[MAX_PATH
];
52 } SC_HSC_A
, *PSC_HSC_A
;
54 #define SC_HSC_W_MAGIC 0x0CABFEED
58 PSP_FILE_CALLBACK_W msghandler
;
60 WCHAR most_recent_cabinet_name
[MAX_PATH
];
61 } SC_HSC_W
, *PSC_HSC_W
;
63 static BOOL
LoadCABINETDll(void)
65 if (!CABINET_hInstance
) {
66 CABINET_hInstance
= LoadLibraryA("cabinet.dll");
67 if (CABINET_hInstance
) {
68 sc_FDICreate
= (void *)GetProcAddress(CABINET_hInstance
, "FDICreate");
69 sc_FDICopy
= (void *)GetProcAddress(CABINET_hInstance
, "FDICopy");
70 sc_FDIDestroy
= (void *)GetProcAddress(CABINET_hInstance
, "FDIDestroy");
73 ERR("load cabinet dll failed.\n");
80 static void UnloadCABINETDll(void)
82 if (CABINET_hInstance
) {
83 FreeLibrary(CABINET_hInstance
);
84 CABINET_hInstance
= 0;
88 /* FDICreate callbacks */
90 static void *sc_cb_alloc(ULONG cb
)
92 return HeapAlloc(GetProcessHeap(), 0, cb
);
95 static void sc_cb_free(void *pv
)
97 HeapFree(GetProcessHeap(), 0, pv
);
100 static INT_PTR
sc_cb_open(char *pszFile
, int oflag
, int pmode
)
102 DWORD creation
= 0, sharing
= 0;
105 SECURITY_ATTRIBUTES sa
;
107 /* TRACE("(pszFile == %s, oflag == %d, pmode == %d)\n", debugstr_a(pszFile), oflag, pmode); */
109 switch(oflag
& (_O_RDONLY
| _O_WRONLY
| _O_RDWR
)) {
111 ioflag
|= GENERIC_READ
;
114 ioflag
|= GENERIC_WRITE
;
117 ioflag
|= GENERIC_READ
& GENERIC_WRITE
;
119 case _O_WRONLY
| _O_RDWR
: /* hmmm.. */
120 ERR("_O_WRONLY & _O_RDWR in oflag?\n");
124 if (oflag
& _O_CREAT
) {
126 creation
= CREATE_NEW
;
127 else if (oflag
& _O_TRUNC
)
128 creation
= CREATE_ALWAYS
;
130 creation
= OPEN_ALWAYS
;
131 } else /* no _O_CREAT */ {
132 if (oflag
& _O_TRUNC
)
133 creation
= TRUNCATE_EXISTING
;
135 creation
= OPEN_EXISTING
;
138 switch( pmode
& 0x70 ) {
143 sharing
= FILE_SHARE_READ
;
146 sharing
= FILE_SHARE_WRITE
;
150 sharing
= FILE_SHARE_READ
| FILE_SHARE_WRITE
;
153 ERR("<-- -1 (Unhandled pmode 0x%x)\n", pmode
);
157 if (oflag
& ~(_O_BINARY
| _O_TRUNC
| _O_EXCL
| _O_CREAT
| _O_RDWR
| _O_WRONLY
| _O_NOINHERIT
))
158 WARN("unsupported oflag 0x%04x\n",oflag
);
160 sa
.nLength
= sizeof( SECURITY_ATTRIBUTES
);
161 sa
.lpSecurityDescriptor
= NULL
;
162 sa
.bInheritHandle
= (ioflag
& _O_NOINHERIT
) ? FALSE
: TRUE
;
164 ret
= (INT_PTR
) CreateFileA(pszFile
, ioflag
, sharing
, &sa
, creation
, FILE_ATTRIBUTE_NORMAL
, NULL
);
166 /* TRACE("<-- %d\n", ret); */
171 static UINT
sc_cb_read(INT_PTR hf
, void *pv
, UINT cb
)
176 /* TRACE("(hf == %d, pv == ^%p, cb == %u)\n", hf, pv, cb); */
178 rslt
= ReadFile((HANDLE
) hf
, pv
, cb
, &num_read
, NULL
);
181 /* eof and failure both give "-1" return */
182 if ((! rslt
) || ((cb
> 0) && (num_read
== 0))) {
183 /* TRACE("<-- -1\n"); */
187 /* TRACE("<-- %lu\n", num_read); */
191 static UINT
sc_cb_write(INT_PTR hf
, void *pv
, UINT cb
)
196 /* TRACE("(hf == %d, pv == ^%p, cb == %u)\n", hf, pv, cb); */
198 if ( /* (rv = */ WriteFile((HANDLE
) hf
, pv
, cb
, &num_written
, NULL
) /* ) */
199 && (num_written
== cb
)) {
200 /* TRACE("<-- %lu\n", num_written); */
203 /* TRACE("rv == %d, num_written == %lu, cb == %u\n", rv, num_written,cb); */
204 /* TRACE("<-- -1\n"); */
209 static int sc_cb_close(INT_PTR hf
)
211 /* TRACE("(hf == %d)\n", hf); */
213 if (CloseHandle((HANDLE
) hf
))
219 static long sc_cb_lseek(INT_PTR hf
, long dist
, int seektype
)
223 /* TRACE("(hf == %d, dist == %ld, seektype == %d)\n", hf, dist, seektype); */
225 if (seektype
< 0 || seektype
> 2)
228 if (((ret
= SetFilePointer((HANDLE
) hf
, dist
, NULL
, seektype
)) != INVALID_SET_FILE_POINTER
) || !GetLastError()) {
229 /* TRACE("<-- %lu\n", ret); */
232 /* TRACE("<-- -1\n"); */
237 #define SIZEOF_MYSTERIO (MAX_PATH*3)
239 /* FDICopy callbacks */
241 static INT_PTR
sc_FNNOTIFY_A(FDINOTIFICATIONTYPE fdint
, PFDINOTIFICATION pfdin
)
243 FILE_IN_CABINET_INFO_A fici
;
249 CHAR mysterio
[SIZEOF_MYSTERIO
]; /* how big? undocumented! probably 256... */
251 memset(&(mysterio
[0]), 0, SIZEOF_MYSTERIO
);
253 TRACE("(fdint == %d, pfdin == ^%p)\n", fdint
, pfdin
);
255 if (pfdin
&& pfdin
->pv
&& (*((void **) pfdin
->pv
) == (void *)SC_HSC_A_MAGIC
))
256 phsc
= (PSC_HSC_A
) pfdin
->pv
;
258 ERR("pv %p is not an SC_HSC_A.\n", (pfdin
) ? pfdin
->pv
: NULL
);
263 case fdintCABINET_INFO
:
264 TRACE("Cabinet info notification\n");
265 /* TRACE(" Cabinet name: %s\n", debugstr_a(pfdin->psz1));
266 TRACE(" Cabinet disk: %s\n", debugstr_a(pfdin->psz2));
267 TRACE(" Cabinet path: %s\n", debugstr_a(pfdin->psz3));
268 TRACE(" Cabinet Set#: %d\n", pfdin->setID);
269 TRACE(" Cabinet Cab#: %d\n", pfdin->iCabinet); */
270 WARN("SPFILENOTIFY_CABINETINFO undocumented: guess implementation.\n");
271 ci
.CabinetFile
= &(phsc
->most_recent_cabinet_name
[0]);
272 ci
.CabinetPath
= pfdin
->psz3
;
273 ci
.DiskName
= pfdin
->psz2
;
274 ci
.SetId
= pfdin
->setID
;
275 ci
.CabinetNumber
= pfdin
->iCabinet
;
276 phsc
->msghandler(phsc
->context
, SPFILENOTIFY_CABINETINFO
, (UINT
) &ci
, 0);
278 case fdintPARTIAL_FILE
:
279 TRACE("Partial file notification\n");
280 /* TRACE(" Partial file name: %s\n", debugstr_a(pfdin->psz1)); */
283 TRACE("Copy file notification\n");
284 TRACE(" File name: %s\n", debugstr_a(pfdin
->psz1
));
285 /* TRACE(" File size: %ld\n", pfdin->cb);
286 TRACE(" File date: %u\n", pfdin->date);
287 TRACE(" File time: %u\n", pfdin->time);
288 TRACE(" File attr: %u\n", pfdin->attribs); */
289 fici
.NameInCabinet
= pfdin
->psz1
;
290 fici
.FileSize
= pfdin
->cb
;
292 fici
.DosDate
= pfdin
->date
;
293 fici
.DosTime
= pfdin
->time
;
294 fici
.DosAttribs
= pfdin
->attribs
;
295 memset(&(fici
.FullTargetName
[0]), 0, MAX_PATH
);
296 err
= phsc
->msghandler(phsc
->context
, SPFILENOTIFY_FILEINCABINET
,
297 (UINT
) &fici
, (UINT
) pfdin
->psz1
);
298 if (err
== FILEOP_DOIT
) {
299 TRACE(" Callback specified filename: %s\n", debugstr_a(&(fici
.FullTargetName
[0])));
300 if (!fici
.FullTargetName
[0]) {
301 WARN(" Empty return string causing abort.\n");
302 SetLastError(ERROR_PATH_NOT_FOUND
);
305 return sc_cb_open(&(fici
.FullTargetName
[0]), _O_BINARY
| _O_CREAT
| _O_WRONLY
, _S_IREAD
| _S_IWRITE
);
307 TRACE(" Callback skipped file.\n");
310 case fdintCLOSE_FILE_INFO
:
311 TRACE("Close file notification\n");
312 /* TRACE(" File name: %s\n", debugstr_a(pfdin->psz1));
313 TRACE(" Exec file? %s\n", (pfdin->cb) ? "Yes" : "No");
314 TRACE(" File hndl: %d\n", pfdin->hf); */
315 fp
.Source
= &(phsc
->most_recent_cabinet_name
[0]);
316 fp
.Target
= pfdin
->psz1
;
319 /* the following should be a fixme -- but it occurs too many times */
320 WARN("Should set file date/time/attribs (and execute files?)\n");
321 err
= phsc
->msghandler(phsc
->context
, SPFILENOTIFY_FILEEXTRACTED
, (UINT
) &fp
, 0);
322 if (sc_cb_close(pfdin
->hf
))
323 WARN("_close failed.\n");
329 case fdintNEXT_CABINET
:
330 TRACE("Next cabinet notification\n");
331 /* TRACE(" Cabinet name: %s\n", debugstr_a(pfdin->psz1));
332 TRACE(" Cabinet disk: %s\n", debugstr_a(pfdin->psz2));
333 TRACE(" Cabinet path: %s\n", debugstr_a(pfdin->psz3));
334 TRACE(" Cabinet Set#: %d\n", pfdin->setID);
335 TRACE(" Cabinet Cab#: %d\n", pfdin->iCabinet); */
336 ci
.CabinetFile
= pfdin
->psz1
;
337 ci
.CabinetPath
= pfdin
->psz3
;
338 ci
.DiskName
= pfdin
->psz2
;
339 ci
.SetId
= pfdin
->setID
;
340 ci
.CabinetNumber
= pfdin
->iCabinet
;
341 /* remember the new cabinet name */
342 strcpy(&(phsc
->most_recent_cabinet_name
[0]), pfdin
->psz1
);
343 err
= phsc
->msghandler(phsc
->context
, SPFILENOTIFY_NEEDNEWCABINET
, (UINT
) &ci
, (UINT
) &(mysterio
[0]));
349 /* some easy paranoia. no such carefulness exists on the wide API IIRC */
350 lstrcpynA(pfdin
->psz3
, &(mysterio
[0]), SIZEOF_MYSTERIO
);
355 FIXME("Unknown notification type %d.\n", fdint
);
360 static INT_PTR
sc_FNNOTIFY_W(FDINOTIFICATIONTYPE fdint
, PFDINOTIFICATION pfdin
)
362 FILE_IN_CABINET_INFO_W fici
;
369 WCHAR mysterio
[SIZEOF_MYSTERIO
]; /* how big? undocumented! */
370 WCHAR buf
[MAX_PATH
], buf2
[MAX_PATH
];
371 CHAR charbuf
[MAX_PATH
];
373 memset(&(mysterio
[0]), 0, SIZEOF_MYSTERIO
* sizeof(WCHAR
));
374 memset(&(buf
[0]), 0, MAX_PATH
* sizeof(WCHAR
));
375 memset(&(buf2
[0]), 0, MAX_PATH
* sizeof(WCHAR
));
376 memset(&(charbuf
[0]), 0, MAX_PATH
);
378 TRACE("(fdint == %d, pfdin == ^%p)\n", fdint
, pfdin
);
380 if (pfdin
&& pfdin
->pv
&& (*((void **) pfdin
->pv
) == (void *)SC_HSC_W_MAGIC
))
381 phsc
= (PSC_HSC_W
) pfdin
->pv
;
383 ERR("pv %p is not an SC_HSC_W.\n", (pfdin
) ? pfdin
->pv
: NULL
);
388 case fdintCABINET_INFO
:
389 TRACE("Cabinet info notification\n");
390 /* TRACE(" Cabinet name: %s\n", debugstr_a(pfdin->psz1));
391 TRACE(" Cabinet disk: %s\n", debugstr_a(pfdin->psz2));
392 TRACE(" Cabinet path: %s\n", debugstr_a(pfdin->psz3));
393 TRACE(" Cabinet Set#: %d\n", pfdin->setID);
394 TRACE(" Cabinet Cab#: %d\n", pfdin->iCabinet); */
395 WARN("SPFILENOTIFY_CABINETINFO undocumented: guess implementation.\n");
396 ci
.CabinetFile
= &(phsc
->most_recent_cabinet_name
[0]);
397 len
= 1 + MultiByteToWideChar(CP_ACP
, 0, pfdin
->psz3
, -1, &(buf
[0]), MAX_PATH
);
398 if ((len
> MAX_PATH
) || (len
<= 1))
400 ci
.CabinetPath
= &(buf
[0]);
401 len
= 1 + MultiByteToWideChar(CP_ACP
, 0, pfdin
->psz2
, -1, &(buf2
[0]), MAX_PATH
);
402 if ((len
> MAX_PATH
) || (len
<= 1))
404 ci
.DiskName
= &(buf2
[0]);
405 ci
.SetId
= pfdin
->setID
;
406 ci
.CabinetNumber
= pfdin
->iCabinet
;
407 phsc
->msghandler(phsc
->context
, SPFILENOTIFY_CABINETINFO
, (UINT
) &ci
, 0);
409 case fdintPARTIAL_FILE
:
410 TRACE("Partial file notification\n");
411 /* TRACE(" Partial file name: %s\n", debugstr_a(pfdin->psz1)); */
414 TRACE("Copy file notification\n");
415 TRACE(" File name: %s\n", debugstr_a(pfdin
->psz1
));
416 /* TRACE(" File size: %ld\n", pfdin->cb);
417 TRACE(" File date: %u\n", pfdin->date);
418 TRACE(" File time: %u\n", pfdin->time);
419 TRACE(" File attr: %u\n", pfdin->attribs); */
420 len
= 1 + MultiByteToWideChar(CP_ACP
, 0, pfdin
->psz1
, -1, &(buf2
[0]), MAX_PATH
);
421 if ((len
> MAX_PATH
) || (len
<= 1))
423 fici
.NameInCabinet
= &(buf2
[0]);
424 fici
.FileSize
= pfdin
->cb
;
426 fici
.DosDate
= pfdin
->date
;
427 fici
.DosTime
= pfdin
->time
;
428 fici
.DosAttribs
= pfdin
->attribs
;
429 memset(&(fici
.FullTargetName
[0]), 0, MAX_PATH
* sizeof(WCHAR
));
430 err
= phsc
->msghandler(phsc
->context
, SPFILENOTIFY_FILEINCABINET
,
431 (UINT
) &fici
, (UINT
) pfdin
->psz1
);
432 if (err
== FILEOP_DOIT
) {
433 TRACE(" Callback specified filename: %s\n", debugstr_w(&(fici
.FullTargetName
[0])));
434 if (fici
.FullTargetName
[0]) {
435 len
= strlenW(&(fici
.FullTargetName
[0])) + 1;
436 if ((len
> MAX_PATH
) || (len
<= 1))
438 if (!WideCharToMultiByte(CP_ACP
, 0, &(fici
.FullTargetName
[0]), len
, &(charbuf
[0]), MAX_PATH
, 0, 0))
441 WARN("Empty buffer string caused abort.\n");
442 SetLastError(ERROR_PATH_NOT_FOUND
);
445 return sc_cb_open(&(charbuf
[0]), _O_BINARY
| _O_CREAT
| _O_WRONLY
, _S_IREAD
| _S_IWRITE
);
447 TRACE(" Callback skipped file.\n");
450 case fdintCLOSE_FILE_INFO
:
451 TRACE("Close file notification\n");
452 /* TRACE(" File name: %s\n", debugstr_a(pfdin->psz1));
453 TRACE(" Exec file? %s\n", (pfdin->cb) ? "Yes" : "No");
454 TRACE(" File hndl: %d\n", pfdin->hf); */
455 fp
.Source
= &(phsc
->most_recent_cabinet_name
[0]);
456 len
= 1 + MultiByteToWideChar(CP_ACP
, 0, pfdin
->psz1
, -1, &(buf
[0]), MAX_PATH
);
457 if ((len
> MAX_PATH
) || (len
<= 1))
459 fp
.Target
= &(buf
[0]);
462 /* a valid fixme -- but occurs too many times */
463 /* FIXME("Should set file date/time/attribs (and execute files?)\n"); */
464 err
= phsc
->msghandler(phsc
->context
, SPFILENOTIFY_FILEEXTRACTED
, (UINT
) &fp
, 0);
465 if (sc_cb_close(pfdin
->hf
))
466 WARN("_close failed.\n");
472 case fdintNEXT_CABINET
:
473 TRACE("Next cabinet notification\n");
474 /* TRACE(" Cabinet name: %s\n", debugstr_a(pfdin->psz1));
475 TRACE(" Cabinet disk: %s\n", debugstr_a(pfdin->psz2));
476 TRACE(" Cabinet path: %s\n", debugstr_a(pfdin->psz3));
477 TRACE(" Cabinet Set#: %d\n", pfdin->setID);
478 TRACE(" Cabinet Cab#: %d\n", pfdin->iCabinet); */
479 /* remember the new cabinet name */
480 len
= 1 + MultiByteToWideChar(CP_ACP
, 0, pfdin
->psz1
, -1, &(phsc
->most_recent_cabinet_name
[0]), MAX_PATH
);
481 if ((len
> MAX_PATH
) || (len
<= 1))
482 phsc
->most_recent_cabinet_name
[0] = '\0';
483 ci
.CabinetFile
= &(phsc
->most_recent_cabinet_name
[0]);
484 len
= 1 + MultiByteToWideChar(CP_ACP
, 0, pfdin
->psz3
, -1, &(buf
[0]), MAX_PATH
);
485 if ((len
> MAX_PATH
) || (len
<= 1))
487 ci
.CabinetPath
= &(buf
[0]);
488 len
= 1 + MultiByteToWideChar(CP_ACP
, 0, pfdin
->psz2
, -1, &(buf2
[0]), MAX_PATH
);
489 if ((len
> MAX_PATH
) || (len
<= 1))
491 ci
.DiskName
= &(buf2
[0]);
492 ci
.SetId
= pfdin
->setID
;
493 ci
.CabinetNumber
= pfdin
->iCabinet
;
494 err
= phsc
->msghandler(phsc
->context
, SPFILENOTIFY_NEEDNEWCABINET
, (UINT
) &ci
, (UINT
) &(mysterio
[0]));
500 len
= strlenW(&(mysterio
[0])) + 1;
501 if ((len
> 255) || (len
<= 1))
503 if (!WideCharToMultiByte(CP_ACP
, 0, &(mysterio
[0]), len
, pfdin
->psz3
, 255, 0, 0))
509 FIXME("Unknown notification type %d.\n", fdint
);
514 /***********************************************************************
515 * SetupIterateCabinetA (SETUPAPI.@)
517 BOOL WINAPI
SetupIterateCabinetA(PCSTR CabinetFile
, DWORD Reserved
,
518 PSP_FILE_CALLBACK_A MsgHandler
, PVOID Context
)
523 CHAR pszCabinet
[MAX_PATH
], pszCabPath
[MAX_PATH
], *p
= NULL
;
528 TRACE("(CabinetFile == %s, Reserved == %u, MsgHandler == ^%p, Context == ^%p)\n",
529 debugstr_a(CabinetFile
), Reserved
, MsgHandler
, Context
);
531 if (! LoadCABINETDll())
536 SetLastError(ERROR_INVALID_PARAMETER
);
540 memset(&my_hsc
, 0, sizeof(SC_HSC_A
));
541 pszCabinet
[0] = '\0';
542 pszCabPath
[0] = '\0';
544 fpnsize
= strlen(CabinetFile
);
545 if (fpnsize
>= MAX_PATH
) {
546 SetLastError(ERROR_BAD_PATHNAME
);
550 fpnsize
= GetFullPathNameA(CabinetFile
, MAX_PATH
, &(pszCabPath
[0]), &p
);
551 if (fpnsize
> MAX_PATH
) {
552 SetLastError(ERROR_BAD_PATHNAME
);
557 strcpy(pszCabinet
, p
);
560 strcpy(pszCabinet
, CabinetFile
);
561 pszCabPath
[0] = '\0';
564 TRACE("path: %s, cabfile: %s\n", debugstr_a(pszCabPath
), debugstr_a(pszCabinet
));
566 /* remember the cabinet name */
567 strcpy(&(my_hsc
.most_recent_cabinet_name
[0]), pszCabinet
);
569 my_hsc
.magic
= SC_HSC_A_MAGIC
;
570 my_hsc
.msghandler
= MsgHandler
;
571 my_hsc
.context
= Context
;
572 my_hsc
.hfdi
= sc_FDICreate( sc_cb_alloc
, sc_cb_free
, sc_cb_open
, sc_cb_read
,
573 sc_cb_write
, sc_cb_close
, sc_cb_lseek
, cpuUNKNOWN
, &erf
);
575 if (!my_hsc
.hfdi
) return FALSE
;
577 ret
= ( sc_FDICopy(my_hsc
.hfdi
, pszCabinet
, pszCabPath
,
578 0, sc_FNNOTIFY_A
, NULL
, &my_hsc
) ) ? TRUE
: FALSE
;
580 sc_FDIDestroy(my_hsc
.hfdi
);
585 /***********************************************************************
586 * SetupIterateCabinetW (SETUPAPI.@)
588 BOOL WINAPI
SetupIterateCabinetW(PCWSTR CabinetFile
, DWORD Reserved
,
589 PSP_FILE_CALLBACK_W MsgHandler
, PVOID Context
)
591 CHAR pszCabinet
[MAX_PATH
], pszCabPath
[MAX_PATH
];
595 WCHAR pszCabPathW
[MAX_PATH
], *p
= NULL
;
599 TRACE("(CabinetFile == %s, Reserved == %u, MsgHandler == ^%p, Context == ^%p)\n",
600 debugstr_w(CabinetFile
), Reserved
, MsgHandler
, Context
);
602 if (!LoadCABINETDll())
607 SetLastError(ERROR_INVALID_PARAMETER
);
611 memset(&my_hsc
, 0, sizeof(SC_HSC_W
));
613 fpnsize
= GetFullPathNameW(CabinetFile
, MAX_PATH
, pszCabPathW
, &p
);
614 if (fpnsize
> MAX_PATH
) {
615 SetLastError(ERROR_BAD_PATHNAME
);
620 strcpyW(my_hsc
.most_recent_cabinet_name
, p
);
622 len
= WideCharToMultiByte(CP_ACP
, 0, pszCabPathW
, -1, pszCabPath
,
624 if (!len
) return FALSE
;
626 strcpyW(my_hsc
.most_recent_cabinet_name
, CabinetFile
);
627 pszCabPath
[0] = '\0';
630 len
= WideCharToMultiByte(CP_ACP
, 0, my_hsc
.most_recent_cabinet_name
, -1,
631 pszCabinet
, MAX_PATH
, 0, 0);
632 if (!len
) return FALSE
;
634 TRACE("path: %s, cabfile: %s\n",
635 debugstr_a(pszCabPath
), debugstr_a(pszCabinet
));
637 my_hsc
.magic
= SC_HSC_W_MAGIC
;
638 my_hsc
.msghandler
= MsgHandler
;
639 my_hsc
.context
= Context
;
640 my_hsc
.hfdi
= sc_FDICreate( sc_cb_alloc
, sc_cb_free
, sc_cb_open
, sc_cb_read
,
641 sc_cb_write
, sc_cb_close
, sc_cb_lseek
, cpuUNKNOWN
, &erf
);
643 if (!my_hsc
.hfdi
) return FALSE
;
645 ret
= ( sc_FDICopy(my_hsc
.hfdi
, pszCabinet
, pszCabPath
,
646 0, sc_FNNOTIFY_W
, NULL
, &my_hsc
) ) ? TRUE
: FALSE
;
648 sc_FDIDestroy(my_hsc
.hfdi
);
653 /***********************************************************************
657 * hinstDLL [I] handle to the DLL's instance
659 * lpvReserved [I] reserved, must be NULL
666 BOOL WINAPI
DllMain(HINSTANCE hinstDLL
, DWORD fdwReason
, LPVOID lpvReserved
)
669 case DLL_PROCESS_ATTACH
:
670 DisableThreadLibraryCalls(hinstDLL
);
671 OsVersionInfo
.dwOSVersionInfoSize
= sizeof(OSVERSIONINFOW
);
672 if (!GetVersionExW(&OsVersionInfo
))
674 hInstance
= (HINSTANCE
)hinstDLL
;
676 case DLL_PROCESS_DETACH
: