Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev/heckerpowered #19

Merged
merged 5 commits into from
Aug 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions .NET Linker.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.0.31903.59
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{EF9C24DA-47D6-42EA-BEE6-78BADDD2174C}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = ".NET Linker", "src\.NET Linker\.NET Linker.csproj", "{C5790079-DC23-4ABF-8E73-72DEAC881F8D}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{C5790079-DC23-4ABF-8E73-72DEAC881F8D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C5790079-DC23-4ABF-8E73-72DEAC881F8D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C5790079-DC23-4ABF-8E73-72DEAC881F8D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C5790079-DC23-4ABF-8E73-72DEAC881F8D}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{C5790079-DC23-4ABF-8E73-72DEAC881F8D} = {EF9C24DA-47D6-42EA-BEE6-78BADDD2174C}
EndGlobalSection
EndGlobal
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,7 @@ CMakeFiles/
CMakeScripts/
cmake_install.cmake
CMakeLists.txt
CMakeCache.txt
CMakeCache.txt

src/.NET Linker/bin
src/.NET Linker/obj
3 changes: 3 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,8 @@ xmake -y
xmake f -p windows -a x64 -m release
xmake -y

xmake f -p linux -a x86_64 -m release
xmake -y

# Restore
xmake f -p macosx -a arm64 -m debug
16 changes: 16 additions & 0 deletions src/.NET Linker/.NET Linker.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<RootNamespace>Jvav</RootNamespace>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<PublishSingleFile>true</PublishSingleFile>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Mono.Cecil" Version="0.9.4" />
</ItemGroup>

</Project>
20 changes: 20 additions & 0 deletions src/.NET Linker/Linker/LinkingReader.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using System;
using System.Text;

namespace Jvav.Linker;

public class LinkingReader(Stream inputStream)
{
private readonly BinaryReader reader = new(inputStream);
public Stream InputStream { get; } = inputStream;

public ulong ReadLinkerVersion()
{
return reader.ReadUInt64();
}

public V1.Linking LinkV1()
{
return new V1.Linking(InputStream);
}
}
10 changes: 10 additions & 0 deletions src/.NET Linker/Linker/V1/Identifier.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
namespace Jvav.Linker.V1;

enum Identifier : byte
{
Function,
Variable,
Type,
Instruction,
String
}
223 changes: 223 additions & 0 deletions src/.NET Linker/Linker/V1/InternalOpCodes.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,223 @@
namespace Jvav.Linker.V1;

