ReactOS 0.4.15-dev-7906-g1b85a5f
fltsupport.c File Reference
#include <kmt_test.h>
#include "kmtest.h"
#include <kmt_public.h>
#include <assert.h>
#include <debug.h>
Include dependency graph for fltsupport.c:

Go to the source code of this file.

Classes

struct  _KMTFLT_MESSAGE_HEADER
 

Macros

#define KMT_FLT_USER_MODE
 

Typedefs

typedef struct _KMTFLT_MESSAGE_HEADER KMTFLT_MESSAGE_HEADER
 
typedef struct _KMTFLT_MESSAGE_HEADERPKMTFLT_MESSAGE_HEADER
 

Functions

KmtCloseService

Close the specified driver service handle

Parameters
ServiceHandlePointer to a variable containing the service handle. Will be set to NULL on success
Returns
Win32 error code
DWORD KmtpCreateService (IN PCWSTR ServiceName, IN PCWSTR ServicePath, IN PCWSTR DisplayName OPTIONAL, IN DWORD ServiceType, OUT SC_HANDLE *ServiceHandle)
 
KmtFltAddAltitude

Sets up the mini-filter altitude data in the registry

Parameters
hPortThe altitude string to set
Returns
Win32 error code
DWORD EnablePrivilegeInCurrentProcess (_In_z_ LPWSTR lpPrivName, _In_ BOOL bEnable)
 
DWORD KmtFltAddAltitude (_In_z_ LPWSTR Altitude)
 
DWORD EnablePrivilege (_In_ HANDLE hToken, _In_z_ LPWSTR lpPrivName, _In_ BOOL bEnable)
 
KmtFltCreateService

Create the specified driver service and return a handle to it

Parameters
ServiceNameName of the service to create
ServicePathFile name of the driver, relative to the current directory
DisplayNameService display name
ServiceHandlePointer to a variable to receive the handle to the service
Returns
Win32 error code
DWORD KmtFltCreateService (_In_z_ PCWSTR ServiceName, _In_z_ PCWSTR DisplayName, _Out_ SC_HANDLE *ServiceHandle)
 
KmtFltDeleteService

Delete the specified filter driver

Parameters
ServiceNameIf *ServiceHandle is NULL, name of the service to delete
ServiceHandlePointer to a variable containing the service handle. Will be set to NULL on success
Returns
Win32 error code
DWORD KmtFltDeleteService (_In_opt_z_ PCWSTR ServiceName, _Inout_ SC_HANDLE *ServiceHandle)
 
KmtFltLoadDriver

Delete the specified filter driver

Returns
Win32 error code
DWORD KmtFltLoadDriver (_In_ BOOLEAN EnableDriverLoadPrivlege, _In_ BOOLEAN RestartIfRunning, _In_ BOOLEAN ConnectComms, _Out_ HANDLE *hPort)
 
KmtFltUnloadDriver

Unload the specified filter driver

Parameters
hPortHandle to the filter's comms port
DisonnectCommsTRUE to disconnect the comms connection before unloading
Returns
Win32 error code
DWORD KmtFltUnloadDriver (_In_ HANDLE *hPort, _In_ BOOLEAN DisonnectComms)
 
KmtFltConnectComms

Create a comms connection to the specified filter

Parameters
hPortHandle to the filter's comms port
Returns
Win32 error code
DWORD KmtFltConnectComms (_Out_ HANDLE *hPort)
 
KmtFltDisconnectComms

Disconenct from the comms port

Parameters
hPortHandle to the filter's comms port
Returns
Win32 error code
DWORD KmtFltDisconnectComms (_In_ HANDLE hPort)
 
KmtFltCloseService

Close the specified driver service handle

Parameters
ServiceHandlePointer to a variable containing the service handle. Will be set to NULL on success
Returns
Win32 error code
DWORD KmtFltCloseService (_Inout_ SC_HANDLE *ServiceHandle)
 
KmtFltRunKernelTest

Run the specified filter test part

Parameters
hPortHandle to the filter's comms port
TestNameName of the test to run
Returns
Win32 error code
DWORD KmtFltRunKernelTest (_In_ HANDLE hPort, _In_z_ PCSTR TestName)
 
