ReactOS 0.4.16-dev-1520-gb558596
kmtest_drv.c File Reference
#include <ntddk.h>
#include <ntifs.h>
#include <ndk/ketypes.h>
#include <ntstrsafe.h>
#include <limits.h>
#include <pseh/pseh2.h>
#include <debug.h>
#include <kmt_public.h>
#include <kmt_test.h>
Include dependency graph for kmtest_drv.c:

Go to the source code of this file.

Classes

struct  _KMT_USER_WORK_ENTRY
 
struct  _KMT_USER_WORK_LIST
 

Macros

#define NDEBUG
 
#define KMT_DEFINE_TEST_FUNCTIONS
 

Typedefs

typedef struct _KMT_USER_WORK_ENTRY KMT_USER_WORK_ENTRY
 
typedef struct _KMT_USER_WORK_ENTRYPKMT_USER_WORK_ENTRY
 
typedef struct _KMT_USER_WORK_LIST KMT_USER_WORK_LIST
 
typedef struct _KMT_USER_WORK_LISTPKMT_USER_WORK_LIST
 

Functions

BOOLEAN KmtDetectVirtualMachine (VOID)
 
DriverUnload

Driver cleanup funtion.

Parameters
DriverObjectDriver Object
static VOID NTAPI DriverUnload (IN PDRIVER_OBJECT DriverObject)
 
DriverCreate

Driver Dispatch function for IRP_MJ_CREATE

