mirror of
https://github.com/wheremyfoodat/Panda3DS.git
synced 2025-06-07 19:41:38 +12:00
[FS] Add app data folder, add path safety checks
This commit is contained in:
parent
c16bf5c8aa
commit
b1f2be98fa
6 changed files with 77 additions and 12 deletions
|
@ -1,9 +1,16 @@
|
|||
#include "fs/archive_ext_save_data.hpp"
|
||||
#include <memory>
|
||||
|
||||
namespace fs = std::filesystem;
|
||||
|
||||
bool ExtSaveDataArchive::openFile(const FSPath& path) {
|
||||
if (path.type != PathType::Binary) {
|
||||
Helpers::panic("ExtSaveData accessed with a non-binary path in OpenFile. Type: %d", path.type);
|
||||
if (path.type == PathType::UTF16) {
|
||||
if (!isPathSafe<PathType::UTF16>(path))
|
||||
Helpers::panic("Unsafe path in ExtSaveData::OpenFile");
|
||||
|
||||
fs::path p = IOFile::getAppData() / "NAND";
|
||||
p += fs::path(path.utf16_string).make_preferred();
|
||||
return false;
|
||||
}
|
||||
|
||||
Helpers::panic("ExtSaveDataArchive::OpenFile: Failed");
|
||||
|
@ -15,11 +22,6 @@ ArchiveBase* ExtSaveDataArchive::openArchive(const FSPath& path) {
|
|||
Helpers::panic("ExtSaveData accessed with an invalid path in OpenArchive");
|
||||
}
|
||||
|
||||
u32 mediaType = *(u32*)&path.binary[0];
|
||||
u64 saveID = *(u64*)&path.binary[4]; // TODO: Get rid of UB here.
|
||||
|
||||
Helpers::panic("ExtSaveData: media type = %d\n", mediaType);
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
|
|
|
@ -18,7 +18,8 @@ namespace FSCommands {
|
|||
namespace Result {
|
||||
enum : u32 {
|
||||
Success = 0,
|
||||
Failure = 0xFFFFFFFF
|
||||
FileNotFound = 0xC8804464, // TODO: Verify this
|
||||
Failure = 0xFFFFFFFF,
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -166,9 +167,9 @@ void FSService::openFile(u32 messagePointer) {
|
|||
|
||||
std::optional<Handle> handle = openFileHandle(archive, filePath);
|
||||
if (!handle.has_value()) {
|
||||
Helpers::panic("OpenFile: Failed to open file with given path");
|
||||
}
|
||||
else {
|
||||
printf("OpenFile failed\n");
|
||||
mem.write32(messagePointer + 4, Result::FileNotFound);
|
||||
} else {
|
||||
mem.write32(messagePointer + 4, Result::Success);
|
||||
mem.write32(messagePointer + 8, 0x10); // "Move handle descriptor"
|
||||
mem.write32(messagePointer + 12, handle.value());
|
||||
|
|
|
@ -9,7 +9,7 @@ int main (int argc, char *argv[]) {
|
|||
|
||||
emu.initGraphicsContext();
|
||||
|
||||
auto romPath = std::filesystem::current_path() / (argc > 1 ? argv[1] : "Pokemon Mystery Dungeon - Gates to Infinity (USA).3ds");
|
||||
auto romPath = std::filesystem::current_path() / (argc > 1 ? argv[1] : "Pokemon Rumble Blast (USA).3ds");
|
||||
if (!emu.loadROM(romPath)) {
|
||||
// For some reason just .c_str() doesn't show the proper path
|
||||
Helpers::panic("Failed to load ROM file: %s", romPath.string().c_str());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue