diff --git a/decompile/src/XDK/CRT/ehdata.h b/decompile/src/XDK/CRT/ehdata.h new file mode 100644 index 0000000..23fe04d --- /dev/null +++ b/decompile/src/XDK/CRT/ehdata.h @@ -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 diff --git a/ghidra/make_header.sh b/ghidra/make_header.sh index 1da52e7..3181dfe 100755 --- a/ghidra/make_header.sh +++ b/ghidra/make_header.sh @@ -10,6 +10,7 @@ printf '%s\n' '// Automatically generated mass header file for Ghidra' > jsrf.h HEADERS=" XDK/CRT/stddef.h XDK/Win32.h + XDK/CRT/ehdata.h XDK/D3D.h MUSASHI/MMatrix.hpp JSRF/Core.hpp