Calling BIOS Int 0x10 in protected mode with a different way
Posted: Sat Jan 14, 2017 11:06 am
Hi.
I know, calling bios interrupts directly in protected mode isn't possible. But I wanted to try it a bit... different way.
I got the address of int 10h handler from IVT, then looked what is there.
Result (First 500 bytes)
In ASCII:
This is how did I get the data:
I think there are some problems in disassembly, but nevermind
How can I make that code to work in protected mode? With removal of override prefixes (66) and a bit modification can it work?
Is it possible at least?
Thx.
I know, calling bios interrupts directly in protected mode isn't possible. But I wanted to try it a bit... different way.
I got the address of int 10h handler from IVT, then looked what is there.
Result (First 500 bytes)
Code: Select all
FA FC 66 50 66 51 66 52 66 53 66 55 66 56 66 57 6 1E 8C D0 8E D8 66 89 E3 66 F B7 E4 66 89 E0 50 E8 2 F2 66 89 DC 1F 7 66 5F 66 5E 66 5D 66 5B 66 5A 66 59 66 58 CF 20 20 4E 55 4C 4C A 0 20 20 20 61 3D 25 30 38 78 20 20 62 3D 25 30 38 78 20 20 63 3D 25 30 38 78 20 20 64 3D 25 30 38 78 20 64 73 3D 25 30 34 78 20 65 73 3D 25 30 34 78 20 73 73 3D 25 30 34 78 A 0 20 20 73 69 3D 25 30 38 78 20 64 69 3D 25 30 38 78 20 62 70 3D 25 30 38 78 20 73 70 3D 25 30 38 78 20 63 73 3D 25 30 34 78 20 69 70 3D 25 30 34 78 20 20 66 3D 25 30 34 78 A 0 73 74 75 62 20 25 73 3A 25 64 3A A 0 57 41 52 4E 49 4E 47 20 2D 20 69 6E 74 65 72 6E 61 6C 20 65 72 72 6F 72 20 64 65 74 65 63 74 65 64 20 61 74 20 25 73 3A 25 64 21 A 0 73 65 74 20 56 47 41 20 6D 6F 64 65 20 25 78 A 0 53 74 61 72 74 20 53 65 61 56 47 41 42 49 4F 53 20 28 76 65 72 73 69 6F 6E 20 25 73 29 A 0 65 6E 74 65 72 20 25 73 3A A 0 4E 6F 20 56 42 45 20 44 49 53 50 49 20 69 6E 74 65 72 66 61 63 65 20 64 65 74 65 63 74 65 64 2C 20 66 61 6C 6C 69 6E 67 20 62 61 63 6B 20 74 6F 20 73 74 64 76 67 61 A 0 56 42 45 20 44 49 53 50 49 3A 20 62 64 66 20 25 30 32 78 3A 25 30 32 78 2E 25 78 2C 20 62 61 72 20 25 64 A 0 56 42 45 20 44 49 53 50 49 3A 20 6C 66 62 5F 61 64 64 72 3D 25 78 2C 20 73 69 7A 65 20 25 64 20 4D 42 A 0 52 65 6D 6F 76 69 6E 67 20 6D 6F 64 65 20 25 78 A 0 53 65 61 42 49 4F 53 20 56 42 45 28 43 29 20 32 30 31 31 0 53 65 61 42 49 4F 53 20 44 65 76 65 6C 6F 70 65 72 73 0 53 65 61 42 49 4F 53 20 56 42 45 20 41 64
Disassembled version until iret:úüfPfQfRfSfUfVfWÐØfãf·äfàPèòfÜf_f^f]f[fZfYfXÏ NULL a=%08x b=%08x c=%08x d=%08x ds=%04x es=%04x ss=%04x si=%08x di=%08x bp=%08x sp=%08x cs=%04x ip=%04x f=%04xstub %s:%d:WARNING - internal error detected at %s:%d!set VGA mode %xStart SeaVGABIOS (version %s)enter %s:No VBE DISPI interface detected, falling back to stdvgaVBE DISPI: bdf %02x:%02x.%x, bar %dVBE DISPI: lfb_addr=%x, size %d MBRemoving mode %xSeaBIOS VBE(C) 2011SeaBIOS DevelopersSeaBIOS VBE Ad
Code: Select all
.data:00000000 fa cli
.data:00000001 fc cld
.data:00000002 66 50 push %eax
.data:00000004 66 51 push %ecx
.data:00000006 66 52 push %edx
.data:00000008 66 53 push %ebx
.data:0000000a 66 55 push %ebp
.data:0000000c 66 56 push %esi
.data:0000000e 66 57 push %edi
.data:00000010 61 popa
.data:00000011 e8 cd 08 call 0x000008e1
.data:00000014 ed in (%dx),%ax
.data:00000015 86 68 9e xchg %ch,-0x62(%bx,%si)
.data:00000018 36 6f outsw %ss:(%si),(%dx)
.data:0000001a b7 e4 mov $0xe4,%bh
.data:0000001c 66 89 e0 mov %esp,%eax
.data:0000001f 50 push %ax
.data:00000020 e8 2f 26 call 0x00002652
.data:00000023 68 9d c1 push $0xc19d
.data:00000026 f7 66 5f mulw 0x5f(%bp)
.data:00000029 66 5e pop %esi
.data:0000002b 66 5d pop %ebp
.data:0000002d 66 5b pop %ebx
.data:0000002f 66 5a pop %edx
.data:00000031 66 59 pop %ecx
.data:00000033 66 58 pop %eax
.data:00000035 cf iret
Code: Select all
uint32_t* ptr = (uint32_t*) (0x10 * 4);
uint32_t handler_loc = *ptr;
uint16_t segment, offset = 0;
segment = (handler_loc >> 16) & 0xFFFF;
offset = handler_loc & 0xFFFF;
uint32_t address = (segment * 16) + offset;
for (uint8_t* x = (uint8_t*) address; x < address + 500; x++)
{
printf(" %X ", *x);
}
How can I make that code to work in protected mode? With removal of override prefixes (66) and a bit modification can it work?
Is it possible at least?
Thx.