mirror of
https://github.com/switchbrew/libnx.git
synced 2025-06-21 12:32:40 +02:00
Add cmifCloneCurrentObject and serviceClone (i.e. non-Ex variants)
This commit is contained in:
parent
dedd29b431
commit
2224be3f88
@ -332,6 +332,20 @@ NX_INLINE Result cmifCopyFromCurrentDomain(Handle h, u32 object_id, Handle* out_
|
||||
return rc;
|
||||
}
|
||||
|
||||
NX_INLINE Result cmifCloneCurrentObject(Handle h, Handle* out_h)
|
||||
{
|
||||
cmifMakeControlRequest(armGetTls(), 2, 0);
|
||||
Result rc = svcSendSyncRequest(h);
|
||||
if (R_SUCCEEDED(rc))
|
||||
{
|
||||
CmifResponse resp = {};
|
||||
rc = cmifParseResponse(&resp, armGetTls(), false, 0);
|
||||
if (R_SUCCEEDED(rc) && out_h)
|
||||
*out_h = resp.move_handles[0];
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
|
||||
NX_INLINE Result cmifQueryPointerBufferSize(Handle h, u16* out_size)
|
||||
{
|
||||
cmifMakeControlRequest(armGetTls(), 3, 0);
|
||||
@ -346,10 +360,10 @@ NX_INLINE Result cmifQueryPointerBufferSize(Handle h, u16* out_size)
|
||||
return rc;
|
||||
}
|
||||
|
||||
NX_INLINE Result cmifCloneCurrentObjectEx(Handle h, u32 unk, Handle* out_h)
|
||||
NX_INLINE Result cmifCloneCurrentObjectEx(Handle h, u32 tag, Handle* out_h)
|
||||
{
|
||||
void* raw = cmifMakeControlRequest(armGetTls(), 4, sizeof(u32));
|
||||
*(u32*)raw = unk;
|
||||
*(u32*)raw = tag;
|
||||
Result rc = svcSendSyncRequest(h);
|
||||
if (R_SUCCEEDED(rc))
|
||||
{
|
||||
|
@ -178,16 +178,30 @@ NX_INLINE void serviceClose(Service* s)
|
||||
/**
|
||||
* @brief Clones a service.
|
||||
* @param[in] s Service object.
|
||||
* @param[in] unk Unknown parameter.
|
||||
* @param[out] out_s Output service object.
|
||||
*/
|
||||
NX_INLINE Result serviceCloneEx(Service* s, u32 unk, Service* out_s)
|
||||
NX_INLINE Result serviceClone(Service* s, Service* out_s)
|
||||
{
|
||||
out_s->session = 0;
|
||||
out_s->own_handle = 1;
|
||||
out_s->object_id = s->object_id;
|
||||
out_s->pointer_buffer_size = s->pointer_buffer_size;
|
||||
return cmifCloneCurrentObjectEx(s->session, unk, &out_s->session);
|
||||
return cmifCloneCurrentObject(s->session, &out_s->session);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Clones a service with a session manager tag.
|
||||
* @param[in] s Service object.
|
||||
* @param[in] tag Session manager tag (unused in current official server code)
|
||||
* @param[out] out_s Output service object.
|
||||
*/
|
||||
NX_INLINE Result serviceCloneEx(Service* s, u32 tag, Service* out_s)
|
||||
{
|
||||
out_s->session = 0;
|
||||
out_s->own_handle = 1;
|
||||
out_s->object_id = s->object_id;
|
||||
out_s->pointer_buffer_size = s->pointer_buffer_size;
|
||||
return cmifCloneCurrentObjectEx(s->session, tag, &out_s->session);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user