Started porting Setupapi.dll from WINE to ReactOS.
[reactos.git] / reactos / lib / setupapi / setupx_main.c
1 /*
2 * SETUPX library
3 *
4 * Copyright 1998,2000 Andreas Mohr
5 *
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.
10 *
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.
15 *
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 *
20 * FIXME: Rather non-functional functions for now.
21 *
22 * See:
23 * http://www.geocities.com/SiliconValley/Network/5317/drivers.html
24 * http://willemer.de/informatik/windows/inf_info.htm (German)
25 * http://www.microsoft.com/ddk/ddkdocs/win98ddk/devinst_12uw.htm
26 * DDK: setupx.h
27 * http://mmatrix.tripod.com/customsystemfolder/infsysntaxfull.html
28 * http://www.rdrop.com/~cary/html/inf_faq.html
29 * http://support.microsoft.com/support/kb/articles/q194/6/40.asp
30 *
31 * Stuff tested with:
32 * - rs405deu.exe (German Acroread 4.05 setup)
33 * - ie5setup.exe
34 * - Netmeeting
35 *
36 * FIXME:
37 * - string handling is... weird ;) (buflen etc.)
38 * - memory leaks ?
39 * - separate that mess (but probably only when it's done completely)
40 *
41 * SETUPX consists of several parts with the following acronyms/prefixes:
42 * Di device installer (devinst.c ?)
43 * Gen generic installer (geninst.c ?)
44 * Ip .INF parsing (infparse.c)
45 * LDD logical device descriptor (ldd.c ?)
46 * LDID logical device ID
47 * SU setup (setup.c ?)
48 * Tp text processing (textproc.c ?)
49 * Vcp virtual copy module (vcp.c ?)
50 * ...
51 *
52 * The SETUPX DLL is NOT thread-safe. That's why many installers urge you to
53 * "close all open applications".
54 * All in all the design of it seems to be a bit weak.
55 * Not sure whether my implementation of it is better, though ;-)
56 */
57
58 #include <stdlib.h>
59 #include <stdarg.h>
60 #include <stdio.h>
61 #include <string.h>
62 #include "windef.h"
63 #include "winbase.h"
64 #include "winreg.h"
65 #include "winerror.h"
66 #include "wine/winuser16.h"
67 #include "wownt32.h"
68 #include "wingdi.h"
69 #include "winuser.h"
70 #include "winnls.h"
71 #include "setupapi.h"
72 #include "setupx16.h"
73 #include "setupapi_private.h"
74 #include "winerror.h"
75 #include "wine/debug.h"
76
77 WINE_DEFAULT_DEBUG_CHANNEL(setupapi);
78
79 /***********************************************************************
80 * SURegOpenKey (SETUPX.47)
81 */
82 DWORD WINAPI SURegOpenKey( HKEY hkey, LPCSTR lpszSubKey, PHKEY retkey )
83 {
84 FIXME("(%p,%s,%p), semi-stub.\n",hkey,debugstr_a(lpszSubKey),retkey);
85 return RegOpenKeyA( hkey, lpszSubKey, retkey );
86 }
87
88 /***********************************************************************
89 * SURegQueryValueEx (SETUPX.50)
90 */
91 DWORD WINAPI SURegQueryValueEx( HKEY hkey, LPSTR lpszValueName,
92 LPDWORD lpdwReserved, LPDWORD lpdwType,
93 LPBYTE lpbData, LPDWORD lpcbData )
94 {
95 FIXME("(%p,%s,%p,%p,%p,%ld), semi-stub.\n",hkey,debugstr_a(lpszValueName),
96 lpdwReserved,lpdwType,lpbData,lpcbData?*lpcbData:0);
97 return RegQueryValueExA( hkey, lpszValueName, lpdwReserved, lpdwType,
98 lpbData, lpcbData );
99 }
100
101 /*
102 * Returns pointer to a string list with the first entry being number
103 * of strings.
104 *
105 * Hmm. Should this be InitSubstrData(), GetFirstSubstr() and GetNextSubstr()
106 * instead?
107 */
108 static LPSTR *SETUPX_GetSubStrings(LPSTR start, char delimiter)
109 {
110 LPSTR p, q;
111 LPSTR *res = NULL;
112 DWORD count = 0;
113 int len;
114
115 p = start;
116
117 while (1)
118 {
119 /* find beginning of real substring */
120 while ( (*p == ' ') || (*p == '\t') || (*p == '"') ) p++;
121
122 /* find end of real substring */
123 q = p;
124 while ( (*q)
125 && (*q != ' ') && (*q != '\t') && (*q != '"')
126 && (*q != ';') && (*q != delimiter) ) q++;
127 if (q == p)
128 break;
129 len = (int)q - (int)p;
130
131 /* alloc entry for new substring in steps of 32 units and copy over */
132 if (count % 32 == 0)
133 { /* 1 for count field + current count + 32 */
134 if (res)
135 res = HeapReAlloc(GetProcessHeap(), 0, res, (1+count+32)*sizeof(LPSTR));
136 else
137 res = HeapAlloc(GetProcessHeap(), 0, (1+count+32)*sizeof(LPSTR));
138 }
139 *(res+1+count) = HeapAlloc(GetProcessHeap(), 0, len+1);
140 strncpy(*(res+1+count), p, len);
141 (*(res+1+count))[len] = '\0';
142 count++;
143
144 /* we are still within last substring (before delimiter),
145 * so get out of it */
146 while ((*q) && (*q != ';') && (*q != delimiter)) q++;
147 if ((!*q) || (*q == ';'))
148 break;
149 p = q+1;
150 }
151
152 /* put number of entries at beginning of list */
153 *(DWORD *)res = count;
154 return res;
155 }
156
157 static void SETUPX_FreeSubStrings(LPSTR *substr)
158 {
159 DWORD count = *(DWORD *)substr;
160 LPSTR *pStrings = substr+1;
161 DWORD n;
162
163 for (n=0; n < count; n++)
164 HeapFree(GetProcessHeap(), 0, *pStrings++);
165
166 HeapFree(GetProcessHeap(), 0, substr);
167 }
168
169
170 /***********************************************************************
171 * InstallHinfSection (SETUPX.527)
172 *
173 * hwnd = parent window
174 * hinst = instance of SETUPX.DLL
175 * lpszCmdLine = e.g. "DefaultInstall 132 C:\MYINSTALL\MYDEV.INF"
176 * Here "DefaultInstall" is the .inf file section to be installed (optional).
177 * The 132 value is made of the HOW_xxx flags and sometimes 128 (-> setupx16.h).
178 *
179 * nCmdShow = nCmdShow of CreateProcess
180 */
181 RETERR16 WINAPI InstallHinfSection16( HWND16 hwnd, HINSTANCE16 hinst, LPCSTR lpszCmdLine, INT16 nCmdShow)
182 {
183 LPSTR *pSub;
184 DWORD count;
185 HINF16 hInf = 0;
186 RETERR16 res = OK, tmp;
187 WORD wFlags;
188 BOOL reboot = FALSE;
189
190 TRACE("(%04x, %04x, %s, %d);\n", hwnd, hinst, lpszCmdLine, nCmdShow);
191
192 pSub = SETUPX_GetSubStrings((LPSTR)lpszCmdLine, ' ');
193
194 count = *(DWORD *)pSub;
195 if (count < 2) /* invalid number of arguments ? */
196 goto end;
197 if (IpOpen16(*(pSub+count), &hInf) != OK)
198 {
199 res = ERROR_FILE_NOT_FOUND; /* yes, correct */
200 goto end;
201 }
202 if (VcpOpen16(NULL, 0))
203 goto end;
204 if (GenInstall16(hInf, *(pSub+count-2), GENINSTALL_DO_ALL) != OK)
205 goto end;
206 wFlags = atoi(*(pSub+count-1)) & ~128;
207 switch (wFlags)
208 {
209 case HOW_ALWAYS_SILENT_REBOOT:
210 case HOW_SILENT_REBOOT:
211 reboot = TRUE;
212 break;
213 case HOW_ALWAYS_PROMPT_REBOOT:
214 case HOW_PROMPT_REBOOT:
215 if (MessageBoxA(HWND_32(hwnd), "You must restart Wine before the new settings will take effect.\n\nDo you want to exit Wine now ?", "Systems Settings Change", MB_YESNO|MB_ICONQUESTION) == IDYES)
216 reboot = TRUE;
217 break;
218 default:
219 ERR("invalid flags %d !\n", wFlags);
220 goto end;
221 }
222
223 res = OK;
224 end:
225 tmp = VcpClose16(VCPFL_ALL, NULL);
226 if (tmp != OK)
227 res = tmp;
228 tmp = IpClose16(hInf);
229 if (tmp != OK)
230 res = tmp;
231 SETUPX_FreeSubStrings(pSub);
232 if (reboot)
233 {
234 /* FIXME: we should have a means of terminating all wine + wineserver */
235 MESSAGE("Program or user told me to restart. Exiting Wine...\n");
236 ExitProcess(1);
237 }
238
239 return res;
240 }
241
242 typedef struct
243 {
244 LPCSTR RegValName;
245 LPCSTR StdString; /* fallback string; sub dir of windows directory */
246 } LDID_DATA;
247
248 static const LDID_DATA LDID_Data[34] =
249 {
250 { /* 0 (LDID_NULL) -- not defined */
251 NULL,
252 NULL
253 },
254 { /* 1 (LDID_SRCPATH) = source of installation. hmm, what to do here ? */
255 "SourcePath", /* hmm, does SETUPX have to care about updating it ?? */
256 NULL
257 },
258 { /* 2 (LDID_SETUPTEMP) = setup temp dir */
259 "SetupTempDir",
260 NULL
261 },
262 { /* 3 (LDID_UNINSTALL) = uninstall backup dir */
263 "UninstallDir",
264 NULL
265 },
266 { /* 4 (LDID_BACKUP) = backup dir */
267 "BackupDir",
268 NULL
269 },
270 { /* 5 (LDID_SETUPSCRATCH) = setup scratch dir */
271 "SetupScratchDir",
272 NULL
273 },
274 { /* 6 -- not defined */
275 NULL,
276 NULL
277 },
278 { /* 7 -- not defined */
279 NULL,
280 NULL
281 },
282 { /* 8 -- not defined */
283 NULL,
284 NULL
285 },
286 { /* 9 -- not defined */
287 NULL,
288 NULL
289 },
290 { /* 10 (LDID_WIN) = windows dir */
291 "WinDir",
292 ""
293 },
294 { /* 11 (LDID_SYS) = system dir */
295 "SysDir",
296 NULL /* call GetSystemDirectory() instead */
297 },
298 { /* 12 (LDID_IOS) = IOSubSys dir */
299 NULL, /* FIXME: registry string ? */
300 "SYSTEM\\IOSUBSYS"
301 },
302 { /* 13 (LDID_CMD) = COMMAND dir */
303 NULL, /* FIXME: registry string ? */
304 "COMMAND"
305 },
306 { /* 14 (LDID_CPL) = control panel dir */
307 NULL,
308 ""
309 },
310 { /* 15 (LDID_PRINT) = windows printer dir */
311 NULL,
312 "SYSTEM" /* correct ?? */
313 },
314 { /* 16 (LDID_MAIL) = destination mail dir */
315 NULL,
316 ""
317 },
318 { /* 17 (LDID_INF) = INF dir */
319 "SetupScratchDir", /* correct ? */
320 "INF"
321 },
322 { /* 18 (LDID_HELP) = HELP dir */
323 NULL, /* ??? */
324 "HELP"
325 },
326 { /* 19 (LDID_WINADMIN) = Admin dir */
327 "WinAdminDir",
328 ""
329 },
330 { /* 20 (LDID_FONTS) = Fonts dir */
331 NULL, /* ??? */
332 "FONTS"
333 },
334 { /* 21 (LDID_VIEWERS) = Viewers */
335 NULL, /* ??? */
336 "SYSTEM\\VIEWERS"
337 },
338 { /* 22 (LDID_VMM32) = VMM32 dir */
339 NULL, /* ??? */
340 "SYSTEM\\VMM32"
341 },
342 { /* 23 (LDID_COLOR) = ICM dir */
343 "ICMPath",
344 "SYSTEM\\COLOR"
345 },
346 { /* 24 (LDID_APPS) = root of boot drive ? */
347 "AppsDir",
348 "C:\\"
349 },
350 { /* 25 (LDID_SHARED) = shared dir */
351 "SharedDir",
352 ""
353 },
354 { /* 26 (LDID_WINBOOT) = Windows boot dir */
355 "WinBootDir",
356 ""
357 },
358 { /* 27 (LDID_MACHINE) = machine specific files */
359 "MachineDir",
360 NULL
361 },
362 { /* 28 (LDID_HOST_WINBOOT) = Host Windows boot dir */
363 "HostWinBootDir",
364 NULL
365 },
366 { /* 29 -- not defined */
367 NULL,
368 NULL
369 },
370 { /* 30 (LDID_BOOT) = Root of boot drive */
371 "BootDir",
372 NULL
373 },
374 { /* 31 (LDID_BOOT_HOST) = Root of boot drive host */
375 "BootHost",
376 NULL
377 },
378 { /* 32 (LDID_OLD_WINBOOT) = subdir of root */
379 "OldWinBootDir",
380 NULL
381 },
382 { /* 33 (LDID_OLD_WIN) = old win dir */
383 "OldWinDir",
384 NULL
385 }
386 /* the rest (34-38) isn't too interesting, so I'll forget about it */
387 };
388
389 /*
390 * LDD == Logical Device Descriptor
391 * LDID == Logical Device ID
392 *
393 * The whole LDD/LDID business might go into a separate file named
394 * ldd.c.
395 * At the moment I don't know what the hell these functions are really doing.
396 * That's why I added reporting stubs.
397 * The only thing I do know is that I need them for the LDD/LDID infrastructure.
398 * That's why I implemented them in a way that's suitable for my purpose.
399 */
400 static LDD_LIST *pFirstLDD = NULL;
401
402 static BOOL std_LDDs_done = FALSE;
403
404 void SETUPX_CreateStandardLDDs(void)
405 {
406 HKEY hKey = 0;
407 WORD n;
408 DWORD type, len;
409 LOGDISKDESC_S ldd;
410 char buffer[MAX_PATH];
411
412 /* has to be here, otherwise loop */
413 std_LDDs_done = TRUE;
414
415 RegOpenKeyA(HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Setup", &hKey);
416
417 for (n=0; n < sizeof(LDID_Data)/sizeof(LDID_DATA); n++)
418 {
419 buffer[0] = '\0';
420
421 len = MAX_PATH;
422 if ( (hKey) && (LDID_Data[n].RegValName)
423 && (RegQueryValueExA(hKey, LDID_Data[n].RegValName,
424 NULL, &type, buffer, &len) == ERROR_SUCCESS)
425 && (type == REG_SZ) )
426 {
427 TRACE("found value '%s' for LDID %d\n", buffer, n);
428 }
429 else
430 switch(n)
431 {
432 case LDID_SRCPATH:
433 FIXME("LDID_SRCPATH: what exactly do we have to do here ?\n");
434 strcpy(buffer, "X:\\FIXME");
435 break;
436 case LDID_SYS:
437 GetSystemDirectoryA(buffer, MAX_PATH);
438 break;
439 case LDID_APPS:
440 case LDID_MACHINE:
441 case LDID_HOST_WINBOOT:
442 case LDID_BOOT:
443 case LDID_BOOT_HOST:
444 strcpy(buffer, "C:\\");
445 break;
446 default:
447 if (LDID_Data[n].StdString)
448 {
449 DWORD len = GetWindowsDirectoryA(buffer, MAX_PATH);
450 LPSTR p;
451 p = buffer + len;
452 *p++ = '\\';
453 strcpy(p, LDID_Data[n].StdString);
454 }
455 break;
456 }
457 if (buffer[0])
458 {
459 INIT_LDD(ldd, n);
460 ldd.pszPath = buffer;
461 TRACE("LDID %d -> '%s'\n", ldd.ldid, ldd.pszPath);
462 CtlSetLdd16(&ldd);
463 }
464 }
465 if (hKey) RegCloseKey(hKey);
466 }
467
468 /***********************************************************************
469 * CtlDelLdd (SETUPX.37)
470 *
471 * RETURN
472 * ERR_VCP_LDDINVALID if ldid < LDID_ASSIGN_START.
473 */
474 RETERR16 SETUPX_DelLdd(LOGDISKID16 ldid)
475 {
476 LDD_LIST *pCurr, *pPrev = NULL;
477
478 TRACE("(%d)\n", ldid);
479
480 if (!std_LDDs_done)
481 SETUPX_CreateStandardLDDs();
482
483 if (ldid < LDID_ASSIGN_START)
484 return ERR_VCP_LDDINVALID;
485
486 pCurr = pFirstLDD;
487 /* search until we find the appropriate LDD or hit the end */
488 while ((pCurr != NULL) && (ldid > pCurr->pldd->ldid))
489 {
490 pPrev = pCurr;
491 pCurr = pCurr->next;
492 }
493 if ( (pCurr == NULL) /* hit end of list */
494 || (ldid != pCurr->pldd->ldid) )
495 return ERR_VCP_LDDFIND; /* correct ? */
496
497 /* ok, found our victim: eliminate it */
498
499 if (pPrev)
500 pPrev->next = pCurr->next;
501
502 if (pCurr == pFirstLDD)
503 pFirstLDD = NULL;
504 HeapFree(GetProcessHeap(), 0, pCurr);
505
506 return OK;
507 }
508
509 /***********************************************************************
510 * CtlDelLdd (SETUPX.37)
511 */
512 RETERR16 WINAPI CtlDelLdd16(LOGDISKID16 ldid)
513 {
514 FIXME("(%d); - please report this!\n", ldid);
515 return SETUPX_DelLdd(ldid);
516 }
517
518 /***********************************************************************
519 * CtlFindLdd (SETUPX.35)
520 *
521 * doesn't check pldd ptr validity: crash (W98SE)
522 *
523 * RETURN
524 * ERR_VCP_LDDINVALID if pldd->cbSize != structsize
525 * 1 in all other cases ??
526 *
527 */
528 RETERR16 WINAPI CtlFindLdd16(LPLOGDISKDESC pldd)
529 {
530 LDD_LIST *pCurr, *pPrev = NULL;
531
532 TRACE("(%p)\n", pldd);
533
534 if (!std_LDDs_done)
535 SETUPX_CreateStandardLDDs();
536
537 if (pldd->cbSize != sizeof(LOGDISKDESC_S))
538 return ERR_VCP_LDDINVALID;
539
540 pCurr = pFirstLDD;
541 /* search until we find the appropriate LDD or hit the end */
542 while ((pCurr != NULL) && (pldd->ldid > pCurr->pldd->ldid))
543 {
544 pPrev = pCurr;
545 pCurr = pCurr->next;
546 }
547 if ( (pCurr == NULL) /* hit end of list */
548 || (pldd->ldid != pCurr->pldd->ldid) )
549 return ERR_VCP_LDDFIND; /* correct ? */
550
551 memcpy(pldd, pCurr->pldd, pldd->cbSize);
552 /* hmm, we probably ought to strcpy() the string ptrs here */
553
554 return 1; /* what is this ?? */
555 }
556
557 /***********************************************************************
558 * CtlSetLdd (SETUPX.33)
559 *
560 * Set an LDD entry.
561 *
562 * RETURN
563 * ERR_VCP_LDDINVALID if pldd.cbSize != sizeof(LOGDISKDESC_S)
564 *
565 */
566 RETERR16 WINAPI CtlSetLdd16(LPLOGDISKDESC pldd)
567 {
568 LDD_LIST *pCurr, *pPrev = NULL;
569 LPLOGDISKDESC pCurrLDD;
570 HANDLE heap;
571 BOOL is_new = FALSE;
572
573 TRACE("(%p)\n", pldd);
574
575 if (!std_LDDs_done)
576 SETUPX_CreateStandardLDDs();
577
578 if (pldd->cbSize != sizeof(LOGDISKDESC_S))
579 return ERR_VCP_LDDINVALID;
580
581 heap = GetProcessHeap();
582 pCurr = pFirstLDD;
583 /* search until we find the appropriate LDD or hit the end */
584 while ((pCurr != NULL) && (pldd->ldid > pCurr->pldd->ldid))
585 {
586 pPrev = pCurr;
587 pCurr = pCurr->next;
588 }
589 if (!pCurr || pldd->ldid != pCurr->pldd->ldid)
590 {
591 is_new = TRUE;
592 pCurr = HeapAlloc(heap, 0, sizeof(LDD_LIST));
593 pCurr->pldd = HeapAlloc(heap, 0, sizeof(LOGDISKDESC_S));
594 pCurr->next = NULL;
595 pCurrLDD = pCurr->pldd;
596 }
597 else
598 {
599 pCurrLDD = pCurr->pldd;
600 if (pCurrLDD->pszPath) HeapFree(heap, 0, pCurrLDD->pszPath);
601 if (pCurrLDD->pszVolLabel) HeapFree(heap, 0, pCurrLDD->pszVolLabel);
602 if (pCurrLDD->pszDiskName) HeapFree(heap, 0, pCurrLDD->pszDiskName);
603 }
604
605 memcpy(pCurrLDD, pldd, sizeof(LOGDISKDESC_S));
606
607 if (pldd->pszPath)
608 {
609 pCurrLDD->pszPath = HeapAlloc( heap, 0, strlen(pldd->pszPath)+1 );
610 strcpy( pCurrLDD->pszPath, pldd->pszPath );
611 }
612 if (pldd->pszVolLabel)
613 {
614 pCurrLDD->pszVolLabel = HeapAlloc( heap, 0, strlen(pldd->pszVolLabel)+1 );
615 strcpy( pCurrLDD->pszVolLabel, pldd->pszVolLabel );
616 }
617 if (pldd->pszDiskName)
618 {
619 pCurrLDD->pszDiskName = HeapAlloc( heap, 0, strlen(pldd->pszDiskName)+1 );
620 strcpy( pCurrLDD->pszDiskName, pldd->pszDiskName );
621 }
622
623 if (is_new) /* link into list */
624 {
625 if (pPrev)
626 {
627 pCurr->next = pPrev->next;
628 pPrev->next = pCurr;
629 }
630 if (!pFirstLDD)
631 pFirstLDD = pCurr;
632 }
633
634 return OK;
635 }
636
637
638 /***********************************************************************
639 * CtlAddLdd (SETUPX.36)
640 *
641 * doesn't check pldd ptr validity: crash (W98SE)
642 *
643 */
644 static LOGDISKID16 ldid_to_add = LDID_ASSIGN_START;
645 RETERR16 WINAPI CtlAddLdd16(LPLOGDISKDESC pldd)
646 {
647 pldd->ldid = ldid_to_add++;
648 return CtlSetLdd16(pldd);
649 }
650
651 /***********************************************************************
652 * CtlGetLdd (SETUPX.34)
653 *
654 * doesn't check pldd ptr validity: crash (W98SE)
655 * What the !@#$%&*( is the difference between CtlFindLdd() and CtlGetLdd() ??
656 *
657 * RETURN
658 * ERR_VCP_LDDINVALID if pldd->cbSize != structsize
659 *
660 */
661 static RETERR16 SETUPX_GetLdd(LPLOGDISKDESC pldd)
662 {
663 LDD_LIST *pCurr, *pPrev = NULL;
664
665 if (!std_LDDs_done)
666 SETUPX_CreateStandardLDDs();
667
668 if (pldd->cbSize != sizeof(LOGDISKDESC_S))
669 return ERR_VCP_LDDINVALID;
670
671 pCurr = pFirstLDD;
672 /* search until we find the appropriate LDD or hit the end */
673 while ((pCurr != NULL) && (pldd->ldid > pCurr->pldd->ldid))
674 {
675 pPrev = pCurr;
676 pCurr = pCurr->next;
677 }
678 if (pCurr == NULL) /* hit end of list */
679 return ERR_VCP_LDDFIND; /* correct ? */
680
681 memcpy(pldd, pCurr->pldd, pldd->cbSize);
682 /* hmm, we probably ought to strcpy() the string ptrs here */
683
684 return OK;
685 }
686
687 /**********************************************************************/
688
689 RETERR16 WINAPI CtlGetLdd16(LPLOGDISKDESC pldd)
690 {
691 FIXME("(%p); - please report this!\n", pldd);
692 return SETUPX_GetLdd(pldd);
693 }
694
695 /***********************************************************************
696 * CtlGetLddPath (SETUPX.38)
697 *
698 * Gets the path of an LDD.
699 * No crash if szPath == NULL.
700 * szPath has to be at least MAX_PATH_LEN bytes long.
701 * RETURN
702 * ERR_VCP_LDDUNINIT if LDD for LDID not found.
703 */
704 RETERR16 WINAPI CtlGetLddPath16(LOGDISKID16 ldid, LPSTR szPath)
705 {
706 TRACE("(%d, %p);\n", ldid, szPath);
707
708 if (szPath)
709 {
710 LOGDISKDESC_S ldd;
711 INIT_LDD(ldd, ldid);
712 if (CtlFindLdd16(&ldd) == ERR_VCP_LDDFIND)
713 return ERR_VCP_LDDUNINIT;
714 SETUPX_GetLdd(&ldd);
715 strcpy(szPath, ldd.pszPath);
716 TRACE("ret '%s' for LDID %d\n", szPath, ldid);
717 }
718 return OK;
719 }
720
721 /***********************************************************************
722 * CtlSetLddPath (SETUPX.508)
723 *
724 * Sets the path of an LDD.
725 * Creates LDD for LDID if not existing yet.
726 */
727 RETERR16 WINAPI CtlSetLddPath16(LOGDISKID16 ldid, LPSTR szPath)
728 {
729 LOGDISKDESC_S ldd;
730 TRACE("(%d, '%s');\n", ldid, szPath);
731
732 SetupSetDirectoryIdA( 0, ldid, szPath );
733 INIT_LDD(ldd, ldid);
734 ldd.pszPath = szPath;
735 return CtlSetLdd16(&ldd);
736 }