OS development 101 - How to make a bootloader part 2 - Protected Mode

preview_player
Показать описание
I made a discord server for everyone interested in low level programming and malware.
Check it out:

Whats up everyone, welcome to the seccond part of bootloader development mini-series.
In todays video we gonna implement Global Descriptor Table and load 32 bit Protected Mode.
Make sure you watch part1:

Enjoy!

🖤 SUBSCRIBE 🖤
Twitter/X:
My github:
OSDEV

Timestamps:

0:00 ▶Intro
0:24 ▶Global Descriptor Table
3:45 ▶Implementing GDT
11:22 ▶Switching to Protected Mode

How to write a bootloader from scratch
What happens during a PC boot sequence
Understanding the Power-On Self Test (POST)
How does the BIOS or UEFI work during boot
What is real mode in computing
How to write bootable code for a PC
Steps to create a simple bootloader
How does a BIOS initialize hardware components
What is the Master Boot Record (MBR)
Difference between MBR and GPT
How to load a 32-bit kernel with a bootloader
What are the first 512 bytes of a boot device
How does memory work in real mode
Writing a bootloader with a "Hello World" message
What are the last two bytes of the MBR
How does the boot order affect the boot process
What is the role of the PSU in the boot sequence
How does the BIOS/UEFI transfer control to the kernel
What is the purpose of the Power-On Self Test
Steps to load a kernel using a bootloader
Рекомендации по теме
Комментарии
Автор

NASM has this nice feature which is local labels. Local labels start with '.' character. So instead of 'gdt_start:' and 'gdt_end:' you can have 'gdt:' and '.end:' labels. You refer to local labels with something like 'gdt.end'. Local label identifiers can be reused as many times as you want.

pvc
Автор

That "Limte" comment that you don't notice even after moving it twice, and copying it once! XD

frankcastle
Автор

Cool video👍Unfortunately all Discord links are invalid

hgmtoyl
Автор

In the protected mode we can’t use the bios functions any longer and it is not easy to use the hdd controller on port 01F0h to load a file or to switch into the graphic mode for example. It is more easy to use the 16 bit "BIG" Real Mode to have an read/write access to the memory up to 4 gb.

072A:0100 FA CLI
072A:0101 E470 IN AL, 70
072A:0103 0C80 OR AL, 80
072A:0105 E670 OUT 70, AL
072A:0107 6631C0 XOR EAX, EAX
072A:010A 8CC8 MOV AX, CS
072A:010C A36D01 MOV [016D], AX
072A:010F 66C1E004 SHL EAX, 04
072A:0113 6689C3 MOV EBX, EAX
072A:0116 A3B201 MOV [01B2], AX
072A:0119 A3BA01 MOV [01BA], AX
072A:011C 66C1C810 ROR EAX, 10
072A:0120 A2B401 MOV [01B4], AL
072A:0123 A2BC01 MOV [01BC], AL
072A:0126 6631C0 XOR EAX, EAX
072A:0129 B8A801 MOV AX, 01A8
072A:012C 6601C3 ADD EBX, EAX
072A:012F C706A0012700 MOV WORD PTR [01A0], 0027
072A:0135 66891EA201 MOV [01A2], EBX
072A:013A 9C PUSHF
072A:013B 0F0116A001 LGDT [01A0]
072A:0140 8CD2 MOV DX, SS
072A:0142 0F20C0 MOV EAX, CR0
072A:0145 0C01 OR AL, 01
072A:0147 0F22C0 MOV CR0, EAX
072A:014A EA50010800 JMP 0008:0150
-ucs:150 l1F
072A:0150 B81000 MOV AX, 0010
072A:0153 8ED0 MOV SS, AX
072A:0155 B81800 MOV AX, 0018
072A:0158 8ED8 MOV DS, AX
072A:015A 8EC0 MOV ES, AX
072A:015C 8EE0 MOV FS, AX
072A:015E 8EE8 MOV GS, AX
072A:0160 0F20C0 MOV EAX, CR0
072A:0163 6683E0FE AND EAX, -02
072A:0167 0F22C0 MOV CR0, EAX
072A:016A EA70013407 JMP 0734:0170
-ucs:170 l2F
072A:0170 8ED2 MOV SS, DX
072A:0172 9D POPF
072A:0173 31C9 XOR CX, CX
072A:0175 E464 IN AL, 64
072A:0177 2402 AND AL, 02
072A:0179 E0FA LOOPNZW 0175
072A:017B 751A JNZ 0197
072A:017D B0D1 MOV AL, D1
072A:017F E664 OUT 64, AL
072A:0181 31C9 XOR CX, CX
072A:0183 E464 IN AL, 64
072A:0185 2402 AND AL, 02
072A:0187 E0FA LOOPNZW 0183
072A:0189 75EE JNZ 0179
072A:018B B0DF MOV AL, DF
072A:018D E660 OUT 60, AL
072A:018F 31C9 XOR CX, CX
072A:0191 E464 IN AL, 64
072A:0193 2402 AND AL, 02
072A:0195 E0FA LOOPNZW 0191
072A:0197 E470 IN AL, 70
072A:0199 247F AND AL, 7F
072A:019B E670 OUT 70, AL
072A:019D FB STI
072A:019E C3 RET
-dcs:1A0 l8
072A:01A0 00 00 00 00 00 00 00 00-
-dcs:1A8 l8
072A:01A0 -00 00 00 00 00 00 00 00
-dcs:1B0 l8
072A:01B0 FF FF 00 00 00 9A 00 00-
-dcs:1B8 l8
072A:01B0 -FF FF 00 00 00 92 00 00
-dcs:1C0 l8
072A:01C0 FF FF 00 00 00 92 FF FF-

maxmuster
Автор

whats the difference between dw and db?

jamescraft
Автор

Bro can you make some vedios on how to gain reverse shell access to multiple systems. After gaining access to one system?

RaGhav
Автор

I'm using QEMU, and for some reason whenever I run the program the screen is very, like... not flickery, but the text is updating before it's finished rendering
Edit: it seems that it occurs whenever I jump to what is your "PModeMain" label, with the "CODE_SEGMENT_OFFSET:" before it
Ideally, this is something that'll be fixed in the kernel, but heads up that this happens if you don't have a kernel

xoxogamewolf
Автор

Great video Bro.
Please make a Udemy course on low level programming and Malware.

Programming OS, Network protocol.

It'll definitely become a best seller.

abhinuyadav
Автор

now make boot loader using C
easy just need efi.h and efilib.h to make GPT partition for the UEFI (Modern BIOS)

Abhinava_Playz_YT
visit shbcf.ru