Header Magic is a tool that extends ROM hacking tool that currently only work on headered ROMs, to also work on headerless ROMs as well.
This is not a simple "add header, run application, remove header" script. It truly extends applications to fully support and edit headerless ROMs in-place, while the tool is running.
It does this by hooking the Windows kernel32 file write functions to detect SMC and SFC files, and upon doing so, overrides file size, read and write functions to fake the presence of a header being there.
It will also detect when a ROM file *does* have a header, and treat the file normally. So in a sense, Header Magic ensures that your applications work seamless either with or without a header.
Header Magic was primarily designed due to FuSoYa's unwillingness to add true headerless support to Lunar Magic. However, the tool was created with FuSoYa's permission, which I am very grateful for. It is very important to note that absolutely no support for Header Magic will be provided by FuSoYa, so please do not mention it to him.
Note that Header Magic was designed in such a way as to work with not only all past and future versions of Lunar Magic, but also to work with *any* Windows application that lacks headerless ROM support. Simply edit Header Magic.cfg and point it at any application you like.
Also note that every application is different: if another application does something out of the ordinary, Header Magic may need to be modified or extended to work with it. The underlying theory is sound, however. Absolutely no modifications are made to the programs themselves.
The primary line of discussion and support is on my own forum:
But if you refuse to post there, you can post here as well. Just don't expect an expedient response please.
1.04 - integrated HTTP download + unzip directly into downloader
1.03 - removed Lunar Magic from archive, added downloader
1.02 - fixed launching emulator from LM, and iron-proofed stability
1.01 - fixed file open dialog issue affecting some systems
1.00 - initial release
So it sounds like I won't ever have to bother with adding a header for tools that need it, removing it to test with bsnes for that minor change, then adding it to use that tool again? That sounds great! I'll be sure to test this.
Additionally, how do we set this to work with other applications? When changing applicationName = "Lunar Magic.dll" to applicationName = "C:\Users\ALD\Documents\SMW\BTSD\Blocktool Super Deluxe.exe", I get "unable to open application". Does it only work with the program files in the same folder as the application?
I'm working on a stability fix by utilizing detours, so that I only have to overwrite DLL entry points one time. That should be out shortly, along with an improved launcher.
> So it sounds like I won't ever have to bother with adding a header for tools that need it, removing it to test with bsnes for that minor change, then adding it to use that tool again?
Yes, exactly. Of course, we won't know if tools are compatible with it until we try. This is where you guys come in: help extend Header Magic to work with other tools, and it becomes more universal for all =)
> Sounds good, but what if the program tries to read/write the header?
It will read back 0x00s for the header, and whatever it writes is ignored. Obviously, you can't store data in a header that isn't there. If there's a great need, I can make it read and write a separate <filename>.hdr file, but I'd prefer not to write to the user's hard drive if possible.
> Additionally, how do we set this to work with other applications? When changing applicationName = "Lunar Magic.dll" to applicationName = "C:\Users\ALD\Documents\SMW\BTSD\Blocktool Super Deluxe.exe", I get "unable to open application". Does it only work with the program files in the same folder as the application?
Yes, currently it needs to be in the same folder. I think I botched the paths for drag-and-drop on the last release, too.
I'll try and get this fixed up for the next release. In the mean time, please let me know if you get this to work with any other tools other than Lunar Magic. That'd be totally rad.
Moving the Header Magic files into the BTSD folder causes the same error. Renaming Blocktool Super Deluxe.exe to have a .dll extension doesn't work, but renaming Lunar Magic works, so it's not a problem with file paths.
It should be 100% stable on every system now. Drag-and-drop on the launcher was fixed, the wait cursor upon launching issue was fixed, launching an emulator from within LM was fixed, and detours are used in place of constant function-rewriting.
The last part basically means disassembling and then reassembling code at a different location. Very involved, but it ensures rock-solid stability so it was worth it!
Ultimaximus, I don't know ... it should work. If it still doesn't work with hm102, then perhaps BTSD isn't a real Windows binary? .NET applications for instance are fake executables.
Erm, byuu... if you recall, I did ask that you distribute this completely separate from LM. Check the "Legal Notice" section in LM's readme.txt file for more info.
Oh my, I'm terribly sorry, but I missed that.
I tried my best to respect your work and wishes. I obtained your permission to make this first. Then, through substantial trouble, I avoided ever modifying your binary, not even in memory, not even to disable the CRC self-check or header check. I further still allowed headered ROM support, included your readme+help file, and added the readme asking people not to bug you about the application.
I've corrected the mistake by removing Lunar Magic from the archive, and I've uploaded a new version. Please accept my apologies.
It now uses wget and unzip to auto-download and extract the completely unmodified Lunar Magic archive if it does not exist, which should only be on the very first run. It fulfills FuSoYa's legal requirements to the letter; it only takes one second; and as an added bonus, it makes my package download 3x smaller!
> (Mind if I submit it to the tools section, byuu?)
By all means, please do. The license is public domain.
The hm103.zip archive is the auto-downloading one designed to work directly with Lunar Magic, whereas header-magic_v01.tar.bz2 is the source code and generic binary meant to be extensible through a configuration file and such.
I'd recommend posting the former, since it's much easier to get started with. It pulls lm182.zip from tukuyomi's server, but you can also use your own copy/version of LM by placing it in the same folder as "Lunar Magic.dll". And if you want, I can make it pull lm182.zip from smwcentral.net instead.
I could make it fetch "lm-latest.zip" from somewhere, and then one simply needs to upload the new version with that archive name. We just have to make sure we point it at a web address that will remain valid as long as possible. Not too hard to do these days.
I'm sure you can also do it yourself by hex editing the main executable and updating the URL. Search for byuusan.kuro-hitsuji.net in the binary.
And of course, you'd want to thoroughly test each new version for compatibility first. So long as FuSoYa doesn't make any major changes, it should remain compatible.
My goal is to keep the software as absolutely simple to use as possible.
I don't want the user to have to manually visit a website, or download a file, or even copy a file. Since I'm not allowed to include the file with the archive, that means I need to auto-download it. It's the only way to keep it exactly as easy to use as if I had included the file, while still fulfilling FuSoYa's custom licensing conditions.
I've written my own minimalist HTTP download (4KB source) and ZIP extraction (10KB source) code, which eliminates the need for wget.exe and unzip.exe in the archive.
It's now just my launcher EXE, my injector DLL and my readme file.
Also, it downloads from byuusan.kuro-hitsuji.net/header-magic/lunar-magic.zip now. So in theory, all we need to do is update that archive with the latest compatible Lunar Magic release. No need to update Header Magic itself for new Lunar Magic releases. Hopefully renaming the official archive is permitted, please advise if not and I'll make it read a text file to get the latest archive name instead.
Lastly, I removed hm100/101/102.zip, since they still had FuSoYa's binary in them, and were thus violating the license.