Skip to content

Commit

Permalink
Merge pull request #18 from dolkensp/feature/aesdecrypt
Browse files Browse the repository at this point in the history
Minor bugfix for string lengths
  • Loading branch information
peter-dolkens authored Dec 3, 2019
2 parents ad70aea + 00bec16 commit e40a1ae
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
3 changes: 3 additions & 0 deletions src/unforge/Extensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,9 @@ public static String ReadCString(this BinaryReader binaryReader)

binaryReader.BaseStream.Seek(nul, SeekOrigin.Begin);

// Why is this necessary?
if (stringLength > chars.Length) stringLength = chars.Length;

// If there is actually a string to read
if (stringLength > 0)
{
Expand Down
7 changes: 4 additions & 3 deletions src/unp4k/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,16 @@ class Program
{
static void Main(string[] args)
{
var key = new Byte[] { 0x5E, 0x7A, 0x20, 0x02, 0x30, 0x2E, 0xEB, 0x1A, 0x3B, 0xB6, 0x17, 0xC3, 0x0F, 0xDE, 0x1E, 0x47 };

if (args.Length == 0) args = new[] { @"Data.p4k" };

if (args.Length == 1) args = new[] { args[0], "*.*" };

using (var pakFile = File.OpenRead(args[0]))
{
var pak = new ZipFile(pakFile) { Key = new Byte[] { 0x5E, 0x7A, 0x20, 0x02, 0x30, 0x2E, 0xEB, 0x1A, 0x3B, 0xB6, 0x17, 0xC3, 0x0F, 0xDE, 0x1E, 0x47 } };
var pak = new ZipFile(pakFile) { Key = key };
byte[] buf = new byte[4096];

foreach (ZipEntry entry in pak)
{
Expand All @@ -48,8 +51,6 @@ static void Main(string[] args)

using (Stream s = pak.GetInputStream(entry))
{
byte[] buf = new byte[4096];

using (FileStream fs = File.Create(entry.Name))
{
StreamUtils.Copy(s, fs, buf);
Expand Down

0 comments on commit e40a1ae

Please sign in to comment.