reshuffling of dlls
[reactos.git] / reactos / dll / version / install.c
1 /*
2 * Implementation of VERSION.DLL - File Installer routines
3 *
4 * Copyright 1996,1997 Marcus Meissner
5 * Copyright 1997 David Cuthbert
6 *
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 *
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 *
21 * TODO
22 * o Check the installation functions.
23 */
24 #include "config.h"
25 #include "wine/port.h"
26
27 #include <stdlib.h>
28 #include <stdarg.h>
29 #include <stdio.h>
30 #include <string.h>
31
32 #include "windef.h"
33 #include "winbase.h"
34 #include "winver.h"
35 #include "winnls.h"
36 #include "wine/unicode.h"
37 #include "winerror.h"
38 #include "lzexpand.h"
39 #include "wine/debug.h"
40
41 WINE_DEFAULT_DEBUG_CHANNEL(ver);
42
43 /* Couple of Hacks */
44 extern inline DWORD WINAPI GetLastError(void)
45 {
46 DWORD ret;
47 __asm__ __volatile__( ".byte 0x64\n\tmovl 0x60,%0" : "=r" (ret) );
48 return ret;
49 }
50
51 /******************************************************************************
52 * testFileExistenceA
53 *
54 * Tests whether a given path/file combination exists. If the file does
55 * not exist, the return value is zero. If it does exist, the return
56 * value is non-zero.
57 *
58 * Revision history
59 * 30-May-1997 Dave Cuthbert (dacut@ece.cmu.edu)
60 * Original implementation
61 *
62 */
63 static int testFileExistenceA( char const * path, char const * file, BOOL excl )
64 {
65 char filename[1024];
66 int filenamelen;
67 OFSTRUCT fileinfo;
68
69 fileinfo.cBytes = sizeof(OFSTRUCT);
70
71 strcpy(filename, path);
72 filenamelen = strlen(filename);
73
74 /* Add a trailing \ if necessary */
75 if(filenamelen) {
76 if(filename[filenamelen - 1] != '\\')
77 strcat(filename, "\\");
78 }
79 else /* specify the current directory */
80 strcpy(filename, ".\\");
81
82 /* Create the full pathname */
83 strcat(filename, file);
84
85 return (OpenFile(filename, &fileinfo,
86 OF_EXIST | (excl ? OF_SHARE_EXCLUSIVE : 0)) != HFILE_ERROR);
87 }
88
89 /******************************************************************************
90 * testFileExistenceW
91 */
92 static int testFileExistenceW( const WCHAR *path, const WCHAR *file, BOOL excl )
93 {
94 char *filename;
95 DWORD pathlen, filelen;
96 int ret;
97 OFSTRUCT fileinfo;
98
99 fileinfo.cBytes = sizeof(OFSTRUCT);
100
101 pathlen = WideCharToMultiByte( CP_ACP, 0, path, -1, NULL, 0, NULL, NULL );
102 filelen = WideCharToMultiByte( CP_ACP, 0, file, -1, NULL, 0, NULL, NULL );
103 filename = HeapAlloc( GetProcessHeap(), 0, pathlen+filelen+2 );
104
105 WideCharToMultiByte( CP_ACP, 0, path, -1, filename, pathlen, NULL, NULL );
106 /* Add a trailing \ if necessary */
107 if (pathlen > 1)
108 {
109 if (filename[pathlen-2] != '\\') strcpy( &filename[pathlen-1], "\\" );
110 }
111 else /* specify the current directory */
112 strcpy(filename, ".\\");
113
114 WideCharToMultiByte( CP_ACP, 0, file, -1, filename+strlen(filename), filelen, NULL, NULL );
115
116 ret = (OpenFile(filename, &fileinfo,
117 OF_EXIST | (excl ? OF_SHARE_EXCLUSIVE : 0)) != HFILE_ERROR);
118 HeapFree( GetProcessHeap(), 0, filename );
119 return ret;
120 }
121
122 /*****************************************************************************
123 * VerFindFileA [VERSION.@]
124 *
125 * Determines where to install a file based on whether it locates another
126 * version of the file in the system. The values VerFindFile returns are
127 * used in a subsequent call to the VerInstallFile function.
128 *
129 * Revision history:
130 * 30-May-1997 Dave Cuthbert (dacut@ece.cmu.edu)
131 * Reimplementation of VerFindFile from original stub.
132 */
133 DWORD WINAPI VerFindFileA(
134 DWORD flags,
135 LPSTR lpszFilename,
136 LPSTR lpszWinDir,
137 LPSTR lpszAppDir,
138 LPSTR lpszCurDir,
139 UINT *lpuCurDirLen,
140 LPSTR lpszDestDir,
141 UINT *lpuDestDirLen )
142 {
143 DWORD retval = 0;
144 const char *curDir;
145 const char *destDir;
146 unsigned int curDirSizeReq;
147 unsigned int destDirSizeReq;
148 char systemDir[MAX_PATH];
149
150 /* Print out debugging information */
151 TRACE("flags = %x filename=%s windir=%s appdir=%s curdirlen=%p(%u) destdirlen=%p(%u)\n",
152 flags, debugstr_a(lpszFilename), debugstr_a(lpszWinDir), debugstr_a(lpszAppDir),
153 lpuCurDirLen, lpuCurDirLen ? *lpuCurDirLen : 0,
154 lpuDestDirLen, lpuDestDirLen ? *lpuDestDirLen : 0 );
155
156 /* Figure out where the file should go; shared files default to the
157 system directory */
158
159 GetSystemDirectoryA(systemDir, sizeof(systemDir));
160 curDir = "";
161 destDir = "";
162
163 if(flags & VFFF_ISSHAREDFILE)
164 {
165 destDir = systemDir;
166 /* Were we given a filename? If so, try to find the file. */
167 if(lpszFilename)
168 {
169 if(testFileExistenceA(destDir, lpszFilename, FALSE)) curDir = destDir;
170 else if(lpszAppDir && testFileExistenceA(lpszAppDir, lpszFilename, FALSE))
171 {
172 curDir = lpszAppDir;
173 retval |= VFF_CURNEDEST;
174 }
175 }
176 }
177 else /* not a shared file */
178 {
179 if(lpszAppDir)
180 {
181 destDir = lpszAppDir;
182 if(lpszFilename)
183 {
184 if(testFileExistenceA(destDir, lpszFilename, FALSE)) curDir = destDir;
185 else if(testFileExistenceA(systemDir, lpszFilename, FALSE))
186 {
187 curDir = systemDir;
188 retval |= VFF_CURNEDEST;
189 }
190 }
191 }
192 }
193
194 if (lpszFilename && !testFileExistenceA(curDir, lpszFilename, TRUE))
195 retval |= VFF_FILEINUSE;
196
197 curDirSizeReq = strlen(curDir) + 1;
198 destDirSizeReq = strlen(destDir) + 1;
199
200 /* Make sure that the pointers to the size of the buffers are
201 valid; if not, do NOTHING with that buffer. If that pointer
202 is valid, then make sure that the buffer pointer is valid, too! */
203
204 if(lpuDestDirLen && lpszDestDir)
205 {
206 if (*lpuDestDirLen < destDirSizeReq) retval |= VFF_BUFFTOOSMALL;
207 lstrcpynA(lpszDestDir, destDir, *lpuDestDirLen);
208 *lpuDestDirLen = destDirSizeReq;
209 }
210 if(lpuCurDirLen && lpszCurDir)
211 {
212 if(*lpuCurDirLen < curDirSizeReq) retval |= VFF_BUFFTOOSMALL;
213 lstrcpynA(lpszCurDir, curDir, *lpuCurDirLen);
214 *lpuCurDirLen = curDirSizeReq;
215 }
216
217 TRACE("ret = %lu (%s%s%s) curdir=%s destdir=%s\n", retval,
218 (retval & VFF_CURNEDEST) ? "VFF_CURNEDEST " : "",
219 (retval & VFF_FILEINUSE) ? "VFF_FILEINUSE " : "",
220 (retval & VFF_BUFFTOOSMALL) ? "VFF_BUFFTOOSMALL " : "",
221 debugstr_a(lpszCurDir), debugstr_a(lpszDestDir));
222
223 return retval;
224 }
225
226 /*****************************************************************************
227 * VerFindFileW [VERSION.@]
228 */
229 DWORD WINAPI VerFindFileW( DWORD flags,LPWSTR lpszFilename,LPWSTR lpszWinDir,
230 LPWSTR lpszAppDir, LPWSTR lpszCurDir,UINT *lpuCurDirLen,
231 LPWSTR lpszDestDir,UINT *lpuDestDirLen )
232 {
233 static const WCHAR emptyW;
234 DWORD retval = 0;
235 const WCHAR *curDir;
236 const WCHAR *destDir;
237 unsigned int curDirSizeReq;
238 unsigned int destDirSizeReq;
239 WCHAR systemDir[MAX_PATH];
240
241 /* Print out debugging information */
242 TRACE("flags = %x filename=%s windir=%s appdir=%s curdirlen=%p(%u) destdirlen=%p(%u)\n",
243 flags, debugstr_w(lpszFilename), debugstr_w(lpszWinDir), debugstr_w(lpszAppDir),
244 lpuCurDirLen, lpuCurDirLen ? *lpuCurDirLen : 0,
245 lpuDestDirLen, lpuDestDirLen ? *lpuDestDirLen : 0 );
246
247 /* Figure out where the file should go; shared files default to the
248 system directory */
249
250 GetSystemDirectoryW(systemDir, sizeof(systemDir)/sizeof(WCHAR));
251 curDir = &emptyW;
252 destDir = &emptyW;
253
254 if(flags & VFFF_ISSHAREDFILE)
255 {
256 destDir = systemDir;
257 /* Were we given a filename? If so, try to find the file. */
258 if(lpszFilename)
259 {
260 if(testFileExistenceW(destDir, lpszFilename, FALSE)) curDir = destDir;
261 else if(lpszAppDir && testFileExistenceW(lpszAppDir, lpszFilename, FALSE))
262 {
263 curDir = lpszAppDir;
264 retval |= VFF_CURNEDEST;
265 }
266 }
267 }
268 else /* not a shared file */
269 {
270 if(lpszAppDir)
271 {
272 destDir = lpszAppDir;
273 if(lpszFilename)
274 {
275 if(testFileExistenceW(destDir, lpszFilename, FALSE)) curDir = destDir;
276 else if(testFileExistenceW(systemDir, lpszFilename, FALSE))
277 {
278 curDir = systemDir;
279 retval |= VFF_CURNEDEST;
280 }
281 }
282 }
283 }
284
285 if (lpszFilename && !testFileExistenceW(curDir, lpszFilename, TRUE))
286 retval |= VFF_FILEINUSE;
287
288 curDirSizeReq = strlenW(curDir) + 1;
289 destDirSizeReq = strlenW(destDir) + 1;
290
291 /* Make sure that the pointers to the size of the buffers are
292 valid; if not, do NOTHING with that buffer. If that pointer
293 is valid, then make sure that the buffer pointer is valid, too! */
294
295 if(lpuDestDirLen && lpszDestDir)
296 {
297 if (*lpuDestDirLen < destDirSizeReq) retval |= VFF_BUFFTOOSMALL;
298 lstrcpynW(lpszDestDir, destDir, *lpuDestDirLen);
299 *lpuDestDirLen = destDirSizeReq;
300 }
301 if(lpuCurDirLen && lpszCurDir)
302 {
303 if(*lpuCurDirLen < curDirSizeReq) retval |= VFF_BUFFTOOSMALL;
304 lstrcpynW(lpszCurDir, curDir, *lpuCurDirLen);
305 *lpuCurDirLen = curDirSizeReq;
306 }
307
308 TRACE("ret = %lu (%s%s%s) curdir=%s destdir=%s\n", retval,
309 (retval & VFF_CURNEDEST) ? "VFF_CURNEDEST " : "",
310 (retval & VFF_FILEINUSE) ? "VFF_FILEINUSE " : "",
311 (retval & VFF_BUFFTOOSMALL) ? "VFF_BUFFTOOSMALL " : "",
312 debugstr_w(lpszCurDir), debugstr_w(lpszDestDir));
313 return retval;
314 }
315
316 static LPBYTE
317 _fetch_versioninfo(LPSTR fn,VS_FIXEDFILEINFO **vffi) {
318 DWORD alloclen;
319 LPBYTE buf;
320 DWORD ret;
321
322 alloclen = 1000;
323 buf=HeapAlloc(GetProcessHeap(), 0, alloclen);
324 if(buf == NULL) {
325 WARN("Memory exausted while fetching version info!\n");
326 return NULL;
327 }
328 while (1) {
329 ret = GetFileVersionInfoA(fn,0,alloclen,buf);
330 if (!ret) {
331 HeapFree(GetProcessHeap(), 0, buf);
332 return NULL;
333 }
334 if (alloclen<*(WORD*)buf) {
335 alloclen = *(WORD*)buf;
336 HeapFree(GetProcessHeap(), 0, buf);
337 buf = HeapAlloc(GetProcessHeap(), 0, alloclen);
338 if(buf == NULL) {
339 WARN("Memory exausted while fetching version info!\n");
340 return NULL;
341 }
342 } else {
343 *vffi = (VS_FIXEDFILEINFO*)(buf+0x14);
344 if ((*vffi)->dwSignature == 0x004f0049) /* hack to detect unicode */
345 *vffi = (VS_FIXEDFILEINFO*)(buf+0x28);
346 if ((*vffi)->dwSignature != VS_FFI_SIGNATURE)
347 WARN("Bad VS_FIXEDFILEINFO signature 0x%08lx\n",(*vffi)->dwSignature);
348 return buf;
349 }
350 }
351 }
352
353 static DWORD
354 _error2vif(DWORD error) {
355 switch (error) {
356 case ERROR_ACCESS_DENIED:
357 return VIF_ACCESSVIOLATION;
358 case ERROR_SHARING_VIOLATION:
359 return VIF_SHARINGVIOLATION;
360 default:
361 return 0;
362 }
363 }
364
365
366 /******************************************************************************
367 * VerInstallFileA [VERSION.@]
368 */
369 DWORD WINAPI VerInstallFileA(
370 DWORD flags,LPSTR srcfilename,LPSTR destfilename,LPSTR srcdir,
371 LPSTR destdir,LPSTR curdir,LPSTR tmpfile,UINT *tmpfilelen )
372 {
373 LPCSTR pdest;
374 char destfn[260],tmpfn[260],srcfn[260];
375 HFILE hfsrc,hfdst;
376 DWORD attr,ret,xret,tmplast;
377 LPBYTE buf1,buf2;
378 OFSTRUCT ofs;
379
380 TRACE("(%x,%s,%s,%s,%s,%s,%p,%d)\n",
381 flags,srcfilename,destfilename,srcdir,destdir,curdir,tmpfile,*tmpfilelen
382 );
383 xret = 0;
384 sprintf(srcfn,"%s\\%s",srcdir,srcfilename);
385 if (!destdir || !*destdir) pdest = srcdir;
386 else pdest = destdir;
387 sprintf(destfn,"%s\\%s",pdest,destfilename);
388 hfsrc=LZOpenFileA(srcfn,&ofs,OF_READ);
389 if (hfsrc < 0)
390 return VIF_CANNOTREADSRC;
391 sprintf(tmpfn,"%s\\%s",pdest,destfilename);
392 tmplast=strlen(pdest)+1;
393 attr = GetFileAttributesA(tmpfn);
394 if (attr != INVALID_FILE_ATTRIBUTES) {
395 if (attr & FILE_ATTRIBUTE_READONLY) {
396 LZClose(hfsrc);
397 return VIF_WRITEPROT;
398 }
399 /* FIXME: check if file currently in use and return VIF_FILEINUSE */
400 }
401 attr = INVALID_FILE_ATTRIBUTES;
402 if (flags & VIFF_FORCEINSTALL) {
403 if (tmpfile[0]) {
404 sprintf(tmpfn,"%s\\%s",pdest,tmpfile);
405 tmplast = strlen(pdest)+1;
406 attr = GetFileAttributesA(tmpfn);
407 /* if it exists, it has been copied by the call before.
408 * we jump over the copy part...
409 */
410 }
411 }
412 if (attr == INVALID_FILE_ATTRIBUTES) {
413 char *s;
414
415 GetTempFileNameA(pdest,"ver",0,tmpfn); /* should not fail ... */
416 s=strrchr(tmpfn,'\\');
417 if (s)
418 tmplast = s-tmpfn;
419 else
420 tmplast = 0;
421 hfdst = OpenFile(tmpfn,&ofs,OF_CREATE);
422 if (hfdst == HFILE_ERROR) {
423 LZClose(hfsrc);
424 return VIF_CANNOTCREATE; /* | translated dos error */
425 }
426 ret = LZCopy(hfsrc,hfdst);
427 _lclose(hfdst);
428 if (((long) ret) < 0) {
429 /* translate LZ errors into VIF_xxx */
430 switch (ret) {
431 case LZERROR_BADINHANDLE:
432 case LZERROR_READ:
433 case LZERROR_BADVALUE:
434 case LZERROR_UNKNOWNALG:
435 ret = VIF_CANNOTREADSRC;
436 break;
437 case LZERROR_BADOUTHANDLE:
438 case LZERROR_WRITE:
439 ret = VIF_OUTOFSPACE;
440 break;
441 case LZERROR_GLOBALLOC:
442 case LZERROR_GLOBLOCK:
443 ret = VIF_OUTOFMEMORY;
444 break;
445 default: /* unknown error, should not happen */
446 ret = 0;
447 break;
448 }
449 if (ret) {
450 LZClose(hfsrc);
451 return ret;
452 }
453 }
454 }
455 xret = 0;
456 if (!(flags & VIFF_FORCEINSTALL)) {
457 VS_FIXEDFILEINFO *destvffi,*tmpvffi;
458 buf1 = _fetch_versioninfo(destfn,&destvffi);
459 if (buf1) {
460 buf2 = _fetch_versioninfo(tmpfn,&tmpvffi);
461 if (buf2) {
462 char *tbuf1,*tbuf2;
463 UINT len1,len2;
464
465 len1=len2=40;
466
467 /* compare file versions */
468 if ((destvffi->dwFileVersionMS > tmpvffi->dwFileVersionMS)||
469 ((destvffi->dwFileVersionMS==tmpvffi->dwFileVersionMS)&&
470 (destvffi->dwFileVersionLS > tmpvffi->dwFileVersionLS)
471 )
472 )
473 xret |= VIF_MISMATCH|VIF_SRCOLD;
474 /* compare filetypes and filesubtypes */
475 if ((destvffi->dwFileType!=tmpvffi->dwFileType) ||
476 (destvffi->dwFileSubtype!=tmpvffi->dwFileSubtype)
477 )
478 xret |= VIF_MISMATCH|VIF_DIFFTYPE;
479 if (VerQueryValueA(buf1,"\\VarFileInfo\\Translation",(LPVOID*)&tbuf1,&len1) &&
480 VerQueryValueA(buf2,"\\VarFileInfo\\Translation",(LPVOID*)&tbuf2,&len2)
481 ) {
482 /* irgendwas mit tbuf1 und tbuf2 machen
483 * generiert DIFFLANG|MISMATCH
484 */
485 }
486 HeapFree(GetProcessHeap(), 0, buf2);
487 } else
488 xret=VIF_MISMATCH|VIF_SRCOLD;
489 HeapFree(GetProcessHeap(), 0, buf1);
490 }
491 }
492 if (xret) {
493 if (*tmpfilelen<strlen(tmpfn+tmplast)) {
494 xret|=VIF_BUFFTOOSMALL;
495 DeleteFileA(tmpfn);
496 } else {
497 strcpy(tmpfile,tmpfn+tmplast);
498 *tmpfilelen = strlen(tmpfn+tmplast)+1;
499 xret|=VIF_TEMPFILE;
500 }
501 } else {
502 if (-1!=GetFileAttributesA(destfn))
503 if (!DeleteFileA(destfn)) {
504 xret|=_error2vif(GetLastError())|VIF_CANNOTDELETE;
505 DeleteFileA(tmpfn);
506 LZClose(hfsrc);
507 return xret;
508 }
509 if ((!(flags & VIFF_DONTDELETEOLD)) &&
510 curdir &&
511 *curdir &&
512 lstrcmpiA(curdir,pdest)
513 ) {
514 char curfn[260];
515
516 sprintf(curfn,"%s\\%s",curdir,destfilename);
517 if (INVALID_FILE_ATTRIBUTES != GetFileAttributesA(curfn)) {
518 /* FIXME: check if in use ... if it is, VIF_CANNOTDELETECUR */
519 if (!DeleteFileA(curfn))
520 xret|=_error2vif(GetLastError())|VIF_CANNOTDELETECUR;
521 }
522 }
523 if (!MoveFileA(tmpfn,destfn)) {
524 xret|=_error2vif(GetLastError())|VIF_CANNOTRENAME;
525 DeleteFileA(tmpfn);
526 }
527 }
528 LZClose(hfsrc);
529 return xret;
530 }
531
532
533 /******************************************************************************
534 * VerInstallFileW [VERSION.@]
535 */
536 DWORD WINAPI VerInstallFileW(
537 DWORD flags,LPWSTR srcfilename,LPWSTR destfilename,LPWSTR srcdir,
538 LPWSTR destdir,LPWSTR curdir,LPWSTR tmpfile,UINT *tmpfilelen )
539 {
540 LPSTR wsrcf = NULL, wsrcd = NULL, wdestf = NULL, wdestd = NULL, wtmpf = NULL, wcurd = NULL;
541 DWORD ret;
542 UINT len;
543
544 if (srcfilename)
545 {
546 len = WideCharToMultiByte( CP_ACP, 0, srcfilename, -1, NULL, 0, NULL, NULL );
547 if ((wsrcf = HeapAlloc( GetProcessHeap(), 0, len )))
548 WideCharToMultiByte( CP_ACP, 0, srcfilename, -1, wsrcf, len, NULL, NULL );
549 }
550 if (srcdir)
551 {
552 len = WideCharToMultiByte( CP_ACP, 0, srcdir, -1, NULL, 0, NULL, NULL );
553 if ((wsrcd = HeapAlloc( GetProcessHeap(), 0, len )))
554 WideCharToMultiByte( CP_ACP, 0, srcdir, -1, wsrcd, len, NULL, NULL );
555 }
556 if (destfilename)
557 {
558 len = WideCharToMultiByte( CP_ACP, 0, destfilename, -1, NULL, 0, NULL, NULL );
559 if ((wdestf = HeapAlloc( GetProcessHeap(), 0, len )))
560 WideCharToMultiByte( CP_ACP, 0, destfilename, -1, wdestf, len, NULL, NULL );
561 }
562 if (destdir)
563 {
564 len = WideCharToMultiByte( CP_ACP, 0, destdir, -1, NULL, 0, NULL, NULL );
565 if ((wdestd = HeapAlloc( GetProcessHeap(), 0, len )))
566 WideCharToMultiByte( CP_ACP, 0, destdir, -1, wdestd, len, NULL, NULL );
567 }
568 if (curdir)
569 {
570 len = WideCharToMultiByte( CP_ACP, 0, curdir, -1, NULL, 0, NULL, NULL );
571 if ((wcurd = HeapAlloc( GetProcessHeap(), 0, len )))
572 WideCharToMultiByte( CP_ACP, 0, curdir, -1, wcurd, len, NULL, NULL );
573 }
574 len = *tmpfilelen * sizeof(WCHAR);
575 wtmpf = HeapAlloc( GetProcessHeap(), 0, len );
576 ret = VerInstallFileA(flags,wsrcf,wdestf,wsrcd,wdestd,wcurd,wtmpf,&len);
577 if (!ret)
578 *tmpfilelen = MultiByteToWideChar( CP_ACP, 0, wtmpf, -1, tmpfile, *tmpfilelen );
579 else if (ret & VIF_BUFFTOOSMALL)
580 *tmpfilelen = len; /* FIXME: not correct */
581
582 HeapFree( GetProcessHeap(), 0, wsrcf );
583 HeapFree( GetProcessHeap(), 0, wsrcd );
584 HeapFree( GetProcessHeap(), 0, wdestf );
585 HeapFree( GetProcessHeap(), 0, wdestd );
586 HeapFree( GetProcessHeap(), 0, wtmpf );
587 HeapFree( GetProcessHeap(), 0, wcurd );
588 return ret;
589 }