I understand that there are now more modern and advanced techniques for making a USB stick bootable, so I may be resurrecting an old topic here. It is mostly for the sake of intellectual curiousity, but I hope to gain understanding from it. I have not been able to find the answer to the following question on these forums so far.
pe2usb.bin appears to be a 512-byte boot sector image for a FAT16 partition, loading NTLDR. I have compared it against the standard FAT16 boot sector created by any Windows NT 5.x version (XP for example), or by Windows 7's bootsect /nt52 command. It mostly matches up. However, ignoring the differences in the BPB (which are necessarily drive-specific), I have found the following differences in the boot loader code: (All values are in hex)
CODE
Offset Standard NT 5.x code pe2usb.bin code
03 90 0E
50 38 4E 24 7D 88 56 24 EB
17C 75 04 90 90
I only have a limited knowledge of x86 assembly, so I would like help with understanding the purpose of these alterations. I found the following thread: Boot BartPE from USB Flash Drive, which shows that Bart made these changes on purpose, whilst he was developing the pe2usb method. Sadly I can't find him explaining their role. (Funnily enough, in the opening post he accidentally had the images showing the change backwards, but noone in the thread seemed to have picked up on it). That thread actually only mentions the first two changes, the last change at 17C seemed to have been introduced later.03 90 0E
50 38 4E 24 7D 88 56 24 EB
17C 75 04 90 90
Unfortunately the FAT16 boot sector code under NT 5.x is not analyzed by the Starman at http://thestarman.narod.ru/asm/mbr/index.html and this code is different from FAT32 or from FAT16 under earlier or later OS's.
From my limited knowledge of x86 assembly,
CODE
38 4E 24 7D : CMP ?, ?; JNL ?
88 56 24 EB : MOV ?, ?; JMP ?
so a comparison/conditional jump is being replaced with an unconditional jump. I haven't made progress on the other differences. I don't even understand why replace the NOP at 03 (which is jumped over anyway).88 56 24 EB : MOV ?, ?; JMP ?
Background motivation:
I have an old-ish Dell Inspiron 6400 laptop and was playing around with USB booting on it with a 1Gb Kingston DataTraveler stick. I ran into a caveat when I formatted the primary partition of the USB stick to FAT16 CHS (partition type 06), and using standard NT 5.x boot sector code. During booting, the stick will only load NTLDR if it was one of the first files copied to it. If another large file (for example PE iso image) was copied to the stick first, the laptop just hangs. I found two workarounds, both worked perfectly: Either change the partition to FAT16 LBA (type 0E), or use the boot sector code from pe2usb.bin.
What this shows is that on this laptop there is some issue (probably in BIOS) with handling CHS correctly, which is making deeper sectors on the stick inaccessible during boot. The code in pe2usb.bin seems to work around it, and I would love to know what it does differently.
PS: This is my first post on these forums, so I want to say thank you for the amazing resources available on here. I have just recently come across this place and I am learning a lot.
