ReactOS  0.4.15-dev-1377-ga59cecd
ndisuio.h File Reference
#include <ndis.h>
#include <nuiouser.h>
Include dependency graph for ndisuio.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  _NDISUIO_ADAPTER_CONTEXT
 
struct  _NDISUIO_OPEN_ENTRY
 
struct  _NDISUIO_PACKET_ENTRY
 

Macros

#define NDIS_MAJOR_VERSION   5
 
#define NDIS_MINOR_VERSION   0
 

Typedefs

typedef struct _NDISUIO_ADAPTER_CONTEXT NDISUIO_ADAPTER_CONTEXT
 
typedef struct _NDISUIO_ADAPTER_CONTEXTPNDISUIO_ADAPTER_CONTEXT
 
typedef struct _NDISUIO_OPEN_ENTRY NDISUIO_OPEN_ENTRY
 
typedef struct _NDISUIO_OPEN_ENTRYPNDISUIO_OPEN_ENTRY
 
typedef struct _NDISUIO_PACKET_ENTRY NDISUIO_PACKET_ENTRY
 
typedef struct _NDISUIO_PACKET_ENTRYPNDISUIO_PACKET_ENTRY
 

Functions

NTSTATUS NTAPI NduDispatchCreate (PDEVICE_OBJECT DeviceObject, PIRP Irp)
 
NTSTATUS NTAPI NduDispatchClose (PDEVICE_OBJECT DeviceObject, PIRP Irp)
 
NTSTATUS NTAPI NduDispatchDeviceControl (PDEVICE_OBJECT DeviceObject, PIRP Irp)
 
NDIS_STATUS AllocateAndChainBuffer (PNDISUIO_ADAPTER_CONTEXT AdapterContext, PNDIS_PACKET Packet, PVOID Buffer, ULONG BufferSize, BOOLEAN Front)
 
PNDIS_PACKET CreatePacketFromPoolBuffer (PNDISUIO_ADAPTER_CONTEXT AdapterContext, PVOID Buffer, ULONG BufferSize)
 
VOID CleanupAndFreePacket (PNDIS_PACKET Packet, BOOLEAN FreePool)
 
PNDISUIO_ADAPTER_CONTEXT FindAdapterContextByName (PNDIS_STRING DeviceName)
 
VOID ReferenceAdapterContext (PNDISUIO_ADAPTER_CONTEXT AdapterContext)
 
VOID DereferenceAdapterContextWithOpenEntry (PNDISUIO_ADAPTER_CONTEXT AdapterContext, PNDISUIO_OPEN_ENTRY OpenEntry)
 
VOID NTAPI NduOpenAdapterComplete (NDIS_HANDLE ProtocolBindingContext, NDIS_STATUS Status, NDIS_STATUS OpenStatus)
 
VOID NTAPI NduCloseAdapterComplete (NDIS_HANDLE ProtocolBindingContext, NDIS_STATUS Status)
 
NDIS_STATUS NTAPI NduNetPnPEvent (NDIS_HANDLE ProtocolBindingContext, PNET_PNP_EVENT NetPnPEvent)
 
VOID NTAPI NduSendComplete (NDIS_HANDLE ProtocolBindingContext, PNDIS_PACKET Packet, NDIS_STATUS Status)
 
VOID NTAPI NduTransferDataComplete (NDIS_HANDLE ProtocolBindingContext, PNDIS_PACKET Packet, NDIS_STATUS Status, UINT BytesTransferred)
 
VOID NTAPI NduResetComplete (NDIS_HANDLE ProtocolBindingContext, NDIS_STATUS Status)
 
VOID NTAPI NduRequestComplete (NDIS_HANDLE ProtocolBindingContext, PNDIS_REQUEST NdisRequest, NDIS_STATUS Status)
 
NDIS_STATUS NTAPI NduReceive (NDIS_HANDLE ProtocolBindingContext, NDIS_HANDLE MacReceiveContext, PVOID HeaderBuffer, UINT HeaderBufferSize, PVOID LookAheadBuffer, UINT LookaheadBufferSize, UINT PacketSize)
 
VOID NTAPI NduReceiveComplete (NDIS_HANDLE ProtocolBindingContext)
 
VOID NTAPI NduStatus (NDIS_HANDLE ProtocolBindingContext, NDIS_STATUS GeneralStatus, PVOID StatusBuffer, UINT StatusBufferSize)
 
VOID NTAPI NduStatusComplete (NDIS_HANDLE ProtocolBindingContext)
 
VOID NTAPI NduBindAdapter (PNDIS_STATUS Status, NDIS_HANDLE BindContext, PNDIS_STRING DeviceName, PVOID SystemSpecific1, PVOID SystemSpecific2)
 
VOID NTAPI NduUnbindAdapter (PNDIS_STATUS Status, NDIS_HANDLE ProtocolBindingContext, NDIS_HANDLE UnbindContext)
 
NTSTATUS NTAPI NduDispatchRead (PDEVICE_OBJECT DeviceObject, PIRP Irp)
 
NTSTATUS NTAPI NduDispatchWrite (PDEVICE_OBJECT DeviceObject, PIRP Irp)
 

Variables

PDEVICE_OBJECT GlobalDeviceObject
 
NDIS_HANDLE GlobalProtocolHandle
 
LIST_ENTRY GlobalAdapterList
 
KSPIN_LOCK GlobalAdapterListLock
 

Macro Definition Documentation

◆ NDIS_MAJOR_VERSION

#define NDIS_MAJOR_VERSION   5

Definition at line 78 of file ndisuio.h.

◆ NDIS_MINOR_VERSION

#define NDIS_MINOR_VERSION   0

Definition at line 79 of file ndisuio.h.

Typedef Documentation

◆ NDISUIO_ADAPTER_CONTEXT

◆ NDISUIO_OPEN_ENTRY

◆ NDISUIO_PACKET_ENTRY

◆ PNDISUIO_ADAPTER_CONTEXT

◆ PNDISUIO_OPEN_ENTRY

◆ PNDISUIO_PACKET_ENTRY

Function Documentation

◆ AllocateAndChainBuffer()

NDIS_STATUS AllocateAndChainBuffer ( PNDISUIO_ADAPTER_CONTEXT  AdapterContext,
PNDIS_PACKET  Packet,
PVOID  Buffer,
ULONG  BufferSize,
BOOLEAN  Front 
)

Definition at line 15 of file misc.c.

