ycliper

Популярное

Музыка Кино и Анимация Автомобили Животные Спорт Путешествия Игры Юмор

Интересные видео

2025 Сериалы Трейлеры Новости Как сделать Видеоуроки Diy своими руками

Топ запросов

смотреть а4 schoolboy runaway турецкий сериал смотреть мультфильмы эдисон
Скачать

Loading/Running Programs | UEFI Dev (in C)

Автор: Queso Fuego

Загружено: 2024-02-14

Просмотров: 1870

Описание: Running a program instead of just printing text files.
A program or executable file has a format like any other type of file, and in C it's a relatively simple matter of loading data structures to match the format, loading needed sections of the program to a new buffer, getting the new entry point, and calling that entry point to run the program.

A PE file can be slightly easier to load than an ELF file as the PE format has fields for the total size of the loaded file and its sections, and the entry point and section virtual addresses are already relative and do not need to be computed, for a PIE executable.

Errata:
It's probably a bug loading the ELF program headers' p_memsz amount of data instead of p_filesz.
It's possible that filesz is non-zero while memsz is 0 or at least less than filesz.
Using filesz instead would more closely match the PE loading and would fix any ambiguity and future bugs. The difference in filesz and memsz is implicitly zero padded anyway from memset-ing the
whole buffer to 0.

Random output from printf() was usually from taking 4+ bytes from the argument's memory on the stack via va_arg() inside printf, when the argument is actually 8 or 16 bits. My guess is due to compiler optimizations or otherwise not using address/size prefix bytes in the compiled code.
A fix could be to add size or length specifiers in the formatted string to be parsed by printf, e.g. %xbits8 or %xz8 for 8 bits. Or look up how gcc and others work around those issues.

Notes:
Sorry about any flashbangs, could've used a darker color for drawing to the framebuffer.

Probably could have used (elf header + sizeof elf_header_var) or (input_buffer + elf_header_phoff) to get to the program headers instead, which may make a little more sense for the ELF layout as the program headers immediately follow the overall Elf header.

I also kept thinking the default text line length was 25 characters instead of 80. The senility's kicking in early these days.

Links:
https://uefi.org/specifications (uefi & other specifications)
https://en.wikipedia.org/wiki/Executa...
https://en.wikipedia.org/wiki/Portabl...
https://learn.microsoft.com/en-us/win...
https://github.com/mentebinaria/readpe (readelf-esque tool for PE files)

UEFI Programming playlist:
   • UEFI Programming in C  

Git Repo:
https://github.com/queso-fuego/uefi-dev
https://codeberg.org/queso_fuego/uefi...

Repo state at the start of this video:
git clone --recurse-submodules https://github.com/queso-fuego/uefi-dev
cd uefi-dev
git checkout 20ff7f39ba9ca2aade5ffce975b9ff08ee8e2044

Repo state at the end of this video:
git checkout 1de80a5fba694550cbb8095d415a0d8f087bf6b7

Next video:
Getting the memory map and exiting boot services, and maybe making an installer option to write the disk image and kernel to another disk. That way you could "install" everything and reboot to use the new OS or loaded program.

Join the Community Discord:   / discord  

Contact:
https://queso_fuego.codeberg.page/contact.html

Support:
https://queso_fuego.codeberg.page/support.html

Questions about setup/software/etc.?
Check the FAQ: https://queso_fuego.codeberg.page/about.html

0:00:00 intro, add example program to draw to screen
0:14:45 change load file function to load flat binary program
0:28:07 close timer event before running program
0:29:28 "fix" void pointer to function pointer cast
0:31:13 load flat binary from PE obj instead of ELF
0:34:32 build elf & pe from makefile, check header bytes
0:44:17 ELF structs for basic ELF64 format
0:50:30 print info and load ELF file (copy paste my own code)
1:25:18 PE structs and info for basic PE32+ format
1:43:09 print info and load PE file
2:19:15 coming up & outro

Music credits:
"Acid Trumpet" Kevin MacLeod (incompetech.com)
Licensed under Creative Commons: By Attribution 4.0 License
http://creativecommons.org/licenses/b...

[Chiptune] Medieval: Minstrel Dance by RandomMind
Music: https://www.chosic.com/free-music/all/

#uefidev #cprogramming #PIEhole

Не удается загрузить Youtube-плеер. Проверьте блокировку Youtube в вашей сети.
Повторяем попытку...
Loading/Running Programs | UEFI Dev (in C)

Поделиться в:

Доступные форматы для скачивания:

Скачать видео

  • Информация по загрузке:

Скачать аудио

Похожие видео

Get Memory Map & Exit Boot Services | UEFI Dev (in C)

Get Memory Map & Exit Boot Services | UEFI Dev (in C)

Loading ELF PIE Executables | 32 Bit OS Dev (in C)

Loading ELF PIE Executables | 32 Bit OS Dev (in C)

Как взломать любое программное обеспечение

Как взломать любое программное обеспечение

x86_64 GDT for Remapped Kernel (2/2) | UEFI Dev (in C)

x86_64 GDT for Remapped Kernel (2/2) | UEFI Dev (in C)

Тайны ядра Windows: Переполнение буфера, структура KPCR, EPROCESS и защита SMEP.

Тайны ядра Windows: Переполнение буфера, структура KPCR, EPROCESS и защита SMEP.

Чего ждать от рефлексии в C++26

Чего ждать от рефлексии в C++26

UEFI Programming in C

UEFI Programming in C

Domain-Driven Design | Просто о сложном

Domain-Driven Design | Просто о сложном

Block IO Protocol Media Information | UEFI Dev (in C)

Block IO Protocol Media Information | UEFI Dev (in C)

Интернет в небе: Сергей

Интернет в небе: Сергей "Флеш" о том, как «Шахеды» и «Герберы» научились работать в одной связке

Принц Персии: разбираем код гениальной игры, вытирая слезы счастья

Принц Персии: разбираем код гениальной игры, вытирая слезы счастья

Задача для математической олимпиады | Как решить относительно a, b

Задача для математической олимпиады | Как решить относительно a, b

Behold the Infamous PS2 Linux Kit

Behold the Infamous PS2 Linux Kit

Setup x86_64 Paging to Remap Kernel (1/2) | UEFI Dev (in C)

Setup x86_64 Paging to Remap Kernel (1/2) | UEFI Dev (in C)

Попросил ИИ-агента настроить Linux сервер и установить N8N с базой данных. СПРАВИТСЯ?

Попросил ИИ-агента настроить Linux сервер и установить N8N с базой данных. СПРАВИТСЯ?

Тензорные объяснения интуитивно: ковариантный, контравариантный, ранг

Тензорные объяснения интуитивно: ковариантный, контравариантный, ранг

Printing Global Variables (then Changing Boot Order) | UEFI Dev (in C)

Printing Global Variables (then Changing Boot Order) | UEFI Dev (in C)

Making an Initial File Tree | 32 Bit OS Dev (in C)

Making an Initial File Tree | 32 Bit OS Dev (in C)

Mouse Cursor & Simple Pointer Protocol | UEFI Dev (in C)

Mouse Cursor & Simple Pointer Protocol | UEFI Dev (in C)

tmux — Как Стать Терминальным Чадом

tmux — Как Стать Терминальным Чадом

© 2025 ycliper. Все права защищены.



  • Контакты
  • О нас
  • Политика конфиденциальности



Контакты для правообладателей: [email protected]