Parameters
DeviceObjectDevice Object
IrpI/O request packet
Returns
Status
static NTSTATUS NTAPI DriverCreate (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
DriverCleanup

Driver Dispatch function for IRP_MJ_CLEANUP

Parameters
DeviceObjectDevice Object
IrpI/O request packet
Returns
Status
static NTSTATUS NTAPI DriverCleanup (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
DriverClose

Driver Dispatch function for IRP_MJ_CLOSE

Parameters
DeviceObjectDevice Object
IrpI/O request packet
Returns
Status
static NTSTATUS NTAPI DriverClose (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
DriverIoControl

Driver Dispatch function for IRP_MJ_DEVICE_CONTROL

Parameters
DeviceObjectDevice Object
IrpI/O request packet
Returns
Status
static NTSTATUS NTAPI DriverIoControl (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
KmtUserModeCallback

Enqueue a request to the usermode callback queue and blocks until the work is finished.

Parameters
OperationTODO
ParametersTODO TODO: why is this PVOID?
Returns
Response from user mode
PKMT_RESPONSE KmtUserModeCallback (IN KMT_CALLBACK_INFORMATION_CLASS Operation, IN PVOID Parameters)
 
KmtFreeCallbackResponse

TODO

Parameters
ResponseTODO
VOID KmtFreeCallbackResponse (PKMT_RESPONSE Response)
 
KmtCleanUsermodeCallbacks

TODO

static VOID KmtCleanUsermodeCallbacks (VOID)
 

Variables

DRIVER_INITIALIZE DriverEntry
 
static DRIVER_UNLOAD DriverUnload
 

Macro Definition Documentation

◆ KMT_DEFINE_TEST_FUNCTIONS

#define KMT_DEFINE_TEST_FUNCTIONS

Definition at line 20 of file kmtest_drv.c.

◆ NDEBUG

#define NDEBUG

Definition at line 16 of file kmtest_drv.c.

Typedef Documentation

◆ KMT_USER_WORK_ENTRY

◆ KMT_USER_WORK_LIST

◆ PKMT_USER_WORK_ENTRY

◆ PKMT_USER_WORK_LIST

Function Documentation

◆ DriverCleanup()

static NTSTATUS NTAPI DriverCleanup ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp 
)
static

Definition at line 223 of file kmtest_drv.c.

226{
228 PIO_STACK_LOCATION IoStackLocation;
229 PKMT_DEVICE_EXTENSION DeviceExtension;
230
231 PAGED_CODE();
232
233 IoStackLocation = IoGetCurrentIrpStackLocation(Irp);
234
235 DPRINT("DriverCleanup. DeviceObject=%p, RequestorMode=%d, FileObject=%p, FsContext=%p, FsContext2=%p\n",
236 DeviceObject, Irp->RequestorMode, IoStackLocation->FileObject,
237 IoStackLocation->FileObject->FsContext, IoStackLocation->FileObject->FsContext2);
238
239 ASSERT(IoStackLocation->FileObject->FsContext2 == NULL);
240 DeviceExtension = DeviceObject->DeviceExtension;
241 if (DeviceExtension->Mdl && IoStackLocation->FileObject->FsContext == DeviceExtension->Mdl)
242 {
243 MmUnlockPages(DeviceExtension->Mdl);
244 IoFreeMdl(DeviceExtension->Mdl);
245 DeviceExtension->Mdl = NULL;
246 ResultBuffer = DeviceExtension->ResultBuffer = NULL;
247 }
248 else
249 {
250 ASSERT(IoStackLocation->FileObject->FsContext == NULL);
251 }
252
253 Irp->IoStatus.Status = Status;
254 Irp->IoStatus.Information = 0;
255
257
258 return Status;
259}
static PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(PIRP Irp)
#define PAGED_CODE()
LONG NTSTATUS
Definition: precomp.h:26
_In_ PIRP Irp
Definition: csq.h:116
#define NULL
Definition: types.h:112
#define IoFreeMdl
Definition: fxmdl.h:89
Status
Definition: gdiplustypes.h:25
PKMT_RESULTBUFFER ResultBuffer
VOID NTAPI MmUnlockPages(IN PMDL Mdl)
Definition: mdlsup.c:1435
#define ASSERT(a)
Definition: mode.c:44
#define IoCompleteRequest
Definition: irp.c:1240
#define STATUS_SUCCESS
Definition: shellext.h:65
#define DPRINT
Definition: sndvol32.h:73
PFILE_OBJECT FileObject
Definition: iotypes.h:3169
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
#define IO_NO_INCREMENT
Definition: iotypes.h:598

◆ DriverClose()

static NTSTATUS NTAPI DriverClose ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp 
)
static

Definition at line 276 of file kmtest_drv.c.

279{
281
282 PAGED_CODE();
283
284 DPRINT("DriverClose. DeviceObject=%p, RequestorMode=%d\n",
285 DeviceObject, Irp->RequestorMode);
286
287 Irp->IoStatus.Status = Status;
288 Irp->IoStatus.Information = 0;
289
291
292 return Status;
293}

◆ DriverCreate()

static NTSTATUS NTAPI DriverCreate ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp 
)
static

Definition at line 185 of file kmtest_drv.c.

188{
190 PIO_STACK_LOCATION IoStackLocation;
191
192 PAGED_CODE();
193
194 IoStackLocation = IoGetCurrentIrpStackLocation(Irp);
195
196 DPRINT("DriverCreate. DeviceObject=%p, RequestorMode=%d, FileObject=%p, FsContext=%p, FsContext2=%p\n",
197 DeviceObject, Irp->RequestorMode, IoStackLocation->FileObject,
198 IoStackLocation->FileObject->FsContext, IoStackLocation->FileObject->FsContext2);
199
200 Irp->IoStatus.Status = Status;
201 Irp->IoStatus.Information = 0;
202
204
205 return Status;
206}

◆ DriverIoControl()

static NTSTATUS NTAPI DriverIoControl ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp 
)
static

Definition at line 310 of file kmtest_drv.c.

