1//
2// Copyright (c) Microsoft. All rights reserved.
3// Licensed under the MIT license. See LICENSE file in the project root for full license information.
4//
5
6#ifndef _IEEMemoryManager
7#define _IEEMemoryManager
8
9#include "runtimedetails.h"
10
11/*
12interface IEEMemoryManager : IUnknown
13{
14 LPVOID ClrVirtualAlloc(
15 [in] LPVOID lpAddress, // region to reserve or commit
16 [in] SIZE_T dwSize, // size of region
17 [in] DWORD flAllocationType, // type of allocation
18 [in] DWORD flProtect // type of access protection
19 )
20
21 BOOL ClrVirtualFree(
22 [in] LPVOID lpAddress, // address of region
23 [in] SIZE_T dwSize, // size of region
24 [in] DWORD dwFreeType // operation type
25 )
26
27 SIZE_T ClrVirtualQuery(
28 [in] const void* lpAddress, // address of region
29 [in] PMEMORY_BASIC_INFORMATION lpBuffer, // information buffer
30 [in] SIZE_T dwLength // size of buffer
31 )
32
33 BOOL ClrVirtualProtect(
34 [in] LPVOID lpAddress, // region of committed pages
35 [in] SIZE_T dwSize, // size of the region
36 [in] DWORD flNewProtect, // desired access protection
37 [in] DWORD* lpflOldProtect // old protection
38 )
39
40 HANDLE ClrGetProcessHeap()
41
42 HANDLE ClrHeapCreate(
43 [in] DWORD flOptions, // heap allocation attributes
44 [in] SIZE_T dwInitialSize, // initial heap size
45 [in] SIZE_T dwMaximumSize // maximum heap size
46 )
47
48 BOOL ClrHeapDestroy(
49 [in] HANDLE hHeap // handle to heap
50 )
51
52 LPVOID ClrHeapAlloc(
53 [in] HANDLE hHeap, // handle to private heap block
54 [in] DWORD dwFlags, // heap allocation control
55 [in] SIZE_T dwBytes // number of bytes to allocate
56 )
57
58 BOOL ClrHeapFree(
59 [in] HANDLE hHeap, // handle to heap
60 [in] DWORD dwFlags, // heap free options
61 [in] LPVOID lpMem // pointer to memory
62 )
63
64 BOOL ClrHeapValidate(
65 [in] HANDLE hHeap, // handle to heap
66 [in] DWORD dwFlags, // heap access options
67 [in] const void* lpMem // optional pointer to memory block
68 )
69
70 HANDLE ClrGetProcessExecutableHeap()
71
72}; // interface IEEMemoryManager
73
74*/
75
76class interceptor_IEEMM : public IEEMemoryManager
77{
78private:
79 //***************************************************************************
80 // IUnknown methods
81 //***************************************************************************
82
83 HRESULT STDMETHODCALLTYPE QueryInterface(REFIID id, void** pInterface);
84 ULONG STDMETHODCALLTYPE AddRef();
85 ULONG STDMETHODCALLTYPE Release();
86
87 //***************************************************************************
88 // IEEMemoryManager methods for locking
89 //***************************************************************************
90 LPVOID STDMETHODCALLTYPE ClrVirtualAlloc(LPVOID lpAddress, SIZE_T dwSize, DWORD flAllocationType, DWORD flProtect);
91 BOOL STDMETHODCALLTYPE ClrVirtualFree(LPVOID lpAddress, SIZE_T dwSize, DWORD dwFreeType);
92 SIZE_T STDMETHODCALLTYPE ClrVirtualQuery(LPCVOID lpAddress, PMEMORY_BASIC_INFORMATION lpBuffer, SIZE_T dwLength);
93 BOOL STDMETHODCALLTYPE ClrVirtualProtect(LPVOID lpAddress,
94 SIZE_T dwSize,
95 DWORD flNewProtect,
96 PDWORD lpflOldProtect);
97 HANDLE STDMETHODCALLTYPE ClrGetProcessHeap();
98 HANDLE STDMETHODCALLTYPE ClrHeapCreate(DWORD flOptions, SIZE_T dwInitialSize, SIZE_T dwMaximumSize);
99 BOOL STDMETHODCALLTYPE ClrHeapDestroy(HANDLE hHeap);
100 LPVOID STDMETHODCALLTYPE ClrHeapAlloc(HANDLE hHeap, DWORD dwFlags, SIZE_T dwBytes);
101 BOOL STDMETHODCALLTYPE ClrHeapFree(HANDLE hHeap, DWORD dwFlags, LPVOID lpMem);
102 BOOL STDMETHODCALLTYPE ClrHeapValidate(HANDLE hHeap, DWORD dwFlags, LPCVOID lpMem);
103 HANDLE STDMETHODCALLTYPE ClrGetProcessExecutableHeap();
104
105public:
106 // Added so we know where to make the real calls to.
107 IEEMemoryManager* original_IEEMM;
108};
109
110#endif
111