Skip to content
This repository has been archived by the owner on Sep 13, 2024. It is now read-only.

Commit

Permalink
release ready
Browse files Browse the repository at this point in the history
  • Loading branch information
Umbra999 committed Jul 4, 2023
1 parent 16adb50 commit d6a2171
Show file tree
Hide file tree
Showing 1,147 changed files with 134 additions and 172,104 deletions.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified .vs/UEDumpParser/v17/.suo
Binary file not shown.
7 changes: 6 additions & 1 deletion UEDumpParser/Boot.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
namespace UEDumpParser
using UEDumpParser.Wrappers;

namespace UEDumpParser
{
internal class Boot
{
Expand Down Expand Up @@ -39,6 +41,9 @@ public static void Main()
WriteEndLines(StructOffsetsFile);

WriteEndLines(EnumOffsetsFile);

Logger.Log("Dump successfully parsed");
Console.ReadLine();
}

private static void WriteStartLines(string path, string ClassName)
Expand Down
77 changes: 77 additions & 0 deletions UEDumpParser/ConventionHelper.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
namespace UEDumpParser
{
internal class ConventionHelper
{
public static string GetManagedType(string Type)
{
switch (Type)
{
case "uint8_t":
return "byte";

case "int8_t":
return "sbyte";

case "uint16_t":
return "ushort";

case "int16_t":
return "short";

case "uint32_t":
return "uint";

case "int32_t":
return "int";

case "uint64_t":
return "ulong";

case "int64_t":
return "long";

case "intptr_t":
return "Intptr";

case "uintptr_t":
return "UIntPtr";

case "size_t": // could also be a UIntPtr/UInt/Int ig
return "int";

case "ptrdiff_t": // could also be a IntPtr/Int ig
return "int";
}

if (IsManagedType(Type)) return Type;

return null;
}

public static bool IsManagedType(string Type)
{
if (Type == "byte") return true;
if (Type == "sbyte") return true;
if (Type == "ushort") return true;
if (Type == "short") return true;
if (Type == "uint") return true;
if (Type == "int") return true;
if (Type == "ulong") return true;
if (Type == "long") return true;
if (Type == "IntPtr") return true;
if (Type == "UIntPtr") return true;
if (Type == "float") return true;
if (Type == "double") return true;
if (Type == "decimal") return true;
if (Type == "char") return true;
if (Type == "string") return true;
if (Type == "bool") return true;
if (Type == "object") return true;

if (Type == "struct") return true;

return false;
}

}
}
266 changes: 17 additions & 249 deletions UEDumpParser/CppToSharp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,249 +55,28 @@ public static string[] ConvertClass(string path)
{
string[] splitted = Line.Split(" ");

string Type = splitted[0].Trim();

switch (Type)
string Type = ConventionHelper.GetManagedType(splitted[0].Trim());
if (Type == null)
{
case "struct":
{
string propName = splitted[1].Trim();
int propIndex = Line.IndexOf(propName);
string propLine = Line.Substring(propIndex).Replace(";", "");
string[] split = propLine.Split(" ");

string Name = Utils.SanitizeString(split[split.Length - 3]);

if (!Utils.IsStringValid(Name)) continue;

string Offset = split[split.Length - 1].Split("(")[0];
string OffsetType = Utils.IsByte(Offset) ? "byte" : Utils.IsUshort(Offset) ? "ushort" : "uint";
string StructType = split[0];

string prop = $"public const {OffsetType} {Name} = {Offset}; // {Type} ({StructType})";
Converted.Add(" " + prop);
}
break;

case "bool":
{
string propName = splitted[1].Trim();
int propIndex = Line.IndexOf(propName);
string propLine = Line.Substring(propIndex).Replace(";", "");
string[] split = propLine.Split(" ");

string Name = Utils.SanitizeString(split[split.Length - 3]);

if (!Utils.IsStringValid(Name)) continue;

string Offset = split[split.Length - 1].Split("(")[0];
string OffsetType = Utils.IsByte(Offset) ? "byte" : Utils.IsUshort(Offset) ? "ushort" : "uint";

string prop = $"public const {OffsetType} {Name} = {Offset}; // {Type}";
Converted.Add(" " + prop);
}
break;

case "char":
{
string propName = splitted[1].Trim();
int propIndex = Line.IndexOf(propName);
string propLine = Line.Substring(propIndex).Replace(";", "");
string[] split = propLine.Split(" ");

string Name = Utils.SanitizeString(split[split.Length - 3]);

if (!Utils.IsStringValid(Name)) continue;

string Offset = split[split.Length - 1].Split("(")[0];
string OffsetType = Utils.IsByte(Offset) ? "byte" : Utils.IsUshort(Offset) ? "ushort" : "uint";

string prop = $"public const {OffsetType} {Name} = {Offset}; // {Type}";
Converted.Add(" " + prop);
}
break;

case "float":
{
string propName = splitted[1].Trim();
int propIndex = Line.IndexOf(propName);
string propLine = Line.Substring(propIndex).Replace(";", "");
string[] split = propLine.Split(" ");

string Name = Utils.SanitizeString(split[split.Length - 3]);

if (!Utils.IsStringValid(Name)) continue;

string Offset = split[split.Length - 1].Split("(")[0];
string OffsetType = Utils.IsByte(Offset) ? "byte" : Utils.IsUshort(Offset) ? "ushort" : "uint";

string prop = $"public const {OffsetType} {Name} = {Offset}; // {Type}";
Converted.Add(" " + prop);
}
break;

case "void":
{
// not supported yet
}
break;

case "int32_t":
{
string propName = splitted[1].Trim();
int propIndex = Line.IndexOf(propName);
string propLine = Line.Substring(propIndex).Replace(";", "");
string[] split = propLine.Split(" ");

string Name = Utils.SanitizeString(split[split.Length - 3]);

if (!Utils.IsStringValid(Name)) continue;

string Offset = split[split.Length - 1].Split("(")[0];
string OffsetType = Utils.IsByte(Offset) ? "byte" : Utils.IsUshort(Offset) ? "ushort" : "uint";

string prop = $"public const {OffsetType} {Name} = {Offset}; // {Type}";
Converted.Add(" " + prop);
}
break;

case "uint32_t":
{
string propName = splitted[1].Trim();
int propIndex = Line.IndexOf(propName);
string propLine = Line.Substring(propIndex).Replace(";", "");
string[] split = propLine.Split(" ");

string Name = Utils.SanitizeString(split[split.Length - 3]);

if (!Utils.IsStringValid(Name)) continue;

string Offset = split[split.Length - 1].Split("(")[0];
string OffsetType = Utils.IsByte(Offset) ? "byte" : Utils.IsUshort(Offset) ? "ushort" : "uint";

string prop = $"public const {OffsetType} {Name} = {Offset}; // {Type}";
Converted.Add(" " + prop);
}
break;

case "uint16_t":
{
string propName = splitted[1].Trim();
int propIndex = Line.IndexOf(propName);
string propLine = Line.Substring(propIndex).Replace(";", "");
string[] split = propLine.Split(" ");

string Name = Utils.SanitizeString(split[split.Length - 3]);

if (!Utils.IsStringValid(Name)) continue;

string Offset = split[split.Length - 1].Split("(")[0];
string OffsetType = Utils.IsByte(Offset) ? "byte" : Utils.IsUshort(Offset) ? "ushort" : "uint";

string prop = $"public const {OffsetType} {Name} = {Offset}; // {Type}";
Converted.Add(" " + prop);
}
break;

case "int8_t":
{
string propName = splitted[1].Trim();
int propIndex = Line.IndexOf(propName);
string propLine = Line.Substring(propIndex).Replace(";", "");
string[] split = propLine.Split(" ");

string Name = Utils.SanitizeString(split[split.Length - 3]);

if (!Utils.IsStringValid(Name)) continue;

string Offset = split[split.Length - 1].Split("(")[0];
string OffsetType = Utils.IsByte(Offset) ? "byte" : Utils.IsUshort(Offset) ? "ushort" : "uint";

string prop = $"public const {OffsetType} {Name} = {Offset}; // {Type}";
Converted.Add(" " + prop);
}
break;

case "int16_t":
{
string propName = splitted[1].Trim();
int propIndex = Line.IndexOf(propName);
string propLine = Line.Substring(propIndex).Replace(";", "");
string[] split = propLine.Split(" ");

string Name = Utils.SanitizeString(split[split.Length - 3]);

if (!Utils.IsStringValid(Name)) continue;

string Offset = split[split.Length - 1].Split("(")[0];
string OffsetType = Utils.IsByte(Offset) ? "byte" : Utils.IsUshort(Offset) ? "ushort" : "uint";

string prop = $"public const {OffsetType} {Name} = {Offset}; // {Type}";
Converted.Add(" " + prop);
}
break;

case "int64_t":
{
string propName = splitted[1].Trim();
int propIndex = Line.IndexOf(propName);
string propLine = Line.Substring(propIndex).Replace(";", "");
string[] split = propLine.Split(" ");

string Name = Utils.SanitizeString(split[split.Length - 3]);

if (!Utils.IsStringValid(Name)) continue;

string Offset = split[split.Length - 1].Split("(")[0];
string OffsetType = Utils.IsByte(Offset) ? "byte" : Utils.IsUshort(Offset) ? "ushort" : "uint";

string prop = $"public const {OffsetType} {Name} = {Offset}; // {Type}";
Converted.Add(" " + prop);
}
break;

case "uint64_t":
{
string propName = splitted[1].Trim();
int propIndex = Line.IndexOf(propName);
string propLine = Line.Substring(propIndex).Replace(";", "");
string[] split = propLine.Split(" ");

string Name = Utils.SanitizeString(split[split.Length - 3]);

if (!Utils.IsStringValid(Name)) continue;

string Offset = split[split.Length - 1].Split("(")[0];
string OffsetType = Utils.IsByte(Offset) ? "byte" : Utils.IsUshort(Offset) ? "ushort" : "uint";

string prop = $"public const {OffsetType} {Name} = {Offset}; // {Type}";
Converted.Add(" " + prop);
}
break;

case "double":
{
string propName = splitted[1].Trim();
int propIndex = Line.IndexOf(propName);
string propLine = Line.Substring(propIndex).Replace(";", "");
string[] split = propLine.Split(" ");
Logger.LogWarning($"Unsupported type: {splitted[0].Trim()}");
continue;
}

string Name = Utils.SanitizeString(split[split.Length - 3]);
string propName = splitted[1].Trim();
int propIndex = Line.IndexOf(propName);
string propLine = Line.Substring(propIndex).Replace(";", "");
string[] split = propLine.Split(" ");

if (!Utils.IsStringValid(Name)) continue;
string Name = Utils.SanitizeString(split[split.Length - 3]);

string Offset = split[split.Length - 1].Split("(")[0];
string OffsetType = Utils.IsByte(Offset) ? "byte" : Utils.IsUshort(Offset) ? "ushort" : "uint";
if (!Utils.IsStringValid(Name)) continue;

string prop = $"public const {OffsetType} {Name} = {Offset}; // {Type}";
Converted.Add(" " + prop);
}
break;
string Offset = split[split.Length - 1].Split("(")[0];
string OffsetType = Utils.IsByte(Offset) ? "byte" : Utils.IsUshort(Offset) ? "ushort" : "uint";
string StructType = split[0];

default:
Logger.LogWarning($"Unsupported type: {Type}");
break;
}
string prop = $"public const {OffsetType} {Name} = {Offset}; // {Type} ({StructType})";
Converted.Add(" " + prop);
}
}

Expand All @@ -316,18 +95,7 @@ public static void ConvertEnum(string Line)

if (splitted.Length != 6) return;

string Type = "int";
switch (splitted[4].Trim())
{
case "uint8_t":
Type = "byte";
break;

default:
Logger.LogWarning($"Unsupported type: {splitted[4].Trim()}");
break;
}

string Type = ConventionHelper.GetManagedType(splitted[4].Trim());
string classInit = $"public enum {splitted[2]} : {Type}";
Converted.Add(" " + classInit);

Expand Down
Loading

0 comments on commit d6a2171

Please sign in to comment.