Skip to content

Commit

Permalink
Old bugfix for decompiling
Browse files Browse the repository at this point in the history
  • Loading branch information
TheGag96 committed Oct 20, 2017
1 parent 0707938 commit fed0ddb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion dub.sdl
Original file line number Diff line number Diff line change
Expand Up @@ -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/"
dflags "-Jsource/" "-boundscheck=on"
11 changes: 6 additions & 5 deletions source/app.d
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit fed0ddb

Please sign in to comment.