EaseFilter Demo Project
FilterWorker.cpp
Go to the documentation of this file.
1 
3 //
4 // (C) Copyright 2011 EaseFilter Technologies Inc.
5 // All Rights Reserved
6 //
7 // This software is part of a licensed software product and may
8 // only be used or copied in accordance with the terms of that license.
9 //
11 
12 #include "stdafx.h"
13 #include "Tools.h"
14 #include "FilterAPI.h"
15 #include "FilterMessage.h"
16 #include "FilterWorker.h"
17 #include "ControlFilterHandler.h"
18 
19 BOOL
20 __stdcall
22  IN PMESSAGE_SEND_DATA pSendMessage,
23  IN OUT PMESSAGE_REPLY_DATA pReplyMessage)
24 {
25 
26  BOOL ret = TRUE;
27 
28  DisplayFilterMessageInfo(pSendMessage);
29 
30  if(pReplyMessage)
31  {
32  ret = ProcessControlFilter(pSendMessage,pReplyMessage);
33  }
34 
35  return ret;
36 }
37 
38 VOID
39 __stdcall
41 {
42  printf("Filter connection was disconnected.\n");
43  return;
44 }
45 
46 
47 
48 void
49 SendConfigInfoToFilter(ULONG FilterType,WCHAR* FilterFolder,ULONG IoRegistration ,ULONG AccessFlag,UCHAR* encryptionKey,ULONG keyLength)
50 {
51 
52 
53  //Set the filter maximum wait time for response from the user mode call back function.
54  SetConnectionTimeout(30);
55 
56  //Set the filter type to file system monitor/call back filter.
57  SetFilterType(FilterType);
58 
59  //Setup the filter rule,filter mask is the folder to be monitored,
60  //accessFlag is the I/O access control of the folder, only affect callback filter,
61  //reparseMask is the destination folder for reparse file open, only when the accessFlag = REPARSE_FILE_OPEN.
62 
63  ULONG accessFlag = AccessFlag;
64 
65  //test control filter to exclude the file access
66  //accessFlag = ALLOW_MAX_RIGHT_ACCESS | EXCLUDE_FILE_ACCESS;
67 
68  if( FilterFolder )
69  {
70  if( !AddNewFilterRule(accessFlag,FilterFolder))
71  {
72  PrintLastErrorMessage(L"AddFilterRule failed.");
73  return;
74  }
75 
76  if( keyLength > 0)
77  {
78  AddEncryptionKeyToFilterRule(FilterFolder,keyLength,encryptionKey);
79  }
80  }
81 
82 
83  //Exclude the process Id from the filter.
84  /* if(!AddExcludedProcessId(GetCurrentProcessId()))
85  {
86  PrintLastErrorMessage(L"AddExcludedProcessId failed.");
87  return;
88  }*/
89 
90  //Only include process id will be watched,all others processes will be excluded.
91  //AddIncludedProcessId(GetCurrentProcessId());
92 
93  if(!RegisterIoRequest(IoRegistration))
94  {
95  PrintLastErrorMessage(L"RegisterIoRequest failed.");
96  return;
97  }
98 }
99 
100 
VOID DisplayFilterMessageInfo(IN PMESSAGE_SEND_DATA pSendMessage)
ULONG PUCHAR encryptionKey
Definition: FilterAPI.h:561
WCHAR WCHAR ULONG keyLength
Definition: FilterAPI.h:553
VOID __stdcall DisconnectCallback()
enum _FilterType FilterType
enum _AccessFlag AccessFlag
BOOL ProcessControlFilter(IN PMESSAGE_SEND_DATA pSendMessage, IN OUT PMESSAGE_REPLY_DATA pReplyMessage)
BOOL __stdcall MessageCallback(IN PMESSAGE_SEND_DATA pSendMessage, IN OUT PMESSAGE_REPLY_DATA pReplyMessage)
void PrintLastErrorMessage(WCHAR *message)
Definition: Tools.cpp:49
void SendConfigInfoToFilter(ULONG FilterType, WCHAR *FilterFolder, ULONG IoRegistration, ULONG AccessFlag, UCHAR *encryptionKey, ULONG keyLength)

Social Network


Services Overview

Architect, implement and test file system filter drivers for a wide range of functionality. We can offer several levels of assistance to meet your specific.

Contact Us

You are welcome to contact us for salse or partnership.

Sales: sales@easefilter.com
Support: support@easefilter.com
Info: info@easefilter.com