Result APT_AppletUtility(u32* out, u32 a, u32 size1, u8* buf1, u32 size2, u8* buf2)
{
+ u32 saved_threadstorage[2];
+
u32* cmdbuf=getThreadCommandBuffer();
cmdbuf[0]=IPC_MakeHeader(0x4B,3,2); // 0x4B00C2
cmdbuf[1]=a;
cmdbuf[5]=(u32)buf1;
u32 *staticbufs = getThreadStaticBuffers();
+ saved_threadstorage[0]=staticbufs[0];
+ saved_threadstorage[1]=staticbufs[1];
+
staticbufs[0]=IPC_Desc_StaticBuffer(size2,0);
staticbufs[1]=(u32)buf2;
- Result ret=0;
- if(R_FAILED(ret=svcSendSyncRequest(aptuHandle)))return ret;
-
+ Result ret=svcSendSyncRequest(aptuHandle);
+
+ staticbufs[0]=saved_threadstorage[0];
+ staticbufs[1]=saved_threadstorage[1];
+
+ if(R_FAILED(ret))return ret;
+
if(out)*out=cmdbuf[2];
return cmdbuf[1];
staticbufs[0] = IPC_Desc_StaticBuffer(length,0);
staticbufs[1] = (u32)buffer;
- if (R_FAILED(ret = svcSendSyncRequest(dspHandle))) return ret;
+ ret = svcSendSyncRequest(dspHandle);
staticbufs[0] = saved1;
staticbufs[1] = saved2;
-
+
+ if (R_FAILED(ret)) return ret;
+
if (length_read)
*length_read = cmdbuf[2] & 0xFFFF;
return cmdbuf[1];
staticbufs[1] = (u32)tmpaddr;
ret = svcSendSyncRequest(SOCU_handle);
+
+ staticbufs[0] = saved_threadstorage[0];
+ staticbufs[1] = saved_threadstorage[1];
+
if(ret != 0) {
__release_handle(fd);
errno = SYNC_ERROR;
return ret;
}
- staticbufs[0] = saved_threadstorage[0];
- staticbufs[1] = saved_threadstorage[1];
-
ret = (int)cmdbuf[1];
if(ret == 0)
ret = _net_convert_error(cmdbuf[2]);
staticbufs[1] = (u32)outbuf;
ret = svcSendSyncRequest(SOCU_handle);
+
+ staticbufs[0] = saved_threadstorage[0];
+ staticbufs[1] = saved_threadstorage[1];
+
if(ret != 0) {
h_errno = NO_RECOVERY;
return NULL;
}
- staticbufs[0] = saved_threadstorage[0];
- staticbufs[1] = saved_threadstorage[1];
-
ret = (int)cmdbuf[1];
if(ret == 0)
ret = _net_convert_error(cmdbuf[2]);
staticbufs[1] = (u32)tmpaddr;
ret = svcSendSyncRequest(SOCU_handle);
+
+ staticbufs[0] = saved_threadstorage[0];
+ staticbufs[1] = saved_threadstorage[1];
+
if(ret != 0) {
errno = SYNC_ERROR;
return ret;
}
- staticbufs[0] = saved_threadstorage[0];
- staticbufs[1] = saved_threadstorage[1];
-
ret = (int)cmdbuf[1];
if(ret == 0)
ret = _net_convert_error(cmdbuf[2]);
staticbufs[1] = (u32)tmpaddr;
ret = svcSendSyncRequest(SOCU_handle);
+
+ staticbufs[0] = saved_threadstorage[0];
+ staticbufs[1] = saved_threadstorage[1];
+
if(ret != 0) {
errno = SYNC_ERROR;
return ret;
}
- staticbufs[0] = saved_threadstorage[0];
- staticbufs[1] = saved_threadstorage[1];
-
ret = (int)cmdbuf[1];
if(ret == 0)
ret = _net_convert_error(cmdbuf[2]);
staticbufs[1] = (u32)optval;
ret = svcSendSyncRequest(SOCU_handle);
+
+ staticbufs[0] = saved_threadstorage[0];
+ staticbufs[1] = saved_threadstorage[1];
+
if(ret != 0) {
errno = SYNC_ERROR;
return ret;
}
- staticbufs[0] = saved_threadstorage[0];
- staticbufs[1] = saved_threadstorage[1];
-
ret = (int)cmdbuf[1];
if(ret == 0)
ret = _net_convert_error(cmdbuf[2]);
staticbufs[1] = (u32)tmp_fds;
ret = svcSendSyncRequest(SOCU_handle);
+
+ staticbufs[0] = saved_threadstorage[0];
+ staticbufs[1] = saved_threadstorage[1];
+
if(ret != 0) {
free(tmp_fds);
errno = SYNC_ERROR;
return ret;
}
- staticbufs[0] = saved_threadstorage[0];
- staticbufs[1] = saved_threadstorage[1];
-
ret = (int)cmdbuf[1];
if(ret == 0)
ret = _net_convert_error(cmdbuf[2]);
staticbufs[1] = (u32)tmpaddr;
ret = svcSendSyncRequest(SOCU_handle);
+
+ staticbufs[0] = saved_threadstorage[0];
+ staticbufs[1] = saved_threadstorage[1];
+
if(ret != 0) {
errno = SYNC_ERROR;
return -1;
}
- staticbufs[0] = saved_threadstorage[0];
- staticbufs[1] = saved_threadstorage[1];
-
ret = (int)cmdbuf[1];
if(ret == 0)
ret = _net_convert_error(cmdbuf[2]);