From 0d5fd6cd688b11166e8161cf4e65a79c2862c33e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herv=C3=A9=20Poussineau?= Date: Wed, 2 Aug 2006 20:45:13 +0000 Subject: [PATCH] - Implement INF_STYLE_OLDNT style in SetupOpenInfFileW - Add some documentation in header file svn path=/trunk/; revision=23422 --- reactos/dll/win32/setupapi/parser.c | 12 +++++- reactos/dll/win32/setupapi/setupapi_private.h | 39 ++++++++++++++----- 2 files changed, 39 insertions(+), 12 deletions(-) diff --git a/reactos/dll/win32/setupapi/parser.c b/reactos/dll/win32/setupapi/parser.c index 7a0f762473e..0b9974d3106 100644 --- a/reactos/dll/win32/setupapi/parser.c +++ b/reactos/dll/win32/setupapi/parser.c @@ -910,7 +910,7 @@ static void append_inf_file( struct inf_file *parent, struct inf_file *child ) * * parse an INF file. */ -static struct inf_file *parse_file( HANDLE handle, UINT *error_line ) +static struct inf_file *parse_file( HANDLE handle, UINT *error_line, DWORD style ) { void *buffer; DWORD err = 0; @@ -962,6 +962,8 @@ static struct inf_file *parse_file( HANDLE handle, UINT *error_line ) if (!err) /* now check signature */ { int version_index = find_section( file, Version ); + if (version_index == -1 && (style & INF_STYLE_OLDNT)) + goto done; if (version_index != -1) { struct line *line = find_line( file, version_index, Signature ); @@ -1148,6 +1150,12 @@ HINF WINAPI SetupOpenInfFileW( PCWSTR name, PCWSTR class, DWORD style, UINT *err TRACE("%s %s %lx %p\n", debugstr_w(name), debugstr_w(class), style, error); + if (style & ~(INF_STYLE_OLDNT | INF_STYLE_WIN4)) + { + SetLastError(ERROR_INVALID_PARAMETER); + return (HINF)INVALID_HANDLE_VALUE; + } + if (strchrW( name, '\\' ) || strchrW( name, '/' )) { if (!(len = GetFullPathNameW( name, 0, NULL, NULL ))) return (HINF)INVALID_HANDLE_VALUE; @@ -1185,7 +1193,7 @@ HINF WINAPI SetupOpenInfFileW( PCWSTR name, PCWSTR class, DWORD style, UINT *err if (handle != INVALID_HANDLE_VALUE) { - file = parse_file( handle, error ); + file = parse_file( handle, error, style ); CloseHandle( handle ); } if (!file) diff --git a/reactos/dll/win32/setupapi/setupapi_private.h b/reactos/dll/win32/setupapi/setupapi_private.h index f83c8b15c53..8977a33cb4b 100644 --- a/reactos/dll/win32/setupapi/setupapi_private.h +++ b/reactos/dll/win32/setupapi/setupapi_private.h @@ -1,6 +1,6 @@ /* * Copyright 2001 Andreas Mohr - * Copyright 2005 Hervé Poussineau + * Copyright 2005-2006 Hervé Poussineau * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -54,6 +54,7 @@ struct DeviceInterface /* Element of DeviceInfoElement.InterfaceListHead */ { LIST_ENTRY ListEntry; + /* Link to is parent device */ struct DeviceInfoElement* DeviceInfo; GUID InterfaceClassGuid; @@ -64,14 +65,19 @@ struct DeviceInterface /* Element of DeviceInfoElement.InterfaceListHead */ */ DWORD Flags; - WCHAR SymbolicLink[ANYSIZE_ARRAY]; /* \\?\ACPI#PNP0501#4&2658d0a0&0#{GUID} */ + /* Contains the symbolic link of this interface, for example + * \\?\ACPI#PNP0501#4&2658d0a0&0#{GUID} */ + WCHAR SymbolicLink[ANYSIZE_ARRAY]; }; /* We don't want to open the .inf file to read only one information in it, so keep a handle to it once it * has been already loaded once. Keep also a reference counter */ struct InfFileDetails { + /* Handle to the .inf file */ HINF hInf; + /* Reference count to this object. Once it raises 0, the .inf file is + * automatically closed and this memory structure is deleted */ LONG References; /* Contains the directory name of the .inf file. @@ -81,6 +87,7 @@ struct InfFileDetails * Points into szData at then end of the structure */ PCWSTR FileName; + /* Variable size array (contains data for DirectoryName and FileName) */ WCHAR szData[ANYSIZE_ARRAY]; }; @@ -105,9 +112,11 @@ struct ClassInstallParams struct DeviceInfoElement /* Element of DeviceInfoSet.ListHead */ { LIST_ENTRY ListEntry; - DEVINST dnDevInst; /* Used in CM_* functions */ + /* Used when dealing with CM_* functions */ + DEVINST dnDevInst; - /* Reserved Field points to a struct DriverInfoElement */ + /* Reserved Field of SP_DEVINSTALL_PARAMS_W structure + * points to a struct DriverInfoElement */ SP_DEVINSTALL_PARAMS_W InstallParams; /* Information about devnode: @@ -151,23 +160,29 @@ struct DeviceInfoElement /* Element of DeviceInfoSet.ListHead */ /* Used by SetupDiGetClassInstallParamsW/SetupDiSetClassInstallParamsW */ struct ClassInstallParams ClassInstallParams; + /* Variable size array (contains data for DeviceName, UniqueId, DeviceDescription) */ WCHAR Data[ANYSIZE_ARRAY]; }; struct DeviceInfoSet /* HDEVINFO */ { DWORD magic; /* SETUP_DEV_INFO_SET_MAGIC */ - GUID ClassGuid; /* If != GUID_NULL, only devices of this class can be in the device info set */ - HKEY HKLM; /* Local or distant HKEY_LOCAL_MACHINE registry key */ - HMACHINE hMachine; /* Used in CM_* functions */ + /* If != GUID_NULL, only devices of this class can be in the device info set */ + GUID ClassGuid; + /* Local or distant HKEY_LOCAL_MACHINE registry key */ + HKEY HKLM; + /* Used when dealing with CM_* functions */ + HMACHINE hMachine; /* Reserved Field points to a struct DriverInfoElement */ SP_DEVINSTALL_PARAMS_W InstallParams; - /* If the driver is not searched/detected, this list is empty */ - LIST_ENTRY DriverListHead; /* List of struct DriverInfoElement */ + /* List of struct DriverInfoElement (if no driver has been + * searched/detected, this list is empty) */ + LIST_ENTRY DriverListHead; - LIST_ENTRY ListHead; /* List of struct DeviceInfoElement */ + /* List of struct DeviceInfoElement */ + LIST_ENTRY ListHead; struct DeviceInfoElement *SelectedDevice; /* Used by SetupDiGetClassInstallParamsW/SetupDiSetClassInstallParamsW */ @@ -177,6 +192,8 @@ struct DeviceInfoSet /* HDEVINFO */ * or NULL if related to local machine. Points into szData field at the * end of the structure */ PCWSTR MachineName; + + /* Variable size array (contains data for MachineName) */ WCHAR szData[ANYSIZE_ARRAY]; }; @@ -188,6 +205,8 @@ struct ClassImageList * or NULL if related to local machine. Points into szData field at the * end of the structure */ PCWSTR MachineName; + + /* Variable size array (contains data for MachineName) */ WCHAR szData[ANYSIZE_ARRAY]; };