UNIX

Xenon_Exec Elf From Memory

May 9th, 2012
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.63 KB | None | 0 0
  1. void *elfPosition = (void *)0x1400000;
  2. int elfSize;
  3.  
  4. int main(){
  5.     // Init console and video
  6.     videoInit();
  7.  
  8.     // Create FILE type for our elf to load from USB to memory address
  9.     FILE *elfFile = fopen("uda:/xenon.elf32", "rb");
  10.  
  11.     // Get the size of the elf
  12.     fseek(elfFile, 0, SEEK_END);
  13.     elfSize = ftell(elfFile);
  14.     rewind(elfFile);
  15.  
  16.     /* Now that we have all the info we need about the file,
  17.        we can read the executeable into the memory address
  18.        we defined at the top of the file.
  19.     */
  20.     fread(&elfPosition[elfSize], 1, elfSize, elfFile);
  21.  
  22.     // Execute the elf from the memory address
  23.     elf_runFromMemory(elfPosition, elfSize);
  24. }
Advertisement
Add Comment
Please, Sign In to add comment