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 | #include "standardpch.h" |
7 | #include "coreclrcallbacks.h" |
8 | #include "iexecutionengine.h" |
9 | |
10 | CoreClrCallbacks* original_CoreClrCallbacks = nullptr; |
11 | pfnEEHeapAllocInProcessHeap original_EEHeapAllocInProcessHeap = nullptr; |
12 | pfnEEHeapFreeInProcessHeap original_EEHeapFreeInProcessHeap = nullptr; |
13 | |
14 | IExecutionEngine* STDMETHODCALLTYPE IEE_t() |
15 | { |
16 | interceptor_IEE* iee = new interceptor_IEE(); |
17 | iee->original_IEE = original_CoreClrCallbacks->m_pfnIEE(); |
18 | return iee; |
19 | } |
20 | |
21 | /*#pragma warning( suppress :4996 ) //deprecated |
22 | HRESULT STDMETHODCALLTYPE GetCORSystemDirectory(LPWSTR pbuffer, DWORD cchBuffer, DWORD* pdwlength) |
23 | { |
24 | DebugBreakorAV(131); |
25 | return 0; |
26 | } |
27 | */ |
28 | |
29 | LPVOID STDMETHODCALLTYPE EEHeapAllocInProcessHeap(DWORD dwFlags, SIZE_T dwBytes) |
30 | { |
31 | return original_EEHeapAllocInProcessHeap(dwFlags, dwBytes); |
32 | } |
33 | |
34 | BOOL STDMETHODCALLTYPE EEHeapFreeInProcessHeap(DWORD dwFlags, LPVOID lpMem) |
35 | { |
36 | return original_EEHeapFreeInProcessHeap(dwFlags, lpMem); |
37 | } |
38 | |
39 | void* STDMETHODCALLTYPE GetCLRFunction(LPCSTR functionName) |
40 | { |
41 | if (strcmp(functionName, "EEHeapAllocInProcessHeap") == 0) |
42 | { |
43 | original_EEHeapAllocInProcessHeap = |
44 | (pfnEEHeapAllocInProcessHeap)original_CoreClrCallbacks->m_pfnGetCLRFunction("EEHeapAllocInProcessHeap"); |
45 | return (void*)EEHeapAllocInProcessHeap; |
46 | } |
47 | if (strcmp(functionName, "EEHeapFreeInProcessHeap") == 0) |
48 | { |
49 | original_EEHeapFreeInProcessHeap = |
50 | (pfnEEHeapFreeInProcessHeap)original_CoreClrCallbacks->m_pfnGetCLRFunction("EEHeapFreeInProcessHeap"); |
51 | return (void*)EEHeapFreeInProcessHeap; |
52 | } |
53 | return original_CoreClrCallbacks->m_pfnGetCLRFunction(functionName); |
54 | } |
55 |