20 {
22  PNDIS_BUFFER NdisBuffer;
23 
24  /* Allocate the NDIS buffer mapping the pool */
26  &NdisBuffer,
27  AdapterContext->BufferPoolHandle,
28  Buffer,
29  BufferSize);
31  {
32  DPRINT1("No free buffer descriptors\n");
33  return Status;
34  }
35 
36  if (Front)
37  {
38  /* Chain the buffer to front */
39  NdisChainBufferAtFront(Packet, NdisBuffer);
40  }
41  else
42  {
43  /* Chain the buffer to back */
44  NdisChainBufferAtBack(Packet, NdisBuffer);
45  }
46 
47  /* Return success */
48  return NDIS_STATUS_SUCCESS;
49 }
NDIS_HANDLE BufferPoolHandle
Definition: ndisuio.h:34
_In_ NDIS_HANDLE _In_ PNDIS_PACKET Packet
Definition: ndis.h:1548
MDL * PNDIS_BUFFER
Definition: ndis.h:343
#define NdisChainBufferAtFront(Packet, Buffer)
Definition: ndis.h:3106
int NDIS_STATUS
Definition: ntddndis.h:471
Definition: bufpool.h:45
VOID EXPORT NdisAllocateBuffer(OUT PNDIS_STATUS Status, OUT PNDIS_BUFFER *Buffer, IN NDIS_HANDLE PoolHandle, IN PVOID VirtualAddress, IN UINT Length)
Definition: buffer.c:336
Status
Definition: gdiplustypes.h:24
#define NDIS_STATUS_SUCCESS
Definition: ndis.h:346
#define DPRINT1
Definition: precomp.h:8
#define NdisChainBufferAtBack(Packet, Buffer)
Definition: ndis.h:3128
_In_ WDFMEMORY _Out_opt_ size_t * BufferSize
Definition: wdfmemory.h:251

Referenced by CreatePacketFromPoolBuffer().

◆ CleanupAndFreePacket()

VOID CleanupAndFreePacket ( PNDIS_PACKET  Packet,
BOOLEAN  FreePool 
)

Definition at line 83 of file misc.c.

84 {
86  PVOID Data;
87  ULONG Length;
88 
89  /* Free each buffer and its backing pool memory */
90  while (TRUE)
91  {
92  /* Unchain each buffer */
94  if (!Buffer)
95  break;
96 
97  /* Get the backing memory */
99 
100  /* Free the buffer */
102 
103  if (FreePool)
104  {
105  /* Free the backing memory */
106  ExFreePool(Data);
107  }
108  }
109 
110  /* Free the packet descriptor */
112 }
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
_In_ NDIS_HANDLE _In_ PNDIS_PACKET Packet
Definition: ndis.h:1548
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34
#define TRUE
Definition: types.h:120
MDL * PNDIS_BUFFER
Definition: ndis.h:343
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG _In_opt_ PVOID Data
Definition: wdfdevice.h:4527
VOID EXPORT NdisFreeBuffer(IN PNDIS_BUFFER Buffer)
Definition: buffer.c:811
#define FreePool(P)
Definition: mntmgr.h:154
Definition: bufpool.h:45
VOID EXPORT NdisFreePacket(IN PNDIS_PACKET Packet)
Definition: buffer.c:828
VOID EXPORT NdisUnchainBufferAtFront(IN OUT PNDIS_PACKET Packet, OUT PNDIS_BUFFER *Buffer)
Definition: buffer.c:1069
VOID EXPORT NdisQueryBuffer(IN PNDIS_BUFFER Buffer, OUT PVOID *VirtualAddress OPTIONAL, OUT PUINT Length)
Definition: buffer.c:955
unsigned int ULONG
Definition: retypes.h:1
#define ExFreePool(addr)
Definition: env_spec_w32.h:352

Referenced by NduDispatchWrite(), and NduReceive().

◆ CreatePacketFromPoolBuffer()

PNDIS_PACKET CreatePacketFromPoolBuffer ( PNDISUIO_ADAPTER_CONTEXT  AdapterContext,
PVOID  Buffer,
ULONG  BufferSize 
)

Definition at line 52 of file misc.c.

55 {
58 
59  /* Allocate a packet descriptor */
61  &Packet,
62  AdapterContext->PacketPoolHandle);
64  {
65  DPRINT1("No free packet descriptors\n");
66  return NULL;
67  }
68 
69  /* Use the helper to chain the buffer */
70  Status = AllocateAndChainBuffer(AdapterContext, Packet,
73  {
75  return NULL;
76  }
77 
78  /* Return the packet */
79  return Packet;
80 }
VOID EXPORT NdisAllocatePacket(OUT PNDIS_STATUS Status, OUT PNDIS_PACKET *Packet, IN NDIS_HANDLE PoolHandle)
Definition: buffer.c:394
_In_ NDIS_HANDLE _In_ PNDIS_PACKET Packet
Definition: ndis.h:1548
#define TRUE
Definition: types.h:120
int NDIS_STATUS
Definition: ntddndis.h:471
NDIS_STATUS AllocateAndChainBuffer(PNDISUIO_ADAPTER_CONTEXT AdapterContext, PNDIS_PACKET Packet, PVOID Buffer, ULONG BufferSize, BOOLEAN Front)
Definition: misc.c:15
NDIS_HANDLE PacketPoolHandle
Definition: ndisuio.h:33
Definition: bufpool.h:45
Status
Definition: gdiplustypes.h:24
VOID EXPORT NdisFreePacket(IN PNDIS_PACKET Packet)
Definition: buffer.c:828
#define NDIS_STATUS_SUCCESS
Definition: ndis.h:346
#define NULL
Definition: types.h:112
#define DPRINT1
Definition: precomp.h:8
_In_ WDFMEMORY _Out_opt_ size_t * BufferSize
Definition: wdfmemory.h:251

Referenced by NduDispatchWrite(), and NduReceive().

◆ DereferenceAdapterContextWithOpenEntry()

VOID DereferenceAdapterContextWithOpenEntry ( PNDISUIO_ADAPTER_CONTEXT  AdapterContext,
PNDISUIO_OPEN_ENTRY  OpenEntry 
)

Definition at line 149 of file misc.c.

151 {
152  KIRQL OldIrql;
153 
154  /* Lock the adapter context */
155  KeAcquireSpinLock(&AdapterContext->Spinlock, &OldIrql);
156 
157  /* Decrement the open count */
158  AdapterContext->OpenCount--;
159 
160  /* Cleanup the open entry if we were given one */
161  if (OpenEntry != NULL)
162  {
163  /* Remove the open entry */
164  RemoveEntryList(&OpenEntry->ListEntry);
165 
166  /* Invalidate the FO */
167  OpenEntry->FileObject->FsContext = NULL;
168  OpenEntry->FileObject->FsContext2 = NULL;
169 
170  /* Free the open entry */
171  ExFreePool(OpenEntry);
172  }
173 
174  /* Release the adapter context lock */
175  KeReleaseSpinLock(&AdapterContext->Spinlock, OldIrql);
176 }
KSPIN_LOCK Spinlock
Definition: ndisuio.h:50
FORCEINLINE BOOLEAN RemoveEntryList(_In_ PLIST_ENTRY Entry)
Definition: rtlfuncs.h:105
UCHAR KIRQL
Definition: env_spec_w32.h:591
#define KeAcquireSpinLock(sl, irql)
Definition: env_spec_w32.h:609
PFILE_OBJECT FileObject
Definition: ndisuio.h:56
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:790
LIST_ENTRY ListEntry
Definition: ndisuio.h:62
#define NULL
Definition: types.h:112
#define KeReleaseSpinLock(sl, irql)
Definition: env_spec_w32.h:627
#define ExFreePool(addr)
Definition: env_spec_w32.h:352

Referenced by NduDispatchClose(), and OpenDeviceReadWrite().

