Nani the fuck

This commit is contained in:
2017-08-09 08:39:33 -04:00
parent d337623bd0
commit 5fb9d86b62
9 changed files with 81 additions and 35 deletions

View File

@@ -1,9 +1,13 @@
#include <3ds.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "themes.h"
#include "unicode.h"
#include "fs.h"
Result single_install(theme* theme)
Result single_install(theme theme_to_install)
{
char *body;
char *music;
@@ -13,46 +17,49 @@ Result single_install(theme* theme)
u32 music_size;
u32 savedata_size;
savedata_size = file_to_buf(fsMakePath(PATH_ASCII, "/SaveData.dat"), ArchiveHomeExt, savedata_buf)
savedata_size = file_to_buf(fsMakePath(PATH_ASCII, "/SaveData.dat"), ArchiveHomeExt, savedata_buf);
savedata_buf[0x141b] = 0;
memset(&savedata_buf[0x13b8], 0, 8);
savedata_buf[0x13bd] = 3;
savedata_buf[0x13b8] = 0xff;
buf_to_file(savedata_size, "/SaveData.dat", ArchiveHomeExt, savedata_buf);
Result res = buf_to_file(savedata_size, "/SaveData.dat", ArchiveHomeExt, savedata_buf);
printf("%li\n", res);
free(savedata_buf);
// Open body cache file. Test if theme is zipped
if (theme->is_zip)
if (theme_to_install.is_zip)
{
body_size = zip_file_to_buf("body_lz.bin", theme->path, body);
body_size = zip_file_to_buf("body_LZ.bin", theme_to_install.path, body);
} else {
u16 path[0x106];
memcpy(path, theme->path, 0x106);
u16 path[0x106] = {0};
memcpy(path, theme_to_install.path, 0x106 * sizeof(u16));
struacat(path, "/body_lz.bin");
body_size = file_to_buf(path, body);
body_size = file_to_buf(fsMakePath(PATH_UTF16, path), ArchiveSD, body);
}
if (body_size == 0)
{
free(body);
return MAKERESULT(RL_PERMANENT, RL_CANCELED, RL_APPLICATION, RD_NOT_FOUND);
puts("bodyrip");
return MAKERESULT(RL_PERMANENT, RS_CANCELED, RM_APPLICATION, RD_NOT_FOUND);
}
if (check_file_exists("/BodyCache.bin", ArchiveThemeExt)) FSUSER_DeleteFile(ArchiveThemeExt, fsMakePath("/BodyCache.bin"));
if (check_file_exists("/BodyCache.bin", ArchiveThemeExt)) FSUSER_DeleteFile(ArchiveThemeExt, fsMakePath(PATH_ASCII, "/BodyCache.bin"));
FSUSER_CreateFile(ArchiveThemeExt, fsMakePath(PATH_ASCII, "/BodyCache.bin"), 0, body_size);
u32 size = buf_to_file(body_size, "/BodyCache.bin", ArchiveThemeExt, body); // Write body data to file
free(body);
if (size == 0) return MAKERESULT(RL_PERMANENT, RL_CANCELED, RL_APPLICATION, RD_NOT_FOUND);
if (size == 0) return MAKERESULT(RL_PERMANENT, RS_CANCELED, RM_APPLICATION, RD_NOT_FOUND);
if (theme->is_zip) // Same as above but this time with bgm
if (theme_to_install.is_zip) // Same as above but this time with bgm
{
music_size = zip_file_to_buf("bgm.bcstm", theme->path, music);
music_size = zip_file_to_buf("bgm.bcstm", theme_to_install.path, music);
} else {
u16 path[0x106];
memcpy(path, theme->path, 0x106);
u16 path[0x106] = {0};
memcpy(path, theme_to_install.path, 0x106 * sizeof(16));
struacat(path, "/bgm.bcstm");
music_size = file_to_buf(path, music);
music_size = file_to_buf(fsMakePath(PATH_UTF16, path), ArchiveSD, music);
}
if (music_size == 0)
@@ -61,15 +68,17 @@ Result single_install(theme* theme)
music = calloc(1, 3371008);
} else if (size > 3371008) {
free(music);
return MAKERESULT(RL_PERMANENT, RL_CANCELED, RL_APPLICATION, RD_TOO_LARGE);
puts("musicrip");
return MAKERESULT(RL_PERMANENT, RS_CANCELED, RM_APPLICATION, RD_TOO_LARGE);
}
if (check_file_exists("/BgmCache.bin", ArchiveThemeExt)) FSUSER_DeleteFile(ArchiveThemeExt, fsMakePath("/BgmCache.bin"));
if (check_file_exists("/BgmCache.bin", ArchiveThemeExt)) FSUSER_DeleteFile(ArchiveThemeExt, fsMakePath(PATH_ASCII, "/BgmCache.bin"));
FSUSER_CreateFile(ArchiveThemeExt, fsMakePath(PATH_ASCII, "/BgmCache.bin"), 0, music_size);
size = buf_to_file(music_size, "/BgmCache.bin", ArchiveThemeExt, music);
free(music);
if (size == 0) return MAKERESULT(RL_PERMANENT, RL_CANCELED, RL_APPLICATION, RD_NOT_FOUND);
if (size == 0) return MAKERESULT(RL_PERMANENT, RS_CANCELED, RM_APPLICATION, RD_NOT_FOUND);
file_to_buf(fsMakePath(PATH_ASCII, "/ThemeManage.bin"), ArchiveThemeExt, thememanage_buf);
thememanage_buf[0x00] = 1;