ReactOS 0.4.15-dev-8061-g57b775e
message.c
Go to the documentation of this file.
1/*
2* PROJECT: Filesystem Filter Manager library
3* LICENSE: GPL - See COPYING in the top level directory
4* FILE: dll/win32/fltlib/message.c
5* PURPOSE: Handles messaging to and from the filter manager
6* PROGRAMMERS: Ged Murphy (ged.murphy@reactos.org)
7*/
8
9#define WIN32_NO_STATUS
10#include <windef.h>
11#include <winbase.h>
12
13#define NTOS_MODE_USER
14#include <ndk/iofuncs.h>
15#include <ndk/obfuncs.h>
16#include <ndk/rtlfuncs.h>
17#include <fltuser.h>
18#include <fltmgr_shared.h>
19
20#include "fltlib.h"
21
27 _In_reads_bytes_opt_(wSizeOfContext) LPCVOID lpContext,
28 _In_ WORD wSizeOfContext,
29 _In_opt_ LPSECURITY_ATTRIBUTES lpSecurityAttributes,
30 _Outptr_ HANDLE *hPort)
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}
127
130WINAPI
132 _In_reads_bytes_(dwInBufferSize) LPVOID lpInBuffer,
133 _In_ DWORD dwInBufferSize,
134 _Out_writes_bytes_to_opt_(dwOutBufferSize, *lpBytesReturned) LPVOID lpOutBuffer,
135 _In_ DWORD dwOutBufferSize,
137{
139 UNREFERENCED_PARAMETER(lpInBuffer);
140 UNREFERENCED_PARAMETER(dwInBufferSize);
141 UNREFERENCED_PARAMETER(lpOutBuffer);
142 UNREFERENCED_PARAMETER(dwOutBufferSize);
144 return E_NOTIMPL;
145}
146
149WINAPI
151 _Out_writes_bytes_(dwMessageBufferSize) PFILTER_MESSAGE_HEADER lpMessageBuffer,
152 _In_ DWORD dwMessageBufferSize,
154{
156 UNREFERENCED_PARAMETER(lpMessageBuffer);
157 UNREFERENCED_PARAMETER(dwMessageBufferSize);
159 return E_NOTIMPL;
160}
161
164WINAPI
166 _In_reads_bytes_(dwReplyBufferSize) PFILTER_REPLY_HEADER lpReplyBuffer,
167 _In_ DWORD dwReplyBufferSize)
168{
170 UNREFERENCED_PARAMETER(lpReplyBuffer);
171 UNREFERENCED_PARAMETER(dwReplyBufferSize);
172 return E_NOTIMPL;
173}
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 E_NOTIMPL
Definition: ddrawi.h:99
#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_ 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: message.c:131
_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: message.c:25
_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: message.c:150
_Must_inspect_result_ HRESULT WINAPI FilterReplyMessage(_In_ HANDLE hPort, _In_reads_bytes_(dwReplyBufferSize) PFILTER_REPLY_HEADER lpReplyBuffer, _In_ DWORD dwReplyBufferSize)
Definition: message.c:165
unsigned long DWORD
Definition: ntddk_ex.h:95
unsigned short WORD
Definition: ntddk_ex.h:93
_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
#define _In_reads_bytes_(size)
Definition: ms_sal.h:321
#define _Out_writes_bytes_(size)
Definition: ms_sal.h:350
#define _Outptr_
Definition: ms_sal.h:427
#define _Inout_opt_
Definition: ms_sal.h:379
#define _Must_inspect_result_
Definition: ms_sal.h:558
#define _Out_
Definition: ms_sal.h:345
#define _Out_writes_bytes_to_opt_(size, count)
Definition: ms_sal.h:361
#define _In_
Definition: ms_sal.h:308
#define _In_reads_bytes_opt_(size)
Definition: ms_sal.h:322
#define _In_opt_
Definition: ms_sal.h:309
_In_ HANDLE _In_ DWORD _In_ DWORD _Inout_opt_ LPOVERLAPPED lpOverlapped
Definition: mswsock.h:93
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 UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
#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
uint32_t * LPDWORD
Definition: typedefs.h:59
#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
_In_ DWORD _In_ DWORD _In_ DWORD _Out_ LPDWORD lpBytesReturned
Definition: winddi.h:1705
CONST void * LPCVOID
Definition: windef.h:191
#define WINAPI
Definition: msvc.h:6
__wchar_t WCHAR
Definition: xmlstorage.h:180
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185