Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygenquery.c
Go to the documentation of this file.
00001 /* 00002 * setupapi query functions 00003 * 00004 * Copyright 2006 James Hawkins 00005 * 00006 * This library is free software; you can redistribute it and/or 00007 * modify it under the terms of the GNU Lesser General Public 00008 * License as published by the Free Software Foundation; either 00009 * version 2.1 of the License, or (at your option) any later version. 00010 * 00011 * This library is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00014 * Lesser General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU Lesser General Public 00017 * License along with this library; if not, write to the Free Software 00018 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA 00019 */ 00020 00021 #include "setupapi_private.h" 00022 00023 WINE_DEFAULT_DEBUG_CHANNEL(setupapi); 00024 00025 static const WCHAR source_disks_names[] = 00026 {'S','o','u','r','c','e','D','i','s','k','s','N','a','m','e','s',0}; 00027 static const WCHAR source_disks_files[] = 00028 {'S','o','u','r','c','e','D','i','s','k','s','F','i','l','e','s',0}; 00029 00030 /* fills the PSP_INF_INFORMATION struct fill_info is TRUE 00031 * always returns the required size of the information 00032 */ 00033 static BOOL fill_inf_info(HINF inf, PSP_INF_INFORMATION buffer, DWORD size, DWORD *required) 00034 { 00035 LPCWSTR filename = PARSER_get_inf_filename(inf); 00036 DWORD total_size = FIELD_OFFSET(SP_INF_INFORMATION, VersionData) 00037 + (lstrlenW(filename) + 1) * sizeof(WCHAR); 00038 00039 if (required) *required = total_size; 00040 00041 /* FIXME: we need to parse the INF file to find the correct version info */ 00042 if (buffer) 00043 { 00044 if (size < total_size) 00045 { 00046 SetLastError(ERROR_INSUFFICIENT_BUFFER); 00047 return FALSE; 00048 } 00049 buffer->InfStyle = INF_STYLE_WIN4; 00050 buffer->InfCount = 1; 00051 /* put the filename in buffer->VersionData */ 00052 lstrcpyW((LPWSTR)&buffer->VersionData[0], filename); 00053 } 00054 return TRUE; 00055 } 00056 00057 static HINF search_for_inf(LPCVOID InfSpec, DWORD SearchControl) 00058 { 00059 HINF hInf = INVALID_HANDLE_VALUE; 00060 WCHAR inf_path[MAX_PATH]; 00061 00062 static const WCHAR infW[] = {'\\','i','n','f','\\',0}; 00063 static const WCHAR system32W[] = {'\\','s','y','s','t','e','m','3','2','\\',0}; 00064 00065 if (SearchControl == INFINFO_REVERSE_DEFAULT_SEARCH) 00066 { 00067 GetWindowsDirectoryW(inf_path, MAX_PATH); 00068 lstrcatW(inf_path, system32W); 00069 lstrcatW(inf_path, InfSpec); 00070 00071 hInf = SetupOpenInfFileW(inf_path, NULL, 00072 INF_STYLE_OLDNT | INF_STYLE_WIN4, NULL); 00073 if (hInf != INVALID_HANDLE_VALUE) 00074 return hInf; 00075 00076 GetWindowsDirectoryW(inf_path, MAX_PATH); 00077 lstrcpyW(inf_path, infW); 00078 lstrcatW(inf_path, InfSpec); 00079 00080 return SetupOpenInfFileW(inf_path, NULL, 00081 INF_STYLE_OLDNT | INF_STYLE_WIN4, NULL); 00082 } 00083 00084 return INVALID_HANDLE_VALUE; 00085 } 00086 00087 /*********************************************************************** 00088 * SetupGetInfInformationA (SETUPAPI.@) 00089 * 00090 */ 00091 BOOL WINAPI SetupGetInfInformationA(LPCVOID InfSpec, DWORD SearchControl, 00092 PSP_INF_INFORMATION ReturnBuffer, 00093 DWORD ReturnBufferSize, PDWORD RequiredSize) 00094 { 00095 LPWSTR inf = (LPWSTR)InfSpec; 00096 DWORD len; 00097 BOOL ret; 00098 00099 if (InfSpec && SearchControl >= INFINFO_INF_NAME_IS_ABSOLUTE) 00100 { 00101 len = lstrlenA(InfSpec) + 1; 00102 inf = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR)); 00103 MultiByteToWideChar(CP_ACP, 0, InfSpec, -1, inf, len); 00104 } 00105 00106 ret = SetupGetInfInformationW(inf, SearchControl, ReturnBuffer, 00107 ReturnBufferSize, RequiredSize); 00108 00109 if (SearchControl >= INFINFO_INF_NAME_IS_ABSOLUTE) 00110 HeapFree(GetProcessHeap(), 0, inf); 00111 00112 return ret; 00113 } 00114 00115 /*********************************************************************** 00116 * SetupGetInfInformationW (SETUPAPI.@) 00117 * 00118 * BUGS 00119 * Only handles the case when InfSpec is an INF handle. 00120 */ 00121 BOOL WINAPI SetupGetInfInformationW(LPCVOID InfSpec, DWORD SearchControl, 00122 PSP_INF_INFORMATION ReturnBuffer, 00123 DWORD ReturnBufferSize, PDWORD RequiredSize) 00124 { 00125 HINF inf; 00126 BOOL ret; 00127 DWORD infSize; 00128 00129 TRACE("(%p, %d, %p, %d, %p)\n", InfSpec, SearchControl, ReturnBuffer, 00130 ReturnBufferSize, RequiredSize); 00131 00132 if (!InfSpec) 00133 { 00134 if (SearchControl == INFINFO_INF_SPEC_IS_HINF) 00135 SetLastError(ERROR_INVALID_HANDLE); 00136 else 00137 SetLastError(ERROR_INVALID_PARAMETER); 00138 00139 return FALSE; 00140 } 00141 00142 switch (SearchControl) 00143 { 00144 case INFINFO_INF_SPEC_IS_HINF: 00145 inf = (HINF)InfSpec; 00146 break; 00147 case INFINFO_INF_NAME_IS_ABSOLUTE: 00148 case INFINFO_DEFAULT_SEARCH: 00149 inf = SetupOpenInfFileW(InfSpec, NULL, 00150 INF_STYLE_OLDNT | INF_STYLE_WIN4, NULL); 00151 break; 00152 case INFINFO_REVERSE_DEFAULT_SEARCH: 00153 inf = search_for_inf(InfSpec, SearchControl); 00154 break; 00155 case INFINFO_INF_PATH_LIST_SEARCH: 00156 FIXME("Unhandled search control: %d\n", SearchControl); 00157 00158 if (RequiredSize) 00159 *RequiredSize = 0; 00160 00161 return FALSE; 00162 default: 00163 SetLastError(ERROR_INVALID_PARAMETER); 00164 return FALSE; 00165 } 00166 00167 if (inf == INVALID_HANDLE_VALUE) 00168 { 00169 SetLastError(ERROR_FILE_NOT_FOUND); 00170 return FALSE; 00171 } 00172 00173 ret = fill_inf_info(inf, ReturnBuffer, ReturnBufferSize, &infSize); 00174 if (!ReturnBuffer && (ReturnBufferSize >= infSize)) 00175 { 00176 SetLastError(ERROR_INVALID_PARAMETER); 00177 ret = FALSE; 00178 } 00179 if (RequiredSize) *RequiredSize = infSize; 00180 00181 if (SearchControl >= INFINFO_INF_NAME_IS_ABSOLUTE) 00182 SetupCloseInfFile(inf); 00183 00184 return ret; 00185 } 00186 00187 /*********************************************************************** 00188 * SetupQueryInfFileInformationA (SETUPAPI.@) 00189 */ 00190 BOOL WINAPI SetupQueryInfFileInformationA(PSP_INF_INFORMATION InfInformation, 00191 UINT InfIndex, PSTR ReturnBuffer, 00192 DWORD ReturnBufferSize, PDWORD RequiredSize) 00193 { 00194 LPWSTR filenameW; 00195 DWORD size; 00196 BOOL ret; 00197 00198 ret = SetupQueryInfFileInformationW(InfInformation, InfIndex, NULL, 0, &size); 00199 if (!ret) 00200 return FALSE; 00201 00202 filenameW = HeapAlloc(GetProcessHeap(), 0, size * sizeof(WCHAR)); 00203 00204 ret = SetupQueryInfFileInformationW(InfInformation, InfIndex, 00205 filenameW, size, &size); 00206 if (!ret) 00207 { 00208 HeapFree(GetProcessHeap(), 0, filenameW); 00209 return FALSE; 00210 } 00211 00212 if (RequiredSize) 00213 *RequiredSize = size; 00214 00215 if (!ReturnBuffer) 00216 { 00217 HeapFree(GetProcessHeap(), 0, filenameW); 00218 if (ReturnBufferSize) 00219 { 00220 SetLastError(ERROR_INVALID_PARAMETER); 00221 return FALSE; 00222 } 00223 00224 return TRUE; 00225 } 00226 00227 if (size > ReturnBufferSize) 00228 { 00229 HeapFree(GetProcessHeap(), 0, filenameW); 00230 SetLastError(ERROR_INSUFFICIENT_BUFFER); 00231 return FALSE; 00232 } 00233 00234 WideCharToMultiByte(CP_ACP, 0, filenameW, -1, ReturnBuffer, size, NULL, NULL); 00235 HeapFree(GetProcessHeap(), 0, filenameW); 00236 00237 return ret; 00238 } 00239 00240 /*********************************************************************** 00241 * SetupQueryInfFileInformationW (SETUPAPI.@) 00242 */ 00243 BOOL WINAPI SetupQueryInfFileInformationW(PSP_INF_INFORMATION InfInformation, 00244 UINT InfIndex, PWSTR ReturnBuffer, 00245 DWORD ReturnBufferSize, PDWORD RequiredSize) 00246 { 00247 DWORD len; 00248 LPWSTR ptr; 00249 00250 TRACE("(%p, %u, %p, %d, %p) Stub!\n", InfInformation, InfIndex, 00251 ReturnBuffer, ReturnBufferSize, RequiredSize); 00252 00253 if (!InfInformation) 00254 { 00255 SetLastError(ERROR_INVALID_PARAMETER); 00256 return FALSE; 00257 } 00258 00259 if (InfIndex != 0) 00260 FIXME("Appended INF files are not handled\n"); 00261 00262 ptr = (LPWSTR)&InfInformation->VersionData[0]; 00263 len = lstrlenW(ptr); 00264 00265 if (RequiredSize) 00266 *RequiredSize = len + 1; 00267 00268 if (!ReturnBuffer) 00269 return TRUE; 00270 00271 if (ReturnBufferSize < len) 00272 { 00273 SetLastError(ERROR_INSUFFICIENT_BUFFER); 00274 return FALSE; 00275 } 00276 00277 lstrcpyW(ReturnBuffer, ptr); 00278 return TRUE; 00279 } 00280 00281 /*********************************************************************** 00282 * SetupGetSourceFileLocationA (SETUPAPI.@) 00283 */ 00284 00285 BOOL WINAPI SetupGetSourceFileLocationA( HINF hinf, PINFCONTEXT context, PCSTR filename, 00286 PUINT source_id, PSTR buffer, DWORD buffer_size, 00287 PDWORD required_size ) 00288 { 00289 BOOL ret = FALSE; 00290 WCHAR *filenameW = NULL, *bufferW = NULL; 00291 DWORD required; 00292 INT size; 00293 00294 TRACE("%p, %p, %s, %p, %p, 0x%08x, %p\n", hinf, context, debugstr_a(filename), source_id, 00295 buffer, buffer_size, required_size); 00296 00297 if (filename && *filename && !(filenameW = strdupAtoW( filename ))) 00298 return FALSE; 00299 00300 if (!SetupGetSourceFileLocationW( hinf, context, filenameW, source_id, NULL, 0, &required )) 00301 goto done; 00302 00303 if (!(bufferW = HeapAlloc( GetProcessHeap(), 0, required * sizeof(WCHAR) ))) 00304 goto done; 00305 00306 if (!SetupGetSourceFileLocationW( hinf, context, filenameW, source_id, bufferW, required, NULL )) 00307 goto done; 00308 00309 size = WideCharToMultiByte( CP_ACP, 0, bufferW, -1, NULL, 0, NULL, NULL ); 00310 if (required_size) *required_size = size; 00311 00312 if (buffer) 00313 { 00314 if (buffer_size >= size) 00315 WideCharToMultiByte( CP_ACP, 0, bufferW, -1, buffer, buffer_size, NULL, NULL ); 00316 else 00317 { 00318 SetLastError( ERROR_INSUFFICIENT_BUFFER ); 00319 goto done; 00320 } 00321 } 00322 ret = TRUE; 00323 00324 done: 00325 HeapFree( GetProcessHeap(), 0, filenameW ); 00326 HeapFree( GetProcessHeap(), 0, bufferW ); 00327 return ret; 00328 } 00329 00330 static LPWSTR get_source_id( HINF hinf, PINFCONTEXT context, PCWSTR filename ) 00331 { 00332 WCHAR Section[MAX_PATH]; 00333 DWORD size; 00334 LPWSTR source_id; 00335 00336 if (!SetupDiGetActualSectionToInstallW(hinf, source_disks_files, Section, MAX_PATH, NULL, NULL)) 00337 return NULL; 00338 00339 if (!SetupFindFirstLineW( hinf, Section, filename, context ) && 00340 !SetupFindFirstLineW( hinf, source_disks_files, filename, context )) 00341 return NULL; 00342 00343 if (!SetupGetStringFieldW( context, 1, NULL, 0, &size )) 00344 return NULL; 00345 00346 if (!(source_id = HeapAlloc( GetProcessHeap(), 0, size * sizeof(WCHAR) ))) 00347 return NULL; 00348 00349 if (!SetupGetStringFieldW( context, 1, source_id, size, NULL )) 00350 { 00351 HeapFree( GetProcessHeap(), 0, source_id ); 00352 return NULL; 00353 } 00354 00355 if (!SetupDiGetActualSectionToInstallW(hinf, source_disks_names, Section, MAX_PATH, NULL, NULL)) 00356 return NULL; 00357 00358 if (!SetupFindFirstLineW( hinf, Section, source_id, context ) && 00359 !SetupFindFirstLineW( hinf, source_disks_names, source_id, context )) 00360 { 00361 HeapFree( GetProcessHeap(), 0, source_id ); 00362 return NULL; 00363 } 00364 return source_id; 00365 } 00366 00367 /*********************************************************************** 00368 * SetupGetSourceFileLocationW (SETUPAPI.@) 00369 */ 00370 00371 BOOL WINAPI SetupGetSourceFileLocationW( HINF hinf, PINFCONTEXT context, PCWSTR filename, 00372 PUINT source_id, PWSTR buffer, DWORD buffer_size, 00373 PDWORD required_size ) 00374 { 00375 INFCONTEXT ctx; 00376 WCHAR *end, *source_id_str; 00377 00378 TRACE("%p, %p, %s, %p, %p, 0x%08x, %p\n", hinf, context, debugstr_w(filename), source_id, 00379 buffer, buffer_size, required_size); 00380 00381 if (!context) context = &ctx; 00382 00383 if (!(source_id_str = get_source_id( hinf, context, filename ))) 00384 return FALSE; 00385 00386 *source_id = strtolW( source_id_str, &end, 10 ); 00387 if (end == source_id_str || *end) 00388 { 00389 HeapFree( GetProcessHeap(), 0, source_id_str ); 00390 return FALSE; 00391 } 00392 HeapFree( GetProcessHeap(), 0, source_id_str ); 00393 00394 if (SetupGetStringFieldW( context, 4, buffer, buffer_size, required_size )) 00395 return TRUE; 00396 00397 if (required_size) *required_size = 1; 00398 if (buffer) 00399 { 00400 if (buffer_size >= 1) buffer[0] = 0; 00401 else 00402 { 00403 SetLastError( ERROR_INSUFFICIENT_BUFFER ); 00404 return FALSE; 00405 } 00406 } 00407 return TRUE; 00408 } 00409 00410 /*********************************************************************** 00411 * SetupGetSourceInfoA (SETUPAPI.@) 00412 */ 00413 00414 BOOL WINAPI SetupGetSourceInfoA( HINF hinf, UINT source_id, UINT info, 00415 PSTR buffer, DWORD buffer_size, LPDWORD required_size ) 00416 { 00417 BOOL ret = FALSE; 00418 WCHAR *bufferW = NULL; 00419 DWORD required; 00420 INT size; 00421 00422 TRACE("%p, %d, %d, %p, %d, %p\n", hinf, source_id, info, buffer, buffer_size, 00423 required_size); 00424 00425 if (!SetupGetSourceInfoW( hinf, source_id, info, NULL, 0, &required )) 00426 return FALSE; 00427 00428 if (!(bufferW = HeapAlloc( GetProcessHeap(), 0, required * sizeof(WCHAR) ))) 00429 return FALSE; 00430 00431 if (!SetupGetSourceInfoW( hinf, source_id, info, bufferW, required, NULL )) 00432 goto done; 00433 00434 size = WideCharToMultiByte( CP_ACP, 0, bufferW, -1, NULL, 0, NULL, NULL ); 00435 if (required_size) *required_size = size; 00436 00437 if (buffer) 00438 { 00439 if (buffer_size >= size) 00440 WideCharToMultiByte( CP_ACP, 0, bufferW, -1, buffer, buffer_size, NULL, NULL ); 00441 else 00442 { 00443 SetLastError( ERROR_INSUFFICIENT_BUFFER ); 00444 goto done; 00445 } 00446 } 00447 ret = TRUE; 00448 00449 done: 00450 HeapFree( GetProcessHeap(), 0, bufferW ); 00451 return ret; 00452 } 00453 00454 /*********************************************************************** 00455 * SetupGetSourceInfoW (SETUPAPI.@) 00456 */ 00457 00458 BOOL WINAPI SetupGetSourceInfoW( HINF hinf, UINT source_id, UINT info, 00459 PWSTR buffer, DWORD buffer_size, LPDWORD required_size ) 00460 { 00461 WCHAR Section[MAX_PATH]; 00462 INFCONTEXT ctx; 00463 WCHAR source_id_str[11]; 00464 static const WCHAR fmt[] = {'%','d',0}; 00465 DWORD index; 00466 00467 TRACE("%p, %d, %d, %p, %d, %p\n", hinf, source_id, info, buffer, buffer_size, 00468 required_size); 00469 00470 sprintfW( source_id_str, fmt, source_id ); 00471 00472 if (!SetupDiGetActualSectionToInstallW(hinf, source_disks_names, Section, MAX_PATH, NULL, NULL)) 00473 return FALSE; 00474 00475 if (!SetupFindFirstLineW( hinf, Section, source_id_str, &ctx ) && 00476 !SetupFindFirstLineW( hinf, source_disks_names, source_id_str, &ctx )) 00477 return FALSE; 00478 00479 switch (info) 00480 { 00481 case SRCINFO_PATH: index = 4; break; 00482 case SRCINFO_TAGFILE: index = 2; break; 00483 case SRCINFO_DESCRIPTION: index = 1; break; 00484 default: 00485 WARN("unknown info level: %d\n", info); 00486 return FALSE; 00487 } 00488 00489 if (SetupGetStringFieldW( &ctx, index, buffer, buffer_size, required_size )) 00490 return TRUE; 00491 00492 if (required_size) *required_size = 1; 00493 if (buffer) 00494 { 00495 if (buffer_size >= 1) buffer[0] = 0; 00496 else 00497 { 00498 SetLastError( ERROR_INSUFFICIENT_BUFFER ); 00499 return FALSE; 00500 } 00501 } 00502 return TRUE; 00503 } 00504 00505 /*********************************************************************** 00506 * SetupGetTargetPathA (SETUPAPI.@) 00507 */ 00508 00509 BOOL WINAPI SetupGetTargetPathA( HINF hinf, PINFCONTEXT context, PCSTR section, PSTR buffer, 00510 DWORD buffer_size, PDWORD required_size ) 00511 { 00512 BOOL ret = FALSE; 00513 WCHAR *sectionW = NULL, *bufferW = NULL; 00514 DWORD required; 00515 INT size; 00516 00517 TRACE("%p, %p, %s, %p, 0x%08x, %p\n", hinf, context, debugstr_a(section), buffer, 00518 buffer_size, required_size); 00519 00520 if (section && !(sectionW = strdupAtoW( section ))) 00521 return FALSE; 00522 00523 if (!SetupGetTargetPathW( hinf, context, sectionW, NULL, 0, &required )) 00524 goto done; 00525 00526 if (!(bufferW = HeapAlloc( GetProcessHeap(), 0, required * sizeof(WCHAR) ))) 00527 goto done; 00528 00529 if (!SetupGetTargetPathW( hinf, context, sectionW, bufferW, required, NULL )) 00530 goto done; 00531 00532 size = WideCharToMultiByte( CP_ACP, 0, bufferW, -1, NULL, 0, NULL, NULL ); 00533 if (required_size) *required_size = size; 00534 00535 if (buffer) 00536 { 00537 if (buffer_size >= size) 00538 WideCharToMultiByte( CP_ACP, 0, bufferW, -1, buffer, buffer_size, NULL, NULL ); 00539 else 00540 { 00541 SetLastError( ERROR_INSUFFICIENT_BUFFER ); 00542 goto done; 00543 } 00544 } 00545 ret = TRUE; 00546 00547 done: 00548 HeapFree( GetProcessHeap(), 0, sectionW ); 00549 HeapFree( GetProcessHeap(), 0, bufferW ); 00550 return ret; 00551 } 00552 00553 /*********************************************************************** 00554 * SetupGetTargetPathW (SETUPAPI.@) 00555 */ 00556 00557 BOOL WINAPI SetupGetTargetPathW( HINF hinf, PINFCONTEXT context, PCWSTR section, PWSTR buffer, 00558 DWORD buffer_size, PDWORD required_size ) 00559 { 00560 static const WCHAR destination_dirs[] = 00561 {'D','e','s','t','i','n','a','t','i','o','n','D','i','r','s',0}; 00562 static const WCHAR default_dest_dir[] = 00563 {'D','e','f','a','u','l','t','D','e','s','t','D','i','r',0}; 00564 00565 INFCONTEXT ctx; 00566 WCHAR *dir, systemdir[MAX_PATH]; 00567 unsigned int size; 00568 BOOL ret = FALSE; 00569 00570 TRACE("%p, %p, %s, %p, 0x%08x, %p\n", hinf, context, debugstr_w(section), buffer, 00571 buffer_size, required_size); 00572 00573 if (context) ret = SetupFindFirstLineW( hinf, destination_dirs, NULL, context ); 00574 else if (section) 00575 { 00576 if (!(ret = SetupFindFirstLineW( hinf, destination_dirs, section, &ctx ))) 00577 ret = SetupFindFirstLineW( hinf, destination_dirs, default_dest_dir, &ctx ); 00578 } 00579 if (!ret || !(dir = PARSER_get_dest_dir( context ? context : &ctx ))) 00580 { 00581 GetSystemDirectoryW( systemdir, MAX_PATH ); 00582 dir = systemdir; 00583 } 00584 size = strlenW( dir ) + 1; 00585 if (required_size) *required_size = size; 00586 00587 if (buffer) 00588 { 00589 if (buffer_size >= size) 00590 lstrcpyW( buffer, dir ); 00591 else 00592 { 00593 SetLastError( ERROR_INSUFFICIENT_BUFFER ); 00594 HeapFree( GetProcessHeap(), 0, dir ); 00595 return FALSE; 00596 } 00597 } 00598 if (dir != systemdir) HeapFree( GetProcessHeap(), 0, dir ); 00599 return TRUE; 00600 } 00601 00602 /*********************************************************************** 00603 * SetupQueryInfOriginalFileInformationA (SETUPAPI.@) 00604 */ 00605 BOOL WINAPI SetupQueryInfOriginalFileInformationA( 00606 PSP_INF_INFORMATION InfInformation, UINT InfIndex, 00607 PSP_ALTPLATFORM_INFO AlternativePlatformInfo, 00608 PSP_ORIGINAL_FILE_INFO_A OriginalFileInfo) 00609 { 00610 BOOL ret; 00611 SP_ORIGINAL_FILE_INFO_W OriginalFileInfoW; 00612 00613 TRACE("(%p, %d, %p, %p)\n", InfInformation, InfIndex, 00614 AlternativePlatformInfo, OriginalFileInfo); 00615 00616 if (OriginalFileInfo->cbSize != sizeof(*OriginalFileInfo)) 00617 { 00618 WARN("incorrect OriginalFileInfo->cbSize of %d\n", OriginalFileInfo->cbSize); 00619 SetLastError( ERROR_INVALID_USER_BUFFER ); 00620 return FALSE; 00621 } 00622 00623 OriginalFileInfoW.cbSize = sizeof(OriginalFileInfoW); 00624 ret = SetupQueryInfOriginalFileInformationW(InfInformation, InfIndex, 00625 AlternativePlatformInfo, &OriginalFileInfoW); 00626 if (ret) 00627 { 00628 WideCharToMultiByte(CP_ACP, 0, OriginalFileInfoW.OriginalInfName, -1, 00629 OriginalFileInfo->OriginalInfName, MAX_PATH, NULL, NULL); 00630 WideCharToMultiByte(CP_ACP, 0, OriginalFileInfoW.OriginalCatalogName, -1, 00631 OriginalFileInfo->OriginalCatalogName, MAX_PATH, NULL, NULL); 00632 } 00633 00634 return ret; 00635 } 00636 00637 /*********************************************************************** 00638 * SetupQueryInfOriginalFileInformationW (SETUPAPI.@) 00639 */ 00640 BOOL WINAPI SetupQueryInfOriginalFileInformationW( 00641 PSP_INF_INFORMATION InfInformation, UINT InfIndex, 00642 PSP_ALTPLATFORM_INFO AlternativePlatformInfo, 00643 PSP_ORIGINAL_FILE_INFO_W OriginalFileInfo) 00644 { 00645 LPCWSTR inf_name; 00646 LPCWSTR inf_path; 00647 HINF hinf; 00648 static const WCHAR wszVersion[] = { 'V','e','r','s','i','o','n',0 }; 00649 static const WCHAR wszCatalogFile[] = { 'C','a','t','a','l','o','g','F','i','l','e',0 }; 00650 00651 FIXME("(%p, %d, %p, %p): semi-stub\n", InfInformation, InfIndex, 00652 AlternativePlatformInfo, OriginalFileInfo); 00653 00654 if (OriginalFileInfo->cbSize != sizeof(*OriginalFileInfo)) 00655 { 00656 WARN("incorrect OriginalFileInfo->cbSize of %d\n", OriginalFileInfo->cbSize); 00657 SetLastError(ERROR_INVALID_USER_BUFFER); 00658 return FALSE; 00659 } 00660 00661 inf_path = (LPWSTR)&InfInformation->VersionData[0]; 00662 00663 /* FIXME: we should get OriginalCatalogName from CatalogFile line in 00664 * the original inf file and cache it, but that would require building a 00665 * .pnf file. */ 00666 hinf = SetupOpenInfFileW(inf_path, NULL, INF_STYLE_WIN4, NULL); 00667 if (hinf == INVALID_HANDLE_VALUE) return FALSE; 00668 00669 if (!SetupGetLineTextW(NULL, hinf, wszVersion, wszCatalogFile, 00670 OriginalFileInfo->OriginalCatalogName, 00671 sizeof(OriginalFileInfo->OriginalCatalogName)/sizeof(OriginalFileInfo->OriginalCatalogName[0]), 00672 NULL)) 00673 { 00674 OriginalFileInfo->OriginalCatalogName[0] = '\0'; 00675 } 00676 SetupCloseInfFile(hinf); 00677 00678 /* FIXME: not quite correct as we just return the same file name as 00679 * destination (copied) inf file, not the source (original) inf file. 00680 * to fix it properly would require building a .pnf file */ 00681 /* file name is stored in VersionData field of InfInformation */ 00682 inf_name = strrchrW(inf_path, '\\'); 00683 if (inf_name) inf_name++; 00684 else inf_name = inf_path; 00685 00686 strcpyW(OriginalFileInfo->OriginalInfName, inf_name); 00687 00688 return TRUE; 00689 } Generated on Sun May 27 2012 04:17:02 for ReactOS by
1.7.6.1
|