[NDISUIO]

- Use the correct IOCTL input buffer
[WLANCONF]
- Fix parameters to IOCTL_NDISUIO_QUERY_BINDING
- Wlanconf is ready for testing with a real WLAN adapter (for anyone who wants to checkout this branch and try it)
- Run "wlanconf -s <SSID>" to connect to an unencrypted wireless network
- Run "wlanconf -s <SSID> -w <WEP key>" to connect to a WEP encrypted wireless network (WPA not supported)

svn path=/branches/wlan-bringup/; revision=54875
This commit is contained in:
Cameron Gutman 2012-01-08 06:08:47 +00:00
parent 45a4987c53
commit 781ac406d4
2 changed files with 31 additions and 15 deletions

View file

@ -116,23 +116,31 @@ OpenAdapterHandle(DWORD Index)
HANDLE hDriver; HANDLE hDriver;
BOOL bSuccess; BOOL bSuccess;
DWORD dwBytesReturned; DWORD dwBytesReturned;
char Buffer[1024]; DWORD QueryBindingSize = sizeof(NDISUIO_QUERY_BINDING) + (1024 * sizeof(WCHAR));
PNDISUIO_QUERY_BINDING QueryBinding = (PNDISUIO_QUERY_BINDING)Buffer; PNDISUIO_QUERY_BINDING QueryBinding;
/* Open the driver handle */ /* Open the driver handle */
hDriver = OpenDriverHandle(); hDriver = OpenDriverHandle();
if (hDriver == INVALID_HANDLE_VALUE) if (hDriver == INVALID_HANDLE_VALUE)
return INVALID_HANDLE_VALUE; return INVALID_HANDLE_VALUE;
/* Allocate the binding struct */
QueryBinding = HeapAlloc(GetProcessHeap(), 0, QueryBindingSize);
if (!QueryBinding)
{
CloseHandle(hDriver);
return INVALID_HANDLE_VALUE;
}
/* Query for bindable adapters */ /* Query for bindable adapters */
QueryBinding->BindingIndex = 0; QueryBinding->BindingIndex = 0;
do { do {
bSuccess = DeviceIoControl(hDriver, bSuccess = DeviceIoControl(hDriver,
IOCTL_NDISUIO_QUERY_BINDING, IOCTL_NDISUIO_QUERY_BINDING,
NULL, QueryBinding,
0, QueryBindingSize,
NULL, QueryBinding,
0, QueryBindingSize,
&dwBytesReturned, &dwBytesReturned,
NULL); NULL);
if (QueryBinding->BindingIndex == Index) if (QueryBinding->BindingIndex == Index)
@ -142,6 +150,7 @@ OpenAdapterHandle(DWORD Index)
if (!bSuccess) if (!bSuccess)
{ {
HeapFree(GetProcessHeap(), 0, QueryBinding);
CloseHandle(hDriver); CloseHandle(hDriver);
return INVALID_HANDLE_VALUE; return INVALID_HANDLE_VALUE;
} }
@ -155,6 +164,8 @@ OpenAdapterHandle(DWORD Index)
0, 0,
&dwBytesReturned, &dwBytesReturned,
NULL); NULL);
HeapFree(GetProcessHeap(), 0, QueryBinding);
if (!bSuccess) if (!bSuccess)
{ {
CloseHandle(hDriver); CloseHandle(hDriver);

View file

@ -19,6 +19,7 @@ WaitForBind(PIRP Irp, PIO_STACK_LOCATION IrpSp)
* no official documentation on it. I'm just implementing it as a no-op * no official documentation on it. I'm just implementing it as a no-op
* right now because I don't see any reason we need it. We handle an open * right now because I don't see any reason we need it. We handle an open
* and bind just fine with IRP_MJ_CREATE and IOCTL_NDISUIO_OPEN_DEVICE */ * and bind just fine with IRP_MJ_CREATE and IOCTL_NDISUIO_OPEN_DEVICE */
DPRINT("Wait for bind complete\n");
Irp->IoStatus.Status = STATUS_SUCCESS; Irp->IoStatus.Status = STATUS_SUCCESS;
Irp->IoStatus.Information = 0; Irp->IoStatus.Information = 0;
@ -33,7 +34,7 @@ NTSTATUS
QueryBinding(PIRP Irp, PIO_STACK_LOCATION IrpSp) QueryBinding(PIRP Irp, PIO_STACK_LOCATION IrpSp)
{ {
PNDISUIO_ADAPTER_CONTEXT AdapterContext; PNDISUIO_ADAPTER_CONTEXT AdapterContext;
PNDISUIO_QUERY_BINDING QueryBinding = IrpSp->Parameters.DeviceIoControl.Type3InputBuffer; PNDISUIO_QUERY_BINDING QueryBinding = Irp->AssociatedIrp.SystemBuffer;
ULONG BindingLength = IrpSp->Parameters.DeviceIoControl.InputBufferLength; ULONG BindingLength = IrpSp->Parameters.DeviceIoControl.InputBufferLength;
NTSTATUS Status; NTSTATUS Status;
PLIST_ENTRY CurrentEntry; PLIST_ENTRY CurrentEntry;
@ -58,15 +59,19 @@ QueryBinding(PIRP Irp, PIO_STACK_LOCATION IrpSp)
{ {
AdapterContext = CONTAINING_RECORD(CurrentEntry, NDISUIO_ADAPTER_CONTEXT, ListEntry); AdapterContext = CONTAINING_RECORD(CurrentEntry, NDISUIO_ADAPTER_CONTEXT, ListEntry);
DPRINT("Query binding for index %d is adapter %wZ\n", i, &AdapterContext->DeviceName); DPRINT("Query binding for index %d is adapter %wZ\n", i, &AdapterContext->DeviceName);
if (AdapterContext->DeviceName.Length <= QueryBinding->DeviceNameLength) BytesCopied = sizeof(NDISUIO_QUERY_BINDING);
if (AdapterContext->DeviceName.Length <= BindingLength - BytesCopied)
{ {
BytesCopied += AdapterContext->DeviceName.Length; BytesCopied += AdapterContext->DeviceName.Length;
QueryBinding->DeviceNameOffset = BytesCopied;
QueryBinding->DeviceNameLength = AdapterContext->DeviceName.Length;
RtlCopyMemory((PUCHAR)QueryBinding + QueryBinding->DeviceNameOffset, RtlCopyMemory((PUCHAR)QueryBinding + QueryBinding->DeviceNameOffset,
AdapterContext->DeviceName.Buffer, AdapterContext->DeviceName.Buffer,
BytesCopied); QueryBinding->DeviceNameLength);
QueryBinding->DeviceNameLength = AdapterContext->DeviceName.Length;
/* FIXME: Copy description too */ /* FIXME: Copy description too */
QueryBinding->DeviceDescrOffset = BytesCopied;
QueryBinding->DeviceDescrLength = 0; QueryBinding->DeviceDescrLength = 0;
/* Successful */ /* Successful */
@ -147,7 +152,7 @@ SetAdapterOid(PIRP Irp, PIO_STACK_LOCATION IrpSp)
Irp->IoStatus.Information = 0; Irp->IoStatus.Information = 0;
SetOidRequest = IrpSp->Parameters.DeviceIoControl.Type3InputBuffer; SetOidRequest = Irp->AssociatedIrp.SystemBuffer;
RequestLength = IrpSp->Parameters.DeviceIoControl.InputBufferLength; RequestLength = IrpSp->Parameters.DeviceIoControl.InputBufferLength;
if (SetOidRequest && RequestLength >= sizeof(NDIS_OID)) if (SetOidRequest && RequestLength >= sizeof(NDIS_OID))
{ {
@ -203,7 +208,7 @@ QueryAdapterOid(PIRP Irp, PIO_STACK_LOCATION IrpSp)
Irp->IoStatus.Information = 0; Irp->IoStatus.Information = 0;
QueryOidRequest = IrpSp->Parameters.DeviceIoControl.Type3InputBuffer; QueryOidRequest = Irp->AssociatedIrp.SystemBuffer;
RequestLength = IrpSp->Parameters.DeviceIoControl.InputBufferLength; RequestLength = IrpSp->Parameters.DeviceIoControl.InputBufferLength;
if (QueryOidRequest && RequestLength >= sizeof(NDIS_OID)) if (QueryOidRequest && RequestLength >= sizeof(NDIS_OID))
{ {
@ -263,7 +268,7 @@ OpenDeviceReadWrite(PIRP Irp, PIO_STACK_LOCATION IrpSp)
if (NameLength != 0) if (NameLength != 0)
{ {
DeviceName.MaximumLength = DeviceName.Length = NameLength; DeviceName.MaximumLength = DeviceName.Length = NameLength;
DeviceName.Buffer = IrpSp->Parameters.DeviceIoControl.Type3InputBuffer; DeviceName.Buffer = Irp->AssociatedIrp.SystemBuffer;
/* Check if this already has a context */ /* Check if this already has a context */
AdapterContext = FindAdapterContextByName(&DeviceName); AdapterContext = FindAdapterContextByName(&DeviceName);
@ -357,7 +362,7 @@ OpenDeviceWrite(PIRP Irp, PIO_STACK_LOCATION IrpSp)
if (NameLength != 0) if (NameLength != 0)
{ {
DeviceName.MaximumLength = DeviceName.Length = NameLength; DeviceName.MaximumLength = DeviceName.Length = NameLength;
DeviceName.Buffer = IrpSp->Parameters.DeviceIoControl.Type3InputBuffer; DeviceName.Buffer = Irp->AssociatedIrp.SystemBuffer;
/* Check if this already has a context */ /* Check if this already has a context */
AdapterContext = FindAdapterContextByName(&DeviceName); AdapterContext = FindAdapterContextByName(&DeviceName);