Add ehdata.h

Bunch of spooky low-level exception handling stuff needed to delinking
working again.
This commit is contained in:
KeybadeBlox 2026-03-20 23:29:39 -04:00
parent e58f774d82
commit b95a664688
2 changed files with 159 additions and 0 deletions

View file

@ -0,0 +1,158 @@
/* JSRF Decompilation: XDK/CRT/ehdata.h
Internal exception handling structures.
*/
#ifndef EHDATA_H
#define EHDATA_H
#include "../Win32.h"
struct ThrowInfo {
unsigned attributes;
int pmfnUnwind;
int pForwardCompat;
int pCatchableTypeArray;
};
struct ExceptionParameters {
DWORD magicNumber;
void * pExceptionObject;
ThrowInfo * pThrowInfo;
void * pThrowImageBase;
};
struct ExceptionRecord {
DWORD ExceptionCode;
DWORD ExceptionFlags;
ExceptionRecord * ExceptionRecord;
void * ExceptionAddress;
DWORD NumberParameters;
ExceptionParameters Params;
};
typedef ULONG EHRegistrationNode;
struct EH_RUNTIME_FUNCTION {
DWORD BeginAddress;
DWORD EndAddress;
DWORD UnwindData;
};
// Saved floating point register context
struct REG_CONTEXT_FLOAT {
WORD ControlWord;
WORD StatusWord;
WORD TagWord;
WORD ErrorOpcode;
DWORD ErrorOffset;
DWORD ErrorSelector;
DWORD DataOffset;
DWORD DataSelector;
DWORD MXCsr;
DWORD Reserved2;
BYTE RegisterArea[128];
BYTE XmmRegisterArea[128];
BYTE Reserved4[224];
DWORD Cr0NpxState;
};
// Saved register context
struct REG_CONTEXT {
DWORD ContextFlags;
REG_CONTEXT_FLOAT FloatSave;
DWORD Edi;
DWORD Esi;
DWORD Ebx;
DWORD Edx;
DWORD Ecx;
DWORD Eax;
DWORD Ebp;
DWORD Eip;
DWORD SegCs;
DWORD EFlags;
DWORD Esp;
DWORD SegSs;
};
struct EH_UNWIND_HISTORY_TABLE_ENTRY {
ULONGLONG ImageBase;
EH_RUNTIME_FUNCTION * FunctionEntry;
};
struct EH_UNWIND_HISTORY_TABLE {
DWORD Count;
BYTE LocalHint;
BYTE GlobalHint;
BYTE Search;
BYTE Once;
ULONGLONG LowAddress;
ULONGLONG HighAddress;
EH_UNWIND_HISTORY_TABLE_ENTRY Entry[12];
};
struct EHDispatcherContext {
LONGLONG ControlPc;
LONGLONG ImageBase;
EH_RUNTIME_FUNCTION * FunctionEntry;
ULONG EstablisherFrame;
ULONGLONG TargetIp;
REG_CONTEXT * ContextRecord;
void * LanguageHandler;
void * HandlerData;
EH_UNWIND_HISTORY_TABLE * HistoryTable;
};
// One of these is emitted for each section of each function that needs to
// handle unwinding
struct EHUnwindMapEntry {
int toState;
void * action;
};
struct EHTypeDescriptor {
void * pVFTable;
void * spare;
char name[0];
};
struct EHHandlerType {
DWORD adjectives;
EHTypeDescriptor * pType;
int dispCatchObj;
void * addressOfHandler;
};
// One of these is emitted for each try block of each function that needs to
// handle unwinding
struct EHTryBlockMapEntry {
int tryLow;
int tryHigh;
int catchHigh;
int nCatches;
EHHandlerType * pHandlerArray;
};
// When a function needs unwinding code generated, this struct is emitted, and
// a function is also emitted that calls __CxxFrameHandler() with a pointer to
// said struct
struct EHFuncInfo {
DWORD magicNumber;
int maxState;
EHUnwindMapEntry * pUnwindMap; // Pointer to array
DWORD nTryBlocks;
EHTryBlockMapEntry * pTryBlockMap; // Pointer to array
DWORD nIPMapEntries;
void * pIPtoStateMap;
};
enum EH_EXCEPTION_DISPOSITION {
ExceptionContinueExecution,
ExceptionContinueSearch,
ExceptionNestedException,
ExceptionCollidedUnwind
};
#endif