◆ FindAdapterContextByName()

PNDISUIO_ADAPTER_CONTEXT FindAdapterContextByName ( PNDIS_STRING  DeviceName)

Definition at line 115 of file misc.c.

116 {
117  KIRQL OldIrql;
118  PLIST_ENTRY CurrentEntry;
119  PNDISUIO_ADAPTER_CONTEXT AdapterContext;
120 
122  CurrentEntry = GlobalAdapterList.Flink;
123  while (CurrentEntry != &GlobalAdapterList)
124  {
125  AdapterContext = CONTAINING_RECORD(CurrentEntry, NDISUIO_ADAPTER_CONTEXT, ListEntry);
126 
127  /* Check if the device name matches */
128  if (RtlEqualUnicodeString(&AdapterContext->DeviceName, DeviceName, TRUE))
129  {
131  return AdapterContext;
132  }
133 
134  CurrentEntry = CurrentEntry->Flink;
135  }
137 
138  return NULL;
139 }
#define TRUE
Definition: types.h:120
UCHAR KIRQL
Definition: env_spec_w32.h:591
_Must_inspect_result_ _In_ PWDFDEVICE_INIT _In_opt_ PCUNICODE_STRING DeviceName
Definition: wdfdevice.h:3272
KSPIN_LOCK GlobalAdapterListLock
Definition: main.c:16
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
#define KeAcquireSpinLock(sl, irql)
Definition: env_spec_w32.h:609
UNICODE_STRING DeviceName
Definition: ndisuio.h:44
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:790
Definition: typedefs.h:119
LIST_ENTRY GlobalAdapterList
Definition: main.c:17
#define NULL
Definition: types.h:112
#define KeReleaseSpinLock(sl, irql)
Definition: env_spec_w32.h:627
NTSYSAPI BOOLEAN NTAPI RtlEqualUnicodeString(PUNICODE_STRING String1, PUNICODE_STRING String2, BOOLEAN CaseInSensitive)

Referenced by OpenDeviceReadWrite().

◆ NduBindAdapter()

VOID NTAPI NduBindAdapter ( PNDIS_STATUS  Status,
NDIS_HANDLE  BindContext,
PNDIS_STRING  DeviceName,
PVOID  SystemSpecific1,
PVOID  SystemSpecific2 
)

Definition at line 538 of file protocol.c.

543 {
544  /* Use our helper function to create a context for this adapter */
546 }
_Must_inspect_result_ _In_ PWDFDEVICE_INIT _In_opt_ PCUNICODE_STRING DeviceName
Definition: wdfdevice.h:3272
Status
Definition: gdiplustypes.h:24
static NDIS_STATUS BindAdapterByName(PNDIS_STRING DeviceName)
Definition: protocol.c:383

Referenced by DriverEntry().

◆ NduCloseAdapterComplete()

VOID NTAPI NduCloseAdapterComplete ( NDIS_HANDLE  ProtocolBindingContext,
NDIS_STATUS  Status 
)

Definition at line 31 of file protocol.c.

33 {
35 
36  DPRINT("Asynchronous adapter close completed\n");
37 
38  /* Store the final status and signal the event */
39  AdapterContext->AsyncStatus = Status;
40  KeSetEvent(&AdapterContext->AsyncEvent, IO_NO_INCREMENT, FALSE);
41 }
_Must_inspect_result_ _Out_ PNDIS_STATUS _Out_ PNDIS_STATUS _Out_ PNDIS_HANDLE _Out_ PUINT _In_ UINT _In_ NDIS_HANDLE _In_ NDIS_HANDLE ProtocolBindingContext
Definition: ndis.h:6013
LONG NTAPI KeSetEvent(IN PKEVENT Event, IN KPRIORITY Increment, IN BOOLEAN Wait)
Definition: eventobj.c:159
#define FALSE
Definition: types.h:117
void DPRINT(...)
Definition: polytest.cpp:61
Status
Definition: gdiplustypes.h:24
NDIS_STATUS AsyncStatus
Definition: ndisuio.h:22
#define IO_NO_INCREMENT
Definition: iotypes.h:581

Referenced by DriverEntry().

◆ NduDispatchClose()

NTSTATUS NTAPI NduDispatchClose ( PDEVICE_OBJECT  DeviceObject,
PIRP  Irp 
)

Definition at line 40 of file createclose.c.

42 {
44  PNDISUIO_ADAPTER_CONTEXT AdapterContext = IrpSp->FileObject->FsContext;
45  PNDISUIO_OPEN_ENTRY OpenEntry = IrpSp->FileObject->FsContext2;
46 
48 
49  DPRINT("Closing file object 0x%x\n", IrpSp->FileObject);
50 
51  /* Check if this handle was ever associated with an adapter */
52  if (AdapterContext != NULL)
53  {
54  ASSERT(OpenEntry != NULL);
55 
56  DPRINT("Removing binding to adapter %wZ\n", &AdapterContext->DeviceName);
57 
58  /* Call the our helper */
59  DereferenceAdapterContextWithOpenEntry(AdapterContext, OpenEntry);
60  }
61 
62  /* Completed */
63  Irp->IoStatus.Status = STATUS_SUCCESS;
64  Irp->IoStatus.Information = 0;
66 
67  /* Return success */
68  return STATUS_SUCCESS;
69 }
VOID DereferenceAdapterContextWithOpenEntry(PNDISUIO_ADAPTER_CONTEXT AdapterContext, PNDISUIO_OPEN_ENTRY OpenEntry)
Definition: misc.c:149
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
_In_ PIRP Irp
Definition: csq.h:116
Definition: ndisuio.h:53
#define IoCompleteRequest
Definition: irp.c:1240
void DPRINT(...)
Definition: polytest.cpp:61
#define ASSERT(a)
Definition: mode.c:45
UNICODE_STRING DeviceName
Definition: ndisuio.h:44
PDEVICE_OBJECT GlobalDeviceObject
Definition: main.c:14
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2789
PFILE_OBJECT FileObject
Definition: iotypes.h:3148
_In_ PIO_STACK_LOCATION IrpSp
Definition: create.c:4137
#define NULL
Definition: types.h:112
#define IO_NO_INCREMENT
Definition: iotypes.h:581
#define STATUS_SUCCESS
Definition: shellext.h:65

Referenced by DriverEntry().

◆ NduDispatchCreate()

NTSTATUS NTAPI NduDispatchCreate ( PDEVICE_OBJECT  DeviceObject,
PIRP  Irp 
)

Definition at line 16 of file createclose.c.

