RAM dump

Discussion in '3DS - Homebrew Development and Emulators' started by -LuCas-, Feb 20, 2015.

  1. -LuCas-
    OP

    -LuCas- Member

    Newcomer
    34
    12
    Dec 6, 2014
    Italy
    How can I dump the Ram and then write it ?
     
  2. Rinnegatamante

    Rinnegatamante GBAtemp Psycho!

    Member
    3,127
    3,270
    Nov 24, 2014
    Italy
    Bologna
    You must do something like this:

    Code:
    void DumpRam(char* output,u32 base,u32 length){
        Handle fileHandle;
        u32 bytesWritten;
        u32 MAX_RAM_ADDRESS = (base + length); // Don't know if ninjhax accessible offsets starts from 0x0 but it can access only 64 MB RAM
        u32 i = base;
        FS_path filePath=FS_makePath(PATH_CHAR, output);
        FS_archive dump=(FS_archive){ARCH_SDMC, (FS_path){PATH_EMPTY, 1, (u8*)""}};
        FSUSER_OpenFileDirectly(NULL, &fileHandle, dump, filePath, FS_OPEN_CREATE | FS_OPEN_WRITE, FS_ATTRIBUTE_NONE);
        while (i <= MAX_RAM_ADDRESS){
            FSFILE_Write(fileHandle, &bytesWritten, (i-base), *(u8*)i, 1, FS_WRITE_FLUSH);
            i++;
        }
        FSFILE_Close(fileHandle);
        svcCloseHandle(fileHandle);
    }
     
  3. -LuCas-
    This message by -LuCas- has been removed from public view by BORTZ, Feb 21, 2015, Reason: english only.
    Feb 20, 2015
  4. SMOKE

    SMOKE Advanced Member

    Newcomer
    59
    22
    Jan 8, 2015
    United States