Add SRC
This commit is contained in:
parent
d9ca2aa563
commit
1f8ac28147
|
@ -0,0 +1,22 @@
|
|||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 15
|
||||
VisualStudioVersion = 15.0.26228.76
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PSMUI", "PSMUI\PSMUI.csproj", "{4CAC0026-0B89-44FC-9F5C-3AD9ABC3B3C1}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{4CAC0026-0B89-44FC-9F5C-3AD9ABC3B3C1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{4CAC0026-0B89-44FC-9F5C-3AD9ABC3B3C1}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{4CAC0026-0B89-44FC-9F5C-3AD9ABC3B3C1}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{4CAC0026-0B89-44FC-9F5C-3AD9ABC3B3C1}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
EndGlobal
|
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<configuration>
|
||||
<startup>
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
|
||||
</startup>
|
||||
</configuration>
|
|
@ -0,0 +1,581 @@
|
|||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using General;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Xml;
|
||||
|
||||
|
||||
namespace CXML
|
||||
{
|
||||
|
||||
enum AttributeType
|
||||
{
|
||||
TYPE_NONE,
|
||||
TYPE_INT,
|
||||
TYPE_FLOAT,
|
||||
TYPE_STRING,
|
||||
TYPE_CHAR,
|
||||
TYPE_STYLE_ID,
|
||||
TYPE_INTEGER_ARRAY,
|
||||
TYPE_FLOAT_ARRAY,
|
||||
TYPE_FILE,
|
||||
TYPE_ID_STRING_LOOPBACK,
|
||||
TYPE_ID_STRING,
|
||||
TYPE_ID_INT_LOOPBACK,
|
||||
TYPE_ID_INT
|
||||
};
|
||||
|
||||
class CXMLParser
|
||||
{
|
||||
|
||||
private static bool _checkMagicNumber()
|
||||
{
|
||||
|
||||
String Magic = Tools.ReadStringAt(InfoFile, 0x00);
|
||||
|
||||
if (Magic.StartsWith("PSMA"))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else if(Magic.StartsWith("RCOF"))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else if (Magic.StartsWith("RCSF"))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private static string _lastFileName = "";
|
||||
|
||||
static String MainDir = "";
|
||||
static String FileDir = "";
|
||||
static String XMLFilename = "";
|
||||
|
||||
static FileStream InfoFile;
|
||||
|
||||
static MemoryStream TreeTable;
|
||||
static MemoryStream StringIDTable;
|
||||
static MemoryStream IntIDTable;
|
||||
static MemoryStream StringTable;
|
||||
static MemoryStream CharTable;
|
||||
static MemoryStream StylesIDTable;
|
||||
static MemoryStream IntArrayTable;
|
||||
static MemoryStream FloatArrayTable;
|
||||
static MemoryStream FileTable;
|
||||
|
||||
|
||||
static BinaryReader bTreeTable;
|
||||
static BinaryReader bIntIDTable;
|
||||
static BinaryReader bFloatArrayTable;
|
||||
static BinaryReader bIntArrayTable;
|
||||
static BinaryReader bStylesIDTable;
|
||||
static BinaryReader bStringIDTable;
|
||||
|
||||
static XmlWriter XMLFile;
|
||||
|
||||
public static void Init(string path, bool CheckMagic = true, string outputDir = "")
|
||||
{
|
||||
InfoFile = File.Open(path, FileMode.Open, FileAccess.Read);
|
||||
if(CheckMagic)
|
||||
{
|
||||
if (!_checkMagicNumber())
|
||||
{
|
||||
throw new Exception("Incorrect magic number.");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
TreeTable = Tools.ByteToStream(GetTreeTable());
|
||||
StringIDTable = Tools.ByteToStream(GetStringIDTable());
|
||||
IntIDTable = Tools.ByteToStream(GetIntIDTable());
|
||||
StringTable = Tools.ByteToStream(GetStringTable());
|
||||
CharTable = Tools.ByteToStream(GetCharTable());
|
||||
StylesIDTable = Tools.ByteToStream(GetStyleIDTable());
|
||||
IntArrayTable = Tools.ByteToStream(GetIntArrayTable());
|
||||
FloatArrayTable = Tools.ByteToStream(GetFloatArrayTable());
|
||||
FileTable = Tools.ByteToStream(GetFileTable());
|
||||
|
||||
bTreeTable = new BinaryReader(TreeTable);
|
||||
bIntIDTable = new BinaryReader(IntIDTable);
|
||||
bFloatArrayTable = new BinaryReader(FloatArrayTable);
|
||||
bIntArrayTable = new BinaryReader(IntArrayTable);
|
||||
bStylesIDTable = new BinaryReader(StylesIDTable);
|
||||
bStringIDTable = new BinaryReader(StringIDTable);
|
||||
|
||||
MainDir = outputDir + Path.GetFileNameWithoutExtension(path);
|
||||
FileDir = Path.Combine(MainDir, "files");
|
||||
XMLFilename = Path.GetFileNameWithoutExtension(path) + ".xml";
|
||||
try
|
||||
{
|
||||
if (Directory.Exists(MainDir))
|
||||
Directory.Delete(MainDir, true);
|
||||
|
||||
if (!Directory.Exists(FileDir))
|
||||
Directory.CreateDirectory(FileDir);
|
||||
}
|
||||
catch (Exception) { };
|
||||
|
||||
}
|
||||
|
||||
public static void Term()
|
||||
{
|
||||
InfoFile.Close();
|
||||
TreeTable.Close();
|
||||
StringIDTable.Close();
|
||||
IntIDTable.Close();
|
||||
StringTable.Close();
|
||||
CharTable.Close();
|
||||
StylesIDTable.Close();
|
||||
IntArrayTable.Close();
|
||||
FloatArrayTable.Close();
|
||||
FileTable.Close();
|
||||
|
||||
bTreeTable.Close();
|
||||
bIntIDTable.Close();
|
||||
bFloatArrayTable.Close();
|
||||
bIntArrayTable.Close();
|
||||
bStylesIDTable.Close();
|
||||
}
|
||||
|
||||
public static int GetTreeTableOffset()
|
||||
{
|
||||
return Tools.ReadIntAt(InfoFile,0x8);
|
||||
}
|
||||
|
||||
public static int GetTreeTableSize()
|
||||
{
|
||||
return Tools.ReadIntAt(InfoFile, 0xC);
|
||||
}
|
||||
|
||||
public static int GetIDStringTableOffset()
|
||||
{
|
||||
return Tools.ReadIntAt(InfoFile, 0x10);
|
||||
}
|
||||
|
||||
public static int GetIDStringTableSize()
|
||||
{
|
||||
return Tools.ReadIntAt(InfoFile, 0x14);
|
||||
}
|
||||
|
||||
public static int GetIDIntTableOffset()
|
||||
{
|
||||
return Tools.ReadIntAt(InfoFile, 0x18);
|
||||
}
|
||||
|
||||
public static int GetIDIntTableSize()
|
||||
{
|
||||
return Tools.ReadIntAt(InfoFile, 0x1C);
|
||||
}
|
||||
|
||||
public static int GetStringTableOffset()
|
||||
{
|
||||
return Tools.ReadIntAt(InfoFile, 0x20);
|
||||
}
|
||||
|
||||
public static int GetStringTableSize()
|
||||
{
|
||||
return Tools.ReadIntAt(InfoFile, 0x24);
|
||||
}
|
||||
|
||||
public static int GetCharTableOffset()
|
||||
{
|
||||
return Tools.ReadIntAt(InfoFile, 0x28);
|
||||
}
|
||||
|
||||
public static int GetCharTableSize()
|
||||
{
|
||||
return Tools.ReadIntAt(InfoFile, 0x2C);
|
||||
}
|
||||
|
||||
public static int GetStyleIDTableOffset()
|
||||
{
|
||||
return Tools.ReadIntAt(InfoFile, 0x30);
|
||||
}
|
||||
|
||||
public static int GetStyleIDTableSize()
|
||||
{
|
||||
return Tools.ReadIntAt(InfoFile, 0x34);
|
||||
}
|
||||
|
||||
public static int GetIntArrayTableOffset()
|
||||
{
|
||||
return Tools.ReadIntAt(InfoFile, 0x38);
|
||||
}
|
||||
|
||||
public static int GetIntArrayTableSize()
|
||||
{
|
||||
return Tools.ReadIntAt(InfoFile, 0x3C);
|
||||
}
|
||||
|
||||
public static int GetFloatArrayTableOffset()
|
||||
{
|
||||
return Tools.ReadIntAt(InfoFile, 0x40);
|
||||
}
|
||||
|
||||
public static int GetFloatArrayTableSize()
|
||||
{
|
||||
return Tools.ReadIntAt(InfoFile, 0x44);
|
||||
}
|
||||
|
||||
public static int GetFileTableOffset()
|
||||
{
|
||||
return Tools.ReadIntAt(InfoFile, 0x48);
|
||||
}
|
||||
|
||||
public static int GetFileTableSize()
|
||||
{
|
||||
return Tools.ReadIntAt(InfoFile, 0x4C);
|
||||
}
|
||||
|
||||
public static byte[] GetTreeTable()
|
||||
{
|
||||
int TableOffset = GetTreeTableOffset();
|
||||
int TableSize = GetTreeTableSize();
|
||||
InfoFile.Seek(TableOffset, SeekOrigin.Begin);
|
||||
byte[] Table = new byte[TableSize];
|
||||
InfoFile.Read(Table, 0x00, TableSize);
|
||||
return Table;
|
||||
}
|
||||
|
||||
public static byte[] GetStringIDTable()
|
||||
{
|
||||
int IDStrTableOffset = GetIDStringTableOffset();
|
||||
int IDStrTableSize = GetIDStringTableSize();
|
||||
InfoFile.Seek(IDStrTableOffset, SeekOrigin.Begin);
|
||||
byte[] IDStringTable = new byte[IDStrTableSize];
|
||||
InfoFile.Read(IDStringTable, 0x00, IDStrTableSize);
|
||||
return IDStringTable;
|
||||
}
|
||||
|
||||
public static byte[] GetIntIDTable()
|
||||
{
|
||||
int IDIntTableOffset = GetIDIntTableOffset();
|
||||
int IDIntTableSize = GetIDIntTableSize();
|
||||
InfoFile.Seek(IDIntTableOffset, SeekOrigin.Begin);
|
||||
byte[] IDIntTable = new byte[IDIntTableSize];
|
||||
InfoFile.Read(IDIntTable, 0x00, IDIntTableSize);
|
||||
return IDIntTable;
|
||||
}
|
||||
|
||||
public static byte[] GetStringTable()
|
||||
{
|
||||
int StringTableOffset = GetStringTableOffset();
|
||||
int StringTableSize = GetStringTableSize();
|
||||
InfoFile.Seek(StringTableOffset, SeekOrigin.Begin);
|
||||
byte[] StringTable = new byte[StringTableSize];
|
||||
InfoFile.Read(StringTable, 0x00, StringTableSize);
|
||||
return StringTable;
|
||||
}
|
||||
|
||||
public static byte[] GetCharTable()
|
||||
{
|
||||
int CharTableOffset = GetCharTableOffset();
|
||||
int CharTableSize = GetCharTableSize();
|
||||
InfoFile.Seek(CharTableOffset, SeekOrigin.Begin);
|
||||
byte[] CharTable = new byte[CharTableSize];
|
||||
InfoFile.Read(CharTable, 0x00, CharTableSize);
|
||||
return CharTable;
|
||||
}
|
||||
|
||||
public static byte[] GetStyleIDTable()
|
||||
{
|
||||
int StyleIDTableOffset = GetStyleIDTableOffset();
|
||||
int StyleIDTableSize = GetStyleIDTableSize();
|
||||
InfoFile.Seek(StyleIDTableOffset, SeekOrigin.Begin);
|
||||
byte[] StyleIDTable = new byte[StyleIDTableSize];
|
||||
InfoFile.Read(StyleIDTable, 0x00, StyleIDTableSize);
|
||||
return StyleIDTable;
|
||||
}
|
||||
|
||||
public static byte[] GetIntArrayTable()
|
||||
{
|
||||
int IntArrayTableOffset = GetIntArrayTableOffset();
|
||||
int IntArrayTableSize = GetIntArrayTableSize();
|
||||
InfoFile.Seek(IntArrayTableOffset, SeekOrigin.Begin);
|
||||
byte[] IntArrayTable = new byte[IntArrayTableSize];
|
||||
InfoFile.Read(IntArrayTable, 0x00, IntArrayTableSize);
|
||||
return IntArrayTable;
|
||||
}
|
||||
|
||||
public static byte[] GetFloatArrayTable()
|
||||
{
|
||||
int FloatArrayTableOffset = GetFloatArrayTableOffset();
|
||||
int FloatArrayTableSize = GetFloatArrayTableSize();
|
||||
InfoFile.Seek(FloatArrayTableOffset, SeekOrigin.Begin);
|
||||
byte[] FloatArrayTable = new byte[FloatArrayTableSize];
|
||||
InfoFile.Read(FloatArrayTable, 0x00, FloatArrayTableSize);
|
||||
return FloatArrayTable;
|
||||
}
|
||||
|
||||
public static byte[] GetFileTable()
|
||||
{
|
||||
int DataOffset = GetFileTableOffset();
|
||||
int DataLength = GetFileTableSize();
|
||||
InfoFile.Seek(DataOffset, SeekOrigin.Begin);
|
||||
byte[] FileTable = new byte[DataLength];
|
||||
InfoFile.Read(FileTable, 0x00, DataLength);
|
||||
return FileTable;
|
||||
}
|
||||
|
||||
public static void DecompileCXML(String CXMLFile, bool force = false, String outputDir = "")
|
||||
{
|
||||
try
|
||||
{
|
||||
Term();
|
||||
}
|
||||
catch (Exception) { };
|
||||
Init(CXMLFile,force,outputDir);
|
||||
|
||||
Directory.CreateDirectory(MainDir);
|
||||
|
||||
XmlWriterSettings XMLSettings = new XmlWriterSettings();
|
||||
XMLSettings.Indent = true;
|
||||
|
||||
XMLFile = XmlWriter.Create(Path.Combine(MainDir, XMLFilename), XMLSettings);
|
||||
XMLFile.WriteStartDocument();
|
||||
|
||||
ReadElements();
|
||||
|
||||
XMLFile.WriteEndDocument();
|
||||
XMLFile.Flush();
|
||||
XMLFile.Close();
|
||||
|
||||
Term();
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static void ReadAttribute(String ElementName = "")
|
||||
{
|
||||
int AttributePtr = bTreeTable.ReadInt32();
|
||||
AttributeType Type = (AttributeType)bTreeTable.ReadInt32();
|
||||
|
||||
String AttributeName = Tools.ReadStringAt(StringTable, AttributePtr);
|
||||
object AttributeValue = "";
|
||||
|
||||
Console.WriteLine("AttributeType: " + Type.ToString() + " - "+ TreeTable.Position.ToString());
|
||||
switch (Type)
|
||||
{
|
||||
case AttributeType.TYPE_NONE:
|
||||
Console.WriteLine("UNSUPPORTED TYPE @ " + TreeTable.Position);
|
||||
Console.ReadKey();
|
||||
break;
|
||||
case AttributeType.TYPE_INT:
|
||||
AttributeValue = bTreeTable.ReadInt32();
|
||||
TreeTable.Seek(4, SeekOrigin.Current);
|
||||
break;
|
||||
case AttributeType.TYPE_FLOAT:
|
||||
float FloatValue = bTreeTable.ReadSingle();
|
||||
AttributeValue = Tools.RemoveDecimals(FloatValue);
|
||||
TreeTable.Seek(4, SeekOrigin.Current);
|
||||
break;
|
||||
case AttributeType.TYPE_STRING:
|
||||
int StringOffset = bTreeTable.ReadInt32();
|
||||
int StringLen = bTreeTable.ReadInt32();
|
||||
|
||||
byte[] StringBytes = new byte[StringLen];
|
||||
StringTable.Seek(StringOffset, 0x00);
|
||||
StringTable.Read(StringBytes, 0x00, StringLen);
|
||||
|
||||
AttributeValue = Encoding.UTF8.GetString(StringBytes);
|
||||
break;
|
||||
case AttributeType.TYPE_CHAR:
|
||||
int CharOffset = bTreeTable.ReadInt32() * 2;
|
||||
int CharLen = bTreeTable.ReadInt32();
|
||||
|
||||
byte[] CharBytes = new byte[CharLen];
|
||||
CharTable.Seek(CharOffset, 0x00);
|
||||
CharTable.Read(CharBytes, 0x00, CharLen);
|
||||
|
||||
AttributeValue = Encoding.Unicode.GetString(CharBytes);
|
||||
break;
|
||||
case AttributeType.TYPE_STYLE_ID:
|
||||
int StyleTableOffset = bTreeTable.ReadInt32();
|
||||
int StyleTableSize = bTreeTable.ReadInt32();
|
||||
|
||||
byte[] StyleTableData = new byte[StyleTableSize];
|
||||
|
||||
StylesIDTable.Seek(StyleTableOffset, SeekOrigin.Begin);
|
||||
StylesIDTable.Read(StyleTableData, 0x00, StyleTableSize);
|
||||
AttributeValue = BitConverter.ToString(StyleTableData).Replace("-","");
|
||||
break;
|
||||
case AttributeType.TYPE_INTEGER_ARRAY:
|
||||
int IntArrayOffset = bTreeTable.ReadInt32();
|
||||
int IntArraySize = bTreeTable.ReadInt32();
|
||||
IntArrayTable.Seek(IntArrayOffset, SeekOrigin.Begin);
|
||||
|
||||
List<int> IntList = new List<int>();
|
||||
|
||||
for (int i = 0; i < IntArraySize; i++)
|
||||
{
|
||||
int IntValue = bIntArrayTable.ReadInt32();
|
||||
IntList.Add(IntValue);
|
||||
}
|
||||
int[] IntArray = IntList.ToArray();
|
||||
AttributeValue = String.Join(", ", IntArray);
|
||||
break;
|
||||
case AttributeType.TYPE_FLOAT_ARRAY:
|
||||
int FloatArrayOffset = bTreeTable.ReadInt32();
|
||||
int FloatArraySize = bTreeTable.ReadInt32();
|
||||
FloatArrayTable.Seek(FloatArrayOffset, SeekOrigin.Begin);
|
||||
|
||||
List<string> StrList = new List<string>();
|
||||
|
||||
for(int i = 0; i < FloatArraySize; i++)
|
||||
{
|
||||
FloatValue = bFloatArrayTable.ReadSingle();
|
||||
StrList.Add(Tools.RemoveDecimals(FloatValue));
|
||||
}
|
||||
string[] StrArray = StrList.ToArray();
|
||||
AttributeValue = String.Join(", ", StrArray);
|
||||
break;
|
||||
case AttributeType.TYPE_FILE:
|
||||
int FilePtr = bTreeTable.ReadInt32();
|
||||
int FileSz = bTreeTable.ReadInt32();
|
||||
|
||||
String FileName = "";
|
||||
|
||||
Byte[] FileData = new Byte[FileSz];
|
||||
FileTable.Seek(FilePtr, SeekOrigin.Begin);
|
||||
FileTable.Read(FileData, 0, FileSz);
|
||||
|
||||
int count = 0;
|
||||
string CounterStr = count.ToString();
|
||||
do
|
||||
{
|
||||
String Extension = Tools.GetFileExtension(FileData);
|
||||
CounterStr = count.ToString();
|
||||
if (count == 0)
|
||||
CounterStr = "";
|
||||
FileName = Path.Combine(FileDir , ElementName , AttributeName + CounterStr + Extension);
|
||||
count++;
|
||||
}
|
||||
while (File.Exists(FileName));
|
||||
|
||||
Console.WriteLine("Writing: " + FileName);
|
||||
|
||||
if (!Directory.Exists(Path.GetDirectoryName(FileName)))
|
||||
Directory.CreateDirectory(Path.GetDirectoryName(FileName));
|
||||
|
||||
File.WriteAllBytes(FileName, FileData);
|
||||
|
||||
AttributeValue = FileName;
|
||||
break;
|
||||
case AttributeType.TYPE_ID_STRING_LOOPBACK:
|
||||
int StringIdTableOffset = bTreeTable.ReadInt32();
|
||||
StringIDTable.Seek(StringIdTableOffset, SeekOrigin.Begin);
|
||||
|
||||
int LoopbackPtr = bStringIDTable.ReadInt32();
|
||||
int StringPtr = Tools.ReadIntAt(TreeTable, LoopbackPtr);
|
||||
string LoopbackAttribute = Tools.ReadStringAt(StringTable, StringPtr);
|
||||
|
||||
Console.WriteLine("Loopback: " + LoopbackAttribute);
|
||||
|
||||
AttributeValue = Tools.ReadString(StringIDTable);
|
||||
|
||||
TreeTable.Seek(4, SeekOrigin.Current);
|
||||
break;
|
||||
case AttributeType.TYPE_ID_STRING:
|
||||
Console.WriteLine("UNSUPPORTED TYPE @ " + TreeTable.Position);
|
||||
Console.ReadKey();
|
||||
break;
|
||||
case AttributeType.TYPE_ID_INT_LOOPBACK:
|
||||
int IntIdTableOffset = bTreeTable.ReadInt32();
|
||||
IntIDTable.Seek(IntIdTableOffset, SeekOrigin.Begin);
|
||||
|
||||
LoopbackPtr = bIntIDTable.ReadInt32();
|
||||
StringPtr = Tools.ReadIntAt(TreeTable, LoopbackPtr);
|
||||
|
||||
int IDValue = bIntIDTable.ReadInt32();
|
||||
|
||||
|
||||
LoopbackAttribute = Tools.ReadStringAt(StringTable, StringPtr);
|
||||
Console.WriteLine("Loopback: " + LoopbackAttribute);
|
||||
|
||||
AttributeValue = IDValue.ToString("X8");
|
||||
|
||||
TreeTable.Seek(4, SeekOrigin.Current);
|
||||
break;
|
||||
case AttributeType.TYPE_ID_INT:
|
||||
IntIdTableOffset = bTreeTable.ReadInt32();
|
||||
IntIDTable.Seek(IntIdTableOffset + 4, SeekOrigin.Begin);
|
||||
IDValue = bIntIDTable.ReadInt32();
|
||||
|
||||
AttributeValue = IDValue.ToString("X8");
|
||||
TreeTable.Seek(4, SeekOrigin.Current);
|
||||
break;
|
||||
default:
|
||||
Console.WriteLine("UNKNOWN TYPE @ " + TreeTable.Position);
|
||||
break;
|
||||
};
|
||||
|
||||
|
||||
Console.WriteLine(AttributeName + "=" + AttributeValue.ToString());
|
||||
XMLFile.WriteAttributeString(AttributeName, AttributeValue.ToString());
|
||||
XMLFile.Flush();
|
||||
}
|
||||
|
||||
public static void ReadElements()
|
||||
{
|
||||
|
||||
int ElementPtr = bTreeTable.ReadInt32();
|
||||
int NumAttributes = bTreeTable.ReadInt32();
|
||||
|
||||
int ParentPtr = bTreeTable.ReadInt32();
|
||||
int PrevSibling = bTreeTable.ReadInt32();
|
||||
int NextSibling = bTreeTable.ReadInt32();
|
||||
|
||||
int FirstChild = bTreeTable.ReadInt32();
|
||||
int LastChild = bTreeTable.ReadInt32();
|
||||
|
||||
String ElementName = Tools.ReadStringAt(StringTable, ElementPtr);
|
||||
Console.WriteLine("Creating Element: " + ElementName);
|
||||
Console.WriteLine("Attribute Count: " + NumAttributes);
|
||||
|
||||
Console.WriteLine("ParentPtr: " + ParentPtr);
|
||||
Console.WriteLine("PrevSibling: " + PrevSibling);
|
||||
Console.WriteLine("NextSibling: " + NextSibling);
|
||||
|
||||
Console.WriteLine("FirstChild: " + FirstChild);
|
||||
Console.WriteLine("LastChild: " + LastChild);
|
||||
|
||||
XMLFile.WriteStartElement(ElementName);
|
||||
|
||||
if(NumAttributes > 0)
|
||||
{
|
||||
for (int i = 0; i < NumAttributes; i++)
|
||||
{
|
||||
ReadAttribute(ElementName);
|
||||
}
|
||||
}
|
||||
|
||||
if (FirstChild != -1)
|
||||
{
|
||||
TreeTable.Seek(FirstChild, SeekOrigin.Begin);
|
||||
ReadElements();
|
||||
}
|
||||
|
||||
|
||||
XMLFile.WriteEndElement();
|
||||
XMLFile.Flush();
|
||||
|
||||
if (NextSibling != -1)
|
||||
{
|
||||
TreeTable.Seek(NextSibling, SeekOrigin.Begin);
|
||||
ReadElements();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,105 @@
|
|||
namespace PSMUI
|
||||
{
|
||||
partial class PSMUI
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(PSMUI));
|
||||
this.GameList = new System.Windows.Forms.Panel();
|
||||
this.ScreenRes = new System.Windows.Forms.Label();
|
||||
this.screenResolution = new System.Windows.Forms.ComboBox();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// GameList
|
||||
//
|
||||
this.GameList.AutoScroll = true;
|
||||
this.GameList.BackColor = System.Drawing.Color.Teal;
|
||||
this.GameList.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center;
|
||||
this.GameList.Dock = System.Windows.Forms.DockStyle.Bottom;
|
||||
this.GameList.Location = new System.Drawing.Point(0, 33);
|
||||
this.GameList.Name = "GameList";
|
||||
this.GameList.Size = new System.Drawing.Size(1264, 598);
|
||||
this.GameList.TabIndex = 3;
|
||||
//
|
||||
// ScreenRes
|
||||
//
|
||||
this.ScreenRes.AutoSize = true;
|
||||
this.ScreenRes.ForeColor = System.Drawing.Color.White;
|
||||
this.ScreenRes.Location = new System.Drawing.Point(12, 9);
|
||||
this.ScreenRes.Name = "ScreenRes";
|
||||
this.ScreenRes.Size = new System.Drawing.Size(60, 13);
|
||||
this.ScreenRes.TabIndex = 4;
|
||||
this.ScreenRes.Text = "Resoultion:";
|
||||
//
|
||||
// screenResolution
|
||||
//
|
||||
this.screenResolution.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.screenResolution.FormattingEnabled = true;
|
||||
this.screenResolution.Items.AddRange(new object[] {
|
||||
"1280x670",
|
||||
"1920x1080",
|
||||
"800x480",
|
||||
"960x544",
|
||||
"1280x800",
|
||||
"1920x1200"});
|
||||
this.screenResolution.Location = new System.Drawing.Point(78, 6);
|
||||
this.screenResolution.Name = "screenResolution";
|
||||
this.screenResolution.Size = new System.Drawing.Size(141, 21);
|
||||
this.screenResolution.TabIndex = 1;
|
||||
//
|
||||
// PSMUI
|
||||
//
|
||||
this.AllowDrop = true;
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(192)))), ((int)(((byte)(192)))));
|
||||
this.ClientSize = new System.Drawing.Size(1264, 631);
|
||||
this.Controls.Add(this.screenResolution);
|
||||
this.Controls.Add(this.ScreenRes);
|
||||
this.Controls.Add(this.GameList);
|
||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
|
||||
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
|
||||
this.MaximizeBox = false;
|
||||
this.MinimizeBox = false;
|
||||
this.Name = "PSMUI";
|
||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
|
||||
this.Text = "Game Browser";
|
||||
this.Load += new System.EventHandler(this.PSMUI_Load);
|
||||
this.DragDrop += new System.Windows.Forms.DragEventHandler(this.PSMUI_DragDrop);
|
||||
this.DragEnter += new System.Windows.Forms.DragEventHandler(this.PSMUI_DragEnter);
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
private System.Windows.Forms.Panel GameList;
|
||||
private System.Windows.Forms.Label ScreenRes;
|
||||
private System.Windows.Forms.ComboBox screenResolution;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,321 @@
|
|||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
using System.IO.Compression;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Threading;
|
||||
using System.Windows.Forms;
|
||||
using System.Xml;
|
||||
|
||||
namespace PSMUI
|
||||
{
|
||||
public partial class PSMUI : Form
|
||||
{
|
||||
int NumberOfGames = 0;
|
||||
Label noGamesMessage = new Label();
|
||||
|
||||
|
||||
[DllImport("user32.dll", SetLastError = true)]
|
||||
internal static extern bool MoveWindow(IntPtr hWnd, int X, int Y, int nWidth, int nHeight, bool bRepaint);
|
||||
[DllImport("user32.dll")]
|
||||
static extern int SetWindowText(IntPtr hWnd, string text);
|
||||
public struct Rect
|
||||
{
|
||||
public int Left { get; set; }
|
||||
public int Top { get; set; }
|
||||
public int Right { get; set; }
|
||||
public int Bottom { get; set; }
|
||||
}
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
public static extern bool GetWindowRect(IntPtr hwnd, ref Rect rectangle);
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
internal extern static int SetWindowLong(IntPtr hwnd, int index, int value);
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
internal extern static int GetWindowLong(IntPtr hwnd, int index);
|
||||
|
||||
|
||||
public PSMUI()
|
||||
{
|
||||
InitializeComponent();
|
||||
screenResolution.SelectedIndex = 0;
|
||||
}
|
||||
|
||||
private string GetPSMName(string id)
|
||||
{
|
||||
XmlDocument Docu = new XmlDocument();
|
||||
Docu.Load(Path.Combine("APPMETA", id , id + ".xml"));
|
||||
XmlNode node = Docu.DocumentElement.SelectSingleNode("/application/name/localized_item[1]");
|
||||
return node.Attributes["value"].InnerText;
|
||||
|
||||
}
|
||||
|
||||
private Point GetImagePosition()
|
||||
{
|
||||
Point location = new Point(160, 45);
|
||||
for (int i = 0; i < NumberOfGames; i++)
|
||||
{
|
||||
location.X += 128 + 35;
|
||||
if (location.X + 128 + 35 >= 1280)
|
||||
{
|
||||
location.Y += 128 + 45;
|
||||
location.X = 160;
|
||||
}
|
||||
}
|
||||
return location;
|
||||
}
|
||||
|
||||
private Point GetTextPosition()
|
||||
{
|
||||
Point location = new Point(160, 175);
|
||||
for (int i = 0; i < NumberOfGames; i++)
|
||||
{
|
||||
location.X += 128 + 35;
|
||||
if (location.X + 128 + 35 >= 1280)
|
||||
{
|
||||
location.Y += 175;
|
||||
location.X = 160;
|
||||
}
|
||||
}
|
||||
return location;
|
||||
}
|
||||
|
||||
private void AddPsmGame(string id)
|
||||
{
|
||||
noGamesMessage.Visible = false;
|
||||
|
||||
PictureBox PSMGameHighlight = new PictureBox();
|
||||
PictureBox PSMGameIcon = new PictureBox();
|
||||
Label PSMGameName = new Label();
|
||||
|
||||
Point ImgPos = GetImagePosition();
|
||||
|
||||
PSMGameHighlight.Visible = true;
|
||||
PSMGameHighlight.Width = 160;
|
||||
PSMGameHighlight.Height = 180;
|
||||
PSMGameHighlight.BackColor = Color.Transparent;
|
||||
PSMGameHighlight.Location = new Point(ImgPos.X - 16, ImgPos.Y - 16);
|
||||
PSMGameHighlight.MouseEnter += PSMGameHighlight_MouseEnter;
|
||||
PSMGameHighlight.MouseLeave += PSMGameHighlight_MouseLeave;
|
||||
PSMGameHighlight.MouseClick += PSMGameHighlight_MouseClick;
|
||||
PSMGameHighlight.Tag = PSMGameName;
|
||||
PSMGameHighlight.Name = id;
|
||||
GameList.Controls.Add(PSMGameHighlight);
|
||||
|
||||
PSMGameIcon.Visible = true;
|
||||
PSMGameIcon.Width = 128;
|
||||
PSMGameIcon.Height = 128;
|
||||
PSMGameIcon.BackgroundImage = Image.FromFile(Path.Combine("APPMETA", id, "files", "images", "icon_128x128.png"));
|
||||
PSMGameIcon.Location = ImgPos;
|
||||
PSMGameIcon.MouseEnter += PSMGameHighlight_MouseEnter;
|
||||
PSMGameIcon.MouseLeave += PSMGameHighlight_MouseLeave;
|
||||
PSMGameIcon.MouseClick += PSMGameHighlight_MouseClick;
|
||||
PSMGameIcon.Tag = PSMGameHighlight;
|
||||
PSMGameIcon.Name = id;
|
||||
GameList.Controls.Add(PSMGameIcon);
|
||||
|
||||
PSMGameName.Visible = true;
|
||||
PSMGameName.Width = 128;
|
||||
PSMGameName.Height = 25;
|
||||
PSMGameName.TextAlign = ContentAlignment.TopCenter;
|
||||
PSMGameName.BackColor = Color.Transparent;
|
||||
PSMGameName.ForeColor = Color.White;
|
||||
PSMGameName.Text = GetPSMName(id);
|
||||
PSMGameName.Location = GetTextPosition();
|
||||
PSMGameName.Tag = PSMGameHighlight;
|
||||
PSMGameName.MouseEnter += PSMGameHighlight_MouseEnter;
|
||||
PSMGameName.MouseLeave += PSMGameHighlight_MouseLeave;
|
||||
PSMGameName.MouseClick += PSMGameHighlight_MouseClick;
|
||||
PSMGameName.Name = id;
|
||||
GameList.Controls.Add(PSMGameName);
|
||||
|
||||
NumberOfGames += 1;
|
||||
PSMGameHighlight.SendToBack();
|
||||
|
||||
Application.DoEvents();
|
||||
}
|
||||
|
||||
|
||||
private void PSMGameHighlight_MouseClick(object PSMGameBackground, MouseEventArgs e)
|
||||
{
|
||||
String id = PSMGameBackground.GetType().GetProperty("Name").GetValue(PSMGameBackground, null).ToString();
|
||||
Console.WriteLine("Starting: "+id);
|
||||
Process proc = new Process();
|
||||
|
||||
string PSM_SDK = Path.Combine(Directory.GetCurrentDirectory(), "SDK");
|
||||
if (proc.StartInfo.EnvironmentVariables.ContainsKey("SCE_PSM_SDK"))
|
||||
proc.StartInfo.EnvironmentVariables.Remove("SCE_PSM_SDK");
|
||||
string[] DIMENSIONS = screenResolution.Text.Split('x');
|
||||
string SIM_PATH = Path.Combine("SDK", "target","win32","psm.exe");
|
||||
|
||||
proc.StartInfo.FileName = SIM_PATH;
|
||||
proc.StartInfo.Arguments = "\""+Path.Combine(Directory.GetCurrentDirectory(),"PSM",id,"Application","app.exe")+ "\" --window-width " + DIMENSIONS[0] + " --window-height " + DIMENSIONS[1];
|
||||
proc.StartInfo.UseShellExecute = false;
|
||||
proc.StartInfo.RedirectStandardError = true;
|
||||
proc.StartInfo.RedirectStandardOutput = true;
|
||||
proc.StartInfo.CreateNoWindow = true;
|
||||
proc.StartInfo.EnvironmentVariables.Add("SCE_PSM_SDK", PSM_SDK);
|
||||
|
||||
proc.OutputDataReceived += Proc_OutputDataReceived;
|
||||
proc.ErrorDataReceived += Proc_ErrorDataReceived;
|
||||
Console.WriteLine(proc.StartInfo.FileName + " " + proc.StartInfo.Arguments);
|
||||
proc.Start();
|
||||
this.Hide();
|
||||
|
||||
IntPtr myhnd = Process.GetCurrentProcess().MainWindowHandle;
|
||||
Rect MySize = new Rect();
|
||||
GetWindowRect(myhnd, ref MySize);
|
||||
|
||||
Thread.Sleep(500);
|
||||
IntPtr hnd = proc.MainWindowHandle;
|
||||
Console.WriteLine("Window Handle: "+hnd);
|
||||
|
||||
Rect CurSize = new Rect();
|
||||
GetWindowRect(hnd, ref CurSize);
|
||||
|
||||
int width = CurSize.Right - CurSize.Left;
|
||||
int height = CurSize.Bottom - CurSize.Top;
|
||||
Console.WriteLine("Window Info: t "+CurSize.Top+" l "+CurSize.Left+" r "+CurSize.Right+" b "+CurSize.Bottom);
|
||||
|
||||
MoveWindow(hnd, (Screen.PrimaryScreen.Bounds.Width / 2) - width / 2, (Screen.PrimaryScreen.Bounds.Height / 2) - height / 2, width, height, false);
|
||||
SetWindowText(hnd, GetPSMName(id));
|
||||
|
||||
const int GWL_STYLE = -16;
|
||||
long value = GetWindowLong(hnd, GWL_STYLE);
|
||||
SetWindowLong(hnd, GWL_STYLE, (int)(value & -131073 & -65537));
|
||||
proc.WaitForExit();
|
||||
|
||||
this.Show();
|
||||
|
||||
}
|
||||
|
||||
private void Proc_ErrorDataReceived(object sender, DataReceivedEventArgs e)
|
||||
{
|
||||
Console.WriteLine(e.Data);
|
||||
MessageBox.Show(e.Data, "Exception", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
|
||||
private void Proc_OutputDataReceived(object sender, DataReceivedEventArgs e)
|
||||
{
|
||||
|
||||
Console.WriteLine(e.Data);
|
||||
}
|
||||
|
||||
private void PSMGameHighlight_MouseLeave(object PSMGameBackground, EventArgs e)
|
||||
{
|
||||
object TaggedObject = PSMGameBackground.GetType().GetProperty("Tag").GetValue(PSMGameBackground, null);
|
||||
object TaggedTaggedObject = TaggedObject.GetType().GetProperty("Tag").GetValue(TaggedObject, null);
|
||||
|
||||
PSMGameBackground.GetType().GetProperty("BackColor").SetValue(PSMGameBackground, Color.Transparent);
|
||||
if (TaggedObject != null)
|
||||
TaggedObject.GetType().GetProperty("BackColor").SetValue(TaggedObject, Color.Transparent);
|
||||
if (TaggedTaggedObject != null)
|
||||
TaggedTaggedObject.GetType().GetProperty("BackColor").SetValue(TaggedTaggedObject, Color.Transparent);
|
||||
|
||||
}
|
||||
|
||||
private void PSMGameHighlight_MouseEnter(object PSMGameBackground, EventArgs e)
|
||||
{
|
||||
object TaggedObject = PSMGameBackground.GetType().GetProperty("Tag").GetValue(PSMGameBackground, null);
|
||||
object TaggedTaggedObject = TaggedObject.GetType().GetProperty("Tag").GetValue(TaggedObject, null);
|
||||
|
||||
PSMGameBackground.GetType().GetProperty("BackColor").SetValue(PSMGameBackground, Color.BlueViolet);
|
||||
if (TaggedObject != null)
|
||||
TaggedObject.GetType().GetProperty("BackColor").SetValue(TaggedObject, Color.BlueViolet);
|
||||
if (TaggedTaggedObject != null)
|
||||
TaggedTaggedObject.GetType().GetProperty("BackColor").SetValue(TaggedTaggedObject, Color.BlueViolet);
|
||||
}
|
||||
|
||||
private void ReloadGameList()
|
||||
{
|
||||
NumberOfGames = 0;
|
||||
GameList.Controls.Clear();
|
||||
|
||||
if (Directory.Exists("PSM"))
|
||||
{
|
||||
noGamesMessage.Visible = false;
|
||||
foreach (string dir in Directory.GetDirectories("APPMETA"))
|
||||
{
|
||||
AddPsmGame(Path.GetFileNameWithoutExtension(dir));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
noGamesMessage.Visible = true;
|
||||
noGamesMessage.BackColor = Color.Transparent;
|
||||
noGamesMessage.ForeColor =Color.White;
|
||||
noGamesMessage.Location = new Point(GameList.Width / 2 - 60, GameList.Height / 2);
|
||||
noGamesMessage.Name = "noGamesMessage";
|
||||
noGamesMessage.Size = new Size(127, 26);
|
||||
noGamesMessage.TabIndex = 2;
|
||||
noGamesMessage.Text = "No games are installed...\r\nDrag n drop .zip files here";
|
||||
GameList.Controls.Add(noGamesMessage);
|
||||
}
|
||||
}
|
||||
|
||||
private void PSMUI_Load(object sender, EventArgs e)
|
||||
{
|
||||
ReloadGameList();
|
||||
}
|
||||
|
||||
private void PSMUI_DragDrop(object sender, DragEventArgs e)
|
||||
{
|
||||
var files = (string[])e.Data.GetData(DataFormats.FileDrop);
|
||||
foreach(string file in files)
|
||||
{
|
||||
Console.WriteLine("Processing: " + file);
|
||||
if (Path.GetExtension(file) != ".zip")
|
||||
{
|
||||
Console.WriteLine("ERROR: " + file + " Is not .zip!");
|
||||
MessageBox.Show(file+" is not a ZIP file.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
|
||||
Console.WriteLine("Extracting app.info" + file);
|
||||
|
||||
ZipArchive zf = ZipFile.OpenRead(file);
|
||||
ZipArchiveEntry entry = zf.GetEntry("Application/app.info");
|
||||
|
||||
if(entry == null)
|
||||
{
|
||||
Console.WriteLine("ERROR: " + file + " Missing app.info!");
|
||||
MessageBox.Show(file + " is not a PSM Game (missing Application/app.info)", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
|
||||
Directory.CreateDirectory("APPMETA");
|
||||
Directory.CreateDirectory("PSM");
|
||||
string InfoFile = Path.Combine("APPMETA/", Path.GetFileNameWithoutExtension(file)+".info");
|
||||
entry.ExtractToFile(InfoFile, true);
|
||||
Console.WriteLine("Decompiling "+ InfoFile);
|
||||
CXML.CXMLParser.DecompileCXML(InfoFile,false,"APPMETA/");
|
||||
Console.WriteLine("Done!");
|
||||
Console.WriteLine("Extracting game...");
|
||||
foreach(ZipArchiveEntry ze in zf.Entries)
|
||||
{
|
||||
string name = Path.Combine("PSM", Path.GetFileNameWithoutExtension(file)) + "/"+ ze.FullName;
|
||||
if(ze.FullName.EndsWith("\\") || ze.FullName.EndsWith("/"))
|
||||
{
|
||||
Directory.CreateDirectory(name);
|
||||
}
|
||||
else
|
||||
{
|
||||
ze.ExtractToFile(name, true);
|
||||
}
|
||||
Console.WriteLine("Writing: " + name);
|
||||
Application.DoEvents();
|
||||
}
|
||||
Console.WriteLine("Done!");
|
||||
ReloadGameList();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void PSMUI_DragEnter(object sender, DragEventArgs e)
|
||||
{
|
||||
if (e.Data.GetDataPresent(DataFormats.FileDrop))
|
||||
e.Effect = DragDropEffects.Copy;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,99 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{4CAC0026-0B89-44FC-9F5C-3AD9ABC3B3C1}</ProjectGuid>
|
||||
<OutputType>Exe</OutputType>
|
||||
<RootNamespace>PSMUI</RootNamespace>
|
||||
<AssemblyName>PSMUI</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<StartupObject />
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<ApplicationIcon>psm.ico</ApplicationIcon>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.IO.Compression" />
|
||||
<Reference Include="System.IO.Compression.FileSystem" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Deployment" />
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.Net.Http" />
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="CXML.cs" />
|
||||
<Compile Include="PSMUI.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="PSMUI.Designer.cs">
|
||||
<DependentUpon>PSMUI.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Program.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Tools.cs" />
|
||||
<EmbeddedResource Include="Properties\Resources.resx">
|
||||
<Generator>ResXFileCodeGenerator</Generator>
|
||||
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
||||
<SubType>Designer</SubType>
|
||||
</EmbeddedResource>
|
||||
<Compile Include="Properties\Resources.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>Resources.resx</DependentUpon>
|
||||
<DesignTime>True</DesignTime>
|
||||
</Compile>
|
||||
<EmbeddedResource Include="PSMUI.resx">
|
||||
<DependentUpon>PSMUI.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<None Include="Properties\Settings.settings">
|
||||
<Generator>SettingsSingleFileGenerator</Generator>
|
||||
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
|
||||
</None>
|
||||
<Compile Include="Properties\Settings.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>Settings.settings</DependentUpon>
|
||||
<DesignTimeSharedInput>True</DesignTimeSharedInput>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="App.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Resources\bg_local_phone.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="psm.ico" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,22 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace PSMUI
|
||||
{
|
||||
static class Program
|
||||
{
|
||||
/// <summary>
|
||||
/// The main entry point for the application.
|
||||
/// </summary>
|
||||
[STAThread]
|
||||
static void Main()
|
||||
{
|
||||
Application.EnableVisualStyles();
|
||||
Application.SetCompatibleTextRenderingDefault(false);
|
||||
Application.Run(new PSMUI());
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("PSMUI")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("PSMUI")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2019")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid("4cac0026-0b89-44fc-9f5c-3ad9abc3b3c1")]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
|
@ -0,0 +1,73 @@
|
|||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:4.0.30319.42000
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace PSMUI.Properties {
|
||||
using System;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// A strongly-typed resource class, for looking up localized strings, etc.
|
||||
/// </summary>
|
||||
// This class was auto-generated by the StronglyTypedResourceBuilder
|
||||
// class via a tool like ResGen or Visual Studio.
|
||||
// To add or remove a member, edit your .ResX file then rerun ResGen
|
||||
// with the /str option, or rebuild your VS project.
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
internal class Resources {
|
||||
|
||||
private static global::System.Resources.ResourceManager resourceMan;
|
||||
|
||||
private static global::System.Globalization.CultureInfo resourceCulture;
|
||||
|
||||
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
|
||||
internal Resources() {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the cached ResourceManager instance used by this class.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Resources.ResourceManager ResourceManager {
|
||||
get {
|
||||
if (object.ReferenceEquals(resourceMan, null)) {
|
||||
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("PSMUI.Properties.Resources", typeof(Resources).Assembly);
|
||||
resourceMan = temp;
|
||||
}
|
||||
return resourceMan;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Overrides the current thread's CurrentUICulture property for all
|
||||
/// resource lookups using this strongly typed resource class.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Globalization.CultureInfo Culture {
|
||||
get {
|
||||
return resourceCulture;
|
||||
}
|
||||
set {
|
||||
resourceCulture = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap bg_local_phone {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("bg_local_phone", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,124 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
|
||||
<data name="bg_local_phone" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\bg_local_phone.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
</root>
|
|
@ -0,0 +1,30 @@
|
|||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:4.0.30319.42000
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace PSMUI.Properties
|
||||
{
|
||||
|
||||
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
|
||||
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
|
||||
{
|
||||
|
||||
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
|
||||
|
||||
public static Settings Default
|
||||
{
|
||||
get
|
||||
{
|
||||
return defaultInstance;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)">
|
||||
<Profiles>
|
||||
<Profile Name="(Default)" />
|
||||
</Profiles>
|
||||
<Settings />
|
||||
</SettingsFile>
|
Binary file not shown.
After Width: | Height: | Size: 297 KiB |
|
@ -0,0 +1,243 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace General
|
||||
{
|
||||
class Tools
|
||||
{
|
||||
public static String RemoveDecimals(float FloatValue)
|
||||
{
|
||||
String FloatStr = FloatValue.ToString();
|
||||
String[] FloatParts = FloatStr.Split('.');
|
||||
if (FloatParts.Length > 1)
|
||||
if (FloatParts[1].Length > 2)
|
||||
FloatParts[1] = FloatParts[1].Substring(0, 2);
|
||||
|
||||
|
||||
FloatStr = String.Join(".", FloatParts);
|
||||
return FloatStr;
|
||||
}
|
||||
public static void WriteStringToStream(Stream s, String str)
|
||||
{
|
||||
Byte[] bytes = Encoding.UTF8.GetBytes(str);
|
||||
s.Write(bytes, 0x00, bytes.Length);
|
||||
}
|
||||
public static MemoryStream ByteToStream(byte[] Array)
|
||||
{
|
||||
MemoryStream ms = new MemoryStream();
|
||||
ms.Write(Array, 0x00, Array.Length);
|
||||
ms.Seek(0, SeekOrigin.Begin);
|
||||
return ms;
|
||||
}
|
||||
|
||||
public static byte[] StreamToByte(Stream stream)
|
||||
{
|
||||
int StreamLen = (int)stream.Length;
|
||||
byte[] Bytes = new byte[StreamLen];
|
||||
stream.Seek(0, SeekOrigin.Begin);
|
||||
stream.Read(Bytes, 0x00, StreamLen);
|
||||
return Bytes;
|
||||
}
|
||||
|
||||
public static string GetFileExtension(byte[] Bytes)
|
||||
{
|
||||
if (IsImage(Bytes))
|
||||
{
|
||||
return ".png";
|
||||
}
|
||||
else if (IsZlib(Bytes))
|
||||
{
|
||||
return ".zlib";
|
||||
}
|
||||
else if (IsRcf(Bytes))
|
||||
{
|
||||
return ".rcs";
|
||||
}
|
||||
else if (IsDDS(Bytes))
|
||||
{
|
||||
return ".dds";
|
||||
}
|
||||
else if (IsVAG(Bytes))
|
||||
{
|
||||
return ".vag";
|
||||
}
|
||||
else if (IsGim(Bytes))
|
||||
{
|
||||
return ".gim";
|
||||
}
|
||||
else
|
||||
{
|
||||
return ".bin";
|
||||
}
|
||||
}
|
||||
|
||||
public static bool IsVAG(byte[] Bytes)
|
||||
{
|
||||
MemoryStream Data = ByteToStream(Bytes);
|
||||
String header = ReadString(Data, 4);
|
||||
if (header.StartsWith("VAG"))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static bool IsDDS(byte[] Bytes)
|
||||
{
|
||||
MemoryStream Data = ByteToStream(Bytes);
|
||||
String header = ReadString(Data, 4);
|
||||
if (header.StartsWith("DDS"))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static bool IsRcf(byte[] Bytes)
|
||||
{
|
||||
MemoryStream Data = ByteToStream(Bytes);
|
||||
String header = ReadString(Data, 5);
|
||||
if (header.StartsWith("RCSF"))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static bool IsGim(byte[] Bytes)
|
||||
{
|
||||
MemoryStream Data = ByteToStream(Bytes);
|
||||
String header = ReadString(Data, 4);
|
||||
if (header.StartsWith("MIG"))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static bool IsZlib(byte[] Bytes)
|
||||
{
|
||||
if (Bytes[0] == 0x78)
|
||||
{
|
||||
if (Bytes[1] == 0x01)
|
||||
return true;
|
||||
if (Bytes[1] == 0x9C)
|
||||
return true;
|
||||
if (Bytes[1] == 0xDA)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static bool IsImage(byte[] Bytes)
|
||||
{
|
||||
try
|
||||
{
|
||||
GetBitmap(Bytes);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static Bitmap GetBitmap(byte[] BitmapBytes)
|
||||
{
|
||||
MemoryStream ms = ByteToStream(BitmapBytes);
|
||||
Bitmap bmp = new Bitmap(ms);
|
||||
ms.Dispose();
|
||||
return bmp;
|
||||
}
|
||||
|
||||
public static String ReadStringAt(Stream ms, int location)
|
||||
{
|
||||
long ogPos = ms.Position;
|
||||
ms.Seek(location, SeekOrigin.Begin);
|
||||
String str = ReadString(ms);
|
||||
ms.Seek(ogPos, SeekOrigin.Begin);
|
||||
return str;
|
||||
}
|
||||
|
||||
public static int ReadIntAt(Stream ms, int location)
|
||||
{
|
||||
BinaryReader BinReader = new BinaryReader(ms);
|
||||
long ogPos = ms.Position;
|
||||
ms.Seek(location, SeekOrigin.Begin);
|
||||
int i = BinReader.ReadInt32();
|
||||
ms.Seek(ogPos, SeekOrigin.Begin);
|
||||
return i;
|
||||
}
|
||||
|
||||
public static int ReadInt(Stream ms)
|
||||
{
|
||||
BinaryReader BinReader = new BinaryReader(ms);
|
||||
int i = BinReader.ReadInt32();
|
||||
return i;
|
||||
}
|
||||
|
||||
public static int ReadBigEndainIntAt(Stream ms, int location)
|
||||
{
|
||||
long ogPos = ms.Position;
|
||||
ms.Seek(location, SeekOrigin.Begin);
|
||||
int i = ReadBigEndainInt(ms);
|
||||
ms.Seek(ogPos, SeekOrigin.Begin);
|
||||
return i;
|
||||
}
|
||||
|
||||
public static int ReadBigEndainInt(Stream ms)
|
||||
{
|
||||
byte[] IntBytes = new byte[4];
|
||||
ms.Read(IntBytes, 0x00, 4);
|
||||
IntBytes = IntBytes.Reverse().ToArray();
|
||||
int i = BitConverter.ToInt32(IntBytes, 0x00);
|
||||
return i;
|
||||
}
|
||||
|
||||
public static String ReadString(Stream ms, int limit = -1)
|
||||
{
|
||||
int i = 0xFF;
|
||||
int counter = 0;
|
||||
|
||||
MemoryStream StringStream = new MemoryStream();
|
||||
|
||||
do
|
||||
{
|
||||
i = ms.ReadByte();
|
||||
if (i == 0 || counter == limit)
|
||||
break;
|
||||
StringStream.WriteByte((byte)i);
|
||||
counter += 1;
|
||||
}
|
||||
while (true);
|
||||
|
||||
byte[] StringData = StringStream.ToArray();
|
||||
|
||||
String str = Encoding.UTF8.GetString(StringData);
|
||||
|
||||
return str;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Binary file not shown.
After Width: | Height: | Size: 264 KiB |
Loading…
Reference in New Issue