-
Notifications
You must be signed in to change notification settings - Fork 1
/
Memory.h
37 lines (31 loc) · 1.03 KB
/
Memory.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#pragma once
#include "framework.h"
class ProcessMemory
{
public:
static ProcessMemory& getInstance()
{
static ProcessMemory instance; // Guaranteed to be destroyed.
// Instantiated on first use.
return instance;
}
private:
ProcessMemory() {
codeHeap = HeapCreate(HEAP_CREATE_ENABLE_EXECUTE, 0, 0);
dataHeap = GetProcessHeap();
} // Constructor? (the {} brackets) are needed here.
// C++ 11
// =======
// We can use the better technique of deleting the methods
// we don't want.
public:
ProcessMemory(ProcessMemory const&) = delete;
void operator=(ProcessMemory const&) = delete;
HANDLE codeHeap = 0;
HANDLE dataHeap = 0;
// Note: Scott Meyers mentions in his Effective Modern
// C++ book, that deleted functions should generally
// be public as it results in better error messages
// due to the compilers behavior to check accessibility
// before deleted status
};