1 /*
2  * PROJECT:     ReactOS kernel-mode tests
3  * LICENSE:     LGPL-2.1+ (https://spdx.org/licenses/LGPL-2.1+)
4  * PURPOSE:     Kernel-Mode Test Suite loader application declarations
5  * COPYRIGHT:   Copyright 2011-2018 Thomas Faber <thomas.faber@reactos.org>
6  *              Copyright 2017 Ged Murphy <gedmurphy@reactos.org>
7  */
8 
9 #ifndef _KMTESTS_H_
10 #define _KMTESTS_H_
11 
12 extern PCSTR ErrorFileAndLine;
13 
14 #ifndef KMT_STRINGIZE
15 #define KMT_STRINGIZE(x) #x
16 #endif /* !defined KMT_STRINGIZE */
17 
18 #define location(file, line)                    do { ErrorFileAndLine = file ":" KMT_STRINGIZE(line); } while (0)
19 #define error_value(Error, value)               do { location(__FILE__, __LINE__); Error = value; } while (0)
20 #define error(Error)                            error_value(Error, GetLastError())
21 #define error_goto(Error, label)                do { error(Error); goto label; } while (0)
22 #define error_value_goto(Error, value, label)   do { error_value(Error, value); goto label; } while (0)
23 
24 /* service management functions */
25 DWORD
26 KmtServiceInit(VOID);
27 
28 DWORD
29 KmtServiceCleanup(
30     BOOLEAN IgnoreErrors);
31 
32 DWORD
33 KmtCreateService(
34     IN PCWSTR ServiceName,
35     IN PCWSTR ServicePath,
36     IN PCWSTR DisplayName OPTIONAL,
37     OUT SC_HANDLE *ServiceHandle);
38 
39 DWORD
40 KmtStartService(
41     IN PCWSTR ServiceName OPTIONAL,
42     IN OUT SC_HANDLE *ServiceHandle);
43 
44 DWORD
45 KmtCreateAndStartService(
46     IN PCWSTR ServiceName,
47     IN PCWSTR ServicePath,
48     IN PCWSTR DisplayName OPTIONAL,
49     OUT SC_HANDLE *ServiceHandle,
50     IN BOOLEAN RestartIfRunning);
51 
52 DWORD
53 KmtStopService(
54     IN PCWSTR ServiceName OPTIONAL,
55     IN OUT SC_HANDLE *ServiceHandle);
56 
57 DWORD
58 KmtDeleteService(
59     IN PCWSTR ServiceName OPTIONAL,
60     IN OUT SC_HANDLE *ServiceHandle);
61 
62 DWORD KmtCloseService(
63     IN OUT SC_HANDLE *ServiceHandle);
64 
65 
66 #ifdef KMT_FLT_USER_MODE
67 
68 DWORD
69 KmtFltLoad(
70     _In_z_ PCWSTR ServiceName);
71 
72 DWORD
73 KmtFltCreateAndStartService(
74     _In_z_ PCWSTR ServiceName,
75     _In_z_ PCWSTR ServicePath,
76     _In_z_ PCWSTR DisplayName OPTIONAL,
77     _Out_ SC_HANDLE *ServiceHandle,
78     _In_ BOOLEAN RestartIfRunning);
79 
80 DWORD
81 KmtFltConnect(
82     _In_z_ PCWSTR ServiceName,
83     _Out_ HANDLE *hPort);
84 
85 DWORD
86 KmtFltDisconnect(
87     _Out_ HANDLE *hPort);
88 
89 DWORD
90 KmtFltSendMessage(
91     _In_ HANDLE hPort,
92     _In_reads_bytes_(dwInBufferSize) LPVOID lpInBuffer,
93     _In_ DWORD dwInBufferSize,
94     _Out_writes_bytes_to_opt_(dwOutBufferSize, *lpBytesReturned) LPVOID lpOutBuffer,
95     _In_ DWORD dwOutBufferSize,
96     _Out_opt_ LPDWORD lpBytesReturned);
97 
98 DWORD
99 KmtFltGetMessage(
100     _In_ HANDLE hPort,
101     _Out_writes_bytes_(dwMessageBufferSize) PFILTER_MESSAGE_HEADER lpMessageBuffer,
102     _In_ DWORD dwMessageBufferSize,
103     _In_opt_ LPOVERLAPPED Overlapped);
104 
105 DWORD
106 KmtFltReplyMessage(
107     _In_ HANDLE hPort,
108     _In_reads_bytes_(dwReplyBufferSize) PFILTER_REPLY_HEADER lpReplyBuffer,
109     _In_ DWORD dwReplyBufferSize);
110 
111 DWORD
112 KmtFltGetMessageResult(
113     _In_ HANDLE hPort,
114     _In_ LPOVERLAPPED Overlapped,
115     _Out_ LPDWORD BytesTransferred);
116 
117 DWORD
118 KmtFltUnload(
119     _In_z_ PCWSTR ServiceName);
120 
121 DWORD
122 KmtFltDeleteService(
123     _In_z_ PCWSTR ServiceName OPTIONAL,
124     _Inout_ SC_HANDLE *ServiceHandle);
125 
126 DWORD KmtFltCloseService(
127     _Inout_ SC_HANDLE *ServiceHandle);
128 
129 #endif /* KMT_FILTER_DRIVER */
130 
131 #endif /* !defined _KMTESTS_H_ */
132