enum InternalOpCodes
{
Add = 0x58,
AddOvf = 0xD6,
AddOvfUn = 0xD7,
And = 0x5F,
Arglist = 0xFE00,
Beq = 0x3B,
BeqS = 0x2E,
Bge = 0x3C,
BgeS = 0x2F,
BgeUn = 0x41,
BgeUnS = 0x34,
Bgt = 0x3D,
BgtS = 0x30,
BgtUn = 0x42,
BgtUnS = 0x35,
Ble = 0x3E,
BleS = 0x31,
BleUn = 0x43,
BleUnS = 0x36,
Blt = 0x3F,
BltS = 0x32,
BltUn = 0x44,
BltUnS = 0x37,
BneUn = 0x40,
BneUnS = 0x33,
Box = 0x8C,
Br = 0x38,
BrS = 0x2B,
Break = 0x01,
Brfalse = 0x39,
BrfalseS = 0x2C,
Brtrue = 0x3A,
BrtrueS = 0x2D,
Call = 0x28,
Calli = 0x29,
Callvirt = 0x6F,
Castclass = 0x74,
Ceq = 0xFF01,
Cgt = 0xFE02,
CgtUn = 0xFE03,
Ckfinite = 0xC3,
Clt = 0xFE04,
CltUn = 0xFE05,
Constrained = 0xFF16,
ConvI = 0xD3,
ConvI1 = 0x67,
ConvI2 = 0x68,
ConvI4 = 0x69,
ConvI8 = 0x6A,
ConvOvfI = 0xD4,
ConvOvfIUn = 0x8A,
ConvOvfI1 = 0xB3,
ConvOvfI1Un = 0x82,
ConvOvfI2 = 0xB5,
ConvOvfI2Un = 0x83,
ConvOvfI4 = 0xB7,
ConvOvfI4Un = 0x84,
ConvOvfI8 = 0xB9,
ConvOvfI8Un = 0x85,
ConvOvfU = 0xD5,
ConvOvfUUn = 0x8B,
ConvOvfU1 = 0xB4,
ConvOvfU1Un = 0x86,
ConvOvfU2 = 0xB6,
ConvOvfU2Un = 0x87,
ConvOvfU4 = 0xB8,
ConvOvfu4Un = 0x88,
ConvOvfU8 = 0xBA,
ConvOvfU8Un = 0x89,
ConvRUn = 0x76,
ConvR4 = 0x6B,
ConvR8 = 0x6C,
ConvU = 0xE0,
ConvU1 = 0xD2,
ConvU2 = 0xD1,
ConvU4 = 0x6D,
ConvU8 = 0x6E,
Cpblk = 0xFE17,
Cpobj = 0x70,
Div = 0x5B,
DivUn = 0x5C,
Dup = 0x25,
Endfilter = 0xFE11,
Endfinally = 0xDC,
Initblk = 0xFE18,
Initobj = 0xFE15,
Isinst = 0x75,
jmp = 0x27,
Ldarg = 0xFE09,
Ldarg0 = 0x02,
Ldarg1 = 0x03,
Ldarg2 = 0x04,
Ldarg3 = 0x05,
LdargS = 0x0E,
Ldarga = 0xFE0A,
LdargaS = 0x0F,
LdcI4 = 0x20,
LcdI40 = 0x16,
LdcI41 = 0x17,
LdcI42 = 0x18,
LdcI43 = 0x19,
LdcI44 = 0x1A,
LdcI45 = 0x1B,
LdcI46 = 0x1C,
LdcI47 = 0x1D,
LdcI48 = 0x1E,
LdcI4M1 = 0x15,
LdcI4S = 0x1F,
LdcI8 = 0x21,
LdcR4 = 0x22,
LdcR8 = 0x23,
Ldelem = 0xA3,
LdelemI = 0x97,
LdelemI1 = 0x90,
LdelemI2 = 0x92,
LdelemI4 = 0x94,
LdelemI8 = 0x96,
LdelemR4 = 0x98,
LdelemR8 = 0x99,
LdelemRef = 0x9A,
LdelemU1 = 0x91,
LdelemU2 = 0x93,
LdelemU4 = 0x95,
Ldelema = 0x8F,
Ldfld = 0x7B,
Ldflda = 0x7C,
Ldftn = 0xFF06,
LdindI = 0x4D,
LdindI1 = 0x46,
LdindI2 = 0x48,
LdindI4 = 0x4A,
LdindI8 = 0x4C,
LdindR4 = 0x4E,
LdindR8 = 0x4F,
LdindRef = 0x50,
LdindU1 = 0x47,
LdindU2 = 0x49,
LdindU4 = 0x4B,
Ldlen = 0x8E,
Ldloc = 0xFE0C,
Ldloc0 = 0x06,
Ldloc1 = 0x07,
Ldloc2 = 0x08,
Ldloc3 = 0x09,
LdlocS = 0x11,
Ldloca = 0xFE0D,
LdlocaS = 0x12,
Ldnull = 0x14,
Ldobj = 0x71,
Ldsfld = 0x7E,
Ldsflda = 0x7F,
Ldstr = 0x72,
Ldtoken = 0xD0,
Ldvirtftn = 0xFF07,
Leave = 0xDD,
LeaveS = 0xDE,
Localloc = 0xFE0F,
Mkrefany = 0xC6,
Mul = 0x5A,
MulOvf = 0xD8,
MulOvfUn = 0xD9,
Neg = 0x65,
Newarr = 0x8D,
Newobj = 0x73,
Nop = 0x00,
Not = 0x66,
Or = 0x60,
Pop = 0x26,
Readonly = 0xFE1E,
Refanytype = 0xFF1D,
Refanyval = 0xC2,
Rem = 0x5D,
RemUn = 0x5E,
Ret = 0x2A,
Rethrow = 0xFF1A,
Shl = 0x62,
Shr = 0x63,
ShrUn = 0x64,
Sizeof = 0xFE1C,
Starg = 0xFE0B,
StargS = 0x10,
Stelem = 0xA4,
StelemI = 0x9B,
StelemI1 = 0x9C,
StelemI2 = 0x9D,
StelemI4 = 0x9E,
StelemI8 = 0x9F,
StelemR4 = 0xA0,
StelemR8 = 0xA1,
StelemRef = 0xA2,
Stfld = 0x7D,
StindI = 0xDF,
StindI1 = 0x52,
StintI2 = 0x53,
StindI4 = 0x54,
StindI8 = 0x55,
StindR4 = 0x56,
StintR8 = 0x57,
StindRef = 0x51,
Stloc = 0xFF0E,
Stloc0 = 0x0A,
Stloc1 = 0x0B,
Stloc2 = 0x0C,
Stloc3 = 0x0D,
StlocS = 0x13,
Stobj = 0x81,
Stsfld = 0x80,
Sub = 0x59,
SubOvf = 0xDA,
SubOvfUn = 0xDB,
Switch = 0x45,
Tailcall = 0xFF14,
Throw = 0x7A,
Unaligned = 0xFE12,
Unbox = 0x79,
UnboxAny = 0xA5,
Volatile = 0xFE13,
Xor = 0x61,
};
Loading