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 */
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 NdisParameterInteger:
ParameterType = REG_DWORD;
ParameterType = REG_SZ;
Data = &ParameterValue->ParameterData.IntegerData;
DataSize = sizeof(ULONG);
break;
@ -245,7 +245,7 @@ NdisOpenProtocolConfiguration(
return;
}
wcsncpy(KeyName, ProtocolSection->Buffer, ProtocolSection->Length);
wcsncpy(KeyName, ProtocolSection->Buffer, ProtocolSection->Length/sizeof(WCHAR));
wcscpy(KeyName + ProtocolSection->Length, PARAMETERS_KEY);
RtlInitUnicodeString(&KeyNameU, KeyName);
InitializeObjectAttributes(&KeyAttributes, &KeyNameU, OBJ_CASE_INSENSITIVE, NULL, NULL);
@ -440,7 +440,7 @@ NdisReadConfiguration(
*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, status 0x%x\n", *Status));
NDIS_DbgPrint(MID_TRACE,("ZwQueryValueKey #1 failed for %wZ, status 0x%x\n", Keyword, *Status));
*Status = NDIS_STATUS_FAILURE;
return;
}
@ -460,7 +460,7 @@ NdisReadConfiguration(
if(*Status != STATUS_SUCCESS)
{
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;
return;
}
@ -470,14 +470,7 @@ NdisReadConfiguration(
case NdisParameterInteger:
case NdisParameterHexInteger:
{
if(KeyInformation->Type != REG_DWORD)
{
NDIS_DbgPrint(MIN_TRACE,("requested type does not match actual value type\n"));
ExFreePool(KeyInformation);
*ParameterValue = NULL;
*Status = NDIS_STATUS_FAILURE;
return;
}
UNICODE_STRING str;
*ParameterValue = ExAllocatePool(PagedPool, sizeof(NDIS_CONFIGURATION_PARAMETER));
if(!*ParameterValue)
@ -488,12 +481,18 @@ NdisReadConfiguration(
return;
}
str.Length = str.MaximumLength = KeyInformation->DataLength;
str.Buffer = (PWCHAR)KeyInformation->Data;
(*ParameterValue)->ParameterType = ParameterType;
(*ParameterValue)->ParameterData.IntegerData = *((ULONG *)KeyInformation->Data);
*Status = RtlUnicodeStringToInteger(&str, 16, &(*ParameterValue)->ParameterData.IntegerData);
ExFreePool(KeyInformation);
*Status = NDIS_STATUS_SUCCESS;
if(*Status != STATUS_SUCCESS)
*Status = NDIS_STATUS_FAILURE;
else
*Status = NDIS_STATUS_SUCCESS;
return;
}
@ -686,6 +685,12 @@ NdisReadNetworkAddress(
UINT *IntArray = 0;
int i;
/* FIXME - We don't quite support this yet due to buggy code below */
{
*Status = NDIS_STATUS_FAILURE;
return;
}
*NetworkAddress = NULL;
*NetworkAddressLength = 6;/* XXX magic constant */
@ -790,7 +795,7 @@ NdisOpenConfigurationKeyByIndex(
}
/* 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;
InitializeObjectAttributes(&KeyAttributes, KeyName, OBJ_CASE_INSENSITIVE, ConfigurationHandle, NULL);

View file

@ -4,10 +4,13 @@
* FILE: ndis/hardware.c
* PURPOSE: Hardware related routines
* PROGRAMMERS: Casper S. Hornstrup (chorns@users.sourceforge.net)
* Vizzini (vizzini@plasmic.com)
* REVISIONS:
* CSH 01/08-2000 Created
* 8/25/2003 Vizzini - NDIS4/5 and PnP additions
*/
#include <ndissys.h>
#include <miniport.h>
/*
@ -61,17 +64,22 @@ NdisMPciAssignResources(
IN NDIS_HANDLE MiniportHandle,
IN ULONG SlotNumber,
OUT PNDIS_RESOURCE_LIST *AssignedResources)
/*
* NOTES:
* - I think this is fundamentally broken
*/
{
PCM_RESOURCE_LIST ResourceList;
NTSTATUS Status;
PLOGICAL_ADAPTER Adapter = (PLOGICAL_ADAPTER)MiniportHandle;
ResourceList = NULL;
Status = HalAssignSlotResources (NULL, /* FIXME: RegistryPath */
NULL,
NULL, /* FIXME: DriverObject */
NULL, /* FIXME: DeviceObject */
PCIConfiguration, /* FIXME: BusType */
0, /* FIXME: BusNumber */
Status = HalAssignSlotResources (Adapter->Miniport->RegistryPath,
0,
Adapter->Miniport->DriverObject,
0,
PCIBus,
Adapter->BusNumber,
SlotNumber,
&ResourceList);
if (!NT_SUCCESS (Status))
@ -103,17 +111,20 @@ NdisMQueryAdapterResources(
/*
* @unimplemented
* @implemented
*/
NDIS_STATUS
EXPORT
NdisQueryMapRegisterCount(
IN NDIS_INTERFACE_TYPE BusType,
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_FAILURE;
return NDIS_STATUS_NOT_SUPPORTED;
}

View file

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