mfplat: Read queue subscriber within the critical section.
[wine/zf.git] / dlls / setupapi / query.c
blob828d8a1145a26586ca215d7efc60895747628a10
1 /*
2 * setupapi query functions
4 * Copyright 2006 James Hawkins
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 #include <stdarg.h>
22 #include <stdlib.h>
24 #include "windef.h"
25 #include "winbase.h"
26 #include "winuser.h"
27 #include "winreg.h"
28 #include "setupapi.h"
29 #include "advpub.h"
30 #include "winnls.h"
31 #include "wine/debug.h"
32 #include "setupapi_private.h"
34 WINE_DEFAULT_DEBUG_CHANNEL(setupapi);
36 #ifdef __i386__
37 static const WCHAR source_disks_names_platform[] =
38 {'S','o','u','r','c','e','D','i','s','k','s','N','a','m','e','s','.','x','8','6',0};
39 static const WCHAR source_disks_files_platform[] =
40 {'S','o','u','r','c','e','D','i','s','k','s','F','i','l','e','s','.','x','8','6',0};
41 #elif defined(__x86_64__)
42 static const WCHAR source_disks_names_platform[] =
43 {'S','o','u','r','c','e','D','i','s','k','s','N','a','m','e','s','.','a','m','d','6','4',0};
44 static const WCHAR source_disks_files_platform[] =
45 {'S','o','u','r','c','e','D','i','s','k','s','F','i','l','e','s','.','a','m','d','6','4',0};
46 #elif defined(__arm__)
47 static const WCHAR source_disks_names_platform[] =
48 {'S','o','u','r','c','e','D','i','s','k','s','N','a','m','e','s','.','a','r','m',0};
49 static const WCHAR source_disks_files_platform[] =
50 {'S','o','u','r','c','e','D','i','s','k','s','F','i','l','e','s','.','a','r','m',0};
51 #elif defined(__aarch64__)
52 static const WCHAR source_disks_names_platform[] =
53 {'S','o','u','r','c','e','D','i','s','k','s','N','a','m','e','s','.','a','r','m','6','4',0};
54 static const WCHAR source_disks_files_platform[] =
55 {'S','o','u','r','c','e','D','i','s','k','s','F','i','l','e','s','.','a','r','m','6','4',0};
56 #else /* FIXME: other platforms */
57 static const WCHAR source_disks_names_platform[] =
58 {'S','o','u','r','c','e','D','i','s','k','s','N','a','m','e','s',0};
59 static const WCHAR source_disks_files_platform[] =
60 {'S','o','u','r','c','e','D','i','s','k','s','F','i','l','e','s',0};
61 #endif
62 static const WCHAR source_disks_names[] =
63 {'S','o','u','r','c','e','D','i','s','k','s','N','a','m','e','s',0};
64 static const WCHAR source_disks_files[] =
65 {'S','o','u','r','c','e','D','i','s','k','s','F','i','l','e','s',0};
67 /* fills the PSP_INF_INFORMATION struct fill_info is TRUE
68 * always returns the required size of the information
70 static BOOL fill_inf_info(HINF inf, PSP_INF_INFORMATION buffer, DWORD size, DWORD *required)
72 LPCWSTR filename = PARSER_get_inf_filename(inf);
73 DWORD total_size = FIELD_OFFSET(SP_INF_INFORMATION, VersionData)
74 + (lstrlenW(filename) + 1) * sizeof(WCHAR);
76 if (required) *required = total_size;
78 /* FIXME: we need to parse the INF file to find the correct version info */
79 if (buffer)
81 if (size < total_size)
83 SetLastError(ERROR_INSUFFICIENT_BUFFER);
84 return FALSE;
86 buffer->InfStyle = INF_STYLE_WIN4;
87 buffer->InfCount = 1;
88 /* put the filename in buffer->VersionData */
89 lstrcpyW((LPWSTR)&buffer->VersionData[0], filename);
91 return TRUE;
94 static HINF search_for_inf(LPCVOID InfSpec, DWORD SearchControl)
96 HINF hInf = INVALID_HANDLE_VALUE;
97 WCHAR inf_path[MAX_PATH];
99 static const WCHAR infW[] = {'\\','i','n','f','\\',0};
100 static const WCHAR system32W[] = {'\\','s','y','s','t','e','m','3','2','\\',0};
102 if (SearchControl == INFINFO_REVERSE_DEFAULT_SEARCH)
104 GetWindowsDirectoryW(inf_path, MAX_PATH);
105 lstrcatW(inf_path, system32W);
106 lstrcatW(inf_path, InfSpec);
108 hInf = SetupOpenInfFileW(inf_path, NULL,
109 INF_STYLE_OLDNT | INF_STYLE_WIN4, NULL);
110 if (hInf != INVALID_HANDLE_VALUE)
111 return hInf;
113 GetWindowsDirectoryW(inf_path, MAX_PATH);
114 lstrcpyW(inf_path, infW);
115 lstrcatW(inf_path, InfSpec);
117 return SetupOpenInfFileW(inf_path, NULL,
118 INF_STYLE_OLDNT | INF_STYLE_WIN4, NULL);
121 return INVALID_HANDLE_VALUE;
124 /***********************************************************************
125 * SetupGetInfInformationA (SETUPAPI.@)
128 BOOL WINAPI SetupGetInfInformationA(LPCVOID InfSpec, DWORD SearchControl,
129 PSP_INF_INFORMATION ReturnBuffer,
130 DWORD ReturnBufferSize, PDWORD RequiredSize)
132 LPWSTR inf = (LPWSTR)InfSpec;
133 DWORD len;
134 BOOL ret;
136 if (InfSpec && SearchControl >= INFINFO_INF_NAME_IS_ABSOLUTE)
138 len = MultiByteToWideChar(CP_ACP, 0, InfSpec, -1, NULL, 0);
139 inf = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
140 if (!inf)
142 SetLastError(ERROR_NOT_ENOUGH_MEMORY);
143 return FALSE;
145 MultiByteToWideChar(CP_ACP, 0, InfSpec, -1, inf, len);
148 ret = SetupGetInfInformationW(inf, SearchControl, ReturnBuffer,
149 ReturnBufferSize, RequiredSize);
151 if (SearchControl >= INFINFO_INF_NAME_IS_ABSOLUTE)
152 HeapFree(GetProcessHeap(), 0, inf);
154 return ret;
157 /***********************************************************************
158 * SetupGetInfInformationW (SETUPAPI.@)
160 * BUGS
161 * Only handles the case when InfSpec is an INF handle.
163 BOOL WINAPI SetupGetInfInformationW(LPCVOID InfSpec, DWORD SearchControl,
164 PSP_INF_INFORMATION ReturnBuffer,
165 DWORD ReturnBufferSize, PDWORD RequiredSize)
167 HINF inf;
168 BOOL ret;
169 DWORD infSize;
171 TRACE("(%p, %d, %p, %d, %p)\n", InfSpec, SearchControl, ReturnBuffer,
172 ReturnBufferSize, RequiredSize);
174 if (!InfSpec)
176 if (SearchControl == INFINFO_INF_SPEC_IS_HINF)
177 SetLastError(ERROR_INVALID_HANDLE);
178 else
179 SetLastError(ERROR_INVALID_PARAMETER);
181 return FALSE;
184 switch (SearchControl)
186 case INFINFO_INF_SPEC_IS_HINF:
187 inf = (HINF)InfSpec;
188 break;
189 case INFINFO_INF_NAME_IS_ABSOLUTE:
190 case INFINFO_DEFAULT_SEARCH:
191 inf = SetupOpenInfFileW(InfSpec, NULL,
192 INF_STYLE_OLDNT | INF_STYLE_WIN4, NULL);
193 break;
194 case INFINFO_REVERSE_DEFAULT_SEARCH:
195 inf = search_for_inf(InfSpec, SearchControl);
196 break;
197 case INFINFO_INF_PATH_LIST_SEARCH:
198 FIXME("Unhandled search control: %d\n", SearchControl);
200 if (RequiredSize)
201 *RequiredSize = 0;
203 return FALSE;
204 default:
205 SetLastError(ERROR_INVALID_PARAMETER);
206 return FALSE;
209 if (inf == INVALID_HANDLE_VALUE)
211 SetLastError(ERROR_FILE_NOT_FOUND);
212 return FALSE;
215 ret = fill_inf_info(inf, ReturnBuffer, ReturnBufferSize, &infSize);
216 if (!ReturnBuffer && (ReturnBufferSize >= infSize))
218 SetLastError(ERROR_INVALID_PARAMETER);
219 ret = FALSE;
221 if (RequiredSize) *RequiredSize = infSize;
223 if (SearchControl >= INFINFO_INF_NAME_IS_ABSOLUTE)
224 SetupCloseInfFile(inf);
226 return ret;
229 /***********************************************************************
230 * SetupQueryInfFileInformationA (SETUPAPI.@)
232 BOOL WINAPI SetupQueryInfFileInformationA(PSP_INF_INFORMATION InfInformation,
233 UINT InfIndex, PSTR ReturnBuffer,
234 DWORD ReturnBufferSize, PDWORD RequiredSize)
236 LPWSTR filenameW;
237 DWORD size;
238 BOOL ret;
240 ret = SetupQueryInfFileInformationW(InfInformation, InfIndex, NULL, 0, &size);
241 if (!ret)
242 return FALSE;
244 filenameW = HeapAlloc(GetProcessHeap(), 0, size * sizeof(WCHAR));
246 ret = SetupQueryInfFileInformationW(InfInformation, InfIndex,
247 filenameW, size, &size);
248 if (!ret)
250 HeapFree(GetProcessHeap(), 0, filenameW);
251 return FALSE;
254 if (RequiredSize)
255 *RequiredSize = size;
257 if (!ReturnBuffer)
259 HeapFree(GetProcessHeap(), 0, filenameW);
260 if (ReturnBufferSize)
262 SetLastError(ERROR_INVALID_PARAMETER);
263 return FALSE;
266 return TRUE;
269 if (size > ReturnBufferSize)
271 HeapFree(GetProcessHeap(), 0, filenameW);
272 SetLastError(ERROR_INSUFFICIENT_BUFFER);
273 return FALSE;
276 WideCharToMultiByte(CP_ACP, 0, filenameW, -1, ReturnBuffer, size, NULL, NULL);
277 HeapFree(GetProcessHeap(), 0, filenameW);
279 return ret;
282 /***********************************************************************
283 * SetupQueryInfFileInformationW (SETUPAPI.@)
285 BOOL WINAPI SetupQueryInfFileInformationW(PSP_INF_INFORMATION InfInformation,
286 UINT InfIndex, PWSTR ReturnBuffer,
287 DWORD ReturnBufferSize, PDWORD RequiredSize)
289 DWORD len;
290 LPWSTR ptr;
292 TRACE("(%p, %u, %p, %d, %p) Stub!\n", InfInformation, InfIndex,
293 ReturnBuffer, ReturnBufferSize, RequiredSize);
295 if (!InfInformation)
297 SetLastError(ERROR_INVALID_PARAMETER);
298 return FALSE;
301 if (InfIndex != 0)
302 FIXME("Appended INF files are not handled\n");
304 ptr = (LPWSTR)InfInformation->VersionData;
305 len = lstrlenW(ptr);
307 if (RequiredSize)
308 *RequiredSize = len + 1;
310 if (!ReturnBuffer)
311 return TRUE;
313 if (ReturnBufferSize < len)
315 SetLastError(ERROR_INSUFFICIENT_BUFFER);
316 return FALSE;
319 lstrcpyW(ReturnBuffer, ptr);
320 return TRUE;
323 /***********************************************************************
324 * SetupGetSourceFileLocationA (SETUPAPI.@)
327 BOOL WINAPI SetupGetSourceFileLocationA( HINF hinf, PINFCONTEXT context, PCSTR filename,
328 PUINT source_id, PSTR buffer, DWORD buffer_size,
329 PDWORD required_size )
331 BOOL ret = FALSE;
332 WCHAR *filenameW = NULL, *bufferW = NULL;
333 DWORD required;
334 INT size;
336 TRACE("%p, %p, %s, %p, %p, 0x%08x, %p\n", hinf, context, debugstr_a(filename), source_id,
337 buffer, buffer_size, required_size);
339 if (filename && *filename && !(filenameW = strdupAtoW( filename )))
340 return FALSE;
342 if (!SetupGetSourceFileLocationW( hinf, context, filenameW, source_id, NULL, 0, &required ))
343 goto done;
345 if (!(bufferW = HeapAlloc( GetProcessHeap(), 0, required * sizeof(WCHAR) )))
346 goto done;
348 if (!SetupGetSourceFileLocationW( hinf, context, filenameW, source_id, bufferW, required, NULL ))
349 goto done;
351 size = WideCharToMultiByte( CP_ACP, 0, bufferW, -1, NULL, 0, NULL, NULL );
352 if (required_size) *required_size = size;
354 if (buffer)
356 if (buffer_size >= size)
357 WideCharToMultiByte( CP_ACP, 0, bufferW, -1, buffer, buffer_size, NULL, NULL );
358 else
360 SetLastError( ERROR_INSUFFICIENT_BUFFER );
361 goto done;
364 ret = TRUE;
366 done:
367 HeapFree( GetProcessHeap(), 0, filenameW );
368 HeapFree( GetProcessHeap(), 0, bufferW );
369 return ret;
372 static LPWSTR get_source_id( HINF hinf, PINFCONTEXT context, PCWSTR filename )
374 DWORD size;
375 LPWSTR source_id;
377 if (!SetupFindFirstLineW( hinf, source_disks_files_platform, filename, context ) &&
378 !SetupFindFirstLineW( hinf, source_disks_files, filename, context ))
379 return NULL;
381 if (!SetupGetStringFieldW( context, 1, NULL, 0, &size ))
382 return NULL;
384 if (!(source_id = HeapAlloc( GetProcessHeap(), 0, size * sizeof(WCHAR) )))
385 return NULL;
387 if (!SetupGetStringFieldW( context, 1, source_id, size, NULL ))
389 HeapFree( GetProcessHeap(), 0, source_id );
390 return NULL;
393 if (!SetupFindFirstLineW( hinf, source_disks_names_platform, source_id, context ) &&
394 !SetupFindFirstLineW( hinf, source_disks_names, source_id, context ))
396 HeapFree( GetProcessHeap(), 0, source_id );
397 return NULL;
399 return source_id;
402 /***********************************************************************
403 * SetupGetSourceFileLocationW (SETUPAPI.@)
406 BOOL WINAPI SetupGetSourceFileLocationW( HINF hinf, PINFCONTEXT context, PCWSTR filename,
407 PUINT source_id, PWSTR buffer, DWORD buffer_size,
408 PDWORD required_size )
410 INFCONTEXT ctx;
411 WCHAR *end, *source_id_str;
413 TRACE("%p, %p, %s, %p, %p, 0x%08x, %p\n", hinf, context, debugstr_w(filename), source_id,
414 buffer, buffer_size, required_size);
416 if (!context) context = &ctx;
418 if (!(source_id_str = get_source_id( hinf, context, filename )))
419 return FALSE;
421 *source_id = wcstol( source_id_str, &end, 10 );
422 if (end == source_id_str || *end)
424 HeapFree( GetProcessHeap(), 0, source_id_str );
425 return FALSE;
427 HeapFree( GetProcessHeap(), 0, source_id_str );
429 if (SetupGetStringFieldW( context, 4, buffer, buffer_size, required_size ))
430 return TRUE;
432 if (required_size) *required_size = 1;
433 if (buffer)
435 if (buffer_size >= 1) buffer[0] = 0;
436 else
438 SetLastError( ERROR_INSUFFICIENT_BUFFER );
439 return FALSE;
442 return TRUE;
445 /***********************************************************************
446 * SetupGetSourceInfoA (SETUPAPI.@)
449 BOOL WINAPI SetupGetSourceInfoA( HINF hinf, UINT source_id, UINT info,
450 PSTR buffer, DWORD buffer_size, LPDWORD required_size )
452 BOOL ret = FALSE;
453 WCHAR *bufferW = NULL;
454 DWORD required;
455 INT size;
457 TRACE("%p, %d, %d, %p, %d, %p\n", hinf, source_id, info, buffer, buffer_size,
458 required_size);
460 if (!SetupGetSourceInfoW( hinf, source_id, info, NULL, 0, &required ))
461 return FALSE;
463 if (!(bufferW = HeapAlloc( GetProcessHeap(), 0, required * sizeof(WCHAR) )))
464 return FALSE;
466 if (!SetupGetSourceInfoW( hinf, source_id, info, bufferW, required, NULL ))
467 goto done;
469 size = WideCharToMultiByte( CP_ACP, 0, bufferW, -1, NULL, 0, NULL, NULL );
470 if (required_size) *required_size = size;
472 if (buffer)
474 if (buffer_size >= size)
475 WideCharToMultiByte( CP_ACP, 0, bufferW, -1, buffer, buffer_size, NULL, NULL );
476 else
478 SetLastError( ERROR_INSUFFICIENT_BUFFER );
479 goto done;
482 ret = TRUE;
484 done:
485 HeapFree( GetProcessHeap(), 0, bufferW );
486 return ret;
489 /***********************************************************************
490 * SetupGetSourceInfoW (SETUPAPI.@)
493 BOOL WINAPI SetupGetSourceInfoW( HINF hinf, UINT source_id, UINT info,
494 PWSTR buffer, DWORD buffer_size, LPDWORD required_size )
496 INFCONTEXT ctx;
497 WCHAR source_id_str[11];
498 static const WCHAR fmt[] = {'%','d',0};
499 DWORD index;
501 TRACE("%p, %d, %d, %p, %d, %p\n", hinf, source_id, info, buffer, buffer_size,
502 required_size);
504 swprintf( source_id_str, ARRAY_SIZE(source_id_str), fmt, source_id );
506 if (!SetupFindFirstLineW( hinf, source_disks_names_platform, source_id_str, &ctx ) &&
507 !SetupFindFirstLineW( hinf, source_disks_names, source_id_str, &ctx ))
508 return FALSE;
510 switch (info)
512 case SRCINFO_PATH: index = 4; break;
513 case SRCINFO_TAGFILE: index = 2; break;
514 case SRCINFO_DESCRIPTION: index = 1; break;
515 default:
516 WARN("unknown info level: %d\n", info);
517 return FALSE;
520 if (SetupGetStringFieldW( &ctx, index, buffer, buffer_size, required_size ))
521 return TRUE;
523 if (required_size) *required_size = 1;
524 if (buffer)
526 if (buffer_size >= 1) buffer[0] = 0;
527 else
529 SetLastError( ERROR_INSUFFICIENT_BUFFER );
530 return FALSE;
533 return TRUE;
536 /***********************************************************************
537 * SetupGetTargetPathA (SETUPAPI.@)
540 BOOL WINAPI SetupGetTargetPathA( HINF hinf, PINFCONTEXT context, PCSTR section, PSTR buffer,
541 DWORD buffer_size, PDWORD required_size )
543 BOOL ret = FALSE;
544 WCHAR *sectionW = NULL, *bufferW = NULL;
545 DWORD required;
546 INT size;
548 TRACE("%p, %p, %s, %p, 0x%08x, %p\n", hinf, context, debugstr_a(section), buffer,
549 buffer_size, required_size);
551 if (section && !(sectionW = strdupAtoW( section )))
552 return FALSE;
554 if (!SetupGetTargetPathW( hinf, context, sectionW, NULL, 0, &required ))
555 goto done;
557 if (!(bufferW = HeapAlloc( GetProcessHeap(), 0, required * sizeof(WCHAR) )))
558 goto done;
560 if (!SetupGetTargetPathW( hinf, context, sectionW, bufferW, required, NULL ))
561 goto done;
563 size = WideCharToMultiByte( CP_ACP, 0, bufferW, -1, NULL, 0, NULL, NULL );
564 if (required_size) *required_size = size;
566 if (buffer)
568 if (buffer_size >= size)
569 WideCharToMultiByte( CP_ACP, 0, bufferW, -1, buffer, buffer_size, NULL, NULL );
570 else
572 SetLastError( ERROR_INSUFFICIENT_BUFFER );
573 goto done;
576 ret = TRUE;
578 done:
579 HeapFree( GetProcessHeap(), 0, sectionW );
580 HeapFree( GetProcessHeap(), 0, bufferW );
581 return ret;
584 /***********************************************************************
585 * SetupGetTargetPathW (SETUPAPI.@)
588 BOOL WINAPI SetupGetTargetPathW( HINF hinf, PINFCONTEXT context, PCWSTR section, PWSTR buffer,
589 DWORD buffer_size, PDWORD required_size )
591 static const WCHAR destination_dirs[] =
592 {'D','e','s','t','i','n','a','t','i','o','n','D','i','r','s',0};
593 static const WCHAR default_dest_dir[] =
594 {'D','e','f','a','u','l','t','D','e','s','t','D','i','r',0};
596 INFCONTEXT ctx;
597 WCHAR *dir, systemdir[MAX_PATH];
598 unsigned int size;
599 BOOL ret = FALSE;
601 TRACE("%p, %p, %s, %p, 0x%08x, %p\n", hinf, context, debugstr_w(section), buffer,
602 buffer_size, required_size);
604 if (context) ret = SetupFindFirstLineW( hinf, destination_dirs, NULL, context );
605 else if (section)
607 if (!(ret = SetupFindFirstLineW( hinf, destination_dirs, section, &ctx )))
608 ret = SetupFindFirstLineW( hinf, destination_dirs, default_dest_dir, &ctx );
610 if (!ret || !(dir = PARSER_get_dest_dir( context ? context : &ctx )))
612 GetSystemDirectoryW( systemdir, MAX_PATH );
613 dir = systemdir;
615 size = lstrlenW( dir ) + 1;
616 if (required_size) *required_size = size;
618 if (buffer)
620 if (buffer_size >= size)
621 lstrcpyW( buffer, dir );
622 else
624 SetLastError( ERROR_INSUFFICIENT_BUFFER );
625 if (dir != systemdir) HeapFree( GetProcessHeap(), 0, dir );
626 return FALSE;
629 if (dir != systemdir) HeapFree( GetProcessHeap(), 0, dir );
630 return TRUE;
633 /***********************************************************************
634 * SetupQueryInfOriginalFileInformationA (SETUPAPI.@)
636 BOOL WINAPI SetupQueryInfOriginalFileInformationA(
637 PSP_INF_INFORMATION InfInformation, UINT InfIndex,
638 PSP_ALTPLATFORM_INFO AlternativePlatformInfo,
639 PSP_ORIGINAL_FILE_INFO_A OriginalFileInfo)
641 BOOL ret;
642 SP_ORIGINAL_FILE_INFO_W OriginalFileInfoW;
644 TRACE("(%p, %d, %p, %p)\n", InfInformation, InfIndex,
645 AlternativePlatformInfo, OriginalFileInfo);
647 if (OriginalFileInfo->cbSize != sizeof(*OriginalFileInfo))
649 WARN("incorrect OriginalFileInfo->cbSize of %d\n", OriginalFileInfo->cbSize);
650 SetLastError( ERROR_INVALID_USER_BUFFER );
651 return FALSE;
654 OriginalFileInfoW.cbSize = sizeof(OriginalFileInfoW);
655 ret = SetupQueryInfOriginalFileInformationW(InfInformation, InfIndex,
656 AlternativePlatformInfo, &OriginalFileInfoW);
657 if (ret)
659 WideCharToMultiByte(CP_ACP, 0, OriginalFileInfoW.OriginalInfName, -1,
660 OriginalFileInfo->OriginalInfName, MAX_PATH, NULL, NULL);
661 WideCharToMultiByte(CP_ACP, 0, OriginalFileInfoW.OriginalCatalogName, -1,
662 OriginalFileInfo->OriginalCatalogName, MAX_PATH, NULL, NULL);
665 return ret;
668 /***********************************************************************
669 * SetupQueryInfOriginalFileInformationW (SETUPAPI.@)
671 BOOL WINAPI SetupQueryInfOriginalFileInformationW(
672 PSP_INF_INFORMATION InfInformation, UINT InfIndex,
673 PSP_ALTPLATFORM_INFO AlternativePlatformInfo,
674 PSP_ORIGINAL_FILE_INFO_W OriginalFileInfo)
676 LPCWSTR inf_name;
677 LPCWSTR inf_path;
678 HINF hinf;
679 static const WCHAR wszVersion[] = { 'V','e','r','s','i','o','n',0 };
680 static const WCHAR wszCatalogFile[] = { 'C','a','t','a','l','o','g','F','i','l','e',0 };
682 FIXME("(%p, %d, %p, %p): semi-stub\n", InfInformation, InfIndex,
683 AlternativePlatformInfo, OriginalFileInfo);
685 if (OriginalFileInfo->cbSize != sizeof(*OriginalFileInfo))
687 WARN("incorrect OriginalFileInfo->cbSize of %d\n", OriginalFileInfo->cbSize);
688 SetLastError(ERROR_INVALID_USER_BUFFER);
689 return FALSE;
692 inf_path = (LPWSTR)InfInformation->VersionData;
694 /* FIXME: we should get OriginalCatalogName from CatalogFile line in
695 * the original inf file and cache it, but that would require building a
696 * .pnf file. */
697 hinf = SetupOpenInfFileW(inf_path, NULL, INF_STYLE_WIN4, NULL);
698 if (hinf == INVALID_HANDLE_VALUE) return FALSE;
700 if (!SetupGetLineTextW(NULL, hinf, wszVersion, wszCatalogFile,
701 OriginalFileInfo->OriginalCatalogName,
702 ARRAY_SIZE(OriginalFileInfo->OriginalCatalogName), NULL))
704 OriginalFileInfo->OriginalCatalogName[0] = '\0';
706 SetupCloseInfFile(hinf);
708 /* FIXME: not quite correct as we just return the same file name as
709 * destination (copied) inf file, not the source (original) inf file.
710 * to fix it properly would require building a .pnf file */
711 /* file name is stored in VersionData field of InfInformation */
712 inf_name = wcsrchr(inf_path, '\\');
713 if (inf_name) inf_name++;
714 else inf_name = inf_path;
716 lstrcpyW(OriginalFileInfo->OriginalInfName, inf_name);
718 return TRUE;
721 /***********************************************************************
722 * SetupGetInfDriverStoreLocationW (SETUPAPI.@)
724 BOOL WINAPI SetupGetInfDriverStoreLocationW(
725 PCWSTR FileName, PSP_ALTPLATFORM_INFO AlternativePlatformInfo,
726 PCWSTR LocaleName, PWSTR ReturnBuffer, DWORD ReturnBufferSize,
727 PDWORD RequiredSize)
729 FIXME("stub: %s %p %s %p %u %p\n", debugstr_w(FileName), AlternativePlatformInfo, debugstr_w(LocaleName), ReturnBuffer, ReturnBufferSize, RequiredSize);
731 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
732 return FALSE;