ReactOS  0.4.14-dev-293-g2b39b42
misc.c File Reference
#include "ndissys.h"
Include dependency graph for misc.c:

Go to the source code of this file.

Classes

struct  _NDIS_HANDLE_OBJECT
 

Typedefs

typedef struct _NDIS_HANDLE_OBJECT NDIS_HANDLE_OBJECT
 
typedef struct _NDIS_HANDLE_OBJECTPNDIS_HANDLE_OBJECT
 

Functions

VOID EXPORT NdisInterlockedAddUlong (IN PULONG Addend, IN ULONG Increment, IN PNDIS_SPIN_LOCK SpinLock)
 
VOID EXPORT NdisInterlockedAddLargeInteger (IN PLARGE_INTEGER Addend, IN LARGE_INTEGER Increment, IN PNDIS_SPIN_LOCK SpinLock)
 
LONG EXPORT NdisCompareAnsiString (IN PNDIS_ANSI_STRING String1, IN PNDIS_ANSI_STRING String2, BOOLEAN CaseInSensitive)
 
LONG EXPORT NdisCompareUnicodeString (IN PNDIS_STRING String1, IN PNDIS_STRING String2, IN BOOLEAN CaseInSensitive)
 
PLIST_ENTRY EXPORT NdisInterlockedInsertHeadList (IN PLIST_ENTRY ListHead, IN PLIST_ENTRY ListEntry, IN PNDIS_SPIN_LOCK SpinLock)
 
PLIST_ENTRY EXPORT NdisInterlockedInsertTailList (IN PLIST_ENTRY ListHead, IN PLIST_ENTRY ListEntry, IN PNDIS_SPIN_LOCK SpinLock)
 
PLIST_ENTRY EXPORT NdisInterlockedRemoveHeadList (IN PLIST_ENTRY ListHead, IN PNDIS_SPIN_LOCK SpinLock)
 
__inline PNDIS_HANDLE_OBJECT NDIS_HANDLE_TO_POBJECT (NDIS_HANDLE handle)
 
__inline NDIS_HANDLE NDIS_POBJECT_TO_HANDLE (PNDIS_HANDLE_OBJECT obj)
 
VOID EXPORT NdisMapFile (OUT PNDIS_STATUS Status, OUT PVOID *MappedBuffer, IN NDIS_HANDLE FileHandle)
 
VOID EXPORT NdisUnmapFile (IN NDIS_HANDLE FileHandle)
 
VOID EXPORT NdisCloseFile (IN NDIS_HANDLE FileHandle)
 
VOID EXPORT NdisOpenFile (OUT PNDIS_STATUS Status, OUT PNDIS_HANDLE FileHandle, OUT PUINT FileLength, IN PNDIS_STRING FileName, IN NDIS_PHYSICAL_ADDRESS HighestAcceptableAddress)
 
CCHAR EXPORT NdisSystemProcessorCount (VOID)
 
VOID EXPORT NdisGetCurrentProcessorCounts (OUT PULONG pIdleCount, OUT PULONG pKernelAndUser, OUT PULONG pIndex)
 
VOID EXPORT NdisGetSystemUpTime (OUT PULONG pSystemUpTime)
 
LONG EXPORT NdisInterlockedDecrement (IN PLONG Addend)
 
LONG EXPORT NdisInterlockedIncrement (IN PLONG Addend)
 
PSINGLE_LIST_ENTRY EXPORT NdisInterlockedPopEntrySList (IN PSLIST_HEADER ListHead, IN PKSPIN_LOCK Lock)
 
PSINGLE_LIST_ENTRY EXPORT NdisInterlockedPushEntrySList (IN PSLIST_HEADER ListHead, IN PSINGLE_LIST_ENTRY ListEntry, IN PKSPIN_LOCK Lock)
 
VOID NTAPI ndisProcWorkItemHandler (PVOID pContext)
 
NDIS_STATUS EXPORT NdisScheduleWorkItem (IN PNDIS_WORK_ITEM pWorkItem)
 
