[DRWTSN32][SDK][MSVCRT] Provide some fixes for the base apps

This commit is contained in:
Justin Miller 2023-09-27 23:26:46 -07:00
parent 908d758386
commit 31f4dfe94f
5 changed files with 65 additions and 3 deletions

View file

@ -71,6 +71,17 @@ static void PrintThread(FILE* output, DumpData& data, DWORD tid, ThreadData& thr
ctx.R0, ctx.R1, ctx.R2, ctx.R3, ctx.R4, ctx.R5, ctx.R6);
xfprintf(output, "r7:%p r8:%p r9:%p r10:%p r11:%p r12:%p" NEWLINE,
ctx.R7, ctx.R8, ctx.R9, ctx.R10, ctx.R11, ctx.R12);
#elif defined(_M_ARM64)
xfprintf(output, "x0:%p x1:%p x2:%p x3:%p x4:%p x5:%p x6:%p" NEWLINE,
ctx.X0, ctx.X1, ctx.X2, ctx.X3, ctx.X4, ctx.X5, ctx.X6);
xfprintf(output, "x7:%p x8:%p x9:%p x10:%p x11:%p x12:%p" NEWLINE,
ctx.X7, ctx.X8, ctx.X9, ctx.X10, ctx.X11, ctx.X12);
xfprintf(output, "x13:%p x14:%p x15:%p x16:%p x17:%p x18:%p" NEWLINE,
ctx.X13, ctx.X14, ctx.X15, ctx.X16, ctx.X17, ctx.X18);
xfprintf(output, "x19:%p x20:%p x21:%p x22:%p x23:%p x24:%p" NEWLINE,
ctx.X19, ctx.X20, ctx.X21, ctx.X22, ctx.X23, ctx.X24);
xfprintf(output, "x25:%p x26:%p x27:%p x28:%p" NEWLINE,
ctx.X25, ctx.X26, ctx.X27, ctx.X28);
#else
#error Unknown architecture
#endif
@ -87,6 +98,9 @@ static void PrintThread(FILE* output, DumpData& data, DWORD tid, ThreadData& thr
#elif defined(_M_ARM)
xfprintf(output, "sp:%p lr:%p pc:%p cpsr:%p" NEWLINE,
ctx.Sp, ctx.Lr, ctx.Pc, ctx.Cpsr);
#elif defined(_M_ARM64)
xfprintf(output, "sp:%p pc:%p fpcr:%p fpsr:%p" NEWLINE,
ctx.Sp, ctx.Pc, ctx.Fpcr, ctx.Fpsr);
#else
#error Unknown architecture
#endif
@ -107,6 +121,16 @@ static void PrintThread(FILE* output, DumpData& data, DWORD tid, ThreadData& thr
xfprintf(output, "Wvr%d:%p%s", n, ctx.Wvr[n], ((n + 1) == ARM_MAX_WATCHPOINTS) ? NEWLINE : " ");
for (int n = 0; n < ARM_MAX_WATCHPOINTS; ++n)
xfprintf(output, "Wcr%d:%p%s", n, ctx.Wcr[n], ((n + 1) == ARM_MAX_WATCHPOINTS) ? NEWLINE : " ");
#elif defined(_M_ARM64)
for (int n = 0; n < ARM64_MAX_BREAKPOINTS; ++n)
xfprintf(output, "Bvr%d:%p%s", n, ctx.Bvr[n], ((n + 1) == ARM64_MAX_BREAKPOINTS) ? NEWLINE : " ");
for (int n = 0; n < ARM64_MAX_BREAKPOINTS; ++n)
xfprintf(output, "Bcr%d:%p%s", n, ctx.Bcr[n], ((n + 1) == ARM64_MAX_BREAKPOINTS) ? NEWLINE : " ");
for (int n = 0; n < ARM64_MAX_WATCHPOINTS; ++n)
xfprintf(output, "Wvr%d:%p%s", n, ctx.Wvr[n], ((n + 1) == ARM64_MAX_WATCHPOINTS) ? NEWLINE : " ");
for (int n = 0; n < ARM64_MAX_WATCHPOINTS; ++n)
xfprintf(output, "Wcr%d:%p%s", n, ctx.Wcr[n], ((n + 1) == ARM64_MAX_WATCHPOINTS) ? NEWLINE : " ");
#else
#error Unknown architecture
#endif

View file

@ -64,7 +64,7 @@ void PrintStackBacktrace(FILE* output, DumpData& data, ThreadData& thread)
MachineType = IMAGE_FILE_MACHINE_ARM64;
StackFrame.AddrPC.Offset = thread.Context.Pc;
StackFrame.AddrStack.Offset = thread.Context.Sp;
StackFrame.AddrFrame.Offset = thread.Context.u.s.Fp;
StackFrame.AddrFrame.Offset = thread.Context.Fp;
#else
#error "Unknown architecture"
#endif

View file

@ -230,7 +230,7 @@
@ extern _HUGE
@ cdecl _Strftime(str long str ptr ptr)
@ cdecl _XcptFilter(long ptr)
@ stdcall -arch=x86_64,arm __C_specific_handler(ptr long ptr ptr)
@ stdcall -arch=x86_64,arm,arm64 __C_specific_handler(ptr long ptr ptr)
@ cdecl __CppXcptFilter(long ptr)
@ stub -version=0x600+ -arch=i386 __CxxCallUnwindDelDtor
@ stub -arch=i386 __CxxCallUnwindDtor
@ -240,7 +240,7 @@
@ cdecl -arch=i386,x86_64 -norelay __CxxFrameHandler(ptr ptr ptr ptr)
@ cdecl -arch=i386 -norelay __CxxFrameHandler2(ptr ptr ptr ptr) __CxxFrameHandler
@ cdecl -version=0x600+ -arch=x86_64 -norelay __CxxFrameHandler2(ptr ptr ptr ptr) __CxxFrameHandler
@ cdecl -arch=arm -norelay __CxxFrameHandler3(ptr ptr ptr ptr)
@ cdecl -arch=arm,arm64 -norelay __CxxFrameHandler3(ptr ptr ptr ptr)
@ cdecl -version=0x600+ -arch=i386 -norelay __CxxFrameHandler3(ptr ptr ptr ptr)
@ cdecl -version=0x600+ -arch=x86_64 -norelay __CxxFrameHandler3(ptr ptr ptr ptr) __CxxFrameHandler
@ stdcall -arch=i386 __CxxLongjmpUnwind(ptr)

View file

@ -224,6 +224,27 @@ struct thunkCode
}
};
#pragma pack(pop)
#elif defined(_M_ARM64)
#pragma pack(push,4)
struct thunkCode
{
DWORD64 m_mov_x0; /* mov r0, m_this */
DWORD64 m_mov_pc; /* mov pc, m_proc */
DWORD64 m_this;
DWORD64 m_proc;
void
Init(WNDPROC proc, void *pThis)
{
m_mov_x0 = 0xE59F0000;
m_mov_pc = 0xE59FF000;
m_this = (DWORD64)pThis;
m_proc = (DWORD64)proc;
FlushInstructionCache(GetCurrentProcess(), this, sizeof(thunkCode));
}
};
#pragma pack(pop)
#else
#error ARCH not supported

View file

@ -47,7 +47,24 @@ ENDM
CREATE_ALIAS2 $alias, $target
IMPORT IMPSYM($alias), WEAK IMPSYM($target)
MEND
MACRO
CREATE_ALIAS $alias, $target
CREATE_ALIAS1 $alias, $target
CREATE_ALIAS2 $alias, $target
MEND
#elif defined(_M_ARM64)
#include <kxarm64.h>
MACRO
CREATE_ALIAS1 $alias, $target
IMPORT SYM($alias), WEAK SYM($target)
MEND
MACRO
CREATE_ALIAS2 $alias, $target
IMPORT IMPSYM($alias), WEAK IMPSYM($target)
MEND
MACRO
CREATE_ALIAS $alias, $target
CREATE_ALIAS1 $alias, $target