forked from zouxianyu/KernelHiddenExecute
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdlcommon.cpp
More file actions
62 lines (47 loc) · 1.78 KB
/
dlcommon.cpp
File metadata and controls
62 lines (47 loc) · 1.78 KB
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/*
This file is part of driver-loader
Copyright (C) 2017 @maldevel
driver-loader - Load a Windows Kernel Driver.
https://github.com/maldevel/driver-loader
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
For more see the file 'LICENSE' for copying permission.
*/
#include "dlcommon.h"
#include <QDebug>
static HANDLE processHeap;
//retrieve a handle to the default heap of this process
void Common::init(void) {
processHeap = GetProcessHeap();
}
//HeapAlloc wrapper
//allocate a block of memory from a heap
void *Common::hAlloc(SIZE_T size) {
if (processHeap == NULL || size <= 0) return NULL;
return HeapAlloc(processHeap, HEAP_ZERO_MEMORY, size);
}
//HeapReAlloc wrapper
void *Common::hReAlloc(void *mem, SIZE_T size) {
if (processHeap == NULL || mem == NULL || size <= 0) return NULL;
return HeapReAlloc(processHeap, HEAP_ZERO_MEMORY, mem, size);
}
//free a memory block allocated from a heap by the HeapAlloc
void Common::hFree(void *mem) {
if (processHeap == NULL || mem == NULL) return;
HeapFree(processHeap, 0, mem);
mem = NULL;
}
void Common::ConsoleLog(QString log) {
if (log == NULL) return;
if (DEBUG) {
qDebug() << log;
}
}