[NDIS]
[reactos.git] / reactos / drivers / network / ndis / ndis / config.c
index 3f85ab5..addcd71 100644 (file)
@@ -432,7 +432,7 @@ NdisReadConfiguration(
     PMINIPORT_CONFIGURATION_CONTEXT ConfigurationContext = (PMINIPORT_CONFIGURATION_CONTEXT)ConfigurationHandle;
     PVOID Buffer;
 
-    *ParameterValue = NULL;
+    //*ParameterValue = NULL;
     *Status = NDIS_STATUS_FAILURE;
 
     NDIS_DbgPrint(MAX_TRACE,("requested read of %wZ\n", Keyword));
@@ -444,10 +444,8 @@ NdisReadConfiguration(
        return;
     }
 
-    if(
-        !wcsncmp(Keyword->Buffer, L"Environment", Keyword->Length/sizeof(WCHAR)) &&
-        wcslen(L"Environment") == Keyword->Length/sizeof(WCHAR)
-    )
+    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)
@@ -483,10 +481,8 @@ NdisReadConfiguration(
         return;
     }
 
-    if(
-        !wcsncmp(Keyword->Buffer, L"ProcessorType", Keyword->Length/sizeof(WCHAR)) &&
-        wcslen(L"ProcessorType") == Keyword->Length/sizeof(WCHAR)
-    )
+    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)
@@ -519,10 +515,8 @@ NdisReadConfiguration(
         return;
     }
 
-    if(
-        !wcsncmp(Keyword->Buffer, L"NdisVersion", Keyword->Length/sizeof(WCHAR)) &&
-        wcslen(L"NdisVersion") == Keyword->Length/sizeof(WCHAR)
-    )
+    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)
@@ -613,7 +607,7 @@ NdisReadConfiguration(
 
         (*ParameterValue)->ParameterType = NdisParameterBinary;
 
-        Buffer = ExAllocatePool(NonPagedPool, KeyInformation->DataLength);
+        Buffer = ExAllocatePool(PagedPool, KeyInformation->DataLength);
         if (!Buffer)
         {
             NDIS_DbgPrint(MIN_TRACE, ("Insufficient resources.\n"));
@@ -634,7 +628,7 @@ NdisReadConfiguration(
 
         (*ParameterValue)->ParameterType = NdisParameterMultiString;
 
-        Buffer = ExAllocatePool(NonPagedPool, KeyInformation->DataLength);
+        Buffer = ExAllocatePool(PagedPool, KeyInformation->DataLength);
         if (!Buffer)
         {
             NDIS_DbgPrint(MIN_TRACE, ("Insufficient resources.\n"));
@@ -664,13 +658,15 @@ NdisReadConfiguration(
          str.Length = str.MaximumLength = (USHORT)KeyInformation->DataLength;
          str.Buffer = (PWCHAR)KeyInformation->Data;
 
-         if (Base != 0 && IsValidNumericString(&str, Base) &&
-             ((*Status = RtlUnicodeStringToInteger(&str, Base,
-                             &(*ParameterValue)->ParameterData.IntegerData)) == STATUS_SUCCESS))
+         if (Base != 0 && IsValidNumericString(&str, Base))
          {
+             *Status = RtlUnicodeStringToInteger(&str, Base, &(*ParameterValue)->ParameterData.IntegerData);
+              ASSERT(*Status == STATUS_SUCCESS);
+
              NDIS_DbgPrint(MAX_TRACE, ("NdisParameter(Hex)Integer\n"));
 
-             (*ParameterValue)->ParameterType = ParameterType;
+             /* MSDN documents that this is returned for all integers, regardless of the ParameterType passed in */
+             (*ParameterValue)->ParameterType = NdisParameterInteger;
          }
          else
          {
@@ -678,7 +674,7 @@ NdisReadConfiguration(
 
              (*ParameterValue)->ParameterType = NdisParameterString;
 
-             Buffer = ExAllocatePool(NonPagedPool, KeyInformation->DataLength);
+             Buffer = ExAllocatePool(PagedPool, KeyInformation->DataLength);
              if (!Buffer)
              {
                  NDIS_DbgPrint(MIN_TRACE, ("Insufficient resources.\n"));
@@ -703,8 +699,9 @@ NdisReadConfiguration(
         ExFreePool(KeyInformation);
         return;
     }
-    
-    if ((*ParameterValue)->ParameterType != ParameterType)
+
+    if (((*ParameterValue)->ParameterType != ParameterType) &&
+        !((ParameterType == NdisParameterHexInteger) && ((*ParameterValue)->ParameterType == NdisParameterInteger)))
     {
         NDIS_DbgPrint(MIN_TRACE, ("Parameter type mismatch! (Requested: %d | Received: %d)\n",
                                   ParameterType, (*ParameterValue)->ParameterType));