Amiga.org

Amiga computer related discussion => Amiga Hardware Issues and discussion => Topic started by: AF-Domains.net on January 02, 2005, 08:12:52 PM

Title: Extracting files from a kickstart rom
Post by: AF-Domains.net on January 02, 2005, 08:12:52 PM
Is there any sort of command or program that can extract files or code from a kickstart rom?

Thanks

AF-Domains.net
Title: Re: Extracting files from a kickstart rom
Post by: Piru on January 02, 2005, 08:35:58 PM
Quote
Is there any sort of command or program that can extract files or code from a kickstart rom?

No.

There is no generic solution to this problem (basically the problem is that relocs needs to be resolved properly, the code needs to be de-relocated. This is handwork).

Some tools might exist that extract single module (typically these tools have the specific relocs hardcoded).
Title: Re: Extracting files from a kickstart rom
Post by: Matt_H on January 02, 2005, 09:49:09 PM
There's a tool on Aminet by THOR that will extract the modules from the 3.5 or 3.9 update files, but I don't think there's any way to break apart the actual kickstart.
Title: Re: Extracting files from a kickstart rom
Post by: AF-Domains.net on January 02, 2005, 09:50:15 PM
What is the name of the tool?
Title: Re: Extracting files from a kickstart rom
Post by: Matt_H on January 02, 2005, 09:56:11 PM
It's included in the ShellUpdate (http://ftp.plig.org/pub/aminet/util/boot/ShellUpdate.lha) package. I have no idea how to use it properly, however.
Title: Re: Extracting files from a kickstart rom
Post by: AF-Domains.net on January 02, 2005, 09:58:25 PM
What sort of coding or programming languages was the kickstart rom written in?

Since that might help.
Title: Re: Extracting files from a kickstart rom
Post by: Piru on January 02, 2005, 10:35:25 PM
@AF-Domains.net
Quote
What sort of coding or programming languages was the kickstart rom written in?

Assembler and C.

Quote
Since that might help.

No, it really doesn't.
Title: Re: Extracting files from a kickstart rom
Post by: Piru on January 02, 2005, 10:41:02 PM
@AF-Domains.net

I wrote such tool for BlizKick, too. It's called "romupdatesplit" and comes with full source code (well, it's AmigaE though... :-)) BlizKick.lha (http://www.iki.fi/sintonen/sw/BlizKick.lha) has the binary and source code included.

The usage is quite easy, for example:
Code: [Select]
romupdatesplit from "DEVS:AmigaOS ROM Update" to T:
This extracts the modules matching the current system.

To extract all modules, regardless of system type, use ALL/S.
Title: Re: Extracting files from a kickstart rom
Post by: AF-Domains.net on January 05, 2005, 02:42:30 AM
Since it is next to impossible to extract files from the kickrom is it possible to disassemble a kickrom file?
Title: Re: Extracting files from a kickstart rom
Post by: Matt_H on January 05, 2005, 03:33:30 AM
Quote
Since it is next to impossible to extract files from the kickrom is it possible to disassemble a kickrom file?

A) I don't think so, and
B) The legality of such an attempt is questionable.

What are you trying to do, anyway?
Title: Re: Extracting files from a kickstart rom
Post by: AF-Domains.net on January 05, 2005, 07:05:57 AM
I am trying to merge kcikstart 1.4 A15 with kick 3.1 to create a custom rom for my use only.
Title: Re: Extracting files from a kickstart rom
Post by: Piru on January 05, 2005, 07:40:46 AM
@AF-Domains.net
Quote
Since it is next to impossible to extract files from the kickrom is it possible to disassemble a kickrom file?

Yes.

However, the problem remains the same: You need to decide whether values between 0x00f80000-0x00ffffff are pointers (reloc) or data. If you get even single item wrong, the reassembled module will misbehave (in some conditions).
Title: Re: Extracting files from a kickstart rom
Post by: AF-Domains.net on January 05, 2005, 10:05:31 PM
Which are the best Assembly and C programming tools to use to disassemble the kick roms with?
Title: Re: Extracting files from a kickstart rom
Post by: seer on January 05, 2005, 10:20:20 PM
You need to decide whether values between 0x00f80000-0x00ffffff are pointers (reloc) or data

