ReactOS  0.4.15-dev-1374-g8d3e80e
main.c File Reference
#include "ndisuio.h"
#include <debug.h>
Include dependency graph for main.c:

Go to the source code of this file.

Macros

#define NDEBUG
 

Functions

VOID NTAPI NduUnload (PDRIVER_OBJECT DriverObject)
 
NTSTATUS NTAPI DriverEntry (PDRIVER_OBJECT DriverObject, PUNICODE_STRING RegistryPath)
 

Variables

PDEVICE_OBJECT GlobalDeviceObject
 
NDIS_HANDLE GlobalProtocolHandle
 
KSPIN_LOCK GlobalAdapterListLock
 
LIST_ENTRY GlobalAdapterList
 
NDIS_STRING ProtocolName = RTL_CONSTANT_STRING(L"NDISUIO")
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 11 of file main.c.

Function Documentation

◆ DriverEntry()

NTSTATUS NTAPI DriverEntry ( PDRIVER_OBJECT  DriverObject,
PUNICODE_STRING  RegistryPath 
)

Definition at line 28 of file main.c.

30 {
35 
36  /* Setup dispatch functions */
38  DriverObject->MajorFunction[IRP_MJ_CLOSE] = NduDispatchClose;
40  DriverObject->MajorFunction[IRP_MJ_READ] = NduDispatchRead;
41  DriverObject->MajorFunction[IRP_MJ_WRITE] = NduDispatchWrite;
42  DriverObject->DriverUnload = NduUnload;
43 
44  /* Setup global state */
47 
48  /* Create the NDISUIO device object */
50  0,
51  &NtDeviceName,
53  0,
54  FALSE,
56  if (!NT_SUCCESS(Status))
57  {
58  DPRINT1("Failed to create device object with status 0x%x\n", Status);
59  return Status;
60  }
61 
62  /* Create a symbolic link into the DOS devices namespace */
63  Status = IoCreateSymbolicLink(&DosDeviceName, &NtDeviceName);
64  if (!NT_SUCCESS(Status))
65  {
66  DPRINT1("Failed to create symbolic link with status 0x%x\n", Status);
68  return Status;
69  }
70 
71  /* Register the protocol with NDIS */
72  RtlZeroMemory(&Chars, sizeof(Chars));
82  Chars.ReceiveHandler = NduReceive;
84  Chars.StatusHandler = NduStatus;
86  Chars.Name = ProtocolName;
89 
92  &Chars,
93  sizeof(Chars));
95  {
96  DPRINT1("Failed to register protocol with status 0x%x\n", Status);
99  return Status;
100  }
101 
102  DPRINT("NDISUIO: Loaded\n");
103 
104  return STATUS_SUCCESS;
105 }
#define NDIS_MAJOR_VERSION
Definition: ndisuio.h:78
NDIS_STATUS NTAPI NduNetPnPEvent(NDIS_HANDLE ProtocolBindingContext, PNET_PNP_EVENT NetPnPEvent)
Definition: protocol.c:45
#define IRP_MJ_CREATE
Definition: rdpdr.c:44
#define NDISUIO_DEVICE_NAME_DOS
Definition: nuiouser.h:6
NTSTATUS NTAPI NduDispatchCreate(PDEVICE_OBJECT DeviceObject, PIRP Irp)
Definition: createclose.c:16
REQUEST_COMPLETE_HANDLER RequestCompleteHandler
Definition: ndis.h:1887
VOID EXPORT NdisRegisterProtocol(OUT PNDIS_STATUS Status, OUT PNDIS_HANDLE NdisProtocolHandle, IN PNDIS_PROTOCOL_CHARACTERISTICS ProtocolCharacteristics, IN UINT CharacteristicsLength)
Definition: protocol.c:1115
VOID NTAPI NduCloseAdapterComplete(NDIS_HANDLE ProtocolBindingContext, NDIS_STATUS Status)
Definition: protocol.c:31
VOID NTAPI NduUnbindAdapter(PNDIS_STATUS Status, NDIS_HANDLE ProtocolBindingContext, NDIS_HANDLE UnbindContext)
Definition: protocol.c:550
UNBIND_HANDLER UnbindAdapterHandler
Definition: ndis.h:1898
CLOSE_ADAPTER_COMPLETE_HANDLER CloseAdapterCompleteHandler
Definition: ndis.h:1877
VOID NTAPI NduReceiveComplete(NDIS_HANDLE ProtocolBindingContext)
Definition: protocol.c:275
NTSTATUS NTAPI NduDispatchClose(PDEVICE_OBJECT DeviceObject, PIRP Irp)
Definition: createclose.c:40
RECEIVE_COMPLETE_HANDLER ReceiveCompleteHandler
Definition: ndis.h:1892
STATUS_HANDLER StatusHandler
Definition: ndis.h:1893
NTSTATUS NTAPI NduDispatchWrite(PDEVICE_OBJECT DeviceObject, PIRP Irp)
Definition: readwrite.c:158
int NDIS_STATUS
Definition: ntddndis.h:471
VOID NTAPI NduSendComplete(NDIS_HANDLE ProtocolBindingContext, PNDIS_PACKET Packet, NDIS_STATUS Status)
Definition: protocol.c:106
#define FALSE
Definition: types.h:117
VOID NTAPI NduResetComplete(NDIS_HANDLE ProtocolBindingContext, NDIS_STATUS Status)
Definition: protocol.c:137
FORCEINLINE VOID KeInitializeSpinLock(_Out_ PKSPIN_LOCK SpinLock)
Definition: kefuncs.h:238
VOID NTAPI NduStatusComplete(NDIS_HANDLE ProtocolBindingContext)
Definition: protocol.c:292
BIND_HANDLER BindAdapterHandler
Definition: ndis.h:1897
void DPRINT(...)
Definition: polytest.cpp:61
KSPIN_LOCK GlobalAdapterListLock
Definition: main.c:16
RESET_COMPLETE_HANDLER ResetCompleteHandler
Definition: ndis.h:1886
_Must_inspect_result_ _In_ PDRIVER_OBJECT DriverObject
Definition: wdfdriver.h:213
OPEN_ADAPTER_COMPLETE_HANDLER OpenAdapterCompleteHandler
Definition: ndis.h:1876
#define NDISUIO_DEVICE_NAME_NT
Definition: nuiouser.h:5
VOID NTAPI NduOpenAdapterComplete(NDIS_HANDLE ProtocolBindingContext, NDIS_STATUS Status, NDIS_STATUS OpenStatus)
Definition: protocol.c:16
Status
Definition: gdiplustypes.h:24
VOID NTAPI NduBindAdapter(PNDIS_STATUS Status, NDIS_HANDLE BindContext, PNDIS_STRING DeviceName, PVOID SystemSpecific1, PVOID SystemSpecific2)
Definition: protocol.c:538
TRANSFER_DATA_COMPLETE_HANDLER TransferDataCompleteHandler
Definition: ndis.h:1883
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
VOID NTAPI NduRequestComplete(NDIS_HANDLE ProtocolBindingContext, PNDIS_REQUEST NdisRequest, NDIS_STATUS Status)
Definition: protocol.c:151
STATUS_COMPLETE_HANDLER StatusCompleteHandler
Definition: ndis.h:1894
NTSTATUS NTAPI NduDispatchDeviceControl(PDEVICE_OBJECT DeviceObject, PIRP Irp)
Definition: ioctl.c:469
#define NDIS_STATUS_SUCCESS
Definition: ndis.h:346
static char DosDeviceName[DEVICE_SIZE]
Definition: lsdd.c:26
PDEVICE_OBJECT GlobalDeviceObject
Definition: main.c:14
#define IRP_MJ_CLOSE
Definition: rdpdr.c:45
NTSTATUS NTAPI NduDispatchRead(PDEVICE_OBJECT DeviceObject, PIRP Irp)
Definition: readwrite.c:42
RECEIVE_HANDLER ReceiveHandler
Definition: ndis.h:1889
VOID NTAPI IoDeleteDevice(IN PDEVICE_OBJECT DeviceObject)
Definition: device.c:1251
SEND_COMPLETE_HANDLER SendCompleteHandler
Definition: ndis.h:1879
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
LIST_ENTRY GlobalAdapterList
Definition: main.c:17
#define DPRINT1
Definition: precomp.h:8
#define IRP_MJ_READ
Definition: rdpdr.c:46
VOID NTAPI NduStatus(NDIS_HANDLE ProtocolBindingContext, NDIS_STATUS GeneralStatus, PVOID StatusBuffer, UINT StatusBufferSize)
Definition: protocol.c:282
VOID NTAPI NduUnload(PDRIVER_OBJECT DriverObject)
Definition: main.c:21
#define NDIS_MINOR_VERSION
Definition: ndisuio.h:79
NTSTATUS NTAPI IoCreateDevice(IN PDRIVER_OBJECT DriverObject, IN ULONG DeviceExtensionSize, IN PUNICODE_STRING DeviceName, IN DEVICE_TYPE DeviceType, IN ULONG DeviceCharacteristics, IN BOOLEAN Exclusive, OUT PDEVICE_OBJECT *DeviceObject)
Definition: device.c:1031
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
#define IRP_MJ_WRITE
Definition: rdpdr.c:47
#define FILE_DEVICE_SECURE_OPEN
Definition: cdrw_usr.h:46
#define STATUS_SUCCESS
Definition: shellext.h:65
NDIS_STRING ProtocolName
Definition: main.c:19
NDIS_HANDLE GlobalProtocolHandle
Definition: main.c:15
NDIS_STATUS NTAPI NduReceive(NDIS_HANDLE ProtocolBindingContext, NDIS_HANDLE MacReceiveContext, PVOID HeaderBuffer, UINT HeaderBufferSize, PVOID LookAheadBuffer, UINT LookaheadBufferSize, UINT PacketSize)
Definition: protocol.c:166
PNP_EVENT_HANDLER PnPEventHandler
Definition: ndis.h:1899
#define IRP_MJ_DEVICE_CONTROL
Definition: rdpdr.c:52
#define RTL_CONSTANT_STRING(s)
Definition: tunneltest.c:14
VOID NTAPI NduTransferDataComplete(NDIS_HANDLE ProtocolBindingContext, PNDIS_PACKET Packet, NDIS_STATUS Status, UINT BytesTransferred)
Definition: protocol.c:121

◆ NduUnload()

VOID NTAPI NduUnload ( PDRIVER_OBJECT  DriverObject)

Definition at line 21 of file main.c.

22 {
23  DPRINT("NDISUIO: Unloaded\n");
24 }
void DPRINT(...)
Definition: polytest.cpp:61

Referenced by DriverEntry().

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().

◆ ProtocolName

NDIS_STRING ProtocolName = RTL_CONSTANT_STRING(L"NDISUIO")

Definition at line 19 of file main.c.

Referenced by DriverEntry().