Super Simple ELF patching (for HDLoader etc) –
09-09-2004,03:33 PM
Hi guys.
Final Edit notes:
-- I've produced a final release version of my package, now called
-- "ELF_repack_BATs.zip" and decided to attach it to this, the first post
-- of the thread, since that is what each newcomer will see on arrival.
-- So get that final release from the attachment at the bottom of this
-- post. (As yet it's not available anywhere else.)
Old Edit notes (modified):
-- I've removed the two batch listings from this text, as final
-- versions of the files have been released since then.
-- Most of the other text in this first post remains valid, so please
-- read on if you like. (But the docs in the released zip are better.)
I've noticed that several of you have problems with ELF patching,
mainly because you're not familiar with the format and its needs.
Well, neither am I, but experience has taught me ways to get
around such limitations and learn the basics of new stuff quickly,
and now I've come up with a solution that may be useful for many
of you as well.
NB: Those of you who are perfectly familiar with ELF formats,
obviously don't NEED my help to handle them. But please hear
me out anyway, as my solution may still be convenient for
you as well, even though you don't really need it.
I've simply made two bat files onto which you can drag-drop ELF
files to unpack or pack, respectively. The real work is done by
two readily available programs (more below) which are, however,
much more complex in their abilities than most of us want to
deal with normally, when we don't really need those features.
(Which is why I created those bats for my own usage.)
First of all, you need the two packer programs 'sjuncrunch' and
'ps2-packer'. The first one is just a stand-alone exe file which
you'll find at "http://www.oopo.net/consoledev/", and the other
one is a zip archive found at "http://ps2dev.org/kb.x?T=1061".
Unzip "ps2-packer-0.4-win32.zip" into a folder of your choice,
though the rest of my text below will call it "ELF_repack\".
Next copy "sjuncrunch.exe" into that same "ELF_repack\" folder
(where ps2-packer.exe already resides).
Then use Notepad or similar editor (NO wordprocessor) to make 2
text files containing the texts specified below. I suggest you
just cut and paste from the web page to be sure of getting it
right. Save these files as well in the "ELF_repack\" folder,
using the names "unpk_ELF.bat" and "pack_ELF.bat".
(The names don't really matter, but make them descriptive.)
Edit: ----- redundant bat listings removed from here -----
When you drop an ELF file onto either of these bats, or onto any
shortcut pointing to one of them (eg: useful on desktop), it
will start by renaming the file to the same name, followed by the
string ".tmp". That file will then be used as input to the real
programs, with the original name used for the output file. Once
the work is done, the .tmp file is erased, leaving you with the
processed output file using the name of the original file.
Effectively this means that you just pick up the original and drop
it on a batch, which then magically changes the file as needed...
Btw: When patching files, remember to always keep backup(s) of the
untouched originals, no matter how good the patches may seem.
Future (even more improved) patches may require virgin copies
and if you forgot to keep some, you're up the creek with no
paddle.
Well, that's all for now. Happy patching everyone !
Best Regards: dlanor
PS: If unpacking results in an impossibly small file, such as a 1K file from
a 600K original, then it means either that your original was unpacked
already, or that it is damaged somehow. My bats can't know whether
the ELF is packed or not, and sjuncrunch gives no indicatation except
for showing zero-sized blocks and making a small file. You just have
to be aware of this possibility yourself.
DS.
Final edit notes:
-- This post is no longer relevant, get the final release from the first post.
-- The docs in it clarify the problems mentioned here.
I found one problem with the ps2-packer, as used by my pack_ELF.bat.
By default ps2-packer uses a new compression algorithm, which seems
unsupported (naturally) by the older sjuncrunch. This means that ELFs
packed by the current pack_ELF.bat can't be unpacked by unpk_ELF.bat.
This will be easy to fix once I read up on the commandline arguments of
ps2-packer, which I am now starting to do. I'll get back here later to
edit that part of my original post, so as to ensure mutual compatibility
between the two batch files.
Best regards: dlanor
PS: If anyone involved with the ps2-packer project sees this, please take
--- note of this opinion:
----- In adding new modes to an existing format, one of the old modes
----- should be kept as the default mode, to maximize compatibility.
----- Power users who need the new modes will know how to get other
----- modes than the default anyway, unlike those who don't even know
----- that incompatible modes exist.
--- No offense intended! So I hope none is taken...
DS.
Pixel changed the default mode to the one that gives the best compression (which is the whole point of compressing). The old modes are there you just have to give the arguments. Not sure if pixel reads this particular forum but I am pretty sure the PS2-packer project is just him.
Final edit notes:
-- The stuff in this post remains valid but is better explained in the docs of
-- the final release package, now attached to the first post, at the top of
-- this thread. Go get it ("ELF_repack_BATs.zip") from that post instead.
-- Due to that release, I'm also removing the attachment that I placed in
-- this post earlier.
I've now investigated the compatibility problems with ps2-packer
and sjuncrunch, as well as with ps2-unpacker. (alpha release!)
The results are as follows: (As I [hopefully] understand them...)
ps2-packer has NO packing method compatible with sjuncrunch.
--- so ---
sjuncrunch can NOT unpack any ELF packed with ps2-packer.
Those are just two ways of saying the same thing,
and it means that another unpacker is needed.
ps2-unpacker can unpack ELFs packed with ps2-packer.
(except for zlib compression, so avoid using that)
--- but ---
ps2-unpacker can NOT unpack ELFs that sjuncrunch can unpack.
This means that ps2-unpacker can NOT replace sjuncrunch,
and we will continue to need both of them in parallel.
Thus the correct fix to my bat files is not just to change
one of the two I made earlier, but also to add a third one
that will use ps2-unpacker in a similar way. I chose to
rename the one using sjuncrunch to "uncrunch_ELF.bat",
and use the name "unpack_ELF.bat" for the new one.
Proper usage for unpacking is now to start by dropping a
copy (never work on unique originals) of your ELF onto
"uncrunch_ELF.bat". If that produces a bigger file, then
fine, you're done. But if it gives a smaller file, then
you need to make another copy and drop that one onto
"unpack_ELF.bat". If that too gives a smaller file, then
that ELF was either unpacked already, damaged, or somehow
incompatible with both unpackers. Normally that should
never happen, unless someone insists on using the zlib
compression with ps2-packer...
All three bats are included in the attached ELF_repack.zip,
and they should be stored in the "ELF_repack\" folder as
described in my original post, together with sjuncrunch
and ps2-packer as also mentioned in that post.
You also need to download "ps2-unpacker-0.1.1-win32.zip" from
the same site as ps2-packer, but another page. You'll find
it at "http://ps2dev.org/kb.x?T=601". Unzip it and copy the
"ps2-unpacker.exe" file to the same "ELF_repack\" folder I
mentioned above, and you're all set to use the stuff.
I do intend to add some documentation to the zip, but I don't feel like
doing it right now. (Too many other things I want to spend time on.)
As long as the zip stays here, all who get it can read what they need
from the posts anyway, so a doc isn't ugently needed. Right ?
Final release of ELF_repack_BATs.zip (with docs) –
09-11-2004,03:23 PM
Hi Guys!
As promised earlier I have now made the effort to write some proper docs for my BATs, thus making it more of a real release package. I'll leave the other posts mostly intact though, except for adding some edit notes to ensure people get the real package from the first post.
(That is the only attachment left in this thread now, anyway.)
I am new to ELF. May I know what is the difference between your 'unpack_ELF.bat' and 'uncrunch_ELF.bat'? How to decide which to be used when we have a unknown ELF file in hand? Thanks
edit: Play around with it for a while I may already found out the answer I suspected. Does 'unpack_ELF.bat' utilise 'ps2-unpacker.exe' and 'uncrunch' utilise 'sjcrunch.exe' respectively? I had 2 ELFs and one only worked with 'unpack_ELF.bat' and the other only worked with 'uncrunch_ELF.bat'.
Does 'unpack_ELF.bat' utilise 'ps2-unpacker.exe' and 'uncrunch' utilise 'sjcrunch.exe' respectively?.
Yes. This is clearly described in the new README. If you have somehow missed that info you must also have missed the new (final) release package, so go get it from the attachment I've added to the first post.
Btw: If you ever wonder what a BAT does, why not have a look directly ?
---- BATs are just normal text files after all, though they are used to
---- send commands to an interpreter. But if you just right-click a BAT
---- and choose 'edit' in the context menu that appears, you get to see
---- the contents in notepad (or possibly some other editor you use).
Originally Posted by lostinnil
I had 2 ELFs and one only worked with 'unpack_ELF.bat' and the other only worked with 'uncrunch_ELF.bat'.
That is quite normal, and is explained in detail in the new README.