D-Bug & Automation Forum | |
D-Bug & Automation Forum >> Coding >> Either a force relocation packer or a routine to relocate
http://d-bug.mooo.com/dbugforums/cgi-bin/yabb2/YaBB.pl?num=1334222877 Message started by Phill on 12.04.12 at 09:27:56 |
Title: Re: Either a force relocation packer or a routine to relocate Post by ggn on 12.04.12 at 10:18:07
Hi Phill,
assuming that a0 points to the start of the .prg, you can use this code to relocate: [code] movem.l D0-A6,-(SP) lea 2(A0),A1 lea $001C(A0),A0 move.l A0,D0 adda.l (A1)+,A0 ; text adda.l (A1)+,A0 ; data lea (A0),A3 ; BSS Start move.l (A1)+,D3 ; bss adda.l (A1)+,A0 ; rest (symboltable) move.l (A0)+,D1 ;relocation info ?? beq.s end_relocation ;nope... movea.l D0,A1 ; text start adda.l D1,A1 ;1st adress - long offset moveq #0,D1 moveq #1,D2 relo_do: add.l D0,(A1) ;relocate! RELO2: move.b (A0)+,D1 beq.s end_relocation cmp.b D2,D1 bne.s normal_distance lea 254(A1),A1 bra.s RELO2 normal_distance: adda.l D1,A1 bra.s relo_do end_relocation:[/code] So I guess you should grab the program from the pasti, load it (or unpack it) at the address you want, relocate it and apply any stuff from Was (not Was) to remove the protection bits or whatnot. Was' version doesn't have any relocate table, so it's pretty risky trying to relocate it yourself. Hope this helps. |
D-Bug & Automation Forum » Powered by YaBB 2.6.0! YaBB Forum Software © 2000-2024. All Rights Reserved. |