1 /*++
2 
3 Copyright (c) Microsoft Corporation
4 
5 Module Name:
6 
7     FxAutoString.hpp
8 
9 Abstract:
10 
11     This is the C++ header for FxAutoString which represents a UNICODE_STRING
12     and follows the RAII (resource acquisiion is initialization) pattern where
13     it frees the buffer when the struct goes out of scope.
14 
15 Author:
16 
17 
18 
19 Revision History:
20 
21 
22 
23 --*/
24 
25 #ifndef _FXAUTOSTRING_H_
26 #define _FXAUTOSTRING_H_
27 
28 struct FxAutoString {
29     FxAutoString(
30         VOID
31         )
32     {
33         RtlZeroMemory(&m_UnicodeString, sizeof(m_UnicodeString));
34     }
35 
36     ~FxAutoString(
37         VOID
38         )
39     {
40         if (m_UnicodeString.Buffer != NULL) {
41 #if _WDFLDR_
42             ExFreePool(m_UnicodeString.Buffer);
43 #else
44             FxPoolFree(m_UnicodeString.Buffer);
45 #endif
46             RtlZeroMemory(&m_UnicodeString, sizeof(m_UnicodeString));
47         }
48     }
49 
50     UNICODE_STRING m_UnicodeString;
51 };
52 
53 #endif // _FXAUTOSTRING_H_
54