18 {
20 
22 
23  DPRINT("Created file object 0x%x\n", IrpSp->FileObject);
24 
25  /* This is associated with an adapter during IOCTL_NDISUIO_OPEN_(WRITE_)DEVICE */
26  IrpSp->FileObject->FsContext = NULL;
27  IrpSp->FileObject->FsContext2 = NULL;
28 
29  /* Completed successfully */
30  Irp->IoStatus.Status = STATUS_SUCCESS;
31  Irp->IoStatus.Information = FILE_OPENED;
33 
34  /* Return success */
35  return STATUS_SUCCESS;
36 }
#define FILE_OPENED
Definition: nt_native.h:769
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
_In_ PIRP Irp
Definition: csq.h:116
#define IoCompleteRequest
Definition: irp.c:1240
void DPRINT(...)
Definition: polytest.cpp:61
#define ASSERT(a)
Definition: mode.c:45
PDEVICE_OBJECT GlobalDeviceObject
Definition: main.c:14
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2789
PFILE_OBJECT FileObject
Definition: iotypes.h:3148
_In_ PIO_STACK_LOCATION IrpSp
Definition: create.c:4137
#define NULL
Definition: types.h:112
#define IO_NO_INCREMENT
Definition: iotypes.h:581
#define STATUS_SUCCESS
Definition: shellext.h:65

Referenced by DriverEntry().

◆ NduDispatchDeviceControl()

NTSTATUS NTAPI NduDispatchDeviceControl ( PDEVICE_OBJECT  DeviceObject,
PIRP  Irp 
)

Definition at line 469 of file ioctl.c.

471 {
473  PNDISUIO_OPEN_ENTRY OpenEntry;
474 
476 
477  /* Handle open IOCTLs first */
478  switch (IrpSp->Parameters.DeviceIoControl.IoControlCode)
479  {
481  return OpenDeviceReadWrite(Irp, IrpSp);
482 #if 0
483  case IOCTL_NDISUIO_OPEN_WRITE_DEVICE:
484  return OpenDeviceWrite(Irp, IrpSp);
485 #endif
487  return WaitForBind(Irp, IrpSp);
488 
490  return QueryBinding(Irp, IrpSp);
491 
492  default:
493  /* Fail if this file object has no adapter associated */
494  if (IrpSp->FileObject->FsContext == NULL)
495  {
496  Irp->IoStatus.Status = STATUS_INVALID_PARAMETER;
497  Irp->IoStatus.Information = 0;
499 
501  }
502 
503  /* Now handle write IOCTLs */
504  switch (IrpSp->Parameters.DeviceIoControl.IoControlCode)
505  {
507  return SetAdapterOid(Irp, IrpSp);
508 
509  default:
510  /* Check that we have read permissions */
511  OpenEntry = IrpSp->FileObject->FsContext2;
512  if (OpenEntry->WriteOnly)
513  {
514  Irp->IoStatus.Status = STATUS_INVALID_PARAMETER;
515  Irp->IoStatus.Information = 0;
517 
519  }
520 
521  switch (IrpSp->Parameters.DeviceIoControl.IoControlCode)
522  {
523 #if 0
524  case IOCTL_CANCEL_READ:
525  return CancelPacketRead(Irp, IrpSp);
526 #endif
527 
529  return QueryAdapterOid(Irp, IrpSp);
530 
531  default:
532  DPRINT1("Unimplemented\n");
533  Irp->IoStatus.Status = STATUS_NOT_IMPLEMENTED;
534  Irp->IoStatus.Information = 0;
536  return STATUS_NOT_IMPLEMENTED;
537  }
538  }
539  break;
540  }
541 }
static NTSTATUS QueryBinding(PIRP Irp, PIO_STACK_LOCATION IrpSp)
Definition: ioctl.c:34
#define IOCTL_NDISUIO_BIND_WAIT
Definition: nuiouser.h:27
#define IOCTL_NDISUIO_QUERY_OID_VALUE
Definition: nuiouser.h:16
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
static NTSTATUS WaitForBind(PIRP Irp, PIO_STACK_LOCATION IrpSp)
Definition: ioctl.c:16
static NTSTATUS OpenDeviceReadWrite(PIRP Irp, PIO_STACK_LOCATION IrpSp)
Definition: ioctl.c:294
static NTSTATUS SetAdapterOid(PIRP Irp, PIO_STACK_LOCATION IrpSp)
Definition: ioctl.c:146
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
return STATUS_NOT_IMPLEMENTED
_In_ PIRP Irp
Definition: csq.h:116
#define IOCTL_NDISUIO_QUERY_BINDING
Definition: nuiouser.h:23
Definition: ndisuio.h:53
#define IoCompleteRequest
Definition: irp.c:1240
#define ASSERT(a)
Definition: mode.c:45
PDEVICE_OBJECT GlobalDeviceObject
Definition: main.c:14
#define IOCTL_NDISUIO_SET_OID_VALUE
Definition: nuiouser.h:31
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2789
PFILE_OBJECT FileObject
Definition: iotypes.h:3148
BOOLEAN WriteOnly
Definition: ndisuio.h:59
static NTSTATUS QueryAdapterOid(PIRP Irp, PIO_STACK_LOCATION IrpSp)
Definition: ioctl.c:220
_In_ PIO_STACK_LOCATION IrpSp
Definition: create.c:4137
#define NULL
Definition: types.h:112
#define DPRINT1
Definition: precomp.h:8
#define IOCTL_NDISUIO_OPEN_DEVICE
Definition: nuiouser.h:12
#define IO_NO_INCREMENT
Definition: iotypes.h:581
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:3107

Referenced by DriverEntry().

◆ NduDispatchRead()

NTSTATUS NTAPI NduDispatchRead ( PDEVICE_OBJECT  DeviceObject,
PIRP  Irp 
)

Definition at line 42 of file readwrite.c.

