Its probably better to build it from scratch.
Something like this:
https://www.codeproject.com/articles/17263/moving-to-windows-vista-x64Quote:
Remember the old days when you set the SEH in your code?
Well, with x64/Itanium they're gone.
Exception Handlers are now stored as structured in the PE64 Exception Directory.
Quote:
If you need to generate code dynamically and set for it an exception handler, you can use the function RtlAddFunctionTable, which takes as parameter an array of RUNTIME_FUNCTION structures. This means, of course, that you'll have to fill one or more UNWIND_INFO structure/s by yourself.
Other links:
https://docs.microsoft.com/en-us/cpp/build/exception-handling-x64?view=vs-2019http://www.osronline.com/article.cfm%5earticle=469.htmhttps://stackoverflow.com/questions/28549775/seh-handlers-using-rtladdfunctiontableSome (hopefully) translated structs:
Code:
EnableExplicit
Enumeration UNWIND_OP_CODES
#UWOP_PUSH_NONVOL = 0 ;info == register number
#UWOP_ALLOC_LARGE ;no info, alloc size in Next 2 slots
#UWOP_ALLOC_SMALL ;info == size of allocation / 8 - 1
#UWOP_SET_FPREG ;no info, FP = RSP + UNWIND_INFO.FPRegOffset*16
#UWOP_SAVE_NONVOL ;info == register number, offset in Next slot
#UWOP_SAVE_NONVOL_FAR ;info == register number, offset in Next 2 slots
#UWOP_SAVE_XMM128 = 8 ;info == XMM reg number, offset in next slot
#UWOP_SAVE_XMM128_FAR ;info == XMM reg number, offset in next 2 slots
#UWOP_PUSH_MACHFRAME ;info == 0: no error-code, 1: error-code
EndEnumeration
#UNW_FLAG_EHANDLER = $1
#UNW_FLAG_UHANDLER = $2
#UNW_FLAG_CHAININFO = $4
Structure RUNTIME_FUNCTION Align 4
BeginAddress.l
EndAddress.l
UnwindData.l
EndStructure
Structure UNWIND_CODE_INFO
CodeOffset.a
UnwindOp.a[4]
OpInfo.a[4]
EndStructure
Structure UNWIND_CODE
StructureUnion
Info.UNWIND_CODE_INFO
FrameOffset.u
EndStructureUnion
EndStructure
Structure UNWIND_INFO Align 4
Version.a[3]
Flags.a[5]
SizeOgProlog.a
CountOfCodes.a
FrameRegister.a[4]
FrameOffset.a[4]
UnwindCode.UNWIND_CODE[0]
EndStructure
;-> https://docs.microsoft.com/en-us/cpp/build/exception-handling-x64?view=vs-2019
;-> On runtime we could use: RtlAddFunctionTable_()
Im not sure how to actually do it yet, so unless someone wants to help with this
i rather invest my time in something different.