VOID EXPORT NdisGetCurrentProcessorCpuUsage (PULONG pCpuUsage)
 
ULONG EXPORT NdisGetSharedDataAlignment (VOID)
 
UINT EXPORT NdisGetVersion (VOID)
 
UCHAR EXPORT NdisGeneratePartialCancelId (VOID)
 

Variables

LONG CancelId
 
static const WCHAR NDIS_FILE_FOLDER [] = L"\\SystemRoot\\System32\\Drivers\\"
 

Typedef Documentation

◆ NDIS_HANDLE_OBJECT

◆ PNDIS_HANDLE_OBJECT

Function Documentation

◆ NDIS_HANDLE_TO_POBJECT()

__inline PNDIS_HANDLE_OBJECT NDIS_HANDLE_TO_POBJECT ( NDIS_HANDLE  handle)

Definition at line 130 of file misc.c.

131 {
132  return (PNDIS_HANDLE_OBJECT)handle;
133 }
namespace GUID const ADDRINFOEXW ADDRINFOEXW struct timeval OVERLAPPED LPLOOKUPSERVICE_COMPLETION_ROUTINE HANDLE * handle
Definition: sock.c:82

Referenced by NdisCloseFile().

◆ NDIS_POBJECT_TO_HANDLE()

__inline NDIS_HANDLE NDIS_POBJECT_TO_HANDLE ( PNDIS_HANDLE_OBJECT  obj)

Definition at line 137 of file misc.c.

138 {
139  return (NDIS_HANDLE)obj;
140 }
GLsizei GLsizei GLuint * obj
Definition: glext.h:6042

Referenced by NdisOpenFile().

◆ NdisCloseFile()

VOID EXPORT NdisCloseFile ( IN NDIS_HANDLE  FileHandle)

Definition at line 193 of file misc.c.

195 {
196  PNDIS_HANDLE_OBJECT FileHandleObject;
197 
199 
200  NDIS_DbgPrint(MAX_TRACE, ("Called.\n"));
201 
202  ASSERT ( FileHandle );
203 
204  FileHandleObject = NDIS_HANDLE_TO_POBJECT(FileHandle);
205 
206  ASSERT ( FileHandleObject->FileHandle );
207 
208  if ( FileHandleObject->Mapped )
210 
211  ZwClose ( FileHandleObject->FileHandle );
212 
213  memset ( FileHandleObject, 0, sizeof(NDIS_HANDLE_OBJECT) );
214 
215  ExFreePool ( FileHandleObject );
216 }
NTSYSAPI NTSTATUS NTAPI ZwClose(_In_ HANDLE Handle)
HANDLE FileHandle
Definition: stats.c:38
HANDLE FileHandle
Definition: misc.c:122
VOID EXPORT NdisUnmapFile(IN NDIS_HANDLE FileHandle)
Definition: misc.c:178
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define PASSIVE_LEVEL
Definition: env_spec_w32.h:693
__inline PNDIS_HANDLE_OBJECT NDIS_HANDLE_TO_POBJECT(NDIS_HANDLE handle)
Definition: misc.c:130
#define MAX_TRACE
Definition: debug.h:16
BOOLEAN Mapped
Definition: misc.c:123
#define NDIS_DbgPrint(_t_, _x_)
Definition: debug.h:40
#define ASSERT_IRQL(x)
Definition: debug.h:42
#define memset(x, y, z)
Definition: compat.h:39
#define ExFreePool(addr)
Definition: env_spec_w32.h:352

◆ NdisCompareAnsiString()

LONG EXPORT NdisCompareAnsiString ( IN PNDIS_ANSI_STRING  String1,
IN PNDIS_ANSI_STRING  String2,
BOOLEAN  CaseInSensitive 
)

Definition at line 49 of file misc.c.

