3 Pages V  < 1 2 3  
Reply to this topic
 How to patch FAT32 boot sector
post Jul 29 2009, 04:16 PM
Post #21
ktp
Silver Member   ****
Group: Advanced user

  Joined: 16-February 07
Posts: 653
Thank(s): 37


Well, there were so many reformats of the device after my many experimentations, each time I have to reload everything, redo all my mp3 player many settings, reupload my mp3 files, so I am really tired of it. And the last straw was the last experimentation patching mkbootfat MBR, it hang TinyHexer so strongly that even explorer.exe hangs, no way to use the taskbar, just Ctrl-Tab. I tried to unplug by force without success. I have to reboot. It was enough for me, at least for today :-).
+Quote Post
post Jul 31 2009, 06:33 AM
Post #22
dencorso
Member   **
Group: Members

  Joined: 2-June 08
Posts: 33
Thank(s): 4


Brazil


QUOTE (jaclaz @ Jul 26 2009, 03:34 PM) *

For what it's worth, here I offer the boot-land community my revised version of Clemens Fruhwirth's KillCHS utility, both compiled and as source code, alongside with Fruhwirth's original code renamed killchs.ori, to help those interested in determining what I added to the code. My revised version can patch the NTFS boot loader and both flavors of the FAT-32 NTLDR boot loader (viz. MSWIN4.1 and MSDOS5.0). It has been compiled with djgpp's gcc 4.10 and runs in the NT-family Windows OSes, in Win 9x/ME and in plain DOS (but CWSDPMI is required).
Usage is simple:
KillCHS <filename.ext>
It will crash, however, if run without providing a filename.
Update (Aug 01, 2009): I've incorporated Icecube's suggestions (in post #24, below) and revised further the code. The new version (1.2) is more user-friendly, and only accepts one parameter, but it'll just complain and do nothing in case none or more are provided in the command line, instead of crashing on none and ignoring all parameters but the first, when more than one is provided.
Attached File(s)
Attached File  KillCHS.7z ( 34.59K ) Number of downloads: 194
 
+Quote Post
post Jul 31 2009, 12:43 PM
Post #23
was_jaclaz
Finder   ******
Group: Advanced user

  Joined: 14-July 06 From: Gone in the mist

Posts: 7,230
Thank(s): 564


Italy


QUOTE (ktp @ Jul 29 2009, 06:16 PM) *
It was enough for me, at least for today :-).


Yesterday was already tomorrow. wink.gif

Anyway I re-thought a bit about the matter:
QUOTE (jaclaz @ Jul 29 2009, 04:32 PM) *
Of course, it depends on the actual checks the "stupid" MP3 thingy does, if for example it wants the number of "hidden sectors" to be equal to 0, we need to manipulate the data about "reserved sectors" or invent something else. unsure.gif


On a "normal" "superfloppy":
The number of hidden sectors is 0 (zero) as the bootsector is first sector of the disk.
The number of reserved sectors is determined by size of volume and app that formatted it

i.e. in Tiny Hexer "Structure Viewer" (example):
CODE
...
Reserved Sectors:              '0x0020' (32 dec)
...
Hidden sectors:                '0x00000000' (0 dec)
...


On a partitioned drive with 63 hidden sectors the values in the "right" bootsector (the one on sector 63 LBA) are, again in Tiny Hexer:
CODE
...
Reserved Sectors:              '0x0024' (36 dec)
...
Hidden sectors:                '0x0000003F' (63 dec)
...


We copied this latter values on the "fake" bootsector DATA on first sector of disk, and they are actually "wrong", there.

You should try incrementing the "Reserved Sectors" and decrement the "Hidden Sectors" by the offset we created, i.e. 63 or 0x3F.

Thus you will have:
CODE
...
Reserved Sectors:              '0x0063' (99 dec)
...
Hidden sectors:                '0x00000000' (0 dec)
...


When you will feel tomorrow has come, that would be the try to make. wink.gif

