Skip to content

Commit

Permalink
Cx encryption bytecode generation fix.
Browse files Browse the repository at this point in the history
  • Loading branch information
morkt committed Sep 8, 2014
1 parent 12d8236 commit a0162b4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
8 changes: 4 additions & 4 deletions ArcFormats/ArcXP3.cs
Original file line number Diff line number Diff line change
Expand Up @@ -232,10 +232,6 @@ public override ArcFile TryOpen (ArcView file)
if (!string.IsNullOrEmpty (entry.Name) && entry.Segments.Any())
{
dir.Add (entry);
// Trace.WriteLine (string.Format ("{0,-16} {3:X8} {1,11} {2,12}", entry.Name,
// entry.IsEncrypted ? "[encrypted]" : "",
// entry.Segments.First().IsCompressed ? "[compressed]" : "",
// entry.Hash));
}
NextEntry:
header.BaseStream.Position = dir_offset;
Expand All @@ -249,6 +245,10 @@ public override Stream OpenEntry (ArcFile arc, Entry entry)
var xp3_entry = entry as Xp3Entry;
if (null == xp3_entry)
return arc.File.CreateStream (entry.Offset, entry.Size);
// Trace.WriteLine (string.Format ("{0,-16} {3:X8} {1,11} {2,12}", xp3_entry.Name,
// xp3_entry.IsEncrypted ? "[encrypted]" : "",
// xp3_entry.Segments.First().IsCompressed ? "[compressed]" : "",
// xp3_entry.Hash));
if (1 == xp3_entry.Segments.Count && !xp3_entry.IsEncrypted)
{
var segment = xp3_entry.Segments.First();
Expand Down
7 changes: 4 additions & 3 deletions ArcFormats/KiriKiriCx.cs
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ bool EmitBody (CxProgram program, int stage)
else if (!EmitBody2 (program, stage - 1))
return false;

if (!program.Emit (CxByteCode.MOV_EBX_EAX, 2))
if (!program.Emit (CxByteCode.MOV_EBX_EAX, 2)) // 0x89 0xc3
return false;

if (0 != (program.GetRandom() & 1))
Expand Down Expand Up @@ -211,9 +211,10 @@ bool EmitProlog (CxProgram program)
case 2:
// MOV EAX, (Random() & 0x3ff)
// MOV EAX, EncryptionControlBlock[EAX]
rc = program.Emit (CxByteCode.MOV_EAX_IMMED) // 0xbe
rc = program.EmitNop (5) // 0xbe
&& program.Emit (CxByteCode.MOV_EAX_IMMED, 2) // 0x8b 0x86
&& program.EmitUInt32 (program.GetRandom() & 0x3ff)
&& program.Emit (CxByteCode.MOV_EAX_INDIRECT, 6); // 0x8b 0x86
&& program.Emit (CxByteCode.MOV_EAX_INDIRECT, 0);
break;
case 1:
rc = program.Emit (CxByteCode.MOV_EAX_EDI, 2); // 0x8b 0xc7
Expand Down

0 comments on commit a0162b4

Please sign in to comment.