Skip to content

Commit d7dfd3e

Browse files
authored
Merge branch 'master' into master
2 parents d53fc95 + b89bbfd commit d7dfd3e

20 files changed

+454
-273
lines changed

NativeCore/Windows/EnumerateProcesses.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
#include <windows.h>
22
#include <tlhelp32.h>
33
#include <psapi.h>
4-
#include <experimental/filesystem>
5-
namespace fs = std::experimental::filesystem;
4+
#include <filesystem>
65

76
#include "NativeCore.hpp"
87

@@ -73,7 +72,7 @@ void RC_CallConv EnumerateProcesses(EnumerateProcessCallback callbackProcess)
7372
EnumerateProcessData data = { };
7473
data.Id = pe32.th32ProcessID;
7574
GetModuleFileNameExW(process, nullptr, reinterpret_cast<LPWSTR>(data.Path), PATH_MAXIMUM_LENGTH);
76-
const auto name = fs::path(data.Path).filename().u16string();
75+
const auto name = std::filesystem::path(data.Path).filename().u16string();
7776
str16cpy(data.Name, name.c_str(), std::min<size_t>(name.length(), PATH_MAXIMUM_LENGTH - 1));
7877

7978
callbackProcess(&data);

NativeCore/Windows/EnumerateRemoteSectionsAndModules.cpp

Lines changed: 25 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -192,26 +192,31 @@ void RC_CallConv EnumerateRemoteSectionsAndModules(RC_Pointer process, Enumerate
192192
const auto sectionAddress = reinterpret_cast<size_t>(data->BaseAddress) + sectionHeader.VirtualAddress;
193193
for (auto j = it; j != std::end(sections); ++j)
194194
{
195-
if (sectionAddress >= reinterpret_cast<size_t>(j->BaseAddress) && sectionAddress < reinterpret_cast<size_t>(j->BaseAddress) + static_cast<size_t>(j->Size))
196-
{
197-
// Copy the name because it is not null padded.
198-
char buffer[IMAGE_SIZEOF_SHORT_NAME + 1] = { 0 };
199-
std::memcpy(buffer, sectionHeader.Name, IMAGE_SIZEOF_SHORT_NAME);
200-
201-
if (std::strcmp(buffer, ".text") == 0 || std::strcmp(buffer, "code") == 0)
202-
{
203-
j->Category = SectionCategory::CODE;
204-
}
205-
else if (std::strcmp(buffer, ".data") == 0 || std::strcmp(buffer, "data") == 0 || std::strcmp(buffer, ".rdata") == 0 || std::strcmp(buffer, ".idata") == 0)
206-
{
207-
j->Category = SectionCategory::DATA;
208-
}
209-
210-
MultiByteToUnicode(buffer, j->Name, IMAGE_SIZEOF_SHORT_NAME);
211-
std::memcpy(j->ModulePath, data->Path, std::min(MAX_PATH, PATH_MAXIMUM_LENGTH));
212-
213-
break;
214-
}
195+
if (sectionAddress >= reinterpret_cast<size_t>(j->BaseAddress)
196+
&& sectionAddress < reinterpret_cast<size_t>(j->BaseAddress) + static_cast<size_t>(j->Size)
197+
&& sectionHeader.VirtualAddress + sectionHeader.Misc.VirtualSize <= me32.modBaseSize )
198+
{
199+
if ((sectionHeader.Characteristics & IMAGE_SCN_CNT_CODE) == IMAGE_SCN_CNT_CODE)
200+
{
201+
j->Category = SectionCategory::CODE;
202+
}
203+
else if (sectionHeader.Characteristics & (IMAGE_SCN_CNT_INITIALIZED_DATA | IMAGE_SCN_CNT_UNINITIALIZED_DATA))
204+
{
205+
j->Category = SectionCategory::DATA;
206+
}
207+
208+
try {
209+
// Copy the name because it is not null padded.
210+
char buffer[IMAGE_SIZEOF_SHORT_NAME + 1] = { 0 };
211+
std::memcpy(buffer, sectionHeader.Name, IMAGE_SIZEOF_SHORT_NAME);
212+
MultiByteToUnicode(buffer, j->Name, IMAGE_SIZEOF_SHORT_NAME);
213+
} catch (std::range_error &) {
214+
std::memset(j->Name, 0, sizeof j->Name);
215+
}
216+
std::memcpy(j->ModulePath, me32.szExePath, std::min(MAX_PATH, PATH_MAXIMUM_LENGTH));
217+
218+
break;
219+
}
215220
}
216221

217222
}

