Author: gedmurphy
Date: Thu May 18 22:06:49 2017
New Revision: 74583
URL:
http://svn.reactos.org/svn/reactos?rev=74583&view=rev
Log:
[FLTLIB]
- Implement FilterConnectCommunicationPort
- Add the remaining IOCTLs fltlib sends to the fltmgr
Added:
trunk/reactos/dll/win32/fltlib/fltlib.h (with props)
trunk/reactos/dll/win32/fltlib/message.c (with props)
Modified:
trunk/reactos/dll/win32/fltlib/CMakeLists.txt
trunk/reactos/dll/win32/fltlib/fltlib.c
trunk/reactos/dll/win32/fltlib/stubs.c
trunk/reactos/sdk/include/ddk/fltuserstructures.h
trunk/reactos/sdk/include/psdk/ntstatus.h
trunk/reactos/sdk/include/reactos/drivers/fltmgr/fltmgr_shared.h
Modified: trunk/reactos/dll/win32/fltlib/CMakeLists.txt
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/fltlib/CMakeList…
==============================================================================
--- trunk/reactos/dll/win32/fltlib/CMakeLists.txt [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/fltlib/CMakeLists.txt [iso-8859-1] Thu May 18 22:06:49 2017
@@ -9,11 +9,13 @@
list(APPEND SOURCE
fltlib.c
+ message.c
stubs.c
${CMAKE_CURRENT_BINARY_DIR}/fltlib.def)
add_library(fltlib SHARED ${SOURCE} rsrc.rc)
set_module_type(fltlib win32dll)
target_link_libraries(fltlib wine)
+add_target_compile_definitions(fltlib NTDDI_VERSION=NTDDI_WS03SP1)
add_importlibs(fltlib msvcrt kernel32 ntdll)
add_cd_file(TARGET fltlib DESTINATION reactos/system32 FOR all)
Modified: trunk/reactos/dll/win32/fltlib/fltlib.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/fltlib/fltlib.c?…
==============================================================================
--- trunk/reactos/dll/win32/fltlib/fltlib.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/fltlib/fltlib.c [iso-8859-1] Thu May 18 22:06:49 2017
@@ -60,6 +60,18 @@
/* PRIVATE FUNCTIONS ****************************************************************/
+HRESULT
+NtStatusToHResult(_In_ NTSTATUS Status)
+{
+ HRESULT hr;
+ hr = RtlNtStatusToDosError(Status);
+ if (hr != ERROR_SUCCESS)
+ {
+ hr = (ULONG)hr | 0x80070000;
+ }
+ return hr;
+}
+
static
HRESULT
FilterLoadUnload(_In_z_ LPCWSTR lpFilterName,
@@ -103,7 +115,7 @@
/* Tell the filter manager to load the filter for us */
dwError = SendIoctl(hFltMgr,
- Load ? IOCTL_LOAD_FILTER : IOCTL_UNLOAD_FILTER,
+ Load ? IOCTL_FILTER_LOAD : IOCTL_FILTER_UNLOAD,
FilterName,
BufferLength);
Added: trunk/reactos/dll/win32/fltlib/fltlib.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/fltlib/fltlib.h?…
==============================================================================
--- trunk/reactos/dll/win32/fltlib/fltlib.h (added)
+++ trunk/reactos/dll/win32/fltlib/fltlib.h [iso-8859-1] Thu May 18 22:06:49 2017
@@ -0,0 +1,6 @@
+#pragma once
+
+HRESULT
+NtStatusToHResult(
+ _In_ NTSTATUS Status
+);
Propchange: trunk/reactos/dll/win32/fltlib/fltlib.h
------------------------------------------------------------------------------
svn:eol-style = native
Added: trunk/reactos/dll/win32/fltlib/message.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/fltlib/message.c…
==============================================================================
--- trunk/reactos/dll/win32/fltlib/message.c (added)
+++ trunk/reactos/dll/win32/fltlib/message.c [iso-8859-1] Thu May 18 22:06:49 2017
@@ -0,0 +1,180 @@
+/*
+* PROJECT: Filesystem Filter Manager library
+* LICENSE: GPL - See COPYING in the top level directory
+* FILE: dll/win32/fltlib/message.c
+* PURPOSE: Handles messaging to and from the filter manager
+* PROGRAMMERS: Ged Murphy (ged.murphy(a)reactos.org)
+*/
+
+//#include <stdarg.h>
+
+#define WIN32_NO_STATUS
+
+#include "windef.h"
+#include "winbase.h"
+
+#define NTOS_MODE_USER
+#include <ndk/iofuncs.h>
+#include <ndk/obfuncs.h>
+#include <ndk/rtlfuncs.h>
+
+#include "fltuser.h"
+#include "fltlib.h"
+#include <fltmgr_shared.h>
+
+#include "wine/debug.h"
+WINE_DEFAULT_DEBUG_CHANNEL(fltlib);
+
+
+_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)
+{
+ OBJECT_ATTRIBUTES ObjectAttributes;
+ IO_STATUS_BLOCK IoStatusBlock;
+ PFILTER_PORT_DATA PortData;
+ UNICODE_STRING DeviceName;
+ UNICODE_STRING PortName;
+ HANDLE FileHandle;
+ ULONG PortNameSize;
+ ULONG BufferSize;
+ PCHAR Ptr;
+ NTSTATUS Status;
+ HRESULT hr;
+
+ *hPort = INVALID_HANDLE_VALUE;
+
+ /* Sanity check */
+ if (lpContext && wSizeOfContext == 0)
+ {
+ return E_INVALIDARG;
+ }
+
+ /* Get the length of the port name */
+ PortNameSize = wcslen(lpPortName) * sizeof(WCHAR);
+
+ /* Calculate and allocate the size of the required buffer */
+ BufferSize = sizeof(FILTER_PORT_DATA) + PortNameSize + wSizeOfContext;
+ PortData = RtlAllocateHeap(GetProcessHeap(), 0, BufferSize);
+ if (PortData == NULL) return E_OUTOFMEMORY;
+
+ /* Clear out the buffer and find the end of the fixed struct */
+ RtlZeroMemory(PortData, BufferSize);
+ Ptr = (PCHAR)(PortData + 1);
+
+ PortData->Size = BufferSize;
+ PortData->Options = dwOptions;
+
+ /* Setup the port name */
+ RtlInitUnicodeString(&PortName, lpPortName);
+ PortData->PortName.Buffer = (PWCH)Ptr;
+ PortData->PortName.MaximumLength = PortNameSize;
+ RtlCopyUnicodeString(&PortData->PortName, &PortName);
+ Ptr += PortData->PortName.Length;
+
+ /* Check if we were given a context */
+ if (lpContext)
+ {
+ /* Add that into the buffer too */
+ PortData->Context = Ptr;
+ RtlCopyMemory(PortData->Context, lpContext, wSizeOfContext);
+ }
+
+ /* Initialize the object attributes */
+ RtlInitUnicodeString(&DeviceName, L"\\Global??\\FltMgrMsg");
+ InitializeObjectAttributes(&ObjectAttributes,
+ &DeviceName,
+ OBJ_EXCLUSIVE | OBJ_CASE_INSENSITIVE,
+ NULL,
+ NULL);
+
+ /* Check if we were passed any security attributes */
+ if (lpSecurityAttributes)
+ {
+ /* Add these manually and update the flags if we were asked to make it
inheritable */
+ ObjectAttributes.SecurityDescriptor =
lpSecurityAttributes->lpSecurityDescriptor;
+ if (lpSecurityAttributes->bInheritHandle)
+ {
+ ObjectAttributes.Attributes |= OBJ_INHERIT;
+ }
+ }
+
+ /* Now get a handle to the device */
+ Status = NtCreateFile(&FileHandle,
+ SYNCHRONIZE | FILE_READ_DATA | FILE_WRITE_DATA,
+ &ObjectAttributes,
+ &IoStatusBlock,
+ 0,
+ 0,
+ 0,
+ FILE_OPEN_IF,
+ 0,
+ PortData,
+ BufferSize);
+ if (NT_SUCCESS(Status))
+ {
+ *hPort = FileHandle;
+ hr = S_OK;
+ }
+ else
+ {
+ hr = NtStatusToHResult(Status);
+ }
+
+ /* Cleanup and return */
+ RtlFreeHeap(GetProcessHeap(), 0, PortData);
+ return hr;
+}
+
+_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)
+{
+ UNREFERENCED_PARAMETER(hPort);
+ UNREFERENCED_PARAMETER(lpInBuffer);
+ UNREFERENCED_PARAMETER(dwInBufferSize);
+ UNREFERENCED_PARAMETER(lpOutBuffer);
+ UNREFERENCED_PARAMETER(dwOutBufferSize);
+ UNREFERENCED_PARAMETER(lpBytesReturned);
+ return E_NOTIMPL;
+}
+
+_Must_inspect_result_
+HRESULT
+WINAPI
+FilterGetMessage(_In_ HANDLE hPort,
+ _Out_writes_bytes_(dwMessageBufferSize) PFILTER_MESSAGE_HEADER
lpMessageBuffer,
+ _In_ DWORD dwMessageBufferSize,
+ _Inout_opt_ LPOVERLAPPED lpOverlapped)
+{
+ UNREFERENCED_PARAMETER(hPort);
+ UNREFERENCED_PARAMETER(lpMessageBuffer);
+ UNREFERENCED_PARAMETER(dwMessageBufferSize);
+ UNREFERENCED_PARAMETER(lpOverlapped);
+ return E_NOTIMPL;
+}
+
+_Must_inspect_result_
+HRESULT
+WINAPI
+FilterReplyMessage(_In_ HANDLE hPort,
+ _In_reads_bytes_(dwReplyBufferSize) PFILTER_REPLY_HEADER
lpReplyBuffer,
+ _In_ DWORD dwReplyBufferSize)
+{
+ UNREFERENCED_PARAMETER(hPort);
+ UNREFERENCED_PARAMETER(lpReplyBuffer);
+ UNREFERENCED_PARAMETER(dwReplyBufferSize);
+ return E_NOTIMPL;
+}
Propchange: trunk/reactos/dll/win32/fltlib/message.c
------------------------------------------------------------------------------
svn:eol-style = native
Modified: trunk/reactos/dll/win32/fltlib/stubs.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/fltlib/stubs.c?r…
==============================================================================
--- trunk/reactos/dll/win32/fltlib/stubs.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/fltlib/stubs.c [iso-8859-1] Thu May 18 22:06:49 2017
@@ -6,10 +6,6 @@
* PROGRAMMERS: Ged Murphy (ged.murphy(a)reactos.org)
*/
-// Hack - our SDK reports NTDDI_VERSION as 0x05020100 (from _WIN32_WINNT 0x502)
-// which doesn't pass the FLT_MGR_BASELINE check in fltkernel.h
-#define NTDDI_VERSION NTDDI_WS03SP1
-
#include <stdarg.h>
#include "windef.h"
#include "winbase.h"
@@ -322,73 +318,6 @@
return E_NOTIMPL;
}
-
-_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)
-{
- UNREFERENCED_PARAMETER(lpPortName);
- UNREFERENCED_PARAMETER(dwOptions);
- UNREFERENCED_PARAMETER(lpContext);
- UNREFERENCED_PARAMETER(wSizeOfContext);
- UNREFERENCED_PARAMETER(lpSecurityAttributes);
- UNREFERENCED_PARAMETER(hPort);
- return E_NOTIMPL;
-}
-
-_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)
-{
- UNREFERENCED_PARAMETER(hPort);
- UNREFERENCED_PARAMETER(lpInBuffer);
- UNREFERENCED_PARAMETER(dwInBufferSize);
- UNREFERENCED_PARAMETER(lpOutBuffer);
- UNREFERENCED_PARAMETER(dwOutBufferSize);
- UNREFERENCED_PARAMETER(lpBytesReturned);
- return E_NOTIMPL;
-}
-
-_Must_inspect_result_
-HRESULT
-WINAPI
-FilterGetMessage(_In_ HANDLE hPort,
- _Out_writes_bytes_(dwMessageBufferSize) PFILTER_MESSAGE_HEADER
lpMessageBuffer,
- _In_ DWORD dwMessageBufferSize,
- _Inout_opt_ LPOVERLAPPED lpOverlapped)
-{
- UNREFERENCED_PARAMETER(hPort);
- UNREFERENCED_PARAMETER(lpMessageBuffer);
- UNREFERENCED_PARAMETER(dwMessageBufferSize);
- UNREFERENCED_PARAMETER(lpOverlapped);
- return E_NOTIMPL;
-}
-
-_Must_inspect_result_
-HRESULT
-WINAPI
-FilterReplyMessage(_In_ HANDLE hPort,
- _In_reads_bytes_(dwReplyBufferSize) PFILTER_REPLY_HEADER
lpReplyBuffer,
- _In_ DWORD dwReplyBufferSize)
-{
- UNREFERENCED_PARAMETER(hPort);
- UNREFERENCED_PARAMETER(lpReplyBuffer);
- UNREFERENCED_PARAMETER(dwReplyBufferSize);
- return E_NOTIMPL;
-}
-
_Must_inspect_result_
HRESULT
WINAPI
Modified: trunk/reactos/sdk/include/ddk/fltuserstructures.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/sdk/include/ddk/fltuserstr…
==============================================================================
--- trunk/reactos/sdk/include/ddk/fltuserstructures.h [iso-8859-1] (original)
+++ trunk/reactos/sdk/include/ddk/fltuserstructures.h [iso-8859-1] Thu May 18 22:06:49
2017
@@ -35,7 +35,9 @@
typedef HANDLE HFILTER, HFILTER_INSTANCE, HFILTER_VOLUME;
+#ifndef _NTDEF_H
typedef _Return_type_success_(return >= 0) LONG NTSTATUS, *PNTSTATUS;
+#endif
/* Known File System Types */
Modified: trunk/reactos/sdk/include/psdk/ntstatus.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/sdk/include/psdk/ntstatus.…
==============================================================================
--- trunk/reactos/sdk/include/psdk/ntstatus.h [iso-8859-1] (original)
+++ trunk/reactos/sdk/include/psdk/ntstatus.h [iso-8859-1] Thu May 18 22:06:49 2017
@@ -946,6 +946,7 @@
#define STATUS_ASSERTION_FAILURE ((NTSTATUS)0xC0000420L)
#define STATUS_CALLBACK_POP_STACK ((NTSTATUS)0xC0000423)
#define STATUS_ELEVATION_REQUIRED ((NTSTATUS)0xC000042C)
+#define STATUS_ALREADY_REGISTERED ((NTSTATUS)0xC0000718)
#define STATUS_WOW_ASSERTION ((NTSTATUS)0xC0009898)
#define STATUS_INVALID_SIGNATURE ((NTSTATUS)0xC000A000)
#define STATUS_HMAC_NOT_SUPPORTED ((NTSTATUS)0xC000A001)
Modified: trunk/reactos/sdk/include/reactos/drivers/fltmgr/fltmgr_shared.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/sdk/include/reactos/driver…
==============================================================================
--- trunk/reactos/sdk/include/reactos/drivers/fltmgr/fltmgr_shared.h [iso-8859-1]
(original)
+++ trunk/reactos/sdk/include/reactos/drivers/fltmgr/fltmgr_shared.h [iso-8859-1] Thu May
18 22:06:49 2017
@@ -1,11 +1,16 @@
#pragma once
-#define IOCTL_LOAD_FILTER CTL_CODE(FILE_DEVICE_DISK_FILE_SYSTEM, 0x01, 0,
FILE_WRITE_DATA) //88004
-#define IOCTL_UNLOAD_FILTER CTL_CODE(FILE_DEVICE_DISK_FILE_SYSTEM, 0x02, 0,
FILE_WRITE_DATA) //88008
-#define IOCTL_INIT_FIND CTL_CODE(FILE_DEVICE_DISK_FILE_SYSTEM, 0x03, 0,
FILE_READ_DATA) //8400C
-
-//84024 find first
-//84028 find next
+#define IOCTL_FILTER_LOAD CTL_CODE(FILE_DEVICE_DISK_FILE_SYSTEM, 0x01,
METHOD_BUFFERED, FILE_WRITE_DATA) //88004
+#define IOCTL_FILTER_UNLOAD CTL_CODE(FILE_DEVICE_DISK_FILE_SYSTEM, 0x02,
METHOD_BUFFERED, FILE_WRITE_DATA) //88008
+#define IOCTL_FILTER_CREATE CTL_CODE(FILE_DEVICE_DISK_FILE_SYSTEM, 0x03,
METHOD_BUFFERED, FILE_READ_DATA) //8400C
+#define IOCTL_FILTER_ATTATCH CTL_CODE(FILE_DEVICE_DISK_FILE_SYSTEM, 0x04,
METHOD_BUFFERED, FILE_WRITE_DATA) //88010
+#define IOCTL_FILTER_DETATCH CTL_CODE(FILE_DEVICE_DISK_FILE_SYSTEM, 0x05,
METHOD_BUFFERED, FILE_WRITE_DATA) //88014
+#define IOCTL_FILTER_SEND_MESSAGE CTL_CODE(FILE_DEVICE_DISK_FILE_SYSTEM, 0x06,
METHOD_NEITHER, FILE_WRITE_DATA) //8801B
+#define IOCTL_FILTER_GET_MESSAGE CTL_CODE(FILE_DEVICE_DISK_FILE_SYSTEM, 0x07,
METHOD_NEITHER, FILE_READ_DATA) //8401F
+#define IOCTL_FILTER_REPLY_MESSAGE CTL_CODE(FILE_DEVICE_DISK_FILE_SYSTEM, 0x08,
METHOD_NEITHER, FILE_WRITE_DATA) //88023
+#define IOCTL_FILTER_FIND_FIRST CTL_CODE(FILE_DEVICE_DISK_FILE_SYSTEM, 0x09,
METHOD_BUFFERED, FILE_READ_DATA) //84024
+#define IOCTL_FILTER_FIND_NEXT CTL_CODE(FILE_DEVICE_DISK_FILE_SYSTEM, 0x0A,
METHOD_BUFFERED, FILE_READ_DATA) //84028
+#define IOCTL_FILTER_GET_INFO CTL_CODE(FILE_DEVICE_DISK_FILE_SYSTEM, 0x0B,
METHOD_BUFFERED, FILE_READ_DATA) //8402C
typedef struct _FILTER_NAME
@@ -14,3 +19,15 @@
WCHAR FilterName[1];
} FILTER_NAME, *PFILTER_NAME;
+
+
+
+typedef struct _FILTER_PORT_DATA
+{
+ ULONG Size;
+ UNICODE_STRING PortName;
+ ULONG Options;
+ PVOID Context;
+ ULONG ContextSize;
+
+} FILTER_PORT_DATA, *PFILTER_PORT_DATA;