KmtFltSendToDriver

Send an I/O control message with no arguments to the driver opened with KmtOpenDriver

Parameters
hPortHandle to the filter's comms port
MessageThe message to send to the filter
Returns
Win32 error code
DWORD KmtFltSendToDriver (_In_ HANDLE hPort, _In_ DWORD Message)
 
KmtFltSendStringToDriver

Send an I/O control message with a string argument to the driver opened with KmtOpenDriver

Parameters
hPortHandle to the filter's comms port
MessageThe message associated with the string
StringAn ANSI string to send to the filter
Returns
Win32 error code
DWORD KmtFltSendStringToDriver (_In_ HANDLE hPort, _In_ DWORD Message, _In_ PCSTR String)
 
KmtFltSendWStringToDriver

Send an I/O control message with a wide string argument to the driver opened with KmtOpenDriver

Parameters
hPortHandle to the filter's comms port
MessageThe message associated with the string
StringAn wide string to send to the filter
Returns
Win32 error code
DWORD KmtFltSendWStringToDriver (_In_ HANDLE hPort, _In_ DWORD Message, _In_ PCWSTR String)
 
KmtFltSendUlongToDriver

Send an I/O control message with an integer argument to the driver opened with KmtOpenDriver

Parameters
hPortHandle to the filter's comms port
MessageThe message associated with the value
ValueAn 32bit valueng to send to the filter
Returns
Win32 error code
DWORD KmtFltSendUlongToDriver (_In_ HANDLE hPort, _In_ DWORD Message, _In_ DWORD Value)
 
KmtSendBufferToDriver

Send an I/O control message with the specified arguments to the driver opened with KmtOpenDriver

Parameters
hPortHandle to the filter's comms port
MessageThe message associated with the value
InBufferPointer to a buffer to send to the filter
BufferSizeSize of the buffer pointed to by InBuffer
OutBufferPointer to a buffer to receive a response from the filter
OutBufferSizeSize of the buffer pointed to by OutBuffer
BytesReturnedNumber of bytes written in the reply buffer
Returns
Win32 error code
DWORD KmtFltSendBufferToDriver (_In_ HANDLE hPort, _In_ DWORD Message, _In_reads_bytes_(BufferSize) LPVOID InBuffer, _In_ DWORD BufferSize, _Out_writes_bytes_to_opt_(OutBufferSize, *BytesReturned) LPVOID OutBuffer, _In_ DWORD OutBufferSize, _Out_opt_ LPDWORD BytesReturned)
 

Variables

HANDLE KmtestHandle
 
static WCHAR TestServiceName [MAX_PATH]
 

Macro Definition Documentation

◆ KMT_FLT_USER_MODE

#define KMT_FLT_USER_MODE

Definition at line 10 of file fltsupport.c.

Typedef Documentation

◆ KMTFLT_MESSAGE_HEADER

◆ PKMTFLT_MESSAGE_HEADER

Function Documentation

◆ EnablePrivilege()

DWORD EnablePrivilege ( _In_ HANDLE  hToken,
_In_z_ LPWSTR  lpPrivName,
_In_ BOOL  bEnable 
)

Definition at line 532 of file fltsupport.c.

