mirror of
https://github.com/orange-cpp/omath.git
synced 2026-02-13 15:03:27 +00:00
Compare commits
40 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 086eda4ee3 | |||
| 9419e390da | |||
| d919600ac2 | |||
| 11681ac601 | |||
| 6c5152297a | |||
| 547f64e4c4 | |||
| 3129e32f0c | |||
| 72b54e9673 | |||
| 2ff291b255 | |||
| 8eda1ce4bc | |||
| e1b4375621 | |||
| d84259fdcc | |||
| d64c7ad756 | |||
| 710f91999f | |||
| f3fe0e3cee | |||
| c5c5c2e972 | |||
| a7cb056ce7 | |||
| dae1555ec4 | |||
| 2c6ef1b8cc | |||
| d70e8853e8 | |||
| e35d64b486 | |||
| 9868c832a1 | |||
| 42e46f9921 | |||
| e7ccc2ead0 | |||
| 170f969697 | |||
| 131fd891b0 | |||
| a5396b72cb | |||
| ec876ea292 | |||
| 8021050fad | |||
| bd585b5412 | |||
| 06f9a8c9ee | |||
| 160b51da94 | |||
| 064edf9ef1 | |||
| f17d36dcd3 | |||
| ec4f9f6c90 | |||
| cbee8c2c95 | |||
| dc6edbb67f | |||
| 74381eda5c | |||
| 1ef7833bd9 | |||
| c10386f3f6 |
4
.idea/editor.xml
generated
4
.idea/editor.xml
generated
@@ -201,7 +201,7 @@
|
||||
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppStaticDataMemberInUnnamedStruct/@EntryIndexedValue" value="WARNING" type="string" />
|
||||
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppStaticSpecifierOnAnonymousNamespaceMember/@EntryIndexedValue" value="SUGGESTION" type="string" />
|
||||
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppStringLiteralToCharPointerConversion/@EntryIndexedValue" value="WARNING" type="string" />
|
||||
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppTabsAreDisallowed/@EntryIndexedValue" value="WARNING" type="string" />
|
||||
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppTabsAreDisallowed/@EntryIndexedValue" value="DO_NOT_SHOW" type="string" />
|
||||
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppTemplateArgumentsCanBeDeduced/@EntryIndexedValue" value="HINT" type="string" />
|
||||
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppTemplateParameterNeverUsed/@EntryIndexedValue" value="HINT" type="string" />
|
||||
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppTemplateParameterShadowing/@EntryIndexedValue" value="WARNING" type="string" />
|
||||
@@ -215,7 +215,7 @@
|
||||
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppUnmatchedPragmaEndRegionDirective/@EntryIndexedValue" value="WARNING" type="string" />
|
||||
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppUnmatchedPragmaRegionDirective/@EntryIndexedValue" value="WARNING" type="string" />
|
||||
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppUnnamedNamespaceInHeaderFile/@EntryIndexedValue" value="WARNING" type="string" />
|
||||
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppUnnecessaryWhitespace/@EntryIndexedValue" value="WARNING" type="string" />
|
||||
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppUnnecessaryWhitespace/@EntryIndexedValue" value="DO_NOT_SHOW" type="string" />
|
||||
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppUnsignedZeroComparison/@EntryIndexedValue" value="WARNING" type="string" />
|
||||
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppUnusedIncludeDirective/@EntryIndexedValue" value="WARNING" type="string" />
|
||||
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppUseAlgorithmWithCount/@EntryIndexedValue" value="SUGGESTION" type="string" />
|
||||
|
||||
@@ -59,7 +59,7 @@ target("...")
|
||||
cmake --preset windows-release -S .
|
||||
cmake --build cmake-build/build/windows-release --target omath -j 6
|
||||
```
|
||||
Use **\<platform\>-\<build configuration\>** preset to build siutable version for yourself. Like **windows-release** or **linux-release**.
|
||||
Use **\<platform\>-\<build configuration\>** preset to build suitable version for yourself. Like **windows-release** or **linux-release**.
|
||||
|
||||
| Platform Name | Build Config |
|
||||
|---------------|---------------|
|
||||
|
||||
1
LICENSE
1
LICENSE
@@ -20,6 +20,7 @@ freely, subject to the following restrictions:
|
||||
with any of the following entities:
|
||||
* "Yandex" LLC
|
||||
* "Rutube" LLC
|
||||
* "Kaspersky" LLC
|
||||
Or if you represent or are associated with any legal, organizational, or
|
||||
professional entity providing services to or on behalf of the aforementioned entities:
|
||||
You are expressly forbidden from accessing, using, modifying, distributing, or
|
||||
|
||||
17
docs/index.md
Normal file
17
docs/index.md
Normal file
@@ -0,0 +1,17 @@
|
||||
# Welcome to MkDocs
|
||||
|
||||
For full documentation visit [mkdocs.org](https://www.mkdocs.org).
|
||||
|
||||
## Commands
|
||||
|
||||
* `mkdocs new [dir-name]` - Create a new project.
|
||||
* `mkdocs serve` - Start the live-reloading docs server.
|
||||
* `mkdocs build` - Build the documentation site.
|
||||
* `mkdocs -h` - Print help message and exit.
|
||||
|
||||
## Project layout
|
||||
|
||||
mkdocs.yml # The configuration file.
|
||||
docs/
|
||||
index.md # The documentation homepage.
|
||||
... # Other markdown pages, images and other files.
|
||||
@@ -3,8 +3,8 @@
|
||||
//
|
||||
|
||||
#pragma once
|
||||
#include "omath/linear_algebra/triangle.hpp"
|
||||
#include "omath/linear_algebra/vector3.hpp"
|
||||
#include "omath/triangle.hpp"
|
||||
#include <array>
|
||||
|
||||
namespace omath::primitives
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
//
|
||||
|
||||
#pragma once
|
||||
#include "omath/linear_algebra/triangle.hpp"
|
||||
#include "omath/linear_algebra/vector3.hpp"
|
||||
#include "omath/triangle.hpp"
|
||||
#include <array>
|
||||
|
||||
namespace omath::primitives
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
//
|
||||
#pragma once
|
||||
|
||||
#include "omath/linear_algebra/triangle.hpp"
|
||||
#include "omath/linear_algebra/vector3.hpp"
|
||||
#include "omath/triangle.hpp"
|
||||
|
||||
namespace omath::collision
|
||||
{
|
||||
|
||||
@@ -5,8 +5,8 @@
|
||||
#pragma once
|
||||
#include "omath/linear_algebra/mat.hpp"
|
||||
#include "omath/linear_algebra/vector3.hpp"
|
||||
#include <omath/angle.hpp>
|
||||
#include <omath/view_angles.hpp>
|
||||
#include <omath/trigonometry/angle.hpp>
|
||||
#include <omath/trigonometry/view_angles.hpp>
|
||||
|
||||
namespace omath::iw_engine
|
||||
{
|
||||
|
||||
@@ -5,8 +5,8 @@
|
||||
|
||||
#include "omath/linear_algebra/mat.hpp"
|
||||
#include "omath/linear_algebra/vector3.hpp"
|
||||
#include <omath/angle.hpp>
|
||||
#include <omath/view_angles.hpp>
|
||||
#include <omath/trigonometry/angle.hpp>
|
||||
#include <omath/trigonometry/view_angles.hpp>
|
||||
|
||||
namespace omath::opengl_engine
|
||||
{
|
||||
|
||||
@@ -5,8 +5,8 @@
|
||||
|
||||
#include "omath/linear_algebra/mat.hpp"
|
||||
#include "omath/linear_algebra/vector3.hpp"
|
||||
#include <omath/angle.hpp>
|
||||
#include <omath/view_angles.hpp>
|
||||
#include <omath/trigonometry/angle.hpp>
|
||||
#include <omath/trigonometry/view_angles.hpp>
|
||||
|
||||
namespace omath::source_engine
|
||||
{
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
|
||||
#include "omath/linear_algebra/mat.hpp"
|
||||
#include "omath/linear_algebra/vector3.hpp"
|
||||
#include <omath/angle.hpp>
|
||||
#include <omath/view_angles.hpp>
|
||||
#include <omath/trigonometry/angle.hpp>
|
||||
#include <omath/trigonometry/view_angles.hpp>
|
||||
|
||||
namespace omath::unity_engine
|
||||
{
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
|
||||
#include "omath/linear_algebra/mat.hpp"
|
||||
#include "omath/linear_algebra/vector3.hpp"
|
||||
#include <omath/angle.hpp>
|
||||
#include <omath/view_angles.hpp>
|
||||
#include <omath/trigonometry/angle.hpp>
|
||||
#include <omath/trigonometry/view_angles.hpp>
|
||||
|
||||
namespace omath::unreal_engine
|
||||
{
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// Created by Orange on 11/13/2024.
|
||||
//
|
||||
#pragma once
|
||||
#include "linear_algebra/vector3.hpp"
|
||||
#include "vector3.hpp"
|
||||
|
||||
namespace omath
|
||||
{
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "omath/angle.hpp"
|
||||
#include "omath/trigonometry/angle.hpp"
|
||||
#include "omath/linear_algebra/vector2.hpp"
|
||||
#include <cstdint>
|
||||
#include <expected>
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
#pragma once
|
||||
|
||||
// Basic math utilities
|
||||
#include "omath/angles.hpp"
|
||||
#include "omath/angle.hpp"
|
||||
#include "omath/trigonometry/angles.hpp"
|
||||
#include "omath/trigonometry/angle.hpp"
|
||||
|
||||
// Vector classes (in dependency order)
|
||||
#include "omath/linear_algebra/vector2.hpp"
|
||||
@@ -18,11 +18,11 @@
|
||||
#include "omath/linear_algebra/mat.hpp"
|
||||
|
||||
// Color functionality
|
||||
#include "omath/color.hpp"
|
||||
#include "omath/utility/color.hpp"
|
||||
|
||||
// Geometric primitives
|
||||
#include "omath/triangle.hpp"
|
||||
#include "omath/view_angles.hpp"
|
||||
#include "omath/linear_algebra/triangle.hpp"
|
||||
#include "omath/trigonometry/view_angles.hpp"
|
||||
|
||||
// 3D primitives
|
||||
#include "omath/3d_primitives/box.hpp"
|
||||
@@ -82,3 +82,10 @@
|
||||
#include "omath/engines/unreal_engine/camera.hpp"
|
||||
#include "omath/engines/unreal_engine/traits/camera_trait.hpp"
|
||||
#include "omath/engines/unreal_engine/traits/pred_engine_trait.hpp"
|
||||
|
||||
// Reverse Engineering
|
||||
#include "omath/rev_eng/external_rev_object.hpp"
|
||||
#include "omath/rev_eng/internal_rev_object.hpp"
|
||||
|
||||
// Utility
|
||||
#include "omath/utility/pattern_scan.hpp"
|
||||
@@ -7,8 +7,8 @@
|
||||
#include "omath/linear_algebra/mat.hpp"
|
||||
#include "omath/linear_algebra/vector3.hpp"
|
||||
#include "omath/projection/error_codes.hpp"
|
||||
#include <omath/trigonometry/angle.hpp>
|
||||
#include <expected>
|
||||
#include <omath/angle.hpp>
|
||||
#include <type_traits>
|
||||
|
||||
#ifdef OMATH_BUILD_TESTS
|
||||
|
||||
35
include/omath/rev_eng/external_rev_object.hpp
Normal file
35
include/omath/rev_eng/external_rev_object.hpp
Normal file
@@ -0,0 +1,35 @@
|
||||
//
|
||||
// Created by Vlad on 10/4/2025.
|
||||
//
|
||||
|
||||
#pragma once
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
|
||||
namespace omath::rev_eng
|
||||
{
|
||||
template<class ExternalMemoryManagementTrait>
|
||||
class ExternalReverseEngineeredObject
|
||||
{
|
||||
public:
|
||||
explicit ExternalReverseEngineeredObject(const std::uintptr_t addr): m_object_address(addr)
|
||||
{
|
||||
}
|
||||
private:
|
||||
std::uintptr_t m_object_address{};
|
||||
|
||||
protected:
|
||||
template<class Type>
|
||||
[[nodiscard]]
|
||||
Type get_by_offset(const std::ptrdiff_t offset) const
|
||||
{
|
||||
return ExternalMemoryManagementTrait::read_memory(m_object_address+offset);
|
||||
}
|
||||
|
||||
template<class Type>
|
||||
void set_by_offset(const std::ptrdiff_t offset, const Type& value) const
|
||||
{
|
||||
return ExternalMemoryManagementTrait::write_memory(m_object_address+offset, value);
|
||||
}
|
||||
};
|
||||
} // namespace omath::rev_eng
|
||||
37
include/omath/rev_eng/internal_rev_object.hpp
Normal file
37
include/omath/rev_eng/internal_rev_object.hpp
Normal file
@@ -0,0 +1,37 @@
|
||||
//
|
||||
// Created by Vlad on 8/8/2025.
|
||||
//
|
||||
|
||||
#pragma once
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
|
||||
namespace omath::rev_eng
|
||||
{
|
||||
class InternalReverseEngineeredObject
|
||||
{
|
||||
protected:
|
||||
template<class Type>
|
||||
[[nodiscard]] Type& get_by_offset(const std::ptrdiff_t offset)
|
||||
{
|
||||
return *reinterpret_cast<Type*>(reinterpret_cast<std::uintptr_t>(this) + offset);
|
||||
}
|
||||
|
||||
template<class Type>
|
||||
[[nodiscard]] const Type& get_by_offset(const std::ptrdiff_t offset) const
|
||||
{
|
||||
return *reinterpret_cast<Type*>(reinterpret_cast<std::uintptr_t>(this) + offset);
|
||||
}
|
||||
|
||||
template<std::size_t id, class ReturnType>
|
||||
ReturnType call_virtual_method(auto... arg_list)
|
||||
{
|
||||
#ifdef _MSC_VER
|
||||
using VirtualMethodType = ReturnType(__thiscall*)(void*, decltype(arg_list)...);
|
||||
#else
|
||||
using VirtualMethodType = ReturnType(__fastcall*)(void*, decltype(arg_list)...);
|
||||
#endif
|
||||
return (*reinterpret_cast<VirtualMethodType**>(this))[id](this, arg_list...);
|
||||
}
|
||||
};
|
||||
} // namespace omath::rev_eng
|
||||
5
include/omath/system/pe/data_directory.hpp
Normal file
5
include/omath/system/pe/data_directory.hpp
Normal file
@@ -0,0 +1,5 @@
|
||||
//
|
||||
// Created by Vlad on 10/8/2025.
|
||||
//
|
||||
|
||||
#pragma once
|
||||
32
include/omath/system/pe/dos_header.hpp
Normal file
32
include/omath/system/pe/dos_header.hpp
Normal file
@@ -0,0 +1,32 @@
|
||||
//
|
||||
// Created by Vlad on 10/7/2025.
|
||||
//
|
||||
|
||||
#pragma once
|
||||
#include <cstdint>
|
||||
|
||||
namespace omath::system::pe
|
||||
{
|
||||
struct DosHeader final
|
||||
{
|
||||
std::uint16_t e_magic;
|
||||
std::uint16_t e_cblp;
|
||||
std::uint16_t e_cp;
|
||||
std::uint16_t e_crlc;
|
||||
std::uint16_t e_cparhdr;
|
||||
std::uint16_t e_minalloc;
|
||||
std::uint16_t e_maxalloc;
|
||||
std::uint16_t e_ss;
|
||||
std::uint16_t e_sp;
|
||||
std::uint16_t e_csum;
|
||||
std::uint16_t e_ip;
|
||||
std::uint16_t e_cs;
|
||||
std::uint16_t e_lfarlc;
|
||||
std::uint16_t e_ovno;
|
||||
std::uint16_t e_res[4];
|
||||
std::uint16_t e_oemid;
|
||||
std::uint16_t e_oeminfo;
|
||||
std::uint16_t e_res2[10];
|
||||
std::uint32_t e_lfanew;
|
||||
};
|
||||
}
|
||||
56
include/omath/system/pe/file_header.hpp
Normal file
56
include/omath/system/pe/file_header.hpp
Normal file
@@ -0,0 +1,56 @@
|
||||
//
|
||||
// Created by Vlad on 10/7/2025.
|
||||
//
|
||||
|
||||
#pragma once
|
||||
#include <cstdint>
|
||||
|
||||
namespace omath::system::pe
|
||||
{
|
||||
enum class MachineId : std::uint16_t
|
||||
{
|
||||
UNKNOWN = 0x0000,
|
||||
TARGET_HOST = 0x0001, // Useful for indicating we want to interact with the host and not a WoW guest.
|
||||
I386 = 0x014C, // Intel 386.
|
||||
R3000 = 0x0162, // MIPS little-endian, 0x160 big-endian
|
||||
R4000 = 0x0166, // MIPS little-endian
|
||||
R10000 = 0x0168, // MIPS little-endian
|
||||
WCEMIPSV2 = 0x0169, // MIPS little-endian WCE v2
|
||||
ALPHA = 0x0184, // Alpha_AXP
|
||||
SH3 = 0x01A2, // SH3 little-endian
|
||||
SH3DSP = 0x01A3,
|
||||
SH3E = 0x01A4, // SH3E little-endian
|
||||
SH4 = 0x01A6, // SH4 little-endian
|
||||
SH5 = 0x01A8, // SH5
|
||||
ARM = 0x01C0, // ARM Little-Endian
|
||||
THUMB = 0x01C2, // ARM Thumb/Thumb-2 Little-Endian
|
||||
ARMNT = 0x01C4, // ARM Thumb-2 Little-Endian
|
||||
AM33 = 0x01D3,
|
||||
POWERPC = 0x01F0, // IBM PowerPC Little-Endian
|
||||
POWERPCP = 0x01F1,
|
||||
IA64 = 0x0200, // Intel 64
|
||||
MIPS16 = 0x0266, // MIPS
|
||||
ALPHA64 = 0x0284, // ALPHA64
|
||||
MIPSFPU = 0x0366, // MIPS
|
||||
MIPSFPU16 = 0x0466, // MIPS
|
||||
AXP64 = 0x0284,
|
||||
TRICORE = 0x0520, // Infineon
|
||||
CEF = 0x0CEF,
|
||||
EBC = 0x0EBC, // EFI Byte Code
|
||||
AMD64 = 0x8664, // AMD64 (K8)
|
||||
M32R = 0x9041, // M32R little-endian
|
||||
ARM64 = 0xAA64, // ARM64 Little-Endian
|
||||
CEE = 0xC0EE,
|
||||
};
|
||||
|
||||
struct FileHeader final
|
||||
{
|
||||
MachineId machine;
|
||||
uint16_t num_sections;
|
||||
uint32_t timedate_stamp;
|
||||
uint32_t ptr_symbols;
|
||||
uint32_t num_symbols;
|
||||
uint16_t size_optional_header;
|
||||
std::uint16_t characteristics;
|
||||
};
|
||||
}
|
||||
23
include/omath/system/pe/image_nt_headers.hpp
Normal file
23
include/omath/system/pe/image_nt_headers.hpp
Normal file
@@ -0,0 +1,23 @@
|
||||
//
|
||||
// Created by Vlad on 10/9/2025.
|
||||
//
|
||||
|
||||
#pragma once
|
||||
#include "file_header.hpp"
|
||||
#include "optional_header.hpp"
|
||||
|
||||
namespace omath::system::pe
|
||||
{
|
||||
enum class NtArchitecture
|
||||
{
|
||||
x32_bit,
|
||||
x64_bit,
|
||||
};
|
||||
template<NtArchitecture architecture>
|
||||
struct ImageNtHeaders final
|
||||
{
|
||||
std::uint32_t signature;
|
||||
FileHeader file_header;
|
||||
OptionalHeader<architecture == NtArchitecture::x64_bit> optional_header;
|
||||
};
|
||||
} // namespace omath::system::pe
|
||||
118
include/omath/system/pe/optional_header.hpp
Normal file
118
include/omath/system/pe/optional_header.hpp
Normal file
@@ -0,0 +1,118 @@
|
||||
//
|
||||
// Created by Vlad on 10/8/2025.
|
||||
//
|
||||
#pragma once
|
||||
#include <cstdint>
|
||||
|
||||
namespace omath::system::pe
|
||||
{
|
||||
static constexpr std::uint16_t opt_hdr32_magic = 0x010B;
|
||||
static constexpr std::uint16_t opt_hdr64_magic = 0x020B;
|
||||
enum class SubsystemId : std::uint16_t
|
||||
{
|
||||
unknown = 0x0000,
|
||||
native = 0x0001,
|
||||
windows_gui = 0x0002,
|
||||
windows_cui = 0x0003,
|
||||
os2_cui = 0x0005,
|
||||
posix_cui = 0x0007,
|
||||
native_windows = 0x0008,
|
||||
windows_ce_gui = 0x0009,
|
||||
efi_application = 0x000A,
|
||||
efi_boot_service_driver = 0x000B,
|
||||
efi_runtime_driver = 0x000C,
|
||||
efi_rom = 0x000D,
|
||||
xbox = 0x000E,
|
||||
windows_boot_application = 0x0010,
|
||||
xbox_code_catalog = 0x0011,
|
||||
};
|
||||
|
||||
struct DataDirectory final
|
||||
{
|
||||
std::uint32_t rva;
|
||||
std::uint32_t size;
|
||||
};
|
||||
struct OptionalHeaderX64 final
|
||||
{
|
||||
// Standard fields.
|
||||
std::uint16_t magic;
|
||||
std::uint16_t linker_version;
|
||||
|
||||
std::uint32_t size_code;
|
||||
std::uint32_t size_init_data;
|
||||
std::uint32_t size_uninit_data;
|
||||
|
||||
std::uint32_t entry_point;
|
||||
std::uint32_t base_of_code;
|
||||
|
||||
// NT additional fields.
|
||||
std::uint64_t image_base;
|
||||
std::uint32_t section_alignment;
|
||||
std::uint32_t file_alignment;
|
||||
|
||||
std::uint32_t os_version;
|
||||
std::uint32_t img_version;
|
||||
std::uint32_t subsystem_version;
|
||||
std::uint32_t win32_version_value;
|
||||
|
||||
std::uint32_t size_image;
|
||||
std::uint32_t size_headers;
|
||||
|
||||
std::uint32_t checksum;
|
||||
SubsystemId subsystem;
|
||||
std::uint16_t characteristics;
|
||||
|
||||
std::uint64_t size_stack_reserve;
|
||||
std::uint64_t size_stack_commit;
|
||||
std::uint64_t size_heap_reserve;
|
||||
std::uint64_t size_heap_commit;
|
||||
|
||||
std::uint32_t ldr_flags;
|
||||
|
||||
std::uint32_t num_data_directories;
|
||||
DataDirectory data_directories[16];
|
||||
};
|
||||
struct OptionalHeaderX86 final
|
||||
{
|
||||
// Standard fields.
|
||||
uint16_t magic;
|
||||
uint16_t linker_version;
|
||||
|
||||
uint32_t size_code;
|
||||
uint32_t size_init_data;
|
||||
uint32_t size_uninit_data;
|
||||
|
||||
uint32_t entry_point;
|
||||
uint32_t base_of_code;
|
||||
uint32_t base_of_data;
|
||||
|
||||
// NT additional fields.
|
||||
uint32_t image_base;
|
||||
uint32_t section_alignment;
|
||||
uint32_t file_alignment;
|
||||
|
||||
std::uint32_t os_version;
|
||||
std::uint32_t img_version;
|
||||
std::uint32_t subsystem_version;
|
||||
uint32_t win32_version_value;
|
||||
|
||||
uint32_t size_image;
|
||||
uint32_t size_headers;
|
||||
|
||||
uint32_t checksum;
|
||||
SubsystemId subsystem;
|
||||
std::uint16_t characteristics;
|
||||
|
||||
uint32_t size_stack_reserve;
|
||||
uint32_t size_stack_commit;
|
||||
uint32_t size_heap_reserve;
|
||||
uint32_t size_heap_commit;
|
||||
|
||||
uint32_t ldr_flags;
|
||||
|
||||
uint32_t num_data_directories;
|
||||
DataDirectory data_directories[16];
|
||||
};
|
||||
template<bool x64 = true>
|
||||
using OptionalHeader = std::conditional_t<x64, OptionalHeaderX64, OptionalHeaderX86>;
|
||||
} // namespace omath::system::pe
|
||||
32
include/omath/system/pe/section_header.hpp
Normal file
32
include/omath/system/pe/section_header.hpp
Normal file
@@ -0,0 +1,32 @@
|
||||
//
|
||||
// Created by Vlad on 10/8/2025.
|
||||
//
|
||||
|
||||
#pragma once
|
||||
#include <cstdint>
|
||||
|
||||
// Section header
|
||||
//
|
||||
namespace omath::system::pe
|
||||
{
|
||||
struct SectionHeader final
|
||||
{
|
||||
char name[8];
|
||||
union
|
||||
{
|
||||
std::uint32_t physical_address;
|
||||
std::uint32_t virtual_size;
|
||||
};
|
||||
std::uint32_t virtual_address;
|
||||
|
||||
std::uint32_t size_raw_data;
|
||||
std::uint32_t ptr_raw_data;
|
||||
|
||||
std::uint32_t ptr_relocs;
|
||||
std::uint32_t ptr_line_numbers;
|
||||
std::uint32_t num_relocs;
|
||||
std::uint32_t num_line_numbers;
|
||||
|
||||
std::uint32_t characteristics;
|
||||
};
|
||||
}
|
||||
@@ -3,7 +3,7 @@
|
||||
//
|
||||
|
||||
#pragma once
|
||||
#include "omath/angles.hpp"
|
||||
#include "omath/trigonometry/angles.hpp"
|
||||
#include <algorithm>
|
||||
#include <format>
|
||||
#include <utility>
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "linear_algebra/vector4.hpp"
|
||||
#include "omath/linear_algebra/vector4.hpp"
|
||||
#include <cstdint>
|
||||
|
||||
namespace omath
|
||||
82
include/omath/utility/pattern_scan.hpp
Normal file
82
include/omath/utility/pattern_scan.hpp
Normal file
@@ -0,0 +1,82 @@
|
||||
//
|
||||
// Created by Vlad on 10/4/2025.
|
||||
//
|
||||
|
||||
#pragma once
|
||||
#include <expected>
|
||||
#include <optional>
|
||||
#include <span>
|
||||
#include <string_view>
|
||||
#include <vector>
|
||||
|
||||
// ReSharper disable once CppInconsistentNaming
|
||||
class unit_test_pattern_scan_read_test_Test;
|
||||
// ReSharper disable once CppInconsistentNaming
|
||||
class unit_test_pattern_scan_corner_case_1_Test;
|
||||
// ReSharper disable once CppInconsistentNaming
|
||||
class unit_test_pattern_scan_corner_case_2_Test;
|
||||
// ReSharper disable once CppInconsistentNaming
|
||||
class unit_test_pattern_scan_corner_case_3_Test;
|
||||
// ReSharper disable once CppInconsistentNaming
|
||||
class unit_test_pattern_scan_corner_case_4_Test;
|
||||
|
||||
namespace omath
|
||||
{
|
||||
enum class PatternScanError
|
||||
{
|
||||
INVALID_PATTERN_STRING
|
||||
};
|
||||
class PatternScanner final
|
||||
{
|
||||
friend unit_test_pattern_scan_read_test_Test;
|
||||
friend unit_test_pattern_scan_corner_case_1_Test;
|
||||
friend unit_test_pattern_scan_corner_case_2_Test;
|
||||
friend unit_test_pattern_scan_corner_case_3_Test;
|
||||
friend unit_test_pattern_scan_corner_case_4_Test;
|
||||
|
||||
public:
|
||||
[[nodiscard]]
|
||||
static std::span<std::byte>::iterator scan_for_pattern(const std::span<std::byte>& range,
|
||||
const std::string_view& pattern);
|
||||
|
||||
[[nodiscard]]
|
||||
static std::span<std::byte>::iterator scan_for_pattern(std::span<std::byte>&& range,
|
||||
const std::string_view& pattern) = delete;
|
||||
|
||||
template<class IteratorType>
|
||||
requires std::input_or_output_iterator<std::remove_cvref_t<IteratorType>>
|
||||
static IteratorType scan_for_pattern(const IteratorType& begin, const IteratorType& end,
|
||||
const std::string_view& pattern)
|
||||
{
|
||||
const auto parsed_pattern = parse_pattern(pattern);
|
||||
|
||||
if (!parsed_pattern) [[unlikely]]
|
||||
return end;
|
||||
|
||||
const auto whole_range_size = static_cast<std::ptrdiff_t>(std::distance(begin, end));
|
||||
|
||||
const std::ptrdiff_t scan_size = whole_range_size - static_cast<std::ptrdiff_t>(pattern.size());
|
||||
|
||||
for (std::ptrdiff_t i = 0; i < scan_size; i++)
|
||||
{
|
||||
bool found = true;
|
||||
|
||||
for (std::ptrdiff_t j = 0; j < static_cast<std::ptrdiff_t>(parsed_pattern->size()); j++)
|
||||
{
|
||||
found = parsed_pattern->at(j) == std::nullopt || parsed_pattern->at(j) == *(begin + i + j);
|
||||
|
||||
if (!found)
|
||||
break;
|
||||
}
|
||||
if (found)
|
||||
return begin + i;
|
||||
}
|
||||
return end;
|
||||
}
|
||||
|
||||
private:
|
||||
[[nodiscard]]
|
||||
static std::expected<std::vector<std::optional<std::byte>>, PatternScanError>
|
||||
parse_pattern(const std::string_view& pattern_string);
|
||||
};
|
||||
} // namespace omath
|
||||
43
include/omath/utility/pe_pattern_scan.hpp
Normal file
43
include/omath/utility/pe_pattern_scan.hpp
Normal file
@@ -0,0 +1,43 @@
|
||||
//
|
||||
// Created by Vlad on 10/7/2025.
|
||||
//
|
||||
|
||||
#pragma once
|
||||
#include <cstdint>
|
||||
#include <filesystem>
|
||||
#include <optional>
|
||||
#include <string_view>
|
||||
#include <vector>
|
||||
namespace omath
|
||||
{
|
||||
struct PeSectionScanResult
|
||||
{
|
||||
std::uint64_t virtual_base_addr;
|
||||
std::uint64_t raw_base_addr;
|
||||
std::ptrdiff_t target_offset;
|
||||
};
|
||||
class PePatternScanner final
|
||||
{
|
||||
private:
|
||||
struct Section
|
||||
{
|
||||
std::uint64_t virtual_base_addr;
|
||||
std::uint64_t raw_base_addr;
|
||||
std::vector<std::byte> data;
|
||||
};
|
||||
|
||||
public:
|
||||
[[nodiscard]]
|
||||
static std::optional<std::uintptr_t> scan_for_pattern_in_loaded_module(const std::string_view& module_name,
|
||||
const std::string_view& pattern);
|
||||
|
||||
[[nodiscard]]
|
||||
static std::optional<PeSectionScanResult>
|
||||
scan_for_pattern_in_file(const std::filesystem::path& path_to_file, const std::string_view& pattern,
|
||||
const std::string_view& target_section_name = ".text");
|
||||
|
||||
[[nodiscard]]
|
||||
static std::optional<Section> extract_section_from_pe_file(const std::filesystem::path& path_to_file,
|
||||
const std::string_view& section_name);
|
||||
};
|
||||
} // namespace omath
|
||||
1
mkdocs.yml
Normal file
1
mkdocs.yml
Normal file
@@ -0,0 +1 @@
|
||||
site_name: My Docs
|
||||
75
source/utility/pattern_scan.cpp
Normal file
75
source/utility/pattern_scan.cpp
Normal file
@@ -0,0 +1,75 @@
|
||||
//
|
||||
// Created by Vlad on 10/4/2025.
|
||||
//
|
||||
#include "omath/utility/pattern_scan.hpp"
|
||||
#include <charconv>
|
||||
#include <cstdint>
|
||||
#include <algorithm>
|
||||
|
||||
namespace
|
||||
{
|
||||
[[nodiscard]]
|
||||
constexpr bool is_wildcard(const std::string_view& byte_str)
|
||||
{
|
||||
return byte_str == "?" || byte_str == "??";
|
||||
}
|
||||
|
||||
[[nodiscard]]
|
||||
constexpr bool invalid_byte_str_size(const std::string_view& byte_str)
|
||||
{
|
||||
return byte_str.empty() || byte_str.size() >= 3;
|
||||
}
|
||||
}
|
||||
|
||||
namespace omath
|
||||
{
|
||||
|
||||
std::span<std::byte>::iterator
|
||||
PatternScanner::scan_for_pattern(const std::span<std::byte>& range, const std::string_view& pattern)
|
||||
{
|
||||
return scan_for_pattern(range.begin(), range.end(), pattern);
|
||||
}
|
||||
std::expected<std::vector<std::optional<std::byte>>, PatternScanError>
|
||||
PatternScanner::parse_pattern(const std::string_view& pattern_string)
|
||||
{
|
||||
std::vector<std::optional<std::byte>> pattern;
|
||||
|
||||
auto start = pattern_string.cbegin();
|
||||
|
||||
while (start != pattern_string.cend())
|
||||
{
|
||||
const auto end = std::ranges::find(start, pattern_string.cend(), ' ');
|
||||
|
||||
const auto sting_view_start = std::distance(pattern_string.cbegin(), start);
|
||||
const auto sting_view_end = std::distance(start, end);
|
||||
|
||||
const std::string_view byte_str = pattern_string.substr(sting_view_start, sting_view_end);
|
||||
|
||||
if (invalid_byte_str_size(byte_str)) [[unlikely]]
|
||||
{
|
||||
start = end != pattern_string.end() ? std::next(end) : end;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (is_wildcard(byte_str))
|
||||
{
|
||||
pattern.emplace_back(std::nullopt);
|
||||
|
||||
start = end != pattern_string.end() ? std::next(end) : end;
|
||||
continue;
|
||||
}
|
||||
|
||||
std::uint8_t value = 0;
|
||||
// ReSharper disable once CppTooWideScopeInitStatement
|
||||
const auto [_, error_code] = std::from_chars(byte_str.data(), byte_str.data() + byte_str.size(), value, 16);
|
||||
|
||||
if (error_code != std::errc{}) [[unlikely]]
|
||||
return std::unexpected(PatternScanError::INVALID_PATTERN_STRING);
|
||||
|
||||
pattern.emplace_back(static_cast<std::byte>(value));
|
||||
|
||||
start = end != pattern_string.end() ? std::next(end) : end;
|
||||
}
|
||||
return pattern;
|
||||
}
|
||||
} // namespace omath
|
||||
158
source/utility/pe_pattern_scan.cpp
Normal file
158
source/utility/pe_pattern_scan.cpp
Normal file
@@ -0,0 +1,158 @@
|
||||
//
|
||||
// Created by Vlad on 10/7/2025.
|
||||
//
|
||||
#include "omath/utility/pe_pattern_scan.hpp"
|
||||
#include "omath/system/pe/image_nt_headers.hpp"
|
||||
#include "omath/system/pe/section_header.hpp"
|
||||
#include "omath/utility/pattern_scan.hpp"
|
||||
#include <fstream>
|
||||
#include <omath/system/pe/dos_header.hpp>
|
||||
#include <span>
|
||||
#include <stdexcept>
|
||||
#include <variant>
|
||||
#ifdef _WIN32
|
||||
#include <Windows.h>
|
||||
#endif
|
||||
|
||||
using namespace omath::system::pe;
|
||||
using NtHeaderVariant = std::variant<ImageNtHeaders<NtArchitecture::x64_bit>, ImageNtHeaders<NtArchitecture::x32_bit>>;
|
||||
|
||||
namespace
|
||||
{
|
||||
[[nodiscard]]
|
||||
NtHeaderVariant get_nt_header_from_file(std::fstream& file, const DosHeader& dos_header)
|
||||
{
|
||||
ImageNtHeaders<NtArchitecture::x32_bit> x86_headers;
|
||||
file.seekg(dos_header.e_lfanew, std::ios::beg);
|
||||
file.read(reinterpret_cast<char*>(&x86_headers), sizeof(x86_headers));
|
||||
|
||||
if (x86_headers.optional_header.magic == opt_hdr32_magic)
|
||||
return x86_headers;
|
||||
|
||||
ImageNtHeaders<NtArchitecture::x64_bit> x64_headers;
|
||||
file.seekg(dos_header.e_lfanew, std::ios::beg);
|
||||
file.read(reinterpret_cast<char*>(&x64_headers), sizeof(x64_headers));
|
||||
|
||||
return x64_headers;
|
||||
}
|
||||
|
||||
[[nodiscard]]
|
||||
constexpr bool invalid_dos_header_file(const DosHeader& dos_header)
|
||||
{
|
||||
constexpr std::uint16_t dos_hdr_magic = 0x5A4D;
|
||||
return dos_header.e_magic != dos_hdr_magic;
|
||||
}
|
||||
[[nodiscard]]
|
||||
constexpr bool invalid_nt_header_file(const NtHeaderVariant& variant)
|
||||
{
|
||||
constexpr std::uint32_t nt_hdr_magic = 0x4550;
|
||||
return std::visit([](const auto& header) -> bool { return header.signature != nt_hdr_magic; }, variant);
|
||||
}
|
||||
} // namespace
|
||||
|
||||
namespace omath
|
||||
{
|
||||
|
||||
std::optional<std::uintptr_t>
|
||||
PePatternScanner::scan_for_pattern_in_loaded_module([[maybe_unused]] const std::string_view& module_name,
|
||||
[[maybe_unused]] const std::string_view& pattern)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
const auto base_address = reinterpret_cast<std::uintptr_t>(GetModuleHandleA(module_name.data()));
|
||||
|
||||
if (!base_address)
|
||||
return std::nullopt;
|
||||
|
||||
const auto dos_headers = reinterpret_cast<PIMAGE_DOS_HEADER>(base_address);
|
||||
const auto image_nt_headers = reinterpret_cast<PIMAGE_NT_HEADERS>(base_address + dos_headers->e_lfanew);
|
||||
|
||||
// Define .code segment as scan area
|
||||
const auto start = image_nt_headers->OptionalHeader.BaseOfCode;
|
||||
const auto scan_size = image_nt_headers->OptionalHeader.SizeOfCode;
|
||||
|
||||
const auto scan_range = std::span{reinterpret_cast<std::byte*>(base_address) + start, scan_size};
|
||||
|
||||
const auto result = PatternScanner::scan_for_pattern(scan_range, pattern);
|
||||
|
||||
if (result != scan_range.cend())
|
||||
return reinterpret_cast<std::uintptr_t>(&*result);
|
||||
|
||||
return std::nullopt;
|
||||
#else
|
||||
throw std::runtime_error("Pattern scan for loaded modules is only for windows platform");
|
||||
#endif
|
||||
}
|
||||
std::optional<PeSectionScanResult>
|
||||
PePatternScanner::scan_for_pattern_in_file(const std::filesystem::path& path_to_file,
|
||||
const std::string_view& pattern,
|
||||
const std::string_view& target_section_name)
|
||||
{
|
||||
const auto pe_section = extract_section_from_pe_file(path_to_file, target_section_name);
|
||||
|
||||
if (!pe_section.has_value())
|
||||
return std::nullopt;
|
||||
|
||||
const auto scan_result =
|
||||
PatternScanner::scan_for_pattern(pe_section->data.cbegin(), pe_section->data.cend(), pattern);
|
||||
|
||||
if (scan_result == pe_section->data.cend())
|
||||
return std::nullopt;
|
||||
const auto offset = std::distance(pe_section->data.begin(), scan_result);
|
||||
|
||||
return PeSectionScanResult{.virtual_base_addr = pe_section->virtual_base_addr,
|
||||
.raw_base_addr = pe_section->raw_base_addr,
|
||||
.target_offset = offset};
|
||||
}
|
||||
std::optional<PePatternScanner::Section>
|
||||
PePatternScanner::extract_section_from_pe_file(const std::filesystem::path& path_to_file,
|
||||
const std::string_view& section_name)
|
||||
{
|
||||
std::fstream file(path_to_file, std::ios::binary | std::ios::in);
|
||||
|
||||
if (!file.is_open()) [[unlikely]]
|
||||
return std::nullopt;
|
||||
|
||||
DosHeader dos_header{};
|
||||
file.read(reinterpret_cast<char*>(&dos_header), sizeof(dos_header));
|
||||
|
||||
if (invalid_dos_header_file(dos_header)) [[unlikely]]
|
||||
return std::nullopt;
|
||||
|
||||
const auto nt_headers = get_nt_header_from_file(file, dos_header);
|
||||
|
||||
if (invalid_nt_header_file(nt_headers)) [[unlikely]]
|
||||
return std::nullopt;
|
||||
|
||||
return std::visit(
|
||||
[&file, &dos_header, §ion_name](auto& concrete_headers) -> std::optional<Section>
|
||||
{
|
||||
constexpr std::size_t size_of_signature = sizeof(concrete_headers.signature);
|
||||
const auto offset_to_segment_table = dos_header.e_lfanew
|
||||
+ concrete_headers.file_header.size_optional_header
|
||||
+ sizeof(FileHeader) + size_of_signature;
|
||||
|
||||
file.seekg(static_cast<std::fstream::off_type>(offset_to_segment_table), std::ios::beg);
|
||||
|
||||
for (std::size_t i = 0; i < concrete_headers.file_header.num_sections; i++)
|
||||
{
|
||||
SectionHeader current_section{};
|
||||
file.read(reinterpret_cast<char*>(¤t_section), sizeof(current_section));
|
||||
|
||||
if (std::string_view(current_section.name) != section_name)
|
||||
continue;
|
||||
|
||||
std::vector<std::byte> section_data(current_section.size_raw_data);
|
||||
|
||||
file.seekg(current_section.ptr_raw_data, std::ios::beg);
|
||||
file.read(reinterpret_cast<char*>(section_data.data()),
|
||||
static_cast<std::streamsize>(section_data.size()));
|
||||
return Section{.virtual_base_addr = current_section.virtual_address
|
||||
+ concrete_headers.optional_header.image_base,
|
||||
.raw_base_addr = current_section.ptr_raw_data,
|
||||
.data = std::move(section_data)};
|
||||
}
|
||||
return std::nullopt;
|
||||
},
|
||||
nt_headers);
|
||||
}
|
||||
} // namespace omath
|
||||
@@ -2,10 +2,10 @@
|
||||
// Created by Orange on 11/30/2024.
|
||||
//
|
||||
|
||||
#include <omath/trigonometry/angle.hpp>
|
||||
#include <cmath>
|
||||
#include <gtest/gtest.h>
|
||||
#include <numbers>
|
||||
#include <omath/angle.hpp>
|
||||
|
||||
using namespace omath;
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
//
|
||||
// Created by Orange on 11/30/2024.
|
||||
//
|
||||
#include <omath/trigonometry/angles.hpp>
|
||||
#include <gtest/gtest.h>
|
||||
#include <omath/angles.hpp>
|
||||
|
||||
TEST(unit_test_angles, radians_to_deg)
|
||||
{
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
//
|
||||
// Created by Vlad on 01.09.2024.
|
||||
//
|
||||
#include <omath/utility/color.hpp>
|
||||
#include <gtest/gtest.h>
|
||||
#include <omath/color.hpp>
|
||||
|
||||
|
||||
using namespace omath;
|
||||
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
// Revised unit‑test suite for LineTracer (segment‑based Möller–Trumbore)
|
||||
// Pure ASCII: avoids non‑standard characters that MSVC rejects.
|
||||
//
|
||||
#include "omath/linear_algebra/vector3.hpp"
|
||||
#include "omath/linear_algebra/triangle.hpp"
|
||||
#include "omath/collision/line_tracer.hpp"
|
||||
#include "omath/triangle.hpp"
|
||||
#include "omath/linear_algebra/vector3.hpp"
|
||||
#include "gtest/gtest.h"
|
||||
#include <cmath>
|
||||
|
||||
|
||||
53
tests/general/unit_test_pattern_scan.cpp
Normal file
53
tests/general/unit_test_pattern_scan.cpp
Normal file
@@ -0,0 +1,53 @@
|
||||
//
|
||||
// Created by Vlad on 10/4/2025.
|
||||
//
|
||||
#include "omath/utility/pe_pattern_scan.hpp"
|
||||
#include "gtest/gtest.h"
|
||||
#include <omath/utility/pattern_scan.hpp>
|
||||
#include <source_location>
|
||||
#include <print>
|
||||
TEST(unit_test_pattern_scan, read_test)
|
||||
{
|
||||
const auto result = omath::PatternScanner::parse_pattern("FF ? ?? E9");
|
||||
|
||||
EXPECT_EQ(result->at(0), static_cast<std::byte>(0xFF));
|
||||
EXPECT_EQ(result->at(1), std::nullopt);
|
||||
EXPECT_EQ(result->at(2), std::nullopt);
|
||||
EXPECT_EQ(result->at(3), static_cast<std::byte>(0xE9));
|
||||
}
|
||||
|
||||
TEST(unit_test_pattern_scan, corner_case_1)
|
||||
{
|
||||
const auto result = omath::PatternScanner::parse_pattern(" FF ? ?? E9");
|
||||
|
||||
EXPECT_EQ(result->at(0), static_cast<std::byte>(0xFF));
|
||||
EXPECT_EQ(result->at(1), std::nullopt);
|
||||
EXPECT_EQ(result->at(2), std::nullopt);
|
||||
EXPECT_EQ(result->at(3), static_cast<std::byte>(0xE9));
|
||||
}
|
||||
|
||||
TEST(unit_test_pattern_scan, corner_case_2)
|
||||
{
|
||||
const auto result = omath::PatternScanner::parse_pattern(" FF ? ?? E9 ");
|
||||
|
||||
EXPECT_EQ(result->at(0), static_cast<std::byte>(0xFF));
|
||||
EXPECT_EQ(result->at(1), std::nullopt);
|
||||
EXPECT_EQ(result->at(2), std::nullopt);
|
||||
EXPECT_EQ(result->at(3), static_cast<std::byte>(0xE9));
|
||||
}
|
||||
|
||||
TEST(unit_test_pattern_scan, corner_case_3)
|
||||
{
|
||||
const auto result = omath::PatternScanner::parse_pattern(" FF ? ?? E9 ");
|
||||
|
||||
EXPECT_EQ(result->at(0), static_cast<std::byte>(0xFF));
|
||||
EXPECT_EQ(result->at(1), std::nullopt);
|
||||
EXPECT_EQ(result->at(2), std::nullopt);
|
||||
EXPECT_EQ(result->at(3), static_cast<std::byte>(0xE9));
|
||||
}
|
||||
|
||||
TEST(unit_test_pattern_scan, corner_case_4)
|
||||
{
|
||||
const auto result = omath::PatternScanner::parse_pattern("X ? ?? E9 ");
|
||||
EXPECT_FALSE(result.has_value());
|
||||
}
|
||||
50
tests/general/unit_test_reverse_enineering.cpp
Normal file
50
tests/general/unit_test_reverse_enineering.cpp
Normal file
@@ -0,0 +1,50 @@
|
||||
//
|
||||
// Created by Vlad on 10/4/2025.
|
||||
//
|
||||
#include "omath/linear_algebra/vector3.hpp"
|
||||
#include <gtest/gtest.h>
|
||||
#include <omath/rev_eng/internal_rev_object.hpp>
|
||||
|
||||
class Player final
|
||||
{
|
||||
public:
|
||||
virtual int foo() {return 1;}
|
||||
virtual int bar() {return 2;}
|
||||
omath::Vector3<float> m_origin{1.f, 2.f, 3.f};
|
||||
int m_health{123};
|
||||
};
|
||||
|
||||
class RevPlayer : omath::rev_eng::InternalReverseEngineeredObject
|
||||
{
|
||||
public:
|
||||
omath::Vector3<float> get_origin()
|
||||
{
|
||||
return get_by_offset<omath::Vector3<float>>(sizeof(std::uintptr_t));
|
||||
}
|
||||
int get_health()
|
||||
{
|
||||
return get_by_offset<int>(sizeof(std::uintptr_t)+sizeof(omath::Vector3<float>));
|
||||
}
|
||||
|
||||
int rev_foo()
|
||||
{
|
||||
return call_virtual_method<0, int>();
|
||||
}
|
||||
int rev_bar()
|
||||
{
|
||||
return call_virtual_method<1, int>();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
TEST(unit_test_reverse_enineering, read_test)
|
||||
{
|
||||
Player player_original;
|
||||
const auto player_reversed = reinterpret_cast<RevPlayer*>(&player_original);
|
||||
|
||||
EXPECT_EQ(player_original.m_origin, player_reversed->get_origin());
|
||||
EXPECT_EQ(player_original.m_health, player_reversed->get_health());
|
||||
|
||||
EXPECT_EQ(player_original.bar(), player_reversed->rev_bar());
|
||||
EXPECT_EQ(player_original.foo(), player_reversed->rev_foo());
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// Created by Orange on 1/6/2025.
|
||||
//
|
||||
#include "omath/triangle.hpp"
|
||||
#include "omath/linear_algebra/triangle.hpp"
|
||||
#include "omath/linear_algebra/vector3.hpp"
|
||||
#include <cmath> // For std::sqrt, std::isinf, std::isnan
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
//
|
||||
// Created by Orange on 11/30/2024.
|
||||
//
|
||||
#include <omath/view_angles.hpp>
|
||||
#include <omath/trigonometry/view_angles.hpp>
|
||||
@@ -1,7 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE categories
|
||||
SYSTEM "https://resources.jetbrains.com/writerside/1.0/categories.dtd">
|
||||
<categories>
|
||||
<category id="wrs" name="Writerside documentation" order="1"/>
|
||||
<category id="inf" name="Learn more" order="2"/>
|
||||
</categories>
|
||||
@@ -1,13 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE buildprofiles SYSTEM "https://resources.jetbrains.com/writerside/1.0/build-profiles.dtd">
|
||||
<buildprofiles xsi:noNamespaceSchemaLocation="https://resources.jetbrains.com/writerside/1.0/build-profiles.xsd"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
|
||||
<variables></variables>
|
||||
<build-profile instance="o">
|
||||
<variables>
|
||||
<noindex-content>true</noindex-content>
|
||||
</variables>
|
||||
</build-profile>
|
||||
|
||||
</buildprofiles>
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 125 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 67 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 341 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 119 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 306 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 274 KiB |
@@ -1,14 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE instance-profile
|
||||
SYSTEM "https://resources.jetbrains.com/writerside/1.0/product-profile.dtd">
|
||||
|
||||
<instance-profile id="o"
|
||||
name="OMATH"
|
||||
start-page="starter-topic.md">
|
||||
|
||||
<toc-element topic="starter-topic.md"/>
|
||||
<toc-element topic="Documentation.md"/>
|
||||
<toc-element topic="Code-Of-Conduct.md"/>
|
||||
<toc-element topic="Community.md"/>
|
||||
<toc-element topic="License.md"/>
|
||||
</instance-profile>
|
||||
@@ -1,13 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE rules SYSTEM "https://resources.jetbrains.com/writerside/1.0/redirection-rules.dtd">
|
||||
<rules>
|
||||
<!-- format is as follows
|
||||
<rule id="<unique id>">
|
||||
<accepts>page.html</accepts>
|
||||
</rule>
|
||||
-->
|
||||
<rule id="4e037516">
|
||||
<description><![CDATA[Created after removal of "<Empty-MD-Topic.md>" from OMATH]]></description>
|
||||
<accepts>Empty-MD-Topic.html</accepts>
|
||||
</rule>
|
||||
</rules>
|
||||
@@ -1,95 +0,0 @@
|
||||
# Code Of Conduct
|
||||
|
||||
## 🎯 Goal
|
||||
|
||||
My goal is to provide a space where it is safe for everyone to contribute to,
|
||||
and get support for, open-source software in a respectful and cooperative
|
||||
manner.
|
||||
|
||||
I value all contributions and want to make this project and its
|
||||
surrounding community a place for everyone.
|
||||
|
||||
As members, contributors, and everyone else who may participate in the
|
||||
development, I strive to keep the entire experience civil.
|
||||
|
||||
## 📜 Standards
|
||||
|
||||
Our community standards exist in order to make sure everyone feels comfortable
|
||||
contributing to the project(s) together.
|
||||
|
||||
Our standards are:
|
||||
- Do not harass, attack, or in any other way discriminate against anyone, including
|
||||
for their protected traits, including, but not limited to, sex, religion, race,
|
||||
appearance, gender, identity, nationality, sexuality, etc.
|
||||
- Do not go off-topic, do not post spam.
|
||||
- Treat everyone with respect.
|
||||
|
||||
Examples of breaking each rule respectively include:
|
||||
- Harassment, bullying or inappropriate jokes about another person.
|
||||
- Posting distasteful imagery, trolling, or posting things unrelated to the topic at hand.
|
||||
- Treating someone as worse because of their lack of understanding of an issue.
|
||||
|
||||
## ⚡ Enforcement
|
||||
|
||||
Enforcement of this CoC is done by Orange++ and/or other core contributors.
|
||||
|
||||
I, as the core developer, will strive my best to keep this community civil and
|
||||
following the standards outlined above.
|
||||
|
||||
### 🚩 Reporting incidents
|
||||
|
||||
If you believe an incident of breaking these standards has occurred, but nobody has
|
||||
taken appropriate action, you can privately contact the people responsible for dealing
|
||||
with such incidents in multiple ways:
|
||||
|
||||
***E-Mail***
|
||||
- `orange-cpp@yandex.ru`
|
||||
|
||||
***Discord***
|
||||
- `@orange_cpp`
|
||||
|
||||
***Telegram***
|
||||
- `@orange_cpp`
|
||||
|
||||
I guarantee your privacy and will not share those reports with anyone.
|
||||
|
||||
## ⚖️ Enforcement Strategy
|
||||
|
||||
Depending on the severity of the infraction, any action from the list below may be applied.
|
||||
Please keep in mind cases are reviewed on a per-case basis and members are the ultimate
|
||||
deciding factor in the type of punishment.
|
||||
|
||||
If the matter benefited from an outside opinion, a member might reach for more opinions
|
||||
from people unrelated, however, the final decision regarding the action
|
||||
to be taken is still up to the member.
|
||||
|
||||
For example, if the matter at hand regards a representative of a marginalized group or minority,
|
||||
the member might ask for a first-hand opinion from another representative of such group.
|
||||
|
||||
### ✏️ Correction/Edit
|
||||
|
||||
If your message is found to be misleading or poorly worded, a member might
|
||||
edit your message.
|
||||
|
||||
### ⚠️ Warning/Deletion
|
||||
|
||||
If your message is found inappropriate, a member might give you a public or private warning,
|
||||
and/or delete your message.
|
||||
|
||||
### 🔇 Mute
|
||||
|
||||
If your message is disruptive, or you have been repeatedly violating the standards,
|
||||
a member might mute (or temporarily ban) you.
|
||||
|
||||
### ⛔ Ban
|
||||
|
||||
If your message is hateful, very disruptive, or other, less serious infractions are repeated
|
||||
ignoring previous punishments, a member might ban you permanently.
|
||||
|
||||
## 🔎 Scope
|
||||
|
||||
This CoC shall apply to all projects ran under the Orange++ lead and all _official_ communities
|
||||
outside of GitHub.
|
||||
|
||||
However, it is worth noting that official communities outside of GitHub might have their own,
|
||||
additional sets of rules.
|
||||
@@ -1,11 +0,0 @@
|
||||
# Credits
|
||||
|
||||
Thanks to everyone who made this possible, including:
|
||||
|
||||
- Saikari aka luadebug for VCPKG port.
|
||||
|
||||
And a big hand to everyone else who has contributed over the past!
|
||||
|
||||
THANKS! <3
|
||||
|
||||
-- Orange++ <orange-cpp@yandex.ru>
|
||||
@@ -1,54 +0,0 @@
|
||||
# 📥Installation Guide
|
||||
|
||||
## Using vcpkg
|
||||
**Note**: Support vcpkg for package management
|
||||
1. Install [vcpkg](https://github.com/microsoft/vcpkg)
|
||||
2. Run the following command to install the orange-math package:
|
||||
```
|
||||
vcpkg install orange-math
|
||||
```
|
||||
CMakeLists.txt
|
||||
```cmake
|
||||
find_package(omath CONFIG REQUIRED)
|
||||
target_link_libraries(main PRIVATE omath::omath)
|
||||
```
|
||||
For detailed commands on installing different versions and more information, please refer to Microsoft's [official instructions](https://learn.microsoft.com/en-us/vcpkg/get_started/overview).
|
||||
|
||||
## Build from source using CMake
|
||||
1. **Preparation**
|
||||
|
||||
Install needed tools: cmake, clang, git, msvc (windows only).
|
||||
|
||||
1. **Linux:**
|
||||
```bash
|
||||
sudo pacman -Sy cmake ninja clang git
|
||||
```
|
||||
2. **MacOS:**
|
||||
```bash
|
||||
brew install llvm git cmake ninja
|
||||
```
|
||||
3. **Windows:**
|
||||
|
||||
Install Visual Studio from [here](https://visualstudio.microsoft.com/downloads/) and Git from [here](https://git-scm.com/downloads).
|
||||
|
||||
Use x64 Native Tools shell to execute needed commands down below.
|
||||
2. **Clone the repository:**
|
||||
```bash
|
||||
git clone https://github.com/orange-cpp/omath.git
|
||||
```
|
||||
3. **Navigate to the project directory:**
|
||||
```bash
|
||||
cd omath
|
||||
```
|
||||
4. **Build the project using CMake:**
|
||||
```bash
|
||||
cmake --preset windows-release -S .
|
||||
cmake --build cmake-build/build/windows-release --target omath -j 6
|
||||
```
|
||||
Use **\<platform\>-\<build configuration\>** preset to build siutable version for yourself. Like **windows-release** or **linux-release**.
|
||||
|
||||
| Platform Name | Build Config |
|
||||
|---------------|---------------|
|
||||
| windows | release/debug |
|
||||
| linux | release/debug |
|
||||
| darwin | release/debug |
|
||||
@@ -1,9 +0,0 @@
|
||||
# License
|
||||
|
||||
Copyright (c) 2025 Orange++
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
@@ -1,67 +0,0 @@
|
||||
# Intro
|
||||
|
||||

|
||||
|
||||
Oranges's Math Library (omath) is a comprehensive, open-source library aimed at providing efficient, reliable, and versatile mathematical functions and algorithms. Developed primarily in C++, this library is designed to cater to a wide range of mathematical operations essential in scientific computing, engineering, and academic research.
|
||||
|
||||
## 👁🗨 Features
|
||||
- **Efficiency**: Optimized for performance, ensuring quick computations using AVX2.
|
||||
- **Versatility**: Includes a wide array of mathematical functions and algorithms.
|
||||
- **Ease of Use**: Simplified interface for convenient integration into various projects.
|
||||
- **Projectile Prediction**: Projectile prediction engine with O(N) algo complexity, that can power you projectile aim-bot.
|
||||
- **3D Projection**: No need to find view-projection matrix anymore you can make your own projection pipeline.
|
||||
- **Collision Detection**: Production ready code to handle collision detection by using simple interfaces.
|
||||
- **No Additional Dependencies**: No additional dependencies need to use OMath except unit test execution
|
||||
- **Ready for meta-programming**: Omath use templates for common types like Vectors, Matrixes etc, to handle all types!
|
||||
|
||||
## Supported Render Pipelines
|
||||
| ENGINE | SUPPORT |
|
||||
|----------|---------|
|
||||
| Source | ✅YES |
|
||||
| Unity | ✅YES |
|
||||
| IWEngine | ✅YES |
|
||||
| Unreal | ❌NO |
|
||||
|
||||
## Supported Operating Systems
|
||||
|
||||
| OS | SUPPORT |
|
||||
|----------------|---------|
|
||||
| Windows 10/11 | ✅YES |
|
||||
| Linux | ✅YES |
|
||||
| Darwin (MacOS) | ✅YES |
|
||||
|
||||
## ⏬ Installation
|
||||
Please read our [installation guide](https://github.com/orange-cpp/omath/blob/main/INSTALL.md). If this link doesn't work check out INSTALL.md file.
|
||||
|
||||
## ❔ Usage
|
||||
Simple world to screen function
|
||||
```c++
|
||||
TEST(UnitTestProjection, IsPointOnScreen)
|
||||
{
|
||||
const omath::projection::Camera camera({0.f, 0.f, 0.f}, {0, 0.f, 0.f} , {1920.f, 1080.f}, 110.f, 0.1f, 500.f);
|
||||
|
||||
const auto proj = camera.WorldToScreen({100, 0, 15});
|
||||
EXPECT_TRUE(proj.has_value());
|
||||
}
|
||||
```
|
||||
## Showcase
|
||||
|
||||
With `omath/projection` module you can achieve simple ESP hack for powered by Source/Unreal/Unity engine games, like [Apex Legends](https://store.steampowered.com/app/1172470/Apex_Legends/).
|
||||
|
||||

|
||||
Or for InfinityWard Engine based games. Like Call of Duty Black Ops 2!
|
||||

|
||||
Or create simple trigger bot with embeded traceline from omath::collision::LineTrace
|
||||

|
||||
Or even advanced projectile aimbot
|
||||
[Watch Video](https://youtu.be/lM_NJ1yCunw?si=5E87OrQMeypxSJ3E)
|
||||
|
||||
|
||||
## 🫵🏻 Contributing
|
||||
Contributions to `omath` are welcome! Please read `CONTRIBUTING.md` for details on our code of conduct and the process for submitting pull requests.
|
||||
|
||||
## 📜 License
|
||||
This project is licensed under the MIT - see the `LICENSE` file for details.
|
||||
|
||||
## 💘 Acknowledgments
|
||||
- [All contributors](https://github.com/orange-cpp/omath/graphs/contributors)
|
||||
@@ -1,5 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE vars SYSTEM "https://resources.jetbrains.com/writerside/1.0/vars.dtd">
|
||||
<vars>
|
||||
<var name="product" value="Writerside"/>
|
||||
</vars>
|
||||
@@ -1,8 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE ihp SYSTEM "https://resources.jetbrains.com/writerside/1.0/ihp.dtd">
|
||||
|
||||
<ihp version="2.0">
|
||||
<topics dir="topics" web-path="topics"/>
|
||||
<images dir="images" web-path="images"/>
|
||||
<instance src="o.tree"/>
|
||||
</ihp>
|
||||
Reference in New Issue
Block a user