Guest User

gspwn userland ram dumper

a guest
Nov 7th, 2015
336
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.13 KB | None | 0 0
  1. // by shutterbug2000 from GBAtemp
  2.  
  3. #include <3ds.h>
  4. #include <3ds/srv.h>
  5. #include <stdio.h>
  6.  
  7. //Handle* gspHand;
  8.  
  9. int main()
  10. {
  11.  
  12.     FILE *dump;
  13.  
  14.     gfxInitDefault();
  15.     consoleInit(GFX_TOP, NULL);
  16.  
  17.     Handle* gspHand = gspInit();
  18.    
  19.     u8* dumpbuf = linearAlloc(0x10000);
  20.    
  21.     int addr = 0;
  22.    
  23.     for (addr = 0x14000000; addr < 0x1A800000; addr += 0x10000){
  24.     GSPGPU_FlushDataCache(gspHand, addr, 0x10000);
  25.     GX_SetTextureCopy(NULL, (u32*)addr, 0x00000000, (u32*)dumpbuf, 0x00000000, 0x10000, 0x00000008);
  26.     GSPGPU_FlushDataCache(gspHand, dumpbuf, 0x10000);
  27.     dump = fopen("dump.bin", "wb");
  28.     fseek(dump, addr - 0x14000000, SEEK_SET);
  29.     fwrite(dumpbuf, 1, 0x10000, dump);
  30.     fclose(dump);
  31.     printf("\x1b[15;20HDumping...%x", addr);
  32.     }
  33.    
  34.     // Main loop
  35.     while (aptMainLoop())
  36.     {
  37.    
  38.     printf("\x1b[15;19HDone!");
  39.  
  40.     u32 kDown = hidKeysDown();
  41.         if (kDown & KEY_START)
  42.             break; // break in order to return to hbmenu
  43.  
  44.             // Flush and swap framebuffers
  45.         gfxFlushBuffers();
  46.         gfxSwapBuffers();
  47.     }
  48.  
  49.     gfxExit();
  50.     return 0;
  51. }
Advertisement
Add Comment
Please, Sign In to add comment