536{
538 LUID luid;
540 DWORD dwError = ERROR_SUCCESS;
541
542 /* Get the luid for this privilege */
543 if (!LookupPrivilegeValueW(NULL, lpPrivName, &luid))
544 return GetLastError();
545
546 /* Setup the struct with the priv info */
547 TokenPrivileges.PrivilegeCount = 1;
548 TokenPrivileges.Privileges[0].Luid = luid;
549 TokenPrivileges.Privileges[0].Attributes = bEnable ? SE_PRIVILEGE_ENABLED : 0;
550
551 /* Enable the privilege info in the token */
553 FALSE,
555 sizeof(TOKEN_PRIVILEGES),
556 NULL,
557 NULL);
558 if (bSuccess == FALSE) dwError = GetLastError();
559
560 /* return status */
561 return dwError;
562}
#define ERROR_SUCCESS
Definition: deptool.c:10
#define NULL
Definition: types.h:112
#define FALSE
Definition: types.h:117
BOOL WINAPI LookupPrivilegeValueW(LPCWSTR lpSystemName, LPCWSTR lpPrivilegeName, PLUID lpLuid)
Definition: misc.c:782
BOOL WINAPI AdjustTokenPrivileges(HANDLE TokenHandle, BOOL DisableAllPrivileges, PTOKEN_PRIVILEGES NewState, DWORD BufferLength, PTOKEN_PRIVILEGES PreviousState, PDWORD ReturnLength)
Definition: security.c:374
static BOOLEAN bSuccess
Definition: drive.cpp:433
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
_In_ BOOL bEnable
Definition: winddi.h:3426
@ TokenPrivileges
Definition: setypes.h:968
#define SE_PRIVILEGE_ENABLED
Definition: setypes.h:63

Referenced by EnablePrivilegeInCurrentProcess().

◆ EnablePrivilegeInCurrentProcess()

DWORD EnablePrivilegeInCurrentProcess ( _In_z_ LPWSTR  lpPrivName,
_In_ BOOL  bEnable 
)

Definition at line 564 of file fltsupport.c.

567{
568 HANDLE hToken;
570 DWORD dwError = ERROR_SUCCESS;
571
572 /* Get a handle to our token */
575 &hToken);
576 if (bSuccess == FALSE) return GetLastError();
577
578 /* Enable the privilege in the agent token */
579 dwError = EnablePrivilege(hToken, lpPrivName, bEnable);
580
581 /* We're done with this now */
582 CloseHandle(hToken);
583
584 /* return status */
585 return dwError;
586}
BOOL WINAPI OpenProcessToken(HANDLE ProcessHandle, DWORD DesiredAccess, PHANDLE TokenHandle)
Definition: security.c:294
#define CloseHandle
Definition: compat.h:739
#define GetCurrentProcess()
Definition: compat.h:759
DWORD EnablePrivilege(_In_ HANDLE hToken, _In_z_ LPWSTR lpPrivName, _In_ BOOL bEnable)
Definition: fltsupport.c:532
#define TOKEN_ADJUST_PRIVILEGES
Definition: setypes.h:930
#define TOKEN_QUERY
Definition: setypes.h:928

Referenced by KmtFltLoadDriver().

◆ KmtFltAddAltitude()

DWORD KmtFltAddAltitude ( _In_z_ LPWSTR  Altitude)

Definition at line 448 of file fltsupport.c.