44 {
46  PNDISUIO_ADAPTER_CONTEXT AdapterContext = IrpSp->FileObject->FsContext;
47  PNDISUIO_OPEN_ENTRY OpenEntry = IrpSp->FileObject->FsContext2;
48  KIRQL OldIrql, OldCancelIrql;
50  PLIST_ENTRY ListEntry;
51  PNDISUIO_PACKET_ENTRY PacketEntry = NULL;
52  ULONG BytesCopied = 0;
53 
55 
56  if (OpenEntry->WriteOnly)
57  {
58  Irp->IoStatus.Status = STATUS_INVALID_PARAMETER;
59  Irp->IoStatus.Information = 0;
61 
63  }
64 
65  /* Make the read cancellable */
66  IoAcquireCancelSpinLock(&OldCancelIrql);
68  if (Irp->Cancel)
69  {
70  IoReleaseCancelSpinLock(OldCancelIrql);
71 
72  /* Indicate a 0 byte read */
73  Irp->IoStatus.Status = STATUS_SUCCESS;
74  Irp->IoStatus.Information = 0;
76 
77  return STATUS_SUCCESS;
78  }
79  IoReleaseCancelSpinLock(OldCancelIrql);
80 
81  while (TRUE)
82  {
83  KeAcquireSpinLock(&AdapterContext->Spinlock, &OldIrql);
84 
85  /* Check if we have a packet */
86  if (IsListEmpty(&AdapterContext->PacketList))
87  {
88  KeReleaseSpinLock(&AdapterContext->Spinlock, OldIrql);
89 
90  /* Wait for a packet (in the context of the calling user thread) */
91  Status = KeWaitForSingleObject(&AdapterContext->PacketReadEvent,
93  UserMode,
94  TRUE,
95  NULL);
96  if (Status != STATUS_SUCCESS)
97  {
98  /* Remove the cancel routine */
99  IoAcquireCancelSpinLock(&OldCancelIrql);
101  IoReleaseCancelSpinLock(OldCancelIrql);
102 
103  break;
104  }
105  }
106  else
107  {
108  /* Remove the cancel routine */
109  IoAcquireCancelSpinLock(&OldCancelIrql);
111  IoReleaseCancelSpinLock(OldCancelIrql);
112 
113  /* Remove the first packet in the list */
114  ListEntry = RemoveHeadList(&AdapterContext->PacketList);
115  PacketEntry = CONTAINING_RECORD(ListEntry, NDISUIO_PACKET_ENTRY, ListEntry);
116 
117  /* Release the adapter lock */
118  KeReleaseSpinLock(&AdapterContext->Spinlock, OldIrql);
119 
120  /* And we're done with this loop */
122  break;
123  }
124  }
125 
126  /* Check if we got a packet */
127  if (PacketEntry != NULL)
128  {
129  /* Find the right amount of bytes to copy */
130  BytesCopied = PacketEntry->PacketLength;
131  if (BytesCopied > IrpSp->Parameters.Read.Length)
132  BytesCopied = IrpSp->Parameters.Read.Length;
133 
134  /* Copy the packet */
135  RtlCopyMemory(Irp->AssociatedIrp.SystemBuffer,
136  &PacketEntry->PacketData[0],
137  BytesCopied);
138 
139  /* Free the packet entry */
140  ExFreePool(PacketEntry);
141  }
142  else
143  {
144  /* Something failed */
145  BytesCopied = 0;
146  }
147 
148  /* Complete the IRP */
149  Irp->IoStatus.Status = Status;
150  Irp->IoStatus.Information = BytesCopied;
152 
153  return Status;
154 }
Definition: ndisuio.h:65
#define TRUE
Definition: types.h:120
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
LONG NTSTATUS
Definition: precomp.h:26
VOID NTAPI IoAcquireCancelSpinLock(OUT PKIRQL Irql)
Definition: util.c:56
KSPIN_LOCK Spinlock
Definition: ndisuio.h:50
IoSetCancelRoutine(Irp, CancelRoutine)
NTSTATUS NTAPI KeWaitForSingleObject(IN PVOID Object, IN KWAIT_REASON WaitReason, IN KPROCESSOR_MODE WaitMode, IN BOOLEAN Alertable, IN PLARGE_INTEGER Timeout OPTIONAL)
Definition: wait.c:416
_Must_inspect_result_ FORCEINLINE BOOLEAN IsListEmpty(_In_ const LIST_ENTRY *ListHead)
Definition: rtlfuncs.h:57
UCHAR KIRQL
Definition: env_spec_w32.h:591
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
_In_ PIRP Irp
Definition: csq.h:116
Definition: ndisuio.h:53
_In_ UINT _In_ UINT _In_ PNDIS_PACKET _In_ UINT _Out_ PUINT BytesCopied
Definition: ndis.h:3167
#define IoCompleteRequest
Definition: irp.c:1240
FORCEINLINE PLIST_ENTRY RemoveHeadList(_Inout_ PLIST_ENTRY ListHead)
Definition: rtlfuncs.h:128
UCHAR PacketData[1]
Definition: ndisuio.h:74
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
#define IO_NETWORK_INCREMENT
Definition: tcpip.h:43
Status
Definition: gdiplustypes.h:24
#define ASSERT(a)
Definition: mode.c:45
#define KeAcquireSpinLock(sl, irql)
Definition: env_spec_w32.h:609
PDEVICE_OBJECT GlobalDeviceObject
Definition: main.c:14
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:790
Definition: typedefs.h:119
VOID NTAPI IoReleaseCancelSpinLock(IN KIRQL Irql)
Definition: util.c:150
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2789
PFILE_OBJECT FileObject
Definition: iotypes.h:3148
BOOLEAN WriteOnly
Definition: ndisuio.h:59
_In_ PIO_STACK_LOCATION IrpSp
Definition: create.c:4137
#define NULL
Definition: types.h:112
#define KeReleaseSpinLock(sl, irql)
Definition: env_spec_w32.h:627
static VOID NTAPI ReadIrpCancel(PDEVICE_OBJECT DeviceObject, PIRP Irp)
Definition: readwrite.c:17
unsigned int ULONG
Definition: retypes.h:1
#define IO_NO_INCREMENT
Definition: iotypes.h:581
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
#define STATUS_SUCCESS
Definition: shellext.h:65
ULONG PacketLength
Definition: ndisuio.h:68
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:3107
LIST_ENTRY PacketList
Definition: ndisuio.h:37
#define ExFreePool(addr)
Definition: env_spec_w32.h:352

Referenced by DriverEntry().

◆ NduDispatchWrite()

NTSTATUS NTAPI NduDispatchWrite ( PDEVICE_OBJECT  DeviceObject,
PIRP  Irp 
)

Definition at line 158 of file readwrite.c.

160 {
162  PNDISUIO_ADAPTER_CONTEXT AdapterContext = IrpSp->FileObject->FsContext;
165  ULONG BytesCopied = 0;
166 
168 
169  /* Create a packet and buffer descriptor for this user buffer */
170  Packet = CreatePacketFromPoolBuffer(AdapterContext,
171  Irp->AssociatedIrp.SystemBuffer,
172  IrpSp->Parameters.Write.Length);
173  if (Packet)
174  {
175  /* Send it via NDIS */
176  NdisSend(&Status,
177  AdapterContext->BindingHandle,
178  Packet);
179 
180  /* Wait for the send */
182  {
183  KeWaitForSingleObject(&AdapterContext->AsyncEvent,
184  Executive,
185  KernelMode,
186  FALSE,
187  NULL);
188  Status = AdapterContext->AsyncStatus;
189  }
190 
191  /* Check if it succeeded */
193  BytesCopied = IrpSp->Parameters.Write.Length;
194 
196  }
197  else
198  {
199  /* No memory */
201  }
202 
203  /* Complete the IRP */
204  Irp->IoStatus.Status = Status;
205  Irp->IoStatus.Information = BytesCopied;
207 
208  return Status;
209 }
_In_ NDIS_HANDLE _In_ PNDIS_PACKET Packet
Definition: ndis.h:1548
#define NDIS_STATUS_PENDING
Definition: ndis.h:347
VOID CleanupAndFreePacket(PNDIS_PACKET Packet, BOOLEAN FreePool)
Definition: misc.c:83
NTSTATUS NTAPI KeWaitForSingleObject(IN PVOID Object, IN KWAIT_REASON WaitReason, IN KPROCESSOR_MODE WaitMode, IN BOOLEAN Alertable, IN PLARGE_INTEGER Timeout OPTIONAL)
Definition: wait.c:416
int NDIS_STATUS
Definition: ntddndis.h:471
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
#define FALSE
Definition: types.h:117
_In_ PIRP Irp
Definition: csq.h:116
VOID EXPORT NdisSend(OUT PNDIS_STATUS Status, IN NDIS_HANDLE NdisBindingHandle, IN PNDIS_PACKET Packet)
Definition: protocol.c:1272
_In_ UINT _In_ UINT _In_ PNDIS_PACKET _In_ UINT _Out_ PUINT BytesCopied
Definition: ndis.h:3167
#define IoCompleteRequest
Definition: irp.c:1240
#define IO_NETWORK_INCREMENT
Definition: tcpip.h:43
Status
Definition: gdiplustypes.h:24
#define ASSERT(a)
Definition: mode.c:45
NDIS_STATUS AsyncStatus
Definition: ndisuio.h:22
PNDIS_PACKET CreatePacketFromPoolBuffer(PNDISUIO_ADAPTER_CONTEXT AdapterContext, PVOID Buffer, ULONG BufferSize)
Definition: misc.c:52
#define NDIS_STATUS_SUCCESS
Definition: ndis.h:346
PDEVICE_OBJECT GlobalDeviceObject
Definition: main.c:14
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2789
PFILE_OBJECT FileObject
Definition: iotypes.h:3148
NDIS_HANDLE BindingHandle
Definition: ndisuio.h:26
_In_ PIO_STACK_LOCATION IrpSp
Definition: create.c:4137
#define STATUS_NO_MEMORY
Definition: ntstatus.h:260
#define NULL
Definition: types.h:112
unsigned int ULONG
Definition: retypes.h:1
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:3107

