From fed0ddbbaeef15a2fcc9a9ef8bdfb4dfa3efb19b Mon Sep 17 00:00:00 2001 From: TheGag96 Date: Thu, 19 Oct 2017 23:51:13 -0500 Subject: [PATCH] Old bugfix for decompiling --- dub.sdl | 2 +- source/app.d | 11 ++++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/dub.sdl b/dub.sdl index bd1b192..5728a36 100644 --- a/dub.sdl +++ b/dub.sdl @@ -4,4 +4,4 @@ copyright "Copyright © 2015, codeThaumaturge" authors "codeThaumaturge" dependency "tkd" version="~>1.1.4" sourceFiles "source/icon.res" "source/noconsole.def" platform="windows" -dflags "-Jsource/" \ No newline at end of file +dflags "-Jsource/" "-boundscheck=on" \ No newline at end of file diff --git a/source/app.d b/source/app.d index 4e9e740..3452622 100644 --- a/source/app.d +++ b/source/app.d @@ -2,7 +2,7 @@ import tkd.tkdapplication; import std.stdio, std.file, std.process, std.array, std.conv, std.string, std.regex, std.algorithm, std.range; -enum VERSION = "1.0.3"; +enum VERSION = "1.0.4"; class Application : TkdApplication { Text asmBox; @@ -354,15 +354,16 @@ class Application : TkdApplication { if (line.startsWith('b')) { string opcode = line[0..line.countUntil(' ')]; - uint jumpLocation = line[opcode.length+3 .. $].to!int(16); + int jumpLocation = cast(int) (line[opcode.length+3 .. $].to!uint(16)); - if (jumpLocation > codeSize) { + if (jumpLocation > codeSize || jumpLocation < 0) { //check for absolute branches if (opcode.endsWith('a') || opcode.endsWith("a+") || opcode.endsWith("a-")) { - fixed.put(format(" %s 0x%X\n", opcode, jumpLocation)); + fixed.put(format(" %s 0x%X\n", opcode, cast(uint)jumpLocation)); } else { - fixed.put(format(" %s 0x%X\n", opcode, jumpLocation-pos)); + if (jumpLocation >= 0) fixed.put(format(" %s 0x%X\n", opcode, jumpLocation-pos)); + else fixed.put(format(" %s -0x%X\n", opcode, -jumpLocation+pos)); } } else {