NativeCore/Windows/NativeCore.vcxproj

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,8 @@
103103
</PrecompiledHeader>
104104
<WarningLevel>Level3</WarningLevel>
105105
<Optimization>Disabled</Optimization>
106-
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;NATIVECORE_EXPORTS;_CRT_SECURE_NO_WARNINGS;NOMINMAX;RECLASSNET32;%(PreprocessorDefinitions)</PreprocessorDefinitions>
106+
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;NATIVECORE_EXPORTS;_CRT_SECURE_NO_WARNINGS;NOMINMAX;RECLASSNET32;_SILENCE_CXX17_CODECVT_HEADER_DEPRECATION_WARNING;%(PreprocessorDefinitions)</PreprocessorDefinitions>
107+
<LanguageStandard>stdcpp17</LanguageStandard>
107108
</ClCompile>
108109
<Link>
109110
<SubSystem>Windows</SubSystem>
@@ -118,7 +119,8 @@
118119
</PrecompiledHeader>
119120
<WarningLevel>Level3</WarningLevel>
120121
<Optimization>Disabled</Optimization>
121-
<PreprocessorDefinitions>_DEBUG;_WINDOWS;_USRDLL;NATIVECORE_EXPORTS;_CRT_SECURE_NO_WARNINGS;NOMINMAX;RECLASSNET64;%(PreprocessorDefinitions)</PreprocessorDefinitions>
122+
<PreprocessorDefinitions>_DEBUG;_WINDOWS;_USRDLL;NATIVECORE_EXPORTS;_CRT_SECURE_NO_WARNINGS;NOMINMAX;RECLASSNET64;_SILENCE_CXX17_CODECVT_HEADER_DEPRECATION_WARNING;%(PreprocessorDefinitions)</PreprocessorDefinitions>
123+
<LanguageStandard>stdcpp17</LanguageStandard>
122124
</ClCompile>
123125
<Link>
124126
<SubSystem>Windows</SubSystem>
@@ -135,7 +137,8 @@
135137
<Optimization>MaxSpeed</Optimization>
136138
<FunctionLevelLinking>true</FunctionLevelLinking>
137139
<IntrinsicFunctions>true</IntrinsicFunctions>
138-
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;NATIVECORE_EXPORTS;_CRT_SECURE_NO_WARNINGS;NOMINMAX;RECLASSNET32;%(PreprocessorDefinitions)</PreprocessorDefinitions>
140+
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;NATIVECORE_EXPORTS;_CRT_SECURE_NO_WARNINGS;NOMINMAX;RECLASSNET32;_SILENCE_CXX17_CODECVT_HEADER_DEPRECATION_WARNING;%(PreprocessorDefinitions)</PreprocessorDefinitions>
141+
<LanguageStandard>stdcpp17</LanguageStandard>
139142
</ClCompile>
140143
<Link>
141144
<SubSystem>Windows</SubSystem>
@@ -154,7 +157,8 @@
154157
<Optimization>MaxSpeed</Optimization>
155158
<FunctionLevelLinking>true</FunctionLevelLinking>
156159
<IntrinsicFunctions>true</IntrinsicFunctions>
157-
<PreprocessorDefinitions>NDEBUG;_WINDOWS;_USRDLL;NATIVECORE_EXPORTS;_CRT_SECURE_NO_WARNINGS;NOMINMAX;RECLASSNET64;%(PreprocessorDefinitions)</PreprocessorDefinitions>
160+
<PreprocessorDefinitions>NDEBUG;_WINDOWS;_USRDLL;NATIVECORE_EXPORTS;_CRT_SECURE_NO_WARNINGS;NOMINMAX;RECLASSNET64;_SILENCE_CXX17_CODECVT_HEADER_DEPRECATION_WARNING;%(PreprocessorDefinitions)</PreprocessorDefinitions>
161+
<LanguageStandard>stdcpp17</LanguageStandard>
158162
</ClCompile>
159163
<Link>
160164
<SubSystem>Windows</SubSystem>

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ This is a port of ReClass to the .NET platform with lots of additional features.
5353
- [LoadBinary Plugin](https://github.com/ReClassNET/ReClass.NET-LoadBinaryPlugin)
5454
- [Handle Abuser Plugin](https://github.com/ReClassNET/ReClass.NET-HandleAbuser)
5555
- [Unreal Plugin](https://github.com/DrP3pp3r/ReClass.NET-UnrealPlugin) (by [DrP3pp3r](https://github.com/DrP3pp3r))
56+
- [DriverReader](https://github.com/niemand-sec/ReClass.NET-DriverReader) (by [Niemand](https://github.com/niemand-sec))
5657

5758
To install a plugin just copy it in the "Plugins" folder.
5859
If you want to develop your own plugin just learn from the code of the [Sample Plugins](https://github.com/ReClassNET/ReClass.NET-SamplePlugin) and [Frostbite Plugin](https://github.com/ReClassNET/ReClass.NET-FrostbitePlugin) repositories. If you have developed a nice plugin, leave me a message and I will add it to the list above.
@@ -118,4 +119,4 @@ Settings
118119
- leveln
119120
- [buddyfavors](https://github.com/buddyfavors)
120121
- [DrP3pp3r](https://github.com/DrP3pp3r)
121-
- [ko1N](https://github.com/ko1N)
122+
- [ko1N](https://github.com/ko1N)

ReClass.NET/CodeGenerator/CSharpCodeGenerator.cs

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System;
1+
using System;
22
using System.CodeDom.Compiler;
33
using System.Collections.Generic;
44
using System.Diagnostics.Contracts;
@@ -32,8 +32,12 @@ public class CSharpCodeGenerator : ICodeGenerator
3232
[typeof(Utf16TextPtrNode)] = "IntPtr",
3333
[typeof(Utf32TextPtrNode)] = "IntPtr",
3434
[typeof(PointerNode)] = "IntPtr",
35-
[typeof(VirtualMethodTableNode)] = "IntPtr"
36-
};
35+
[typeof(VirtualMethodTableNode)] = "IntPtr",
36+
37+
[typeof(Vector2Node)] = "Vector2",
38+
[typeof(Vector3Node)] = "Vector3",
39+
[typeof(Vector4Node)] = "Vector4"
40+
};
3741

3842
public Language Language => Language.CSharp;
3943

@@ -48,6 +52,9 @@ public string GenerateCode(IReadOnlyList<ClassNode> classes, IReadOnlyList<EnumD
4852
iw.WriteLine("// Warning: The C# code generator doesn't support all node types!");
4953
iw.WriteLine();
5054
iw.WriteLine("using System.Runtime.InteropServices;");
55+
56+
iw.WriteLine("// optional namespace, only for vectors");
57+
iw.WriteLine("using System.Numerics;");
5158
iw.WriteLine();
5259

5360
using (var en = enums.GetEnumerator())
@@ -149,7 +156,7 @@ private static void WriteClass(IndentedTextWriter writer, ClassNode @class, ILog
149156
Contract.Requires(logger != null);
150157

151158
writer.WriteLine("[StructLayout(LayoutKind.Explicit)]");
152-
writer.Write("class ");
159+
writer.Write("public struct ");
153160
writer.Write(@class.Name);
154161

155162
if (!string.IsNullOrEmpty(@class.Comment))
@@ -170,16 +177,7 @@ private static void WriteClass(IndentedTextWriter writer, ClassNode @class, ILog
170177
var type = GetTypeDefinition(node);
171178
if (type != null)
172179
{
173-
writer.Write("[FieldOffset(");
174-
writer.Write(node.Offset);
175-
writer.WriteLine(")]");
176-
177-
writer.Write("public ");
178-
writer.Write(type);
179-
writer.Write(" ");
180-
writer.Write(node.Name);
181-
writer.Write("; //0x");
182-
writer.Write($"{node.Offset:X04}");
180+
writer.Write($"[FieldOffset(0x{node.Offset:X})] public readonly {type} {node.Name};");
183181
if (!string.IsNullOrEmpty(node.Comment))
184182
{
185183
writer.Write(" ");

0 commit comments

Comments
 (0)