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); unknown_string_2 = Helper.AutoReadUnicode(Reader);
CommandLine = Helper.AutoReadUnicode(Reader); CommandLine = Helper.AutoReadUnicode(Reader);
Aboutbox = Helper.AutoReadUnicode(Reader); Aboutbox = Helper.AutoReadUnicode(Reader);
Reader.ReadUInt32();
var binCount = Reader.ReadInt32(); //wtf i cant put it in loop fuck shit 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 class MFAGenerator
{ {
//public static readonly string TemplatePath = @"F:\CPP\DotNetCTFDumper\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 readonly string TemplatePath = @"C:\Users\ivani\Desktop\CTFResearch\testNoFrames.mfa";
public static void BuildMFA() public static void BuildMFA()
{ {

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

@ -57,8 +57,9 @@ namespace DotNetCTFDumper.Utils
{ {
return BaseStream.Position < BaseStream.Length; return BaseStream.Position < BaseStream.Length;
} }
public void WriteInt8(byte value) => Write(value); 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 WriteInt32(int value) => Write(value);
public void WriteInt64(long value) => Write(value); public void WriteInt64(long value) => Write(value);
@ -70,7 +71,6 @@ namespace DotNetCTFDumper.Utils
public void WriteBytes(byte[] value) => Write(value); public void WriteBytes(byte[] value) => Write(value);
public void WriteAscii(string value) public void WriteAscii(string value)
{ {
var bytes = Encoding.ASCII.GetBytes(value); var bytes = Encoding.ASCII.GetBytes(value);
@ -79,42 +79,31 @@ namespace DotNetCTFDumper.Utils
WriteInt8(bytes[i]); WriteInt8(bytes[i]);
} }
} }
public void WriteUnicode(string value)
public void WriteUnicode(string value, bool appendZero = false)
{ {
var bytes = Encoding.Unicode.GetBytes(value); var bytes = Encoding.Unicode.GetBytes(value);
for (int i = 0; i < bytes.Length; i++) for (int i = 0; i < bytes.Length; i++)
{ {
WriteInt8(bytes[i]); WriteInt8(bytes[i]);
} }
if (appendZero) WriteInt16(0);
} }
public void WriteColor(Color color) public void WriteColor(Color color)
{ {
WriteInt8(color.R); WriteInt8(color.R);
WriteInt8(color.G); WriteInt8(color.G);
WriteInt8(color.B); WriteInt8(color.B);
WriteInt8(0); WriteInt8(0);
} }
public void WriteWriter(ByteWriter toWrite) public void WriteWriter(ByteWriter toWrite)
{ {
byte[] data = ((MemoryStream) toWrite.BaseStream).GetBuffer(); 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); this.WriteBytes(data);
} }
} }
} }

@ -65,7 +65,7 @@ namespace DotNetCTFDumper.Utils
writer.WriteInt16((short) value.Length); writer.WriteInt16((short) value.Length);
writer.Skip(1); writer.Skip(1);
writer.WriteInt8(0x80); writer.WriteInt8(0x80);
writer.WriteUnicode(value); writer.WriteUnicode(value,false);
} }
public static DataLoader LoadParameter(int code, ByteReader reader) public static DataLoader LoadParameter(int code, ByteReader reader)
@ -292,4 +292,16 @@ namespace DotNetCTFDumper.Utils
} }
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