Ok, this is something I don't understand. I mean, something must read the ROM otherwise the Amiga doesn't work/boot. So, doesn't that mean you can make a tool that does almost the same ? Read the rom and extract the needed modules ?

Ok, I really have no clue about programming issues, but to me this sounds like "nobody can read a certain book but it can be translated..."

Title: Re: Extracting files from a kickstart rom
Post by: AF-Domains.net on January 05, 2005, 10:27:00 PM
I have already downloaded several programs off aminet to attempt to look inside the kickrom file but it mostly comes out as total garbage, I assume that it probably has something to do with the C programming that the rom was also programmed in.
Title: Re: Extracting files from a kickstart rom
Post by: Piru on January 05, 2005, 11:05:14 PM
@AF-Domains.net
Quote
Which are the best Assembly and C programming tools to use to disassemble the kick roms with?


The best tool for disassembling on Amiga is ReSource (by The Puzzle Factory, Inc.), a commercial tool dedicated for disassembly.

Quote
I have already downloaded several programs off aminet to attempt to look inside the kickrom file but it mostly comes out as total garbage, I assume that it probably has something to do with the C programming that the rom was also programmed in.

Not really. The problem is that there is no easy way determining which part of the binary is data and which is code. So these tools probably blindly disassemble everything as code, and that will never work.

Even with ReSource you still need to manually "guide" the program, adjust the code/data selection (and data type selection) if and when ReSource automagic disassembly gets it wrong.

This is only very very brief explanation, but I am sure this (and your troubles with initial attemps) give you an idea of the magnitude of the problems you're tacking with.
Title: Re: Extracting files from a kickstart rom
Post by: AF-Domains.net on January 05, 2005, 11:12:18 PM
I think I have a very good idea of what I am getting myself into.

After browsing the internet for glimpses of the kickrom programming I only found the brief extract of the fake kick 3.5 rom.

The coding that I saw on that site and the coding I get when running one of the many programs on my 1200 is completely different.

If I succeed on being able to reprogram a romfile it won't be distributed anywhere.
Title: Re: Extracting files from a kickstart rom
Post by: Piru on January 05, 2005, 11:12:23 PM
@seer

Quote
Ok, this is something I don't understand. I mean, something must read the ROM otherwise the Amiga doesn't work/boot.

True.

Quote
So, doesn't that mean you can make a tool that does almost the same ? Read the rom and extract the needed modules ?

No.



The problem is that the specific modules are absolutely relocated at link stage to fixed memory address, and there is no (easy) way to get the relocation information from the already absolute-address linked ROM.

The grabbed modules would only work when mapped exactly the addresses they were located originally. And if you think for a moment this means that the order of the modules can't be changed (some modules could be left out and holes filled with other things, though).

So the problem is that unless if the ripped modules are made 'relocatable' they cannot be 'moved' from their original address. This work of figuring out the 'relocs' for arbitrary ROM part is extremely hard. It certainly cannot be made 100% automatic (some tools can be made that figure out the obvious cases though, but still a lot of manual work is needed).

I hope this explanation helps and isn't too technical.
Title: Re: Extracting files from a kickstart rom
Post by: seer on January 05, 2005, 11:23:55 PM
I hope this explanation helps and isn't too technical.

Thanks for trying ;-) Let's just say the fixed memory address and absolute-address make it a bit hard to understand the problem. But guess I'm looking at it from a "simpeler point of view".

But I suppose it means that if you read the ROM and dump the info, the links inside the ROM are pointing to a certain "adress", so if you put the code at another adress it won't work anymore.

But then, if you know the correct location, and the intention is to "recreate" the ROM or in this case a merged 1.4 + 3.1 ROM couldn't you dump the files in RAM or disk, then "disasemble" it, and reprogram it a bit or put it back in another ROM and have the correct adresses again ?


