Skip to content

Commit

Permalink
Restore heap trick, hello 0.7!
Browse files Browse the repository at this point in the history
  • Loading branch information
XorTroll committed Sep 4, 2019
1 parent 6e7b54d commit 6f72133
Show file tree
Hide file tree
Showing 13 changed files with 71 additions and 46 deletions.
14 changes: 8 additions & 6 deletions Changelog.todo.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Changelog (dummy, to be filled, later used in release time)
# Changelog

- Remote PC

Expand All @@ -8,7 +8,7 @@

- Added option to select a file directly on the remote PC tool (basically same system as on <=0.5 Goldleaf versions, for those who like the classic system!)

- Goldtree's messages were slightly changed to be more accurate.
- Goldtree's messages were slightly changed to be more accurate. Now it shows its version to avoid confusion between different executables.

- NSP installs

Expand Down Expand Up @@ -38,9 +38,7 @@

- Copying files from PC to SD which are over 4GB is now correctly handled, creating a concatenation file (see above) to correctly handle it.

- Goldleaf takes advantage now from hbloader v2.2.0's heap reservation, which reserved 128MB of heap for other applets. Goldleaf probably won't work without this trick, so its support is uncertain with old Atmosphere or other CFWs (unless it's launched overriding an application or from the forwarder)

- The forwarder was updated with hbloader's latest version.
- The forwarder was updated with hbloader's latest version, thus now the forwarder's version is 0.2.

- User / accounts

Expand Down Expand Up @@ -72,4 +70,8 @@

- Goldleaf now has been compiled with an experimental Plutonium branch which uses smart pointers instead of raw pointers aiming no memory leaks!

- Now, Goldleaf also supports dutch language! Thanks a lot to **Mega** for helping with the translation!
- Now, Goldleaf also supports dutch language! Thanks a lot to **Mega** for helping with the translation!

## Known bugs

- Browsing (fast?) over certain (empty?) folders can sometimes have weird behavior, resulting into crashes.
4 changes: 2 additions & 2 deletions Goldleaf/Include/fs/fs_Common.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ namespace fs
void CreateConcatenationFile(pu::String Path);
void CreateDirectory(pu::String Path);
void CopyFile(pu::String Path, pu::String NewPath);
void CopyFileProgress(pu::String Path, pu::String NewPath, std::function<void(u8 Percentage)> Callback);
void CopyFileProgress(pu::String Path, pu::String NewPath, std::function<void(double Done, double Total)> Callback);
void CopyDirectory(pu::String Dir, pu::String NewDir);
void CopyDirectoryProgress(pu::String Dir, pu::String NewDir, std::function<void(u8 Percentage)> Callback);
void CopyDirectoryProgress(pu::String Dir, pu::String NewDir, std::function<void(double Done, double Total)> Callback);
void DeleteFile(pu::String Path);
void DeleteDirectory(pu::String Path);
bool IsFileBinary(pu::String Path);
Expand Down
4 changes: 2 additions & 2 deletions Goldleaf/Include/fs/fs_Explorer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ namespace fs
pu::String MakeFull(pu::String Path);
bool IsFullPath(pu::String Path);
void CopyFile(pu::String Path, pu::String NewPath);
void CopyFileProgress(pu::String Path, pu::String NewPath, std::function<void(u8 Percentage)> Callback);
void CopyFileProgress(pu::String Path, pu::String NewPath, std::function<void(double Done, double Total)> Callback);
void CopyDirectory(pu::String Dir, pu::String NewDir);
void CopyDirectoryProgress(pu::String Dir, pu::String NewDir, std::function<void(u8 Percentage)> Callback);
void CopyDirectoryProgress(pu::String Dir, pu::String NewDir, std::function<void(double Done, double Total)> Callback);
bool IsFileBinary(pu::String Path);
std::vector<u8> ReadFile(pu::String Path);
std::vector<pu::String> ReadFileLines(pu::String Path, u32 LineOffset, u32 LineCount);
Expand Down
7 changes: 7 additions & 0 deletions Goldleaf/Source/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,14 @@
#include <cstdlib>
#include <ctime>

extern char *fake_heap_end;
void *new_heap_addr = NULL;

static constexpr u64 HeapSize = 0x10000000;

void Initialize()
{
if((GetLaunchMode() == LaunchMode::Applet) && R_SUCCEEDED(svcSetHeapSize(&new_heap_addr, HeapSize))) fake_heap_end = (char*)new_heap_addr + HeapSize;
// TODO: Better way to handle this than exiting? User won't know what happened

if(R_FAILED(ncm::Initialize())) exit(1);
Expand Down Expand Up @@ -55,6 +61,7 @@ void Finalize()
ncmExit();
nifmExit();
pdmqryExit();
if(GetLaunchMode() == LaunchMode::Applet) svcSetHeapSize(&new_heap_addr, ((u8*)envGetHeapOverrideAddr() + envGetHeapOverrideSize()) - (u8*)new_heap_addr);
}

namespace ui
Expand Down
4 changes: 2 additions & 2 deletions Goldleaf/Source/fs/fs_Common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ namespace fs
gexp->CopyFile(Path, NewPath);
}

