Skip to content

Commit

Permalink
Fixes in 0.6.1
Browse files Browse the repository at this point in the history
  • Loading branch information
XorTroll committed Aug 6, 2019
1 parent 122e859 commit ea42df9
Show file tree
Hide file tree
Showing 14 changed files with 666 additions and 586 deletions.
Binary file modified Goldleaf/Icon.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions Goldleaf/Include/Types.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,5 +108,6 @@ bool HasKeyFile();
bool IsAtmosphere();
bool IsReiNX();
bool IsSXOS();
u64 GetCurrentApplicationId();
u32 RandomFromRange(u32 Min, u32 Max);
void EnsureDirectories();
28 changes: 27 additions & 1 deletion Goldleaf/Include/usb/usb_Commands.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ namespace usb
static constexpr u32 InputMagic = 0x49434C47; // GLCI
static constexpr u32 OutputMagic = 0x4F434C47; // GLCO

static constexpr size_t BlockSize = 0x2000;
static constexpr size_t BlockSize = 0x1000;

struct BlockBase
{
Expand All @@ -51,6 +51,7 @@ namespace usb

InCommandBlock(CommandId CmdId);
void Write32(u32 Value);
void Write64(u64 Value);
void WriteString(std::string Value);
void WriteBuffer(void *Buf, size_t Size);
void Send();
Expand All @@ -66,6 +67,7 @@ namespace usb
void Cleanup();
bool IsValid();
u32 Read32();
u64 Read64();
std::string ReadString();
void ReadBuffer(void *Buf, size_t Size);
};
Expand Down Expand Up @@ -103,6 +105,30 @@ namespace usb
u32 &val;
};

class In64 : public CommandArgument
{
public:
In64(u64 Value);
void ProcessIn(InCommandBlock &block);
void ProcessAfterIn();
void ProcessOut(OutCommandBlock &block);
void ProcessAfterOut();
private:
u64 val;
};

class Out64 : public CommandArgument
{
public:
Out64(u64 &Value);
void ProcessIn(InCommandBlock &block);
void ProcessAfterIn();
void ProcessOut(OutCommandBlock &block);
void ProcessAfterOut();
private:
u64 &val;
};

class InString : public CommandArgument
{
public:
Expand Down
2 changes: 1 addition & 1 deletion Goldleaf/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ include $(DEVKITPRO)/libnx/switch_rules

APP_TITLE := Goldleaf
APP_AUTHOR := XorTroll
APP_VERSION := 0.6
APP_VERSION := 0.6.1
APP_TITLEID := 050032A5CF12E000

TARGET := Goldleaf
Expand Down
Binary file modified Goldleaf/RomFs/MenuBanner.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions Goldleaf/Source/Types.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,13 @@ bool IsSXOS()
return false;
}

u64 GetCurrentApplicationId()
{
u64 appid = 0;
svcGetInfo(&appid, InfoType_TitleId, CUR_PROCESS_HANDLE, 0);
return appid;
}

u32 RandomFromRange(u32 Min, u32 Max)
{
u32 diff = Max - Min;
Expand Down
26 changes: 13 additions & 13 deletions Goldleaf/Source/fs/fs_Explorer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -696,8 +696,8 @@ namespace fs
bool ex = false;
std::string path = this->MakeFull(Path);
u32 type = 0;
u32 tmpfsz = 0;
usb::ProcessCommand<usb::CommandId::StatPath>(usb::InString(path), usb::Out32(type), usb::Out32(tmpfsz));
u64 tmpfsz = 0;
usb::ProcessCommand<usb::CommandId::StatPath>(usb::InString(path), usb::Out32(type), usb::Out64(tmpfsz));
ex = ((type == 1) || (type == 2));
return ex;
}
Expand All @@ -707,8 +707,8 @@ namespace fs
bool ex = false;
std::string path = this->MakeFull(Path);
u32 type = 0;
u32 tmpfsz = 0;
usb::ProcessCommand<usb::CommandId::StatPath>(usb::InString(path), usb::Out32(type), usb::Out32(tmpfsz));
u64 tmpfsz = 0;
usb::ProcessCommand<usb::CommandId::StatPath>(usb::InString(path), usb::Out32(type), usb::Out64(tmpfsz));
ex = (type == 1);
return ex;
}
Expand All @@ -718,8 +718,8 @@ namespace fs
bool ex = false;
std::string path = this->MakeFull(Path);
u32 type = 0;
u32 tmpfsz = 0;
usb::ProcessCommand<usb::CommandId::StatPath>(usb::InString(path), usb::Out32(type), usb::Out32(tmpfsz));
u64 tmpfsz = 0;
usb::ProcessCommand<usb::CommandId::StatPath>(usb::InString(path), usb::Out32(type), usb::Out64(tmpfsz));
ex = (type == 2);
return ex;
}
Expand Down Expand Up @@ -762,26 +762,26 @@ namespace fs