450{
451 WCHAR DefaultInstance[128];
452 WCHAR KeyPath[256];
453 HKEY hKey = NULL;
454 HKEY hSubKey = NULL;
455 DWORD Zero = 0;
456 LONG Error;
457
458 StringCbCopyW(KeyPath, sizeof(KeyPath), L"SYSTEM\\CurrentControlSet\\Services\\");
459 StringCbCatW(KeyPath, sizeof(KeyPath), TestServiceName);
460 StringCbCatW(KeyPath, sizeof(KeyPath), L"\\Instances\\");
461
463 KeyPath,
464 0,
465 NULL,
468 NULL,
469 &hKey,
470 NULL);
471 if (Error != ERROR_SUCCESS)
472 {
473 return Error;
474 }
475
476 StringCbCopyW(DefaultInstance, sizeof(DefaultInstance), TestServiceName);
477 StringCbCatW(DefaultInstance, sizeof(DefaultInstance), L" Instance");
478
480 L"DefaultInstance",
481 0,
482 REG_SZ,
483 (LPBYTE)DefaultInstance,
484 (lstrlenW(DefaultInstance) + 1) * sizeof(WCHAR));
485 if (Error != ERROR_SUCCESS)
486 {
487 goto Quit;
488 }
489
490 Error = RegCreateKeyW(hKey, DefaultInstance, &hSubKey);
491 if (Error != ERROR_SUCCESS)
492 {
493 goto Quit;
494 }
495
496 Error = RegSetValueExW(hSubKey,
497 L"Altitude",
498 0,
499 REG_SZ,
501 (lstrlenW(Altitude) + 1) * sizeof(WCHAR));
502 if (Error != ERROR_SUCCESS)
503 {
504 goto Quit;
505 }
506
507 Error = RegSetValueExW(hSubKey,
508 L"Flags",
509 0,
510 REG_DWORD,
511 (LPBYTE)&Zero,
512 sizeof(DWORD));
513
514Quit:
515 if (hSubKey)
516 {
517 RegCloseKey(hSubKey);
518 }
519 if (hKey)
520 {
522 }
523
524 return Error;
525
526}
BOOL Error
Definition: chkdsk.c:66
#define RegCloseKey(hKey)
Definition: registry.h:49
LONG WINAPI RegSetValueExW(_In_ HKEY hKey, _In_ LPCWSTR lpValueName, _In_ DWORD Reserved, _In_ DWORD dwType, _In_ CONST BYTE *lpData, _In_ DWORD cbData)
Definition: reg.c:4882
LONG WINAPI RegCreateKeyW(HKEY hKey, LPCWSTR lpSubKey, PHKEY phkResult)
Definition: reg.c:1201
#define lstrlenW
Definition: compat.h:750
IN PVCB IN VBO IN ULONG OUT PBCB OUT PVOID IN BOOLEAN IN BOOLEAN Zero
Definition: fatprocs.h:418
_Must_inspect_result_ _Inout_ PFLT_VOLUME _In_ PCUNICODE_STRING Altitude
Definition: fltkernel.h:1173
static WCHAR TestServiceName[MAX_PATH]
Definition: fltsupport.c:42
FxAutoRegKey hKey
#define REG_SZ
Definition: layer.c:22
#define KEY_CREATE_SUB_KEY
Definition: nt_native.h:1018
#define REG_OPTION_NON_VOLATILE
Definition: nt_native.h:1057
#define KEY_SET_VALUE
Definition: nt_native.h:1017
#define L(x)
Definition: ntvdm.h:50
long LONG
Definition: pedump.c:60
#define REG_DWORD
Definition: sdbapi.c:596
STRSAFEAPI StringCbCopyW(STRSAFE_LPWSTR pszDest, size_t cbDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:166
STRSAFEAPI StringCbCatW(STRSAFE_LPWSTR pszDest, size_t cbDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:342
unsigned char * LPBYTE
Definition: typedefs.h:53
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12
#define RegCreateKeyEx
Definition: winreg.h:501
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by START_TEST().

◆ KmtFltCloseService()

DWORD KmtFltCloseService ( _Inout_ SC_HANDLE *  ServiceHandle)

Definition at line 242 of file fltsupport.c.

244{
245 return KmtCloseService(ServiceHandle);
246}
DWORD KmtCloseService(IN OUT SC_HANDLE *ServiceHandle)
Definition: service.c:392

◆ KmtFltConnectComms()

DWORD KmtFltConnectComms ( _Out_ HANDLE hPort)

Definition at line 207 of file fltsupport.c.

209{
210 return KmtFltConnect(TestServiceName, hPort);
211}
DWORD KmtFltConnect(_In_z_ PCWSTR ServiceName, _Out_ HANDLE *hPort)
Definition: filter.c:119

Referenced by KmtFltLoadDriver(), and START_TEST().

◆ KmtFltCreateService()

DWORD KmtFltCreateService ( _In_z_ PCWSTR  ServiceName,
_In_z_ PCWSTR  DisplayName,
_Out_ SC_HANDLE *  ServiceHandle 
)

Definition at line 63 of file fltsupport.c.

67{
68 WCHAR ServicePath[MAX_PATH];
69
70 StringCbCopyW(ServicePath, sizeof(ServicePath), ServiceName);
71 StringCbCatW(ServicePath, sizeof(ServicePath), L"_drv.sys");
72
75
77 ServicePath,
78 DisplayName,
80 ServiceHandle);
81}
static WCHAR ServiceName[]
Definition: browser.c:19
#define MAX_PATH
Definition: compat.h:34
DWORD KmtpCreateService(IN PCWSTR ServiceName, IN PCWSTR ServicePath, IN PCWSTR DisplayName OPTIONAL, IN DWORD ServiceType, OUT SC_HANDLE *ServiceHandle)
Definition: service.c:414
#define SERVICE_FILE_SYSTEM_DRIVER
Definition: cmtypes.h:954

Referenced by START_TEST().

◆ KmtFltDeleteService()

DWORD KmtFltDeleteService ( _In_opt_z_ PCWSTR  ServiceName,
_Inout_ SC_HANDLE *  ServiceHandle 
)

Definition at line 97 of file fltsupport.c.

100{
101 return KmtDeleteService(ServiceName, ServiceHandle);
102}
DWORD KmtDeleteService(IN PCWSTR ServiceName OPTIONAL, IN OUT SC_HANDLE *ServiceHandle)
Definition: service.c:356

Referenced by START_TEST().

◆ KmtFltDisconnectComms()

DWORD KmtFltDisconnectComms ( _In_ HANDLE  hPort)

Definition at line 224 of file fltsupport.c.

226{
227 return KmtFltDisconnect(hPort);
228}
DWORD KmtFltDisconnect(_In_ HANDLE hPort)
Definition: filter.c:151

Referenced by START_TEST().

◆ KmtFltLoadDriver()

DWORD KmtFltLoadDriver ( _In_ BOOLEAN  EnableDriverLoadPrivlege,
_In_ BOOLEAN  RestartIfRunning,
_In_ BOOLEAN  ConnectComms,
_Out_ HANDLE hPort 
)

Definition at line 112 of file fltsupport.c.

118{
119 DWORD Error;
120
121 if (EnableDriverLoadPrivlege)
122 {
124 if (Error)
125 {
126 return Error;
127 }
128 }
129
131 if ((Error == ERROR_SERVICE_ALREADY_RUNNING) && RestartIfRunning)
132 {
134 if (Error)
135 {
136 // TODO
137 __debugbreak();
138 }
139
141 }
142
143 if (Error)
144 {
145 return Error;
146 }
147
148 if (ConnectComms)
149 {
150 Error = KmtFltConnectComms(hPort);
151 }
152
153 return Error;
154}
#define TRUE
Definition: types.h:120
DWORD EnablePrivilegeInCurrentProcess(_In_z_ LPWSTR lpPrivName, _In_ BOOL bEnable)
Definition: fltsupport.c:564
DWORD KmtFltConnectComms(_Out_ HANDLE *hPort)
Definition: fltsupport.c:207
void __cdecl __debugbreak(void)
Definition: intrin_ppc.h:698
DWORD KmtFltLoad(_In_z_ PCWSTR ServiceName)
Definition: filter.c:30
DWORD KmtFltUnload(_In_z_ PCWSTR ServiceName)
Definition: filter.c:336
#define ERROR_SERVICE_ALREADY_RUNNING
Definition: winerror.h:607
#define SE_LOAD_DRIVER_NAME
Definition: winnt_old.h:375

Referenced by START_TEST().

◆ KmtFltRunKernelTest()

DWORD KmtFltRunKernelTest ( _In_ HANDLE  hPort,
_In_z_ PCSTR  TestName 
)

Definition at line 261 of file fltsupport.c.

264{
265 return KmtFltSendStringToDriver(hPort, KMTFLT_RUN_TEST, TestName);
266}
DWORD KmtFltSendStringToDriver(_In_ HANDLE hPort, _In_ DWORD Message, _In_ PCSTR String)
Definition: fltsupport.c:305
#define KMTFLT_RUN_TEST
Definition: kmt_public.h:30

◆ KmtFltSendBufferToDriver()

DWORD KmtFltSendBufferToDriver ( _In_ HANDLE  hPort,
_In_ DWORD  Message,
_In_reads_bytes_(BufferSize) LPVOID  InBuffer,
_In_ DWORD  BufferSize,
_Out_writes_bytes_to_opt_(OutBufferSize, *BytesReturned) LPVOID  OutBuffer,
_In_ DWORD  OutBufferSize,
_Out_opt_ LPDWORD  BytesReturned 
)

Definition at line 384 of file fltsupport.c.

392{
397 DWORD Error;
398
399 assert(hPort);
400
401 if (BufferSize)
402 {
403 assert(InBuffer);
404
407 if (!Ptr)
408 {
410 }
412 }
413 else
414 {
416 Ptr = &Header;
417 }
418
419 Ptr->Message = Message;
420 if (BufferSize)
421 {
422 Ptr->Buffer = (Ptr + 1);
423 StringCbCopy(Ptr->Buffer, BufferSize, InBuffer);
424 Ptr->BufferSize = BufferSize;
425 }
426
428
429 if (FreeMemory)
430 {
432 }
433
434 return Error;
435}
unsigned char BOOLEAN
static VOID FreeMemory(PCREATE_DATA Data)
Definition: create.c:134
Definition: Header.h:9
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
#define BufferSize
Definition: mmc.h:75
#define GetProcessHeap()
Definition: compat.h:736
#define HeapAlloc
Definition: compat.h:733
#define HeapFree(x, y, z)
Definition: compat.h:735
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
static const WCHAR Message[]
Definition: register.c:74
#define assert(x)
Definition: debug.h:53
struct _KMTFLT_MESSAGE_HEADER KMTFLT_MESSAGE_HEADER
_Must_inspect_result_ _In_ PFSRTL_PER_STREAM_CONTEXT Ptr
Definition: fsrtlfuncs.h:898
DWORD KmtFltSendMessage(_In_ HANDLE hPort, _In_reads_bytes_(dwInBufferSize) LPVOID InBuffer, _In_ DWORD InBufferSize, _Out_writes_bytes_to_opt_(dutBufferSize, *BytesReturned) LPVOID OutBuffer, _In_ DWORD OutBufferSize, _Out_opt_ LPDWORD BytesReturned)
Definition: filter.c:187
_In_ UCHAR _In_ ULONG _Out_ PUCHAR _Outptr_result_bytebuffer_ OutBufferLength PVOID * OutBuffer
Definition: scsi.h:4071
#define StringCbCopy
Definition: strsafe.h:155
_Must_inspect_result_ _In_ WDFIOTARGET _In_opt_ WDFREQUEST _In_ ULONG _In_opt_ PWDF_MEMORY_DESCRIPTOR _In_opt_ PWDF_MEMORY_DESCRIPTOR _In_opt_ PWDF_REQUEST_SEND_OPTIONS _Out_opt_ PULONG_PTR BytesReturned
Definition: wdfiotarget.h:1052
_In_ WDFMEMORY _Out_opt_ size_t * BufferSize
Definition: wdfmemory.h:254
_In_ ULONG OutBufferSize
Definition: wdfwmi.h:87
_In_ ULONG InBufferSize
Definition: wdfwmi.h:106

Referenced by KmtFltSendStringToDriver(), KmtFltSendToDriver(), KmtFltSendUlongToDriver(), and KmtFltSendWStringToDriver().

◆ KmtFltSendStringToDriver()

DWORD KmtFltSendStringToDriver ( _In_ HANDLE  hPort,
_In_ DWORD  Message,
_In_ PCSTR  String 
)

Definition at line 305 of file fltsupport.c.

309{
310 assert(hPort);
311 assert(String);
313}
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
DWORD KmtFltSendBufferToDriver(_In_ HANDLE hPort, _In_ DWORD Message, _In_reads_bytes_(BufferSize) LPVOID InBuffer, _In_ DWORD BufferSize, _Out_writes_bytes_to_opt_(OutBufferSize, *BytesReturned) LPVOID OutBuffer, _In_ DWORD OutBufferSize, _Out_opt_ LPDWORD BytesReturned)
Definition: fltsupport.c:384
_Must_inspect_result_ _In_ WDFDEVICE _In_ WDFSTRING String
Definition: wdfdevice.h:2433

Referenced by KmtFltRunKernelTest().

◆ KmtFltSendToDriver()

DWORD KmtFltSendToDriver ( _In_ HANDLE  hPort,
_In_ DWORD  Message 
)

Definition at line 281 of file fltsupport.c.

284{
285 assert(hPort);
286 return KmtFltSendBufferToDriver(hPort, Message, NULL, 0, NULL, 0, NULL);
287}

◆ KmtFltSendUlongToDriver()

DWORD KmtFltSendUlongToDriver ( _In_ HANDLE  hPort,
_In_ DWORD  Message,
_In_ DWORD  Value 
)

Definition at line 353 of file fltsupport.c.

357{
358 return KmtFltSendBufferToDriver(hPort, Message, &Value, sizeof(Value), NULL, 0, NULL);
359}
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _Out_opt_ PUSHORT _Inout_opt_ PUNICODE_STRING Value
Definition: wdfregistry.h:413

◆ KmtFltSendWStringToDriver()

DWORD KmtFltSendWStringToDriver ( _In_ HANDLE  hPort,
_In_ DWORD  Message,
_In_ PCWSTR  String 
)

Definition at line 330 of file fltsupport.c.

334{
335 return KmtFltSendBufferToDriver(hPort, Message, (PVOID)String, (DWORD)wcslen(String) * sizeof(WCHAR), NULL, 0, NULL);
336}
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)