void CopyFileProgress(pu::String Path, pu::String NewPath, std::function<void(u8 Percentage)> Callback)
void CopyFileProgress(pu::String Path, pu::String NewPath, std::function<void(double Done, double Total)> Callback)
{
Explorer *gexp = GetExplorerForPath(Path);
Explorer *ogexp = GetExplorerForPath(NewPath);
Expand All @@ -82,7 +82,7 @@ namespace fs
gexp->CopyDirectory(Dir, NewDir);
}

void CopyDirectoryProgress(pu::String Dir, pu::String NewDir, std::function<void(u8 Percentage)> Callback)
void CopyDirectoryProgress(pu::String Dir, pu::String NewDir, std::function<void(double Done, double Total)> Callback)
{
Explorer *gexp = GetExplorerForPath(Dir);
gexp->CopyDirectoryProgress(Dir, NewDir, Callback);
Expand Down
7 changes: 3 additions & 4 deletions Goldleaf/Source/fs/fs_Explorer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ namespace fs
}
}

void Explorer::CopyFileProgress(pu::String Path, pu::String NewPath, std::function<void(u8 Percentage)> Callback)
void Explorer::CopyFileProgress(pu::String Path, pu::String NewPath, std::function<void(double Done, double Total)> Callback)
{
pu::String path = this->MakeFull(Path);
auto ex = GetExplorerForMountName(GetPathRoot(NewPath));
Expand All @@ -144,8 +144,7 @@ namespace fs
szrem -= rbytes;
off += rbytes;
ex->WriteFileBlock(NewPath, data, rbytes);
u8 perc = (u8)((double)((double)off / (double)fsize) * 100.0);
Callback(perc);
Callback((double)off, (double)fsize);
}
}

Expand All @@ -170,7 +169,7 @@ namespace fs
}
}

