Skip to content

Commit

Permalink
validation of the -p arguments has been fixed. fixes #15
Browse files Browse the repository at this point in the history
  • Loading branch information
DmitriySalnikov committed Mar 13, 2024
1 parent 6ed271f commit 37d4e74
Show file tree
Hide file tree
Showing 9 changed files with 48 additions and 30 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/dotnet-desktop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:

# Add MSBuild to the PATH: https://github.com/microsoft/setup-msbuild
- name: Setup MSBuild.exe
uses: microsoft/setup-msbuild@v1
uses: microsoft/setup-msbuild@v2

# Add nuget to cache
- name: Setup Cache
Expand Down
8 changes: 2 additions & 6 deletions Bruteforcer/UI/PCKBruteforcer.UI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,8 @@
<Authors>Dmitriy Salnikov</Authors>
<Description>A small utility to find the encryption key for PCK.</Description>
<Copyright>Copyright © 2024</Copyright>
<PackageProjectUrl>
https://github.com/DmitriySalnikov/GodotPCKExplorer/tree/master/Bruteforcer
</PackageProjectUrl>
<RepositoryUrl>
https://github.com/DmitriySalnikov/GodotPCKExplorer/tree/master/Bruteforcer
</RepositoryUrl>
<PackageProjectUrl>https://github.com/DmitriySalnikov/GodotPCKExplorer/tree/master/Bruteforcer</PackageProjectUrl>
<RepositoryUrl>https://github.com/DmitriySalnikov/GodotPCKExplorer/tree/master/Bruteforcer</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<NeutralLanguage>en</NeutralLanguage>
<Version>1.0.0</Version>
Expand Down
19 changes: 16 additions & 3 deletions Core/Global.Shared/Logger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public Logger(string saveFile)

try
{
string dir_name = Path.GetDirectoryName(this.saveFile) ?? "";
string dir_name = Path.GetDirectoryName(this.saveFile) ?? string.Empty;
if (!Directory.Exists(dir_name))
Directory.CreateDirectory(dir_name);

Expand Down Expand Up @@ -104,12 +104,20 @@ public void Dispose()
logWriter = null;
}

public void Flush()
{
FastConsole.Flush();
flushFastConsole.Cancel();
timeFlushConsole = DateTime.UtcNow;
logWriter?.Flush();
}

public void Write(string txt)
{
var isFirst = true;
txt = string.Join(Environment.NewLine,
txt.Split('\n').
Select((t) =>
txt.Split(["\r\n", "\n", "\r"], StringSplitOptions.None)
.Select((t) =>
{
var res = $"[{DateTime.Now.ToString(CultureInfo.InvariantCulture)}]{(isFirst ? "\t" : "-\t")}{t}";
isFirst = false;
Expand Down Expand Up @@ -141,6 +149,11 @@ public void Write(string txt)
}
}

public void WriteError(string txt)
{
Write("❗ Error: " + txt);
}

public void Write(Exception ex)
{
Write($"{ex.GetType().Name}:\n{ex.Message}\nStackTrace:\n{ex.StackTrace}");
Expand Down
2 changes: 1 addition & 1 deletion Core/GodotPCKExplorer/GodotPCKExplorer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
mbedTLS\**\*.pdb;
**\.gitignore
</DefaultItemExcludes>
<Version>1.4.0</Version>
<Version>1.4.1</Version>
<AssemblyVersion>$(Version)</AssemblyVersion>
</PropertyGroup>

Expand Down
9 changes: 9 additions & 0 deletions Core/GodotPCKExplorer/PCKPacker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,15 @@ public static bool PackFiles(string outPck, bool embed, IEnumerable<PCKPackerFil
return false;
}

if (godotVersion.PackVersion == PCKUtils.PCK_VERSION_GODOT_3)
{
if (EncryptionKey != null || EncryptIndex || EncryptFiles)
{
PCKActions.progress?.ShowMessage("Encryption is not supported for PCK files for Godot 3 (pack version 1).", "Error", MessageType.Error);
return false;
}
}

if (embed)
{
if (!File.Exists(outPck))
Expand Down
2 changes: 1 addition & 1 deletion Core/GodotPCKExplorer/PCKReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ public bool OpenFile(BinaryReader fileReader, bool show_NotPCKError = true, bool
PCK_Flags = 0;
PCK_FileBase = 0;

if (PCK_VersionPack == 2)
if (PCK_VersionPack == PCKUtils.PCK_VERSION_GODOT_4)
{
PCK_Flags = fileReader.ReadInt32(); // 20-23
PCK_FileBaseAddressOffset = fileReader.BaseStream.Position;
Expand Down
25 changes: 14 additions & 11 deletions Explorer/Console/ConsoleCommands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -273,18 +273,21 @@ static void PackPCKCommand(string[] args, bool embed)
var encIndex = false;
var encFiles = false;

switch (encType)
if (encKey != null)
{
case "both":
encIndex = true;
encFiles = true;
break;
case "index":
encIndex = true;
break;
case "files":
encFiles = true;
break;
switch (encType)
{
case "both":
encIndex = true;
encFiles = true;
break;
case "index":
encIndex = true;
break;
case "files":
encFiles = true;
break;
}
}

var res = PCKActions.Pack(dirPath, filePath, strVer, prefix, 16, embed, encKey, encIndex, encFiles);
Expand Down
6 changes: 2 additions & 4 deletions Explorer/UI/GodotPCKExplorer.UI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,14 @@
<Product>GodotPCKExplorer</Product>
<PackageId>GodotPCKExplorer.UI</PackageId>
<Authors>Dmitriy Salnikov</Authors>
<Description>
C# implementation of the Godot's PCK file format with the ability to export files from it and create new PCK packs, as well as giving several more useful features.
</Description>
<Description>C# implementation of the Godot's PCK file format with the ability to export files from it and create new PCK packs,&#10;as well as giving several more useful features.</Description>
<Copyright>Copyright © 2024</Copyright>
<PackageProjectUrl>https://github.com/DmitriySalnikov/GodotPCKExplorer</PackageProjectUrl>
<PackageIcon>pckAbout.png</PackageIcon>
<RepositoryUrl>https://github.com/DmitriySalnikov/GodotPCKExplorer</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<NeutralLanguage>en</NeutralLanguage>
<Version>1.4.0</Version>
<Version>1.4.1</Version>

<NoWarn>$(NoWarn);IDE1006</NoWarn>

Expand Down
5 changes: 2 additions & 3 deletions Explorer/UI/VersionCheckGitHub.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using System.Text.Json;
using System.Text.Json.Serialization;
using System.Diagnostics;
using System.Diagnostics;
using System.Reflection;
using System.Text.Json;

internal sealed class VersionCheckerGitHub : IDisposable
{
Expand Down

0 comments on commit 37d4e74

Please sign in to comment.