{
MachineNameW = MultiByteToUnicode(MachineName, CP_ACP);
if (MachineNameW == NULL)
- return (HDEVINFO)INVALID_HANDLE_VALUE;
+ return INVALID_HANDLE_VALUE;
}
hDevInfo = SetupDiCreateDeviceInfoListExW(ClassGuid, hwndParent,
DWORD size = FIELD_OFFSET(struct DeviceInfoSet, szData);
DWORD rc;
CONFIGRET cr;
- HDEVINFO ret = (HDEVINFO)INVALID_HANDLE_VALUE;
+ HDEVINFO ret = INVALID_HANDLE_VALUE;
TRACE("%s %p %s %p\n", debugstr_guid(ClassGuid), hwndParent,
debugstr_w(MachineName), Reserved);
if (Reserved != NULL)
{
SetLastError(ERROR_INVALID_PARAMETER);
- return (HDEVINFO)INVALID_HANDLE_VALUE;
+ return INVALID_HANDLE_VALUE;
}
list = MyMalloc(size);
if (!list)
{
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
- return (HDEVINFO)INVALID_HANDLE_VALUE;
+ return INVALID_HANDLE_VALUE;
}
ZeroMemory(list, FIELD_OFFSET(struct DeviceInfoSet, szData));
TRACE("%p %p %lu %lu %lu %p %s\n", DeviceInfoSet, DeviceInfoData, Scope,
HwProfile, KeyType, InfHandle, debugstr_w(InfSectionName));
- if (!DeviceInfoSet || DeviceInfoSet == (HDEVINFO)INVALID_HANDLE_VALUE)
+ if (!DeviceInfoSet || DeviceInfoSet == INVALID_HANDLE_VALUE)
{
SetLastError(ERROR_INVALID_HANDLE);
return INVALID_HANDLE_VALUE;
SetLastError(ERROR_INVALID_DEVINST_NAME);
return FALSE;
}
- if (!DeviceInfoSet || DeviceInfoSet == (HDEVINFO)INVALID_HANDLE_VALUE)
+ if (!DeviceInfoSet || DeviceInfoSet == INVALID_HANDLE_VALUE)
{
SetLastError(ERROR_INVALID_HANDLE);
return FALSE;
TRACE("%p %p %08x %p %p %p\n", DeviceInfoSet, DeviceInfoData, Flags,
CompareProc, CompareContext, DupDeviceInfoData);
- if (!DeviceInfoSet || DeviceInfoSet == (HDEVINFO)INVALID_HANDLE_VALUE)
+ if (!DeviceInfoSet || DeviceInfoSet == INVALID_HANDLE_VALUE)
{
SetLastError(ERROR_INVALID_HANDLE);
return FALSE;
SetLastError(ERROR_INVALID_PARAMETER);
return FALSE;
}
- if (devinfo && devinfo != (HDEVINFO)INVALID_HANDLE_VALUE)
+ if (devinfo && devinfo != INVALID_HANDLE_VALUE)
{
struct DeviceInfoSet *list = (struct DeviceInfoSet *)devinfo;
if (list->magic == SETUP_DEVICE_INFO_SET_MAGIC)
&size);
if (!ret && GetLastError() != ERROR_INSUFFICIENT_BUFFER)
return FALSE;
- instanceId = MyMalloc(DeviceInstanceIdSize * sizeof(WCHAR));
+ instanceId = MyMalloc(size * sizeof(WCHAR));
if (instanceId)
{
ret = SetupDiGetDeviceInstanceIdW(DeviceInfoSet,
enumstrW = MultiByteToUnicode(enumstr, CP_ACP);
if (!enumstrW)
{
- ret = (HDEVINFO)INVALID_HANDLE_VALUE;
+ ret = INVALID_HANDLE_VALUE;
goto end;
}
}
if (!machineW)
{
MyFree(enumstrW);
- ret = (HDEVINFO)INVALID_HANDLE_VALUE;
+ ret = INVALID_HANDLE_VALUE;
goto end;
}
}
TRACE("%p %p\n", DeviceInfoSet, DevInfoData);
- if (!DeviceInfoSet || DeviceInfoSet == (HDEVINFO)INVALID_HANDLE_VALUE)
+ if (!DeviceInfoSet || DeviceInfoSet == INVALID_HANDLE_VALUE)
{
SetLastError(ERROR_INVALID_HANDLE);
return FALSE;
TRACE("%p %p\n", DeviceInfoSet, DevInfoData);
- if (!DeviceInfoSet || DeviceInfoSet == (HDEVINFO)INVALID_HANDLE_VALUE)
+ if (!DeviceInfoSet || DeviceInfoSet == INVALID_HANDLE_VALUE)
{
SetLastError(ERROR_INVALID_HANDLE);
return FALSE;
debugstr_guid(InterfaceClassGuid), debugstr_w(ReferenceString),
CreationFlags, DeviceInterfaceData);
- if (!DeviceInfoSet || DeviceInfoSet == (HDEVINFO)INVALID_HANDLE_VALUE)
+ if (!DeviceInfoSet || DeviceInfoSet == INVALID_HANDLE_VALUE)
{
SetLastError(ERROR_INVALID_HANDLE);
return FALSE;
TRACE("%p %p %d %08x %p %p\n", DeviceInfoSet, DeviceInterfaceData, Reserved,
samDesired, InfHandle, InfSectionName);
- if (!DeviceInfoSet || DeviceInfoSet == (HDEVINFO)INVALID_HANDLE_VALUE ||
+ if (!DeviceInfoSet || DeviceInfoSet == INVALID_HANDLE_VALUE ||
set->magic != SETUP_DEVICE_INFO_SET_MAGIC)
{
SetLastError(ERROR_INVALID_HANDLE);
TRACE("%p %p %d\n", DeviceInfoSet, DeviceInterfaceData, Reserved);
- if (!DeviceInfoSet || DeviceInfoSet == (HDEVINFO)INVALID_HANDLE_VALUE ||
+ if (!DeviceInfoSet || DeviceInfoSet == INVALID_HANDLE_VALUE ||
set->magic != SETUP_DEVICE_INFO_SET_MAGIC)
{
SetLastError(ERROR_INVALID_HANDLE);
TRACE("%p, %p, %s, %d, %p\n", DeviceInfoSet, DeviceInfoData,
debugstr_guid(InterfaceClassGuid), MemberIndex, DeviceInterfaceData);
- if (!DeviceInfoSet || DeviceInfoSet == (HDEVINFO)INVALID_HANDLE_VALUE ||
+ if (!DeviceInfoSet || DeviceInfoSet == INVALID_HANDLE_VALUE ||
set->magic != SETUP_DEVICE_INFO_SET_MAGIC)
{
SetLastError(ERROR_INVALID_HANDLE);
BOOL ret = FALSE;
TRACE("%p\n", devinfo);
- if (devinfo && devinfo != (HDEVINFO)INVALID_HANDLE_VALUE)
+ if (devinfo && devinfo != INVALID_HANDLE_VALUE)
{
struct DeviceInfoSet *list = (struct DeviceInfoSet *)devinfo;
DeviceInterfaceData, DeviceInterfaceDetailData,
DeviceInterfaceDetailDataSize, RequiredSize, DeviceInfoData);
- if (!DeviceInfoSet || DeviceInfoSet == (HDEVINFO)INVALID_HANDLE_VALUE ||
+ if (!DeviceInfoSet || DeviceInfoSet == INVALID_HANDLE_VALUE ||
set->magic != SETUP_DEVICE_INFO_SET_MAGIC)
{
SetLastError(ERROR_INVALID_HANDLE);
DeviceInterfaceData, DeviceInterfaceDetailData,
DeviceInterfaceDetailDataSize, RequiredSize, DeviceInfoData);
- if (!DeviceInfoSet || DeviceInfoSet == (HDEVINFO)INVALID_HANDLE_VALUE ||
+ if (!DeviceInfoSet || DeviceInfoSet == INVALID_HANDLE_VALUE ||
set->magic != SETUP_DEVICE_INFO_SET_MAGIC)
{
SetLastError(ERROR_INVALID_HANDLE);
return ret;
}
+struct PropertyMapEntry
+{
+ DWORD regType;
+ LPCSTR nameA;
+ LPCWSTR nameW;
+};
+
+static struct PropertyMapEntry PropertyMap[] = {
+ { REG_SZ, "DeviceDesc", REGSTR_VAL_DEVDESC },
+ { REG_MULTI_SZ, "HardwareId", REGSTR_VAL_HARDWAREID },
+ { REG_MULTI_SZ, "CompatibleIDs", REGSTR_VAL_COMPATIBLEIDS },
+ { 0, NULL, NULL }, /* SPDRP_UNUSED0 */
+ { REG_SZ, "Service", REGSTR_VAL_SERVICE },
+ { 0, NULL, NULL }, /* SPDRP_UNUSED1 */
+ { 0, NULL, NULL }, /* SPDRP_UNUSED2 */
+ { REG_SZ, "Class", REGSTR_VAL_CLASS },
+ { REG_SZ, "ClassGUID", REGSTR_VAL_CLASSGUID },
+ { REG_SZ, "Driver", REGSTR_VAL_DRIVER },
+ { REG_DWORD, "ConfigFlags", REGSTR_VAL_CONFIGFLAGS },
+ { REG_SZ, "Mfg", REGSTR_VAL_MFG },
+ { REG_SZ, "FriendlyName", REGSTR_VAL_FRIENDLYNAME },
+ { REG_SZ, "LocationInformation", REGSTR_VAL_LOCATION_INFORMATION },
+ { 0, NULL, NULL }, /* SPDRP_PHYSICAL_DEVICE_OBJECT_NAME */
+ { REG_DWORD, "Capabilities", REGSTR_VAL_CAPABILITIES },
+ { REG_DWORD, "UINumber", REGSTR_VAL_UI_NUMBER },
+ { REG_MULTI_SZ, "UpperFilters", REGSTR_VAL_UPPERFILTERS },
+ { REG_MULTI_SZ, "LowerFilters", REGSTR_VAL_LOWERFILTERS },
+ { 0, NULL, NULL }, /* SPDRP_BUSTYPEGUID */
+ { 0, NULL, NULL }, /* SPDRP_LEGACYBUSTYPE */
+ { 0, NULL, NULL }, /* SPDRP_BUSNUMBER */
+ { 0, NULL, NULL }, /* SPDRP_ENUMERATOR_NAME */
+ { REG_BINARY, "Security", REGSTR_SECURITY },
+ { 0, NULL, NULL }, /* SPDRP_SECURITY_SDS */
+ { 0, NULL, NULL }, /* SPDRP_DEVTYPE */
+ { 0, NULL, NULL }, /* SPDRP_EXCLUSIVE */
+ { 0, NULL, NULL }, /* SPDRP_CHARACTERISTICS */
+ { 0, NULL, NULL }, /* SPDRP_ADDRESS */
+ { REG_SZ, "UINumberDescFormat", REGSTR_UI_NUMBER_DESC_FORMAT },
+ { 0, NULL, NULL }, /* SPDRP_DEVICE_POWER_DATA */
+ { 0, NULL, NULL }, /* SPDRP_REMOVAL_POLICY */
+ { 0, NULL, NULL }, /* SPDRP_REMOVAL_POLICY_HW_DEFAULT */
+ { 0, NULL, NULL }, /* SPDRP_REMOVAL_POLICY_OVERRIDE */
+ { 0, NULL, NULL }, /* SPDRP_INSTALL_STATE */
+};
+
/***********************************************************************
* SetupDiGetDeviceRegistryPropertyA (SETUPAPI.@)
*/
DWORD PropertyBufferSize,
PDWORD RequiredSize)
{
- HKEY hEnumKey, hKey;
- DWORD rc;
BOOL ret = FALSE;
struct DeviceInfoSet *set = (struct DeviceInfoSet *)DeviceInfoSet;
struct DeviceInfo *devInfo;
SetLastError(ERROR_INVALID_PARAMETER);
return FALSE;
}
- if (Property >= SPDRP_MAXIMUM_PROPERTY)
- {
- SetLastError(ERROR_INVALID_PARAMETER);
- return FALSE;
- }
-
devInfo = (struct DeviceInfo *)DeviceInfoData->Reserved;
+ if (Property < sizeof(PropertyMap) / sizeof(PropertyMap[0])
+ && PropertyMap[Property].nameW)
{
- switch (Property)
- {
- case SPDRP_CAPABILITIES:
- case SPDRP_CLASS:
- case SPDRP_CLASSGUID:
- case SPDRP_COMPATIBLEIDS:
- case SPDRP_CONFIGFLAGS:
- case SPDRP_DEVICEDESC:
- case SPDRP_DRIVER:
- case SPDRP_FRIENDLYNAME:
- case SPDRP_HARDWAREID:
- case SPDRP_LOCATION_INFORMATION:
- case SPDRP_LOWERFILTERS:
- case SPDRP_MFG:
- case SPDRP_SECURITY:
- case SPDRP_SERVICE:
- case SPDRP_UI_NUMBER:
- case SPDRP_UI_NUMBER_DESC_FORMAT:
- case SPDRP_UPPERFILTERS:
- {
- LPCWSTR RegistryPropertyName;
- DWORD BufferSize;
-
- switch (Property)
- {
- case SPDRP_CAPABILITIES:
- RegistryPropertyName = REGSTR_VAL_CAPABILITIES; break;
- case SPDRP_CLASS:
- RegistryPropertyName = REGSTR_VAL_CLASS; break;
- case SPDRP_CLASSGUID:
- RegistryPropertyName = REGSTR_VAL_CLASSGUID; break;
- case SPDRP_COMPATIBLEIDS:
- RegistryPropertyName = REGSTR_VAL_COMPATIBLEIDS; break;
- case SPDRP_CONFIGFLAGS:
- RegistryPropertyName = REGSTR_VAL_CONFIGFLAGS; break;
- case SPDRP_DEVICEDESC:
- RegistryPropertyName = REGSTR_VAL_DEVDESC; break;
- case SPDRP_DRIVER:
- RegistryPropertyName = REGSTR_VAL_DRIVER; break;
- case SPDRP_FRIENDLYNAME:
- RegistryPropertyName = REGSTR_VAL_FRIENDLYNAME; break;
- case SPDRP_HARDWAREID:
- RegistryPropertyName = REGSTR_VAL_HARDWAREID; break;
- case SPDRP_LOCATION_INFORMATION:
- RegistryPropertyName = REGSTR_VAL_LOCATION_INFORMATION; break;
- case SPDRP_LOWERFILTERS:
- RegistryPropertyName = REGSTR_VAL_LOWERFILTERS; break;
- case SPDRP_MFG:
- RegistryPropertyName = REGSTR_VAL_MFG; break;
- case SPDRP_SECURITY:
- RegistryPropertyName = REGSTR_SECURITY; break;
- case SPDRP_SERVICE:
- RegistryPropertyName = REGSTR_VAL_SERVICE; break;
- case SPDRP_UI_NUMBER:
- RegistryPropertyName = REGSTR_VAL_UI_NUMBER; break;
- case SPDRP_UI_NUMBER_DESC_FORMAT:
- RegistryPropertyName = REGSTR_UI_NUMBER_DESC_FORMAT; break;
- case SPDRP_UPPERFILTERS:
- RegistryPropertyName = REGSTR_VAL_UPPERFILTERS; break;
- default:
- /* Should not happen */
- RegistryPropertyName = NULL; break;
- }
-
- /* Open registry key name */
- rc = RegOpenKeyExW(
- set->HKLM,
- REGSTR_PATH_SYSTEMENUM,
- 0, /* Options */
- 0,
- &hEnumKey);
- if (rc != ERROR_SUCCESS)
- {
- SetLastError(rc);
- break;
- }
- rc = RegOpenKeyExW(
- hEnumKey,
- devInfo->Data,
- 0, /* Options */
- KEY_QUERY_VALUE,
- &hKey);
- RegCloseKey(hEnumKey);
- if (rc != ERROR_SUCCESS)
- {
- SetLastError(rc);
- break;
- }
- /* Read registry entry */
- BufferSize = PropertyBufferSize;
- rc = RegQueryValueExW(
- hKey,
- RegistryPropertyName,
- NULL, /* Reserved */
- PropertyRegDataType,
- PropertyBuffer,
- &BufferSize);
- if (RequiredSize)
- *RequiredSize = BufferSize;
- switch(rc) {
- case ERROR_SUCCESS:
- if (PropertyBuffer != NULL || BufferSize == 0)
- ret = TRUE;
- else
- SetLastError(ERROR_INSUFFICIENT_BUFFER);
- break;
- case ERROR_MORE_DATA:
- SetLastError(ERROR_INSUFFICIENT_BUFFER);
- break;
- default:
- SetLastError(rc);
- }
- RegCloseKey(hKey);
- break;
- }
-
- case SPDRP_PHYSICAL_DEVICE_OBJECT_NAME:
- {
- DWORD required = (strlenW(devInfo->Data) + 1) * sizeof(WCHAR);
+ DWORD size = PropertyBufferSize;
+ HKEY hKey;
+ LONG l;
+ hKey = SetupDiOpenDevRegKey(DeviceInfoSet, DeviceInfoData, DICS_FLAG_GLOBAL, 0, DIREG_DEV, KEY_QUERY_VALUE);
+ if (hKey == INVALID_HANDLE_VALUE)
+ return FALSE;
+ l = RegQueryValueExW(hKey, PropertyMap[Property].nameW,
+ NULL, PropertyRegDataType, PropertyBuffer, &size);
+ RegCloseKey(hKey);
- if (PropertyRegDataType)
- *PropertyRegDataType = REG_SZ;
- if (RequiredSize)
- *RequiredSize = required;
- if (PropertyBufferSize >= required)
- {
- strcpyW((LPWSTR)PropertyBuffer, devInfo->Data);
+ if (RequiredSize)
+ *RequiredSize = size;
+ switch(l) {
+ case ERROR_SUCCESS:
+ if (PropertyBuffer != NULL || size == 0)
ret = TRUE;
- }
else
SetLastError(ERROR_INSUFFICIENT_BUFFER);
break;
- }
-
- /*case SPDRP_BUSTYPEGUID:
- case SPDRP_LEGACYBUSTYPE:
- case SPDRP_BUSNUMBER:
- case SPDRP_ENUMERATOR_NAME:
- case SPDRP_SECURITY_SDS:
- case SPDRP_DEVTYPE:
- case SPDRP_EXCLUSIVE:
- case SPDRP_CHARACTERISTICS:
- case SPDRP_ADDRESS:
- case SPDRP_DEVICE_POWER_DATA:*/
-#if (WINVER >= 0x501)
- /*case SPDRP_REMOVAL_POLICY:
- case SPDRP_REMOVAL_POLICY_HW_DEFAULT:
- case SPDRP_REMOVAL_POLICY_OVERRIDE:
- case SPDRP_INSTALL_STATE:*/
-#endif
-
+ case ERROR_MORE_DATA:
+ SetLastError(ERROR_INSUFFICIENT_BUFFER);
+ break;
default:
- {
- ERR("Property 0x%lx not implemented\n", Property);
- SetLastError(ERROR_NOT_SUPPORTED);
- }
+ SetLastError(l);
+ }
+ }
+ else if (Property == SPDRP_PHYSICAL_DEVICE_OBJECT_NAME)
+ {
+ DWORD required = (strlenW(devInfo->Data) + 1) * sizeof(WCHAR);
+
+ if (PropertyRegDataType)
+ *PropertyRegDataType = REG_SZ;
+ if (RequiredSize)
+ *RequiredSize = required;
+ if (PropertyBufferSize >= required)
+ {
+ strcpyW((LPWSTR)PropertyBuffer, devInfo->Data);
+ ret = TRUE;
}
+ else
+ SetLastError(ERROR_INSUFFICIENT_BUFFER);
+ }
+ else
+ {
+ ERR("Property 0x%lx not implemented\n", Property);
+ SetLastError(ERROR_NOT_SUPPORTED);
}
return ret;
}
SetLastError(ERROR_INVALID_PARAMETER);
return FALSE;
}
-
- switch (Property)
+ if (Property < sizeof(PropertyMap) / sizeof(PropertyMap[0])
+ && PropertyMap[Property].nameW)
{
- case SPDRP_COMPATIBLEIDS:
- case SPDRP_CONFIGFLAGS:
- case SPDRP_FRIENDLYNAME:
- case SPDRP_HARDWAREID:
- case SPDRP_LOCATION_INFORMATION:
- case SPDRP_LOWERFILTERS:
- case SPDRP_SECURITY:
- case SPDRP_SERVICE:
- case SPDRP_UI_NUMBER_DESC_FORMAT:
- case SPDRP_UPPERFILTERS:
- {
- LPCWSTR RegistryPropertyName;
- DWORD RegistryDataType;
- HKEY hKey;
- LONG rc;
-
- switch (Property)
- {
- case SPDRP_COMPATIBLEIDS:
- RegistryPropertyName = REGSTR_VAL_COMPATIBLEIDS;
- RegistryDataType = REG_MULTI_SZ;
- break;
- case SPDRP_CONFIGFLAGS:
- RegistryPropertyName = REGSTR_VAL_CONFIGFLAGS;
- RegistryDataType = REG_DWORD;
- break;
- case SPDRP_FRIENDLYNAME:
- RegistryPropertyName = REGSTR_VAL_FRIENDLYNAME;
- RegistryDataType = REG_SZ;
- break;
- case SPDRP_HARDWAREID:
- RegistryPropertyName = REGSTR_VAL_HARDWAREID;
- RegistryDataType = REG_MULTI_SZ;
- break;
- case SPDRP_LOCATION_INFORMATION:
- RegistryPropertyName = REGSTR_VAL_LOCATION_INFORMATION;
- RegistryDataType = REG_SZ;
- break;
- case SPDRP_LOWERFILTERS:
- RegistryPropertyName = REGSTR_VAL_LOWERFILTERS;
- RegistryDataType = REG_MULTI_SZ;
- break;
- case SPDRP_SECURITY:
- RegistryPropertyName = REGSTR_SECURITY;
- RegistryDataType = REG_BINARY;
- break;
- case SPDRP_SERVICE:
- RegistryPropertyName = REGSTR_VAL_SERVICE;
- RegistryDataType = REG_SZ;
- break;
- case SPDRP_UI_NUMBER_DESC_FORMAT:
- RegistryPropertyName = REGSTR_UI_NUMBER_DESC_FORMAT;
- RegistryDataType = REG_SZ;
- break;
- case SPDRP_UPPERFILTERS:
- RegistryPropertyName = REGSTR_VAL_UPPERFILTERS;
- RegistryDataType = REG_MULTI_SZ;
- break;
- default:
- /* Should not happen */
- RegistryPropertyName = NULL;
- RegistryDataType = REG_BINARY;
- break;
- }
- /* Open device registry key */
- hKey = SetupDiOpenDevRegKey(DeviceInfoSet, DeviceInfoData, DICS_FLAG_GLOBAL, 0, DIREG_DEV, KEY_SET_VALUE);
- if (hKey != INVALID_HANDLE_VALUE)
- {
- /* Write new data */
- rc = RegSetValueExW(
- hKey,
- RegistryPropertyName,
- 0, /* Reserved */
- RegistryDataType,
- PropertyBuffer,
- PropertyBufferSize);
- if (rc == ERROR_SUCCESS)
- ret = TRUE;
- else
- SetLastError(rc);
- RegCloseKey(hKey);
- }
- break;
- }
-
- /*case SPDRP_CHARACTERISTICS:
- case SPDRP_DEVTYPE:
- case SPDRP_EXCLUSIVE:*/
-#if (WINVER >= 0x501)
- //case SPDRP_REMOVAL_POLICY_OVERRIDE:
-#endif
- //case SPDRP_SECURITY_SDS:
-
- default:
- {
- ERR("Property 0x%lx not implemented\n", Property);
- SetLastError(ERROR_NOT_SUPPORTED);
- }
+ HKEY hKey;
+ LONG l;
+ hKey = SetupDiOpenDevRegKey(DeviceInfoSet, DeviceInfoData, DICS_FLAG_GLOBAL, 0, DIREG_DEV, KEY_SET_VALUE);
+ if (hKey == INVALID_HANDLE_VALUE)
+ return FALSE;
+ /* Write new data */
+ l = RegSetValueExW(
+ hKey, PropertyMap[Property].nameW, 0,
+ PropertyMap[Property].regType, PropertyBuffer,
+ PropertyBufferSize);
+ if (!l)
+ ret = TRUE;
+ else
+ SetLastError(l);
+ RegCloseKey(hKey);
+ }
+ else
+ {
+ ERR("Property 0x%lx not implemented\n", Property);
+ SetLastError(ERROR_NOT_SUPPORTED);
}
TRACE("Returning %d\n", ret);
TRACE("%p %p %d %d %d %x\n", DeviceInfoSet, DeviceInfoData,
Scope, HwProfile, KeyType, samDesired);
- if (!DeviceInfoSet || DeviceInfoSet == (HDEVINFO)INVALID_HANDLE_VALUE)
+ if (!DeviceInfoSet || DeviceInfoSet == INVALID_HANDLE_VALUE)
{
SetLastError(ERROR_INVALID_HANDLE);
return INVALID_HANDLE_VALUE;
TRACE("%p %p %d %d %d\n", DeviceInfoSet, DeviceInfoData, Scope, HwProfile,
KeyType);
- if (!DeviceInfoSet || DeviceInfoSet == (HDEVINFO)INVALID_HANDLE_VALUE)
+ if (!DeviceInfoSet || DeviceInfoSet == INVALID_HANDLE_VALUE)
{
SetLastError(ERROR_INVALID_HANDLE);
return FALSE;
/* retrieve a given line from section/line index */
-inline static struct line *get_line( struct inf_file *file, unsigned int section_index,
+static inline struct line *get_line( struct inf_file *file, unsigned int section_index,
unsigned int line_index )
{
struct section *section;
/* push the current state on the parser stack */
-inline static void push_state( struct parser *parser, enum parser_state state )
+static inline void push_state( struct parser *parser, enum parser_state state )
{
ASSERT( parser->stack_pos < sizeof(parser->stack)/sizeof(parser->stack[0]) );
parser->stack[parser->stack_pos++] = state;
/* pop the current state */
-inline static void pop_state( struct parser *parser )
+static inline void pop_state( struct parser *parser )
{
ASSERT( parser->stack_pos );
parser->state = parser->stack[--parser->stack_pos];
/* set the parser state and return the previous one */
-inline static enum parser_state set_state( struct parser *parser, enum parser_state state )
+static inline enum parser_state set_state( struct parser *parser, enum parser_state state )
{
enum parser_state ret = parser->state;
parser->state = state;
/* check if the pointer points to an end of file */
-inline static int is_eof( const struct parser *parser, const WCHAR *ptr )
+static inline int is_eof( const struct parser *parser, const WCHAR *ptr )
{
return (ptr >= parser->end || *ptr == CONTROL_Z);
}
/* check if the pointer points to an end of line */
-inline static int is_eol( const struct parser *parser, const WCHAR *ptr )
+static inline int is_eol( const struct parser *parser, const WCHAR *ptr )
{
return (ptr >= parser->end || *ptr == CONTROL_Z || *ptr == '\n');
}
HINF WINAPI SetupOpenInfFileA( PCSTR name, PCSTR class, DWORD style, UINT *error )
{
UNICODE_STRING nameW, classW;
- HINF ret = (HINF)INVALID_HANDLE_VALUE;
+ HINF ret = INVALID_HANDLE_VALUE;
classW.Buffer = NULL;
if (class && !RtlCreateUnicodeStringFromAsciiz( &classW, class ))
if (strchrW( name, '\\' ) || strchrW( name, '/' ))
{
- if (!(len = GetFullPathNameW( name, 0, NULL, NULL ))) return (HINF)INVALID_HANDLE_VALUE;
+ if (!(len = GetFullPathNameW( name, 0, NULL, NULL ))) return INVALID_HANDLE_VALUE;
if (!(path = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) )))
{
SetLastError( ERROR_NOT_ENOUGH_MEMORY );
- return (HINF)INVALID_HANDLE_VALUE;
+ return INVALID_HANDLE_VALUE;
}
GetFullPathNameW( name, len, path, NULL );
handle = CreateFileW( path, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, 0 );
if (!(path = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) )))
{
SetLastError( ERROR_NOT_ENOUGH_MEMORY );
- return (HINF)INVALID_HANDLE_VALUE;
+ return INVALID_HANDLE_VALUE;
}
GetWindowsDirectoryW( path, len );
p = path + strlenW(path);
if (!file)
{
HeapFree( GetProcessHeap(), 0, path );
- return (HINF)INVALID_HANDLE_VALUE;
+ return INVALID_HANDLE_VALUE;
}
TRACE( "%s -> %p\n", debugstr_w(path), file );
file->filename = path;
/* Not enough memory */
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
SetupCloseInfFile((HINF)file);
- return (HINF)INVALID_HANDLE_VALUE;
+ return INVALID_HANDLE_VALUE;
}
else if (!PARSER_GetInfClassW((HINF)file, &ClassGuid, ClassName, strlenW(class) + 1, NULL))
{
HeapFree(GetProcessHeap(), 0, ClassName);
SetLastError(ERROR_CLASS_MISMATCH);
SetupCloseInfFile((HINF)file);
- return (HINF)INVALID_HANDLE_VALUE;
+ return INVALID_HANDLE_VALUE;
}
else if (strcmpW(class, ClassName) != 0)
{
HeapFree(GetProcessHeap(), 0, ClassName);
SetLastError(ERROR_CLASS_MISMATCH);
SetupCloseInfFile((HINF)file);
- return (HINF)INVALID_HANDLE_VALUE;
+ return INVALID_HANDLE_VALUE;
}
HeapFree(GetProcessHeap(), 0, ClassName);
}
if (!name) return SetupOpenAppendInfFileW( NULL, parent_hinf, error );
child_hinf = SetupOpenInfFileA( name, NULL, INF_STYLE_WIN4, error );
- if (child_hinf == (HINF)INVALID_HANDLE_VALUE) return FALSE;
+ if (child_hinf == INVALID_HANDLE_VALUE) return FALSE;
append_inf_file( parent_hinf, child_hinf );
TRACE( "%p: appended %s (%p)\n", parent_hinf, debugstr_a(name), child_hinf );
return TRUE;
sizeof(filename)/sizeof(WCHAR), NULL ))
{
child_hinf = SetupOpenInfFileW( filename, NULL, INF_STYLE_WIN4, error );
- if (child_hinf == (HINF)INVALID_HANDLE_VALUE) return FALSE;
+ if (child_hinf == INVALID_HANDLE_VALUE) return FALSE;
append_inf_file( parent_hinf, child_hinf );
TRACE( "%p: appended %s (%p)\n", parent_hinf, debugstr_w(filename), child_hinf );
}
return TRUE;
}
child_hinf = SetupOpenInfFileW( name, NULL, INF_STYLE_WIN4, error );
- if (child_hinf == (HINF)INVALID_HANDLE_VALUE) return FALSE;
+ if (child_hinf == INVALID_HANDLE_VALUE) return FALSE;
append_inf_file( parent_hinf, child_hinf );
TRACE( "%p: appended %s (%p)\n", parent_hinf, debugstr_w(name), child_hinf );
return TRUE;