void Explorer::CopyDirectoryProgress(pu::String Dir, pu::String NewDir, std::function<void(u8 Percentage)> Callback)
void Explorer::CopyDirectoryProgress(pu::String Dir, pu::String NewDir, std::function<void(double Done, double Total)> Callback)
{
pu::String dir = this->MakeFull(Dir);
pu::String ndir = this->MakeFull(NewDir);
Expand Down
12 changes: 7 additions & 5 deletions Goldleaf/Source/ui/ui_AccountLayout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,12 +133,14 @@ namespace ui
auto linkedinfo = acc::GetUserLinkedInfo();
pu::String str = set::GetDictionaryEntry(328) + " " + hos::FormatHex(linkedinfo.AccountId);
str += "\n" + set::GetDictionaryEntry(329) + " " + hos::FormatHex(linkedinfo.NintendoAccountId);
auto sopt = mainapp->CreateShowDialog(set::GetDictionaryEntry(330), str, { set::GetDictionaryEntry(331), set::GetDictionaryEntry(234) }, true);
auto sopt = mainapp->CreateShowDialog(set::GetDictionaryEntry(330), str, { set::GetDictionaryEntry(331), set::GetDictionaryEntry(18) }, true);
if(sopt != 0) return;
sopt = mainapp->CreateShowDialog(set::GetDictionaryEntry(332), set::GetDictionaryEntry(333), { set::GetDictionaryEntry(111), set::GetDictionaryEntry(18) }, true);
if(sopt < 0) return;
auto res = acc::UnlinkLocally();
if(res == 0) mainapp->ShowNotification(set::GetDictionaryEntry(334));
else HandleResult(res, set::GetDictionaryEntry(335));
if(sopt == 0)
{
auto res = acc::UnlinkLocally();
if(res == 0) mainapp->ShowNotification(set::GetDictionaryEntry(334));
else HandleResult(res, set::GetDictionaryEntry(335));
}
}
}
11 changes: 7 additions & 4 deletions Goldleaf/Source/ui/ui_CopyLayout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,10 @@ namespace ui
{
if(Directory)
{
fs::CopyDirectoryProgress(Path, NewPath, [&](u8 p)
fs::CopyDirectoryProgress(Path, NewPath, [&](double done, double total)
{
this->copyBar->SetProgress(p);
this->copyBar->SetMaxValue(total);
this->copyBar->SetProgress(done);
mainapp->CallForRender();
});
mainapp->ShowNotification(set::GetDictionaryEntry(141));
Expand All @@ -36,9 +37,11 @@ namespace ui
int sopt = mainapp->CreateShowDialog(set::GetDictionaryEntry(153), set::GetDictionaryEntry(143), { set::GetDictionaryEntry(239), set::GetDictionaryEntry(18) }, true);
if(sopt < 0) return;
}
fs::CopyFileProgress(Path, NewPath, [&](u8 p)
fs::DeleteFile(NewPath);
fs::CopyFileProgress(Path, NewPath, [&](double done, double total)
{
this->copyBar->SetProgress(p);
this->copyBar->SetMaxValue(total);
this->copyBar->SetProgress(done);
mainapp->CallForRender();
});
mainapp->ShowNotification(set::GetDictionaryEntry(240));
Expand Down
3 changes: 2 additions & 1 deletion Goldleaf/Source/ui/ui_MainApplication.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -671,8 +671,9 @@ namespace ui

void MainApplication::OnInput(u64 Down, u64 Up, u64 Held)
{
if((Down & KEY_MINUS) && (GetLaunchMode() == LaunchMode::Applet))
if((Down & KEY_MINUS) && (GetCurrentApplicationId() != GOLDLEAF_APPID))
{
// Don't allow closing if Goldleaf forwarder!
this->CloseWithFadeOut();
}
else if((Down & KEY_ZL) || (Down & KEY_ZR)) ShowPowerTasksDialog(set::GetDictionaryEntry(229), set::GetDictionaryEntry(230));
Expand Down
6 changes: 5 additions & 1 deletion Goldleaf/Source/ui/ui_MainMenuLayout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,11 @@ namespace ui
int sopt = mainapp->CreateShowDialog(set::GetDictionaryEntry(348), set::GetDictionaryEntry(349), {set::GetDictionaryEntry(111), set::GetDictionaryEntry(18)}, true);
if(sopt != 0) return;
if(acc::SelectUser()) mainapp->ShowNotification(set::GetDictionaryEntry(324));
else mainapp->ShowNotification(set::GetDictionaryEntry(350));
else
{
mainapp->ShowNotification(set::GetDictionaryEntry(350));
return;
}
}
mainapp->LoadMenuData(set::GetDictionaryEntry(41), "Accounts", set::GetDictionaryEntry(42));
mainapp->GetAccountLayout()->Load();
Expand Down
30 changes: 18 additions & 12 deletions Goldleaf/Source/ui/ui_TitleDumperLayout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -209,9 +209,10 @@ namespace ui
pu::String txmeta = outdir + "/" + hos::ContentIdAsString(meta) + ".cnmt.nca";
fs::CreateConcatenationFile(txmeta);
this->ncaBar->SetVisible(true);
fs::CopyFileProgress(xmeta, txmeta, [&](u8 p)
fs::CopyFileProgress(xmeta, txmeta, [&](double done, double total)
{
this->ncaBar->SetProgress(p);
this->ncaBar->SetMaxValue(total);
this->ncaBar->SetProgress(done);
mainapp->CallForRender();
});
this->ncaBar->SetVisible(false);
Expand All @@ -222,9 +223,10 @@ namespace ui
pu::String txprogram = outdir + "/" + hos::ContentIdAsString(program) + ".nca";
fs::CreateConcatenationFile(txprogram);
this->ncaBar->SetVisible(true);
fs::CopyFileProgress(xprogram, txprogram, [&](u8 p)
fs::CopyFileProgress(xprogram, txprogram, [&](double done, double total)
{
this->ncaBar->SetProgress(p);
this->ncaBar->SetMaxValue(total);
this->ncaBar->SetProgress(done);
mainapp->CallForRender();
});
this->ncaBar->SetVisible(false);
Expand All @@ -236,9 +238,10 @@ namespace ui
pu::String txcontrol = outdir + "/" + hos::ContentIdAsString(control) + ".nca";
fs::CreateConcatenationFile(txcontrol);
this->ncaBar->SetVisible(true);
fs::CopyFileProgress(xcontrol, txcontrol, [&](u8 p)
fs::CopyFileProgress(xcontrol, txcontrol, [&](double done, double total)
{
this->ncaBar->SetProgress(p);
this->ncaBar->SetMaxValue(total);
this->ncaBar->SetProgress(done);
mainapp->CallForRender();
});
this->ncaBar->SetVisible(false);
Expand All @@ -250,9 +253,10 @@ namespace ui
pu::String txlinfo = outdir + "/" + hos::ContentIdAsString(linfo) + ".nca";
fs::CreateConcatenationFile(txlinfo);
this->ncaBar->SetVisible(true);
fs::CopyFileProgress(xlinfo, txlinfo, [&](u8 p)
fs::CopyFileProgress(xlinfo, txlinfo, [&](double done, double total)
{
this->ncaBar->SetProgress(p);
this->ncaBar->SetMaxValue(total);
this->ncaBar->SetProgress(done);
mainapp->CallForRender();
});
this->ncaBar->SetVisible(false);
Expand All @@ -264,9 +268,10 @@ namespace ui
pu::String txhoff = outdir + "/" + hos::ContentIdAsString(hoff) + ".nca";
fs::CreateConcatenationFile(txhoff);
this->ncaBar->SetVisible(true);
fs::CopyFileProgress(xhoff, txhoff, [&](u8 p)
fs::CopyFileProgress(xhoff, txhoff, [&](double done, double total)
{
this->ncaBar->SetProgress(p);
this->ncaBar->SetMaxValue(total);
this->ncaBar->SetProgress(done);
mainapp->CallForRender();
});
this->ncaBar->SetVisible(false);
Expand All @@ -278,9 +283,10 @@ namespace ui
pu::String txdata = outdir + "/" + hos::ContentIdAsString(data) + ".nca";
fs::CreateConcatenationFile(txdata);
this->ncaBar->SetVisible(true);
fs::CopyFileProgress(xdata, txdata, [&](u8 p)
fs::CopyFileProgress(xdata, txdata, [&](double done, double total)
{
this->ncaBar->SetProgress(p);
this->ncaBar->SetMaxValue(total);
this->ncaBar->SetProgress(done);
mainapp->CallForRender();
});
this->ncaBar->SetVisible(false);
Expand Down
4 changes: 2 additions & 2 deletions Goldtree/Goldtree/Goldtree.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
<Description>Goldleaf's USB client for PC</Description>
<Authors>XorTroll</Authors>
<Copyright>Copyright 2018 - 2019 Goldleaf project, by XorTroll</Copyright>
<AssemblyVersion>0.6.1.0</AssemblyVersion>
<FileVersion>0.6.1.0</FileVersion>
<AssemblyVersion>0.7.0.0</AssemblyVersion>
<FileVersion>0.7.0.0</FileVersion>
<NeutralLanguage>en</NeutralLanguage>
<AutoGenerateBindingRedirects>false</AutoGenerateBindingRedirects>
<Version>0.7</Version>
Expand Down
11 changes: 6 additions & 5 deletions Goldtree/Goldtree/Program.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System;
using System.IO;
using System.Text;
using System.Diagnostics;
using System.Reflection;
using libusbK;

namespace gtree
Expand Down Expand Up @@ -65,7 +65,6 @@ public void LLogL(string Text)

public class Program
{
public static readonly string Name = "Goldtree";
public static readonly string Description = "Goldleaf's USB client for PC";

public static readonly LogMode Log = new LogMode("Log", ConsoleColor.Cyan);
Expand All @@ -77,11 +76,13 @@ public class Program

public static void Initialize()
{
Console.Title = Name + " - " + Description;
var name = Assembly.GetExecutingAssembly().GetName().Name;
var ver = FileVersionInfo.GetVersionInfo(Assembly.GetExecutingAssembly().Location).FileVersion;
Console.Title = name + " v" + ver + " - " + Description;
Console.WriteLine();
Console.Write(" ");
Console.ForegroundColor = ConsoleColor.DarkYellow;
Console.Write(Name);
Console.Write(name + " v" + ver);
Console.ForegroundColor = ConsoleColor.Gray;
Console.Write(" - ");
Console.ForegroundColor = ConsoleColor.White;
Expand Down

0 comments on commit 6f72133

Please sign in to comment.