Well, I did say I'm looking at it from a very different and simpel POV.



Title: Re: Extracting files from a kickstart rom
Post by: AF-Domains.net on January 05, 2005, 11:30:22 PM
Would it be possible to copy both roms onto a flashrom and modify them from their instead of dumping them to disk?

I am creating a merged 1.4 and 3.1 rom to add some of the features that were in 1.4 but were never implemented into later versions of the kickstart and also to see if I can improve any part of both of the roms.
Title: Re: Extracting files from a kickstart rom
Post by: Piru on January 06, 2005, 12:33:00 AM
@seer
Quote
But I suppose it means that if you read the ROM and dump the info, the links inside the ROM are pointing to a certain "adress", so if you put the code at another adress it won't work anymore.

That's precisely what the problem is.

Quote
But then, if you know the correct location, and the intention is to "recreate" the ROM or in this case a merged 1.4 + 3.1 ROM couldn't you dump the files in RAM or disk, then "disasemble" it, and reprogram it a bit or put it back in another ROM and have the correct adresses again ?

The obvious problem here is that both roms use the *same* addresses, and thus the modules would overlap. It might be possible to find certain combinations that could be merged without overlap, but it's very unlikely you could find really useful combos, esp since traditionally the modules are linked in certain fixed order (that appears to be a side-effect from the link phase).

@AF-Domains.net
Quote
Would it be possible to copy both roms onto a flashrom and modify them from their instead of dumping them to disk?

