mirror of
https://github.com/WerWolv/ImHex-Patterns.git
synced 2026-03-31 13:25:58 -05:00
Compare commits
4 Commits
ImHex-v1.2
...
ImHex-v1.2
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8e70a5524d | ||
|
|
9c0bf1433c | ||
|
|
43afbfa120 | ||
|
|
f75703fd2b |
9
includes/std/array.pat
Normal file
9
includes/std/array.pat
Normal file
@@ -0,0 +1,9 @@
|
||||
#pragma once
|
||||
|
||||
namespace std {
|
||||
|
||||
struct Array<T, auto Size> {
|
||||
T data[Size] [[inline]];
|
||||
};
|
||||
|
||||
}
|
||||
@@ -47,4 +47,26 @@ namespace std::mem {
|
||||
return builtin::std::mem::read_string(address, size);
|
||||
};
|
||||
|
||||
|
||||
struct MagicSearch<auto Magic, T> {
|
||||
if ($ < (std::mem::size() - std::string::length(Magic) - 1)) {
|
||||
char __potentialMagic__[std::string::length(Magic)] [[hidden, no_unique_address]];
|
||||
|
||||
if (__potentialMagic__ == Magic) {
|
||||
T data [[inline]];
|
||||
} else {
|
||||
padding[1];
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
padding[1];
|
||||
continue;
|
||||
}
|
||||
};
|
||||
|
||||
union Reinterpreter<From, To> {
|
||||
From from;
|
||||
To to;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -4,6 +4,22 @@
|
||||
|
||||
namespace std::string {
|
||||
|
||||
struct SizedStringBase<SizeType, DataType> {
|
||||
SizeType size;
|
||||
DataType data[size];
|
||||
} [[sealed, format("std::string::impl::format_sized_string"), transform("std::string::impl::format_sized_string")]];
|
||||
|
||||
using SizedString<SizeType> = SizedStringBase<SizeType, char>;
|
||||
using SizedString16<SizeType> = SizedStringBase<SizeType, char16>;
|
||||
|
||||
namespace impl {
|
||||
|
||||
fn format_sized_string(ref auto string) {
|
||||
return string.data;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
fn length(str string) {
|
||||
return builtin::std::string::length(string);
|
||||
};
|
||||
|
||||
31
includes/type/base.pat
Normal file
31
includes/type/base.pat
Normal file
@@ -0,0 +1,31 @@
|
||||
#pragma once
|
||||
|
||||
#include <std/io.pat>
|
||||
#include <std/math.pat>
|
||||
|
||||
namespace type {
|
||||
|
||||
using Hex<T> = T [[format("type::impl::format_hex")]];
|
||||
using Oct<T> = T [[format("type::impl::format_oct")]];
|
||||
using Dec<T> = T [[format("type::impl::format_dec")]];
|
||||
using Bin<T> = T [[format("type::impl::format_bin")]];
|
||||
|
||||
namespace impl {
|
||||
|
||||
fn format_number(auto value, str fmt) {
|
||||
bool negative = value < 0;
|
||||
|
||||
if (negative)
|
||||
return std::format("-" + fmt, std::math::abs(value));
|
||||
else
|
||||
return std::format(fmt, value);
|
||||
};
|
||||
|
||||
fn format_hex(auto value) { return format_number(value, "0x{:02X}"); };
|
||||
fn format_oct(auto value) { return format_number(value, "0o{:03o}"); };
|
||||
fn format_dec(auto value) { return format_number(value, "{}"); };
|
||||
fn format_bin(auto value) { return format_number(value, "0b{:08b}"); };
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
#include <std/io.pat>
|
||||
#include <std/math.pat>
|
||||
#include <std/mem.pat>
|
||||
|
||||
namespace type {
|
||||
|
||||
@@ -41,10 +42,10 @@ namespace type {
|
||||
result = (sign << 31) | ((exponent + (0x7F - 15)) << 23) | (mantissa << 13);
|
||||
}
|
||||
|
||||
U32ToFloatConverter converter;
|
||||
converter.intValue = result;
|
||||
std::mem::Reinterpreter<u32, float> converter;
|
||||
converter.from = result;
|
||||
|
||||
return std::format("{}", converter.floatValue);
|
||||
return std::format("{}", converter.to);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -1,13 +1,14 @@
|
||||
#pragma once
|
||||
#include <std/io.pat>
|
||||
|
||||
namespace type {
|
||||
|
||||
using Size8 = u8 [[format("type::impl::size_formatter")]];
|
||||
using Size16 = u16 [[format("type::impl::size_formatter")]];
|
||||
using Size32 = u32 [[format("type::impl::size_formatter")]];
|
||||
using Size64 = u64 [[format("type::impl::size_formatter")]];
|
||||
using Size128 = u128 [[format("type::impl::size_formatter")]];
|
||||
using Size<T> = T [[format("type::impl::size_formatter")]];
|
||||
|
||||
using Size8 = Size<u8>;
|
||||
using Size16 = Size<u16>;
|
||||
using Size32 = Size<u32>;
|
||||
using Size64 = Size<u64>;
|
||||
using Size128 = Size<u128>;
|
||||
|
||||
namespace impl {
|
||||
|
||||
@@ -45,4 +46,4 @@ namespace type {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user