mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 18:15:11 +00:00
[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:
parent
45a4987c53
commit
781ac406d4
2 changed files with 31 additions and 15 deletions
|
@ -116,23 +116,31 @@ OpenAdapterHandle(DWORD Index)
|
|||
HANDLE hDriver;
|
||||
BOOL bSuccess;
|
||||
DWORD dwBytesReturned;
|
||||
char Buffer[1024];
|
||||
PNDISUIO_QUERY_BINDING QueryBinding = (PNDISUIO_QUERY_BINDING)Buffer;
|
||||
DWORD QueryBindingSize = sizeof(NDISUIO_QUERY_BINDING) + (1024 * sizeof(WCHAR));
|
||||
PNDISUIO_QUERY_BINDING QueryBinding;
|
||||
|
||||
/* Open the driver handle */
|
||||
hDriver = OpenDriverHandle();
|
||||
if (hDriver == 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 */
|
||||
QueryBinding->BindingIndex = 0;
|
||||
do {
|
||||
bSuccess = DeviceIoControl(hDriver,
|
||||
IOCTL_NDISUIO_QUERY_BINDING,
|
||||
NULL,
|
||||
0,
|
||||
NULL,
|
||||
0,
|
||||
QueryBinding,
|
||||
QueryBindingSize,
|
||||
QueryBinding,
|
||||
QueryBindingSize,
|
||||
&dwBytesReturned,
|
||||
NULL);
|
||||
if (QueryBinding->BindingIndex == Index)
|
||||
|
@ -142,6 +150,7 @@ OpenAdapterHandle(DWORD Index)
|
|||
|
||||
if (!bSuccess)
|
||||
{
|
||||
HeapFree(GetProcessHeap(), 0, QueryBinding);
|
||||
CloseHandle(hDriver);
|
||||
return INVALID_HANDLE_VALUE;
|
||||
}
|
||||
|
@ -155,6 +164,8 @@ OpenAdapterHandle(DWORD Index)
|
|||
0,
|
||||
&dwBytesReturned,
|
||||
NULL);
|
||||
HeapFree(GetProcessHeap(), 0, QueryBinding);
|
||||
|
||||
if (!bSuccess)
|
||||
{
|
||||
CloseHandle(hDriver);
|
||||
|
|
|
@ -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
|
||||
* 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 */
|
||||
DPRINT("Wait for bind complete\n");
|
||||
|
||||
Irp->IoStatus.Status = STATUS_SUCCESS;
|
||||
Irp->IoStatus.Information = 0;
|
||||
|
@ -33,14 +34,14 @@ NTSTATUS
|
|||
QueryBinding(PIRP Irp, PIO_STACK_LOCATION IrpSp)
|
||||
{
|
||||
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;
|
||||
NTSTATUS Status;
|
||||
PLIST_ENTRY CurrentEntry;
|
||||
KIRQL OldIrql;
|
||||
ULONG i;
|
||||
ULONG BytesCopied = 0;
|
||||
|
||||
|
||||
if (QueryBinding && BindingLength >= sizeof(NDISUIO_QUERY_BINDING))
|
||||
{
|
||||
KeAcquireSpinLock(&GlobalAdapterListLock, &OldIrql);
|
||||
|
@ -58,15 +59,19 @@ QueryBinding(PIRP Irp, PIO_STACK_LOCATION IrpSp)
|
|||
{
|
||||
AdapterContext = CONTAINING_RECORD(CurrentEntry, NDISUIO_ADAPTER_CONTEXT, ListEntry);
|
||||
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;
|
||||
|
||||
QueryBinding->DeviceNameOffset = BytesCopied;
|
||||
QueryBinding->DeviceNameLength = AdapterContext->DeviceName.Length;
|
||||
RtlCopyMemory((PUCHAR)QueryBinding + QueryBinding->DeviceNameOffset,
|
||||
AdapterContext->DeviceName.Buffer,
|
||||
BytesCopied);
|
||||
QueryBinding->DeviceNameLength = AdapterContext->DeviceName.Length;
|
||||
QueryBinding->DeviceNameLength);
|
||||
|
||||
/* FIXME: Copy description too */
|
||||
QueryBinding->DeviceDescrOffset = BytesCopied;
|
||||
QueryBinding->DeviceDescrLength = 0;
|
||||
|
||||
/* Successful */
|
||||
|
@ -147,7 +152,7 @@ SetAdapterOid(PIRP Irp, PIO_STACK_LOCATION IrpSp)
|
|||
|
||||
Irp->IoStatus.Information = 0;
|
||||
|
||||
SetOidRequest = IrpSp->Parameters.DeviceIoControl.Type3InputBuffer;
|
||||
SetOidRequest = Irp->AssociatedIrp.SystemBuffer;
|
||||
RequestLength = IrpSp->Parameters.DeviceIoControl.InputBufferLength;
|
||||
if (SetOidRequest && RequestLength >= sizeof(NDIS_OID))
|
||||
{
|
||||
|
@ -203,7 +208,7 @@ QueryAdapterOid(PIRP Irp, PIO_STACK_LOCATION IrpSp)
|
|||
|
||||
Irp->IoStatus.Information = 0;
|
||||
|
||||
QueryOidRequest = IrpSp->Parameters.DeviceIoControl.Type3InputBuffer;
|
||||
QueryOidRequest = Irp->AssociatedIrp.SystemBuffer;
|
||||
RequestLength = IrpSp->Parameters.DeviceIoControl.InputBufferLength;
|
||||
if (QueryOidRequest && RequestLength >= sizeof(NDIS_OID))
|
||||
{
|
||||
|
@ -263,7 +268,7 @@ OpenDeviceReadWrite(PIRP Irp, PIO_STACK_LOCATION IrpSp)
|
|||
if (NameLength != 0)
|
||||
{
|
||||
DeviceName.MaximumLength = DeviceName.Length = NameLength;
|
||||
DeviceName.Buffer = IrpSp->Parameters.DeviceIoControl.Type3InputBuffer;
|
||||
DeviceName.Buffer = Irp->AssociatedIrp.SystemBuffer;
|
||||
|
||||
/* Check if this already has a context */
|
||||
AdapterContext = FindAdapterContextByName(&DeviceName);
|
||||
|
@ -357,7 +362,7 @@ OpenDeviceWrite(PIRP Irp, PIO_STACK_LOCATION IrpSp)
|
|||
if (NameLength != 0)
|
||||
{
|
||||
DeviceName.MaximumLength = DeviceName.Length = NameLength;
|
||||
DeviceName.Buffer = IrpSp->Parameters.DeviceIoControl.Type3InputBuffer;
|
||||
DeviceName.Buffer = Irp->AssociatedIrp.SystemBuffer;
|
||||
|
||||
/* Check if this already has a context */
|
||||
AdapterContext = FindAdapterContextByName(&DeviceName);
|
||||
|
|
Loading…
Reference in a new issue