53 {
54  /* This one needs to be verified also. See the
55  * comment in NdisInterlockedAddLargeInteger
56  */
57 
58  return RtlCompareString(String1, String2, CaseInSensitive);
59 }
NTSYSAPI LONG NTAPI RtlCompareString(PSTRING String1, PSTRING String2, BOOLEAN CaseInSensitive)
_In_ const STRING _In_ BOOLEAN CaseInSensitive
Definition: rtlfuncs.h:2292
_In_ const STRING * String2
Definition: rtlfuncs.h:2261

◆ NdisCompareUnicodeString()

LONG EXPORT NdisCompareUnicodeString ( IN PNDIS_STRING  String1,
IN PNDIS_STRING  String2,
IN BOOLEAN  CaseInSensitive 
)

Definition at line 66 of file misc.c.

70 {
71  /* This one needs to be verified also. See the
72  * comment in NdisInterlockedAddLargeInteger
73  */
74 
76 }
_In_ const STRING _In_ BOOLEAN CaseInSensitive
Definition: rtlfuncs.h:2292
ULONG RtlCompareUnicodeString(PUNICODE_STRING s1, PUNICODE_STRING s2, BOOLEAN UpCase)
Definition: string_lib.cpp:31
_In_ const STRING * String2
Definition: rtlfuncs.h:2261

◆ NdisGeneratePartialCancelId()

UCHAR EXPORT NdisGeneratePartialCancelId ( VOID  )

Definition at line 526 of file misc.c.

527 {
528  UCHAR PartialCancelId;
529 
530  PartialCancelId = (UCHAR)InterlockedIncrement(&CancelId);
531 
532  NDIS_DbgPrint(MAX_TRACE, ("Cancel ID %u\n", PartialCancelId));
533 
534  return PartialCancelId;
535 }
unsigned char UCHAR
Definition: xmlstorage.h:181
#define InterlockedIncrement
Definition: armddk.h:53
#define MAX_TRACE
Definition: debug.h:16
#define NDIS_DbgPrint(_t_, _x_)
Definition: debug.h:40
LONG CancelId
Definition: main.c:23

◆ NdisGetCurrentProcessorCounts()

VOID EXPORT NdisGetCurrentProcessorCounts ( OUT PULONG  pIdleCount,
OUT PULONG  pKernelAndUser,
OUT PULONG  pIndex 
)

Definition at line 336 of file misc.c.

346 {
347  NDIS_DbgPrint(MAX_TRACE, ("Called.\n"));
348 
350 }
VOID NTAPI ExGetCurrentProcessorCounts(PULONG ThreadKernelTime, PULONG TotalCpuTime, PULONG ProcessorNumber)
Definition: sysinfo.c:345
_Out_ PULONG _Out_ PULONG pIndex
Definition: ndis.h:4564
#define MAX_TRACE
Definition: debug.h:16
_Out_ PULONG pKernelAndUser
Definition: ndis.h:4564
unsigned int * PULONG
Definition: retypes.h:1
#define NDIS_DbgPrint(_t_, _x_)
Definition: debug.h:40

◆ NdisGetCurrentProcessorCpuUsage()

VOID EXPORT NdisGetCurrentProcessorCpuUsage ( PULONG  pCpuUsage)

Definition at line 484 of file misc.c.

491 {
492  NDIS_DbgPrint(MAX_TRACE, ("Called.\n"));
493 
495 }
VOID NTAPI ExGetCurrentProcessorCpuUsage(PULONG CpuUsage)
Definition: sysinfo.c:324
#define MAX_TRACE
Definition: debug.h:16
#define NDIS_DbgPrint(_t_, _x_)
Definition: debug.h:40

◆ NdisGetSharedDataAlignment()

ULONG EXPORT NdisGetSharedDataAlignment ( VOID  )

Definition at line 502 of file misc.c.

503 {
504  NDIS_DbgPrint(MAX_TRACE, ("Called.\n"));
505 
507 }
ULONG NTAPI KeGetRecommendedSharedDataAlignment(VOID)
Definition: cpu.c:471
#define MAX_TRACE
Definition: debug.h:16
#define NDIS_DbgPrint(_t_, _x_)
Definition: debug.h:40

