Fix the case of product and company names.
[wine] / dlls / 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             res = HeapReAlloc(GetProcessHeap(), 0, res, (1+count+32)*sizeof(LPSTR));
135         }
136         *(res+1+count) = HeapAlloc(GetProcessHeap(), 0, len+1);
137         strncpy(*(res+1+count), p, len);
138         (*(res+1+count))[len] = '\0';
139         count++;
140
141         /* we are still within last substring (before delimiter),
142          * so get out of it */
143         while ((*q) && (*q != ';') && (*q != delimiter)) q++;
144         if ((!*q) || (*q == ';'))
145             break;
146         p = q+1;
147     }
148
149     /* put number of entries at beginning of list */
150     *(DWORD *)res = count;
151     return res;
152 }
153
154 static void SETUPX_FreeSubStrings(LPSTR *substr)
155 {
156     DWORD count = *(DWORD *)substr;
157     LPSTR *pStrings = substr+1;
158     DWORD n;
159
160     for (n=0; n < count; n++)
161         HeapFree(GetProcessHeap(), 0, *pStrings++);
162
163     HeapFree(GetProcessHeap(), 0, substr);
164 }
165
166
167 /***********************************************************************
168  *              InstallHinfSection (SETUPX.527)
169  *
170  * hwnd = parent window
171  * hinst = instance of SETUPX.DLL
172  * lpszCmdLine = e.g. "DefaultInstall 132 C:\MYINSTALL\MYDEV.INF"
173  * Here "DefaultInstall" is the .inf file section to be installed (optional).
174  * The 132 value is made of the HOW_xxx flags and sometimes 128 (-> setupx16.h).
175  *
176  * nCmdShow = nCmdShow of CreateProcess
177  */
178 RETERR16 WINAPI InstallHinfSection16( HWND16 hwnd, HINSTANCE16 hinst, LPCSTR lpszCmdLine, INT16 nCmdShow)
179 {
180     LPSTR *pSub;
181     DWORD count;
182     HINF16 hInf = 0;
183     RETERR16 res = OK, tmp;
184     WORD wFlags;
185     BOOL reboot = FALSE;
186
187     TRACE("(%04x, %04x, %s, %d);\n", hwnd, hinst, lpszCmdLine, nCmdShow);
188
189     pSub = SETUPX_GetSubStrings((LPSTR)lpszCmdLine, ' ');
190
191     count = *(DWORD *)pSub;
192     if (count < 2) /* invalid number of arguments ? */
193         goto end;
194     if (IpOpen16(*(pSub+count), &hInf) != OK)
195     {
196         res = ERROR_FILE_NOT_FOUND; /* yes, correct */
197         goto end;
198     }
199     if (VcpOpen16(NULL, 0))
200         goto end;
201     if (GenInstall16(hInf, *(pSub+count-2), GENINSTALL_DO_ALL) != OK)
202         goto end;
203     wFlags = atoi(*(pSub+count-1)) & ~128;
204     switch (wFlags)
205     {
206         case HOW_ALWAYS_SILENT_REBOOT:
207         case HOW_SILENT_REBOOT:
208             reboot = TRUE;
209             break;
210         case HOW_ALWAYS_PROMPT_REBOOT:
211         case HOW_PROMPT_REBOOT:
212             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)
213                 reboot = TRUE;
214             break;
215         default:
216             ERR("invalid flags %d !\n", wFlags);
217             goto end;
218     }
219
220     res = OK;
221 end:
222     tmp = VcpClose16(VCPFL_ALL, NULL);
223     if (tmp != OK)
224         res = tmp;
225     tmp = IpClose16(hInf);
226     if (tmp != OK)
227         res = tmp;
228     SETUPX_FreeSubStrings(pSub);
229     if (reboot)
230     {
231         /* FIXME: we should have a means of terminating all wine + wineserver */
232         MESSAGE("Program or user told me to restart. Exiting Wine...\n");
233         ExitProcess(1);
234     }
235
236     return res;
237 }
238
239 typedef struct
240 {
241     LPCSTR RegValName;
242     LPCSTR StdString; /* fallback string; sub dir of windows directory */
243 } LDID_DATA;
244
245 static const LDID_DATA LDID_Data[34] =
246 {
247     { /* 0 (LDID_NULL) -- not defined */
248         NULL,
249         NULL
250     },
251     { /* 1 (LDID_SRCPATH) = source of installation. hmm, what to do here ? */
252         "SourcePath", /* hmm, does SETUPX have to care about updating it ?? */
253         NULL
254     },
255     { /* 2 (LDID_SETUPTEMP) = setup temp dir */
256         "SetupTempDir",
257         NULL
258     },
259     { /* 3 (LDID_UNINSTALL) = uninstall backup dir */
260         "UninstallDir",
261         NULL
262     },
263     { /* 4 (LDID_BACKUP) = backup dir */
264         "BackupDir",
265         NULL
266     },
267     { /* 5 (LDID_SETUPSCRATCH) = setup scratch dir */
268         "SetupScratchDir",
269         NULL
270     },
271     { /* 6 -- not defined */
272         NULL,
273         NULL
274     },
275     { /* 7 -- not defined */
276         NULL,
277         NULL
278     },
279     { /* 8 -- not defined */
280         NULL,
281         NULL
282     },
283     { /* 9 -- not defined */
284         NULL,
285         NULL
286     },
287     { /* 10 (LDID_WIN) = windows dir */
288         "WinDir",
289         ""
290     },
291     { /* 11 (LDID_SYS) = system dir */
292         "SysDir",
293         NULL /* call GetSystemDirectory() instead */
294     },
295     { /* 12 (LDID_IOS) = IOSubSys dir */
296         NULL, /* FIXME: registry string ? */
297         "SYSTEM\\IOSUBSYS"
298     },
299     { /* 13 (LDID_CMD) = COMMAND dir */
300         NULL, /* FIXME: registry string ? */
301         "COMMAND"
302     },
303     { /* 14 (LDID_CPL) = control panel dir */
304         NULL,
305         ""
306     },
307     { /* 15 (LDID_PRINT) = windows printer dir */
308         NULL,
309         "SYSTEM" /* correct ?? */
310     },
311     { /* 16 (LDID_MAIL) = destination mail dir */
312         NULL,
313         ""
314     },
315     { /* 17 (LDID_INF) = INF dir */
316         "SetupScratchDir", /* correct ? */
317         "INF"
318     },
319     { /* 18 (LDID_HELP) = HELP dir */
320         NULL, /* ??? */
321         "HELP"
322     },
323     { /* 19 (LDID_WINADMIN) = Admin dir */
324         "WinAdminDir",
325         ""
326     },
327     { /* 20 (LDID_FONTS) = Fonts dir */
328         NULL, /* ??? */
329         "FONTS"
330     },
331     { /* 21 (LDID_VIEWERS) = Viewers */
332         NULL, /* ??? */
333         "SYSTEM\\VIEWERS"
334     },
335     { /* 22 (LDID_VMM32) = VMM32 dir */
336         NULL, /* ??? */
337         "SYSTEM\\VMM32"
338     },
339     { /* 23 (LDID_COLOR) = ICM dir */
340         "ICMPath",
341         "SYSTEM\\COLOR"
342     },
343     { /* 24 (LDID_APPS) = root of boot drive ? */
344         "AppsDir",
345         "C:\\"
346     },
347     { /* 25 (LDID_SHARED) = shared dir */
348         "SharedDir",
349         ""
350     },
351     { /* 26 (LDID_WINBOOT) = Windows boot dir */
352         "WinBootDir",
353         ""
354     },
355     { /* 27 (LDID_MACHINE) = machine specific files */
356         "MachineDir",
357         NULL
358     },
359     { /* 28 (LDID_HOST_WINBOOT) = Host Windows boot dir */
360         "HostWinBootDir",
361         NULL
362     },
363     { /* 29 -- not defined */
364         NULL,
365         NULL
366     },
367     { /* 30 (LDID_BOOT) = Root of boot drive */
368         "BootDir",
369         NULL
370     },
371     { /* 31 (LDID_BOOT_HOST) = Root of boot drive host */
372         "BootHost",
373         NULL
374     },
375     { /* 32 (LDID_OLD_WINBOOT) = subdir of root */
376         "OldWinBootDir",
377         NULL
378     },
379     { /* 33 (LDID_OLD_WIN) = old win dir */
380         "OldWinDir",
381         NULL
382     }
383     /* the rest (34-38) isn't too interesting, so I'll forget about it */
384 };
385
386 /*
387  * LDD  == Logical Device Descriptor
388  * LDID == Logical Device ID
389  *
390  * The whole LDD/LDID business might go into a separate file named
391  * ldd.c.
392  * At the moment I don't know what the hell these functions are really doing.
393  * That's why I added reporting stubs.
394  * The only thing I do know is that I need them for the LDD/LDID infrastructure.
395  * That's why I implemented them in a way that's suitable for my purpose.
396  */
397 static LDD_LIST *pFirstLDD = NULL;
398
399 static BOOL std_LDDs_done = FALSE;
400
401 void SETUPX_CreateStandardLDDs(void)
402 {
403     HKEY hKey = 0;
404     WORD n;
405     DWORD type, len;
406     LOGDISKDESC_S ldd;
407     char buffer[MAX_PATH];
408
409     /* has to be here, otherwise loop */
410     std_LDDs_done = TRUE;
411
412     RegOpenKeyA(HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Setup", &hKey);
413
414     for (n=0; n < sizeof(LDID_Data)/sizeof(LDID_DATA); n++)
415     {
416         buffer[0] = '\0';
417
418         len = MAX_PATH;
419         if ( (hKey) && (LDID_Data[n].RegValName)
420         &&   (RegQueryValueExA(hKey, LDID_Data[n].RegValName,
421                 NULL, &type, buffer, &len) == ERROR_SUCCESS)
422         &&   (type == REG_SZ) )
423         {
424             TRACE("found value '%s' for LDID %d\n", buffer, n);
425         }
426         else
427         switch(n)
428         {
429             case LDID_SRCPATH:
430                 FIXME("LDID_SRCPATH: what exactly do we have to do here ?\n");
431                 strcpy(buffer, "X:\\FIXME");
432                 break;
433             case LDID_SYS:
434                 GetSystemDirectoryA(buffer, MAX_PATH);
435                 break;
436             case LDID_APPS:
437             case LDID_MACHINE:
438             case LDID_HOST_WINBOOT:
439             case LDID_BOOT:
440             case LDID_BOOT_HOST:
441                 strcpy(buffer, "C:\\");
442                 break;
443             default:
444                 if (LDID_Data[n].StdString)
445                 {
446                     DWORD len = GetWindowsDirectoryA(buffer, MAX_PATH);
447                     LPSTR p;
448                     p = buffer + len;
449                     *p++ = '\\';
450                     strcpy(p, LDID_Data[n].StdString);
451                 }
452                 break;
453         }
454         if (buffer[0])
455         {
456             INIT_LDD(ldd, n);
457             ldd.pszPath = buffer;
458             TRACE("LDID %d -> '%s'\n", ldd.ldid, ldd.pszPath);
459             CtlSetLdd16(&ldd);
460         }
461     }
462     if (hKey) RegCloseKey(hKey);
463 }
464
465 /***********************************************************************
466  * CtlDelLdd            (SETUPX.37)
467  *
468  * RETURN
469  *   ERR_VCP_LDDINVALID if ldid < LDID_ASSIGN_START.
470  */
471 RETERR16 SETUPX_DelLdd(LOGDISKID16 ldid)
472 {
473     LDD_LIST *pCurr, *pPrev = NULL;
474
475     TRACE("(%d)\n", ldid);
476
477     if (!std_LDDs_done)
478         SETUPX_CreateStandardLDDs();
479
480     if (ldid < LDID_ASSIGN_START)
481         return ERR_VCP_LDDINVALID;
482
483     pCurr = pFirstLDD;
484     /* search until we find the appropriate LDD or hit the end */
485     while ((pCurr != NULL) && (ldid > pCurr->pldd->ldid))
486     {
487          pPrev = pCurr;
488          pCurr = pCurr->next;
489     }
490     if ( (pCurr == NULL) /* hit end of list */
491       || (ldid != pCurr->pldd->ldid) )
492         return ERR_VCP_LDDFIND; /* correct ? */
493
494     /* ok, found our victim: eliminate it */
495
496     if (pPrev)
497         pPrev->next = pCurr->next;
498
499     if (pCurr == pFirstLDD)
500         pFirstLDD = NULL;
501     HeapFree(GetProcessHeap(), 0, pCurr);
502
503     return OK;
504 }
505
506 /***********************************************************************
507  *              CtlDelLdd (SETUPX.37)
508  */
509 RETERR16 WINAPI CtlDelLdd16(LOGDISKID16 ldid)
510 {
511     FIXME("(%d); - please report this!\n", ldid);
512     return SETUPX_DelLdd(ldid);
513 }
514
515 /***********************************************************************
516  * CtlFindLdd           (SETUPX.35)
517  *
518  * doesn't check pldd ptr validity: crash (W98SE)
519  *
520  * RETURN
521  *   ERR_VCP_LDDINVALID if pldd->cbSize != structsize
522  *   1 in all other cases ??
523  *
524  */
525 RETERR16 WINAPI CtlFindLdd16(LPLOGDISKDESC pldd)
526 {
527     LDD_LIST *pCurr, *pPrev = NULL;
528
529     TRACE("(%p)\n", pldd);
530
531     if (!std_LDDs_done)
532         SETUPX_CreateStandardLDDs();
533
534     if (pldd->cbSize != sizeof(LOGDISKDESC_S))
535         return ERR_VCP_LDDINVALID;
536
537     pCurr = pFirstLDD;
538     /* search until we find the appropriate LDD or hit the end */
539     while ((pCurr != NULL) && (pldd->ldid > pCurr->pldd->ldid))
540     {
541         pPrev = pCurr;
542         pCurr = pCurr->next;
543     }
544     if ( (pCurr == NULL) /* hit end of list */
545       || (pldd->ldid != pCurr->pldd->ldid) )
546         return ERR_VCP_LDDFIND; /* correct ? */
547
548     memcpy(pldd, pCurr->pldd, pldd->cbSize);
549     /* hmm, we probably ought to strcpy() the string ptrs here */
550
551     return 1; /* what is this ?? */
552 }
553
554 /***********************************************************************
555  * CtlSetLdd                    (SETUPX.33)
556  *
557  * Set an LDD entry.
558  *
559  * RETURN
560  *   ERR_VCP_LDDINVALID if pldd.cbSize != sizeof(LOGDISKDESC_S)
561  *
562  */
563 RETERR16 WINAPI CtlSetLdd16(LPLOGDISKDESC pldd)
564 {
565     LDD_LIST *pCurr, *pPrev = NULL;
566     LPLOGDISKDESC pCurrLDD;
567     HANDLE heap;
568     BOOL is_new = FALSE;
569
570     TRACE("(%p)\n", pldd);
571
572     if (!std_LDDs_done)
573         SETUPX_CreateStandardLDDs();
574
575     if (pldd->cbSize != sizeof(LOGDISKDESC_S))
576         return ERR_VCP_LDDINVALID;
577
578     heap = GetProcessHeap();
579     pCurr = pFirstLDD;
580     /* search until we find the appropriate LDD or hit the end */
581     while ((pCurr != NULL) && (pldd->ldid > pCurr->pldd->ldid))
582     {
583          pPrev = pCurr;
584          pCurr = pCurr->next;
585     }
586     if (!pCurr || pldd->ldid != pCurr->pldd->ldid)
587     {
588         is_new = TRUE;
589         pCurr = HeapAlloc(heap, 0, sizeof(LDD_LIST));
590         pCurr->pldd = HeapAlloc(heap, 0, sizeof(LOGDISKDESC_S));
591         pCurr->next = NULL;
592         pCurrLDD = pCurr->pldd;
593     }
594     else
595     {
596         pCurrLDD = pCurr->pldd;
597         if (pCurrLDD->pszPath)          HeapFree(heap, 0, pCurrLDD->pszPath);
598         if (pCurrLDD->pszVolLabel)      HeapFree(heap, 0, pCurrLDD->pszVolLabel);
599         if (pCurrLDD->pszDiskName)      HeapFree(heap, 0, pCurrLDD->pszDiskName);
600     }
601
602     memcpy(pCurrLDD, pldd, sizeof(LOGDISKDESC_S));
603
604     if (pldd->pszPath)
605     {
606         pCurrLDD->pszPath = HeapAlloc( heap, 0, strlen(pldd->pszPath)+1 );
607         strcpy( pCurrLDD->pszPath, pldd->pszPath );
608     }
609     if (pldd->pszVolLabel)
610     {
611         pCurrLDD->pszVolLabel = HeapAlloc( heap, 0, strlen(pldd->pszVolLabel)+1 );
612         strcpy( pCurrLDD->pszVolLabel, pldd->pszVolLabel );
613     }
614     if (pldd->pszDiskName)
615     {
616         pCurrLDD->pszDiskName = HeapAlloc( heap, 0, strlen(pldd->pszDiskName)+1 );
617         strcpy( pCurrLDD->pszDiskName, pldd->pszDiskName );
618     }
619
620     if (is_new) /* link into list */
621     {
622         if (pPrev)
623         {
624             pCurr->next = pPrev->next;
625             pPrev->next = pCurr;
626         }
627         if (!pFirstLDD)
628             pFirstLDD = pCurr;
629     }
630
631     return OK;
632 }
633
634
635 /***********************************************************************
636  * CtlAddLdd            (SETUPX.36)
637  *
638  * doesn't check pldd ptr validity: crash (W98SE)
639  *
640  */
641 static LOGDISKID16 ldid_to_add = LDID_ASSIGN_START;
642 RETERR16 WINAPI CtlAddLdd16(LPLOGDISKDESC pldd)
643 {
644     pldd->ldid = ldid_to_add++;
645     return CtlSetLdd16(pldd);
646 }
647
648 /***********************************************************************
649  * CtlGetLdd            (SETUPX.34)
650  *
651  * doesn't check pldd ptr validity: crash (W98SE)
652  * What the !@#$%&*( is the difference between CtlFindLdd() and CtlGetLdd() ??
653  *
654  * RETURN
655  *   ERR_VCP_LDDINVALID if pldd->cbSize != structsize
656  *
657  */
658 static RETERR16 SETUPX_GetLdd(LPLOGDISKDESC pldd)
659 {
660     LDD_LIST *pCurr, *pPrev = NULL;
661
662     if (!std_LDDs_done)
663         SETUPX_CreateStandardLDDs();
664
665     if (pldd->cbSize != sizeof(LOGDISKDESC_S))
666         return ERR_VCP_LDDINVALID;
667
668     pCurr = pFirstLDD;
669     /* search until we find the appropriate LDD or hit the end */
670     while ((pCurr != NULL) && (pldd->ldid > pCurr->pldd->ldid))
671     {
672          pPrev = pCurr;
673          pCurr = pCurr->next;
674     }
675     if (pCurr == NULL) /* hit end of list */
676         return ERR_VCP_LDDFIND; /* correct ? */
677
678     memcpy(pldd, pCurr->pldd, pldd->cbSize);
679     /* hmm, we probably ought to strcpy() the string ptrs here */
680
681     return OK;
682 }
683
684 /**********************************************************************/
685
686 RETERR16 WINAPI CtlGetLdd16(LPLOGDISKDESC pldd)
687 {
688     FIXME("(%p); - please report this!\n", pldd);
689     return SETUPX_GetLdd(pldd);
690 }
691
692 /***********************************************************************
693  *              CtlGetLddPath           (SETUPX.38)
694  *
695  * Gets the path of an LDD.
696  * No crash if szPath == NULL.
697  * szPath has to be at least MAX_PATH_LEN bytes long.
698  * RETURN
699  *   ERR_VCP_LDDUNINIT if LDD for LDID not found.
700  */
701 RETERR16 WINAPI CtlGetLddPath16(LOGDISKID16 ldid, LPSTR szPath)
702 {
703     TRACE("(%d, %p);\n", ldid, szPath);
704
705     if (szPath)
706     {
707         LOGDISKDESC_S ldd;
708         INIT_LDD(ldd, ldid);
709         if (CtlFindLdd16(&ldd) == ERR_VCP_LDDFIND)
710             return ERR_VCP_LDDUNINIT;
711         SETUPX_GetLdd(&ldd);
712         strcpy(szPath, ldd.pszPath);
713         TRACE("ret '%s' for LDID %d\n", szPath, ldid);
714     }
715     return OK;
716 }
717
718 /***********************************************************************
719  *              CtlSetLddPath           (SETUPX.508)
720  *
721  * Sets the path of an LDD.
722  * Creates LDD for LDID if not existing yet.
723  */
724 RETERR16 WINAPI CtlSetLddPath16(LOGDISKID16 ldid, LPSTR szPath)
725 {
726     LOGDISKDESC_S ldd;
727     TRACE("(%d, '%s');\n", ldid, szPath);
728
729     SetupSetDirectoryIdA( 0, ldid, szPath );
730     INIT_LDD(ldd, ldid);
731     ldd.pszPath = szPath;
732     return CtlSetLdd16(&ldd);
733 }