WDK Mini Filter Example
ctx/support.c
Go to the documentation of this file.
1 /*++
2 
3 Copyright (c) 1999 - 2002 Microsoft Corporation
4 
5 Module Name:
6 
7  operations.c
8 
9 Abstract:
10 
11  This is the support routines module of the kernel mode filter driver implementing
12  context sample.
13 
14 
15 Environment:
16 
17  Kernel mode
18 
19 
20 --*/
21 
22 
23 
24 #include "pch.h"
25 
26 //
27 // Assign text sections for each routine.
28 //
29 
30 #ifdef ALLOC_PRAGMA
31 #pragma alloc_text(PAGE, CtxAllocateUnicodeString)
32 #pragma alloc_text(PAGE, CtxFreeUnicodeString)
33 #endif
34 
35 //
36 // Support Routines
37 //
38 
39 _At_(String->Length, _Out_range_(==, 0))
40 _At_(String->MaximumLength, _In_)
41 _At_(String->Buffer, _Pre_maybenull_ _Post_notnull_ _Post_writable_byte_size_(String->MaximumLength))
42 NTSTATUS
43 CtxAllocateUnicodeString (
44  _Out_ PUNICODE_STRING String
45  )
46 /*++
47 
48 Routine Description:
49 
50  This routine allocates a unicode string
51 
52 Arguments:
53 
54  String - supplies the size of the string to be allocated in the MaximumLength field
55  return the unicode string
56 
57 Return Value:
58 
59  STATUS_SUCCESS - success
60  STATUS_INSUFFICIENT_RESOURCES - failure
61 
62 --*/
63 {
64  PAGED_CODE();
65 
66  String->Buffer = ExAllocatePoolWithTag( PagedPool,
67  String->MaximumLength,
69 
70  if (String->Buffer == NULL) {
71 
72  DebugTrace( DEBUG_TRACE_ERROR,
73  ("[Ctx]: Failed to allocate unicode string of size 0x%x\n",
74  String->MaximumLength) );
75 
76  return STATUS_INSUFFICIENT_RESOURCES;
77  }
78 
79  String->Length = 0;
80 
81  return STATUS_SUCCESS;
82 }
83 
84 _At_(String->Length, _Out_range_(==, 0))
85 _At_(String->MaximumLength, _Out_range_(==, 0))
86 _At_(String->Buffer, _Pre_notnull_ _Post_null_)
87 VOID
88 CtxFreeUnicodeString (
89  _Pre_notnull_ PUNICODE_STRING String
90  )
91 /*++
92 
93 Routine Description:
94 
95  This routine frees a unicode string
96 
97 Arguments:
98 
99  String - supplies the string to be freed
100 
101 Return Value:
102 
103  None
104 
105 --*/
106 {
107  PAGED_CODE();
108 
109  ExFreePoolWithTag( String->Buffer,
110  CTX_STRING_TAG );
111 
112  String->Length = String->MaximumLength = 0;
113  String->Buffer = NULL;
114 }
115 
116 
117 
_At_(String->Length, _Out_range_(==, 0)) _At_(String -> MaximumLength, _In_) _At_(String->Buffer, _Pre_maybenull_ _Post_notnull_ _Post_writable_byte_size_(String->MaximumLength)) NTSTATUS CtxAllocateUnicodeString(_Out_ PUNICODE_STRING String)
Definition: ctx/support.c:39
#define DebugTrace(Level, Data)
Definition: cancelSafe.c:36
_In_ BOOLEAN _Out_ PFILE_BASIC_INFORMATION Buffer
NcLoadRegistryStringRetry NULL
Definition: ncinit.c:53
PAGED_CODE()
#define CTX_STRING_TAG
Definition: CtxStruc.h:26
OutputString MaximumLength
Definition: ncinit.c:155

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