313{
315 PIO_STACK_LOCATION IoStackLocation;
316 SIZE_T Length = 0;
317
318 PAGED_CODE();
319
320 IoStackLocation = IoGetCurrentIrpStackLocation(Irp);
321
322 DPRINT("DriverIoControl. Code=0x%08X, DeviceObject=%p, FileObject=%p, FsContext=%p, FsContext2=%p\n",
323 IoStackLocation->Parameters.DeviceIoControl.IoControlCode,
324 DeviceObject, IoStackLocation->FileObject,
325 IoStackLocation->FileObject->FsContext, IoStackLocation->FileObject->FsContext2);
326
327 switch (IoStackLocation->Parameters.DeviceIoControl.IoControlCode)
328 {
330 {
332 LPSTR OutputBuffer = Irp->AssociatedIrp.SystemBuffer;
333 size_t Remaining = IoStackLocation->Parameters.DeviceIoControl.OutputBufferLength;
334
335 DPRINT("DriverIoControl. IOCTL_KMTEST_GET_TESTS, outlen=%lu\n",
336 IoStackLocation->Parameters.DeviceIoControl.OutputBufferLength);
337
338 for (TestEntry = TestList; TestEntry->TestName; ++TestEntry)
339 {
340 RtlStringCbCopyExA(OutputBuffer, Remaining, TestEntry->TestName, &OutputBuffer, &Remaining, 0);
341 if (Remaining)
342 {
343 *OutputBuffer++ = '\0';
344 --Remaining;
345 }
346 }
347 if (Remaining)
348 {
349 *OutputBuffer++ = '\0';
350 --Remaining;
351 }
352 Length = IoStackLocation->Parameters.DeviceIoControl.OutputBufferLength - Remaining;
353 break;
354 }
356 {
359
360 DPRINT("DriverIoControl. IOCTL_KMTEST_RUN_TEST, inlen=%lu, outlen=%lu\n",
361 IoStackLocation->Parameters.DeviceIoControl.InputBufferLength,
362 IoStackLocation->Parameters.DeviceIoControl.OutputBufferLength);
363 TestName.Length = TestName.MaximumLength = (USHORT)min(IoStackLocation->Parameters.DeviceIoControl.InputBufferLength, USHRT_MAX);
364 TestName.Buffer = Irp->AssociatedIrp.SystemBuffer;
365 DPRINT("DriverIoControl. Run test: %Z\n", &TestName);
366
367 for (TestEntry = TestList; TestEntry->TestName; ++TestEntry)
368 {
369 ANSI_STRING EntryName;
370 if (TestEntry->TestName[0] == '-')
371 RtlInitAnsiString(&EntryName, TestEntry->TestName + 1);
372 else
373 RtlInitAnsiString(&EntryName, TestEntry->TestName);
374
375 if (!RtlCompareString(&TestName, &EntryName, FALSE))
376 {
377 DPRINT1("DriverIoControl. Starting test %Z\n", &EntryName);
378 TestEntry->TestFunction();
379 DPRINT1("DriverIoControl. Finished test %Z\n", &EntryName);
380 break;
381 }
382 }
383
384 if (!TestEntry->TestName)
386
387 break;
388 }
390 {
391 PKMT_DEVICE_EXTENSION DeviceExtension = DeviceObject->DeviceExtension;
392
393 DPRINT("DriverIoControl. IOCTL_KMTEST_SET_RESULTBUFFER, buffer=%p, inlen=%lu, outlen=%lu\n",
394 IoStackLocation->Parameters.DeviceIoControl.Type3InputBuffer,
395 IoStackLocation->Parameters.DeviceIoControl.InputBufferLength,
396 IoStackLocation->Parameters.DeviceIoControl.OutputBufferLength);
397
398 if (DeviceExtension->Mdl)
399 {
400 if (IoStackLocation->FileObject->FsContext != DeviceExtension->Mdl)
401 {
403 break;
404 }
405 MmUnlockPages(DeviceExtension->Mdl);
406 IoFreeMdl(DeviceExtension->Mdl);
407 IoStackLocation->FileObject->FsContext = NULL;
408 ResultBuffer = DeviceExtension->ResultBuffer = NULL;
409 }
410
411 DeviceExtension->Mdl = IoAllocateMdl(IoStackLocation->Parameters.DeviceIoControl.Type3InputBuffer,
412 IoStackLocation->Parameters.DeviceIoControl.InputBufferLength,
413 FALSE, FALSE, NULL);
414 if (!DeviceExtension->Mdl)
415 {
417 break;
418 }
419
421 {
422 MmProbeAndLockPages(DeviceExtension->Mdl, UserMode, IoModifyAccess);
423 }
425 {
427 IoFreeMdl(DeviceExtension->Mdl);
428 DeviceExtension->Mdl = NULL;
429 break;
430 } _SEH2_END;
431
432 ResultBuffer = DeviceExtension->ResultBuffer = MmGetSystemAddressForMdlSafe(DeviceExtension->Mdl, NormalPagePriority);
433 IoStackLocation->FileObject->FsContext = DeviceExtension->Mdl;
434
435 DPRINT("DriverIoControl. ResultBuffer: %ld %ld %ld %ld\n",
438 break;
439 }
441 {
445
446 DPRINT("DriverIoControl. IOCTL_KMTEST_USERMODE_AWAIT_REQ, len=%lu\n",
447 IoStackLocation->Parameters.DeviceIoControl.OutputBufferLength);
448
449 /* TODO: prevent multiple concurrent invocations */
450 Timeout.QuadPart = TimeoutDuration;
451 Status = KeWaitForSingleObject(&WorkList.NewWorkEvent, UserRequest, UserMode, FALSE, &Timeout);
452
453 if (Status == STATUS_TIMEOUT)
454 DPRINT1("KeWaitForSingleObject timed out!\n");
455
457 break;
458
459 if (IoStackLocation->Parameters.DeviceIoControl.OutputBufferLength < sizeof(KMT_CALLBACK_REQUEST_PACKET))
460 {
462 break;
463 }
464
465 ASSERT(!IsListEmpty(&WorkList.ListHead));
466
467 Entry = WorkList.ListHead.Flink;
469
470 Length = sizeof(WorkItem->Request);
471 RtlCopyMemory(Irp->AssociatedIrp.SystemBuffer, &WorkItem->Request, Length);
473
474 KeClearEvent(&WorkList.NewWorkEvent);
475 break;
476
477 }
479 {
481 PKMT_USER_WORK_ENTRY WorkEntry;
483 ULONG ResponseSize = IoStackLocation->Parameters.DeviceIoControl.OutputBufferLength;
484
485 DPRINT("DriverIoControl. IOCTL_KMTEST_USERMODE_SEND_RESPONSE, inlen=%lu, outlen=%lu\n",
486 IoStackLocation->Parameters.DeviceIoControl.InputBufferLength,
487 IoStackLocation->Parameters.DeviceIoControl.OutputBufferLength);
488
489 if (IoStackLocation->Parameters.DeviceIoControl.InputBufferLength != sizeof(ULONG) || ResponseSize != sizeof(KMT_RESPONSE))
490 {
492 break;
493 }
494
495 /* FIXME: don't misuse the output buffer as an input! */
497 if (Response == NULL)
498 {
500 break;
501 }
502
503 ExAcquireFastMutex(&WorkList.Lock);
504
506
507 Entry = WorkList.ListHead.Flink;
508 while (Entry != &WorkList.ListHead)
509 {
510 WorkEntry = CONTAINING_RECORD(Entry, KMT_USER_WORK_ENTRY, ListEntry);
511 if (WorkEntry->Request.RequestId == *(PULONG)Irp->AssociatedIrp.SystemBuffer)
512 {
513 WorkEntry->Response = ExAllocatePoolWithTag(PagedPool, sizeof(KMT_RESPONSE), 'pseR');
514 if (WorkEntry->Response == NULL)
515 {
517 break;
518 }
519
520 RtlCopyMemory(WorkEntry->Response, Response, ResponseSize);
523 break;
524 }
525
526 Entry = Entry->Flink;
527 }
528
529 ExReleaseFastMutex(&WorkList.Lock);
530
531 break;
532 }
533 default:
534 DPRINT1("DriverIoControl. Invalid IoCtl code 0x%08X\n",
535 IoStackLocation->Parameters.DeviceIoControl.IoControlCode);
537 break;
538 }
539
540 Irp->IoStatus.Status = Status;
541 Irp->IoStatus.Information = Length;
542
544
545 return Status;
546}
#define DPRINT1
Definition: precomp.h:8
#define STATUS_TIMEOUT
Definition: d3dkmdt.h:49
#define FALSE
Definition: types.h:117
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
#define IsListEmpty(ListHead)
Definition: env_spec_w32.h:954
#define KeWaitForSingleObject(pEvt, foo, a, b, c)
Definition: env_spec_w32.h:478
#define KeSetEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:476
#define PagedPool
Definition: env_spec_w32.h:308
VOID NTAPI KeClearEvent(IN PKEVENT Event)
Definition: eventobj.c:22
#define IoAllocateMdl
Definition: fxmdl.h:88
VOID FASTCALL ExAcquireFastMutex(IN PFAST_MUTEX FastMutex)
Definition: fmutex.c:23
VOID FASTCALL ExReleaseFastMutex(IN PFAST_MUTEX FastMutex)
Definition: fmutex.c:31
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:90
#define USHRT_MAX
Definition: limits.h:38
#define IOCTL_KMTEST_GET_TESTS
Definition: kmt_public.h:13
#define IOCTL_KMTEST_USERMODE_AWAIT_REQ
Definition: kmt_public.h:25
#define IOCTL_KMTEST_USERMODE_SEND_RESPONSE
Definition: kmt_public.h:22
#define IOCTL_KMTEST_RUN_TEST
Definition: kmt_public.h:16
#define IOCTL_KMTEST_SET_RESULTBUFFER
Definition: kmt_public.h:19
VOID NTAPI MmProbeAndLockPages(IN PMDL Mdl, IN KPROCESSOR_MODE AccessMode, IN LOCK_OPERATION Operation)
Definition: mdlsup.c:931
@ NormalPagePriority
Definition: imports.h:54
static void TestEntry(const ENTRY *pEntry)
WCHAR TestName[MAX_PATH]
Definition: main.cpp:13
#define min(a, b)
Definition: monoChain.cc:55
#define UserMode
Definition: asm.h:39
NTSYSAPI LONG NTAPI RtlCompareString(PSTRING String1, PSTRING String2, BOOLEAN CaseInSensitive)
NTSYSAPI VOID NTAPI RtlInitAnsiString(PANSI_STRING DestinationString, PCSZ SourceString)
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102
#define STATUS_OBJECTID_NOT_FOUND
Definition: ntstatus.h:860
#define STATUS_USER_APC
Definition: ntstatus.h:78
#define STATUS_INVALID_BUFFER_SIZE
Definition: ntstatus.h:650
#define STATUS_KERNEL_APC
Definition: ntstatus.h:79
NTSTRSAFEAPI RtlStringCbCopyExA(_Out_writes_bytes_(cbDest) _Always_(_Post_z_) NTSTRSAFE_PSTR pszDest, _In_ size_t cbDest, _In_ NTSTRSAFE_PCSTR pszSrc, _Outptr_opt_result_bytebuffer_(*pcbRemaining) STRSAFE_LPSTR *ppszDestEnd, _Out_opt_ size_t *pcbRemaining, _In_ STRSAFE_DWORD dwFlags)
Definition: ntstrsafe.h:270
unsigned short USHORT
Definition: pedump.c:61
static ULONG Timeout
Definition: ping.c:61
#define _SEH2_GetExceptionCode()
Definition: pseh2_64.h:181
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:82
#define _SEH2_END
Definition: pseh2_64.h:171
#define _SEH2_TRY
Definition: pseh2_64.h:71
base of all file and directory entries
Definition: entries.h:83
volatile LONG Failures
Definition: kmt_test.h:39
volatile LONG LogBufferLength
Definition: kmt_test.h:41
LONG LogBufferMaxLength
Definition: kmt_test.h:42
volatile LONG Successes
Definition: kmt_test.h:38
Definition: ncftp.h:89
struct _IO_STACK_LOCATION::@1701::@1702 DeviceIoControl
union _IO_STACK_LOCATION::@1701 Parameters
Definition: kmtest_drv.c:25
PKMT_RESPONSE Response
Definition: kmtest_drv.c:29
KMT_CALLBACK_REQUEST_PACKET Request
Definition: kmtest_drv.c:28
KEVENT WorkDoneEvent
Definition: kmtest_drv.c:27
Definition: typedefs.h:120
EH_STD::__list__< TestClass, eh_allocator(TestClass) > TestList
Definition: test_list.cpp:31
uint32_t * PULONG
Definition: typedefs.h:59
ULONG_PTR SIZE_T
Definition: typedefs.h:80
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260
uint32_t ULONG
Definition: typedefs.h:59
#define STATUS_INVALID_DEVICE_REQUEST
Definition: udferr_usr.h:138
#define STATUS_ACCESS_DENIED
Definition: udferr_usr.h:145
#define STATUS_OBJECT_NAME_INVALID
Definition: udferr_usr.h:148
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
_Must_inspect_result_ _In_ WDFIOTARGET _In_opt_ WDFREQUEST _In_opt_ PWDF_MEMORY_DESCRIPTOR OutputBuffer
Definition: wdfiotarget.h:863
_Must_inspect_result_ _In_ PWDF_WORKITEM_CONFIG _In_ PWDF_OBJECT_ATTRIBUTES _Out_ WDFWORKITEM * WorkItem
Definition: wdfworkitem.h:115
@ UserRequest
Definition: ketypes.h:421
@ IoModifyAccess
Definition: ketypes.h:865
#define MmGetSystemAddressForMdlSafe(_Mdl, _Priority)
char * LPSTR
Definition: xmlstorage.h:182

◆ DriverUnload()

static VOID NTAPI DriverUnload ( IN PDRIVER_OBJECT  DriverObject)
static

Definition at line 147 of file kmtest_drv.c.

149{
150 PAGED_CODE();
151
153
154 DPRINT("DriverUnload\n");
155
157
159 {
160#if DBG
161 PKMT_DEVICE_EXTENSION DeviceExtension = MainDeviceObject->DeviceExtension;
162 ASSERT(!DeviceExtension->Mdl);
163 ASSERT(!DeviceExtension->ResultBuffer);
164#endif
167 }
168}
static PDEVICE_OBJECT MainDeviceObject
static VOID KmtCleanUsermodeCallbacks(VOID)
Definition: kmtest_drv.c:633
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:329
VOID NTAPI IoDeleteDevice(IN PDEVICE_OBJECT DeviceObject)
Definition: device.c:1251
PVOID DeviceExtension
Definition: env_spec_w32.h:418
_Must_inspect_result_ _In_ PDRIVER_OBJECT DriverObject
Definition: wdfdriver.h:213

◆ KmtCleanUsermodeCallbacks()

static VOID KmtCleanUsermodeCallbacks ( VOID  )
static

Definition at line 633 of file kmtest_drv.c.

634{
636
637 PAGED_CODE();
638
639 ExAcquireFastMutex(&WorkList.Lock);
640
641 Entry = WorkList.ListHead.Flink;
642 while (Entry != &WorkList.ListHead)
643 {
645 if (WorkEntry->Response != NULL)
646 {
648 }
649
650 Entry = Entry->Flink;
651
652 ExFreePoolWithTag(WorkEntry, 'ekrW');
653 }
654
655 ExReleaseFastMutex(&WorkList.Lock);
656}
VOID KmtFreeCallbackResponse(PKMT_RESPONSE Response)
Definition: kmtest_drv.c:618
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1109

Referenced by DriverUnload().

◆ KmtDetectVirtualMachine()

BOOLEAN KmtDetectVirtualMachine ( VOID  )

Definition at line 54 of file vm_detect.c.

55{
56#if defined(_M_IX86) || defined(_M_AMD64)
57 return VmIsHypervisorPresent() || VmIsVbox() || VmIsVMware();
58#else
59 return FALSE;
60#endif
61}

◆ KmtFreeCallbackResponse()

VOID KmtFreeCallbackResponse ( PKMT_RESPONSE  Response)

Definition at line 618 of file kmtest_drv.c.

620{
621 PAGED_CODE();
622
624}

Referenced by KmtCleanUsermodeCallbacks().

◆ KmtUserModeCallback()

PKMT_RESPONSE KmtUserModeCallback ( IN KMT_CALLBACK_INFORMATION_CLASS  Operation,
IN PVOID  Parameters 
)

Definition at line 563 of file kmtest_drv.c.

566{
569 PKMT_USER_WORK_ENTRY WorkEntry;
571
572 PAGED_CODE();
573
574 WorkEntry = ExAllocatePoolWithTag(PagedPool, sizeof(KMT_USER_WORK_ENTRY), 'ekrW');
575 if (WorkEntry == NULL)
576 return NULL;
577
579 WorkEntry->Request.RequestId = RequestId++;
580 WorkEntry->Request.OperationClass = Operation;
581 WorkEntry->Request.Parameters = Parameters;
582 WorkEntry->Response = NULL;
583
584 ExAcquireFastMutex(&WorkList.Lock);
585 InsertTailList(&WorkList.ListHead, &WorkEntry->ListEntry);
586 ExReleaseFastMutex(&WorkList.Lock);
587
588 KeSetEvent(&WorkList.NewWorkEvent, IO_NO_INCREMENT, FALSE);
589
590 Timeout.QuadPart = TimeoutDuration;
592
594 {
595 DPRINT1("Unexpected callback abortion! Reason: %lx\n", Status);
596 }
597
598 ExAcquireFastMutex(&WorkList.Lock);
599 RemoveEntryList(&WorkEntry->ListEntry);
600 ExReleaseFastMutex(&WorkList.Lock);
601
602 Result = WorkEntry->Response;
603
604 ExFreePoolWithTag(WorkEntry, 'ekrW');
605
606 return Result;
607}
#define RemoveEntryList(Entry)
Definition: env_spec_w32.h:986
#define InsertTailList(ListHead, Entry)
#define KeInitializeEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:477
FP_OP Operation
Definition: fpcontrol.c:150
@ NotificationEvent
KMT_CALLBACK_INFORMATION_CLASS OperationClass
Definition: kmt_test.h:66
LIST_ENTRY ListEntry
Definition: kmtest_drv.c:26
_Must_inspect_result_ _In_ WDFQUEUE _In_opt_ WDFREQUEST _In_opt_ WDFFILEOBJECT _Inout_opt_ PWDF_REQUEST_PARAMETERS Parameters
Definition: wdfio.h:869
_At_(*)(_In_ PWSK_CLIENT Client, _In_opt_ PUNICODE_STRING NodeName, _In_opt_ PUNICODE_STRING ServiceName, _In_opt_ ULONG NameSpace, _In_opt_ GUID *Provider, _In_opt_ PADDRINFOEXW Hints, _Outptr_ PADDRINFOEXW *Result, _In_opt_ PEPROCESS OwningProcess, _In_opt_ PETHREAD OwningThread, _Inout_ PIRP Irp Result)(Mem)) NTSTATUS(WSKAPI *PFN_WSK_GET_ADDRESS_INFO
Definition: wsk.h:409
@ Executive
Definition: ketypes.h:415

Variable Documentation

◆ DriverEntry

DRIVER_INITIALIZE DriverEntry

Definition at line 44 of file kmtest_drv.c.

◆ DriverUnload

DRIVER_UNLOAD DriverUnload
static

Definition at line 45 of file kmtest_drv.c.