Referenced by DriverEntry().

◆ NduNetPnPEvent()

NDIS_STATUS NTAPI NduNetPnPEvent ( NDIS_HANDLE  ProtocolBindingContext,
PNET_PNP_EVENT  NetPnPEvent 
)

Definition at line 45 of file protocol.c.

47 {
49 
50  DPRINT("NetPnPEvent\n");
51 
52  switch (NetPnPEvent->NetEvent)
53  {
55  /* Nothing to do */
56  DPRINT1("NetPnPEvent: QueryRemoveDevice\n");
57  return NDIS_STATUS_SUCCESS;
58 
59  case NetEventSetPower:
60  ASSERT(NetPnPEvent->BufferLength >= sizeof(*PowerState));
61 
62  PowerState = NetPnPEvent->Buffer;
63  switch (*PowerState)
64  {
65  case NdisDeviceStateD0:
66  DPRINT1("NetPnPEvent: SetPower D0\n");
67  return NDIS_STATUS_SUCCESS;
68 
69  default:
70  DPRINT1("NetPnPEvent: SetPower state %d not supported\n", *PowerState);
71  return NDIS_STATUS_FAILURE;
72  }
73 
74  case NetEventQueryPower:
75  DPRINT1("NetPnPEvent: QueryPower\n");
76  return NDIS_STATUS_SUCCESS;
77 
79  DPRINT1("NetPnPEvent: CancelRemoveDevice\n");
80  return NDIS_STATUS_SUCCESS;
81 
83  DPRINT1("NetPnPEvent: Reconfigure\n");
84  return NDIS_STATUS_SUCCESS;
85 
86  case NetEventBindList:
87  DPRINT1("NetPnPEvent: BindList\n");
88  return NDIS_STATUS_SUCCESS;
89 
91  DPRINT("NetPnPEvent: BindsComplete\n");
92  return NDIS_STATUS_SUCCESS;
93 
95  DPRINT1("NetPnPEvent: PnPCapabilities\n");
96  return NDIS_STATUS_SUCCESS;
97 
98  default:
99  DPRINT1("NetPnPEvent unimplemented for net event 0x%x\n", NetPnPEvent->NetEvent);
100  return NDIS_STATUS_FAILURE;
101  }
102 }
enum _NDIS_DEVICE_POWER_STATE * PNDIS_DEVICE_POWER_STATE
_In_ NDIS_HANDLE _In_ PNET_PNP_EVENT NetPnPEvent
Definition: ndis.h:6081
void DPRINT(...)
Definition: polytest.cpp:61
#define ASSERT(a)
Definition: mode.c:45
#define NDIS_STATUS_SUCCESS
Definition: ndis.h:346
_Must_inspect_result_ _In_ PWDFDEVICE_INIT _In_ WDF_DEVICE_POWER_STATE PowerState
Definition: wdfdevice.h:3032
#define DPRINT1
Definition: precomp.h:8
#define NDIS_STATUS_FAILURE
Definition: ndis.h:465

Referenced by DriverEntry().

◆ NduOpenAdapterComplete()

VOID NTAPI NduOpenAdapterComplete ( NDIS_HANDLE  ProtocolBindingContext,
NDIS_STATUS  Status,
NDIS_STATUS  OpenStatus 
)

Definition at line 16 of file protocol.c.

19 {
21 
22  DPRINT("Asynchronous adapter open completed\n");
23 
24  /* Store the final status and signal the event */
25  AdapterContext->AsyncStatus = Status;
26  KeSetEvent(&AdapterContext->AsyncEvent, IO_NO_INCREMENT, FALSE);
27 }
_Must_inspect_result_ _Out_ PNDIS_STATUS _Out_ PNDIS_STATUS _Out_ PNDIS_HANDLE _Out_ PUINT _In_ UINT _In_ NDIS_HANDLE _In_ NDIS_HANDLE ProtocolBindingContext
Definition: ndis.h:6013
LONG NTAPI KeSetEvent(IN PKEVENT Event, IN KPRIORITY Increment, IN BOOLEAN Wait)
Definition: eventobj.c:159
#define FALSE
Definition: types.h:117
void DPRINT(...)
Definition: polytest.cpp:61
Status
Definition: gdiplustypes.h:24
NDIS_STATUS AsyncStatus
Definition: ndisuio.h:22
#define IO_NO_INCREMENT
Definition: iotypes.h:581

Referenced by DriverEntry().

◆ NduReceive()

NDIS_STATUS NTAPI NduReceive ( NDIS_HANDLE  ProtocolBindingContext,
NDIS_HANDLE  MacReceiveContext,
PVOID  HeaderBuffer,
UINT  HeaderBufferSize,
PVOID  LookAheadBuffer,
UINT  LookaheadBufferSize,
UINT  PacketSize 
)

Definition at line 166 of file protocol.c.