◆ NdisGetSystemUpTime()

VOID EXPORT NdisGetSystemUpTime ( OUT PULONG  pSystemUpTime)

Definition at line 358 of file misc.c.

359 {
361  LARGE_INTEGER TickCount;
362 
363  NDIS_DbgPrint(MAX_TRACE, ("Called.\n"));
364 
365  /* Get the increment and current tick count */
367  KeQueryTickCount(&TickCount);
368 
369  /* Convert to milliseconds and return */
370  TickCount.QuadPart *= Increment;
371  TickCount.QuadPart /= (10 * 1000);
372  *pSystemUpTime = TickCount.LowPart;
373 }
ULONG NTAPI KeQueryTimeIncrement(VOID)
Definition: clock.c:153
VOID NTAPI KeQueryTickCount(IN PLARGE_INTEGER TickCount)
Definition: clock.c:165
ULONG LowPart
Definition: typedefs.h:104
#define MAX_TRACE
Definition: debug.h:16
#define NDIS_DbgPrint(_t_, _x_)
Definition: debug.h:40
unsigned int ULONG
Definition: retypes.h:1
IN OUT PLONG IN OUT PLONG Addend IN OUT PLONG IN LONG Increment
Definition: CrNtStubs.h:42
LONGLONG QuadPart
Definition: typedefs.h:112

◆ NdisGetVersion()

UINT EXPORT NdisGetVersion ( VOID  )

Definition at line 514 of file misc.c.

515 {
516  NDIS_DbgPrint(MAX_TRACE, ("Called.\n"));
517 
518  return NDIS_VERSION;
519 }
#define NDIS_VERSION
Definition: ndissys.h:27
#define MAX_TRACE
Definition: debug.h:16
#define NDIS_DbgPrint(_t_, _x_)
Definition: debug.h:40

◆ NdisInterlockedAddLargeInteger()

VOID EXPORT NdisInterlockedAddLargeInteger ( IN PLARGE_INTEGER  Addend,
IN LARGE_INTEGER  Increment,
IN PNDIS_SPIN_LOCK  SpinLock 
)

Definition at line 30 of file misc.c.

34 {
35  /* This needs to be verified. The documentation
36  * seems to be missing but it is exported by
37  * NDIS 5.1 so I'm implementing it like the other
38  * interlocked routines
39  */
40 
42 }
IN OUT PLONG Addend
Definition: CrNtStubs.h:22
_In_ PKSERVICE_ROUTINE _In_opt_ PVOID _In_opt_ PKSPIN_LOCK SpinLock
Definition: iofuncs.h:798
LARGE_INTEGER NTAPI ExInterlockedAddLargeInteger(IN OUT PLARGE_INTEGER Addend, IN LARGE_INTEGER Increment, IN OUT PKSPIN_LOCK Lock)
Definition: interlocked.c:62
IN OUT PLONG IN OUT PLONG Addend IN OUT PLONG IN LONG Increment
Definition: CrNtStubs.h:42

◆ NdisInterlockedAddUlong()

VOID EXPORT NdisInterlockedAddUlong ( IN PULONG  Addend,
IN ULONG  Increment,
IN PNDIS_SPIN_LOCK  SpinLock 
)

Definition at line 17 of file misc.c.

21 {
23 }
IN OUT PLONG Addend
Definition: CrNtStubs.h:22
_In_ PKSERVICE_ROUTINE _In_opt_ PVOID _In_opt_ PKSPIN_LOCK SpinLock
Definition: iofuncs.h:798
ULONG NTAPI ExInterlockedAddUlong(IN OUT PULONG Addend, IN ULONG Increment, IN OUT PKSPIN_LOCK Lock)
Definition: interlocked.c:88
IN OUT PLONG IN OUT PLONG Addend IN OUT PLONG IN LONG Increment
Definition: CrNtStubs.h:42

◆ NdisInterlockedDecrement()

LONG EXPORT NdisInterlockedDecrement ( IN PLONG  Addend)

Definition at line 381 of file misc.c.

