-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDLL.h
More file actions
43 lines (39 loc) · 1.57 KB
/
Copy pathDLL.h
File metadata and controls
43 lines (39 loc) · 1.57 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
///----------------------------------------------------------------------------------------------------
/// Copyright (c) Raidcore.GG - All rights reserved.
///
/// Name : DLL.h
/// Description : Contains functions for DLLs.
/// Authors : K. Bieniek
///----------------------------------------------------------------------------------------------------
#pragma once
#include <windows.h>
///----------------------------------------------------------------------------------------------------
/// GetCurrentModule:
/// Returns the module handle of the current module.
///----------------------------------------------------------------------------------------------------
inline HMODULE GetCurrentModule()
{
HMODULE h = nullptr;
GetModuleHandleExA(
GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS,
(LPCSTR)&GetCurrentModule,
&h
);
return h;
}
///----------------------------------------------------------------------------------------------------
/// DLL Namespace
///----------------------------------------------------------------------------------------------------
namespace DLL
{
///----------------------------------------------------------------------------------------------------
/// FindFunction:
/// Returns true if the function was found and writes it to aFunction.
///----------------------------------------------------------------------------------------------------
inline bool FindFunction(HMODULE aModule, LPVOID aFunction, LPCSTR aName)
{
FARPROC* fp = (FARPROC*)aFunction;
*fp = aModule ? GetProcAddress(aModule, aName) : 0;
return (*fp != 0);
}
}