ReactOS  0.4.14-dev-50-g13bb5e2
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;
57  PortData = RtlAllocateHeap(GetProcessHeap(), 0, BufferSize);
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");
85  &DeviceName,
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 */
105  &IoStatusBlock,
106  0,
107  0,
108  0,
109  FILE_OPEN_IF,
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 }
signed char * PCHAR
Definition: retypes.h:7
DWORD dwOptions
Definition: solitaire.cpp:23
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:35
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
#define FILE_OPEN_IF
Definition: from_kernel.h:56
HRESULT hr
Definition: shlfolder.c:183
USHORT MaximumLength
Definition: env_spec_w32.h:370
_Must_inspect_result_ _In_ PFSRTL_PER_STREAM_CONTEXT Ptr
Definition: fsrtlfuncs.h:898
LONG NTSTATUS
Definition: precomp.h:26
BOOLEAN NTAPI RtlFreeHeap(IN PVOID HeapHandle, IN ULONG Flags, IN PVOID HeapBase)
Definition: heap.c:606
HRESULT NtStatusToHResult(_In_ NTSTATUS Status)
Definition: fltlib.c:59
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
WCHAR DeviceName[]
Definition: adapter.cpp:21
NTSYSAPI VOID NTAPI RtlCopyUnicodeString(PUNICODE_STRING DestinationString, PUNICODE_STRING SourceString)
HANDLE FileHandle
Definition: stats.c:38
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define FILE_READ_DATA
Definition: nt_native.h:628
#define E_INVALIDARG
Definition: ddrawi.h:101
smooth NULL
Definition: ftsmooth.c:416
#define OBJ_EXCLUSIVE
Definition: winternl.h:227
#define FILE_WRITE_DATA
Definition: nt_native.h:631
#define PCHAR
Definition: match.c:90
PVOID NTAPI RtlAllocateHeap(IN PVOID HeapHandle, IN ULONG Flags, IN SIZE_T Size)
Definition: heap.c:588
#define GetProcessHeap()
Definition: compat.h:395
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_t WCHAR
Definition: xmlstorage.h:180
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
LONG HRESULT
Definition: typedefs.h:77
#define OBJ_INHERIT
Definition: winternl.h:225
#define BufferSize
Definition: classpnp.h:419
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
WCHAR * PWCH
Definition: ntbasedef.h:417
static const WCHAR L[]
Definition: oid.c:1250
#define SYNCHRONIZE
Definition: nt_native.h:61
Status
Definition: gdiplustypes.h:24
ULONG_PTR SIZE_T
Definition: typedefs.h:78
#define S_OK
Definition: intsafe.h:59
static OUT PIO_STATUS_BLOCK IoStatusBlock
Definition: pipe.c:75
UNICODE_STRING PortName
Definition: fltmgr_shared.h:28
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
struct _FILTER_PORT_DATA FILTER_PORT_DATA
IN PUNICODE_STRING PortName
Definition: conport.c:35

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 {
155  UNREFERENCED_PARAMETER(hPort);
156  UNREFERENCED_PARAMETER(lpMessageBuffer);
157  UNREFERENCED_PARAMETER(dwMessageBufferSize);
159  return E_NOTIMPL;
160 }
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
_In_ HANDLE _In_ DWORD _In_ DWORD _Inout_opt_ LPOVERLAPPED lpOverlapped
Definition: mswsock.h:90
#define E_NOTIMPL
Definition: ddrawi.h:99

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 {
169  UNREFERENCED_PARAMETER(hPort);
170  UNREFERENCED_PARAMETER(lpReplyBuffer);
171  UNREFERENCED_PARAMETER(dwReplyBufferSize);
172  return E_NOTIMPL;
173 }
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
#define E_NOTIMPL
Definition: ddrawi.h:99

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 {
138  UNREFERENCED_PARAMETER(hPort);
139  UNREFERENCED_PARAMETER(lpInBuffer);
140  UNREFERENCED_PARAMETER(dwInBufferSize);
141  UNREFERENCED_PARAMETER(lpOutBuffer);
142  UNREFERENCED_PARAMETER(dwOutBufferSize);
144  return E_NOTIMPL;
145 }
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
#define E_NOTIMPL
Definition: ddrawi.h:99
_In_ DWORD _In_ DWORD _In_ DWORD _Out_ LPDWORD lpBytesReturned
Definition: winddi.h:1704

Referenced by KmtFltSendMessage().