mirror of
https://github.com/DarkMatterCore/nxdumptool.git
synced 2024-11-10 12:41:47 +00:00
15431ec2c8
* AES: moved CTR initializing/updating functions here from nca.c. * BKTR/RomFS/PFS: check if we're dealing with a NCA with titlekey crypto and the titlekey hasn't been retrieved. * BFTTF: use void pointers for output font data. * Mem: Only exclude Unmapped/Uo/ThreadLocal/Reserved memory pages if dealing with FS. * NCA: use content type context pointers inside NCA contexts to manage ContentMeta, ProgramInfo, Nacp and LegalInfo contexts. * NCA: added 'written' bool elements to patch structs to indicate patch write completion. * NPDM: remove unnecessary inline functions, generate PFS patch right after changing ACID data, add a pfsWriteEntryPatchToMemoryBuffer wrapper. * PFS: added PartitionFileSystemFileContext and related functions to deal with NSP headers. * ProgramInfo: removed unnecessary inline functions. * Save: added commented code to dump a full system savefile - will probably use it down the road. * Tik: added support for volatile tickets (thanks to @shchmue and @Whovian9369!), added a rights ID string representation to the Ticket struct, clear Volatile and ELicenseRequired flags in conversions to common tickets. * Title: added a function to calculate the number of titles (current + siblings) from a TItleInfo block. * Utils: added a function to generate a dynamically allocated path string using a prefix, a filename and a extension. * Removed explicit offset checks throughout all the code. * Codestyle fixes. * Updated to-do.
63 lines
2.3 KiB
C
63 lines
2.3 KiB
C
/*
|
|
* mem.h
|
|
*
|
|
* Copyright (c) 2019, shchmue.
|
|
* Copyright (c) 2020, DarkMatterCore <pabloacurielz@gmail.com>.
|
|
*
|
|
* This file is part of nxdumptool (https://github.com/DarkMatterCore/nxdumptool).
|
|
*
|
|
* nxdumptool is free software; you can redistribute it and/or modify it
|
|
* under the terms and conditions of the GNU General Public License,
|
|
* version 2, as published by the Free Software Foundation.
|
|
*
|
|
* nxdumptool is distributed in the hope it will be useful, but WITHOUT
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
|
* more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#ifndef __MEM_H__
|
|
#define __MEM_H__
|
|
|
|
#define FS_SYSMODULE_TID (u64)0x0100000000000000
|
|
#define BOOT_SYSMODULE_TID (u64)0x0100000000000005
|
|
#define SPL_SYSMODULE_TID (u64)0x0100000000000028
|
|
#define ES_SYSMODULE_TID (u64)0x0100000000000033
|
|
|
|
typedef enum {
|
|
MemoryProgramSegmentType_Text = BIT(0),
|
|
MemoryProgramSegmentType_Rodata = BIT(1),
|
|
MemoryProgramSegmentType_Data = BIT(2)
|
|
} MemoryProgramSegmentType;
|
|
|
|
typedef struct {
|
|
u64 program_id;
|
|
u8 mask; ///< MemoryProgramSegmentType. Used with memRetrieveProgramMemorySegment(). Ignored in memRetrieveFullProgramMemory().
|
|
u8 *data;
|
|
u64 data_size;
|
|
} MemoryLocation;
|
|
|
|
/// Retrieves memory segment (.text, .rodata, .data) data from a running program.
|
|
/// These are memory pages with read permission (Perm_R) enabled and type MemType_CodeStatic or MemType_CodeMutable.
|
|
bool memRetrieveProgramMemorySegment(MemoryLocation *location);
|
|
|
|
/// Retrieves full memory data from a running program.
|
|
/// These are any type of memory pages with read permission (Perm_R) enabled and no MemoryAttribute flag set.
|
|
/// MemType_Unmapped, MemType_Io, MemType_ThreadLocal and MemType_Reserved memory pages are excluded if FS program memory is being retrieved, in order to avoid hangs.
|
|
bool memRetrieveFullProgramMemory(MemoryLocation *location);
|
|
|
|
/// Frees a populated MemoryLocation element.
|
|
NX_INLINE void memFreeMemoryLocation(MemoryLocation *location)
|
|
{
|
|
if (!location) return;
|
|
if (location->data) free(location->data);
|
|
location->data = NULL;
|
|
location->data_size = 0;
|
|
}
|
|
|
|
#endif /* __MEM_H__ */
|