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 | if (original_EEHeapAllocInProcessHeap == nullptr) |
32 | __debugbreak(); |
33 | return original_EEHeapAllocInProcessHeap(dwFlags, dwBytes); |
34 | } |
35 | |
36 | BOOL STDMETHODCALLTYPE EEHeapFreeInProcessHeap(DWORD dwFlags, LPVOID lpMem) |
37 | { |
38 | if (original_EEHeapFreeInProcessHeap == nullptr) |
39 | __debugbreak(); |
40 | return original_EEHeapFreeInProcessHeap(dwFlags, lpMem); |
41 | } |
42 | |
43 | void* STDMETHODCALLTYPE GetCLRFunction(LPCSTR functionName) |
44 | { |
45 | if (strcmp(functionName, "EEHeapAllocInProcessHeap") == 0) |
46 | { |
47 | original_EEHeapAllocInProcessHeap = |
48 | (pfnEEHeapAllocInProcessHeap)original_CoreClrCallbacks->m_pfnGetCLRFunction("EEHeapAllocInProcessHeap"); |
49 | return (void*)EEHeapAllocInProcessHeap; |
50 | } |
51 | if (strcmp(functionName, "EEHeapFreeInProcessHeap") == 0) |
52 | { |
53 | original_EEHeapFreeInProcessHeap = |
54 | (pfnEEHeapFreeInProcessHeap)original_CoreClrCallbacks->m_pfnGetCLRFunction("EEHeapFreeInProcessHeap"); |
55 | return (void*)EEHeapFreeInProcessHeap; |
56 | } |
57 | return original_CoreClrCallbacks->m_pfnGetCLRFunction(functionName); |
58 | } |
59 |