389 {
390  return InterlockedDecrement ( Addend );
391 }
IN OUT PLONG Addend
Definition: CrNtStubs.h:22
#define InterlockedDecrement
Definition: armddk.h:52

◆ NdisInterlockedIncrement()

LONG EXPORT NdisInterlockedIncrement ( IN PLONG  Addend)

Definition at line 400 of file misc.c.

408 {
409  return InterlockedIncrement ( Addend );
410 }
IN OUT PLONG Addend
Definition: CrNtStubs.h:22
#define InterlockedIncrement
Definition: armddk.h:53

◆ NdisInterlockedInsertHeadList()

PLIST_ENTRY EXPORT NdisInterlockedInsertHeadList ( IN PLIST_ENTRY  ListHead,
IN PLIST_ENTRY  ListEntry,
IN PNDIS_SPIN_LOCK  SpinLock 
)

Definition at line 84 of file misc.c.

88 {
89  return ExInterlockedInsertHeadList ( ListHead, ListEntry, &SpinLock->SpinLock );
90 }
_In_ PKSERVICE_ROUTINE _In_opt_ PVOID _In_opt_ PKSPIN_LOCK SpinLock
Definition: iofuncs.h:798
PLIST_ENTRY NTAPI ExInterlockedInsertHeadList(IN OUT PLIST_ENTRY ListHead, IN OUT PLIST_ENTRY ListEntry, IN OUT PKSPIN_LOCK Lock)
Definition: interlocked.c:114

◆ NdisInterlockedInsertTailList()

PLIST_ENTRY EXPORT NdisInterlockedInsertTailList ( IN PLIST_ENTRY  ListHead,
IN PLIST_ENTRY  ListEntry,
IN PNDIS_SPIN_LOCK  SpinLock 
)

Definition at line 98 of file misc.c.

102 {
103  return ExInterlockedInsertTailList ( ListHead, ListEntry, &SpinLock->SpinLock );
104 }
PLIST_ENTRY NTAPI ExInterlockedInsertTailList(IN OUT PLIST_ENTRY ListHead, IN OUT PLIST_ENTRY ListEntry, IN OUT PKSPIN_LOCK Lock)
Definition: interlocked.c:140
_In_ PKSERVICE_ROUTINE _In_opt_ PVOID _In_opt_ PKSPIN_LOCK SpinLock
Definition: iofuncs.h:798

◆ NdisInterlockedPopEntrySList()

PSINGLE_LIST_ENTRY EXPORT NdisInterlockedPopEntrySList ( IN PSLIST_HEADER  ListHead,
IN PKSPIN_LOCK  Lock 
)

Definition at line 419 of file misc.c.

428 {
429  return (PSINGLE_LIST_ENTRY)ExInterlockedPopEntrySList ( ListHead, Lock );
430 }
Definition: ntbasedef.h:635
struct _SINGLE_LIST_ENTRY *__fastcall ExInterlockedPopEntrySList(union _SLIST_HEADER *, unsigned long *)
IN OUT PLONG IN OUT PLONG Addend IN OUT PLONG IN LONG IN OUT PLONG IN LONG Increment IN PNDIS_RW_LOCK Lock
Definition: CrNtStubs.h:75

◆ NdisInterlockedPushEntrySList()

PSINGLE_LIST_ENTRY EXPORT NdisInterlockedPushEntrySList ( IN PSLIST_HEADER  ListHead,
IN PSINGLE_LIST_ENTRY  ListEntry,
IN PKSPIN_LOCK  Lock 
)

Definition at line 439 of file misc.c.

449 {
450  return (PSINGLE_LIST_ENTRY)ExInterlockedPushEntrySList ( ListHead, (PSLIST_ENTRY)ListEntry, Lock );
451 }
Definition: ntbasedef.h:635
struct _SINGLE_LIST_ENTRY *__fastcall ExInterlockedPushEntrySList(union _SLIST_HEADER *, struct _SINGLE_LIST_ENTRY *, unsigned long *)
#define PSLIST_ENTRY
Definition: rtltypes.h:130
IN OUT PLONG IN OUT PLONG Addend IN OUT PLONG IN LONG IN OUT PLONG IN LONG Increment IN PNDIS_RW_LOCK Lock
Definition: CrNtStubs.h:75

