Manually merge files
This commit is contained in:
@@ -44,8 +44,12 @@ extern KAutoObject * (*KProcessHandleTable__ToKAutoObject)(KProcessHandleTable *
|
||||
extern void (*KSynchronizationObject__Signal)(KSynchronizationObject *this, bool isPulse);
|
||||
extern Result (*WaitSynchronization1)(void *this_unused, KThread *thread, KSynchronizationObject *syncObject, s64 timeout);
|
||||
extern Result (*KProcessHandleTable__CreateHandle)(KProcessHandleTable *this, Handle *out, KAutoObject *obj, u8 token);
|
||||
extern Result (*KProcessHwInfo__QueryMemory)(KProcessHwInfo *this, MemoryInfo *memoryInfo, PageInfo *pageInfo, void *address);
|
||||
extern Result (*KProcessHwInfo__MapProcessMemory)(KProcessHwInfo *this, KProcessHwInfo *other, void *dst, void *src, u32 nbPages);
|
||||
extern Result (*KProcessHwInfo__UnmapProcessMemory)(KProcessHwInfo *this, void *addr, u32 nbPages);
|
||||
extern Result (*KProcessHwInfo__CheckVaState)(KProcessHwInfo *hwInfo, u32 va, u32 size, u32 state, u32 perm);
|
||||
extern Result (*KProcessHwInfo__GetListOfKBlockInfoForVA)(KProcessHwInfo *hwInfo, KLinkedList *list, u32 va, u32 sizeInPage);
|
||||
extern Result (*KProcessHwInfo__MapListOfKBlockInfo)(KProcessHwInfo *this, u32 va, KLinkedList *list, u32 state, u32 perm, u32 sbz);
|
||||
extern Result (*KEvent__Clear)(KEvent *this);
|
||||
extern void (*KObjectMutex__WaitAndAcquire)(KObjectMutex *this);
|
||||
extern void (*KObjectMutex__ErrorOccured)(void);
|
||||
@@ -53,8 +57,11 @@ extern void (*KObjectMutex__ErrorOccured)(void);
|
||||
extern void (*KScheduler__AdjustThread)(KScheduler *this, KThread *thread, u32 oldSchedulingMask);
|
||||
extern void (*KScheduler__AttemptSwitchingThreadContext)(KScheduler *this);
|
||||
|
||||
extern void (*KLinkedList_KBlockInfo__Clear)(KLinkedList *list);
|
||||
|
||||
extern Result (*ControlMemory)(u32 *addrOut, u32 addr0, u32 addr1, u32 size, MemOp op, MemPerm perm, bool isLoader);
|
||||
extern void (*SleepThread)(s64 ns);
|
||||
extern Result (*CreateEvent)(Handle *out, ResetType resetType);
|
||||
extern Result (*CloseHandle)(Handle handle);
|
||||
extern Result (*GetHandleInfo)(s64 *out, Handle handle, u32 type);
|
||||
extern Result (*GetSystemInfo)(s64 *out, s32 type, s32 param);
|
||||
@@ -65,6 +72,7 @@ extern Result (*SendSyncRequest)(Handle handle);
|
||||
extern Result (*OpenProcess)(Handle *out, u32 processId);
|
||||
extern Result (*GetProcessId)(u32 *out, Handle process);
|
||||
extern Result (*DebugActiveProcess)(Handle *out, u32 processId);
|
||||
extern Result (*SignalEvent)(Handle event);
|
||||
extern Result (*UnmapProcessMemory)(Handle processHandle, void *dst, u32 size);
|
||||
extern Result (*KernelSetState)(u32 type, u32 varg1, u32 varg2, u32 varg3);
|
||||
|
||||
@@ -129,9 +137,12 @@ typedef struct CfwInfo
|
||||
u32 config, multiConfig, bootConfig;
|
||||
u64 hbldr3dsxTitleId;
|
||||
u32 rosalinaMenuCombo;
|
||||
u32 rosalinaFlags;
|
||||
} CfwInfo;
|
||||
|
||||
extern CfwInfo cfwInfo;
|
||||
|
||||
extern vu32 rosalinaState;
|
||||
extern bool hasStartedRosalinaNetworkFuncsOnce;
|
||||
|
||||
KLinkedList* KLinkedList__Initialize(KLinkedList *list);
|
||||
|
||||
@@ -105,6 +105,14 @@ typedef struct ALIGN(4) KMutex
|
||||
union KProcess *owner;
|
||||
} KMutex;
|
||||
|
||||
typedef struct KAddressArbiter
|
||||
{
|
||||
KAutoObject autoObject;
|
||||
struct KThread *first;
|
||||
struct KThread *last;
|
||||
union KProcess *owner;
|
||||
} KAddressArbiter;
|
||||
|
||||
/* 92 */
|
||||
typedef struct KMutexLinkedList
|
||||
{
|
||||
@@ -112,6 +120,30 @@ typedef struct KMutexLinkedList
|
||||
KMutex *last;
|
||||
} KMutexLinkedList;
|
||||
|
||||
enum
|
||||
{
|
||||
TOKEN_KAUTOOBJECT = 0,
|
||||
TOKEN_KSYNCHRONIZATIONOBJECT = 1,
|
||||
TOKEN_KEVENT = 0x1F,
|
||||
TOKEN_KSEMAPHORE = 0x2F,
|
||||
TOKEN_KTIMER = 0x35,
|
||||
TOKEN_KMUTEX = 0x39,
|
||||
TOKEN_KDEBUG = 0x4D,
|
||||
TOKEN_KSERVERPORT = 0x55,
|
||||
TOKEN_KDMAOBJECT = 0x59,
|
||||
TOKEN_KCLIENTPORT = 0x65,
|
||||
TOKEN_KCODESET = 0x68,
|
||||
TOKEN_KSESSION = 0x70,
|
||||
TOKEN_KTHREAD = 0x8D,
|
||||
TOKEN_KSERVERSESSION = 0x95,
|
||||
TOKEN_KADDRESSARBITER = 0x98,
|
||||
TOKEN_KCLIENTSESSION = 0xA5,
|
||||
TOKEN_KPORT = 0xA8,
|
||||
TOKEN_KSHAREDMEMORY = 0xB0,
|
||||
TOKEN_KPROCESS = 0xC5,
|
||||
TOKEN_KRESOURCELIMIT = 0xC8
|
||||
};
|
||||
|
||||
/* 45 */
|
||||
typedef struct KClassToken
|
||||
{
|
||||
@@ -540,6 +572,20 @@ typedef struct KBlockInfo
|
||||
u32 pageCount;
|
||||
} KBlockInfo;
|
||||
|
||||
typedef struct KSharedMemory
|
||||
{
|
||||
KAutoObject autoObject;
|
||||
KLinkedList ownedKBlockInfo;
|
||||
union KProcess *owner;
|
||||
u32 ownerPermissions;
|
||||
u32 otherPermissions;
|
||||
u8 isBlockInfoGenerated;
|
||||
s8 allBlockInfoGenerated;
|
||||
u8 unknown_1;
|
||||
u8 unknown_2;
|
||||
u32 address;
|
||||
} KSharedMemory;
|
||||
|
||||
/* 25 */
|
||||
typedef struct KMemoryBlock
|
||||
{
|
||||
@@ -1037,10 +1083,26 @@ typedef struct KProcess##sys\
|
||||
KThread *mainThread;\
|
||||
u32 interruptEnabledFlags[4];\
|
||||
KProcessHandleTable handleTable;\
|
||||
u8 gap234[52];\
|
||||
/* Custom fields for plugin system
|
||||
{ */ \
|
||||
u32 customFlags; /* see KProcess_CustomFlags enum below */ \
|
||||
Handle onMemoryLayoutChangeEvent;\
|
||||
Handle onProcessExitEvent;\
|
||||
Handle resumeProcessExitEvent;\
|
||||
/* } */ \
|
||||
u8 gap234[36];\
|
||||
u64 unused;\
|
||||
} KProcess##sys;
|
||||
|
||||
enum KProcess_CustomFlags
|
||||
{
|
||||
ForceRWXPages = 1 << 0,
|
||||
SignalOnMemLayoutChanges = 1 << 1,
|
||||
SignalOnExit = 1 << 2,
|
||||
|
||||
MemLayoutChanged = 1 << 16
|
||||
};
|
||||
|
||||
INSTANCIATE_KPROCESS(N3DS);
|
||||
INSTANCIATE_KPROCESS(O3DS8x);
|
||||
INSTANCIATE_KPROCESS(O3DSPre8x);
|
||||
|
||||
129
k11_extension/include/mmu.h
Normal file
129
k11_extension/include/mmu.h
Normal file
@@ -0,0 +1,129 @@
|
||||
#pragma once
|
||||
|
||||
#include "types.h"
|
||||
#include "kernel.h"
|
||||
|
||||
typedef struct
|
||||
{
|
||||
u32 bits1_0 : 2; ///< 0b00
|
||||
} Desc_TranslationFault;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
u32 bits1_0 : 2; ///< 0b01
|
||||
u32 sbz : 3;
|
||||
u32 domain : 4;
|
||||
u32 p : 1;
|
||||
u32 addr : 21;
|
||||
} Desc_CoarsePageTable;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
u32 bits1_0 : 2; ///< 0b10
|
||||
u32 b : 1;
|
||||
u32 c : 1;
|
||||
u32 xn : 1;
|
||||
u32 domain : 4;
|
||||
u32 p : 1;
|
||||
u32 ap : 2;
|
||||
u32 tex : 3;
|
||||
u32 apx : 1;
|
||||
u32 s : 1;
|
||||
u32 ng : 1;
|
||||
u32 bit18 : 1; ///< 0
|
||||
u32 sbz : 1;
|
||||
u32 addr : 12;
|
||||
} Desc_Section;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
u32 bits1_0 : 2; ///< 0b10
|
||||
u32 b : 1;
|
||||
u32 c : 1;
|
||||
u32 xn : 1;
|
||||
u32 domain : 4;
|
||||
u32 p : 1;
|
||||
u32 ap : 2;
|
||||
u32 tex : 3;
|
||||
u32 sbz : 3;
|
||||
u32 bit18 : 1; ///< 1
|
||||
u32 sbz2 : 5;
|
||||
u32 addr : 8;
|
||||
} Desc_Supersection;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
u32 bits1_0 : 2; ///< 0b11
|
||||
} Desc_Reserved;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
u32 bits1_0 : 2; ///< 0b01
|
||||
u32 b : 1;
|
||||
u32 c : 1;
|
||||
u32 ap : 2;
|
||||
u32 sbz : 3;
|
||||
u32 apx : 1;
|
||||
u32 s : 1;
|
||||
u32 ng : 1;
|
||||
u32 tex : 3;
|
||||
u32 xn : 1;
|
||||
u32 addr : 16;
|
||||
} Desc_LargePage;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
u32 xn : 1;
|
||||
u32 bit1 : 1; ///< 1
|
||||
u32 b : 1;
|
||||
u32 c : 1;
|
||||
u32 ap : 2;
|
||||
u32 tex : 3;
|
||||
u32 apx : 1;
|
||||
u32 s : 1;
|
||||
u32 ng : 1;
|
||||
u32 addr : 20;
|
||||
} Desc_SmallPage;
|
||||
|
||||
typedef union
|
||||
{
|
||||
u32 raw;
|
||||
|
||||
Desc_TranslationFault translationFault;
|
||||
Desc_CoarsePageTable coarsePageTable;
|
||||
Desc_Section section;
|
||||
Desc_Supersection supersection;
|
||||
Desc_Reserved reserved;
|
||||
|
||||
} L1Descriptor;
|
||||
|
||||
typedef union
|
||||
{
|
||||
u32 raw;
|
||||
|
||||
Desc_TranslationFault translationFault;
|
||||
Desc_LargePage largePage;
|
||||
Desc_SmallPage smallPage;
|
||||
} L2Descriptor;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
Descriptor_TranslationFault,
|
||||
Descriptor_CoarsePageTable,
|
||||
Descriptor_Section,
|
||||
Descriptor_Supersection,
|
||||
Descriptor_Reserved,
|
||||
Descriptor_LargePage,
|
||||
Descriptor_SmallPage
|
||||
} DescType;
|
||||
|
||||
void L1MMUTable__RWXForAll(u32 *table);
|
||||
void L2MMUTable__RWXForAll(u32 *table);
|
||||
u32 L1MMUTable__GetPAFromVA(u32 *table, u32 va);
|
||||
u32 L2MMUTable__GetPAFromVA(u32 *table, u32 va);
|
||||
u32 L1MMUTable__GetAddressUserPerm(u32 *table, u32 va);
|
||||
u32 L2MMUTable__GetAddressUserPerm(u32 *table, u32 va);
|
||||
|
||||
void KProcessHwInfo__SetMMUTableToRWX(KProcessHwInfo *hwInfo);
|
||||
u32 KProcessHwInfo__GetPAFromVA(KProcessHwInfo *hwInfo, u32 va);
|
||||
u32 KProcessHwInfo__GetAddressUserPerm(KProcessHwInfo *hwInfo, u32 va);
|
||||
21
k11_extension/include/svc/ControlProcess.h
Normal file
21
k11_extension/include/svc/ControlProcess.h
Normal file
@@ -0,0 +1,21 @@
|
||||
#pragma once
|
||||
|
||||
#include "utils.h"
|
||||
#include "kernel.h"
|
||||
#include "svc.h"
|
||||
|
||||
/// Operations for svcControlProcess
|
||||
typedef enum ProcessOp
|
||||
{
|
||||
PROCESSOP_GET_ALL_HANDLES, ///< List all handles of the process, varg3 can be either 0 to fetch all handles, or token of the type to fetch
|
||||
///< svcControlProcess(handle, PROCESSOP_GET_ALL_HANDLES, (u32)&outBuf, 0)
|
||||
PROCESSOP_SET_MMU_TO_RWX, ///< Set the whole memory of the process with rwx access
|
||||
///< svcControlProcess(handle, PROCESSOP_SET_MMU_TO_RWX, 0, 0)
|
||||
PROCESSOP_GET_ON_MEMORY_CHANGE_EVENT,
|
||||
PROCESSOP_GET_ON_EXIT_EVENT,
|
||||
PROCESSOP_GET_PA_FROM_VA, ///< Get the physical address of the va within the process
|
||||
///< svcControlProcess(handle, PROCESSOP_GET_PA_FROM_VA, (u32)&outPa, va)
|
||||
PROCESSOP_SCHEDULE_THREADS,
|
||||
} ProcessOp;
|
||||
|
||||
Result ControlProcess(Handle process, ProcessOp op, u32 varg2, u32 varg3);
|
||||
@@ -30,4 +30,5 @@
|
||||
#include "kernel.h"
|
||||
#include "svc.h"
|
||||
|
||||
Result MapProcessMemoryEx(Handle processHandle, void *dst, void *src, u32 size);
|
||||
Result MapProcessMemoryEx(Handle dstProcessHandle, u32 vaDst, Handle srcProcessHandle, u32 vaSrc, u32 size);
|
||||
Result MapProcessMemoryExWrapper(Handle dstProcessHandle, u32 vaDst, Handle srcProcessHandle, u32 vaSrc, u32 size);
|
||||
|
||||
Reference in New Issue
Block a user