◆ KmtFltUnloadDriver()

DWORD KmtFltUnloadDriver ( _In_ HANDLE hPort,
_In_ BOOLEAN  DisonnectComms 
)

Definition at line 169 of file fltsupport.c.

172{
174
175 if (DisonnectComms)
176 {
177 Error = KmtFltDisconnect(hPort);
178
179 if (Error)
180 {
181 return Error;
182 }
183 }
184
186
187 if (Error)
188 {
189 // TODO
190 __debugbreak();
191 }
192
193 return Error;
194}

Referenced by START_TEST().

◆ KmtpCreateService()

DWORD KmtpCreateService ( IN PCWSTR  ServiceName,
IN PCWSTR  ServicePath,
IN PCWSTR DisplayName  OPTIONAL,
IN DWORD  ServiceType,
OUT SC_HANDLE *  ServiceHandle 
)

Definition at line 414 of file service.c.

420{
422 WCHAR DriverPath[MAX_PATH];
424
425 assert(ServiceHandle);
426 assert(ServiceName && ServicePath);
427
428 if (!GetModuleFileName(NULL, DriverPath, sizeof DriverPath / sizeof DriverPath[0]))
430
431 assert(wcsrchr(DriverPath, L'\\') != NULL);
432 wcsrchr(DriverPath, L'\\')[1] = L'\0';
433
434 result = StringCbCatW(DriverPath, sizeof(DriverPath), ServicePath);
435 if (FAILED(result))
437
440
441 *ServiceHandle = CreateService(ScmHandle, ServiceName, DisplayName,
443 SERVICE_ERROR_NORMAL, DriverPath, NULL, NULL, NULL, NULL, NULL);
444
445 if (!*ServiceHandle)
447
448cleanup:
449 return Error;
450}
#define wcsrchr
Definition: compat.h:16
static void cleanup(void)
Definition: main.c:1335
GLuint64EXT * result
Definition: glext.h:11304
#define S_OK
Definition: intsafe.h:52
#define FAILED(hr)
Definition: intsafe.h:51
#define error_value_goto(Error, value, label)
Definition: kmtest.h:22
#define error_goto(Error, label)
Definition: kmtest.h:21
static SC_HANDLE ScmHandle
Definition: service.c:30
#define SERVICE_ACCESS
Definition: service.c:15
#define INVALID_FILE_ATTRIBUTES
Definition: vfdcmd.c:23
#define GetFileAttributes
Definition: winbase.h:3815
#define GetModuleFileName
Definition: winbase.h:3831
#define CreateService
Definition: winsvc.h:569
#define SERVICE_DEMAND_START
Definition: cmtypes.h:978
#define SERVICE_ERROR_NORMAL
Definition: cmtypes.h:982

Referenced by KmtCreateService(), and KmtFltCreateService().

Variable Documentation

◆ KmtestHandle

HANDLE KmtestHandle
extern

Definition at line 32 of file kmtest.c.

◆ TestServiceName