Sure. But you still need to relocate the other image or they will overlap. And to do that you need to know exactly where to subtract the original address and add the new one (that's what re-relocation is basically: newptr = oldptr - oldbase + newbase).

Quote
I am creating a merged 1.4 and 3.1 rom to add some of the features that were in 1.4 but were never implemented into later versions of the kickstart and also to see if I can improve any part of both of the roms.

You still need to resolve all the relocs for the components you swap / merge.
Title: Re: Extracting files from a kickstart rom
Post by: Doobrey on January 06, 2005, 12:34:40 AM
Quote

seer wrote:
 the links inside the ROM are pointing to a certain "adress", so if you put the code at another adress it won't work anymore.


Yup

Quote

But then, if you know the correct location, and the intention is to "recreate" the ROM or in this case a merged 1.4 + 3.1 ROM couldn't you dump the files in RAM or disk, then "disasemble" it, and reprogram it a bit or put it back in another ROM and have the correct adresses again ?


Almost..
It depends what you`re putting into the other ROM.
If the replacement code is smaller, then it`s not a problem as you can simply overwrite the old code.
But if the new code is larger, then you`ve got to reorganise the other parts in the rom, to get the new code to fit.
 This is where it gets messy, since that means working out bucketloads of new addresses to be patched.

 But as Piru said, it`s not a trivial task to split up a ROM.You gotta know where one part ends and another starts, which isn`t always obvious  :pissed:
 Some parts are easy, as they only have 6 relocs to find, but graphics.library is a real headache , somewhere around 2500 relocs to sort out... and they vary from rom to rom.

 It ain`t an easy task, it took me over 3 months to get a working 3.9 boot rom, but it`s a lot of fun and a great way to learn more about how the AmigaOS really works.. anyway stay tuned, I`m almost ready for some suckers...erm, beta testers   :evilgrin:
Title: Re: Extracting files from a kickstart rom
Post by: Doobrey on January 06, 2005, 12:43:23 AM
Quote

AF-Domains.net wrote:
I am creating a merged 1.4 and 3.1 rom to add some of the features that were in 1.4 but were never implemented into later versions of the kickstart


What features in the 1.4 rom ??

Quote

 and also to see if I can improve any part of both of the roms.


Dunno if you can call it an improvement but I`ve been averaging around 2% space saving per resident, and that`s only doing simple optimisations.
 I`ve also managed things like removing the non-FPU code from the maths libs, saving 2kb.
Title: Re: Extracting files from a kickstart rom
Post by: AF-Domains.net on January 06, 2005, 12:45:25 AM
Just downloaded the ReSourceDemo program off aminet. It kept on giving me recoverable errors on every single computer I have here.

Any other disassmbler/assemblers that would be recommended?
Title: Re: Extracting files from a kickstart rom
Post by: Doobrey on January 06, 2005, 04:07:03 AM

 IRA isn`t too bad at dissassembly, it does miss a few instructions that are on 020+ CPUS though, leaving them as dc.w $xxxx etc.
 vda68k can catch the ones that IRA can`t do

 For reassembly, give phxass a whirl.
Title: Re: Extracting files from a kickstart rom
Post by: AF-Domains.net on January 09, 2005, 10:50:17 PM
If I have gone throught this before then I apologise in advance.

Would it be possible to get instructions on how to extract everything from the rom?

If it is in files coding or both it doesn't matter.
Title: Re: Extracting files from a kickstart rom
Post by: Doobrey on January 10, 2005, 12:15:51 AM
Hang on till tomorrow..I should have something to make life a lot easier  :sealed:

Be warned, it`s docs are crap..I`m not a {bleep}ing novelist  :-)
Title: Re: Extracting files from a kickstart rom
Post by: AF-Domains.net on January 10, 2005, 12:17:25 AM
It doesn't matter how crappy the documents or instructions are aslong as they just about work.

Thanks
Title: Re: Extracting files from a kickstart rom
Post by: Speelgoedmannetje on January 10, 2005, 12:23:30 AM
Quote

Doobrey wrote:
 But as Piru said, it`s not a trivial task to split up a ROM.You gotta know where one part ends and another starts, which isn`t always obvious  :pissed:
 Some parts are easy, as they only have 6 relocs to find, but graphics.library is a real headache , somewhere around 2500 relocs to sort out... and they vary from rom to rom.
 
ehm, not that I got that much experience with hacking things like this (or actually, being a complete N00b), but ehm, since the kickstart rom wasn't included in the H/W of the A1000, there was a kickstart disk. Dunno til which version of the kickstart was released on disk, but surely the adressing on such a kickstart-on-disk is managed differently.
Maybe it's worth checking, for getting more overall insight :-)
Title: Re: Extracting files from a kickstart rom
Post by: AF-Domains.net on January 10, 2005, 12:26:41 AM
With abit of luck I might be able to program an application that will easily allow modification to any sort of kickrom file or disk.

But for now any help is greatly appreciated.
Title: Re: Extracting files from a kickstart rom
Post by: Piru on January 10, 2005, 01:21:37 AM
Quote
since the kickstart rom wasn't included in the H/W of the A1000, there was a kickstart disk. Dunno til which version of the kickstart was released on disk, but surely the adressing on such a kickstart-on-disk is managed differently.

Nope. The image on disk is still absolutely linked, to address 0x00fc0000. Just like real 1.x Kickstart ROM.
Title: Re: Extracting files from a kickstart rom
Post by: Doobrey on January 10, 2005, 03:35:14 AM
Quote

Piru wrote:
Just like real 1.x Kickstart ROM.


Looking at Piru`s avatar,  he doesn`t look old enough to remember Kickstart 1.x  :-D
Title: Re: Extracting files from a kickstart rom
Post by: Speelgoedmannetje on January 10, 2005, 02:39:24 PM
Quote

Doobrey wrote:
Quote

Piru wrote:
Just like real 1.x Kickstart ROM.


Looking at Piru`s avatar,  he doesn`t look old enough to remember Kickstart 1.x  :-D
aaaawww that'd be a cute wizzkid :-)
Title: Re: Extracting files from a kickstart rom
Post by: Doobrey on January 11, 2005, 01:53:21 AM
 Well, I hope this is of use to someone.
 It only handles Kickstart 40.68 (both A1200 and A4000D), and 40.63 for the A500/600/2000, and the AmigaOSRomupdate files.

 Any probs,gimme a yell.

*edit*
 New version with a couple of tools thrown in for free.
RomSplit 0.8 (http://www.doobreynet.co.uk/files/RomSplit0.8.lha)