173 {
175  PNDISUIO_PACKET_ENTRY PacketEntry;
176  PVOID PacketBuffer;
180 
181  DPRINT("Received a %d byte packet\n", PacketSize);
182 
183  /* Discard if nobody is waiting for it */
184  if (AdapterContext->OpenCount == 0)
186 
187  /* Allocate a buffer to hold the packet data and header */
188  PacketBuffer = ExAllocatePool(NonPagedPool, PacketSize + HeaderBufferSize);
189  if (!PacketBuffer)
191 
192  /* Allocate the packet descriptor and buffer */
193  Packet = CreatePacketFromPoolBuffer(AdapterContext,
194  (PUCHAR)PacketBuffer + HeaderBufferSize,
195  PacketSize);
196  if (!Packet)
197  {
198  ExFreePool(PacketBuffer);
200  }
201 
202  /* Transfer the packet data into our data buffer */
203  if (LookaheadBufferSize == PacketSize)
204  {
205  NdisCopyLookaheadData((PVOID)((PUCHAR)PacketBuffer + HeaderBufferSize),
206  LookAheadBuffer,
207  PacketSize,
208  AdapterContext->MacOptions);
210  }
211  else
212  {
214  AdapterContext->BindingHandle,
215  MacReceiveContext,
216  0,
217  PacketSize,
218  Packet,
221  {
222  KeWaitForSingleObject(&AdapterContext->AsyncEvent,
223  Executive,
224  KernelMode,
225  FALSE,
226  NULL);
227  Status = AdapterContext->AsyncStatus;
228  }
230  {
231  DPRINT1("Failed to transfer data with status 0x%x\n", Status);
233  ExFreePool(PacketBuffer);
235  }
236  }
237 
238  /* Copy the header data */
239  RtlCopyMemory(PacketBuffer, HeaderBuffer, HeaderBufferSize);
240 
241  /* Free the packet descriptor and buffers
242  but not the pool because we still need it */
244 
245  /* Allocate a packet entry from pool */
246  PacketEntry = ExAllocatePool(NonPagedPool, sizeof(NDISUIO_PACKET_ENTRY) + BytesTransferred + HeaderBufferSize - 1);
247  if (!PacketEntry)
248  {
249  ExFreePool(PacketBuffer);
250  return NDIS_STATUS_RESOURCES;
251  }
252 
253  /* Initialize the packet entry and copy in packet data */
254  PacketEntry->PacketLength = BytesTransferred + HeaderBufferSize;
255  RtlCopyMemory(PacketEntry->PacketData, PacketBuffer, PacketEntry->PacketLength);
256 
257  /* Free the old buffer */
258  ExFreePool(PacketBuffer);
259 
260  /* Insert the packet on the adapter's packet list */
261  ExInterlockedInsertTailList(&AdapterContext->PacketList,
262  &PacketEntry->ListEntry,
263  &AdapterContext->Spinlock);
264 
265  /* Signal the read event */
266  KeSetEvent(&AdapterContext->PacketReadEvent,
268  FALSE);
269 
270  return NDIS_STATUS_SUCCESS;
271 }
_Must_inspect_result_ _Out_ PNDIS_STATUS _Out_ PNDIS_STATUS _Out_ PNDIS_HANDLE _Out_ PUINT _In_ UINT _In_ NDIS_HANDLE _In_ NDIS_HANDLE ProtocolBindingContext
Definition: ndis.h:6013
Definition: ndisuio.h:65
_Must_inspect_result_ _In_ WDFUSBDEVICE _In_opt_ WDFREQUEST _In_opt_ PWDF_REQUEST_SEND_OPTIONS _In_ PWDF_USB_CONTROL_SETUP_PACKET _In_opt_ PWDF_MEMORY_DESCRIPTOR _Out_opt_ PULONG BytesTransferred
Definition: wdfusb.h:1331
_In_ NDIS_HANDLE _In_ PNDIS_PACKET Packet
Definition: ndis.h:1548
#define NDIS_STATUS_PENDING
Definition: ndis.h:347
unsigned char * PUCHAR
Definition: retypes.h:3
PLIST_ENTRY NTAPI ExInterlockedInsertTailList(IN OUT PLIST_ENTRY ListHead, IN OUT PLIST_ENTRY ListEntry, IN OUT PKSPIN_LOCK Lock)
Definition: interlocked.c:140
KSPIN_LOCK Spinlock
Definition: ndisuio.h:50
VOID CleanupAndFreePacket(PNDIS_PACKET Packet, BOOLEAN FreePool)
Definition: misc.c:83
LONG NTAPI KeSetEvent(IN PKEVENT Event, IN KPRIORITY Increment, IN BOOLEAN Wait)
Definition: eventobj.c:159
NTSTATUS NTAPI KeWaitForSingleObject(IN PVOID Object, IN KWAIT_REASON WaitReason, IN KPROCESSOR_MODE WaitMode, IN BOOLEAN Alertable, IN PLARGE_INTEGER Timeout OPTIONAL)
Definition: wait.c:416
int NDIS_STATUS
Definition: ntddndis.h:471
#define FALSE
Definition: types.h:117
UCHAR PacketData[1]
Definition: ndisuio.h:74
void DPRINT(...)
Definition: polytest.cpp:61
#define IO_NETWORK_INCREMENT
Definition: tcpip.h:43
Status
Definition: gdiplustypes.h:24
#define NDIS_STATUS_NOT_ACCEPTED
Definition: ndis.h:350
#define NdisCopyLookaheadData(Destination, Source, Length, MacOptions)
Definition: ndis.h:3289
NDIS_STATUS AsyncStatus
Definition: ndisuio.h:22
PNDIS_PACKET CreatePacketFromPoolBuffer(PNDISUIO_ADAPTER_CONTEXT AdapterContext, PVOID Buffer, ULONG BufferSize)
Definition: misc.c:52
#define NDIS_STATUS_SUCCESS
Definition: ndis.h:346
#define ExAllocatePool(type, size)
Definition: fbtusb.h:44
NDIS_HANDLE BindingHandle
Definition: ndisuio.h:26
_In_ USHORT PacketSize
Definition: iofuncs.h:1056
unsigned int UINT
Definition: ndis.h:50
#define NULL
Definition: types.h:112
#define DPRINT1
Definition: precomp.h:8
#define NDIS_STATUS_RESOURCES
Definition: ndis.h:466
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
ULONG PacketLength
Definition: ndisuio.h:68
VOID EXPORT NdisTransferData(OUT PNDIS_STATUS Status, IN NDIS_HANDLE NdisBindingHandle, IN NDIS_HANDLE MacReceiveContext, IN UINT ByteOffset, IN UINT BytesToTransfer, IN OUT PNDIS_PACKET Packet, OUT PUINT BytesTransferred)
Definition: protocol.c:1307
LIST_ENTRY PacketList
Definition: ndisuio.h:37
LIST_ENTRY ListEntry
Definition: ndisuio.h:71
#define ExFreePool(addr)
Definition: env_spec_w32.h:352

Referenced by DriverEntry().

◆ NduReceiveComplete()

VOID NTAPI NduReceiveComplete ( NDIS_HANDLE  ProtocolBindingContext)

Definition at line 275 of file protocol.c.

276 {
277  /* No op */
278 }

Referenced by DriverEntry().

◆ NduRequestComplete()

VOID NTAPI NduRequestComplete ( NDIS_HANDLE  ProtocolBindingContext,
PNDIS_REQUEST  NdisRequest,
NDIS_STATUS  Status 
)

Definition at line 151 of file protocol.c.

154 {
156 
157  DPRINT("Asynchronous adapter request completed\n");
158 
159  /* Store the final status and signal the event */
160  AdapterContext->AsyncStatus = Status;
161  KeSetEvent(&AdapterContext->AsyncEvent, IO_NO_INCREMENT, FALSE);
162 }
_Must_inspect_result_ _Out_ PNDIS_STATUS _Out_ PNDIS_STATUS _Out_ PNDIS_HANDLE _Out_ PUINT _In_ UINT _In_ NDIS_HANDLE _In_ NDIS_HANDLE ProtocolBindingContext
Definition: ndis.h:6013
LONG NTAPI KeSetEvent(IN PKEVENT Event, IN KPRIORITY Increment, IN BOOLEAN Wait)
Definition: eventobj.c:159
#define FALSE
Definition: types.h:117
void DPRINT(...)
Definition: polytest.cpp:61
Status
Definition: gdiplustypes.h:24
NDIS_STATUS AsyncStatus
Definition: ndisuio.h:22
#define IO_NO_INCREMENT
Definition: iotypes.h:581