u64 USBPCDriveExplorer::ReadFileBlock(std::string Path, u64 Offset, u64 Size, u8 *Out)
{
u32 rsize = 0;
u64 rsize = 0;
std::string path = this->MakeFull(Path);
usb::ProcessCommand<usb::CommandId::ReadFile>(usb::InString(path), usb::In32((u32)Offset), usb::In32((u32)Size), usb::Out32(rsize), usb::OutBuffer(Out, Size));
return (u64)rsize;
usb::ProcessCommand<usb::CommandId::ReadFile>(usb::InString(path), usb::In64(Offset), usb::In64(Size), usb::Out64(rsize), usb::OutBuffer(Out, Size));
return rsize;
}

u64 USBPCDriveExplorer::WriteFileBlock(std::string Path, u8 *Data, u64 Size)
{
std::string path = this->MakeFull(Path);
usb::ProcessCommand<usb::CommandId::WriteFile>(usb::InString(path), usb::In32((u32)Size), usb::InBuffer(Data, Size));
usb::ProcessCommand<usb::CommandId::WriteFile>(usb::InString(path), usb::In64(Size), usb::InBuffer(Data, Size));
return Size;
}

u64 USBPCDriveExplorer::GetFileSize(std::string Path)
{
u32 sz = 0;
u64 sz = 0;
std::string path = this->MakeFull(Path);
u32 tmptype = 0;
usb::ProcessCommand<usb::CommandId::StatPath>(usb::InString(path), usb::Out32(tmptype), usb::Out32(sz));
return (u64)sz;
usb::ProcessCommand<usb::CommandId::StatPath>(usb::InString(path), usb::Out32(tmptype), usb::Out64(sz));
return sz;
}

u64 USBPCDriveExplorer::GetTotalSpace()
Expand Down
20 changes: 6 additions & 14 deletions Goldleaf/Source/nsp/nsp_Installer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -264,21 +264,11 @@ namespace nsp
ncm::CreatePlaceHolder(&cst, &curid, &curid, ncasize);
u64 noff = 0;
u64 szrem = ncasize;
u64 tmpwritten = 0;
u64 bsec = 0;
auto t1 = std::chrono::steady_clock::now();
while(szrem)
{
auto t2 = std::chrono::steady_clock::now();
u64 diff = std::chrono::duration_cast<std::chrono::seconds>(t2 - t1).count();
if(diff >= 1)
{
t1 = t2;
bsec = tmpwritten;
tmpwritten = 0;
}
u64 rbytes = 0;
u64 rsize = std::min(szrem, reads);
auto t1 = std::chrono::steady_clock::now();
switch(rnca.Type)
{
case ncm::ContentType::Meta:
Expand All @@ -287,13 +277,15 @@ namespace nsp
break;
default:
rbytes = nspentry.ReadFromFile(idxncaname, noff, rsize, rdata);
break;
break;
}
ncm::WritePlaceHolder(&cst, &curid, noff, rdata, rbytes);
noff += rbytes;
tmpwritten += (double)rbytes;
szrem -= rbytes;
OnContentWrite(rnca, i, ncas.size(), (double)noff, (double)ncasize, bsec);
auto t2 = std::chrono::steady_clock::now();
u64 diff = std::chrono::duration_cast<std::chrono::milliseconds>(t2 - t1).count();
double bsec = (1000.0f / (double)diff) * rbytes; // By elapsed time and written bytes, compute how much data has been written in 1sec.
OnContentWrite(rnca, i, ncas.size(), (double)noff, (double)ncasize, (u64)bsec);
}
ncmContentStorageRegister(&cst, &curid, &curid);
ncm::DeletePlaceHolder(&cst, &curid);
Expand Down
4 changes: 2 additions & 2 deletions Goldleaf/Source/ui/ui_MainMenuLayout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,9 @@ namespace ui

void MainMenuLayout::webMenuItem_Click()
{
if(GetLaunchMode() != LaunchMode::Application)
if(GetCurrentApplicationId() != GOLDLEAF_APPID)
{
mainapp->CreateShowDialog(set::GetDictionaryEntry(5), set::GetDictionaryEntry(37), { set::GetDictionaryEntry(234) }, true);
mainapp->CreateShowDialog(set::GetDictionaryEntry(5), set::GetDictionaryEntry(292), { set::GetDictionaryEntry(234) }, true);
return;
}
std::string out = AskForText(set::GetDictionaryEntry(38), "https://");
Expand Down
Loading

0 comments on commit ea42df9

Please sign in to comment.