Advertisement
Guest User

MemoryDump.c

a guest
Feb 28th, 2015
173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.83 KB | None | 0 0
  1. #define START_SECTION __attribute__ ((section (".text.start"), naked))
  2.  
  3. // make sure code is PIE
  4. #ifndef __PIE__
  5. #error "Must compile with -fPIE"
  6. #endif
  7.  
  8. int(*IFile_Open)(void *this, const short *path, int flags) = 0x0022FE08;
  9. int(*IFile_Write)(void *this, unsigned int *written, void *src, unsigned int len) = 0x00168764;
  10. int (*GX_SetTextureCopy)(void *input_buffer, void *output_buffer, unsigned int size, int in_x, int in_y, int out_x, int out_y, int flags) = 0x0011DD48;
  11. int (*GSPGPU_FlushDataCache)(void *addr, unsigned int len) = 0x00191504;
  12. int (*svcSleepThread)(unsigned long long nanoseconds) = 0x0023FFE8;
  13.  
  14. int uvl_entry();
  15.  
  16. int START_SECTION
  17.  
  18. uvl_start ()
  19. {
  20.     __asm__ volatile (".word 0xE1A00000");
  21.     uvl_entry();
  22.     __asm__ volatile ("bx lr");
  23. }
  24.  
  25. int
  26. uvl_entry ()
  27. {
  28.     unsigned int addr;
  29.     void *this = 0x08F10000;
  30.     int *written = 0x08F01000;
  31.     int *buf = 0x18410000;
  32.  
  33.     unsigned int offset;
  34.     int i;
  35.  
  36.     IFile_Open(this, L"dmc:/mem1.bin", 6);
  37.     svcSleepThread(0x400000LL);
  38.  
  39.     //FCRAM dump
  40.     for (addr = 0x14000000; addr < 0x1A800000; addr += 0x10000)
  41.     {
  42.         //dumps a 0x10000 bytes of ram to sd card
  43.         GSPGPU_FlushDataCache(addr, 0x10000);
  44.         GX_SetTextureCopy(addr, buf, 0x10000, 0, 0, 0, 0, 8);
  45.         GSPGPU_FlushDataCache(buf, 0x10000);
  46.         svcSleepThread(0x400000LL);
  47.         IFile_Write(this, written, buf, 0x10000);
  48.  
  49.         //flashes mostly black screen on the bottom screen for a few frames, this is so i know the program is running and not frozen
  50.         GSPGPU_FlushDataCache(0x18000000, 0x00038400);
  51.         GX_SetTextureCopy(0x18000000, 0x1F48F000, 0x00038400, 0, 0, 0, 0, 8);
  52.         svcSleepThread(0x400000LL);
  53.         GSPGPU_FlushDataCache(0x18000000, 0x00038400);
  54.         GX_SetTextureCopy(0x18000000, 0x1F4C7800, 0x00038400, 0, 0, 0, 0, 8);
  55.         svcSleepThread(0x400000LL);
  56.     }
  57.  
  58.     return 0;
  59. }
  60.  
  61. int
  62. uvl_exit (int status)
  63. {
  64.     return 0;
  65. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement