mirror of
https://github.com/switchbrew/libnx.git
synced 2025-06-27 07:12:40 +02:00
Added libappletPushInData. Moved common storage creation+writing code into 1 func, in libapplet.c.
This commit is contained in:
parent
2405872b16
commit
2d5000ba57
@ -41,6 +41,14 @@ void libappletArgsSetPlayStartupSound(LibAppletArgs* a, bool flag);
|
|||||||
*/
|
*/
|
||||||
Result libappletArgsPush(LibAppletArgs* a, AppletHolder *h);
|
Result libappletArgsPush(LibAppletArgs* a, AppletHolder *h);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Creates a storage using the input buffer which is pushed to the AppletHolder via \ref appletHolderPushInData.
|
||||||
|
* @param h AppletHolder object.
|
||||||
|
* @param buffer Input data buffer.
|
||||||
|
* @param size Input data size.
|
||||||
|
*/
|
||||||
|
Result libappletPushInData(AppletHolder *h, const void* buffer, size_t size);
|
||||||
|
|
||||||
/// Wrapper for \ref appletPushToGeneralChannel, see appletPushToGeneralChannel regarding the requirements for using this.
|
/// Wrapper for \ref appletPushToGeneralChannel, see appletPushToGeneralChannel regarding the requirements for using this.
|
||||||
/// Returns to the main Home Menu, equivalent to pressing the HOME button.
|
/// Returns to the main Home Menu, equivalent to pressing the HOME button.
|
||||||
Result libappletRequestHomeMenu(void);
|
Result libappletRequestHomeMenu(void);
|
||||||
|
@ -19,43 +19,54 @@ void libappletArgsSetPlayStartupSound(LibAppletArgs* a, bool flag) {
|
|||||||
a->PlayStartupSound = flag!=0;
|
a->PlayStartupSound = flag!=0;
|
||||||
}
|
}
|
||||||
|
|
||||||
Result libappletArgsPush(LibAppletArgs* a, AppletHolder *h) {
|
static Result _libappletCreateWriteStorage(AppletStorage* s, const void* buffer, size_t size) {
|
||||||
|
Result rc=0;
|
||||||
|
|
||||||
|
rc = appletCreateStorage(s, size);
|
||||||
|
if (R_FAILED(rc)) return rc;
|
||||||
|
|
||||||
|
rc = appletStorageWrite(s, 0, buffer, size);
|
||||||
|
if (R_FAILED(rc)) {
|
||||||
|
appletStorageClose(s);
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
|
||||||
|
static Result _libappletPushInData(AppletHolder *h, const void* buffer, size_t size) {
|
||||||
Result rc=0;
|
Result rc=0;
|
||||||
AppletStorage storage;
|
AppletStorage storage;
|
||||||
|
|
||||||
|
rc = _libappletCreateWriteStorage(&storage, buffer, size);
|
||||||
|
if (R_FAILED(rc)) return rc;
|
||||||
|
|
||||||
|
return appletHolderPushInData(h, &storage);
|
||||||
|
}
|
||||||
|
|
||||||
|
Result libappletArgsPush(LibAppletArgs* a, AppletHolder *h) {
|
||||||
//Official sw stores the header in LibAppletArgs seperately (first 8-bytes), but here we're including it with the LibAppletCommonArguments struct.
|
//Official sw stores the header in LibAppletArgs seperately (first 8-bytes), but here we're including it with the LibAppletCommonArguments struct.
|
||||||
//Official sw uses appletStorageWrite twice, for writing the header then the rest of the struct.
|
//Official sw uses appletStorageWrite twice, for writing the header then the rest of the struct.
|
||||||
|
|
||||||
a->tick = armGetSystemTick();
|
a->tick = armGetSystemTick();
|
||||||
|
|
||||||
rc = appletCreateStorage(&storage, sizeof(LibAppletArgs));
|
return _libappletPushInData(h, a, sizeof(LibAppletArgs));
|
||||||
if (R_FAILED(rc)) return rc;
|
|
||||||
|
|
||||||
rc = appletStorageWrite(&storage, 0, a, sizeof(LibAppletArgs));
|
|
||||||
if (R_FAILED(rc)) {
|
|
||||||
appletStorageClose(&storage);
|
|
||||||
return rc;
|
|
||||||
}
|
|
||||||
|
|
||||||
return appletHolderPushInData(h, &storage);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static Result _libappletQlaunchRequest(u8* buf, size_t size) {
|
static Result _libappletQlaunchRequest(u8* buf, size_t size) {
|
||||||
Result rc=0;
|
Result rc=0;
|
||||||
AppletStorage storage;
|
AppletStorage storage;
|
||||||
|
|
||||||
rc = appletCreateStorage(&storage, size);
|
rc = _libappletCreateWriteStorage(&storage, buf, size);
|
||||||
if (R_FAILED(rc)) return rc;
|
if (R_FAILED(rc)) return rc;
|
||||||
|
|
||||||
rc = appletStorageWrite(&storage, 0, buf, size);
|
|
||||||
if (R_FAILED(rc)) {
|
|
||||||
appletStorageClose(&storage);
|
|
||||||
return rc;
|
|
||||||
}
|
|
||||||
|
|
||||||
return appletPushToGeneralChannel(&storage);
|
return appletPushToGeneralChannel(&storage);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Result libappletPushInData(AppletHolder *h, const void* buffer, size_t size) {
|
||||||
|
return _libappletPushInData(h, buffer, size);
|
||||||
|
}
|
||||||
|
|
||||||
Result libappletRequestHomeMenu(void) {
|
Result libappletRequestHomeMenu(void) {
|
||||||
u8 storagedata[0x10] = {0x53, 0x41, 0x4d, 0x53, 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00};//RequestHomeMenu
|
u8 storagedata[0x10] = {0x53, 0x41, 0x4d, 0x53, 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00};//RequestHomeMenu
|
||||||
return _libappletQlaunchRequest(storagedata, sizeof(storagedata));
|
return _libappletQlaunchRequest(storagedata, sizeof(storagedata));
|
||||||
|
Loading…
Reference in New Issue
Block a user