Update to latest libnx
This commit is contained in:
parent
fcf2315c7a
commit
6475c3b1e7
8 changed files with 129 additions and 28 deletions
|
|
@ -47,6 +47,24 @@ type
|
|||
IpcCommandType_Close = 2, IpcCommandType_LegacyControl = 3,
|
||||
IpcCommandType_Request = 4, IpcCommandType_Control = 5,
|
||||
IpcCommandType_RequestWithContext = 6, IpcCommandType_ControlWithContext = 7
|
||||
DomainMessageType* {.size: sizeof(cint).} = enum
|
||||
DomainMessageType_Invalid = 0, DomainMessageType_SendMessage = 1,
|
||||
DomainMessageType_Close = 2
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## / IPC domain message header.
|
||||
|
||||
type
|
||||
DomainMessageHeader* {.importc: "DomainMessageHeader", header: headeripc, bycopy.} = object
|
||||
Type* {.importc: "Type".}: uint8
|
||||
NumObjectIds* {.importc: "NumObjectIds".}: uint8
|
||||
Length* {.importc: "Length".}: uint16
|
||||
ThisObjectId* {.importc: "ThisObjectId".}: uint32
|
||||
Pad* {.importc: "Pad".}: array[2, uint32]
|
||||
|
||||
IpcCommand* {.importc: "IpcCommand", header: headeripc, bycopy.} = object
|
||||
NumSend* {.importc: "NumSend".}: csize ## A
|
||||
NumRecv* {.importc: "NumRecv".}: csize ## B
|
||||
|
|
@ -67,9 +85,6 @@ type
|
|||
ObjectIds* {.importc: "ObjectIds".}: array[IPC_MAX_OBJECTS, uint32]
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## *
|
||||
## @brief Initializes an IPC command structure.
|
||||
## @param cmd IPC command structure.
|
||||
|
|
@ -236,6 +251,9 @@ type
|
|||
NumHandles* {.importc: "NumHandles".}: csize ## /< Number of handles copied.
|
||||
Handles* {.importc: "Handles".}: array[IPC_MAX_OBJECTS, Handle] ## /< Handles.
|
||||
WasHandleCopied* {.importc: "WasHandleCopied".}: array[IPC_MAX_OBJECTS, bool] ## /< true if the handle was moved, false if it was copied.
|
||||
IsDomainMessage* {.importc: "IsDomainMessage".}: bool ## /< true if the the message is a Domain message.
|
||||
MessageType* {.importc: "MessageType".}: DomainMessageType ## /< Type of the domain message.
|
||||
MessageLength* {.importc: "MessageLength".}: uint32 ## /< Size of rawdata (for domain messages).
|
||||
ThisObjectId* {.importc: "ThisObjectId".}: uint32 ## /< Object ID to call the command on (for domain messages).
|
||||
NumObjectIds* {.importc: "NumObjectIds".}: csize ## /< Number of object IDs (for domain messages).
|
||||
ObjectIds* {.importc: "ObjectIds".}: array[IPC_MAX_OBJECTS, uint32] ## /< Object IDs (for domain messages).
|
||||
|
|
@ -300,17 +318,6 @@ proc ipcConvertSessionToDomain*(session: Handle; object_id_out: ptr uint32): Res
|
|||
|
||||
proc ipcSendObjectId*(cmd: ptr IpcCommand; object_id: uint32) {.inline, cdecl,
|
||||
importc: "ipcSendObjectId", header: headeripc.}
|
||||
## / IPC domain message header.
|
||||
|
||||
type
|
||||
DomainMessageHeader* {.importc: "DomainMessageHeader", header: headeripc, bycopy.} = object
|
||||
Type* {.importc: "Type".}: uint8
|
||||
NumObjectIds* {.importc: "NumObjectIds".}: uint8
|
||||
Length* {.importc: "Length".}: uint16
|
||||
ThisObjectId* {.importc: "ThisObjectId".}: uint32
|
||||
Pad* {.importc: "Pad".}: array[2, uint32]
|
||||
|
||||
|
||||
## *
|
||||
## @brief Prepares the header of an IPC command structure (domain version).
|
||||
## @param cmd IPC command structure.
|
||||
|
|
|
|||
|
|
@ -26,4 +26,11 @@ proc nsvmExit*() {.cdecl, importc: "nsvmExit", header: headerns.}
|
|||
proc nsvmNeedsUpdateVulnerability*(`out`: ptr bool): Result {.cdecl,
|
||||
importc: "nsvmNeedsUpdateVulnerability", header: headerns.}
|
||||
proc nsvmGetSafeSystemVersion*(`out`: ptr uint16): Result {.cdecl,
|
||||
importc: "nsvmGetSafeSystemVersion", header: headerns.}
|
||||
importc: "nsvmGetSafeSystemVersion", header: headerns.}
|
||||
proc nsdevInitialize*(): Result {.cdecl, importc: "nsdevInitialize",
|
||||
header: headerns.}
|
||||
proc nsdevExit*() {.cdecl, importc: "nsdevExit", header: headerns.}
|
||||
proc nsdevTerminateProcess*(pid: uint64): Result {.cdecl,
|
||||
importc: "nsdevTerminateProcess", header: headerns.}
|
||||
proc nsdevTerminateProgram*(tid: uint64): Result {.cdecl,
|
||||
importc: "nsdevTerminateProgram", header: headerns.}
|
||||
|
|
@ -45,9 +45,24 @@ typedef enum {
|
|||
IpcCommandType_Request = 4,
|
||||
IpcCommandType_Control = 5,
|
||||
IpcCommandType_RequestWithContext = 6,
|
||||
IpcCommandType_ControlWithContext = 7
|
||||
IpcCommandType_ControlWithContext = 7,
|
||||
} IpcCommandType;
|
||||
|
||||
typedef enum {
|
||||
DomainMessageType_Invalid = 0,
|
||||
DomainMessageType_SendMessage = 1,
|
||||
DomainMessageType_Close = 2,
|
||||
} DomainMessageType;
|
||||
|
||||
/// IPC domain message header.
|
||||
typedef struct {
|
||||
u8 Type;
|
||||
u8 NumObjectIds;
|
||||
u16 Length;
|
||||
u32 ThisObjectId;
|
||||
u32 Pad[2];
|
||||
} DomainMessageHeader;
|
||||
|
||||
typedef struct {
|
||||
size_t NumSend; // A
|
||||
size_t NumRecv; // B
|
||||
|
|
@ -348,6 +363,9 @@ typedef struct {
|
|||
Handle Handles[IPC_MAX_OBJECTS]; ///< Handles.
|
||||
bool WasHandleCopied[IPC_MAX_OBJECTS]; ///< true if the handle was moved, false if it was copied.
|
||||
|
||||
bool IsDomainMessage; ///< true if the the message is a Domain message.
|
||||
DomainMessageType MessageType; ///< Type of the domain message.
|
||||
u32 MessageLength; ///< Size of rawdata (for domain messages).
|
||||
u32 ThisObjectId; ///< Object ID to call the command on (for domain messages).
|
||||
size_t NumObjectIds; ///< Number of object IDs (for domain messages).
|
||||
u32 ObjectIds[IPC_MAX_OBJECTS]; ///< Object IDs (for domain messages).
|
||||
|
|
@ -366,7 +384,7 @@ typedef struct {
|
|||
size_t NumStaticsOut; ///< Number of output statics available in the response.
|
||||
|
||||
void* Raw; ///< Pointer to the raw embedded data structure in the response.
|
||||
void* RawWithoutPadding; ///< Pointer to the raw embedded data structure, without padding.
|
||||
void* RawWithoutPadding; ///< Pointer to the raw embedded data structure, without padding.
|
||||
size_t RawSize; ///< Size of the raw embedded data.
|
||||
} IpcParsedCommand;
|
||||
|
||||
|
|
@ -380,6 +398,8 @@ static inline Result ipcParse(IpcParsedCommand* r) {
|
|||
u32 ctrl0 = *buf++;
|
||||
u32 ctrl1 = *buf++;
|
||||
size_t i;
|
||||
|
||||
r->IsDomainMessage = false;
|
||||
|
||||
r->CommandType = (IpcCommandType) (ctrl0 & 0xffff);
|
||||
r->HasPid = false;
|
||||
|
|
@ -570,15 +590,6 @@ static inline void ipcSendObjectId(IpcCommand* cmd, u32 object_id) {
|
|||
cmd->ObjectIds[cmd->NumObjectIds++] = object_id;
|
||||
}
|
||||
|
||||
/// IPC domain message header.
|
||||
typedef struct {
|
||||
u8 Type;
|
||||
u8 NumObjectIds;
|
||||
u16 Length;
|
||||
u32 ThisObjectId;
|
||||
u32 Pad[2];
|
||||
} DomainMessageHeader;
|
||||
|
||||
/**
|
||||
* @brief Prepares the header of an IPC command structure (domain version).
|
||||
* @param cmd IPC command structure.
|
||||
|
|
@ -591,7 +602,7 @@ static inline void* ipcPrepareHeaderForDomain(IpcCommand* cmd, size_t sizeof_raw
|
|||
DomainMessageHeader* hdr = (DomainMessageHeader*) raw;
|
||||
u32 *object_ids = (u32*)(((uintptr_t) raw) + sizeof(DomainMessageHeader) + sizeof_raw);
|
||||
|
||||
hdr->Type = 1;
|
||||
hdr->Type = DomainMessageType_SendMessage;
|
||||
hdr->NumObjectIds = (u8)cmd->NumObjectIds;
|
||||
hdr->Length = sizeof_raw;
|
||||
hdr->ThisObjectId = object_id;
|
||||
|
|
@ -609,7 +620,7 @@ static inline void* ipcPrepareHeaderForDomain(IpcCommand* cmd, size_t sizeof_raw
|
|||
*/
|
||||
static inline Result ipcParseForDomain(IpcParsedCommand* r) {
|
||||
Result rc = ipcParse(r);
|
||||
DomainMessageHeader* hdr;
|
||||
DomainMessageHeader *hdr;
|
||||
u32 *object_ids;
|
||||
if(R_FAILED(rc))
|
||||
return rc;
|
||||
|
|
@ -618,8 +629,20 @@ static inline Result ipcParseForDomain(IpcParsedCommand* r) {
|
|||
object_ids = (u32*)(((uintptr_t) hdr) + sizeof(DomainMessageHeader) + hdr->Length);
|
||||
r->Raw = (void*)(((uintptr_t) r->Raw) + sizeof(DomainMessageHeader));
|
||||
|
||||
r->IsDomainMessage = true;
|
||||
r->MessageType = (DomainMessageType)(hdr->Type);
|
||||
switch (r->MessageType) {
|
||||
case DomainMessageType_SendMessage:
|
||||
case DomainMessageType_Close:
|
||||
break;
|
||||
default:
|
||||
return MAKERESULT(Module_Libnx, LibnxError_DomainMessageUnknownType);
|
||||
}
|
||||
r->ThisObjectId = hdr->ThisObjectId;
|
||||
r->NumObjectIds = hdr->NumObjectIds > 8 ? 8 : hdr->NumObjectIds;
|
||||
if ((uintptr_t)object_ids + sizeof(u32) * r->NumObjectIds - (uintptr_t)armGetTls() >= 0x100) {
|
||||
return MAKERESULT(Module_Libnx, LibnxError_DomainMessageTooManyObjectIds);
|
||||
}
|
||||
for(size_t i = 0; i < r->NumObjectIds; i++)
|
||||
r->ObjectIds[i] = object_ids[i];
|
||||
|
||||
|
|
|
|||
|
|
@ -131,6 +131,15 @@ typedef enum {
|
|||
ProcessState_DebugSuspended=7, ///<Process execution suspended by debugger.
|
||||
} ProcessState;
|
||||
|
||||
/// Debug Thread Parameters.
|
||||
typedef enum {
|
||||
DebugThreadParam_ActualPriority=0,
|
||||
DebugThreadParam_State=1,
|
||||
DebugThreadParam_IdealCore=2,
|
||||
DebugThreadParam_CurrentCore=3,
|
||||
DebugThreadParam_CoreMask=4,
|
||||
} DebugThreadParam;
|
||||
|
||||
///@name Memory management
|
||||
///@{
|
||||
|
||||
|
|
@ -833,6 +842,14 @@ Result svcGetDebugThreadContext(u8* out, Handle debug, u64 threadID, u32 flags);
|
|||
*/
|
||||
Result svcGetProcessList(u32 *num_out, u64 *pids_out, u32 max_pids);
|
||||
|
||||
/**
|
||||
* @brief Retrieves a list of all threads for a debug handle (or zero).
|
||||
* @return Result code.
|
||||
* @note Syscall number 0x66.
|
||||
* @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available.
|
||||
*/
|
||||
Result svcGetThreadList(u32 *num_out, u64 *tids_out, u32 max_tids, Handle debug);
|
||||
|
||||
///@}
|
||||
|
||||
///@name Debugging
|
||||
|
|
@ -862,6 +879,14 @@ Result svcReadDebugProcessMemory(void* buffer, Handle debug, u64 addr, u64 size)
|
|||
*/
|
||||
Result svcWriteDebugProcessMemory(Handle debug, void* buffer, u64 addr, u64 size);
|
||||
|
||||
/**
|
||||
* @brief Gets parameters from a thread in a debugging session.
|
||||
* @return Result code.
|
||||
* @note Syscall number 0x6D.
|
||||
* @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available.
|
||||
*/
|
||||
Result svcGetDebugThreadParam(u64* out_64, u32* out_32, Handle debug, u64 threadID, DebugThreadParam param);
|
||||
|
||||
///@}
|
||||
|
||||
///@name Miscellaneous
|
||||
|
|
|
|||
|
|
@ -72,6 +72,8 @@ enum {
|
|||
LibnxError_IncompatSysVer,
|
||||
LibnxError_InitFail_Time,
|
||||
LibnxError_TooManyDevOpTabs,
|
||||
LibnxError_DomainMessageUnknownType,
|
||||
LibnxError_DomainMessageTooManyObjectIds,
|
||||
};
|
||||
|
||||
/// libnx nvidia error codes
|
||||
|
|
|
|||
|
|
@ -38,3 +38,10 @@ void nsvmExit(void);
|
|||
|
||||
Result nsvmNeedsUpdateVulnerability(bool *out);
|
||||
Result nsvmGetSafeSystemVersion(u16 *out);
|
||||
|
||||
/* ns:dev */
|
||||
Result nsdevInitialize();
|
||||
void nsdevExit();
|
||||
|
||||
Result nsdevTerminateProcess(u64 pid);
|
||||
Result nsdevTerminateProgram(u64 tid);
|
||||
|
|
@ -89,6 +89,8 @@ const
|
|||
LibnxError_IncompatSysVer* = 37
|
||||
LibnxError_InitFail_Time* = 38
|
||||
LibnxError_TooManyDevOpTabs* = 39
|
||||
LibnxError_DomainMessageUnknownType* = 40
|
||||
LibnxError_DomainMessageTooManyObjectIds* = 41
|
||||
|
||||
## / libnx nvidia error codes
|
||||
|
||||
|
|
|
|||
|
|
@ -161,6 +161,15 @@ type
|
|||
ProcessState_DebugSuspended = 7 ## /<Process execution suspended by debugger.
|
||||
|
||||
|
||||
## / Debug Thread Parameters.
|
||||
|
||||
type
|
||||
DebugThreadParam* {.size: sizeof(cint).} = enum
|
||||
DebugThreadParam_ActualPriority = 0, DebugThreadParam_State = 1,
|
||||
DebugThreadParam_IdealCore = 2, DebugThreadParam_CurrentCore = 3,
|
||||
DebugThreadParam_CoreMask = 4
|
||||
|
||||
|
||||
## /@name Memory management
|
||||
## /@{
|
||||
## *
|
||||
|
|
@ -895,6 +904,15 @@ proc svcGetDebugThreadContext*(`out`: ptr uint8; debug: Handle; threadID: uint64
|
|||
|
||||
proc svcGetProcessList*(num_out: ptr uint32; pids_out: ptr uint64; max_pids: uint32): Result {.
|
||||
cdecl, importc: "svcGetProcessList", header: headersvc.}
|
||||
## *
|
||||
## @brief Retrieves a list of all threads for a debug handle (or zero).
|
||||
## @return Result code.
|
||||
## @note Syscall number 0x66.
|
||||
## @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available.
|
||||
##
|
||||
|
||||
proc svcGetThreadList*(num_out: ptr uint32; tids_out: ptr uint64; max_tids: uint32; debug: Handle): Result {.
|
||||
cdecl, importc: "svcGetThreadList", header: headersvc.}
|
||||
## /@}
|
||||
## /@name Debugging
|
||||
## /@{
|
||||
|
|
@ -926,6 +944,16 @@ proc svcReadDebugProcessMemory*(buffer: pointer; debug: Handle; `addr`: uint64;
|
|||
|
||||
proc svcWriteDebugProcessMemory*(debug: Handle; buffer: pointer; `addr`: uint64; size: uint64): Result {.
|
||||
cdecl, importc: "svcWriteDebugProcessMemory", header: headersvc.}
|
||||
## *
|
||||
## @brief Gets parameters from a thread in a debugging session.
|
||||
## @return Result code.
|
||||
## @note Syscall number 0x6D.
|
||||
## @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available.
|
||||
##
|
||||
|
||||
proc svcGetDebugThreadParam*(out_64: ptr uint64; out_32: ptr uint32; debug: Handle;
|
||||
threadID: uint64; param: DebugThreadParam): Result {.
|
||||
cdecl, importc: "svcGetDebugThreadParam", header: headersvc.}
|
||||
## /@}
|
||||
## /@name Miscellaneous
|
||||
## /@{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue