ReactOS 0.4.15-dev-8219-ge8b88cf
message.c File Reference
#include <windef.h>
#include <winbase.h>
#include <ndk/iofuncs.h>
#include <ndk/obfuncs.h>
#include <ndk/rtlfuncs.h>
#include <fltuser.h>
#include <fltmgr_shared.h>
#include "fltlib.h"
Include dependency graph for message.c:

Go to the source code of this file.

Macros

#define WIN32_NO_STATUS
 
#define NTOS_MODE_USER
 

Functions

_Must_inspect_result_ HRESULT WINAPI FilterConnectCommunicationPort (_In_ LPCWSTR lpPortName, _In_ DWORD dwOptions, _In_reads_bytes_opt_(wSizeOfContext) LPCVOID lpContext, _In_ WORD wSizeOfContext, _In_opt_ LPSECURITY_ATTRIBUTES lpSecurityAttributes, _Outptr_ HANDLE *hPort)
 
_Must_inspect_result_ HRESULT WINAPI FilterSendMessage (_In_ HANDLE hPort, _In_reads_bytes_(dwInBufferSize) LPVOID lpInBuffer, _In_ DWORD dwInBufferSize, _Out_writes_bytes_to_opt_(dwOutBufferSize, *lpBytesReturned) LPVOID lpOutBuffer, _In_ DWORD dwOutBufferSize, _Out_ LPDWORD lpBytesReturned)
 
_Must_inspect_result_ HRESULT WINAPI FilterGetMessage (_In_ HANDLE hPort, _Out_writes_bytes_(dwMessageBufferSize) PFILTER_MESSAGE_HEADER lpMessageBuffer, _In_ DWORD dwMessageBufferSize, _Inout_opt_ LPOVERLAPPED lpOverlapped)
 
_Must_inspect_result_ HRESULT WINAPI FilterReplyMessage (_In_ HANDLE hPort, _In_reads_bytes_(dwReplyBufferSize) PFILTER_REPLY_HEADER lpReplyBuffer, _In_ DWORD dwReplyBufferSize)
 

Macro Definition Documentation

◆ NTOS_MODE_USER

#define NTOS_MODE_USER

Definition at line 13 of file message.c.

◆ WIN32_NO_STATUS

#define WIN32_NO_STATUS

Definition at line 9 of file message.c.

Function Documentation

◆ FilterConnectCommunicationPort()

_Must_inspect_result_ HRESULT WINAPI FilterConnectCommunicationPort ( _In_ LPCWSTR  lpPortName,
_In_ DWORD  dwOptions,
_In_reads_bytes_opt_(wSizeOfContext) LPCVOID  lpContext,
_In_ WORD  wSizeOfContext,
_In_opt_ LPSECURITY_ATTRIBUTES  lpSecurityAttributes,
_Outptr_ HANDLE hPort 
)

Definition at line 25 of file message.c.

31{
34 PFILTER_PORT_DATA PortData;
38 SIZE_T PortNameSize;
40 PCHAR Ptr;
42 HRESULT hr;
43
44 *hPort = INVALID_HANDLE_VALUE;
45
46 /* Sanity check */
47 if (lpContext && wSizeOfContext == 0)
48 {
49 return E_INVALIDARG;
50 }
51
52 /* Get the length of the port name */
53 PortNameSize = wcslen(lpPortName) * sizeof(WCHAR);
54
55 /* Calculate and allocate the size of the required buffer */
56 BufferSize = sizeof(FILTER_PORT_DATA) + PortNameSize + wSizeOfContext;
58 if (PortData == NULL) return E_OUTOFMEMORY;
59
60 /* Clear out the buffer and find the end of the fixed struct */
61 RtlZeroMemory(PortData, BufferSize);
62 Ptr = (PCHAR)(PortData + 1);
63
64 PortData->Size = BufferSize;
65 PortData->Options = dwOptions;
66
67 /* Setup the port name */
68 RtlInitUnicodeString(&PortName, lpPortName);
69 PortData->PortName.Buffer = (PWCH)Ptr;
70 PortData->PortName.MaximumLength = PortNameSize;
72 Ptr += PortData->PortName.Length;
73
74 /* Check if we were given a context */
75 if (lpContext)
76 {
77 /* Add that into the buffer too */
78 PortData->Context = Ptr;
79 RtlCopyMemory(PortData->Context, lpContext, wSizeOfContext);
80 }
81
82 /* Initialize the object attributes */
83 RtlInitUnicodeString(&DeviceName, L"\\Global??\\FltMgrMsg");
87 NULL,
88 NULL);
89
90 /* Check if we were passed any security attributes */
91 if (lpSecurityAttributes)
92 {
93 /* Add these manually and update the flags if we were asked to make it inheritable */
94 ObjectAttributes.SecurityDescriptor = lpSecurityAttributes->lpSecurityDescriptor;
95 if (lpSecurityAttributes->bInheritHandle)
96 {
97 ObjectAttributes.Attributes |= OBJ_INHERIT;
98 }
99 }
100
101 /* Now get a handle to the device */
106 0,
107 0,
108 0,
110 0,
111 PortData,
112 BufferSize);
113 if (NT_SUCCESS(Status))
114 {
115 *hPort = FileHandle;
116 hr = S_OK;
117 }
118 else
119 {
121 }
122
123 /* Cleanup and return */
124 RtlFreeHeap(GetProcessHeap(), 0, PortData);
125 return hr;
126}
static UNICODE_STRING PortName
LONG NTSTATUS
Definition: precomp.h:26
PVOID NTAPI RtlAllocateHeap(IN PVOID HeapHandle, IN ULONG Flags, IN SIZE_T Size)
Definition: heap.c:590
BOOLEAN NTAPI RtlFreeHeap(IN PVOID HeapHandle, IN ULONG Flags, IN PVOID HeapBase)
Definition: heap.c:608
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:36
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define E_INVALIDARG
Definition: ddrawi.h:101
#define BufferSize
Definition: mmc.h:75
#define NULL
Definition: types.h:112
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define GetProcessHeap()
Definition: compat.h:736
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
_Must_inspect_result_ _In_opt_ PFLT_INSTANCE _Out_ PHANDLE FileHandle
Definition: fltkernel.h:1231
HRESULT NtStatusToHResult(_In_ NTSTATUS Status)
Definition: fltlib.c:59
struct _FILTER_PORT_DATA FILTER_PORT_DATA
#define FILE_OPEN_IF
Definition: from_kernel.h:56
_Must_inspect_result_ _In_ PFSRTL_PER_STREAM_CONTEXT Ptr
Definition: fsrtlfuncs.h:898
Status
Definition: gdiplustypes.h:25
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
#define OBJ_INHERIT
Definition: winternl.h:225
#define OBJ_EXCLUSIVE
Definition: winternl.h:227
#define S_OK
Definition: intsafe.h:52
#define PCHAR
Definition: match.c:90
static OUT PIO_STATUS_BLOCK IoStatusBlock
Definition: pipe.c:75
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
NTSYSAPI VOID NTAPI RtlCopyUnicodeString(PUNICODE_STRING DestinationString, PUNICODE_STRING SourceString)
#define SYNCHRONIZE
Definition: nt_native.h:61
#define FILE_WRITE_DATA
Definition: nt_native.h:631
#define FILE_READ_DATA
Definition: nt_native.h:628
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
NTSTATUS NTAPI NtCreateFile(OUT PHANDLE FileHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes, OUT PIO_STATUS_BLOCK IoStatusBlock, IN PLARGE_INTEGER AllocationSize OPTIONAL, IN ULONG FileAttributes, IN ULONG ShareAccess, IN ULONG CreateDisposition, IN ULONG CreateOptions, IN PVOID EaBuffer OPTIONAL, IN ULONG EaLength)
WCHAR * PWCH
Definition: ntbasedef.h:410
#define L(x)
Definition: ntvdm.h:50
HRESULT hr
Definition: shlfolder.c:183
DWORD dwOptions
Definition: solitaire.cpp:25
UNICODE_STRING PortName
Definition: fltmgr_shared.h:28
USHORT MaximumLength
Definition: env_spec_w32.h:370
ULONG_PTR SIZE_T
Definition: typedefs.h:80
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
char * PCHAR
Definition: typedefs.h:51
_Must_inspect_result_ _In_ PWDFDEVICE_INIT _In_opt_ PCUNICODE_STRING DeviceName
Definition: wdfdevice.h:3275
_In_ WDFMEMORY _Out_opt_ size_t * BufferSize
Definition: wdfmemory.h:254
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by KmtFltConnect().

◆ FilterGetMessage()

_Must_inspect_result_ HRESULT WINAPI FilterGetMessage ( _In_ HANDLE  hPort,
_Out_writes_bytes_(dwMessageBufferSize) PFILTER_MESSAGE_HEADER  lpMessageBuffer,
_In_ DWORD  dwMessageBufferSize,
_Inout_opt_ LPOVERLAPPED  lpOverlapped 
)

Definition at line 150 of file message.c.

154{
156 UNREFERENCED_PARAMETER(lpMessageBuffer);
157 UNREFERENCED_PARAMETER(dwMessageBufferSize);
159 return E_NOTIMPL;
160}
#define E_NOTIMPL
Definition: ddrawi.h:99
_In_ HANDLE _In_ DWORD _In_ DWORD _Inout_opt_ LPOVERLAPPED lpOverlapped
Definition: mswsock.h:93
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317

Referenced by KmtFltGetMessage().

◆ FilterReplyMessage()

_Must_inspect_result_ HRESULT WINAPI FilterReplyMessage ( _In_ HANDLE  hPort,
_In_reads_bytes_(dwReplyBufferSize) PFILTER_REPLY_HEADER  lpReplyBuffer,
_In_ DWORD  dwReplyBufferSize 
)

Definition at line 165 of file message.c.

168{
170 UNREFERENCED_PARAMETER(lpReplyBuffer);
171 UNREFERENCED_PARAMETER(dwReplyBufferSize);
172 return E_NOTIMPL;
173}

Referenced by KmtFltReplyMessage().

◆ FilterSendMessage()

_Must_inspect_result_ HRESULT WINAPI FilterSendMessage ( _In_ HANDLE  hPort,
_In_reads_bytes_(dwInBufferSize) LPVOID  lpInBuffer,
_In_ DWORD  dwInBufferSize,
_Out_writes_bytes_to_opt_(dwOutBufferSize, *lpBytesReturned) LPVOID  lpOutBuffer,
_In_ DWORD  dwOutBufferSize,
_Out_ LPDWORD  lpBytesReturned 
)

Definition at line 131 of file message.c.

137{
139 UNREFERENCED_PARAMETER(lpInBuffer);
140 UNREFERENCED_PARAMETER(dwInBufferSize);
141 UNREFERENCED_PARAMETER(lpOutBuffer);
142 UNREFERENCED_PARAMETER(dwOutBufferSize);
144 return E_NOTIMPL;
145}
_In_ DWORD _In_ DWORD _In_ DWORD _Out_ LPDWORD lpBytesReturned
Definition: winddi.h:1705

Referenced by KmtFltSendMessage().