开发者

Running a code before any operating systems is booted?

开发者 https://www.devze.com 2022-12-14 08:15 出处:网络
Is there a way to write a code that may run w开发者_如何学Gohen System starts while a operating system is not loaded?

Is there a way to write a code that may run w开发者_如何学Gohen System starts while a operating system is not loaded?

I actually want to copy data of a particular partition, sector by sector, into another partition with the help of that code.


Yes there is, lots of ways, but you'll have to learn a hell of a lot before starting. Also this isn't a serverfault question.


You could learn how to run pre-OS booting code by looking at existing software that does that:

  • GRUB boot loader
  • Truecrypt

Both of these are open source - so examine their code. GRUB is perhaps the simpler of the two to study.

Once you know how the code works and how they get to run before your OS boots, then you can write your specific program yourself based on their technique.


Assuming you're talking about x86 architecture here.

When starting up the machine will try reading the first 512 Byte. If the last two bytes are 0xAA55 the machine will execute this code.By that you can run any assembler instructions.

This all is more comfortable once you have an operating system.

Do you have to copy the bytes all the time the machine starts or only once? - For only once grab a live CD or put netboot.me on a floppy and boot that. Then you can do things in a way nicer way.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号