◆ NdisInterlockedRemoveHeadList()

PLIST_ENTRY EXPORT NdisInterlockedRemoveHeadList ( IN PLIST_ENTRY  ListHead,
IN PNDIS_SPIN_LOCK  SpinLock 
)

Definition at line 113 of file misc.c.

116 {
117  return ExInterlockedRemoveHeadList ( ListHead, &SpinLock->SpinLock );
118 }
_In_ PKSERVICE_ROUTINE _In_opt_ PVOID _In_opt_ PKSPIN_LOCK SpinLock
Definition: iofuncs.h:798
PLIST_ENTRY NTAPI ExInterlockedRemoveHeadList(IN OUT PLIST_ENTRY ListHead, IN OUT PKSPIN_LOCK Lock)
Definition: interlocked.c:166

◆ NdisMapFile()

VOID EXPORT NdisMapFile ( OUT PNDIS_STATUS  Status,
OUT PVOID MappedBuffer,
IN NDIS_HANDLE  FileHandle 
)

Definition at line 149 of file misc.c.

153 {
155 
156  NDIS_DbgPrint(MAX_TRACE, ("called: FileHandle 0x%x\n", FileHandle));
157 
158  if (HandleObject->Mapped)
159  {
160  /* If a file already mapped we will return an error code */
161  NDIS_DbgPrint(MIN_TRACE, ("File already mapped\n"));
163  return;
164  }
165 
166  HandleObject->Mapped = TRUE;
167  *MappedBuffer = HandleObject->MapBuffer;
168 
169  /* Set returned status */
171 }
PVOID MapBuffer
Definition: misc.c:125
#define TRUE
Definition: types.h:120
struct _NDIS_HANDLE_OBJECT * PNDIS_HANDLE_OBJECT
HANDLE FileHandle
Definition: stats.c:38
_Out_ PVOID * MappedBuffer
Definition: ndis.h:3245
#define NDIS_STATUS_ALREADY_MAPPED
Definition: ndis.h:494
Status
Definition: gdiplustypes.h:24
#define MAX_TRACE
Definition: debug.h:16
BOOLEAN Mapped
Definition: misc.c:123
#define NDIS_DbgPrint(_t_, _x_)
Definition: debug.h:40
#define MIN_TRACE
Definition: debug.h:14
return STATUS_SUCCESS
Definition: btrfs.c:2966

◆ NdisOpenFile()

VOID EXPORT NdisOpenFile ( OUT PNDIS_STATUS  Status,
OUT PNDIS_HANDLE  FileHandle,
OUT PUINT  FileLength,
IN PNDIS_STRING  FileName,
IN NDIS_PHYSICAL_ADDRESS  HighestAcceptableAddress 
)

Definition at line 224 of file misc.c.

