Author: cgutman
Date: Wed Nov 16 22:01:11 2011
New Revision: 54402
URL:
http://svn.reactos.org/svn/reactos?rev=54402&view=rev
Log:
[NDIS]
- Fix a critical bug in registry entry parsing that was causing all REG_SZ values to be
reported as NdisParameterTypeInteger
- Distinguish between NdisParameterTypeInteger and NdisParameterTypeHexInteger
- 3Com NICs are fully functional now [bug 4330]
Modified:
trunk/reactos/drivers/network/ndis/ndis/config.c
Modified: trunk/reactos/drivers/network/ndis/ndis/config.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/network/ndis/ndis/…
==============================================================================
--- trunk/reactos/drivers/network/ndis/ndis/config.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/network/ndis/ndis/config.c [iso-8859-1] Wed Nov 16 22:01:11
2011
@@ -320,304 +320,6 @@
*Status = NDIS_STATUS_SUCCESS;
}
-
-/*
- * @implemented
- */
-VOID
-EXPORT
-NdisReadConfiguration(
- OUT PNDIS_STATUS Status,
- OUT PNDIS_CONFIGURATION_PARAMETER * ParameterValue,
- IN NDIS_HANDLE ConfigurationHandle,
- IN PNDIS_STRING Keyword,
- IN NDIS_PARAMETER_TYPE ParameterType)
-/*
- * FUNCTION: Read a configuration value from the registry, tracking its resources
- * ARGUMENTS:
- * Status: points to a place to write status into
- * ParameterValue: Pointer to receive a newly-allocated parameter structure
- * ConfigurationHandle: handle originally returned by an open function
- * Keyword: Value name to read, or one of the following constants:
- * Environment - returns NdisEnvironmentWindowsNt
- * ProcessorType - returns NdisProcessorX86 until more architectures are added
- * NdisVersion - returns NDIS_VERSION
- * ParameterType: the type of the value to be queried
- * RETURNS:
- * - A status in Status
- * - A parameter value in ParameterValue
- */
-{
- KEY_VALUE_PARTIAL_INFORMATION *KeyInformation;
- ULONG KeyDataLength;
- PMINIPORT_RESOURCE MiniportResource;
- PMINIPORT_CONFIGURATION_CONTEXT ConfigurationContext =
(PMINIPORT_CONFIGURATION_CONTEXT)ConfigurationHandle;
- PVOID Buffer;
-
- *ParameterValue = NULL;
- *Status = NDIS_STATUS_FAILURE;
-
- NDIS_DbgPrint(MAX_TRACE,("requested read of %wZ\n", Keyword));
-
- if (ConfigurationContext == NULL)
- {
- NDIS_DbgPrint(MIN_TRACE,("invalid parameter ConfigurationContext
(0x%x)\n",ConfigurationContext));
- return;
- }
-
- if(
- !wcsncmp(Keyword->Buffer, L"Environment",
Keyword->Length/sizeof(WCHAR)) &&
- wcslen(L"Environment") == Keyword->Length/sizeof(WCHAR)
- )
- {
- *ParameterValue = ExAllocatePool(PagedPool,
sizeof(NDIS_CONFIGURATION_PARAMETER));
- if(!*ParameterValue)
- {
- NDIS_DbgPrint(MIN_TRACE,("Insufficient resources.\n"));
- *Status = NDIS_STATUS_RESOURCES;
- return;
- }
-
- MiniportResource = ExAllocatePool(PagedPool, sizeof(MINIPORT_RESOURCE));
- if(!MiniportResource)
- {
- NDIS_DbgPrint(MIN_TRACE,("Insufficient resources.\n"));
- ExFreePool(*ParameterValue);
- *ParameterValue = NULL;
- *Status = NDIS_STATUS_RESOURCES;
- return;
- }
-
- MiniportResource->ResourceType = MINIPORT_RESOURCE_TYPE_REGISTRY_DATA;
- MiniportResource->Resource = *ParameterValue;
-
- NDIS_DbgPrint(MID_TRACE,("inserting 0x%x into the resource list\n",
- MiniportResource->Resource));
-
- ExInterlockedInsertTailList(&ConfigurationContext->ResourceListHead,
- &MiniportResource->ListEntry,
&ConfigurationContext->ResourceLock);
-
- (*ParameterValue)->ParameterType = NdisParameterInteger;
- (*ParameterValue)->ParameterData.IntegerData = NdisEnvironmentWindowsNt;
- *Status = NDIS_STATUS_SUCCESS;
-
- return;
- }
-
- if(
- !wcsncmp(Keyword->Buffer, L"ProcessorType",
Keyword->Length/sizeof(WCHAR)) &&
- wcslen(L"ProcessorType") == Keyword->Length/sizeof(WCHAR)
- )
- {
- *ParameterValue = ExAllocatePool(PagedPool,
sizeof(NDIS_CONFIGURATION_PARAMETER));
- if(!*ParameterValue)
- {
- NDIS_DbgPrint(MIN_TRACE,("Insufficient resources.\n"));
- *Status = NDIS_STATUS_RESOURCES;
- return;
- }
-
- MiniportResource = ExAllocatePool(PagedPool, sizeof(MINIPORT_RESOURCE));
- if(!MiniportResource)
- {
- NDIS_DbgPrint(MIN_TRACE,("Insufficient resources.\n"));
- ExFreePool(*ParameterValue);
- *ParameterValue = NULL;
- *Status = NDIS_STATUS_RESOURCES;
- return;
- }
-
- MiniportResource->ResourceType = MINIPORT_RESOURCE_TYPE_REGISTRY_DATA;
- MiniportResource->Resource = *ParameterValue;
- NDIS_DbgPrint(MID_TRACE,("inserting 0x%x into the resource list\n",
MiniportResource->Resource));
- ExInterlockedInsertTailList(&ConfigurationContext->ResourceListHead,
- &MiniportResource->ListEntry,
&ConfigurationContext->ResourceLock);
-
- (*ParameterValue)->ParameterType = NdisParameterInteger;
- (*ParameterValue)->ParameterData.IntegerData = NdisProcessorX86; /* XXX
non-portable */
- *Status = NDIS_STATUS_SUCCESS;
-
- return;
- }
-
- if(
- !wcsncmp(Keyword->Buffer, L"NdisVersion",
Keyword->Length/sizeof(WCHAR)) &&
- wcslen(L"NdisVersion") == Keyword->Length/sizeof(WCHAR)
- )
- {
- *ParameterValue = ExAllocatePool(PagedPool,
sizeof(NDIS_CONFIGURATION_PARAMETER));
- if(!*ParameterValue)
- {
- NDIS_DbgPrint(MIN_TRACE,("Insufficient resources.\n"));
- *Status = NDIS_STATUS_RESOURCES;
- return;
- }
-
- MiniportResource = ExAllocatePool(PagedPool, sizeof(MINIPORT_RESOURCE));
- if(!MiniportResource)
- {
- NDIS_DbgPrint(MIN_TRACE,("Insufficient resources.\n"));
- ExFreePool(*ParameterValue);
- *ParameterValue = NULL;
- *Status = NDIS_STATUS_RESOURCES;
- return;
- }
-
- MiniportResource->ResourceType = MINIPORT_RESOURCE_TYPE_REGISTRY_DATA;
- MiniportResource->Resource = *ParameterValue;
- NDIS_DbgPrint(MID_TRACE,("inserting 0x%x into the resource list\n",
MiniportResource->Resource));
- ExInterlockedInsertTailList(&ConfigurationContext->ResourceListHead,
- &MiniportResource->ListEntry,
&ConfigurationContext->ResourceLock);
-
- (*ParameterValue)->ParameterType = NdisParameterInteger;
- (*ParameterValue)->ParameterData.IntegerData = NDIS_VERSION;
- *Status = NDIS_STATUS_SUCCESS;
-
- NDIS_DbgPrint(MAX_TRACE,("ParameterType = %0x%x, ParameterValue =
0x%x\n",
- (*ParameterValue)->ParameterType,
(*ParameterValue)->ParameterData.IntegerData));
- return;
- }
-
- /* figure out how much buffer i should allocate */
- *Status = ZwQueryValueKey(ConfigurationContext->Handle, Keyword,
KeyValuePartialInformation, NULL, 0, &KeyDataLength);
- if(*Status != STATUS_BUFFER_OVERFLOW && *Status != STATUS_BUFFER_TOO_SMALL
&& *Status != STATUS_SUCCESS)
- {
- NDIS_DbgPrint(MID_TRACE,("ZwQueryValueKey #1 failed for %wZ, status
0x%x\n", Keyword, *Status));
- *Status = NDIS_STATUS_FAILURE;
- return;
- }
-
- /* allocate it */
- KeyInformation = ExAllocatePool(PagedPool, KeyDataLength +
sizeof(KEY_VALUE_PARTIAL_INFORMATION));
- if(!KeyInformation)
- {
- NDIS_DbgPrint(MIN_TRACE,("Insufficient resources.\n"));
- *Status = NDIS_STATUS_RESOURCES;
- return;
- }
-
- /* grab the value */
- *Status = ZwQueryValueKey(ConfigurationContext->Handle, Keyword,
KeyValuePartialInformation,
- KeyInformation, KeyDataLength + sizeof(KEY_VALUE_PARTIAL_INFORMATION),
&KeyDataLength);
- if(*Status != STATUS_SUCCESS)
- {
- ExFreePool(KeyInformation);
- NDIS_DbgPrint(MIN_TRACE,("ZwQueryValueKey #2 failed for %wZ, status
0x%x\n", Keyword, *Status));
- *Status = NDIS_STATUS_FAILURE;
- return;
- }
-
- MiniportResource = ExAllocatePool(PagedPool, sizeof(MINIPORT_RESOURCE));
- if(!MiniportResource)
- {
- NDIS_DbgPrint(MIN_TRACE,("Insufficient resources.\n"));
- ExFreePool(KeyInformation);
- *Status = NDIS_STATUS_RESOURCES;
- return;
- }
-
- *ParameterValue = ExAllocatePool(PagedPool, sizeof(NDIS_CONFIGURATION_PARAMETER));
- if (!*ParameterValue)
- {
- NDIS_DbgPrint(MIN_TRACE, ("Insufficient resources.\n"));
- ExFreePool(MiniportResource);
- ExFreePool(KeyInformation);
- *Status = NDIS_STATUS_RESOURCES;
- return;
- }
-
- RtlZeroMemory(*ParameterValue, sizeof(NDIS_CONFIGURATION_PARAMETER));
-
- if (KeyInformation->Type == REG_BINARY)
- {
- NDIS_DbgPrint(MAX_TRACE, ("NdisParameterBinary\n"));
-
- (*ParameterValue)->ParameterType = NdisParameterBinary;
-
- Buffer = ExAllocatePool(NonPagedPool, KeyInformation->DataLength);
- if (!Buffer)
- {
- NDIS_DbgPrint(MIN_TRACE, ("Insufficient resources.\n"));
- ExFreePool(MiniportResource);
- ExFreePool(KeyInformation);
- *Status = NDIS_STATUS_RESOURCES;
- return;
- }
-
- RtlCopyMemory(Buffer, KeyInformation->Data, KeyInformation->DataLength);
-
- (*ParameterValue)->ParameterData.BinaryData.Buffer = Buffer;
- (*ParameterValue)->ParameterData.BinaryData.Length =
KeyInformation->DataLength;
- }
- else if (KeyInformation->Type == REG_MULTI_SZ)
- {
- NDIS_DbgPrint(MAX_TRACE, ("NdisParameterMultiString\n"));
-
- (*ParameterValue)->ParameterType = NdisParameterMultiString;
-
- Buffer = ExAllocatePool(NonPagedPool, KeyInformation->DataLength);
- if (!Buffer)
- {
- NDIS_DbgPrint(MIN_TRACE, ("Insufficient resources.\n"));
- ExFreePool(MiniportResource);
- ExFreePool(KeyInformation);
- *Status = NDIS_STATUS_RESOURCES;
- return;
- }
-
- RtlCopyMemory(Buffer, KeyInformation->Data, KeyInformation->DataLength);
-
- (*ParameterValue)->ParameterData.StringData.Buffer = Buffer;
- (*ParameterValue)->ParameterData.StringData.Length =
KeyInformation->DataLength;
- }
- else
- {
- UNICODE_STRING str;
-
- str.Length = str.MaximumLength = (USHORT)KeyInformation->DataLength;
- str.Buffer = (PWCHAR)KeyInformation->Data;
-
- if ((*Status = RtlUnicodeStringToInteger(&str, 0,
- &(*ParameterValue)->ParameterData.IntegerData)) ==
STATUS_SUCCESS)
- {
- NDIS_DbgPrint(MAX_TRACE, ("NdisParameterInteger\n"));
-
- (*ParameterValue)->ParameterType = NdisParameterInteger;
- }
- else
- {
- NDIS_DbgPrint(MAX_TRACE, ("NdisParameterString\n"));
-
- (*ParameterValue)->ParameterType = NdisParameterString;
-
- Buffer = ExAllocatePool(NonPagedPool, KeyInformation->DataLength);
- if (!Buffer)
- {
- NDIS_DbgPrint(MIN_TRACE, ("Insufficient resources.\n"));
- ExFreePool(MiniportResource);
- ExFreePool(KeyInformation);
- *Status = NDIS_STATUS_RESOURCES;
- return;
- }
-
- RtlCopyMemory(Buffer, KeyInformation->Data,
KeyInformation->DataLength);
-
- (*ParameterValue)->ParameterData.StringData.Buffer = Buffer;
- (*ParameterValue)->ParameterData.StringData.Length =
KeyInformation->DataLength;
- }
- }
-
- MiniportResource->ResourceType = MINIPORT_RESOURCE_TYPE_REGISTRY_DATA;
- MiniportResource->Resource = *ParameterValue;
-
- ExInterlockedInsertTailList(&ConfigurationContext->ResourceListHead,
&MiniportResource->ListEntry, &ConfigurationContext->ResourceLock);
-
- ExFreePool(KeyInformation);
-
- *Status = NDIS_STATUS_SUCCESS;
-}
-
-
UCHAR UnicodeToHexByte(WCHAR chr)
/*
* FUNCTION: Converts a unicode hex character to its numerical value
@@ -658,9 +360,354 @@
case L'f':
return 15;
}
- return -1;
+ return 0xFF;
}
+BOOLEAN
+IsValidNumericString(PNDIS_STRING String, NDIS_PARAMETER_TYPE *ParameterType)
+/*
+ * FUNCTION: Determines if a string is a valid number
+ * ARGUMENTS:
+ * String: Unicode string to evaluate
+ * RETURNS:
+ * TRUE if it is valid, FALSE if not
+ */
+{
+ ULONG i;
+
+ /* I don't think this will ever happen, but we warn it if it does */
+ if (String->Length == 0)
+ {
+ NDIS_DbgPrint(MIN_TRACE, ("Got an empty string; not sure what to do
here\n"));
+ return FALSE;
+ }
+
+ /* Set the default parameter type */
+ *ParameterType = NdisParameterInteger;
+
+ for (i = 0; i < String->Length / sizeof(WCHAR); i++)
+ {
+ /* Look at the second character for the base */
+ if (i == 1)
+ {
+ if (String->Buffer[i] == L'X' ||
+ String->Buffer[i] == L'x')
+ {
+ NDIS_DbgPrint(MID_TRACE, ("Identified hex string\n"));
+ *ParameterType = NdisParameterHexInteger;
+ continue;
+ }
+ }
+
+ /* Skip any NULL characters we find */
+ if (String->Buffer[i] == UNICODE_NULL)
+ continue;
+
+ /* Make sure the character is valid for a numeric string */
+ if (UnicodeToHexByte(String->Buffer[i]) == 0xFF)
+ return FALSE;
+ }
+
+ /* It's valid */
+ return TRUE;
+}
+
+/*
+ * @implemented
+ */
+VOID
+EXPORT
+NdisReadConfiguration(
+ OUT PNDIS_STATUS Status,
+ OUT PNDIS_CONFIGURATION_PARAMETER * ParameterValue,
+ IN NDIS_HANDLE ConfigurationHandle,
+ IN PNDIS_STRING Keyword,
+ IN NDIS_PARAMETER_TYPE ParameterType)
+/*
+ * FUNCTION: Read a configuration value from the registry, tracking its resources
+ * ARGUMENTS:
+ * Status: points to a place to write status into
+ * ParameterValue: Pointer to receive a newly-allocated parameter structure
+ * ConfigurationHandle: handle originally returned by an open function
+ * Keyword: Value name to read, or one of the following constants:
+ * Environment - returns NdisEnvironmentWindowsNt
+ * ProcessorType - returns NdisProcessorX86 until more architectures are added
+ * NdisVersion - returns NDIS_VERSION
+ * ParameterType: the type of the value to be queried
+ * RETURNS:
+ * - A status in Status
+ * - A parameter value in ParameterValue
+ */
+{
+ KEY_VALUE_PARTIAL_INFORMATION *KeyInformation;
+ ULONG KeyDataLength;
+ PMINIPORT_RESOURCE MiniportResource;
+ PMINIPORT_CONFIGURATION_CONTEXT ConfigurationContext =
(PMINIPORT_CONFIGURATION_CONTEXT)ConfigurationHandle;
+ PVOID Buffer;
+
+ *ParameterValue = NULL;
+ *Status = NDIS_STATUS_FAILURE;
+
+ NDIS_DbgPrint(MAX_TRACE,("requested read of %wZ\n", Keyword));
+
+ if (ConfigurationContext == NULL)
+ {
+ NDIS_DbgPrint(MIN_TRACE,("invalid parameter ConfigurationContext
(0x%x)\n",ConfigurationContext));
+ return;
+ }
+
+ if(
+ !wcsncmp(Keyword->Buffer, L"Environment",
Keyword->Length/sizeof(WCHAR)) &&
+ wcslen(L"Environment") == Keyword->Length/sizeof(WCHAR)
+ )
+ {
+ *ParameterValue = ExAllocatePool(PagedPool,
sizeof(NDIS_CONFIGURATION_PARAMETER));
+ if(!*ParameterValue)
+ {
+ NDIS_DbgPrint(MIN_TRACE,("Insufficient resources.\n"));
+ *Status = NDIS_STATUS_RESOURCES;
+ return;
+ }
+
+ MiniportResource = ExAllocatePool(PagedPool, sizeof(MINIPORT_RESOURCE));
+ if(!MiniportResource)
+ {
+ NDIS_DbgPrint(MIN_TRACE,("Insufficient resources.\n"));
+ ExFreePool(*ParameterValue);
+ *ParameterValue = NULL;
+ *Status = NDIS_STATUS_RESOURCES;
+ return;
+ }
+
+ MiniportResource->ResourceType = MINIPORT_RESOURCE_TYPE_REGISTRY_DATA;
+ MiniportResource->Resource = *ParameterValue;
+
+ NDIS_DbgPrint(MID_TRACE,("inserting 0x%x into the resource list\n",
+ MiniportResource->Resource));
+
+ ExInterlockedInsertTailList(&ConfigurationContext->ResourceListHead,
+ &MiniportResource->ListEntry,
&ConfigurationContext->ResourceLock);
+
+ (*ParameterValue)->ParameterType = NdisParameterInteger;
+ (*ParameterValue)->ParameterData.IntegerData = NdisEnvironmentWindowsNt;
+ *Status = NDIS_STATUS_SUCCESS;
+
+ return;
+ }
+
+ if(
+ !wcsncmp(Keyword->Buffer, L"ProcessorType",
Keyword->Length/sizeof(WCHAR)) &&
+ wcslen(L"ProcessorType") == Keyword->Length/sizeof(WCHAR)
+ )
+ {
+ *ParameterValue = ExAllocatePool(PagedPool,
sizeof(NDIS_CONFIGURATION_PARAMETER));
+ if(!*ParameterValue)
+ {
+ NDIS_DbgPrint(MIN_TRACE,("Insufficient resources.\n"));
+ *Status = NDIS_STATUS_RESOURCES;
+ return;
+ }
+
+ MiniportResource = ExAllocatePool(PagedPool, sizeof(MINIPORT_RESOURCE));
+ if(!MiniportResource)
+ {
+ NDIS_DbgPrint(MIN_TRACE,("Insufficient resources.\n"));
+ ExFreePool(*ParameterValue);
+ *ParameterValue = NULL;
+ *Status = NDIS_STATUS_RESOURCES;
+ return;
+ }
+
+ MiniportResource->ResourceType = MINIPORT_RESOURCE_TYPE_REGISTRY_DATA;
+ MiniportResource->Resource = *ParameterValue;
+ NDIS_DbgPrint(MID_TRACE,("inserting 0x%x into the resource list\n",
MiniportResource->Resource));
+ ExInterlockedInsertTailList(&ConfigurationContext->ResourceListHead,
+ &MiniportResource->ListEntry,
&ConfigurationContext->ResourceLock);
+
+ (*ParameterValue)->ParameterType = NdisParameterInteger;
+ (*ParameterValue)->ParameterData.IntegerData = NdisProcessorX86; /* XXX
non-portable */
+ *Status = NDIS_STATUS_SUCCESS;
+
+ return;
+ }
+
+ if(
+ !wcsncmp(Keyword->Buffer, L"NdisVersion",
Keyword->Length/sizeof(WCHAR)) &&
+ wcslen(L"NdisVersion") == Keyword->Length/sizeof(WCHAR)
+ )
+ {
+ *ParameterValue = ExAllocatePool(PagedPool,
sizeof(NDIS_CONFIGURATION_PARAMETER));
+ if(!*ParameterValue)
+ {
+ NDIS_DbgPrint(MIN_TRACE,("Insufficient resources.\n"));
+ *Status = NDIS_STATUS_RESOURCES;
+ return;
+ }
+
+ MiniportResource = ExAllocatePool(PagedPool, sizeof(MINIPORT_RESOURCE));
+ if(!MiniportResource)
+ {
+ NDIS_DbgPrint(MIN_TRACE,("Insufficient resources.\n"));
+ ExFreePool(*ParameterValue);
+ *ParameterValue = NULL;
+ *Status = NDIS_STATUS_RESOURCES;
+ return;
+ }
+
+ MiniportResource->ResourceType = MINIPORT_RESOURCE_TYPE_REGISTRY_DATA;
+ MiniportResource->Resource = *ParameterValue;
+ NDIS_DbgPrint(MID_TRACE,("inserting 0x%x into the resource list\n",
MiniportResource->Resource));
+ ExInterlockedInsertTailList(&ConfigurationContext->ResourceListHead,
+ &MiniportResource->ListEntry,
&ConfigurationContext->ResourceLock);
+
+ (*ParameterValue)->ParameterType = NdisParameterInteger;
+ (*ParameterValue)->ParameterData.IntegerData = NDIS_VERSION;
+ *Status = NDIS_STATUS_SUCCESS;
+
+ NDIS_DbgPrint(MAX_TRACE,("ParameterType = %0x%x, ParameterValue =
0x%x\n",
+ (*ParameterValue)->ParameterType,
(*ParameterValue)->ParameterData.IntegerData));
+ return;
+ }
+
+ /* figure out how much buffer i should allocate */
+ *Status = ZwQueryValueKey(ConfigurationContext->Handle, Keyword,
KeyValuePartialInformation, NULL, 0, &KeyDataLength);
+ if(*Status != STATUS_BUFFER_OVERFLOW && *Status != STATUS_BUFFER_TOO_SMALL
&& *Status != STATUS_SUCCESS)
+ {
+ NDIS_DbgPrint(MID_TRACE,("ZwQueryValueKey #1 failed for %wZ, status
0x%x\n", Keyword, *Status));
+ *Status = NDIS_STATUS_FAILURE;
+ return;
+ }
+
+ /* allocate it */
+ KeyInformation = ExAllocatePool(PagedPool, KeyDataLength +
sizeof(KEY_VALUE_PARTIAL_INFORMATION));
+ if(!KeyInformation)
+ {
+ NDIS_DbgPrint(MIN_TRACE,("Insufficient resources.\n"));
+ *Status = NDIS_STATUS_RESOURCES;
+ return;
+ }
+
+ /* grab the value */
+ *Status = ZwQueryValueKey(ConfigurationContext->Handle, Keyword,
KeyValuePartialInformation,
+ KeyInformation, KeyDataLength + sizeof(KEY_VALUE_PARTIAL_INFORMATION),
&KeyDataLength);
+ if(*Status != STATUS_SUCCESS)
+ {
+ ExFreePool(KeyInformation);
+ NDIS_DbgPrint(MIN_TRACE,("ZwQueryValueKey #2 failed for %wZ, status
0x%x\n", Keyword, *Status));
+ *Status = NDIS_STATUS_FAILURE;
+ return;
+ }
+
+ MiniportResource = ExAllocatePool(PagedPool, sizeof(MINIPORT_RESOURCE));
+ if(!MiniportResource)
+ {
+ NDIS_DbgPrint(MIN_TRACE,("Insufficient resources.\n"));
+ ExFreePool(KeyInformation);
+ *Status = NDIS_STATUS_RESOURCES;
+ return;
+ }
+
+ *ParameterValue = ExAllocatePool(PagedPool, sizeof(NDIS_CONFIGURATION_PARAMETER));
+ if (!*ParameterValue)
+ {
+ NDIS_DbgPrint(MIN_TRACE, ("Insufficient resources.\n"));
+ ExFreePool(MiniportResource);
+ ExFreePool(KeyInformation);
+ *Status = NDIS_STATUS_RESOURCES;
+ return;
+ }
+
+ RtlZeroMemory(*ParameterValue, sizeof(NDIS_CONFIGURATION_PARAMETER));
+
+ if (KeyInformation->Type == REG_BINARY)
+ {
+ NDIS_DbgPrint(MAX_TRACE, ("NdisParameterBinary\n"));
+
+ (*ParameterValue)->ParameterType = NdisParameterBinary;
+
+ Buffer = ExAllocatePool(NonPagedPool, KeyInformation->DataLength);
+ if (!Buffer)
+ {
+ NDIS_DbgPrint(MIN_TRACE, ("Insufficient resources.\n"));
+ ExFreePool(MiniportResource);
+ ExFreePool(KeyInformation);
+ *Status = NDIS_STATUS_RESOURCES;
+ return;
+ }
+
+ RtlCopyMemory(Buffer, KeyInformation->Data, KeyInformation->DataLength);
+
+ (*ParameterValue)->ParameterData.BinaryData.Buffer = Buffer;
+ (*ParameterValue)->ParameterData.BinaryData.Length =
KeyInformation->DataLength;
+ }
+ else if (KeyInformation->Type == REG_MULTI_SZ)
+ {
+ NDIS_DbgPrint(MAX_TRACE, ("NdisParameterMultiString\n"));
+
+ (*ParameterValue)->ParameterType = NdisParameterMultiString;
+
+ Buffer = ExAllocatePool(NonPagedPool, KeyInformation->DataLength);
+ if (!Buffer)
+ {
+ NDIS_DbgPrint(MIN_TRACE, ("Insufficient resources.\n"));
+ ExFreePool(MiniportResource);
+ ExFreePool(KeyInformation);
+ *Status = NDIS_STATUS_RESOURCES;
+ return;
+ }
+
+ RtlCopyMemory(Buffer, KeyInformation->Data, KeyInformation->DataLength);
+
+ (*ParameterValue)->ParameterData.StringData.Buffer = Buffer;
+ (*ParameterValue)->ParameterData.StringData.Length =
KeyInformation->DataLength;
+ }
+ else
+ {
+ UNICODE_STRING str;
+
+ str.Length = str.MaximumLength = (USHORT)KeyInformation->DataLength;
+ str.Buffer = (PWCHAR)KeyInformation->Data;
+
+ if (IsValidNumericString(&str, &(*ParameterValue)->ParameterType)
&&
+ ((*Status = RtlUnicodeStringToInteger(&str, 0,
+ &(*ParameterValue)->ParameterData.IntegerData)) ==
STATUS_SUCCESS))
+ {
+ NDIS_DbgPrint(MAX_TRACE, ("NdisParameter(Hex)Integer\n"));
+
+ /* IsValidNumericString sets the parameter type when parsing the string */
+ }
+ else
+ {
+ NDIS_DbgPrint(MAX_TRACE, ("NdisParameterString\n"));
+
+ (*ParameterValue)->ParameterType = NdisParameterString;
+
+ Buffer = ExAllocatePool(NonPagedPool, KeyInformation->DataLength);
+ if (!Buffer)
+ {
+ NDIS_DbgPrint(MIN_TRACE, ("Insufficient resources.\n"));
+ ExFreePool(MiniportResource);
+ ExFreePool(KeyInformation);
+ *Status = NDIS_STATUS_RESOURCES;
+ return;
+ }
+
+ RtlCopyMemory(Buffer, KeyInformation->Data,
KeyInformation->DataLength);
+
+ (*ParameterValue)->ParameterData.StringData.Buffer = Buffer;
+ (*ParameterValue)->ParameterData.StringData.Length =
KeyInformation->DataLength;
+ }
+ }
+
+ MiniportResource->ResourceType = MINIPORT_RESOURCE_TYPE_REGISTRY_DATA;
+ MiniportResource->Resource = *ParameterValue;
+
+ ExInterlockedInsertTailList(&ConfigurationContext->ResourceListHead,
&MiniportResource->ListEntry, &ConfigurationContext->ResourceLock);
+
+ ExFreePool(KeyInformation);
+
+ *Status = NDIS_STATUS_SUCCESS;
+}
/*
* @implemented