mirror of
https://git.recroomarchive.org/Radium/libradhook.git
synced 2026-08-07 09:10:59 +00:00
fix: split files, add padding and return checking on disasm
This commit is contained in:
57
include/radhook/private/disassemble.h
Normal file
57
include/radhook/private/disassemble.h
Normal file
@@ -0,0 +1,57 @@
|
||||
#ifndef __LIBRADHOOK_PRIVATE_DISASSEMBLE_H__
|
||||
#define __LIBRADHOOK_PRIVATE_DISASSEMBLE_H__
|
||||
|
||||
#include "radhook/defines.h"
|
||||
|
||||
#if defined(RADIUM_PLATFORM_WINDOWS)
|
||||
# ifndef WIN32_LEAN_AND_MEAN
|
||||
# define WIN32_LEAN_AND_MEAN
|
||||
# endif
|
||||
# include <windows.h>
|
||||
#elif defined(RADIUM_PLATFORM_ANDROID)
|
||||
# include <sys/mman.h>
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
|
||||
#if defined(RADHOOK_ARCH_X64)
|
||||
struct X64Insn {
|
||||
size_t length = 0;
|
||||
bool ripRelative = false;
|
||||
size_t dispOffset = 0;
|
||||
bool relativeControlFlow = false;
|
||||
bool isReturn = false;
|
||||
bool isPadding = false;
|
||||
bool valid = false;
|
||||
};
|
||||
|
||||
X64Insn
|
||||
DecodeX64(
|
||||
const uint8_t* p,
|
||||
size_t avail
|
||||
);
|
||||
|
||||
constexpr size_t kX64StubLen = 14; // FF25 00000000 + imm64
|
||||
constexpr size_t kX64MaxStolen = 32;
|
||||
constexpr size_t kX64MaxRipFixups = 8;
|
||||
|
||||
enum class StolenBytesError {
|
||||
None,
|
||||
BadDecode,
|
||||
RelativeControlFlow,
|
||||
TooManyRipFixups,
|
||||
ExceedsMaxStolen,
|
||||
InsufficientLength,
|
||||
};
|
||||
|
||||
StolenBytesError
|
||||
BuildStolenBytesX64(
|
||||
const uint8_t* target,
|
||||
size_t minLen,
|
||||
uint8_t* outBytes,
|
||||
size_t& outLen,
|
||||
size_t* outRipOffsets,
|
||||
size_t& outRipCount
|
||||
);
|
||||
|
||||
#endif // defined(RADHOOK_ARCH_X64)
|
||||
#endif // __LIBRADHOOK_PRIVATE_DISASSEMBLE_H__
|
||||
Reference in New Issue
Block a user