230 {
231  NDIS_STRING FullFileName;
233  PNDIS_HANDLE_OBJECT FileHandleObject = NULL;
235 
237 
238  NDIS_DbgPrint(MAX_TRACE, ("Called.\n"));
239 
240  ASSERT ( Status && FileName );
241 
243  FullFileName.Buffer = NULL;
244 
245  FullFileName.Length = sizeof(NDIS_FILE_FOLDER) - sizeof(UNICODE_NULL);
246  FullFileName.MaximumLength = FileName->MaximumLength + FullFileName.Length;
247  FullFileName.Buffer = ExAllocatePool ( NonPagedPool, FullFileName.MaximumLength );
248 
249  if ( !FullFileName.Buffer )
250  {
251  NDIS_DbgPrint(MIN_TRACE, ("Insufficient resources\n"));
253  goto cleanup;
254  }
255 
256  FileHandleObject = ExAllocatePool ( NonPagedPool, sizeof(NDIS_HANDLE_OBJECT) );
257  if ( !FileHandleObject )
258  {
259  NDIS_DbgPrint(MIN_TRACE, ("Insufficient resources\n"));
261  goto cleanup;
262  }
263  memset ( FileHandleObject, 0, sizeof(NDIS_HANDLE_OBJECT) );
264 
265  memmove ( FullFileName.Buffer, NDIS_FILE_FOLDER, FullFileName.Length );
266  *Status = RtlAppendUnicodeStringToString ( &FullFileName, FileName );
267  if ( !NT_SUCCESS(*Status) )
268  {
269  NDIS_DbgPrint(MIN_TRACE, ("RtlAppendUnicodeStringToString failed (%x)\n", *Status));
271  goto cleanup;
272  }
273 
275  &FullFileName,
277  NULL,
278  NULL );
279 
280  *Status = ZwCreateFile (
281  &FileHandleObject->FileHandle,
284  &IoStatusBlock,
285  NULL, // PLARGE_INTEGER AllocationSize
286  0, // ULONG FileAttributes
287  FILE_SHARE_READ, // ULONG ShareAccess
288  FILE_OPEN, // ULONG CreateDisposition
289  FILE_SYNCHRONOUS_IO_NONALERT, // ULONG CreateOptions
290  0, // PVOID EaBuffer
291  0 ); // ULONG EaLength
292 
293  if ( !NT_SUCCESS(*Status) )
294  {
295  NDIS_DbgPrint(MIN_TRACE, ("ZwCreateFile failed (%x) Name %wZ\n", *Status, FileName));
297  }
298 
299 cleanup:
300  if ( FullFileName.Buffer != NULL )
301  {
302  ExFreePool ( FullFileName.Buffer );
303  FullFileName.Buffer = NULL;
304  }
305  if ( !NT_SUCCESS(*Status) )
306  {
307  if( FileHandleObject ) {
308  ExFreePool ( FileHandleObject );
309  FileHandleObject = NULL;
310  }
311  *FileHandle = NULL;
312  }
313  else
314  *FileHandle = NDIS_POBJECT_TO_HANDLE(FileHandleObject);
315 
316  return;
317 }
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:35
#define memmove(s1, s2, n)
Definition: mkisofs.h:881
USHORT MaximumLength
Definition: env_spec_w32.h:370
#define FILE_SHARE_READ
Definition: compat.h:125
HANDLE FileHandle
Definition: stats.c:38
#define UNICODE_NULL
#define FILE_READ_DATA
Definition: nt_native.h:628
smooth NULL
Definition: ftsmooth.c:416
HANDLE FileHandle
Definition: misc.c:122
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define NDIS_STATUS_SUCCESS
Definition: ndis.h:346
#define ExAllocatePool(type, size)
Definition: fbtusb.h:44
#define SYNCHRONIZE
Definition: nt_native.h:61
#define PASSIVE_LEVEL
Definition: env_spec_w32.h:693
Status
Definition: gdiplustypes.h:24
#define FILE_OPEN
Definition: from_kernel.h:54
#define MAX_TRACE
Definition: debug.h:16
NTSYSAPI NTSTATUS NTAPI RtlAppendUnicodeStringToString(PUNICODE_STRING Destination, PUNICODE_STRING Source)
static OUT PIO_STATUS_BLOCK IoStatusBlock
Definition: pipe.c:75
#define NDIS_DbgPrint(_t_, _x_)
Definition: debug.h:40
static const WCHAR NDIS_FILE_FOLDER[]
Definition: misc.c:142
#define FILE_SYNCHRONOUS_IO_NONALERT
Definition: from_kernel.h:31
#define NDIS_STATUS_RESOURCES
Definition: ndis.h:466
#define ASSERT_IRQL(x)
Definition: debug.h:42
#define MIN_TRACE
Definition: debug.h:14
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
char * cleanup(char *str)
Definition: wpickclick.c:99
#define memset(x, y, z)
Definition: compat.h:39
#define OBJ_KERNEL_HANDLE
Definition: winternl.h:231
#define NDIS_STATUS_FAILURE
Definition: ndis.h:465
#define ExFreePool(addr)
Definition: env_spec_w32.h:352
__inline NDIS_HANDLE NDIS_POBJECT_TO_HANDLE(PNDIS_HANDLE_OBJECT obj)
Definition: misc.c:137

