Fix MSVC Arm support ##port

This commit is contained in:
Richard Patel 2024-02-18 03:33:17 +00:00 committed by pancake
parent 3e4110a5af
commit add975a801
5 changed files with 25 additions and 7 deletions

View File

@ -598,7 +598,7 @@ static ut32 rbit(ArmOp *op) {
return data;
}
static ut32 mvn(ArmOp *op) {
static ut32 _mvn(ArmOp *op) {
ut32 data = UT32_MAX;
check_cond(op->operands[0].type == ARM_GPR);
@ -1903,7 +1903,7 @@ bool arm64ass(const char *str, ut64 addr, ut32 *op) {
} else if (!strncmp (str, "rev", 3)) {
*op = rev (&ops);
} else if (!strncmp (str, "mvn", 3)) {
*op = mvn (&ops);
*op = _mvn (&ops);
} else if (!strncmp (str, "rbit", 4)) {
*op = rbit (&ops);
} else if (!strncmp (str, "tst", 3)) {

View File

@ -1498,7 +1498,11 @@ static int r_debug_native_bp(RBreakpoint *bp, RBreakpointItem *b, bool set) {
// no hw bps afaik
return false;
#else
#ifdef _MSC_VER
#pragma message ( "r_debug_native_bp not implemented for this platform" )
#else
#warning r_debug_native_bp not implemented for this platform
#endif
#endif
}
return false;

View File

@ -124,7 +124,7 @@ static int windbg_stop(RDebug *dbg) {
static bool do_break = false;
static void __break(void *user) {
static void break_action(void *user) {
RDebug *dbg = (RDebug *)user;
DbgEngContext *idbg = dbg->user;
if (__is_target_kernel (idbg)) {
@ -137,7 +137,7 @@ static RDebugReasonType windbg_wait(RDebug *dbg, int pid) {
DbgEngContext *idbg = dbg->user;
r_return_val_if_fail (idbg && idbg->initialized, 0);
ULONG Type, ProcessId, ThreadId;
r_cons_break_push (__break, dbg);
r_cons_break_push (break_action, dbg);
const ULONG timeout = __is_target_kernel (idbg) ? INFINITE : TIMEOUT;
HRESULT hr;
while ((hr = ITHISCALL (dbgCtrl, WaitForEvent, DEBUG_WAIT_DEFAULT, timeout)) == S_FALSE) {

View File

@ -216,7 +216,9 @@ static void __printwincontext(HANDLE th, CONTEXT *ctx) {
ut64 mm[8];
ut16 top = 0;
int x, nxmm = 0, nymm = 0;
#if _WIN64
#if _M_ARM64
/* pass */
#elif _WIN64
eprintf ("ControlWord = %08x StatusWord = %08x\n", ctx->FltSave.ControlWord, ctx->FltSave.StatusWord);
eprintf ("MxCsr = %08lx TagWord = %08x\n", ctx->MxCsr, ctx->FltSave.TagWord);
eprintf ("ErrorOffset = %08lx DataOffset = %08lx\n", ctx->FltSave.ErrorOffset, ctx->FltSave.DataOffset);
@ -327,6 +329,7 @@ int w32_reg_read(RDebug *dbg, int type, ut8 *buf, int size) {
}
static void __transfer_drx(RDebug *dbg, const ut8 *buf) {
#ifndef _M_ARM64
CONTEXT cur_ctx;
if (w32_reg_read (dbg, R_REG_TYPE_ALL, (ut8 *)&cur_ctx, sizeof (CONTEXT))) {
CONTEXT *new_ctx = (CONTEXT *)buf;
@ -334,6 +337,7 @@ static void __transfer_drx(RDebug *dbg, const ut8 *buf) {
memcpy (&cur_ctx.Dr0, &new_ctx->Dr0, drx_size);
*new_ctx = cur_ctx;
}
#endif
}
int w32_reg_write(RDebug *dbg, int type, const ut8 *buf, int size) {
@ -748,7 +752,9 @@ static const char *get_exception_name(DWORD ExceptionCode) {
EXCEPTION_STR (EXCEPTION_SINGLE_STEP);
EXCEPTION_STR (EXCEPTION_STACK_OVERFLOW);
EXCEPTION_STR (STATUS_UNWIND_CONSOLIDATE);
#ifndef _M_ARM64
EXCEPTION_STR (EXCEPTION_POSSIBLE_DEADLOCK);
#endif
EXCEPTION_STR (DBG_CONTROL_BREAK);
EXCEPTION_STR (CONTROL_C_EXIT);
case 0x6ba: return "FILE_DIALOG_EXCEPTION";
@ -998,10 +1004,12 @@ bool w32_step(RDebug *dbg) {
if (!w32_reg_read (dbg, R_REG_TYPE_GPR, (ut8 *)&ctx, sizeof (ctx))) {
return false;
}
#ifndef _M_ARM64
ctx.EFlags |= 0x100;
if (!w32_reg_write (dbg, R_REG_TYPE_GPR, (ut8 *)&ctx, sizeof (ctx))) {
return false;
}
#endif
// (void)r_debug_handle_signals (dbg);
return w32_continue (dbg, dbg->pid, dbg->tid, dbg->reason.signum);
}
@ -1132,7 +1140,9 @@ RList *w32_thread_list(RDebug *dbg, int pid, RList *list) {
dbg->tid = te.th32ThreadID;
w32_reg_read (dbg, R_REG_TYPE_GPR, (ut8 *)&ctx, sizeof (ctx));
// TODO: is needed check context for x32 and x64??
#if _WIN64
#if _M_ARM64
pc = ctx.Pc;
#elif _WIN64
pc = ctx.Rip;
#else
pc = ctx.Eip;

View File

@ -602,7 +602,11 @@ static inline void *r_new_copy(int size, void *data) {
# endif
#else
#ifdef _MSC_VER
#ifdef _WIN64
#if defined(_M_ARM64)
#define R_SYS_ARCH "arm"
#define R_SYS_BITS R_SYS_BITS_64
#define R_SYS_ENDIAN 0
#elif defined(_WIN64)
#define R_SYS_ARCH "x86"
#define R_SYS_BITS (R_SYS_BITS_32 | R_SYS_BITS_64)
#define R_SYS_ENDIAN 0