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)
if (!bSuccess)
{
+ HeapFree(GetProcessHeap(), 0, QueryBinding);
CloseHandle(hDriver);
return INVALID_HANDLE_VALUE;
}
0,
&dwBytesReturned,
NULL);
+ HeapFree(GetProcessHeap(), 0, QueryBinding);
+
if (!bSuccess)
{
CloseHandle(hDriver);
* 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;
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);
{
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 */
Irp->IoStatus.Information = 0;
- SetOidRequest = IrpSp->Parameters.DeviceIoControl.Type3InputBuffer;
+ SetOidRequest = Irp->AssociatedIrp.SystemBuffer;
RequestLength = IrpSp->Parameters.DeviceIoControl.InputBufferLength;
if (SetOidRequest && RequestLength >= sizeof(NDIS_OID))
{
Irp->IoStatus.Information = 0;
- QueryOidRequest = IrpSp->Parameters.DeviceIoControl.Type3InputBuffer;
+ QueryOidRequest = Irp->AssociatedIrp.SystemBuffer;
RequestLength = IrpSp->Parameters.DeviceIoControl.InputBufferLength;
if (QueryOidRequest && RequestLength >= sizeof(NDIS_OID))
{
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);
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);