implemented NdisMPciAssignResources and fixed several string length bugs

svn path=/trunk/; revision=5976
This commit is contained in:
Vizzini 2003-09-04 06:51:31 +00:00
parent 0e0fac5636
commit ce2f631b26
3 changed files with 43 additions and 27 deletions

View file

@ -81,10 +81,10 @@ NdisWriteConfiguration(
/* reset parameter type to standard reg types */ /* reset parameter type to standard reg types */
switch(ParameterType) switch(ParameterType)
{ {
/* HexInteger is stored as a string on 9x (as are other dwords), but we don't have to worry about that */ /* TODO: figure out what do do with these; are they different? */
case NdisParameterHexInteger: case NdisParameterHexInteger:
case NdisParameterInteger: case NdisParameterInteger:
ParameterType = REG_DWORD; ParameterType = REG_SZ;
Data = &ParameterValue->ParameterData.IntegerData; Data = &ParameterValue->ParameterData.IntegerData;
DataSize = sizeof(ULONG); DataSize = sizeof(ULONG);
break; break;
@ -245,7 +245,7 @@ NdisOpenProtocolConfiguration(
return; return;
} }
wcsncpy(KeyName, ProtocolSection->Buffer, ProtocolSection->Length); wcsncpy(KeyName, ProtocolSection->Buffer, ProtocolSection->Length/sizeof(WCHAR));
wcscpy(KeyName + ProtocolSection->Length, PARAMETERS_KEY); wcscpy(KeyName + ProtocolSection->Length, PARAMETERS_KEY);
RtlInitUnicodeString(&KeyNameU, KeyName); RtlInitUnicodeString(&KeyNameU, KeyName);
InitializeObjectAttributes(&KeyAttributes, &KeyNameU, OBJ_CASE_INSENSITIVE, NULL, NULL); InitializeObjectAttributes(&KeyAttributes, &KeyNameU, OBJ_CASE_INSENSITIVE, NULL, NULL);
@ -440,7 +440,7 @@ NdisReadConfiguration(
*Status = ZwQueryValueKey(ConfigurationContext->Handle, Keyword, KeyValuePartialInformation, NULL, 0, &KeyDataLength); *Status = ZwQueryValueKey(ConfigurationContext->Handle, Keyword, KeyValuePartialInformation, NULL, 0, &KeyDataLength);
if(*Status != STATUS_BUFFER_OVERFLOW && *Status != STATUS_BUFFER_TOO_SMALL && *Status != STATUS_SUCCESS) if(*Status != STATUS_BUFFER_OVERFLOW && *Status != STATUS_BUFFER_TOO_SMALL && *Status != STATUS_SUCCESS)
{ {
NDIS_DbgPrint(MID_TRACE,("ZwQueryValueKey #1 failed, status 0x%x\n", *Status)); NDIS_DbgPrint(MID_TRACE,("ZwQueryValueKey #1 failed for %wZ, status 0x%x\n", Keyword, *Status));
*Status = NDIS_STATUS_FAILURE; *Status = NDIS_STATUS_FAILURE;
return; return;
} }
@ -460,7 +460,7 @@ NdisReadConfiguration(
if(*Status != STATUS_SUCCESS) if(*Status != STATUS_SUCCESS)
{ {
ExFreePool(KeyInformation); ExFreePool(KeyInformation);
NDIS_DbgPrint(MID_TRACE,("ZwQueryValueKey #2 failed, status 0x%x\n", *Status)); NDIS_DbgPrint(MID_TRACE,("ZwQueryValueKey #2 failed for %wZ, status 0x%x\n", Keyword, *Status));
*Status = NDIS_STATUS_FAILURE; *Status = NDIS_STATUS_FAILURE;
return; return;
} }
@ -470,14 +470,7 @@ NdisReadConfiguration(
case NdisParameterInteger: case NdisParameterInteger:
case NdisParameterHexInteger: case NdisParameterHexInteger:
{ {
if(KeyInformation->Type != REG_DWORD) UNICODE_STRING str;
{
NDIS_DbgPrint(MIN_TRACE,("requested type does not match actual value type\n"));
ExFreePool(KeyInformation);
*ParameterValue = NULL;
*Status = NDIS_STATUS_FAILURE;
return;
}
*ParameterValue = ExAllocatePool(PagedPool, sizeof(NDIS_CONFIGURATION_PARAMETER)); *ParameterValue = ExAllocatePool(PagedPool, sizeof(NDIS_CONFIGURATION_PARAMETER));
if(!*ParameterValue) if(!*ParameterValue)
@ -488,11 +481,17 @@ NdisReadConfiguration(
return; return;
} }
str.Length = str.MaximumLength = KeyInformation->DataLength;
str.Buffer = (PWCHAR)KeyInformation->Data;
(*ParameterValue)->ParameterType = ParameterType; (*ParameterValue)->ParameterType = ParameterType;
(*ParameterValue)->ParameterData.IntegerData = *((ULONG *)KeyInformation->Data); *Status = RtlUnicodeStringToInteger(&str, 16, &(*ParameterValue)->ParameterData.IntegerData);
ExFreePool(KeyInformation); ExFreePool(KeyInformation);
if(*Status != STATUS_SUCCESS)
*Status = NDIS_STATUS_FAILURE;
else
*Status = NDIS_STATUS_SUCCESS; *Status = NDIS_STATUS_SUCCESS;
return; return;
@ -686,6 +685,12 @@ NdisReadNetworkAddress(
UINT *IntArray = 0; UINT *IntArray = 0;
int i; int i;
/* FIXME - We don't quite support this yet due to buggy code below */
{
*Status = NDIS_STATUS_FAILURE;
return;
}
*NetworkAddress = NULL; *NetworkAddress = NULL;
*NetworkAddressLength = 6;/* XXX magic constant */ *NetworkAddressLength = 6;/* XXX magic constant */
@ -790,7 +795,7 @@ NdisOpenConfigurationKeyByIndex(
} }
/* should i fail instead if the passed-in string isn't long enough? */ /* should i fail instead if the passed-in string isn't long enough? */
wcsncpy(KeyName->Buffer, KeyInformation->Name, KeyName->MaximumLength); wcsncpy(KeyName->Buffer, KeyInformation->Name, KeyName->MaximumLength/sizeof(WCHAR));
KeyName->Length = KeyInformation->NameLength; KeyName->Length = KeyInformation->NameLength;
InitializeObjectAttributes(&KeyAttributes, KeyName, OBJ_CASE_INSENSITIVE, ConfigurationHandle, NULL); InitializeObjectAttributes(&KeyAttributes, KeyName, OBJ_CASE_INSENSITIVE, ConfigurationHandle, NULL);

View file

@ -4,10 +4,13 @@
* FILE: ndis/hardware.c * FILE: ndis/hardware.c
* PURPOSE: Hardware related routines * PURPOSE: Hardware related routines
* PROGRAMMERS: Casper S. Hornstrup (chorns@users.sourceforge.net) * PROGRAMMERS: Casper S. Hornstrup (chorns@users.sourceforge.net)
* Vizzini (vizzini@plasmic.com)
* REVISIONS: * REVISIONS:
* CSH 01/08-2000 Created * CSH 01/08-2000 Created
* 8/25/2003 Vizzini - NDIS4/5 and PnP additions
*/ */
#include <ndissys.h> #include <ndissys.h>
#include <miniport.h>
/* /*
@ -61,17 +64,22 @@ NdisMPciAssignResources(
IN NDIS_HANDLE MiniportHandle, IN NDIS_HANDLE MiniportHandle,
IN ULONG SlotNumber, IN ULONG SlotNumber,
OUT PNDIS_RESOURCE_LIST *AssignedResources) OUT PNDIS_RESOURCE_LIST *AssignedResources)
/*
* NOTES:
* - I think this is fundamentally broken
*/
{ {
PCM_RESOURCE_LIST ResourceList; PCM_RESOURCE_LIST ResourceList;
NTSTATUS Status; NTSTATUS Status;
PLOGICAL_ADAPTER Adapter = (PLOGICAL_ADAPTER)MiniportHandle;
ResourceList = NULL; ResourceList = NULL;
Status = HalAssignSlotResources (NULL, /* FIXME: RegistryPath */ Status = HalAssignSlotResources (Adapter->Miniport->RegistryPath,
NULL, 0,
NULL, /* FIXME: DriverObject */ Adapter->Miniport->DriverObject,
NULL, /* FIXME: DeviceObject */ 0,
PCIConfiguration, /* FIXME: BusType */ PCIBus,
0, /* FIXME: BusNumber */ Adapter->BusNumber,
SlotNumber, SlotNumber,
&ResourceList); &ResourceList);
if (!NT_SUCCESS (Status)) if (!NT_SUCCESS (Status))
@ -103,17 +111,20 @@ NdisMQueryAdapterResources(
/* /*
* @unimplemented * @implemented
*/ */
NDIS_STATUS NDIS_STATUS
EXPORT EXPORT
NdisQueryMapRegisterCount( NdisQueryMapRegisterCount(
IN NDIS_INTERFACE_TYPE BusType, IN NDIS_INTERFACE_TYPE BusType,
OUT PUINT MapRegisterCount) OUT PUINT MapRegisterCount)
/*
* On X86 (and all other current hardware), map registers aren't real hardware,
* and there is no real limit to the number that can be allocated.
* As such, we do what microsoft does on the x86 hals and return as follows
*/
{ {
UNIMPLEMENTED return NDIS_STATUS_NOT_SUPPORTED;
return NDIS_STATUS_FAILURE;
} }

View file

@ -611,7 +611,7 @@ NdisRegisterProtocol(
wcscpy(RegistryPathStr, SERVICES_KEY); wcscpy(RegistryPathStr, SERVICES_KEY);
wcsncat(RegistryPathStr, ((WCHAR *)ProtocolCharacteristics->Name.Buffer), wcsncat(RegistryPathStr, ((WCHAR *)ProtocolCharacteristics->Name.Buffer),
ProtocolCharacteristics->Name.Length); ProtocolCharacteristics->Name.Length / sizeof(WCHAR));
RegistryPathStr[wcslen(SERVICES_KEY)+ProtocolCharacteristics->Name.Length/sizeof(WCHAR)] = 0; RegistryPathStr[wcslen(SERVICES_KEY)+ProtocolCharacteristics->Name.Length/sizeof(WCHAR)] = 0;
wcscat(RegistryPathStr, LINKAGE_KEY); wcscat(RegistryPathStr, LINKAGE_KEY);