WDK Mini Filter Example
user/avscan.c
Go to the documentation of this file.
1 /*++
2 
3 Copyright (c) 2011 Microsoft Corporation
4 
5 Module Name:
6 
7  avscan.c
8 
9 Abstract:
10 
11  The user space anti-virus scanner. It is the entry point of
12  the user program.
13 
14  In its initialization, it forks scan listening threads and
15  run a couple of unit tests and wait for a user input.
16 
17  Before the user types 'q' to quit this program, the scan
18  threads will continue to work.
19 
20 Environment:
21 
22  User mode
23 
24 --*/
25 
26 #include <windows.h>
27 #include <stdio.h>
28 #include <fltUser.h>
29 #include "utility.h"
30 #include "avlib.h"
31 #include "userscan.h"
32 
33 int _cdecl
35  _Unreferenced_parameter_ int argc,
36  _Unreferenced_parameter_ char *argv[]
37  )
38 /*++
39 
40 Routine Description:
41 
42  Entry main function of the user space program.
43 
44 Arguments:
45 
46  argc - The number of arguments
47  argv - The arguments
48 
49 Return Value:
50 
51  0 - No error occurs.
52  255 - Error occurs.
53 
54 --*/
55 {
56 
57  UCHAR c;
58  HRESULT hr = S_OK;
59  USER_SCAN_CONTEXT userScanCtx = {0};
60 
61  UNREFERENCED_PARAMETER( argc );
62  UNREFERENCED_PARAMETER( argv );
63 
64 
65  //
66  // Initialize scan listening threads.
67  //
68 
69  hr = UserScanInit(&userScanCtx);
70  if (FAILED(hr)) {
71  fprintf(stderr, "Failed to initialize user scan data\n");
72  DisplayError( hr );
73  return 255;
74  }
75 
76  //
77  // Read user's input until it reads 'q'
78  //
79 
80  for(;;) {
81 
82  printf("press 'q' to quit: ");
83  c = (unsigned char) getchar();
84  if (c == 'q') {
85 
86  break;
87  }
88  }
89 
90  //
91  // Finalize the scan thread contexts.
92  //
93 
94  hr = UserScanFinalize(&userScanCtx);
95  if (FAILED(hr)) {
96  fprintf(stderr, "Failed to finalize the user scan data.\n");
97  }
98 
99  return 0;
100 }
101 
HRESULT UserScanFinalize(_In_ PUSER_SCAN_CONTEXT Context)
Definition: userscan.c:362
UNREFERENCED_PARAMETER(FileObject)
int _cdecl main(_Unreferenced_parameter_ int argc, _Unreferenced_parameter_ char *argv[])
Definition: user/avscan.c:34
HRESULT UserScanInit(_Inout_ PUSER_SCAN_CONTEXT Context)
Definition: userscan.c:138
VOID DisplayError(_In_ DWORD Code)
Definition: user/utility.c:26

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