Referenced by DriverEntry().

◆ NduResetComplete()

VOID NTAPI NduResetComplete ( NDIS_HANDLE  ProtocolBindingContext,
NDIS_STATUS  Status 
)

Definition at line 137 of file protocol.c.

139 {
141 
142  DPRINT("Asynchronous adapter reset completed\n");
143 
144  /* Store the final status and signal the event */
145  AdapterContext->AsyncStatus = Status;
146  KeSetEvent(&AdapterContext->AsyncEvent, IO_NO_INCREMENT, FALSE);
147 }
_Must_inspect_result_ _Out_ PNDIS_STATUS _Out_ PNDIS_STATUS _Out_ PNDIS_HANDLE _Out_ PUINT _In_ UINT _In_ NDIS_HANDLE _In_ NDIS_HANDLE ProtocolBindingContext
Definition: ndis.h:6013
LONG NTAPI KeSetEvent(IN PKEVENT Event, IN KPRIORITY Increment, IN BOOLEAN Wait)
Definition: eventobj.c:159
#define FALSE
Definition: types.h:117
void DPRINT(...)
Definition: polytest.cpp:61
Status
Definition: gdiplustypes.h:24
NDIS_STATUS AsyncStatus
Definition: ndisuio.h:22
#define IO_NO_INCREMENT
Definition: iotypes.h:581

Referenced by DriverEntry().

◆ NduSendComplete()

VOID NTAPI NduSendComplete ( NDIS_HANDLE  ProtocolBindingContext,
PNDIS_PACKET  Packet,
NDIS_STATUS  Status 
)

Definition at line 106 of file protocol.c.

109 {
111 
112  DPRINT("Asynchronous adapter send completed\n");
113 
114  /* Store the final status and signal the event */
115  AdapterContext->AsyncStatus = Status;
116  KeSetEvent(&AdapterContext->AsyncEvent, IO_NO_INCREMENT, FALSE);
117 }
_Must_inspect_result_ _Out_ PNDIS_STATUS _Out_ PNDIS_STATUS _Out_ PNDIS_HANDLE _Out_ PUINT _In_ UINT _In_ NDIS_HANDLE _In_ NDIS_HANDLE ProtocolBindingContext
Definition: ndis.h:6013
LONG NTAPI KeSetEvent(IN PKEVENT Event, IN KPRIORITY Increment, IN BOOLEAN Wait)
Definition: eventobj.c:159
#define FALSE
Definition: types.h:117
void DPRINT(...)
Definition: polytest.cpp:61
Status
Definition: gdiplustypes.h:24
NDIS_STATUS AsyncStatus
Definition: ndisuio.h:22
#define IO_NO_INCREMENT
Definition: iotypes.h:581

Referenced by DriverEntry().

◆ NduStatus()

VOID NTAPI NduStatus ( NDIS_HANDLE  ProtocolBindingContext,
NDIS_STATUS  GeneralStatus,
PVOID  StatusBuffer,
UINT  StatusBufferSize 
)

Definition at line 282 of file protocol.c.

286 {
287  /* FIXME: Implement status tracking */
288 }

Referenced by DriverEntry().

◆ NduStatusComplete()

VOID NTAPI NduStatusComplete ( NDIS_HANDLE  ProtocolBindingContext)

Definition at line 292 of file protocol.c.

293 {
294  /* FIXME: Implement status tracking */
295 }

Referenced by DriverEntry().

◆ NduTransferDataComplete()

VOID NTAPI NduTransferDataComplete ( NDIS_HANDLE  ProtocolBindingContext,
PNDIS_PACKET  Packet,
NDIS_STATUS  Status,
UINT  BytesTransferred 
)

Definition at line 121 of file protocol.c.

125 {
127 
128  DPRINT("Asynchronous adapter transfer completed\n");
129 
130  /* Store the final status and signal the event */
131  AdapterContext->AsyncStatus = Status;
132  KeSetEvent(&AdapterContext->AsyncEvent, IO_NO_INCREMENT, FALSE);
133 }
_Must_inspect_result_ _Out_ PNDIS_STATUS _Out_ PNDIS_STATUS _Out_ PNDIS_HANDLE _Out_ PUINT _In_ UINT _In_ NDIS_HANDLE _In_ NDIS_HANDLE ProtocolBindingContext
Definition: ndis.h:6013
LONG NTAPI KeSetEvent(IN PKEVENT Event, IN KPRIORITY Increment, IN BOOLEAN Wait)
Definition: eventobj.c:159
#define FALSE
Definition: types.h:117
void DPRINT(...)
Definition: polytest.cpp:61
Status
Definition: gdiplustypes.h:24
NDIS_STATUS AsyncStatus
Definition: ndisuio.h:22
#define IO_NO_INCREMENT
Definition: iotypes.h:581

Referenced by DriverEntry().

◆ NduUnbindAdapter()

VOID NTAPI NduUnbindAdapter ( PNDIS_STATUS  Status,
NDIS_HANDLE  ProtocolBindingContext,
NDIS_HANDLE  UnbindContext 
)

Definition at line 550 of file protocol.c.

553 {
554  /* This is forced unbind. UnbindAdapterByContext() will take care of
555  * invalidating file handles pointer to this adapter for us */
557 }
_Must_inspect_result_ _Out_ PNDIS_STATUS _Out_ PNDIS_STATUS _Out_ PNDIS_HANDLE _Out_ PUINT _In_ UINT _In_ NDIS_HANDLE _In_ NDIS_HANDLE ProtocolBindingContext
Definition: ndis.h:6013
static NDIS_STATUS UnbindAdapterByContext(PNDISUIO_ADAPTER_CONTEXT AdapterContext)
Definition: protocol.c:299
Status
Definition: gdiplustypes.h:24

Referenced by DriverEntry().

◆ ReferenceAdapterContext()

VOID ReferenceAdapterContext ( PNDISUIO_ADAPTER_CONTEXT  AdapterContext)

Definition at line 142 of file misc.c.

143 {
144  /* Increment the open count */
145  AdapterContext->OpenCount++;
146 }

Referenced by OpenDeviceReadWrite().

Variable Documentation

◆ GlobalAdapterList

LIST_ENTRY GlobalAdapterList

Definition at line 17 of file main.c.

Referenced by BindAdapterByName(), DriverEntry(), FindAdapterContextByName(), and QueryBinding().

◆ GlobalAdapterListLock

KSPIN_LOCK GlobalAdapterListLock

◆ GlobalDeviceObject

◆ GlobalProtocolHandle

NDIS_HANDLE GlobalProtocolHandle

Definition at line 15 of file main.c.

Referenced by BindAdapterByName(), and DriverEntry().