Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add fltlib API #923

Closed
wants to merge 9 commits into from
Closed

Add fltlib API #923

wants to merge 9 commits into from

Conversation

mat-gas
Copy link

@mat-gas mat-gas commented Jul 13, 2020

this PR adds support for fltlib API :

This way, winapi is (normally) able to load/unload, connect to a minifilter..

@retep998 retep998 added the waiting on review Waiting for a reviewer to review the PR label Jul 13, 2020
Copy link

@roblabla roblabla left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Requires changes.

  • Organization of code

    • All definitions go into the source file that directly maps to the header the definition is from:
      • ⚠️ some definitions in fltuser should go in a separate shared::fltuserstructures module.
    • Definitions are defined in the same order as they are in the original header
      • ⚠️ Definitions are not given in the same order as the original header.
  • Extern functions

    • ABIS are correct (WINAPI = "system"): ✔️
    • Names are correct (functions, parameters): ✔️
    • Parameter types are correct: ⚠️ PHANDLE used instead of *mut HANDLE (resolves to the same underlying type).
    • Return types are correct: ✔️
  • Constants

    • Names are correct: ✔️
    • Values are correct: ✔️
    • Types are correct: ✔️
      • All the ULONG consts go in various ULONG members of structures.
      • FLT_PORT_FLAG_SYNC_HANDLE is used with FilterConnectCommunicationPort' dwOptions, a DWORD.
  • Structs

    • Struct definitions are wrapped in STRUCT! macro: ✔️
    • Struct names are correct: ⚠️ problems around anonymous names
    • Param names are correct: ✔️
    • Param types are correct: ✔️
  • Unions

    • Unions are wrapped in the UNION! macro: ✔️
    • Union names are correct: ⚠️ problems around anonymous unions
    • Union container size is correct: ✔️
    • Union member names are correct: ✔️
    • Union member mutable accessor is in form FieldName_mut: ⚠️
    • Union member types are correct: ✔️
  • Enums

    • Enum definitions are wrapped in ENUM! macro: ✔️
    • Enum names are correct: ✔️
    • Enum variant names are correct: ✔️
    • Enum variant values are correct: ✔️

pub fn FilterUnload(
lpFilterName: LPCWSTR
) -> HRESULT;
// FilterVolumeClose@4 // ?????

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// FilterVolumeClose@4 // ?????

Not sure what this comment is about? I couldn't find FilterVolumeClose in the header.

use shared::ntdef::NTSTATUS;
use um::minwinbase::{LPOVERLAPPED, LPSECURITY_ATTRIBUTES};
use um::winnt::{HANDLE, HRESULT, LPCWSTR, LPWSTR, PHANDLE, ULONGLONG, WCHAR};
pub type HFILTER = HANDLE;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A lot of those definitions should go in a module shared::fltuserstructures, as they are defined in a header called shared/fltuserstructures.h

use um::minwinbase::{LPOVERLAPPED, LPSECURITY_ATTRIBUTES};
use um::winnt::{HANDLE, HRESULT, LPCWSTR, LPWSTR, PHANDLE, ULONGLONG, WCHAR};
pub type HFILTER = HANDLE;
pub type PHFILTER = *mut HFILTER;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
pub type PHFILTER = *mut HFILTER;

I couldn't find PHFILTER in the windows header files.

pub type HFILTER = HANDLE;
pub type PHFILTER = *mut HFILTER;
pub type HFILTER_INSTANCE = HANDLE;
pub type PHFILTER_INSTANCE = *mut HFILTER_INSTANCE;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
pub type PHFILTER_INSTANCE = *mut HFILTER_INSTANCE;

I couldn't find PHFILTER_INSTANCE in the windows header files.

FLT_FSTYPE_CIMFS, //Composite Image file system (\FileSystem\cimfs)
}}
ENUM!{enum FILTER_INFORMATION_CLASS {
FilterFullInformation = 0,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
FilterFullInformation = 0,
FilterFullInformation,

Windows header file doesn't specify = 0.

UNION!{union INSTANCE_AGGREGATE_STANDARD_INFORMATION_Type_u {
[u32; 8],
MiniFilter mut_MiniFilter: INSTANCE_AGGREGATE_STANDARD_INFORMATION_u_s_MiniFilter,
LegacyFilter mut_LegacyFilter: INSTANCE_AGGREGATE_STANDARD_INFORMATION_u_s_LegacyFilter,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
LegacyFilter mut_LegacyFilter: INSTANCE_AGGREGATE_STANDARD_INFORMATION_u_s_LegacyFilter,
LegacyFilter LegacyFilter_mut: INSTANCE_AGGREGATE_STANDARD_INFORMATION_Type_LegacyFilter,

STRUCT!{struct INSTANCE_AGGREGATE_STANDARD_INFORMATION {
NextEntryOffset: ULONG,
Flags: ULONG,
Type: INSTANCE_AGGREGATE_STANDARD_INFORMATION_Type_u,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Type: INSTANCE_AGGREGATE_STANDARD_INFORMATION_Type_u,
Type: INSTANCE_AGGREGATE_STANDARD_INFORMATION_Type,

lpContext: LPCVOID,
wSizeOfContext: WORD,
lpSecurityAttributes: LPSECURITY_ATTRIBUTES,
hPort: PHANDLE

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
hPort: PHANDLE
hPort: *mut HANDLE

The windows header file uses a raw pointer here.

) -> HRESULT;
pub fn FilterCreate(
lpFilterName: LPCWSTR,
hFilter: PHFILTER

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
hFilter: PHFILTER
hFilter: *mut HFILTER

lpFilterName: LPCWSTR,
lpVolumeName: LPCWSTR,
lpInstanceName: LPCWSTR,
hInstance: PHFILTER_INSTANCE

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
hInstance: PHFILTER_INSTANCE
hInstance: *mut HFILTER_INSTANCE

Copy link

@roblabla roblabla left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

All problems from previous review fixed!

@roblabla roblabla mentioned this pull request Dec 4, 2020
14 tasks
@mvforell
Copy link

mvforell commented Jan 9, 2021

Any estimate on when this will be merged and when a new version will be published?

This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
waiting on review Waiting for a reviewer to review the PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants