mirror of
https://github.com/hedge-dev/XenonRecomp.git
synced 2025-06-06 01:02:08 +00:00
Add X_RUNTIME_FUNCTION
This commit is contained in:
parent
6e48ca31ab
commit
9d6c760ab9
@ -20,6 +20,19 @@ const void* Image::Find(size_t address) const
|
||||
return section->data + (address - section->base);
|
||||
}
|
||||
|
||||
const Section* Image::Find(const std::string_view& name) const
|
||||
{
|
||||
for (const auto& section : sections)
|
||||
{
|
||||
if (section.name == name)
|
||||
{
|
||||
return §ion;
|
||||
}
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
std::expected<Image, int> Image::ParseImage(const uint8_t* data, size_t size)
|
||||
{
|
||||
if (data[0] == ELFMAG0 && data[1] == ELFMAG1 && data[2] == ELFMAG2 && data[3] == ELFMAG3)
|
||||
|
@ -32,6 +32,12 @@ struct Image
|
||||
*/
|
||||
const void* Find(size_t address) const;
|
||||
|
||||
/**
|
||||
* \param name Name of section
|
||||
* \return Section
|
||||
*/
|
||||
const Section* Find(const std::string_view& name) const;
|
||||
|
||||
/**
|
||||
* \brief Parse given data to an image, reallocates with ownership
|
||||
* \param data Pointer to data
|
||||
|
@ -162,6 +162,24 @@ struct _XLIST_ENTRY;
|
||||
typedef _XLIST_ENTRY XLIST_ENTRY;
|
||||
typedef xpointer<XLIST_ENTRY> PXLIST_ENTRY;
|
||||
|
||||
typedef struct _X_RUNTIME_FUNCTION
|
||||
{
|
||||
DWORD BeginAddress;
|
||||
|
||||
union
|
||||
{
|
||||
DWORD Data;
|
||||
struct
|
||||
{
|
||||
DWORD FunctionType : 2;
|
||||
DWORD FunctionLength : 22;
|
||||
DWORD PrologLength : 8;
|
||||
};
|
||||
};
|
||||
} X_RUNTIME_FUNCTION;
|
||||
|
||||
static_assert(sizeof(X_RUNTIME_FUNCTION) == 8);
|
||||
|
||||
typedef struct _XLIST_ENTRY
|
||||
{
|
||||
XDWORD Flink;
|
||||
|
@ -90,12 +90,6 @@ typedef struct _XEX_HEADER
|
||||
be<uint32_t> NumberOfOptionalHeaders;
|
||||
} XEX_HEADER;
|
||||
|
||||
typedef struct _X_RUNTIME_FUNCTION
|
||||
{
|
||||
be<DWORD> BeginAddress;
|
||||
be<DWORD> Flags; // honestly, no idea
|
||||
} X_RUNTIME_FUNCTION;
|
||||
|
||||
template<typename T>
|
||||
inline static const T* Xex2FindOptionalHeader(const void* base, const XEX_OPTIONAL_HEADER* headers, size_t n, _XEX_OPTIONAL_HEADER_TYPES type)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user