How do i load files using grub?
How do i load files using grub?
i've read that you can use grub to load files for you into memory. how do i do this? and where in memory will they be?
- JackScott
- Member
- Posts: 1036
- Joined: Thu Dec 21, 2006 3:03 am
- Location: Hobart, Australia
- Mastodon: https://aus.social/@jackscottau
- Matrix: @JackScottAU:matrix.org
- GitHub: https://github.com/JackScottAU
- Contact:
http://www.gnu.org/software/grub/manual ... tml#module
http://www.gnu.org/software/grub/manual ... ion-format
Between those two documents, the ideas should become apparent. You specify that you want GRUB to load a module, and then parse the multiboot information structure to find the module in memory once you get into the kernel.
http://www.gnu.org/software/grub/manual ... ion-format
Between those two documents, the ideas should become apparent. You specify that you want GRUB to load a module, and then parse the multiboot information structure to find the module in memory once you get into the kernel.
Also, check the bottom of this page.
okay after reading those links i came up with this:
now the file i want loaded looks like this
i when i run my OS it tells me that the modules have been loaded, but it seems the code pointer is pointing to the '@' and not the '=' like it's suppose to. and decrementing the pointer doesn't work because then it's pointing to a '?'
Code: Select all
void _main(void* mbd,unsigned int magic)
{
char *code;
char *bootdata=mbd;
unsigned int flags;
unsigned int loaded_modules;
flags=(unsigned int)*bootdata;
if((flags&0x08)==0x08)
{
Printf("Modules were loaded succesfully\n");
bootdata+=20;
loaded_modules=*bootdata;
Printf("Number of modules loaded: %d\n",loaded_modules);
bootdata+=4;
code=&bootdata;
}
else
{
Printf("Modules were not succesfully loaded\n");
}
Code: Select all
=@aa#a!a
No. Firstly bootdata should be of type "unsigned int *".
Then...
Should do it.
Then...
Code: Select all
code = (char*)*bootdata;