-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathCodeCave.h
More file actions
36 lines (25 loc) · 798 Bytes
/
CodeCave.h
File metadata and controls
36 lines (25 loc) · 798 Bytes
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
#pragma once
#include <Windows.h>
#include <vector>
#include <memory>
#define MEMORY_SEARCH_RANGE 256 * 1024 * 1024 // 256 MB
#define DEFAULT_WIN_PAGE_ALLOC_SIZE 0x1000
#define CC_SUCCESS 0x00;
#define CC_QUERY_FAILED 0x01;
#define CC_ALLOC_FAILED 0x02;
#define CC_CAVE_NOT_FOUND 0x03;
typedef PBYTE MEMORY_PAGE;
// TODO support 32 bit
typedef struct CodeCave {
MEMORY_PAGE pCaveBase;
UINT64 uLen;
UINT64 uUsed;
} CodeCave, *PCodeCave;
typedef class CodeCaveManager {
private:
std::vector<CodeCave> vecCaves;
public:
~CodeCaveManager();
DWORD FindCodeCave(_In_ PVOID pSearchBase, _In_ UINT64 uNeededBytes, _Inout_ PCodeCave pCodeCave);
} CodeCaveManager, *PCodeCaveManager;
inline std::unique_ptr<CodeCaveManager> instCCManager = std::make_unique<CodeCaveManager>();