fixed mfa writting

master
REDxEYE 4 years ago
parent 97d1d3d3e1
commit e03e50a993

@ -282,7 +282,7 @@ namespace DotNetCTFDumper.MMFParser.Data
unknown_string_2 = Helper.AutoReadUnicode(Reader);
CommandLine = Helper.AutoReadUnicode(Reader);
Aboutbox = Helper.AutoReadUnicode(Reader);
Reader.ReadUInt32();
var binCount = Reader.ReadInt32(); //wtf i cant put it in loop fuck shit

@ -6,8 +6,8 @@ namespace DotNetCTFDumper.MMFParser.Decompiling
{
public static class MFAGenerator
{
//public static readonly string TemplatePath = @"F:\CPP\DotNetCTFDumper\testNoFrames.mfa";
public static readonly string TemplatePath = @"C:\Users\ivani\Desktop\CTFResearch\testNoFrames.mfa";
public static readonly string TemplatePath = @"C:\Users\MED45\Downloads\testNoFrames.mfa";
// public static readonly string TemplatePath = @"C:\Users\ivani\Desktop\CTFResearch\testNoFrames.mfa";
public static void BuildMFA()
{

@ -6,7 +6,7 @@ namespace DotNetCTFDumper.Utils
{
public static bool GetFlag(UInt32 flagbyte, int pos)
{
UInt32 mask = (uint) (2 << pos);
UInt32 mask = (uint) (1 << pos);
UInt32 result = flagbyte & mask;
return result == mask;
}

@ -36,7 +36,7 @@ namespace DotNetCTFDumper.Utils
{
BaseStream.Seek(count, SeekOrigin.Current);
}
public Int64 Tell()
{
@ -57,19 +57,19 @@ namespace DotNetCTFDumper.Utils
{
return BaseStream.Position < BaseStream.Length;
}
public void WriteInt8(byte value) => Write(value);
public void WriteInt16(short value)=>Write(value);
public void WriteInt16(short value) => Write(value);
public void WriteInt32(int value) => Write(value);
public void WriteInt64(long value) => Write(value);
public void WriteUInt16(ushort value) => Write(value);
public void WriteUInt32(UInt32 value) => Write(value);
public void WriteUInt64(ulong value) => Write(value);
public void WriteSingle(float value) => Write(value);
public void WriteBytes(byte[] value) => Write(value);
public void WriteAscii(string value)
{
@ -79,42 +79,31 @@ namespace DotNetCTFDumper.Utils
WriteInt8(bytes[i]);
}
}
public void WriteUnicode(string value)
public void WriteUnicode(string value, bool appendZero = false)
{
var bytes = Encoding.Unicode.GetBytes(value);
for (int i = 0; i < bytes.Length; i++)
{
WriteInt8(bytes[i]);
}
if (appendZero) WriteInt16(0);
}
public void WriteColor(Color color)
{
WriteInt8(color.R);
WriteInt8(color.G);
WriteInt8(color.B);
WriteInt8(0);
}
public void WriteWriter(ByteWriter toWrite)
{
byte[] data = ((MemoryStream) toWrite.BaseStream).GetBuffer();
Array.Resize<byte>(ref data,(int) toWrite.Size());
Array.Resize<byte>(ref data, (int) toWrite.Size());
this.WriteBytes(data);
}
}
}

@ -65,7 +65,7 @@ namespace DotNetCTFDumper.Utils
writer.WriteInt16((short) value.Length);
writer.Skip(1);
writer.WriteInt8(0x80);
writer.WriteUnicode(value);
writer.WriteUnicode(value,false);
}
public static DataLoader LoadParameter(int code, ByteReader reader)
@ -289,7 +289,19 @@ namespace DotNetCTFDumper.Utils
// Step 3: return the new array.
return result;
}
}
public static class StringExtensionMethods
{
public static string ReplaceFirst(this string text, string search, string replace)
{
int pos = text.IndexOf(search);
if (pos < 0)
{
return text;
}
return text.Substring(0, pos) + replace + text.Substring(pos + search.Length);
}
}
}
Loading…
Cancel
Save