Kim Mik
2009-Dec-28 21:42 UTC
[syslinux] [PATCH] chain.c32: add support for booting the Recovery Console of Windows NT/2K/XP
The following patch for chain.c32 adds support to boot the Recovery Console of Windows NT/2K/XP. Normally when you want to boot the recovery console, you need to patch "cmdcons\0" into the bootsectorof the partition (8 bytes starting at 0x3 (4th byte)). We can do this patching in memory: strcpy((char *) 0x7c03, "cmdcons"); To boot the recovery console with chain.c32: chain.c32 cmldr=/cmldr - Gert Hulselmans $ diff -u chain.c.textmode chain.c.cmldr --- chain.c.textmode 2009-12-28 21:32:17.658783777 +0100 +++ chain.c.cmldr 2009-12-28 22:23:15.118787984 +0100 @@ -48,6 +48,10 @@ * ntldr=<loader>: * equivalent to -seg 0x2000 -file <loader>, used with WinNT's loaders * + * cmldr=<loader>: + * used with Recovery Console of Windows NT/2K/XP. + * same as ntldr=<loader> & "cmdcons\0" written to memory address 0000:7C03 + * * freedos=<loader>: * equivalent to -seg 0x60 -file <loader>, used with FreeDOS kernel.sys. * @@ -85,6 +89,7 @@ uint16_t keeppxe; uint16_t seg; bool isolinux; + bool cmldr; bool swap; bool hide; } opt; @@ -679,6 +684,10 @@ } else if (!strncmp(argv[i], "ntldr=", 6)) { opt.seg = 0x2000; /* NTLDR wants this address */ opt.loadfile = argv[i] + 6; + } else if (!strncmp(argv[i], "cmldr=", 6)) { + opt.seg = 0x2000; /* CMLDR wants this address */ + opt.loadfile = argv[i] + 6; + opt.cmldr = true; } else if (!strncmp(argv[i], "freedos=", 8)) { opt.seg = 0x60; /* FREEDOS wants this address */ opt.loadfile = argv[i] + 8; @@ -714,7 +723,8 @@ " chain.c32 boot [<partition>] [options]\n" "Options: file=<loader> load file, instead of boot sector\n" " isolinux=<loader> load another version of ISOLINUX\n" - " ntldr=<loader> load Windows bootloaders: NTLDR, SETUPLDR, BOOTMGR\n" + " ntldr=<loader> load Windows loaders NTLDR, SETUPLDR.BIN or BOOTMGR\n" + " cmldr=<loader> load Recovery Console of Windows NT/2K/XP (cmldr)\n" " freedos=<loader> load FreeDOS kernel.sys\n" " msdos=<loader> load MS-DOS io.sys\n" " pcdos=<loader> load PC-DOS ibmbio.com\n" @@ -876,6 +886,13 @@ } } + /* To boot the Recovery Console of Windows NT/2K/XP we need to write + the string "cmdcons\0" to memory location 0000:7C03. + Memory location 0000:7C00 contains the bootsector of the partition. + */ + if (opt.cmldr) + strcpy((char *) 0x7c03, "cmdcons"); + } else if (partinfo) { /* Actually read the boot sector */ /* Pick the first buffer that isn't already in use */
H. Peter Anvin
2009-Dec-28 23:04 UTC
[syslinux] [PATCH] chain.c32: add support for booting the Recovery Console of Windows NT/2K/XP
On 12/28/2009 01:42 PM, Kim Mik wrote:> The following patch for chain.c32 adds support to boot the Recovery Console of Windows NT/2K/XP. > Normally when you want to boot the recovery console, you need to patch "cmdcons\0" into the > bootsectorof the partition (8 bytes starting at 0x3 (4th byte)). > > We can do this patching in memory: > strcpy((char *) 0x7c03, "cmdcons"); > > To boot the recovery console with chain.c32: > chain.c32 cmldr=/cmldr > > - Gert HulselmansHi Gert, Could you do me a favor and make the following changes to your patch submissions: a) please do the diff from one level above the build root, and don't change the name of the target file, so you end up with something looking like: --- syslinux/com32/modules/chain.c.textmode 2009-12-28 21:32:17.658783777 +0100 +++ syslinux/com32/modules/chain.c 2009-12-28 22:23:15.118787984 +0100 b) Please add a line to the text: Signed-off-by: Gert Hulselmans <kimmik999999 at yahoo.co.uk> Both of these will make my life a little easier. Thanks, -hpa -- H. Peter Anvin, Intel Open Source Technology Center I work for Intel. I don't speak on their behalf.