◆ ndisProcWorkItemHandler()

VOID NTAPI ndisProcWorkItemHandler ( PVOID  pContext)

Definition at line 456 of file misc.c.

457 {
458  PNDIS_WORK_ITEM pNdisItem = (PNDIS_WORK_ITEM)pContext;
459 
460  NDIS_DbgPrint(MAX_TRACE, ("Called.\n"));
461 
462  pNdisItem->Routine(pNdisItem, pNdisItem->Context);
463 }
PVOID Context
Definition: ndis.h:2318
NDIS_PROC Routine
Definition: ndis.h:2319
#define MAX_TRACE
Definition: debug.h:16
struct _NDIS_WORK_ITEM * PNDIS_WORK_ITEM
#define NDIS_DbgPrint(_t_, _x_)
Definition: debug.h:40

Referenced by NdisScheduleWorkItem().

◆ NdisScheduleWorkItem()

NDIS_STATUS EXPORT NdisScheduleWorkItem ( IN PNDIS_WORK_ITEM  pWorkItem)

Definition at line 467 of file misc.c.

469 {
470  PWORK_QUEUE_ITEM pntWorkItem = (PWORK_QUEUE_ITEM)pWorkItem->WrapperReserved;
471 
472  NDIS_DbgPrint(MAX_TRACE, ("Called.\n"));
473 
474  ExInitializeWorkItem(pntWorkItem, ndisProcWorkItemHandler, pWorkItem);
475  ExQueueWorkItem(pntWorkItem, DelayedWorkQueue);
476  return NDIS_STATUS_SUCCESS;
477 }
VOID NTAPI ExQueueWorkItem(IN PWORK_QUEUE_ITEM WorkItem, IN WORK_QUEUE_TYPE QueueType)
Definition: work.c:717
VOID NTAPI ndisProcWorkItemHandler(PVOID pContext)
Definition: misc.c:456
#define ExInitializeWorkItem(Item, Routine, Context)
Definition: exfuncs.h:265
#define NDIS_STATUS_SUCCESS
Definition: ndis.h:346
#define MAX_TRACE
Definition: debug.h:16
struct _WORK_QUEUE_ITEM * PWORK_QUEUE_ITEM
#define NDIS_DbgPrint(_t_, _x_)
Definition: debug.h:40

◆ NdisSystemProcessorCount()

CCHAR EXPORT NdisSystemProcessorCount ( VOID  )

Definition at line 324 of file misc.c.

326 {
327  return KeNumberProcessors;
328 }
CCHAR KeNumberProcessors
Definition: krnlinit.c:35

◆ NdisUnmapFile()

VOID EXPORT NdisUnmapFile ( IN NDIS_HANDLE  FileHandle)

Definition at line 178 of file misc.c.

180 {
182 
183  NDIS_DbgPrint(MAX_TRACE, ("Called.\n"));
184 
185  HandleObject->Mapped = FALSE;
186 }
struct _NDIS_HANDLE_OBJECT * PNDIS_HANDLE_OBJECT
HANDLE FileHandle
Definition: stats.c:38
#define MAX_TRACE
Definition: debug.h:16
BOOLEAN Mapped
Definition: misc.c:123
#define NDIS_DbgPrint(_t_, _x_)
Definition: debug.h:40

Referenced by NdisCloseFile().

Variable Documentation

◆ CancelId

LONG CancelId

◆ NDIS_FILE_FOLDER

const WCHAR NDIS_FILE_FOLDER[] = L"\\SystemRoot\\System32\\Drivers\\"
static

Definition at line 142 of file misc.c.

Referenced by NdisOpenFile().