Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit b671864

Browse filesBrowse files
committed
Add project files.
1 parent bf15e72 commit b671864
Copy full SHA for b671864
Expand file treeCollapse file tree

16 files changed

+29520
-0
lines changed
Open diff view settings
Collapse file

‎MemoryModule/MemoryModule.cpp‎

Copy file name to clipboardExpand all lines: MemoryModule/MemoryModule.cpp
+886Lines changed: 886 additions & 0 deletions
Large diffs are not rendered by default.
Collapse file

‎MemoryModule/MemoryModule.h‎

Copy file name to clipboard
+153Lines changed: 153 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,153 @@
1+
#pragma once
2+
3+
#ifndef __MEMORY_MODULE_HEADER
4+
#define __MEMORY_MODULE_HEADER
5+
6+
#include <windows.h>
7+
8+
#pragma warning(disable:4996)
9+
struct ExportNameEntry {
10+
LPCSTR name;
11+
WORD idx;
12+
};
13+
typedef struct {
14+
LPVOID address;
15+
LPVOID alignedAddress;
16+
SIZE_T size;
17+
DWORD characteristics;
18+
BOOL last;
19+
} SECTIONFINALIZEDATA, * PSECTIONFINALIZEDATA;
20+
typedef BOOL(WINAPI* DllEntryProc)(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpReserved);
21+
#ifdef _WIN64
22+
typedef struct POINTER_LIST {
23+
struct POINTER_LIST* next;
24+
void* address;
25+
} POINTER_LIST;
26+
#endif
27+
typedef void* HMEMORYMODULE;
28+
typedef void* HMEMORYRSRC;
29+
typedef struct _MEMORYMODULE {
30+
/*
31+
---------------------------
32+
|xxxxxxxx BaseAddress |
33+
|... |
34+
|... |
35+
|... | --> IMAGE_DOS_HEADER
36+
|... | --> IMAGE_NT_HEADERS
37+
|... |
38+
|... |
39+
--------------------------
40+
struct MEMORYMODULE;
41+
... (align)
42+
codes
43+
*/
44+
ULONG64 Signature;
45+
__declspec(align(sizeof(size_t))) struct {
46+
DWORD SizeofHeaders;
47+
48+
//Not implemented
49+
struct {
50+
union {
51+
//Status Flags
52+
BYTE initialized : 1;
53+
BYTE reservedStatusFlags : 7;
54+
55+
BYTE cbFlagsReserved;
56+
57+
//Load Flags
58+
WORD notMapDll : 1;
59+
WORD notInsertLdrEntry : 1;
60+
WORD notInsertInvertedFunctionTableEntry : 1;
61+
WORD notUseReferenceCount : 1;
62+
WORD reservedLoadFlags : 12;
63+
};
64+
DWORD dwModuleFlags;
65+
};
66+
};
67+
68+
LPBYTE codeBase; //codeBase == ImageBase + OptionalHeader.BaseOfCode;
69+
__declspec(align(sizeof(size_t))) struct {
70+
PVOID lpReserved;
71+
};
72+
73+
HMODULE* hModulesList; //Import module handles
74+
__declspec(align(sizeof(size_t))) struct {
75+
DWORD dwModulesCount; //number of module handles
76+
DWORD dwReserved;
77+
};
78+
79+
ExportNameEntry* nameExportsTable;
80+
__declspec(align(sizeof(size_t))) struct {
81+
DWORD pageSize; //SYSTEM_INFO::dwPageSize
82+
DWORD headers_align; //headers_align == OptionalHeaders.BaseOfCode;
83+
};
84+
85+
#ifdef _WIN64
86+
POINTER_LIST* blockedMemory;
87+
PVOID lpReserved2;
88+
#endif
89+
} MEMORYMODULE, * PMEMORYMODULE;
90+
91+
92+
#define MEMORY_MODULE_SIGNATURE 0x00aabbcc11ffee00
93+
94+
#ifdef __cplusplus
95+
extern "C" {
96+
#endif
97+
98+
/**
99+
* Load DLL from memory location with the given size.
100+
*
101+
* All dependencies are resolved using default LoadLibrary/GetProcAddress
102+
* calls through the Windows API.
103+
*/
104+
HMEMORYMODULE MemoryLoadLibrary(const void*, size_t);
105+
106+
/**
107+
* Get address of exported method. Supports loading both by name and by
108+
* ordinal value.
109+
*/
110+
FARPROC MemoryGetProcAddress(HMEMORYMODULE, LPCSTR);
111+
112+
/**
113+
* Free previously loaded DLL.
114+
*/
115+
bool MemoryFreeLibrary(HMEMORYMODULE);
116+
117+
/**
118+
* Find the location of a resource with the specified type and name.
119+
*/
120+
HMEMORYRSRC MemoryFindResource(HMEMORYMODULE, LPCTSTR, LPCTSTR);
121+
122+
/**
123+
* Find the location of a resource with the specified type, name and language.
124+
*/
125+
HMEMORYRSRC MemoryFindResourceEx(HMEMORYMODULE, LPCTSTR, LPCTSTR, WORD);
126+
127+
/**
128+
* Get the size of the resource in bytes.
129+
*/
130+
DWORD MemorySizeofResource(HMEMORYMODULE, HMEMORYRSRC);
131+
132+
/**
133+
* Get a pointer to the contents of the resource.
134+
*/
135+
LPVOID MemoryLoadResource(HMEMORYMODULE, HMEMORYRSRC);
136+
137+
/**
138+
* Load a string resource.
139+
*/
140+
int MemoryLoadString(HMEMORYMODULE, UINT, LPTSTR, int);
141+
142+
/**
143+
* Load a string resource with a given language.
144+
*/
145+
int MemoryLoadStringEx(HMEMORYMODULE, UINT, LPTSTR, int, WORD);
146+
147+
bool WINAPI IsValidMemoryModuleHandle(HMEMORYMODULE hModule);
148+
149+
#ifdef __cplusplus
150+
}
151+
#endif
152+
153+
#endif // __MEMORY_MODULE_HEADER
Collapse file