@dencorso
Thanks for the app.
I cross-posted it on original thread:
http://www.911cd.net/forums//index.php?sho...1702&st=241

cheers.gif

jaclaz


--------------------
+Quote Post
post Jul 31 2009, 01:02 PM
Post #24
Icecube
Silver Member   ****
Group: Advanced user

  Joined: 7-September 08
Posts: 641
Thank(s): 172


Belgium


@dencorso
The following code will check if a argv1 exists before continuing.
Also added some more info about what the program does (maybe not complete. I didn't read the topic very carefully).
CODE
int main(int argc, char **argv) {

    printf("\nKillCHS, by Clemens Fruhwirth <clemens@endorphin.org>, 2007.\n\
(revised by dencorso, 2009).\n\n \
   This program binary patches the FAT32/NTFS boot loader to never ever\n \
   use CHS based indexing again. CHS based access is broken when then\n \
   disk geometry for heads and sectors is different from the one\n \
   stored in the BPB.\n\n");

    if(argc < 2) {
        perror("Usage: killchs <file>\n"); return 1;
    }

    int fd=open(argv[1],O_RDWR|O_BINARY);
    unsigned char buf[512];

Side note: The source code is also not consistently formatted.


--------------------
+Quote Post
post Jul 31 2009, 04:20 PM
Post #25
wimb
Silver Member   ****
Group: Advanced user

  Joined: 10-July 07
Posts: 726
Thank(s): 225


Netherlands


@ktp

To make it bootable you need also:

FAT32 Bootsector - drive-id patch 0x80 at offset 0x40 , after XP format it is 00 and Not bootable

http://www.boot-land.net/forums/index.php?...5306&st=214

More Info on BootSector patches in Format Stick Section of improved Tutorial
http://www.boot-land.net/forums/index.php?showtopic=5306

cheers.gif


--------------------
+Quote Post
post Aug 1 2009, 04:15 AM
Post #26
dencorso
Member   **
Group: Members

  Joined: 2-June 08
Posts: 33
Thank(s): 4


Brazil


QUOTE (jaclaz @ Jul 31 2009, 12:43 PM)
Thanks, jaclaz! I have updated the KillCHS program to v. 1.2, by incorporating Icecube's suggestions (thanks, Icecube!), and revising a little more the whole code. The new version is now in place of the former, still in post #22, so that your posted link remains valid. You both rock! thumbup.gif
Side note: The source code remains not consistently formatted, but is nevetheless, a little better, visually.
+Quote Post
post Aug 6 2009, 10:38 AM
Post #27
online
Silver Member   ****
Group: Advanced user

  Joined: 28-July 07
Posts: 777
Thank(s): 41


@ktp
Not sure if the patching at every boot-up could be useful in your case... unsure.gif
Please, see here
http://www.boot-land.net/forums/index.php?...ost&p=73826


--------------------
+Quote Post

3 Pages V  < 1 2 3
Reply to this topic
1 User(s) are reading this topic ()



Collapse

  Topic Replies Topic Starter Views Last Action
No New Posts Boot Land Stats, August
4 Nuno Brito 155 Yesterday, 02:07 PM
Last post by: NFX
No New Posts boot full ubuntu from grub4dos
3 sara - pmedia 146 Yesterday, 08:12 AM
Last post by: Wonko the Sane
No New Posts HOW TO Integrate Fedora 13 Into a Sardu + G4D Multiboot USB
HOW TO
4 fms 237 29th August 2010 - 03:51 PM
Last post by: Wonko the Sane
No new Topic has attachmentsTool to Add Seagate DiscWizard to PE3 Wim
Free Acronis TrueImage 11
14 oriensol 1,372 29th August 2010 - 03:03 AM
Last post by: oriensol
No new booting vista/2008/w7 from usb sub folder
grub4dos launches bootmgr but bootmgr cannot find what it needs?!?
112 anystupidname 16,945 27th August 2010 - 07:41 PM
Last post by: steve6375