From: H. Peter Anvin Date: Mon, 25 May 2009 21:56:11 +0000 (-0700) Subject: com32r: verify the COM32R magic number X-Git-Tag: syslinux-4.00-pre1~79 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=66faa55d9decdea13f3be830e9999c23574a34c5;p=profile%2Fivi%2Fsyslinux.git com32r: verify the COM32R magic number Since we might be having COM32 and COM32R in the same filesystem, do check for the appropriate COM32R magic before doing anything else. Signed-off-by: H. Peter Anvin --- diff --git a/core/com32.inc b/core/com32.inc index 1ab4248..1f14125 100644 --- a/core/com32.inc +++ b/core/com32.inc @@ -54,6 +54,15 @@ is_com32_image: mov bx,abort_check ; Don't print dots, but allow abort call load_high + mov esi,com32_entry + mov edi,trackbuf + mov ecx,5 + call bcopy + cmp dword [trackbuf],0xcd4cfeb8 + jne not_com32r + cmp byte [trackbuf+4],0x21 + jne not_com32r + com32_start: ; ; Point the stack to the end of (permitted) high memory @@ -94,3 +103,13 @@ com32_exit: mov dword [PMESP],__stack_end ; Stop use of COM32 stack sti jmp enter_command + +not_com32r: + mov si,KernelCName + call writestr + mov si,not_com32r_msg + call writestr + jmp enter_command + + section .data16 +not_com32r_msg db ': not a COM32R image', CR, LF, 0 diff --git a/doc/comboot.txt b/doc/comboot.txt index 1b087a1..101b173 100644 --- a/doc/comboot.txt +++ b/doc/comboot.txt @@ -61,8 +61,8 @@ be possible to create a COM32 execution engine that would run under something like Linux DOSEMU, it is recommended that the code does not assume CPL 0 unless absolutely necessary. -It is highly recommended that every COM32R program begins with the byte -sequence B8 FE 4C CD 21 (mov eax,21cd4cfeh) as a magic number. +A COM32R program must start with the byte sequence B8 FE 4C CD 21 (mov +eax,21cd4cfeh) as a magic number. The COM32R format replaces the earlier COM32 format, which was linked to a fixed address (0x101000).