‎MemoryModule/MemoryModule.vcxproj‎

Copy file name to clipboard
+176Lines changed: 176 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,176 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<ItemGroup Label="ProjectConfigurations">
4+
<ProjectConfiguration Include="Debug|Win32">
5+
<Configuration>Debug</Configuration>
6+
<Platform>Win32</Platform>
7+
</ProjectConfiguration>
8+
<ProjectConfiguration Include="Release|Win32">
9+
<Configuration>Release</Configuration>
10+
<Platform>Win32</Platform>
11+
</ProjectConfiguration>
12+
<ProjectConfiguration Include="Debug|x64">
13+
<Configuration>Debug</Configuration>
14+
<Platform>x64</Platform>
15+
</ProjectConfiguration>
16+
<ProjectConfiguration Include="Release|x64">
17+
<Configuration>Release</Configuration>
18+
<Platform>x64</Platform>
19+
</ProjectConfiguration>
20+
</ItemGroup>
21+
<ItemGroup>
22+
<ClCompile Include="MemoryModule.cpp" />
23+
<ClCompile Include="Native.cpp" />
24+
<ClCompile Include="NativeFunctionsInternal.cpp" />
25+
</ItemGroup>
26+
<ItemGroup>
27+
<ClInclude Include="MemoryModule.h" />
28+
<ClInclude Include="Native.h" />
29+
<ClInclude Include="NativeFunctionsInternal.h" />
30+
<ClInclude Include="rtltype.h" />
31+
</ItemGroup>
32+
<PropertyGroup Label="Globals">
33+
<VCProjectVersion>16.0</VCProjectVersion>
34+
<ProjectGuid>{5B1F46DB-036E-4A50-AF5F-F5D6584D42C6}</ProjectGuid>
35+
<Keyword>Win32Proj</Keyword>
36+
<RootNamespace>MemoryModule</RootNamespace>
37+
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
38+
<ProjectName>MemoryModule</ProjectName>
39+
</PropertyGroup>
40+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
41+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
42+
<ConfigurationType>StaticLibrary</ConfigurationType>
43+
<UseDebugLibraries>true</UseDebugLibraries>
44+
<PlatformToolset>v142</PlatformToolset>
45+
<CharacterSet>Unicode</CharacterSet>
46+
</PropertyGroup>
47+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
48+
<ConfigurationType>StaticLibrary</ConfigurationType>
49+
<UseDebugLibraries>false</UseDebugLibraries>
50+
<PlatformToolset>v142</PlatformToolset>
51+
<WholeProgramOptimization>true</WholeProgramOptimization>
52+
<CharacterSet>Unicode</CharacterSet>
53+
</PropertyGroup>
54+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
55+
<ConfigurationType>StaticLibrary</ConfigurationType>
56+
<UseDebugLibraries>true</UseDebugLibraries>
57+
<PlatformToolset>v142</PlatformToolset>
58+
<CharacterSet>Unicode</CharacterSet>
59+
</PropertyGroup>
60+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
61+
<ConfigurationType>StaticLibrary</ConfigurationType>
62+
<UseDebugLibraries>false</UseDebugLibraries>
63+
<PlatformToolset>v142</PlatformToolset>
64+
<WholeProgramOptimization>true</WholeProgramOptimization>
65+
<CharacterSet>Unicode</CharacterSet>
66+
</PropertyGroup>
67+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
68+
<ImportGroup Label="ExtensionSettings">
69+
</ImportGroup>
70+
<ImportGroup Label="Shared">
71+
</ImportGroup>
72+
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
73+
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
74+
</ImportGroup>
75+
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
76+
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
77+
</ImportGroup>
78+
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
79+
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
80+
</ImportGroup>
81+
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
82+
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
83+
</ImportGroup>
84+
<PropertyGroup Label="UserMacros" />
85+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
86+
<LinkIncremental>true</LinkIncremental>
87+
</PropertyGroup>
88+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
89+
<LinkIncremental>true</LinkIncremental>
90+
</PropertyGroup>
91+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
92+
<LinkIncremental>false</LinkIncremental>
93+
</PropertyGroup>
94+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
95+
<LinkIncremental>false</LinkIncremental>
96+
</PropertyGroup>
97+
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
98+
<ClCompile>
99+
<PrecompiledHeader>NotUsing</PrecompiledHeader>
100+
<WarningLevel>Level3</WarningLevel>
101+
<SDLCheck>true</SDLCheck>
102+
<PreprocessorDefinitions>WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
103+
<ConformanceMode>true</ConformanceMode>
104+
<PrecompiledHeaderFile>
105+
</PrecompiledHeaderFile>
106+
<PrecompiledHeaderOutputFile />
107+
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
108+
</ClCompile>
109+
<Link>
110+
<SubSystem>Windows</SubSystem>
111+
<GenerateDebugInformation>true</GenerateDebugInformation>
112+
</Link>
113+
</ItemDefinitionGroup>
114+
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
115+
<ClCompile>
116+
<PrecompiledHeader>NotUsing</PrecompiledHeader>
117+
<WarningLevel>Level3</WarningLevel>
118+
<SDLCheck>true</SDLCheck>
119+
<PreprocessorDefinitions>_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
120+
<ConformanceMode>true</ConformanceMode>
121+
<PrecompiledHeaderFile>
122+
</PrecompiledHeaderFile>
123+
<PrecompiledHeaderOutputFile />
124+
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
125+
</ClCompile>
126+
<Link>
127+
<SubSystem>Windows</SubSystem>
128+
<GenerateDebugInformation>true</GenerateDebugInformation>
129+
</Link>
130+
</ItemDefinitionGroup>
131+
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
132+
<ClCompile>
133+
<PrecompiledHeader>NotUsing</PrecompiledHeader>
134+
<WarningLevel>Level3</WarningLevel>
135+
<FunctionLevelLinking>true</FunctionLevelLinking>
136+
<IntrinsicFunctions>true</IntrinsicFunctions>
137+
<SDLCheck>true</SDLCheck>
138+
<PreprocessorDefinitions>WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
139+
<ConformanceMode>true</ConformanceMode>
140+
<PrecompiledHeaderFile>
141+
</PrecompiledHeaderFile>
142+
<PrecompiledHeaderOutputFile />
143+
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
144+
</ClCompile>
145+
<Link>
146+
<SubSystem>Windows</SubSystem>
147+
<EnableCOMDATFolding>true</EnableCOMDATFolding>
148+
<OptimizeReferences>true</OptimizeReferences>
149+
<GenerateDebugInformation>true</GenerateDebugInformation>
150+
</Link>
151+
</ItemDefinitionGroup>
152+
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
153+
<ClCompile>
154+
<PrecompiledHeader>NotUsing</PrecompiledHeader>
155+
<WarningLevel>Level3</WarningLevel>
156+
<FunctionLevelLinking>true</FunctionLevelLinking>
157+
<IntrinsicFunctions>true</IntrinsicFunctions>
158+
<SDLCheck>true</SDLCheck>
159+
<PreprocessorDefinitions>NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
160+
<ConformanceMode>true</ConformanceMode>
161+
<PrecompiledHeaderFile>
162+
</PrecompiledHeaderFile>
163+
<PrecompiledHeaderOutputFile />
164+
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
165+
</ClCompile>
166+
<Link>
167+
<SubSystem>Windows</SubSystem>
168+
<EnableCOMDATFolding>true</EnableCOMDATFolding>
169+
<OptimizeReferences>true</OptimizeReferences>
170+
<GenerateDebugInformation>true</GenerateDebugInformation>
171+
</Link>
172+
</ItemDefinitionGroup>
173+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
174+
<ImportGroup Label="ExtensionTargets">
175+
</ImportGroup>
176+
</Project>
Collapse file
+42Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<ItemGroup>
4+
<Filter Include="Source Files">
5+
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
6+
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
7+
</Filter>
8+
<Filter Include="Header Files">
9+
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
10+
<Extensions>h;hh;hpp;hxx;hm;inl;inc;ipp;xsd</Extensions>
11+
</Filter>
12+
<Filter Include="Resource Files">
13+
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
14+
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
15+
</Filter>
16+
</ItemGroup>
17+
<ItemGroup>
18+
<ClCompile Include="MemoryModule.cpp">
19+
<Filter>Source Files</Filter>
20+
</ClCompile>
21+
<ClCompile Include="Native.cpp">
22+
<Filter>Source Files</Filter>
23+
</ClCompile>
24+
<ClCompile Include="NativeFunctionsInternal.cpp">
25+
<Filter>Source Files</Filter>
26+
</ClCompile>
27+
</ItemGroup>
28+
<ItemGroup>
29+
<ClInclude Include="MemoryModule.h">
30+
<Filter>Header Files</Filter>
31+
</ClInclude>
32+
<ClInclude Include="Native.h">
33+
<Filter>Header Files</Filter>
34+
</ClInclude>
35+
<ClInclude Include="rtltype.h">
36+
<Filter>Header Files</Filter>
37+
</ClInclude>
38+
<ClInclude Include="NativeFunctionsInternal.h">
39+
<Filter>Header Files</Filter>
40+
</ClInclude>
41+
</ItemGroup>
42+
</Project>

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.