[Add] FishNet

This commit is contained in:
2026-03-30 20:11:57 +07:00
parent ee793a3361
commit c22c08753a
1797 changed files with 197950 additions and 1 deletions
@@ -0,0 +1,30 @@
<Project>
<PropertyGroup>
<EnableDefaultItems>false</EnableDefaultItems>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<IsPackable>false</IsPackable>
<Configurations>Debug;Release</Configurations>
<PublicSign Condition=" '$(OS)' != 'Windows_NT' ">true</PublicSign>
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>$(MSBuildThisFileDirectory)\cecil.snk</AssemblyOriginatorKeyFile>
<DefineConstants Condition=" '$(TargetFramework)' == 'netstandard2.0' OR '$(TargetFramework)' == 'netcoreapp2.1' ">$(DefineConstants);NET_CORE</DefineConstants>
<RootNamespace></RootNamespace>
</PropertyGroup>
<PropertyGroup Condition=" '$(TargetFramework)' == 'net40' ">
<DisableImplicitFrameworkReferences>true</DisableImplicitFrameworkReferences>
</PropertyGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'net40' ">
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies.net40" Version="1.0.0" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0" PrivateAssets="All" />
</ItemGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'net40' ">
<Reference Include="System" />
<Reference Include="System.Core" />
</ItemGroup>
<PropertyGroup>
<CecilOverrides Condition="'$(CecilOverrides)' == ''">$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), Mono.Cecil.overrides))\Mono.Cecil.overrides</CecilOverrides>
</PropertyGroup>
<Import Project="$(CecilOverrides)" Condition="Exists('$(CecilOverrides)')" />
</Project>
@@ -0,0 +1,14 @@
fileFormatVersion: 2
guid: c3a066bef0608d24987201601e20a905
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 207815
packageName: 'FishNet: Networking Evolved'
packageVersion: 4.6.22R
assetPath: Assets/FishNet/CodeGenerating/cecil-0.11.4/Directory.Build.props
uploadId: 866910
@@ -0,0 +1,21 @@
Copyright (c) 2008 - 2015 Jb Evain
Copyright (c) 2008 - 2011 Novell, Inc.
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,14 @@
fileFormatVersion: 2
guid: 65323af257ddec3409ed36503b853604
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 207815
packageName: 'FishNet: Networking Evolved'
packageVersion: 4.6.22R
assetPath: Assets/FishNet/CodeGenerating/cecil-0.11.4/LICENSE.txt
uploadId: 866910
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 23bfd4374c8423f4ebf6716985b8c720
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,235 @@
//
// Author:
// Jb Evain (jbevain@gmail.com)
//
// Copyright (c) 2008 - 2015 Jb Evain
// Copyright (c) 2008 - 2011 Novell, Inc.
//
// Licensed under the MIT/X11 license.
//
namespace MonoFN.Cecil.Cil
{
public enum Code
{
Nop,
Break,
Ldarg_0,
Ldarg_1,
Ldarg_2,
Ldarg_3,
Ldloc_0,
Ldloc_1,
Ldloc_2,
Ldloc_3,
Stloc_0,
Stloc_1,
Stloc_2,
Stloc_3,
Ldarg_S,
Ldarga_S,
Starg_S,
Ldloc_S,
Ldloca_S,
Stloc_S,
Ldnull,
Ldc_I4_M1,
Ldc_I4_0,
Ldc_I4_1,
Ldc_I4_2,
Ldc_I4_3,
Ldc_I4_4,
Ldc_I4_5,
Ldc_I4_6,
Ldc_I4_7,
Ldc_I4_8,
Ldc_I4_S,
Ldc_I4,
Ldc_I8,
Ldc_R4,
Ldc_R8,
Dup,
Pop,
Jmp,
Call,
Calli,
Ret,
Br_S,
Brfalse_S,
Brtrue_S,
Beq_S,
Bge_S,
Bgt_S,
Ble_S,
Blt_S,
Bne_Un_S,
Bge_Un_S,
Bgt_Un_S,
Ble_Un_S,
Blt_Un_S,
Br,
Brfalse,
Brtrue,
Beq,
Bge,
Bgt,
Ble,
Blt,
Bne_Un,
Bge_Un,
Bgt_Un,
Ble_Un,
Blt_Un,
Switch,
Ldind_I1,
Ldind_U1,
Ldind_I2,
Ldind_U2,
Ldind_I4,
Ldind_U4,
Ldind_I8,
Ldind_I,
Ldind_R4,
Ldind_R8,
Ldind_Ref,
Stind_Ref,
Stind_I1,
Stind_I2,
Stind_I4,
Stind_I8,
Stind_R4,
Stind_R8,
Add,
Sub,
Mul,
Div,
Div_Un,
Rem,
Rem_Un,
And,
Or,
Xor,
Shl,
Shr,
Shr_Un,
Neg,
Not,
Conv_I1,
Conv_I2,
Conv_I4,
Conv_I8,
Conv_R4,
Conv_R8,
Conv_U4,
Conv_U8,
Callvirt,
Cpobj,
Ldobj,
Ldstr,
Newobj,
Castclass,
Isinst,
Conv_R_Un,
Unbox,
Throw,
Ldfld,
Ldflda,
Stfld,
Ldsfld,
Ldsflda,
Stsfld,
Stobj,
Conv_Ovf_I1_Un,
Conv_Ovf_I2_Un,
Conv_Ovf_I4_Un,
Conv_Ovf_I8_Un,
Conv_Ovf_U1_Un,
Conv_Ovf_U2_Un,
Conv_Ovf_U4_Un,
Conv_Ovf_U8_Un,
Conv_Ovf_I_Un,
Conv_Ovf_U_Un,
Box,
Newarr,
Ldlen,
Ldelema,
Ldelem_I1,
Ldelem_U1,
Ldelem_I2,
Ldelem_U2,
Ldelem_I4,
Ldelem_U4,
Ldelem_I8,
Ldelem_I,
Ldelem_R4,
Ldelem_R8,
Ldelem_Ref,
Stelem_I,
Stelem_I1,
Stelem_I2,
Stelem_I4,
Stelem_I8,
Stelem_R4,
Stelem_R8,
Stelem_Ref,
Ldelem_Any,
Stelem_Any,
Unbox_Any,
Conv_Ovf_I1,
Conv_Ovf_U1,
Conv_Ovf_I2,
Conv_Ovf_U2,
Conv_Ovf_I4,
Conv_Ovf_U4,
Conv_Ovf_I8,
Conv_Ovf_U8,
Refanyval,
Ckfinite,
Mkrefany,
Ldtoken,
Conv_U2,
Conv_U1,
Conv_I,
Conv_Ovf_I,
Conv_Ovf_U,
Add_Ovf,
Add_Ovf_Un,
Mul_Ovf,
Mul_Ovf_Un,
Sub_Ovf,
Sub_Ovf_Un,
Endfinally,
Leave,
Leave_S,
Stind_I,
Conv_U,
Arglist,
Ceq,
Cgt,
Cgt_Un,
Clt,
Clt_Un,
Ldftn,
Ldvirtftn,
Ldarg,
Ldarga,
Starg,
Ldloc,
Ldloca,
Stloc,
Localloc,
Endfilter,
Unaligned,
Volatile,
Tail,
Initobj,
Constrained,
Cpblk,
Initblk,
No,
Rethrow,
Sizeof,
Refanytype,
Readonly
}
}
@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 2619210c5ef352b4aac70d8e5fab7a43
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 207815
packageName: 'FishNet: Networking Evolved'
packageVersion: 4.6.22R
assetPath: Assets/FishNet/CodeGenerating/cecil-0.11.4/Mono.Cecil.Cil/Code.cs
uploadId: 866910
@@ -0,0 +1,675 @@
//
// Author:
// Jb Evain (jbevain@gmail.com)
//
// Copyright (c) 2008 - 2015 Jb Evain
// Copyright (c) 2008 - 2011 Novell, Inc.
//
// Licensed under the MIT/X11 license.
//
using MonoFN.Cecil.PE;
using MonoFN.Collections.Generic;
using System;
namespace MonoFN.Cecil.Cil
{
internal sealed class CodeReader : BinaryStreamReader
{
internal readonly MetadataReader reader;
private int start;
private MethodDefinition method;
private MethodBody body;
private int Offset
{
get { return Position - start; }
}
public CodeReader(MetadataReader reader) : base(reader.image.Stream.value)
{
this.reader = reader;
}
public int MoveTo(MethodDefinition method)
{
this.method = method;
reader.context = method;
int position = Position;
Position = (int)reader.image.ResolveVirtualAddress((uint)method.RVA);
return position;
}
public void MoveBackTo(int position)
{
reader.context = null;
Position = position;
}
public MethodBody ReadMethodBody(MethodDefinition method)
{
int position = MoveTo(method);
body = new(method);
ReadMethodBody();
MoveBackTo(position);
return body;
}
public int ReadCodeSize(MethodDefinition method)
{
int position = MoveTo(method);
int code_size = ReadCodeSize();
MoveBackTo(position);
return code_size;
}
private int ReadCodeSize()
{
byte flags = ReadByte();
switch (flags & 0x3)
{
case 0x2: // tiny
return flags >> 2;
case 0x3: // fat
Advance(-1 + 2 + 2); // go back, 2 bytes flags, 2 bytes stack size
return (int)ReadUInt32();
default:
throw new InvalidOperationException();
}
}
private void ReadMethodBody()
{
byte flags = ReadByte();
switch (flags & 0x3)
{
case 0x2: // tiny
body.code_size = flags >> 2;
body.MaxStackSize = 8;
ReadCode();
break;
case 0x3: // fat
Advance(-1);
ReadFatMethod();
break;
default:
throw new InvalidOperationException();
}
ISymbolReader symbol_reader = reader.module.symbol_reader;
if (symbol_reader != null && method.debug_info == null)
method.debug_info = symbol_reader.Read(method);
if (method.debug_info != null)
ReadDebugInfo();
}
private void ReadFatMethod()
{
ushort flags = ReadUInt16();
body.max_stack_size = ReadUInt16();
body.code_size = (int)ReadUInt32();
body.local_var_token = new(ReadUInt32());
body.init_locals = (flags & 0x10) != 0;
if (body.local_var_token.RID != 0)
body.variables = ReadVariables(body.local_var_token);
ReadCode();
if ((flags & 0x8) != 0)
ReadSection();
}
public VariableDefinitionCollection ReadVariables(MetadataToken local_var_token)
{
int position = reader.position;
VariableDefinitionCollection variables = reader.ReadVariables(local_var_token, method);
reader.position = position;
return variables;
}
private void ReadCode()
{
start = Position;
int code_size = body.code_size;
if (code_size < 0 || Length <= (uint)(code_size + Position))
code_size = 0;
int end = start + code_size;
Collection<Instruction> instructions = body.instructions = new InstructionCollection(method, (code_size + 1) / 2);
while (Position < end)
{
int offset = Position - start;
OpCode opcode = ReadOpCode();
Instruction current = new(offset, opcode);
if (opcode.OperandType != OperandType.InlineNone)
current.operand = ReadOperand(current);
instructions.Add(current);
}
ResolveBranches(instructions);
}
private OpCode ReadOpCode()
{
byte il_opcode = ReadByte();
return il_opcode != 0xfe ? OpCodes.OneByteOpCode[il_opcode] : OpCodes.TwoBytesOpCode[ReadByte()];
}
private object ReadOperand(Instruction instruction)
{
switch (instruction.opcode.OperandType)
{
case OperandType.InlineSwitch:
int length = ReadInt32();
int base_offset = Offset + 4 * length;
int[] branches = new int [length];
for (int i = 0; i < length; i++)
branches[i] = base_offset + ReadInt32();
return branches;
case OperandType.ShortInlineBrTarget:
return ReadSByte() + Offset;
case OperandType.InlineBrTarget:
return ReadInt32() + Offset;
case OperandType.ShortInlineI:
if (instruction.opcode == OpCodes.Ldc_I4_S)
return ReadSByte();
return ReadByte();
case OperandType.InlineI:
return ReadInt32();
case OperandType.ShortInlineR:
return ReadSingle();
case OperandType.InlineR:
return ReadDouble();
case OperandType.InlineI8:
return ReadInt64();
case OperandType.ShortInlineVar:
return GetVariable(ReadByte());
case OperandType.InlineVar:
return GetVariable(ReadUInt16());
case OperandType.ShortInlineArg:
return GetParameter(ReadByte());
case OperandType.InlineArg:
return GetParameter(ReadUInt16());
case OperandType.InlineSig:
return GetCallSite(ReadToken());
case OperandType.InlineString:
return GetString(ReadToken());
case OperandType.InlineTok:
case OperandType.InlineType:
case OperandType.InlineMethod:
case OperandType.InlineField:
return reader.LookupToken(ReadToken());
default:
throw new NotSupportedException();
}
}
public string GetString(MetadataToken token)
{
return reader.image.UserStringHeap.Read(token.RID);
}
public ParameterDefinition GetParameter(int index)
{
return body.GetParameter(index);
}
public VariableDefinition GetVariable(int index)
{
return body.GetVariable(index);
}
public CallSite GetCallSite(MetadataToken token)
{
return reader.ReadCallSite(token);
}
private void ResolveBranches(Collection<Instruction> instructions)
{
Instruction[] items = instructions.items;
int size = instructions.size;
for (int i = 0; i < size; i++)
{
Instruction instruction = items[i];
switch (instruction.opcode.OperandType)
{
case OperandType.ShortInlineBrTarget:
case OperandType.InlineBrTarget:
instruction.operand = GetInstruction((int)instruction.operand);
break;
case OperandType.InlineSwitch:
int[] offsets = (int[])instruction.operand;
Instruction[] branches = new Instruction [offsets.Length];
for (int j = 0; j < offsets.Length; j++)
branches[j] = GetInstruction(offsets[j]);
instruction.operand = branches;
break;
}
}
}
private Instruction GetInstruction(int offset)
{
return GetInstruction(body.Instructions, offset);
}
private static Instruction GetInstruction(Collection<Instruction> instructions, int offset)
{
int size = instructions.size;
Instruction[] items = instructions.items;
if (offset < 0 || offset > items[size - 1].offset)
return null;
int min = 0;
int max = size - 1;
while (min <= max)
{
int mid = min + (max - min) / 2;
Instruction instruction = items[mid];
int instruction_offset = instruction.offset;
if (offset == instruction_offset)
return instruction;
if (offset < instruction_offset)
max = mid - 1;
else
min = mid + 1;
}
return null;
}
private void ReadSection()
{
Align(4);
const byte fat_format = 0x40;
const byte more_sects = 0x80;
byte flags = ReadByte();
if ((flags & fat_format) == 0)
ReadSmallSection();
else
ReadFatSection();
if ((flags & more_sects) != 0)
ReadSection();
}
private void ReadSmallSection()
{
int count = ReadByte() / 12;
Advance(2);
ReadExceptionHandlers(count, () => (int)ReadUInt16(), () => (int)ReadByte());
}
private void ReadFatSection()
{
Advance(-1);
int count = (ReadInt32() >> 8) / 24;
ReadExceptionHandlers(count, ReadInt32, ReadInt32);
}
// inline ?
private void ReadExceptionHandlers(int count, Func<int> read_entry, Func<int> read_length)
{
for (int i = 0; i < count; i++)
{
ExceptionHandler handler = new((ExceptionHandlerType)(read_entry() & 0x7));
handler.TryStart = GetInstruction(read_entry());
handler.TryEnd = GetInstruction(handler.TryStart.Offset + read_length());
handler.HandlerStart = GetInstruction(read_entry());
handler.HandlerEnd = GetInstruction(handler.HandlerStart.Offset + read_length());
ReadExceptionHandlerSpecific(handler);
body.ExceptionHandlers.Add(handler);
}
}
private void ReadExceptionHandlerSpecific(ExceptionHandler handler)
{
switch (handler.HandlerType)
{
case ExceptionHandlerType.Catch:
handler.CatchType = (TypeReference)reader.LookupToken(ReadToken());
break;
case ExceptionHandlerType.Filter:
handler.FilterStart = GetInstruction(ReadInt32());
break;
default:
Advance(4);
break;
}
}
public MetadataToken ReadToken()
{
return new(ReadUInt32());
}
private void ReadDebugInfo()
{
if (method.debug_info.sequence_points != null)
ReadSequencePoints();
if (method.debug_info.scope != null)
ReadScope(method.debug_info.scope);
if (method.custom_infos != null)
ReadCustomDebugInformations(method);
}
private void ReadCustomDebugInformations(MethodDefinition method)
{
Collection<CustomDebugInformation> custom_infos = method.custom_infos;
for (int i = 0; i < custom_infos.Count; i++)
{
StateMachineScopeDebugInformation state_machine_scope = custom_infos[i] as StateMachineScopeDebugInformation;
if (state_machine_scope != null)
ReadStateMachineScope(state_machine_scope);
AsyncMethodBodyDebugInformation async_method = custom_infos[i] as AsyncMethodBodyDebugInformation;
if (async_method != null)
ReadAsyncMethodBody(async_method);
}
}
private void ReadAsyncMethodBody(AsyncMethodBodyDebugInformation async_method)
{
if (async_method.catch_handler.Offset > -1)
async_method.catch_handler = new(GetInstruction(async_method.catch_handler.Offset));
if (!async_method.yields.IsNullOrEmpty())
for (int i = 0; i < async_method.yields.Count; i++)
async_method.yields[i] = new(GetInstruction(async_method.yields[i].Offset));
if (!async_method.resumes.IsNullOrEmpty())
for (int i = 0; i < async_method.resumes.Count; i++)
async_method.resumes[i] = new(GetInstruction(async_method.resumes[i].Offset));
}
private void ReadStateMachineScope(StateMachineScopeDebugInformation state_machine_scope)
{
if (state_machine_scope.scopes.IsNullOrEmpty())
return;
foreach (StateMachineScope scope in state_machine_scope.scopes)
{
scope.start = new(GetInstruction(scope.start.Offset));
Instruction end_instruction = GetInstruction(scope.end.Offset);
scope.end = end_instruction == null ? new() : new InstructionOffset(end_instruction);
}
}
private void ReadSequencePoints()
{
MethodDebugInformation symbol = method.debug_info;
for (int i = 0; i < symbol.sequence_points.Count; i++)
{
SequencePoint sequence_point = symbol.sequence_points[i];
Instruction instruction = GetInstruction(sequence_point.Offset);
if (instruction != null)
sequence_point.offset = new(instruction);
}
}
private void ReadScopes(Collection<ScopeDebugInformation> scopes)
{
for (int i = 0; i < scopes.Count; i++)
ReadScope(scopes[i]);
}
private void ReadScope(ScopeDebugInformation scope)
{
Instruction start_instruction = GetInstruction(scope.Start.Offset);
if (start_instruction != null)
scope.Start = new(start_instruction);
Instruction end_instruction = GetInstruction(scope.End.Offset);
scope.End = end_instruction != null ? new(end_instruction) : new InstructionOffset();
if (!scope.variables.IsNullOrEmpty())
{
for (int i = 0; i < scope.variables.Count; i++)
{
VariableDebugInformation variable_info = scope.variables[i];
VariableDefinition variable = GetVariable(variable_info.Index);
if (variable != null)
variable_info.index = new(variable);
}
}
if (!scope.scopes.IsNullOrEmpty())
ReadScopes(scope.scopes);
}
public ByteBuffer PatchRawMethodBody(MethodDefinition method, CodeWriter writer, out int code_size, out MetadataToken local_var_token)
{
int position = MoveTo(method);
ByteBuffer buffer = new();
byte flags = ReadByte();
switch (flags & 0x3)
{
case 0x2: // tiny
buffer.WriteByte(flags);
local_var_token = MetadataToken.Zero;
code_size = flags >> 2;
PatchRawCode(buffer, code_size, writer);
break;
case 0x3: // fat
Advance(-1);
PatchRawFatMethod(buffer, writer, out code_size, out local_var_token);
break;
default:
throw new NotSupportedException();
}
MoveBackTo(position);
return buffer;
}
private void PatchRawFatMethod(ByteBuffer buffer, CodeWriter writer, out int code_size, out MetadataToken local_var_token)
{
ushort flags = ReadUInt16();
buffer.WriteUInt16(flags);
buffer.WriteUInt16(ReadUInt16());
code_size = ReadInt32();
buffer.WriteInt32(code_size);
local_var_token = ReadToken();
if (local_var_token.RID > 0)
{
VariableDefinitionCollection variables = ReadVariables(local_var_token);
buffer.WriteUInt32(variables != null ? writer.GetStandAloneSignature(variables).ToUInt32() : 0);
}
else
{
buffer.WriteUInt32(0);
}
PatchRawCode(buffer, code_size, writer);
if ((flags & 0x8) != 0)
PatchRawSection(buffer, writer.metadata);
}
private void PatchRawCode(ByteBuffer buffer, int code_size, CodeWriter writer)
{
MetadataBuilder metadata = writer.metadata;
buffer.WriteBytes(ReadBytes(code_size));
int end = buffer.position;
buffer.position -= code_size;
while (buffer.position < end)
{
OpCode opcode;
byte il_opcode = buffer.ReadByte();
if (il_opcode != 0xfe)
{
opcode = OpCodes.OneByteOpCode[il_opcode];
}
else
{
byte il_opcode2 = buffer.ReadByte();
opcode = OpCodes.TwoBytesOpCode[il_opcode2];
}
switch (opcode.OperandType)
{
case OperandType.ShortInlineI:
case OperandType.ShortInlineBrTarget:
case OperandType.ShortInlineVar:
case OperandType.ShortInlineArg:
buffer.position += 1;
break;
case OperandType.InlineVar:
case OperandType.InlineArg:
buffer.position += 2;
break;
case OperandType.InlineBrTarget:
case OperandType.ShortInlineR:
case OperandType.InlineI:
buffer.position += 4;
break;
case OperandType.InlineI8:
case OperandType.InlineR:
buffer.position += 8;
break;
case OperandType.InlineSwitch:
int length = buffer.ReadInt32();
buffer.position += length * 4;
break;
case OperandType.InlineString:
string @string = GetString(new(buffer.ReadUInt32()));
buffer.position -= 4;
buffer.WriteUInt32(new MetadataToken(TokenType.String, metadata.user_string_heap.GetStringIndex(@string)).ToUInt32());
break;
case OperandType.InlineSig:
CallSite call_site = GetCallSite(new(buffer.ReadUInt32()));
buffer.position -= 4;
buffer.WriteUInt32(writer.GetStandAloneSignature(call_site).ToUInt32());
break;
case OperandType.InlineTok:
case OperandType.InlineType:
case OperandType.InlineMethod:
case OperandType.InlineField:
IMetadataTokenProvider provider = reader.LookupToken(new(buffer.ReadUInt32()));
buffer.position -= 4;
buffer.WriteUInt32(metadata.LookupToken(provider).ToUInt32());
break;
}
}
}
private void PatchRawSection(ByteBuffer buffer, MetadataBuilder metadata)
{
int position = Position;
Align(4);
buffer.WriteBytes(Position - position);
const byte fat_format = 0x40;
const byte more_sects = 0x80;
byte flags = ReadByte();
if ((flags & fat_format) == 0)
{
buffer.WriteByte(flags);
PatchRawSmallSection(buffer, metadata);
}
else
{
PatchRawFatSection(buffer, metadata);
}
if ((flags & more_sects) != 0)
PatchRawSection(buffer, metadata);
}
private void PatchRawSmallSection(ByteBuffer buffer, MetadataBuilder metadata)
{
byte length = ReadByte();
buffer.WriteByte(length);
Advance(2);
buffer.WriteUInt16(0);
int count = length / 12;
PatchRawExceptionHandlers(buffer, metadata, count, false);
}
private void PatchRawFatSection(ByteBuffer buffer, MetadataBuilder metadata)
{
Advance(-1);
int length = ReadInt32();
buffer.WriteInt32(length);
int count = (length >> 8) / 24;
PatchRawExceptionHandlers(buffer, metadata, count, true);
}
private void PatchRawExceptionHandlers(ByteBuffer buffer, MetadataBuilder metadata, int count, bool fat_entry)
{
const int fat_entry_size = 16;
const int small_entry_size = 6;
for (int i = 0; i < count; i++)
{
ExceptionHandlerType handler_type;
if (fat_entry)
{
uint type = ReadUInt32();
handler_type = (ExceptionHandlerType)(type & 0x7);
buffer.WriteUInt32(type);
}
else
{
ushort type = ReadUInt16();
handler_type = (ExceptionHandlerType)(type & 0x7);
buffer.WriteUInt16(type);
}
buffer.WriteBytes(ReadBytes(fat_entry ? fat_entry_size : small_entry_size));
switch (handler_type)
{
case ExceptionHandlerType.Catch:
IMetadataTokenProvider exception = reader.LookupToken(ReadToken());
buffer.WriteUInt32(metadata.LookupToken(exception).ToUInt32());
break;
default:
buffer.WriteUInt32(ReadUInt32());
break;
}
}
}
}
}
@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 451f6a2407c53554f9a16eeb62d806ce
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 207815
packageName: 'FishNet: Networking Evolved'
packageVersion: 4.6.22R
assetPath: Assets/FishNet/CodeGenerating/cecil-0.11.4/Mono.Cecil.Cil/CodeReader.cs
uploadId: 866910
@@ -0,0 +1,668 @@
//
// Author:
// Jb Evain (jbevain@gmail.com)
//
// Copyright (c) 2008 - 2015 Jb Evain
// Copyright (c) 2008 - 2011 Novell, Inc.
//
// Licensed under the MIT/X11 license.
//
using MonoFN.Cecil.Metadata;
using MonoFN.Cecil.PE;
using MonoFN.Collections.Generic;
using System;
using System.Collections.Generic;
using RVA = System.UInt32;
namespace MonoFN.Cecil.Cil
{
internal sealed class CodeWriter : ByteBuffer
{
private readonly RVA code_base;
internal readonly MetadataBuilder metadata;
private readonly Dictionary<uint, MetadataToken> standalone_signatures;
private readonly Dictionary<ByteBuffer, RVA> tiny_method_bodies;
private MethodBody body;
public CodeWriter(MetadataBuilder metadata) : base(0)
{
code_base = metadata.text_map.GetNextRVA(TextSegment.CLIHeader);
this.metadata = metadata;
standalone_signatures = new();
tiny_method_bodies = new(new ByteBufferEqualityComparer());
}
public RVA WriteMethodBody(MethodDefinition method)
{
RVA rva;
if (IsUnresolved(method))
{
if (method.rva == 0)
return 0;
rva = WriteUnresolvedMethodBody(method);
}
else
{
if (IsEmptyMethodBody(method.Body))
return 0;
rva = WriteResolvedMethodBody(method);
}
return rva;
}
private static bool IsEmptyMethodBody(MethodBody body)
{
return body.instructions.IsNullOrEmpty() && body.variables.IsNullOrEmpty();
}
private static bool IsUnresolved(MethodDefinition method)
{
return method.HasBody && method.HasImage && method.body == null;
}
private RVA WriteUnresolvedMethodBody(MethodDefinition method)
{
CodeReader code_reader = metadata.module.reader.code;
int code_size;
MetadataToken local_var_token;
ByteBuffer raw_body = code_reader.PatchRawMethodBody(method, this, out code_size, out local_var_token);
bool fat_header = (raw_body.buffer[0] & 0x3) == 0x3;
if (fat_header)
Align(4);
RVA rva = BeginMethod();
if (fat_header || !GetOrMapTinyMethodBody(raw_body, ref rva))
{
WriteBytes(raw_body);
}
if (method.debug_info == null)
return rva;
ISymbolWriter symbol_writer = metadata.symbol_writer;
if (symbol_writer != null)
{
method.debug_info.code_size = code_size;
method.debug_info.local_var_token = local_var_token;
symbol_writer.Write(method.debug_info);
}
return rva;
}
private RVA WriteResolvedMethodBody(MethodDefinition method)
{
RVA rva;
body = method.Body;
ComputeHeader();
if (RequiresFatHeader())
{
Align(4);
rva = BeginMethod();
WriteFatHeader();
WriteInstructions();
if (body.HasExceptionHandlers)
WriteExceptionHandlers();
}
else
{
rva = BeginMethod();
WriteByte((byte)(0x2 | (body.CodeSize << 2))); // tiny
WriteInstructions();
int start_position = (int)(rva - code_base);
int body_size = position - start_position;
byte[] body_bytes = new byte [body_size];
Array.Copy(buffer, start_position, body_bytes, 0, body_size);
if (GetOrMapTinyMethodBody(new(body_bytes), ref rva))
position = start_position;
}
ISymbolWriter symbol_writer = metadata.symbol_writer;
if (symbol_writer != null && method.debug_info != null)
{
method.debug_info.code_size = body.CodeSize;
method.debug_info.local_var_token = body.local_var_token;
symbol_writer.Write(method.debug_info);
}
return rva;
}
private bool GetOrMapTinyMethodBody(ByteBuffer body, ref RVA rva)
{
RVA existing_rva;
if (tiny_method_bodies.TryGetValue(body, out existing_rva))
{
rva = existing_rva;
return true;
}
tiny_method_bodies.Add(body, rva);
return false;
}
private void WriteFatHeader()
{
MethodBody body = this.body;
byte flags = 0x3; // fat
if (body.InitLocals)
flags |= 0x10; // init locals
if (body.HasExceptionHandlers)
flags |= 0x8; // more sections
WriteByte(flags);
WriteByte(0x30);
WriteInt16((short)body.max_stack_size);
WriteInt32(body.code_size);
body.local_var_token = body.HasVariables ? GetStandAloneSignature(body.Variables) : MetadataToken.Zero;
WriteMetadataToken(body.local_var_token);
}
private void WriteInstructions()
{
Collection<Instruction> instructions = body.Instructions;
Instruction[] items = instructions.items;
int size = instructions.size;
for (int i = 0; i < size; i++)
{
Instruction instruction = items[i];
WriteOpCode(instruction.opcode);
WriteOperand(instruction);
}
}
private void WriteOpCode(OpCode opcode)
{
if (opcode.Size == 1)
{
WriteByte(opcode.Op2);
}
else
{
WriteByte(opcode.Op1);
WriteByte(opcode.Op2);
}
}
private void WriteOperand(Instruction instruction)
{
OpCode opcode = instruction.opcode;
OperandType operand_type = opcode.OperandType;
if (operand_type == OperandType.InlineNone)
return;
object operand = instruction.operand;
if (operand == null && !(operand_type == OperandType.InlineBrTarget || operand_type == OperandType.ShortInlineBrTarget))
{
throw new ArgumentException();
}
switch (operand_type)
{
case OperandType.InlineSwitch:
{
Instruction[] targets = (Instruction[])operand;
WriteInt32(targets.Length);
int diff = instruction.Offset + opcode.Size + 4 * (targets.Length + 1);
for (int i = 0; i < targets.Length; i++)
WriteInt32(GetTargetOffset(targets[i]) - diff);
break;
}
case OperandType.ShortInlineBrTarget:
{
Instruction target = (Instruction)operand;
int offset = target != null ? GetTargetOffset(target) : body.code_size;
WriteSByte((sbyte)(offset - (instruction.Offset + opcode.Size + 1)));
break;
}
case OperandType.InlineBrTarget:
{
Instruction target = (Instruction)operand;
int offset = target != null ? GetTargetOffset(target) : body.code_size;
WriteInt32(offset - (instruction.Offset + opcode.Size + 4));
break;
}
case OperandType.ShortInlineVar:
WriteByte((byte)GetVariableIndex((VariableDefinition)operand));
break;
case OperandType.ShortInlineArg:
WriteByte((byte)GetParameterIndex((ParameterDefinition)operand));
break;
case OperandType.InlineVar:
WriteInt16((short)GetVariableIndex((VariableDefinition)operand));
break;
case OperandType.InlineArg:
WriteInt16((short)GetParameterIndex((ParameterDefinition)operand));
break;
case OperandType.InlineSig:
WriteMetadataToken(GetStandAloneSignature((CallSite)operand));
break;
case OperandType.ShortInlineI:
if (opcode == OpCodes.Ldc_I4_S)
WriteSByte((sbyte)operand);
else
WriteByte((byte)operand);
break;
case OperandType.InlineI:
WriteInt32((int)operand);
break;
case OperandType.InlineI8:
WriteInt64((long)operand);
break;
case OperandType.ShortInlineR:
WriteSingle((float)operand);
break;
case OperandType.InlineR:
WriteDouble((double)operand);
break;
case OperandType.InlineString:
WriteMetadataToken(new(TokenType.String, GetUserStringIndex((string)operand)));
break;
case OperandType.InlineType:
case OperandType.InlineField:
case OperandType.InlineMethod:
case OperandType.InlineTok:
WriteMetadataToken(metadata.LookupToken((IMetadataTokenProvider)operand));
break;
default:
throw new ArgumentException();
}
}
private int GetTargetOffset(Instruction instruction)
{
if (instruction == null)
{
Instruction last = body.instructions[body.instructions.size - 1];
return last.offset + last.GetSize();
}
return instruction.offset;
}
private uint GetUserStringIndex(string @string)
{
if (@string == null)
return 0;
return metadata.user_string_heap.GetStringIndex(@string);
}
private static int GetVariableIndex(VariableDefinition variable)
{
return variable.Index;
}
private int GetParameterIndex(ParameterDefinition parameter)
{
if (body.method.HasThis)
{
if (parameter == body.this_parameter)
return 0;
return parameter.Index + 1;
}
return parameter.Index;
}
private bool RequiresFatHeader()
{
MethodBody body = this.body;
return body.CodeSize >= 64 || body.InitLocals || body.HasVariables || body.HasExceptionHandlers || body.MaxStackSize > 8;
}
private void ComputeHeader()
{
int offset = 0;
Collection<Instruction> instructions = body.instructions;
Instruction[] items = instructions.items;
int count = instructions.size;
int stack_size = 0;
int max_stack = 0;
Dictionary<Instruction, int> stack_sizes = null;
if (body.HasExceptionHandlers)
ComputeExceptionHandlerStackSize(ref stack_sizes);
for (int i = 0; i < count; i++)
{
Instruction instruction = items[i];
instruction.offset = offset;
offset += instruction.GetSize();
ComputeStackSize(instruction, ref stack_sizes, ref stack_size, ref max_stack);
}
body.code_size = offset;
body.max_stack_size = max_stack;
}
private void ComputeExceptionHandlerStackSize(ref Dictionary<Instruction, int> stack_sizes)
{
Collection<ExceptionHandler> exception_handlers = body.ExceptionHandlers;
for (int i = 0; i < exception_handlers.Count; i++)
{
ExceptionHandler exception_handler = exception_handlers[i];
switch (exception_handler.HandlerType)
{
case ExceptionHandlerType.Catch:
AddExceptionStackSize(exception_handler.HandlerStart, ref stack_sizes);
break;
case ExceptionHandlerType.Filter:
AddExceptionStackSize(exception_handler.FilterStart, ref stack_sizes);
AddExceptionStackSize(exception_handler.HandlerStart, ref stack_sizes);
break;
}
}
}
private static void AddExceptionStackSize(Instruction handler_start, ref Dictionary<Instruction, int> stack_sizes)
{
if (handler_start == null)
return;
if (stack_sizes == null)
stack_sizes = new();
stack_sizes[handler_start] = 1;
}
private static void ComputeStackSize(Instruction instruction, ref Dictionary<Instruction, int> stack_sizes, ref int stack_size, ref int max_stack)
{
int computed_size;
if (stack_sizes != null && stack_sizes.TryGetValue(instruction, out computed_size))
stack_size = computed_size;
max_stack = Math.Max(max_stack, stack_size);
ComputeStackDelta(instruction, ref stack_size);
max_stack = Math.Max(max_stack, stack_size);
CopyBranchStackSize(instruction, ref stack_sizes, stack_size);
ComputeStackSize(instruction, ref stack_size);
}
private static void CopyBranchStackSize(Instruction instruction, ref Dictionary<Instruction, int> stack_sizes, int stack_size)
{
if (stack_size == 0)
return;
switch (instruction.opcode.OperandType)
{
case OperandType.ShortInlineBrTarget:
case OperandType.InlineBrTarget:
CopyBranchStackSize(ref stack_sizes, (Instruction)instruction.operand, stack_size);
break;
case OperandType.InlineSwitch:
Instruction[] targets = (Instruction[])instruction.operand;
for (int i = 0; i < targets.Length; i++)
CopyBranchStackSize(ref stack_sizes, targets[i], stack_size);
break;
}
}
private static void CopyBranchStackSize(ref Dictionary<Instruction, int> stack_sizes, Instruction target, int stack_size)
{
if (stack_sizes == null)
stack_sizes = new();
int branch_stack_size = stack_size;
int computed_size;
if (stack_sizes.TryGetValue(target, out computed_size))
branch_stack_size = Math.Max(branch_stack_size, computed_size);
stack_sizes[target] = branch_stack_size;
}
private static void ComputeStackSize(Instruction instruction, ref int stack_size)
{
switch (instruction.opcode.FlowControl)
{
case FlowControl.Branch:
case FlowControl.Throw:
case FlowControl.Return:
stack_size = 0;
break;
}
}
private static void ComputeStackDelta(Instruction instruction, ref int stack_size)
{
switch (instruction.opcode.FlowControl)
{
case FlowControl.Call:
{
IMethodSignature method = (IMethodSignature)instruction.operand;
// pop 'this' argument
if (method.HasImplicitThis() && instruction.opcode.Code != Code.Newobj)
stack_size--;
// pop normal arguments
if (method.HasParameters)
stack_size -= method.Parameters.Count;
// pop function pointer
if (instruction.opcode.Code == Code.Calli)
stack_size--;
// push return value
if (method.ReturnType.etype != ElementType.Void || instruction.opcode.Code == Code.Newobj)
stack_size++;
break;
}
default:
ComputePopDelta(instruction.opcode.StackBehaviourPop, ref stack_size);
ComputePushDelta(instruction.opcode.StackBehaviourPush, ref stack_size);
break;
}
}
private static void ComputePopDelta(StackBehaviour pop_behavior, ref int stack_size)
{
switch (pop_behavior)
{
case StackBehaviour.Popi:
case StackBehaviour.Popref:
case StackBehaviour.Pop1:
stack_size--;
break;
case StackBehaviour.Pop1_pop1:
case StackBehaviour.Popi_pop1:
case StackBehaviour.Popi_popi:
case StackBehaviour.Popi_popi8:
case StackBehaviour.Popi_popr4:
case StackBehaviour.Popi_popr8:
case StackBehaviour.Popref_pop1:
case StackBehaviour.Popref_popi:
stack_size -= 2;
break;
case StackBehaviour.Popi_popi_popi:
case StackBehaviour.Popref_popi_popi:
case StackBehaviour.Popref_popi_popi8:
case StackBehaviour.Popref_popi_popr4:
case StackBehaviour.Popref_popi_popr8:
case StackBehaviour.Popref_popi_popref:
stack_size -= 3;
break;
case StackBehaviour.PopAll:
stack_size = 0;
break;
}
}
private static void ComputePushDelta(StackBehaviour push_behaviour, ref int stack_size)
{
switch (push_behaviour)
{
case StackBehaviour.Push1:
case StackBehaviour.Pushi:
case StackBehaviour.Pushi8:
case StackBehaviour.Pushr4:
case StackBehaviour.Pushr8:
case StackBehaviour.Pushref:
stack_size++;
break;
case StackBehaviour.Push1_push1:
stack_size += 2;
break;
}
}
private void WriteExceptionHandlers()
{
Align(4);
Collection<ExceptionHandler> handlers = body.ExceptionHandlers;
if (handlers.Count < 0x15 && !RequiresFatSection(handlers))
WriteSmallSection(handlers);
else
WriteFatSection(handlers);
}
private static bool RequiresFatSection(Collection<ExceptionHandler> handlers)
{
for (int i = 0; i < handlers.Count; i++)
{
ExceptionHandler handler = handlers[i];
if (IsFatRange(handler.TryStart, handler.TryEnd))
return true;
if (IsFatRange(handler.HandlerStart, handler.HandlerEnd))
return true;
if (handler.HandlerType == ExceptionHandlerType.Filter && IsFatRange(handler.FilterStart, handler.HandlerStart))
return true;
}
return false;
}
private static bool IsFatRange(Instruction start, Instruction end)
{
if (start == null)
throw new ArgumentException();
if (end == null)
return true;
return end.Offset - start.Offset > 255 || start.Offset > 65535;
}
private void WriteSmallSection(Collection<ExceptionHandler> handlers)
{
const byte eh_table = 0x1;
WriteByte(eh_table);
WriteByte((byte)(handlers.Count * 12 + 4));
WriteBytes(2);
WriteExceptionHandlers(handlers, i => WriteUInt16((ushort)i), i => WriteByte((byte)i));
}
private void WriteFatSection(Collection<ExceptionHandler> handlers)
{
const byte eh_table = 0x1;
const byte fat_format = 0x40;
WriteByte(eh_table | fat_format);
int size = handlers.Count * 24 + 4;
WriteByte((byte)(size & 0xff));
WriteByte((byte)((size >> 8) & 0xff));
WriteByte((byte)((size >> 16) & 0xff));
WriteExceptionHandlers(handlers, WriteInt32, WriteInt32);
}
private void WriteExceptionHandlers(Collection<ExceptionHandler> handlers, Action<int> write_entry, Action<int> write_length)
{
for (int i = 0; i < handlers.Count; i++)
{
ExceptionHandler handler = handlers[i];
write_entry((int)handler.HandlerType);
write_entry(handler.TryStart.Offset);
write_length(GetTargetOffset(handler.TryEnd) - handler.TryStart.Offset);
write_entry(handler.HandlerStart.Offset);
write_length(GetTargetOffset(handler.HandlerEnd) - handler.HandlerStart.Offset);
WriteExceptionHandlerSpecific(handler);
}
}
private void WriteExceptionHandlerSpecific(ExceptionHandler handler)
{
switch (handler.HandlerType)
{
case ExceptionHandlerType.Catch:
WriteMetadataToken(metadata.LookupToken(handler.CatchType));
break;
case ExceptionHandlerType.Filter:
WriteInt32(handler.FilterStart.Offset);
break;
default:
WriteInt32(0);
break;
}
}
public MetadataToken GetStandAloneSignature(Collection<VariableDefinition> variables)
{
uint signature = metadata.GetLocalVariableBlobIndex(variables);
return GetStandAloneSignatureToken(signature);
}
public MetadataToken GetStandAloneSignature(CallSite call_site)
{
uint signature = metadata.GetCallSiteBlobIndex(call_site);
MetadataToken token = GetStandAloneSignatureToken(signature);
call_site.MetadataToken = token;
return token;
}
private MetadataToken GetStandAloneSignatureToken(uint signature)
{
MetadataToken token;
if (standalone_signatures.TryGetValue(signature, out token))
return token;
token = new(TokenType.Signature, metadata.AddStandAloneSignature(signature));
standalone_signatures.Add(signature, token);
return token;
}
private RVA BeginMethod()
{
return (RVA)(code_base + position);
}
private void WriteMetadataToken(MetadataToken token)
{
WriteUInt32(token.ToUInt32());
}
private void Align(int align)
{
align--;
WriteBytes(((position + align) & ~align) - position);
}
}
}
@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 278f89c983a1bc6429c65a1d49dff091
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 207815
packageName: 'FishNet: Networking Evolved'
packageVersion: 4.6.22R
assetPath: Assets/FishNet/CodeGenerating/cecil-0.11.4/Mono.Cecil.Cil/CodeWriter.cs
uploadId: 866910
@@ -0,0 +1,90 @@
//
// Author:
// Jb Evain (jbevain@gmail.com)
//
// Copyright (c) 2008 - 2015 Jb Evain
// Copyright (c) 2008 - 2011 Novell, Inc.
//
// Licensed under the MIT/X11 license.
//
using System;
namespace MonoFN.Cecil.Cil
{
public enum DocumentType
{
Other,
Text
}
public enum DocumentHashAlgorithm
{
None,
MD5,
SHA1,
SHA256
}
public enum DocumentLanguage
{
Other,
C,
Cpp,
CSharp,
Basic,
Java,
Cobol,
Pascal,
Cil,
JScript,
Smc,
MCpp,
FSharp
}
public enum DocumentLanguageVendor
{
Other,
Microsoft
}
public sealed class Document : DebugInformation
{
public string Url { get; set; }
public DocumentType Type
{
get { return TypeGuid.ToType(); }
set { TypeGuid = value.ToGuid(); }
}
public Guid TypeGuid { get; set; }
public DocumentHashAlgorithm HashAlgorithm
{
get { return HashAlgorithmGuid.ToHashAlgorithm(); }
set { HashAlgorithmGuid = value.ToGuid(); }
}
public Guid HashAlgorithmGuid { get; set; }
public DocumentLanguage Language
{
get { return LanguageGuid.ToLanguage(); }
set { LanguageGuid = value.ToGuid(); }
}
public Guid LanguageGuid { get; set; }
public DocumentLanguageVendor LanguageVendor
{
get { return LanguageVendorGuid.ToVendor(); }
set { LanguageVendorGuid = value.ToGuid(); }
}
public Guid LanguageVendorGuid { get; set; }
public byte[] Hash { get; set; }
public byte[] EmbeddedSource { get; set; }
public Document(string url)
{
this.Url = url;
Hash = Empty<byte>.Array;
EmbeddedSource = Empty<byte>.Array;
token = new(TokenType.Document);
}
}
}
@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 86b3083301304a341b6059ea8c29be7a
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 207815
packageName: 'FishNet: Networking Evolved'
packageVersion: 4.6.22R
assetPath: Assets/FishNet/CodeGenerating/cecil-0.11.4/Mono.Cecil.Cil/Document.cs
uploadId: 866910
@@ -0,0 +1,36 @@
//
// Author:
// Jb Evain (jbevain@gmail.com)
//
// Copyright (c) 2008 - 2015 Jb Evain
// Copyright (c) 2008 - 2011 Novell, Inc.
//
// Licensed under the MIT/X11 license.
//
namespace MonoFN.Cecil.Cil
{
public enum ExceptionHandlerType
{
Catch = 0,
Filter = 1,
Finally = 2,
Fault = 4
}
public sealed class ExceptionHandler
{
public Instruction TryStart { get; set; }
public Instruction TryEnd { get; set; }
public Instruction FilterStart { get; set; }
public Instruction HandlerStart { get; set; }
public Instruction HandlerEnd { get; set; }
public TypeReference CatchType { get; set; }
public ExceptionHandlerType HandlerType { get; set; }
public ExceptionHandler(ExceptionHandlerType handlerType)
{
HandlerType = handlerType;
}
}
}
@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: eb17bcae1a67ec344b65d6ed78ffb704
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 207815
packageName: 'FishNet: Networking Evolved'
packageVersion: 4.6.22R
assetPath: Assets/FishNet/CodeGenerating/cecil-0.11.4/Mono.Cecil.Cil/ExceptionHandler.cs
uploadId: 866910
@@ -0,0 +1,287 @@
//
// Author:
// Jb Evain (jbevain@gmail.com)
//
// Copyright (c) 2008 - 2015 Jb Evain
// Copyright (c) 2008 - 2011 Novell, Inc.
//
// Licensed under the MIT/X11 license.
//
using MonoFN.Collections.Generic;
using System;
namespace MonoFN.Cecil.Cil
{
public sealed class ILProcessor
{
private readonly Collection<Instruction> instructions;
public MethodBody Body { get; }
internal ILProcessor(MethodBody body)
{
this.Body = body;
instructions = body.Instructions;
}
public Instruction Create(OpCode opcode)
{
return Instruction.Create(opcode);
}
public Instruction Create(OpCode opcode, TypeReference type)
{
return Instruction.Create(opcode, type);
}
public Instruction Create(OpCode opcode, CallSite site)
{
return Instruction.Create(opcode, site);
}
public Instruction Create(OpCode opcode, MethodReference method)
{
return Instruction.Create(opcode, method);
}
public Instruction Create(OpCode opcode, FieldReference field)
{
return Instruction.Create(opcode, field);
}
public Instruction Create(OpCode opcode, string value)
{
return Instruction.Create(opcode, value);
}
public Instruction Create(OpCode opcode, sbyte value)
{
return Instruction.Create(opcode, value);
}
public Instruction Create(OpCode opcode, byte value)
{
if (opcode.OperandType == OperandType.ShortInlineVar)
return Instruction.Create(opcode, Body.Variables[value]);
if (opcode.OperandType == OperandType.ShortInlineArg)
return Instruction.Create(opcode, Body.GetParameter(value));
return Instruction.Create(opcode, value);
}
public Instruction Create(OpCode opcode, int value)
{
if (opcode.OperandType == OperandType.InlineVar)
return Instruction.Create(opcode, Body.Variables[value]);
if (opcode.OperandType == OperandType.InlineArg)
return Instruction.Create(opcode, Body.GetParameter(value));
return Instruction.Create(opcode, value);
}
public Instruction Create(OpCode opcode, long value)
{
return Instruction.Create(opcode, value);
}
public Instruction Create(OpCode opcode, float value)
{
return Instruction.Create(opcode, value);
}
public Instruction Create(OpCode opcode, double value)
{
return Instruction.Create(opcode, value);
}
public Instruction Create(OpCode opcode, Instruction target)
{
return Instruction.Create(opcode, target);
}
public Instruction Create(OpCode opcode, Instruction[] targets)
{
return Instruction.Create(opcode, targets);
}
public Instruction Create(OpCode opcode, VariableDefinition variable)
{
return Instruction.Create(opcode, variable);
}
public Instruction Create(OpCode opcode, ParameterDefinition parameter)
{
return Instruction.Create(opcode, parameter);
}
public void Emit(OpCode opcode)
{
Append(Create(opcode));
}
public void Emit(OpCode opcode, TypeReference type)
{
Append(Create(opcode, type));
}
public void Emit(OpCode opcode, MethodReference method)
{
Append(Create(opcode, method));
}
public void Emit(OpCode opcode, CallSite site)
{
Append(Create(opcode, site));
}
public void Emit(OpCode opcode, FieldReference field)
{
Append(Create(opcode, field));
}
public void Emit(OpCode opcode, string value)
{
Append(Create(opcode, value));
}
public void Emit(OpCode opcode, byte value)
{
Append(Create(opcode, value));
}
public void Emit(OpCode opcode, sbyte value)
{
Append(Create(opcode, value));
}
public void Emit(OpCode opcode, int value)
{
Append(Create(opcode, value));
}
public void Emit(OpCode opcode, long value)
{
Append(Create(opcode, value));
}
public void Emit(OpCode opcode, float value)
{
Append(Create(opcode, value));
}
public void Emit(OpCode opcode, double value)
{
Append(Create(opcode, value));
}
public void Emit(OpCode opcode, Instruction target)
{
Append(Create(opcode, target));
}
public void Emit(OpCode opcode, Instruction[] targets)
{
Append(Create(opcode, targets));
}
public void Emit(OpCode opcode, VariableDefinition variable)
{
Append(Create(opcode, variable));
}
public void Emit(OpCode opcode, ParameterDefinition parameter)
{
Append(Create(opcode, parameter));
}
public void InsertBefore(Instruction target, Instruction instruction)
{
if (target == null)
throw new ArgumentNullException("target");
if (instruction == null)
throw new ArgumentNullException("instruction");
int index = instructions.IndexOf(target);
if (index == -1)
throw new ArgumentOutOfRangeException("target");
instructions.Insert(index, instruction);
}
public void InsertAfter(Instruction target, Instruction instruction)
{
if (target == null)
throw new ArgumentNullException("target");
if (instruction == null)
throw new ArgumentNullException("instruction");
int index = instructions.IndexOf(target);
if (index == -1)
throw new ArgumentOutOfRangeException("target");
instructions.Insert(index + 1, instruction);
}
public void InsertAfter(int index, Instruction instruction)
{
if (index < 0 || index >= instructions.Count)
throw new ArgumentOutOfRangeException("index");
if (instruction == null)
throw new ArgumentNullException("instruction");
instructions.Insert(index + 1, instruction);
}
public void Append(Instruction instruction)
{
if (instruction == null)
throw new ArgumentNullException("instruction");
instructions.Add(instruction);
}
public void Replace(Instruction target, Instruction instruction)
{
if (target == null)
throw new ArgumentNullException("target");
if (instruction == null)
throw new ArgumentNullException("instruction");
InsertAfter(target, instruction);
Remove(target);
}
public void Replace(int index, Instruction instruction)
{
if (instruction == null)
throw new ArgumentNullException("instruction");
InsertAfter(index, instruction);
RemoveAt(index);
}
public void Remove(Instruction instruction)
{
if (instruction == null)
throw new ArgumentNullException("instruction");
if (!instructions.Remove(instruction))
throw new ArgumentOutOfRangeException("instruction");
}
public void RemoveAt(int index)
{
if (index < 0 || index >= instructions.Count)
throw new ArgumentOutOfRangeException("index");
instructions.RemoveAt(index);
}
public void Clear()
{
instructions.Clear();
}
}
}
@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 26902ea42064c624d82727d9ef9a8f5e
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 207815
packageName: 'FishNet: Networking Evolved'
packageVersion: 4.6.22R
assetPath: Assets/FishNet/CodeGenerating/cecil-0.11.4/Mono.Cecil.Cil/ILProcessor.cs
uploadId: 866910
@@ -0,0 +1,290 @@
//
// Author:
// Jb Evain (jbevain@gmail.com)
//
// Copyright (c) 2008 - 2015 Jb Evain
// Copyright (c) 2008 - 2011 Novell, Inc.
//
// Licensed under the MIT/X11 license.
//
using System;
using System.Text;
namespace MonoFN.Cecil.Cil
{
public sealed class Instruction
{
internal int offset;
internal OpCode opcode;
internal object operand;
internal Instruction previous;
internal Instruction next;
public int Offset
{
get { return offset; }
set { offset = value; }
}
public OpCode OpCode
{
get { return opcode; }
set { opcode = value; }
}
public object Operand
{
get { return operand; }
set { operand = value; }
}
public Instruction Previous
{
get { return previous; }
set { previous = value; }
}
public Instruction Next
{
get { return next; }
set { next = value; }
}
internal Instruction(int offset, OpCode opCode)
{
this.offset = offset;
opcode = opCode;
}
internal Instruction(OpCode opcode, object operand)
{
this.opcode = opcode;
this.operand = operand;
}
public int GetSize()
{
int size = opcode.Size;
switch (opcode.OperandType)
{
case OperandType.InlineSwitch:
return size + (1 + ((Instruction[])operand).Length) * 4;
case OperandType.InlineI8:
case OperandType.InlineR:
return size + 8;
case OperandType.InlineBrTarget:
case OperandType.InlineField:
case OperandType.InlineI:
case OperandType.InlineMethod:
case OperandType.InlineString:
case OperandType.InlineTok:
case OperandType.InlineType:
case OperandType.ShortInlineR:
case OperandType.InlineSig:
return size + 4;
case OperandType.InlineArg:
case OperandType.InlineVar:
return size + 2;
case OperandType.ShortInlineBrTarget:
case OperandType.ShortInlineI:
case OperandType.ShortInlineArg:
case OperandType.ShortInlineVar:
return size + 1;
default:
return size;
}
}
public override string ToString()
{
StringBuilder instruction = new();
AppendLabel(instruction, this);
instruction.Append(':');
instruction.Append(' ');
instruction.Append(opcode.Name);
if (operand == null)
return instruction.ToString();
instruction.Append(' ');
switch (opcode.OperandType)
{
case OperandType.ShortInlineBrTarget:
case OperandType.InlineBrTarget:
AppendLabel(instruction, (Instruction)operand);
break;
case OperandType.InlineSwitch:
Instruction[] labels = (Instruction[])operand;
for (int i = 0; i < labels.Length; i++)
{
if (i > 0)
instruction.Append(',');
AppendLabel(instruction, labels[i]);
}
break;
case OperandType.InlineString:
instruction.Append('\"');
instruction.Append(operand);
instruction.Append('\"');
break;
default:
instruction.Append(operand);
break;
}
return instruction.ToString();
}
private static void AppendLabel(StringBuilder builder, Instruction instruction)
{
builder.Append("IL_");
builder.Append(instruction.offset.ToString("x4"));
}
public static Instruction Create(OpCode opcode)
{
if (opcode.OperandType != OperandType.InlineNone)
throw new ArgumentException("opcode");
return new(opcode, null);
}
public static Instruction Create(OpCode opcode, TypeReference type)
{
if (type == null)
throw new ArgumentNullException("type");
if (opcode.OperandType != OperandType.InlineType && opcode.OperandType != OperandType.InlineTok)
throw new ArgumentException("opcode");
return new(opcode, type);
}
public static Instruction Create(OpCode opcode, CallSite site)
{
if (site == null)
throw new ArgumentNullException("site");
if (opcode.Code != Code.Calli)
throw new ArgumentException("code");
return new(opcode, site);
}
public static Instruction Create(OpCode opcode, MethodReference method)
{
if (method == null)
throw new ArgumentNullException("method");
if (opcode.OperandType != OperandType.InlineMethod && opcode.OperandType != OperandType.InlineTok)
throw new ArgumentException("opcode");
return new(opcode, method);
}
public static Instruction Create(OpCode opcode, FieldReference field)
{
if (field == null)
throw new ArgumentNullException("field");
if (opcode.OperandType != OperandType.InlineField && opcode.OperandType != OperandType.InlineTok)
throw new ArgumentException("opcode");
return new(opcode, field);
}
public static Instruction Create(OpCode opcode, string value)
{
if (value == null)
throw new ArgumentNullException("value");
if (opcode.OperandType != OperandType.InlineString)
throw new ArgumentException("opcode");
return new(opcode, value);
}
public static Instruction Create(OpCode opcode, sbyte value)
{
if (opcode.OperandType != OperandType.ShortInlineI && opcode != OpCodes.Ldc_I4_S)
throw new ArgumentException("opcode");
return new(opcode, value);
}
public static Instruction Create(OpCode opcode, byte value)
{
if (opcode.OperandType != OperandType.ShortInlineI || opcode == OpCodes.Ldc_I4_S)
throw new ArgumentException("opcode");
return new(opcode, value);
}
public static Instruction Create(OpCode opcode, int value)
{
if (opcode.OperandType != OperandType.InlineI)
throw new ArgumentException("opcode");
return new(opcode, value);
}
public static Instruction Create(OpCode opcode, long value)
{
if (opcode.OperandType != OperandType.InlineI8)
throw new ArgumentException("opcode");
return new(opcode, value);
}
public static Instruction Create(OpCode opcode, float value)
{
if (opcode.OperandType != OperandType.ShortInlineR)
throw new ArgumentException("opcode");
return new(opcode, value);
}
public static Instruction Create(OpCode opcode, double value)
{
if (opcode.OperandType != OperandType.InlineR)
throw new ArgumentException("opcode");
return new(opcode, value);
}
public static Instruction Create(OpCode opcode, Instruction target)
{
if (target == null)
throw new ArgumentNullException("target");
if (opcode.OperandType != OperandType.InlineBrTarget && opcode.OperandType != OperandType.ShortInlineBrTarget)
throw new ArgumentException("opcode");
return new(opcode, target);
}
public static Instruction Create(OpCode opcode, Instruction[] targets)
{
if (targets == null)
throw new ArgumentNullException("targets");
if (opcode.OperandType != OperandType.InlineSwitch)
throw new ArgumentException("opcode");
return new(opcode, targets);
}
public static Instruction Create(OpCode opcode, VariableDefinition variable)
{
if (variable == null)
throw new ArgumentNullException("variable");
if (opcode.OperandType != OperandType.ShortInlineVar && opcode.OperandType != OperandType.InlineVar)
throw new ArgumentException("opcode");
return new(opcode, variable);
}
public static Instruction Create(OpCode opcode, ParameterDefinition parameter)
{
if (parameter == null)
throw new ArgumentNullException("parameter");
if (opcode.OperandType != OperandType.ShortInlineArg && opcode.OperandType != OperandType.InlineArg)
throw new ArgumentException("opcode");
return new(opcode, parameter);
}
}
}
@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 2d1536adbd2ca174abbd624473e722c3
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 207815
packageName: 'FishNet: Networking Evolved'
packageVersion: 4.6.22R
assetPath: Assets/FishNet/CodeGenerating/cecil-0.11.4/Mono.Cecil.Cil/Instruction.cs
uploadId: 866910
@@ -0,0 +1,441 @@
//
// Author:
// Jb Evain (jbevain@gmail.com)
//
// Copyright (c) 2008 - 2015 Jb Evain
// Copyright (c) 2008 - 2011 Novell, Inc.
//
// Licensed under the MIT/X11 license.
//
using MonoFN.Collections.Generic;
using System;
using System.Threading;
namespace MonoFN.Cecil.Cil
{
public sealed class MethodBody
{
internal readonly MethodDefinition method;
internal ParameterDefinition this_parameter;
internal int max_stack_size;
internal int code_size;
internal bool init_locals;
internal MetadataToken local_var_token;
internal Collection<Instruction> instructions;
internal Collection<ExceptionHandler> exceptions;
internal Collection<VariableDefinition> variables;
public MethodDefinition Method
{
get { return method; }
}
public int MaxStackSize
{
get { return max_stack_size; }
set { max_stack_size = value; }
}
public int CodeSize
{
get { return code_size; }
}
public bool InitLocals
{
get { return init_locals; }
set { init_locals = value; }
}
public MetadataToken LocalVarToken
{
get { return local_var_token; }
set { local_var_token = value; }
}
public Collection<Instruction> Instructions
{
get
{
if (instructions == null)
Interlocked.CompareExchange(ref instructions, new InstructionCollection(method), null);
return instructions;
}
}
public bool HasExceptionHandlers
{
get { return !exceptions.IsNullOrEmpty(); }
}
public Collection<ExceptionHandler> ExceptionHandlers
{
get
{
if (exceptions == null)
Interlocked.CompareExchange(ref exceptions, new(), null);
return exceptions;
}
}
public bool HasVariables
{
get { return !variables.IsNullOrEmpty(); }
}
public Collection<VariableDefinition> Variables
{
get
{
if (variables == null)
Interlocked.CompareExchange(ref variables, new VariableDefinitionCollection(method), null);
return variables;
}
}
public ParameterDefinition ThisParameter
{
get
{
if (method == null || method.DeclaringType == null)
throw new NotSupportedException();
if (!method.HasThis)
return null;
if (this_parameter == null)
Interlocked.CompareExchange(ref this_parameter, CreateThisParameter(method), null);
return this_parameter;
}
}
private static ParameterDefinition CreateThisParameter(MethodDefinition method)
{
TypeReference parameter_type = method.DeclaringType as TypeReference;
if (parameter_type.HasGenericParameters)
{
GenericInstanceType instance = new(parameter_type, parameter_type.GenericParameters.Count);
for (int i = 0; i < parameter_type.GenericParameters.Count; i++)
instance.GenericArguments.Add(parameter_type.GenericParameters[i]);
parameter_type = instance;
}
if (parameter_type.IsValueType || parameter_type.IsPrimitive)
parameter_type = new ByReferenceType(parameter_type);
return new(parameter_type, method);
}
public MethodBody(MethodDefinition method)
{
this.method = method;
}
public ILProcessor GetILProcessor()
{
return new(this);
}
}
internal sealed class VariableDefinitionCollection : Collection<VariableDefinition>
{
private readonly MethodDefinition method;
internal VariableDefinitionCollection(MethodDefinition method)
{
this.method = method;
}
internal VariableDefinitionCollection(MethodDefinition method, int capacity) : base(capacity)
{
this.method = method;
}
protected override void OnAdd(VariableDefinition item, int index)
{
item.index = index;
}
protected override void OnInsert(VariableDefinition item, int index)
{
item.index = index;
UpdateVariableIndices(index, 1);
}
protected override void OnSet(VariableDefinition item, int index)
{
item.index = index;
}
protected override void OnRemove(VariableDefinition item, int index)
{
UpdateVariableIndices(index + 1, -1, item);
item.index = -1;
}
private void UpdateVariableIndices(int startIndex, int offset, VariableDefinition variableToRemove = null)
{
for (int i = startIndex; i < size; i++)
items[i].index = i + offset;
MethodDebugInformation debug_info = method == null ? null : method.debug_info;
if (debug_info == null || debug_info.Scope == null)
return;
foreach (ScopeDebugInformation scope in debug_info.GetScopes())
{
if (!scope.HasVariables)
continue;
Collection<VariableDebugInformation> variables = scope.Variables;
int variableDebugInfoIndexToRemove = -1;
for (int i = 0; i < variables.Count; i++)
{
VariableDebugInformation variable = variables[i];
// If a variable is being removed detect if it has debug info counterpart, if so remove that as well.
// Note that the debug info can be either resolved (has direct reference to the VariableDefinition)
// or unresolved (has only the number index of the variable) - this needs to handle both cases.
if (variableToRemove != null && ((variable.index.IsResolved && variable.index.ResolvedVariable == variableToRemove) || (!variable.index.IsResolved && variable.Index == variableToRemove.Index)))
{
variableDebugInfoIndexToRemove = i;
continue;
}
// For unresolved debug info updates indeces to keep them pointing to the same variable.
if (!variable.index.IsResolved && variable.Index >= startIndex)
{
variable.index = new(variable.Index + offset);
}
}
if (variableDebugInfoIndexToRemove >= 0)
variables.RemoveAt(variableDebugInfoIndexToRemove);
}
}
}
internal class InstructionCollection : Collection<Instruction>
{
private readonly MethodDefinition method;
internal InstructionCollection(MethodDefinition method)
{
this.method = method;
}
internal InstructionCollection(MethodDefinition method, int capacity) : base(capacity)
{
this.method = method;
}
protected override void OnAdd(Instruction item, int index)
{
if (index == 0)
return;
Instruction previous = items[index - 1];
previous.next = item;
item.previous = previous;
}
protected override void OnInsert(Instruction item, int index)
{
int startOffset = 0;
if (size != 0)
{
Instruction current = items[index];
if (current == null)
{
Instruction last = items[index - 1];
last.next = item;
item.previous = last;
return;
}
startOffset = current.Offset;
Instruction previous = current.previous;
if (previous != null)
{
previous.next = item;
item.previous = previous;
}
current.previous = item;
item.next = current;
}
UpdateLocalScopes(null, null);
}
protected override void OnSet(Instruction item, int index)
{
Instruction current = items[index];
item.previous = current.previous;
item.next = current.next;
current.previous = null;
current.next = null;
UpdateLocalScopes(item, current);
}
protected override void OnRemove(Instruction item, int index)
{
Instruction previous = item.previous;
if (previous != null)
previous.next = item.next;
Instruction next = item.next;
if (next != null)
next.previous = item.previous;
RemoveSequencePoint(item);
UpdateLocalScopes(item, next ?? previous);
item.previous = null;
item.next = null;
}
private void RemoveSequencePoint(Instruction instruction)
{
MethodDebugInformation debug_info = method.debug_info;
if (debug_info == null || !debug_info.HasSequencePoints)
return;
Collection<SequencePoint> sequence_points = debug_info.sequence_points;
for (int i = 0; i < sequence_points.Count; i++)
{
if (sequence_points[i].Offset == instruction.offset)
{
sequence_points.RemoveAt(i);
return;
}
}
}
private void UpdateLocalScopes(Instruction removedInstruction, Instruction existingInstruction)
{
MethodDebugInformation debug_info = method.debug_info;
if (debug_info == null)
return;
// Local scopes store start/end pair of "instruction offsets". Instruction offset can be either resolved, in which case it
// has a reference to Instruction, or unresolved in which case it stores numerical offset (instruction offset in the body).
// Typically local scopes loaded from PE/PDB files will be resolved, but it's not a requirement.
// Each instruction has its own offset, which is populated on load, but never updated (this would be pretty expensive to do).
// Instructions created during the editting will typically have offset 0 (so incorrect).
// Local scopes created during editing will also likely be resolved (so no numerical offsets).
// So while local scopes which are unresolved are relatively rare if they appear, manipulating them based
// on the offsets allone is pretty hard (since we can't rely on correct offsets of instructions).
// On the other hand resolved local scopes are easy to maintain, since they point to instructions and thus inserting
// instructions is basically a no-op and removing instructions is as easy as changing the pointer.
// For this reason the algorithm here is:
// - First make sure that all instruction offsets are resolved - if not - resolve them
// - First time this will be relatively expensinve as it will walk the entire method body to convert offsets to instruction pointers
// Almost all local scopes are stored in the "right" order (sequentially per start offsets), so the code uses a simple one-item
// cache instruction<->offset to avoid walking instructions multiple times (that would only happen for scopes which are out of order).
// - Subsequent calls should be cheap as it will only walk all local scopes without doing anything
// - If there was an edit on local scope which makes some of them unresolved, the cost is proportional
// - Then update as necessary by manipulaitng instruction references alone
InstructionOffsetCache cache = new()
{
Offset = 0,
Index = 0,
Instruction = items[0]
};
UpdateLocalScope(debug_info.Scope, removedInstruction, existingInstruction, ref cache);
}
private void UpdateLocalScope(ScopeDebugInformation scope, Instruction removedInstruction, Instruction existingInstruction, ref InstructionOffsetCache cache)
{
if (scope == null)
return;
if (!scope.Start.IsResolved)
scope.Start = ResolveInstructionOffset(scope.Start, ref cache);
if (!scope.Start.IsEndOfMethod && scope.Start.ResolvedInstruction == removedInstruction)
scope.Start = new(existingInstruction);
if (scope.HasScopes)
{
foreach (ScopeDebugInformation subScope in scope.Scopes)
UpdateLocalScope(subScope, removedInstruction, existingInstruction, ref cache);
}
if (!scope.End.IsResolved)
scope.End = ResolveInstructionOffset(scope.End, ref cache);
if (!scope.End.IsEndOfMethod && scope.End.ResolvedInstruction == removedInstruction)
scope.End = new(existingInstruction);
}
private struct InstructionOffsetCache
{
public int Offset;
public int Index;
public Instruction Instruction;
}
private InstructionOffset ResolveInstructionOffset(InstructionOffset inputOffset, ref InstructionOffsetCache cache)
{
if (inputOffset.IsResolved)
return inputOffset;
int offset = inputOffset.Offset;
if (cache.Offset == offset)
return new(cache.Instruction);
if (cache.Offset > offset)
{
// This should be rare - we're resolving offset pointing to a place before the current cache position
// resolve by walking the instructions from start and don't cache the result.
int size = 0;
for (int i = 0; i < items.Length; i++)
{
if (size == offset)
return new(items[i]);
if (size > offset)
return new(items[i - 1]);
size += items[i].GetSize();
}
// Offset is larger than the size of the body - so it points after the end
return new();
}
else
{
// The offset points after the current cache position - so continue counting and update the cache
int size = cache.Offset;
for (int i = cache.Index; i < items.Length; i++)
{
cache.Index = i;
cache.Offset = size;
Instruction item = items[i];
// Allow for trailing null values in the case of
// instructions.Size < instructions.Capacity
if (item == null)
break;
cache.Instruction = item;
if (cache.Offset == offset)
return new(cache.Instruction);
if (cache.Offset > offset)
return new(items[i - 1]);
size += item.GetSize();
}
return new();
}
}
}
}
@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 4be4045de2c6a0e428e5910f4e76cfac
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 207815
packageName: 'FishNet: Networking Evolved'
packageVersion: 4.6.22R
assetPath: Assets/FishNet/CodeGenerating/cecil-0.11.4/Mono.Cecil.Cil/MethodBody.cs
uploadId: 866910
@@ -0,0 +1,437 @@
//
// Author:
// Jb Evain (jbevain@gmail.com)
//
// Copyright (c) 2008 - 2015 Jb Evain
// Copyright (c) 2008 - 2011 Novell, Inc.
//
// Licensed under the MIT/X11 license.
//
using System;
namespace MonoFN.Cecil.Cil
{
public enum FlowControl
{
Branch,
Break,
Call,
Cond_Branch,
Meta,
Next,
Phi,
Return,
Throw
}
public enum OpCodeType
{
Annotation,
Macro,
Nternal,
Objmodel,
Prefix,
Primitive
}
public enum OperandType
{
InlineBrTarget,
InlineField,
InlineI,
InlineI8,
InlineMethod,
InlineNone,
InlinePhi,
InlineR,
InlineSig,
InlineString,
InlineSwitch,
InlineTok,
InlineType,
InlineVar,
InlineArg,
ShortInlineBrTarget,
ShortInlineI,
ShortInlineR,
ShortInlineVar,
ShortInlineArg
}
public enum StackBehaviour
{
Pop0,
Pop1,
Pop1_pop1,
Popi,
Popi_pop1,
Popi_popi,
Popi_popi8,
Popi_popi_popi,
Popi_popr4,
Popi_popr8,
Popref,
Popref_pop1,
Popref_popi,
Popref_popi_popi,
Popref_popi_popi8,
Popref_popi_popr4,
Popref_popi_popr8,
Popref_popi_popref,
PopAll,
Push0,
Push1,
Push1_push1,
Pushi,
Pushi8,
Pushr4,
Pushr8,
Pushref,
Varpop,
Varpush
}
public struct OpCode : IEquatable<OpCode>
{
private readonly byte code;
private readonly byte flow_control;
private readonly byte opcode_type;
private readonly byte operand_type;
private readonly byte stack_behavior_pop;
private readonly byte stack_behavior_push;
public string Name
{
get { return OpCodeNames.names[(int)Code]; }
}
public int Size
{
get { return Op1 == 0xff ? 1 : 2; }
}
public byte Op1 { get; }
public byte Op2 { get; }
public short Value
{
get { return Op1 == 0xff ? Op2 : (short)((Op1 << 8) | Op2); }
}
public Code Code
{
get { return (Code)code; }
}
public FlowControl FlowControl
{
get { return (FlowControl)flow_control; }
}
public OpCodeType OpCodeType
{
get { return (OpCodeType)opcode_type; }
}
public OperandType OperandType
{
get { return (OperandType)operand_type; }
}
public StackBehaviour StackBehaviourPop
{
get { return (StackBehaviour)stack_behavior_pop; }
}
public StackBehaviour StackBehaviourPush
{
get { return (StackBehaviour)stack_behavior_push; }
}
internal OpCode(int x, int y)
{
Op1 = (byte)((x >> 0) & 0xff);
Op2 = (byte)((x >> 8) & 0xff);
code = (byte)((x >> 16) & 0xff);
flow_control = (byte)((x >> 24) & 0xff);
opcode_type = (byte)((y >> 0) & 0xff);
operand_type = (byte)((y >> 8) & 0xff);
stack_behavior_pop = (byte)((y >> 16) & 0xff);
stack_behavior_push = (byte)((y >> 24) & 0xff);
if (Op1 == 0xff)
OpCodes.OneByteOpCode[Op2] = this;
else
OpCodes.TwoBytesOpCode[Op2] = this;
}
public override int GetHashCode()
{
return Value;
}
public override bool Equals(object obj)
{
if (!(obj is OpCode))
return false;
OpCode opcode = (OpCode)obj;
return Op1 == opcode.Op1 && Op2 == opcode.Op2;
}
public bool Equals(OpCode opcode)
{
return Op1 == opcode.Op1 && Op2 == opcode.Op2;
}
public static bool operator ==(OpCode one, OpCode other)
{
return one.Op1 == other.Op1 && one.Op2 == other.Op2;
}
public static bool operator !=(OpCode one, OpCode other)
{
return one.Op1 != other.Op1 || one.Op2 != other.Op2;
}
public override string ToString()
{
return Name;
}
}
internal static class OpCodeNames
{
internal static readonly string[] names;
static OpCodeNames()
{
byte[] table = new byte[]
{
3, 110, 111, 112,
5, 98, 114, 101, 97, 107,
7, 108, 100, 97, 114, 103, 46, 48,
7, 108, 100, 97, 114, 103, 46, 49,
7, 108, 100, 97, 114, 103, 46, 50,
7, 108, 100, 97, 114, 103, 46, 51,
7, 108, 100, 108, 111, 99, 46, 48,
7, 108, 100, 108, 111, 99, 46, 49,
7, 108, 100, 108, 111, 99, 46, 50,
7, 108, 100, 108, 111, 99, 46, 51,
7, 115, 116, 108, 111, 99, 46, 48,
7, 115, 116, 108, 111, 99, 46, 49,
7, 115, 116, 108, 111, 99, 46, 50,
7, 115, 116, 108, 111, 99, 46, 51,
7, 108, 100, 97, 114, 103, 46, 115,
8, 108, 100, 97, 114, 103, 97, 46, 115,
7, 115, 116, 97, 114, 103, 46, 115,
7, 108, 100, 108, 111, 99, 46, 115,
8, 108, 100, 108, 111, 99, 97, 46, 115,
7, 115, 116, 108, 111, 99, 46, 115,
6, 108, 100, 110, 117, 108, 108,
9, 108, 100, 99, 46, 105, 52, 46, 109, 49,
8, 108, 100, 99, 46, 105, 52, 46, 48,
8, 108, 100, 99, 46, 105, 52, 46, 49,
8, 108, 100, 99, 46, 105, 52, 46, 50,
8, 108, 100, 99, 46, 105, 52, 46, 51,
8, 108, 100, 99, 46, 105, 52, 46, 52,
8, 108, 100, 99, 46, 105, 52, 46, 53,
8, 108, 100, 99, 46, 105, 52, 46, 54,
8, 108, 100, 99, 46, 105, 52, 46, 55,
8, 108, 100, 99, 46, 105, 52, 46, 56,
8, 108, 100, 99, 46, 105, 52, 46, 115,
6, 108, 100, 99, 46, 105, 52,
6, 108, 100, 99, 46, 105, 56,
6, 108, 100, 99, 46, 114, 52,
6, 108, 100, 99, 46, 114, 56,
3, 100, 117, 112,
3, 112, 111, 112,
3, 106, 109, 112,
4, 99, 97, 108, 108,
5, 99, 97, 108, 108, 105,
3, 114, 101, 116,
4, 98, 114, 46, 115,
9, 98, 114, 102, 97, 108, 115, 101, 46, 115,
8, 98, 114, 116, 114, 117, 101, 46, 115,
5, 98, 101, 113, 46, 115,
5, 98, 103, 101, 46, 115,
5, 98, 103, 116, 46, 115,
5, 98, 108, 101, 46, 115,
5, 98, 108, 116, 46, 115,
8, 98, 110, 101, 46, 117, 110, 46, 115,
8, 98, 103, 101, 46, 117, 110, 46, 115,
8, 98, 103, 116, 46, 117, 110, 46, 115,
8, 98, 108, 101, 46, 117, 110, 46, 115,
8, 98, 108, 116, 46, 117, 110, 46, 115,
2, 98, 114,
7, 98, 114, 102, 97, 108, 115, 101,
6, 98, 114, 116, 114, 117, 101,
3, 98, 101, 113,
3, 98, 103, 101,
3, 98, 103, 116,
3, 98, 108, 101,
3, 98, 108, 116,
6, 98, 110, 101, 46, 117, 110,
6, 98, 103, 101, 46, 117, 110,
6, 98, 103, 116, 46, 117, 110,
6, 98, 108, 101, 46, 117, 110,
6, 98, 108, 116, 46, 117, 110,
6, 115, 119, 105, 116, 99, 104,
8, 108, 100, 105, 110, 100, 46, 105, 49,
8, 108, 100, 105, 110, 100, 46, 117, 49,
8, 108, 100, 105, 110, 100, 46, 105, 50,
8, 108, 100, 105, 110, 100, 46, 117, 50,
8, 108, 100, 105, 110, 100, 46, 105, 52,
8, 108, 100, 105, 110, 100, 46, 117, 52,
8, 108, 100, 105, 110, 100, 46, 105, 56,
7, 108, 100, 105, 110, 100, 46, 105,
8, 108, 100, 105, 110, 100, 46, 114, 52,
8, 108, 100, 105, 110, 100, 46, 114, 56,
9, 108, 100, 105, 110, 100, 46, 114, 101, 102,
9, 115, 116, 105, 110, 100, 46, 114, 101, 102,
8, 115, 116, 105, 110, 100, 46, 105, 49,
8, 115, 116, 105, 110, 100, 46, 105, 50,
8, 115, 116, 105, 110, 100, 46, 105, 52,
8, 115, 116, 105, 110, 100, 46, 105, 56,
8, 115, 116, 105, 110, 100, 46, 114, 52,
8, 115, 116, 105, 110, 100, 46, 114, 56,
3, 97, 100, 100,
3, 115, 117, 98,
3, 109, 117, 108,
3, 100, 105, 118,
6, 100, 105, 118, 46, 117, 110,
3, 114, 101, 109,
6, 114, 101, 109, 46, 117, 110,
3, 97, 110, 100,
2, 111, 114,
3, 120, 111, 114,
3, 115, 104, 108,
3, 115, 104, 114,
6, 115, 104, 114, 46, 117, 110,
3, 110, 101, 103,
3, 110, 111, 116,
7, 99, 111, 110, 118, 46, 105, 49,
7, 99, 111, 110, 118, 46, 105, 50,
7, 99, 111, 110, 118, 46, 105, 52,
7, 99, 111, 110, 118, 46, 105, 56,
7, 99, 111, 110, 118, 46, 114, 52,
7, 99, 111, 110, 118, 46, 114, 56,
7, 99, 111, 110, 118, 46, 117, 52,
7, 99, 111, 110, 118, 46, 117, 56,
8, 99, 97, 108, 108, 118, 105, 114, 116,
5, 99, 112, 111, 98, 106,
5, 108, 100, 111, 98, 106,
5, 108, 100, 115, 116, 114,
6, 110, 101, 119, 111, 98, 106,
9, 99, 97, 115, 116, 99, 108, 97, 115, 115,
6, 105, 115, 105, 110, 115, 116,
9, 99, 111, 110, 118, 46, 114, 46, 117, 110,
5, 117, 110, 98, 111, 120,
5, 116, 104, 114, 111, 119,
5, 108, 100, 102, 108, 100,
6, 108, 100, 102, 108, 100, 97,
5, 115, 116, 102, 108, 100,
6, 108, 100, 115, 102, 108, 100,
7, 108, 100, 115, 102, 108, 100, 97,
6, 115, 116, 115, 102, 108, 100,
5, 115, 116, 111, 98, 106,
14, 99, 111, 110, 118, 46, 111, 118, 102, 46, 105, 49, 46, 117, 110,
14, 99, 111, 110, 118, 46, 111, 118, 102, 46, 105, 50, 46, 117, 110,
14, 99, 111, 110, 118, 46, 111, 118, 102, 46, 105, 52, 46, 117, 110,
14, 99, 111, 110, 118, 46, 111, 118, 102, 46, 105, 56, 46, 117, 110,
14, 99, 111, 110, 118, 46, 111, 118, 102, 46, 117, 49, 46, 117, 110,
14, 99, 111, 110, 118, 46, 111, 118, 102, 46, 117, 50, 46, 117, 110,
14, 99, 111, 110, 118, 46, 111, 118, 102, 46, 117, 52, 46, 117, 110,
14, 99, 111, 110, 118, 46, 111, 118, 102, 46, 117, 56, 46, 117, 110,
13, 99, 111, 110, 118, 46, 111, 118, 102, 46, 105, 46, 117, 110,
13, 99, 111, 110, 118, 46, 111, 118, 102, 46, 117, 46, 117, 110,
3, 98, 111, 120,
6, 110, 101, 119, 97, 114, 114,
5, 108, 100, 108, 101, 110,
7, 108, 100, 101, 108, 101, 109, 97,
9, 108, 100, 101, 108, 101, 109, 46, 105, 49,
9, 108, 100, 101, 108, 101, 109, 46, 117, 49,
9, 108, 100, 101, 108, 101, 109, 46, 105, 50,
9, 108, 100, 101, 108, 101, 109, 46, 117, 50,
9, 108, 100, 101, 108, 101, 109, 46, 105, 52,
9, 108, 100, 101, 108, 101, 109, 46, 117, 52,
9, 108, 100, 101, 108, 101, 109, 46, 105, 56,
8, 108, 100, 101, 108, 101, 109, 46, 105,
9, 108, 100, 101, 108, 101, 109, 46, 114, 52,
9, 108, 100, 101, 108, 101, 109, 46, 114, 56,
10, 108, 100, 101, 108, 101, 109, 46, 114, 101, 102,
8, 115, 116, 101, 108, 101, 109, 46, 105,
9, 115, 116, 101, 108, 101, 109, 46, 105, 49,
9, 115, 116, 101, 108, 101, 109, 46, 105, 50,
9, 115, 116, 101, 108, 101, 109, 46, 105, 52,
9, 115, 116, 101, 108, 101, 109, 46, 105, 56,
9, 115, 116, 101, 108, 101, 109, 46, 114, 52,
9, 115, 116, 101, 108, 101, 109, 46, 114, 56,
10, 115, 116, 101, 108, 101, 109, 46, 114, 101, 102,
10, 108, 100, 101, 108, 101, 109, 46, 97, 110, 121,
10, 115, 116, 101, 108, 101, 109, 46, 97, 110, 121,
9, 117, 110, 98, 111, 120, 46, 97, 110, 121,
11, 99, 111, 110, 118, 46, 111, 118, 102, 46, 105, 49,
11, 99, 111, 110, 118, 46, 111, 118, 102, 46, 117, 49,
11, 99, 111, 110, 118, 46, 111, 118, 102, 46, 105, 50,
11, 99, 111, 110, 118, 46, 111, 118, 102, 46, 117, 50,
11, 99, 111, 110, 118, 46, 111, 118, 102, 46, 105, 52,
11, 99, 111, 110, 118, 46, 111, 118, 102, 46, 117, 52,
11, 99, 111, 110, 118, 46, 111, 118, 102, 46, 105, 56,
11, 99, 111, 110, 118, 46, 111, 118, 102, 46, 117, 56,
9, 114, 101, 102, 97, 110, 121, 118, 97, 108,
8, 99, 107, 102, 105, 110, 105, 116, 101,
8, 109, 107, 114, 101, 102, 97, 110, 121,
7, 108, 100, 116, 111, 107, 101, 110,
7, 99, 111, 110, 118, 46, 117, 50,
7, 99, 111, 110, 118, 46, 117, 49,
6, 99, 111, 110, 118, 46, 105,
10, 99, 111, 110, 118, 46, 111, 118, 102, 46, 105,
10, 99, 111, 110, 118, 46, 111, 118, 102, 46, 117,
7, 97, 100, 100, 46, 111, 118, 102,
10, 97, 100, 100, 46, 111, 118, 102, 46, 117, 110,
7, 109, 117, 108, 46, 111, 118, 102,
10, 109, 117, 108, 46, 111, 118, 102, 46, 117, 110,
7, 115, 117, 98, 46, 111, 118, 102,
10, 115, 117, 98, 46, 111, 118, 102, 46, 117, 110,
10, 101, 110, 100, 102, 105, 110, 97, 108, 108, 121,
5, 108, 101, 97, 118, 101,
7, 108, 101, 97, 118, 101, 46, 115,
7, 115, 116, 105, 110, 100, 46, 105,
6, 99, 111, 110, 118, 46, 117,
7, 97, 114, 103, 108, 105, 115, 116,
3, 99, 101, 113,
3, 99, 103, 116,
6, 99, 103, 116, 46, 117, 110,
3, 99, 108, 116,
6, 99, 108, 116, 46, 117, 110,
5, 108, 100, 102, 116, 110,
9, 108, 100, 118, 105, 114, 116, 102, 116, 110,
5, 108, 100, 97, 114, 103,
6, 108, 100, 97, 114, 103, 97,
5, 115, 116, 97, 114, 103,
5, 108, 100, 108, 111, 99,
6, 108, 100, 108, 111, 99, 97,
5, 115, 116, 108, 111, 99,
8, 108, 111, 99, 97, 108, 108, 111, 99,
9, 101, 110, 100, 102, 105, 108, 116, 101, 114,
10, 117, 110, 97, 108, 105, 103, 110, 101, 100, 46,
9, 118, 111, 108, 97, 116, 105, 108, 101, 46,
5, 116, 97, 105, 108, 46,
7, 105, 110, 105, 116, 111, 98, 106,
12, 99, 111, 110, 115, 116, 114, 97, 105, 110, 101, 100, 46,
5, 99, 112, 98, 108, 107,
7, 105, 110, 105, 116, 98, 108, 107,
3, 110, 111, 46,
7, 114, 101, 116, 104, 114, 111, 119,
6, 115, 105, 122, 101, 111, 102,
10, 114, 101, 102, 97, 110, 121, 116, 121, 112, 101,
9, 114, 101, 97, 100, 111, 110, 108, 121, 46
};
names = new string [219];
for (int i = 0, p = 0; i < names.Length; i++)
{
char[] buffer = new char [table[p++]];
for (int j = 0; j < buffer.Length; j++)
buffer[j] = (char)table[p++];
names[i] = new(buffer);
}
}
}
}
@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 5d8b234c106529441912c10b87502175
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 207815
packageName: 'FishNet: Networking Evolved'
packageVersion: 4.6.22R
assetPath: Assets/FishNet/CodeGenerating/cecil-0.11.4/Mono.Cecil.Cil/OpCode.cs
uploadId: 866910
@@ -0,0 +1,237 @@
//
// Author:
// Jb Evain (jbevain@gmail.com)
//
// Copyright (c) 2008 - 2015 Jb Evain
// Copyright (c) 2008 - 2011 Novell, Inc.
//
// Licensed under the MIT/X11 license.
//
namespace MonoFN.Cecil.Cil
{
public static class OpCodes
{
internal static readonly OpCode[] OneByteOpCode = new OpCode [0xe0 + 1];
internal static readonly OpCode[] TwoBytesOpCode = new OpCode [0x1e + 1];
public static readonly OpCode Nop = new((0xff << 0) | (0x00 << 8) | ((byte)Code.Nop << 16) | ((byte)FlowControl.Next << 24), ((byte)OpCodeType.Primitive << 0) | ((byte)OperandType.InlineNone << 8) | ((byte)StackBehaviour.Pop0 << 16) | ((byte)StackBehaviour.Push0 << 24));
public static readonly OpCode Break = new((0xff << 0) | (0x01 << 8) | ((byte)Code.Break << 16) | ((byte)FlowControl.Break << 24), ((byte)OpCodeType.Primitive << 0) | ((byte)OperandType.InlineNone << 8) | ((byte)StackBehaviour.Pop0 << 16) | ((byte)StackBehaviour.Push0 << 24));
public static readonly OpCode Ldarg_0 = new((0xff << 0) | (0x02 << 8) | ((byte)Code.Ldarg_0 << 16) | ((byte)FlowControl.Next << 24), ((byte)OpCodeType.Macro << 0) | ((byte)OperandType.InlineNone << 8) | ((byte)StackBehaviour.Pop0 << 16) | ((byte)StackBehaviour.Push1 << 24));
public static readonly OpCode Ldarg_1 = new((0xff << 0) | (0x03 << 8) | ((byte)Code.Ldarg_1 << 16) | ((byte)FlowControl.Next << 24), ((byte)OpCodeType.Macro << 0) | ((byte)OperandType.InlineNone << 8) | ((byte)StackBehaviour.Pop0 << 16) | ((byte)StackBehaviour.Push1 << 24));
public static readonly OpCode Ldarg_2 = new((0xff << 0) | (0x04 << 8) | ((byte)Code.Ldarg_2 << 16) | ((byte)FlowControl.Next << 24), ((byte)OpCodeType.Macro << 0) | ((byte)OperandType.InlineNone << 8) | ((byte)StackBehaviour.Pop0 << 16) | ((byte)StackBehaviour.Push1 << 24));
public static readonly OpCode Ldarg_3 = new((0xff << 0) | (0x05 << 8) | ((byte)Code.Ldarg_3 << 16) | ((byte)FlowControl.Next << 24), ((byte)OpCodeType.Macro << 0) | ((byte)OperandType.InlineNone << 8) | ((byte)StackBehaviour.Pop0 << 16) | ((byte)StackBehaviour.Push1 << 24));
public static readonly OpCode Ldloc_0 = new((0xff << 0) | (0x06 << 8) | ((byte)Code.Ldloc_0 << 16) | ((byte)FlowControl.Next << 24), ((byte)OpCodeType.Macro << 0) | ((byte)OperandType.InlineNone << 8) | ((byte)StackBehaviour.Pop0 << 16) | ((byte)StackBehaviour.Push1 << 24));
public static readonly OpCode Ldloc_1 = new((0xff << 0) | (0x07 << 8) | ((byte)Code.Ldloc_1 << 16) | ((byte)FlowControl.Next << 24), ((byte)OpCodeType.Macro << 0) | ((byte)OperandType.InlineNone << 8) | ((byte)StackBehaviour.Pop0 << 16) | ((byte)StackBehaviour.Push1 << 24));
public static readonly OpCode Ldloc_2 = new((0xff << 0) | (0x08 << 8) | ((byte)Code.Ldloc_2 << 16) | ((byte)FlowControl.Next << 24), ((byte)OpCodeType.Macro << 0) | ((byte)OperandType.InlineNone << 8) | ((byte)StackBehaviour.Pop0 << 16) | ((byte)StackBehaviour.Push1 << 24));
public static readonly OpCode Ldloc_3 = new((0xff << 0) | (0x09 << 8) | ((byte)Code.Ldloc_3 << 16) | ((byte)FlowControl.Next << 24), ((byte)OpCodeType.Macro << 0) | ((byte)OperandType.InlineNone << 8) | ((byte)StackBehaviour.Pop0 << 16) | ((byte)StackBehaviour.Push1 << 24));
public static readonly OpCode Stloc_0 = new((0xff << 0) | (0x0a << 8) | ((byte)Code.Stloc_0 << 16) | ((byte)FlowControl.Next << 24), ((byte)OpCodeType.Macro << 0) | ((byte)OperandType.InlineNone << 8) | ((byte)StackBehaviour.Pop1 << 16) | ((byte)StackBehaviour.Push0 << 24));
public static readonly OpCode Stloc_1 = new((0xff << 0) | (0x0b << 8) | ((byte)Code.Stloc_1 << 16) | ((byte)FlowControl.Next << 24), ((byte)OpCodeType.Macro << 0) | ((byte)OperandType.InlineNone << 8) | ((byte)StackBehaviour.Pop1 << 16) | ((byte)StackBehaviour.Push0 << 24));
public static readonly OpCode Stloc_2 = new((0xff << 0) | (0x0c << 8) | ((byte)Code.Stloc_2 << 16) | ((byte)FlowControl.Next << 24), ((byte)OpCodeType.Macro << 0) | ((byte)OperandType.InlineNone << 8) | ((byte)StackBehaviour.Pop1 << 16) | ((byte)StackBehaviour.Push0 << 24));
public static readonly OpCode Stloc_3 = new((0xff << 0) | (0x0d << 8) | ((byte)Code.Stloc_3 << 16) | ((byte)FlowControl.Next << 24), ((byte)OpCodeType.Macro << 0) | ((byte)OperandType.InlineNone << 8) | ((byte)StackBehaviour.Pop1 << 16) | ((byte)StackBehaviour.Push0 << 24));
public static readonly OpCode Ldarg_S = new((0xff << 0) | (0x0e << 8) | ((byte)Code.Ldarg_S << 16) | ((byte)FlowControl.Next << 24), ((byte)OpCodeType.Macro << 0) | ((byte)OperandType.ShortInlineArg << 8) | ((byte)StackBehaviour.Pop0 << 16) | ((byte)StackBehaviour.Push1 << 24));
public static readonly OpCode Ldarga_S = new((0xff << 0) | (0x0f << 8) | ((byte)Code.Ldarga_S << 16) | ((byte)FlowControl.Next << 24), ((byte)OpCodeType.Macro << 0) | ((byte)OperandType.ShortInlineArg << 8) | ((byte)StackBehaviour.Pop0 << 16) | ((byte)StackBehaviour.Pushi << 24));
public static readonly OpCode Starg_S = new((0xff << 0) | (0x10 << 8) | ((byte)Code.Starg_S << 16) | ((byte)FlowControl.Next << 24), ((byte)OpCodeType.Macro << 0) | ((byte)OperandType.ShortInlineArg << 8) | ((byte)StackBehaviour.Pop1 << 16) | ((byte)StackBehaviour.Push0 << 24));
public static readonly OpCode Ldloc_S = new((0xff << 0) | (0x11 << 8) | ((byte)Code.Ldloc_S << 16) | ((byte)FlowControl.Next << 24), ((byte)OpCodeType.Macro << 0) | ((byte)OperandType.ShortInlineVar << 8) | ((byte)StackBehaviour.Pop0 << 16) | ((byte)StackBehaviour.Push1 << 24));
public static readonly OpCode Ldloca_S = new((0xff << 0) | (0x12 << 8) | ((byte)Code.Ldloca_S << 16) | ((byte)FlowControl.Next << 24), ((byte)OpCodeType.Macro << 0) | ((byte)OperandType.ShortInlineVar << 8) | ((byte)StackBehaviour.Pop0 << 16) | ((byte)StackBehaviour.Pushi << 24));
public static readonly OpCode Stloc_S = new((0xff << 0) | (0x13 << 8) | ((byte)Code.Stloc_S << 16) | ((byte)FlowControl.Next << 24), ((byte)OpCodeType.Macro << 0) | ((byte)OperandType.ShortInlineVar << 8) | ((byte)StackBehaviour.Pop1 << 16) | ((byte)StackBehaviour.Push0 << 24));
public static readonly OpCode Ldnull = new((0xff << 0) | (0x14 << 8) | ((byte)Code.Ldnull << 16) | ((byte)FlowControl.Next << 24), ((byte)OpCodeType.Primitive << 0) | ((byte)OperandType.InlineNone << 8) | ((byte)StackBehaviour.Pop0 << 16) | ((byte)StackBehaviour.Pushref << 24));
public static readonly OpCode Ldc_I4_M1 = new((0xff << 0) | (0x15 << 8) | ((byte)Code.Ldc_I4_M1 << 16) | ((byte)FlowControl.Next << 24), ((byte)OpCodeType.Macro << 0) | ((byte)OperandType.InlineNone << 8) | ((byte)StackBehaviour.Pop0 << 16) | ((byte)StackBehaviour.Pushi << 24));
public static readonly OpCode Ldc_I4_0 = new((0xff << 0) | (0x16 << 8) | ((byte)Code.Ldc_I4_0 << 16) | ((byte)FlowControl.Next << 24), ((byte)OpCodeType.Macro << 0) | ((byte)OperandType.InlineNone << 8) | ((byte)StackBehaviour.Pop0 << 16) | ((byte)StackBehaviour.Pushi << 24));
public static readonly OpCode Ldc_I4_1 = new((0xff << 0) | (0x17 << 8) | ((byte)Code.Ldc_I4_1 << 16) | ((byte)FlowControl.Next << 24), ((byte)OpCodeType.Macro << 0) | ((byte)OperandType.InlineNone << 8) | ((byte)StackBehaviour.Pop0 << 16) | ((byte)StackBehaviour.Pushi << 24));
public static readonly OpCode Ldc_I4_2 = new((0xff << 0) | (0x18 << 8) | ((byte)Code.Ldc_I4_2 << 16) | ((byte)FlowControl.Next << 24), ((byte)OpCodeType.Macro << 0) | ((byte)OperandType.InlineNone << 8) | ((byte)StackBehaviour.Pop0 << 16) | ((byte)StackBehaviour.Pushi << 24));
public static readonly OpCode Ldc_I4_3 = new((0xff << 0) | (0x19 << 8) | ((byte)Code.Ldc_I4_3 << 16) | ((byte)FlowControl.Next << 24), ((byte)OpCodeType.Macro << 0) | ((byte)OperandType.InlineNone << 8) | ((byte)StackBehaviour.Pop0 << 16) | ((byte)StackBehaviour.Pushi << 24));
public static readonly OpCode Ldc_I4_4 = new((0xff << 0) | (0x1a << 8) | ((byte)Code.Ldc_I4_4 << 16) | ((byte)FlowControl.Next << 24), ((byte)OpCodeType.Macro << 0) | ((byte)OperandType.InlineNone << 8) | ((byte)StackBehaviour.Pop0 << 16) | ((byte)StackBehaviour.Pushi << 24));
public static readonly OpCode Ldc_I4_5 = new((0xff << 0) | (0x1b << 8) | ((byte)Code.Ldc_I4_5 << 16) | ((byte)FlowControl.Next << 24), ((byte)OpCodeType.Macro << 0) | ((byte)OperandType.InlineNone << 8) | ((byte)StackBehaviour.Pop0 << 16) | ((byte)StackBehaviour.Pushi << 24));
public static readonly OpCode Ldc_I4_6 = new((0xff << 0) | (0x1c << 8) | ((byte)Code.Ldc_I4_6 << 16) | ((byte)FlowControl.Next << 24), ((byte)OpCodeType.Macro << 0) | ((byte)OperandType.InlineNone << 8) | ((byte)StackBehaviour.Pop0 << 16) | ((byte)StackBehaviour.Pushi << 24));
public static readonly OpCode Ldc_I4_7 = new((0xff << 0) | (0x1d << 8) | ((byte)Code.Ldc_I4_7 << 16) | ((byte)FlowControl.Next << 24), ((byte)OpCodeType.Macro << 0) | ((byte)OperandType.InlineNone << 8) | ((byte)StackBehaviour.Pop0 << 16) | ((byte)StackBehaviour.Pushi << 24));
public static readonly OpCode Ldc_I4_8 = new((0xff << 0) | (0x1e << 8) | ((byte)Code.Ldc_I4_8 << 16) | ((byte)FlowControl.Next << 24), ((byte)OpCodeType.Macro << 0) | ((byte)OperandType.InlineNone << 8) | ((byte)StackBehaviour.Pop0 << 16) | ((byte)StackBehaviour.Pushi << 24));
public static readonly OpCode Ldc_I4_S = new((0xff << 0) | (0x1f << 8) | ((byte)Code.Ldc_I4_S << 16) | ((byte)FlowControl.Next << 24), ((byte)OpCodeType.Macro << 0) | ((byte)OperandType.ShortInlineI << 8) | ((byte)StackBehaviour.Pop0 << 16) | ((byte)StackBehaviour.Pushi << 24));
public static readonly OpCode Ldc_I4 = new((0xff << 0) | (0x20 << 8) | ((byte)Code.Ldc_I4 << 16) | ((byte)FlowControl.Next << 24), ((byte)OpCodeType.Primitive << 0) | ((byte)OperandType.InlineI << 8) | ((byte)StackBehaviour.Pop0 << 16) | ((byte)StackBehaviour.Pushi << 24));
public static readonly OpCode Ldc_I8 = new((0xff << 0) | (0x21 << 8) | ((byte)Code.Ldc_I8 << 16) | ((byte)FlowControl.Next << 24), ((byte)OpCodeType.Primitive << 0) | ((byte)OperandType.InlineI8 << 8) | ((byte)StackBehaviour.Pop0 << 16) | ((byte)StackBehaviour.Pushi8 << 24));
public static readonly OpCode Ldc_R4 = new((0xff << 0) | (0x22 << 8) | ((byte)Code.Ldc_R4 << 16) | ((byte)FlowControl.Next << 24), ((byte)OpCodeType.Primitive << 0) | ((byte)OperandType.ShortInlineR << 8) | ((byte)StackBehaviour.Pop0 << 16) | ((byte)StackBehaviour.Pushr4 << 24));
public static readonly OpCode Ldc_R8 = new((0xff << 0) | (0x23 << 8) | ((byte)Code.Ldc_R8 << 16) | ((byte)FlowControl.Next << 24), ((byte)OpCodeType.Primitive << 0) | ((byte)OperandType.InlineR << 8) | ((byte)StackBehaviour.Pop0 << 16) | ((byte)StackBehaviour.Pushr8 << 24));
public static readonly OpCode Dup = new((0xff << 0) | (0x25 << 8) | ((byte)Code.Dup << 16) | ((byte)FlowControl.Next << 24), ((byte)OpCodeType.Primitive << 0) | ((byte)OperandType.InlineNone << 8) | ((byte)StackBehaviour.Pop1 << 16) | ((byte)StackBehaviour.Push1_push1 << 24));
public static readonly OpCode Pop = new((0xff << 0) | (0x26 << 8) | ((byte)Code.Pop << 16) | ((byte)FlowControl.Next << 24), ((byte)OpCodeType.Primitive << 0) | ((byte)OperandType.InlineNone << 8) | ((byte)StackBehaviour.Pop1 << 16) | ((byte)StackBehaviour.Push0 << 24));
public static readonly OpCode Jmp = new((0xff << 0) | (0x27 << 8) | ((byte)Code.Jmp << 16) | ((byte)FlowControl.Call << 24), ((byte)OpCodeType.Primitive << 0) | ((byte)OperandType.InlineMethod << 8) | ((byte)StackBehaviour.Pop0 << 16) | ((byte)StackBehaviour.Push0 << 24));
public static readonly OpCode Call = new((0xff << 0) | (0x28 << 8) | ((byte)Code.Call << 16) | ((byte)FlowControl.Call << 24), ((byte)OpCodeType.Primitive << 0) | ((byte)OperandType.InlineMethod << 8) | ((byte)StackBehaviour.Varpop << 16) | ((byte)StackBehaviour.Varpush << 24));
public static readonly OpCode Calli = new((0xff << 0) | (0x29 << 8) | ((byte)Code.Calli << 16) | ((byte)FlowControl.Call << 24), ((byte)OpCodeType.Primitive << 0) | ((byte)OperandType.InlineSig << 8) | ((byte)StackBehaviour.Varpop << 16) | ((byte)StackBehaviour.Varpush << 24));
public static readonly OpCode Ret = new((0xff << 0) | (0x2a << 8) | ((byte)Code.Ret << 16) | ((byte)FlowControl.Return << 24), ((byte)OpCodeType.Primitive << 0) | ((byte)OperandType.InlineNone << 8) | ((byte)StackBehaviour.Varpop << 16) | ((byte)StackBehaviour.Push0 << 24));
public static readonly OpCode Br_S = new((0xff << 0) | (0x2b << 8) | ((byte)Code.Br_S << 16) | ((byte)FlowControl.Branch << 24), ((byte)OpCodeType.Macro << 0) | ((byte)OperandType.ShortInlineBrTarget << 8) | ((byte)StackBehaviour.Pop0 << 16) | ((byte)StackBehaviour.Push0 << 24));
public static readonly OpCode Brfalse_S = new((0xff << 0) | (0x2c << 8) | ((byte)Code.Brfalse_S << 16) | ((byte)FlowControl.Cond_Branch << 24), ((byte)OpCodeType.Macro << 0) | ((byte)OperandType.ShortInlineBrTarget << 8) | ((byte)StackBehaviour.Popi << 16) | ((byte)StackBehaviour.Push0 << 24));
public static readonly OpCode Brtrue_S = new((0xff << 0) | (0x2d << 8) | ((byte)Code.Brtrue_S << 16) | ((byte)FlowControl.Cond_Branch << 24), ((byte)OpCodeType.Macro << 0) | ((byte)OperandType.ShortInlineBrTarget << 8) | ((byte)StackBehaviour.Popi << 16) | ((byte)StackBehaviour.Push0 << 24));
public static readonly OpCode Beq_S = new((0xff << 0) | (0x2e << 8) | ((byte)Code.Beq_S << 16) | ((byte)FlowControl.Cond_Branch << 24), ((byte)OpCodeType.Macro << 0) | ((byte)OperandType.ShortInlineBrTarget << 8) | ((byte)StackBehaviour.Pop1_pop1 << 16) | ((byte)StackBehaviour.Push0 << 24));
public static readonly OpCode Bge_S = new((0xff << 0) | (0x2f << 8) | ((byte)Code.Bge_S << 16) | ((byte)FlowControl.Cond_Branch << 24), ((byte)OpCodeType.Macro << 0) | ((byte)OperandType.ShortInlineBrTarget << 8) | ((byte)StackBehaviour.Pop1_pop1 << 16) | ((byte)StackBehaviour.Push0 << 24));
public static readonly OpCode Bgt_S = new((0xff << 0) | (0x30 << 8) | ((byte)Code.Bgt_S << 16) | ((byte)FlowControl.Cond_Branch << 24), ((byte)OpCodeType.Macro << 0) | ((byte)OperandType.ShortInlineBrTarget << 8) | ((byte)StackBehaviour.Pop1_pop1 << 16) | ((byte)StackBehaviour.Push0 << 24));
public static readonly OpCode Ble_S = new((0xff << 0) | (0x31 << 8) | ((byte)Code.Ble_S << 16) | ((byte)FlowControl.Cond_Branch << 24), ((byte)OpCodeType.Macro << 0) | ((byte)OperandType.ShortInlineBrTarget << 8) | ((byte)StackBehaviour.Pop1_pop1 << 16) | ((byte)StackBehaviour.Push0 << 24));
public static readonly OpCode Blt_S = new((0xff << 0) | (0x32 << 8) | ((byte)Code.Blt_S << 16) | ((byte)FlowControl.Cond_Branch << 24), ((byte)OpCodeType.Macro << 0) | ((byte)OperandType.ShortInlineBrTarget << 8) | ((byte)StackBehaviour.Pop1_pop1 << 16) | ((byte)StackBehaviour.Push0 << 24));
public static readonly OpCode Bne_Un_S = new((0xff << 0) | (0x33 << 8) | ((byte)Code.Bne_Un_S << 16) | ((byte)FlowControl.Cond_Branch << 24), ((byte)OpCodeType.Macro << 0) | ((byte)OperandType.ShortInlineBrTarget << 8) | ((byte)StackBehaviour.Pop1_pop1 << 16) | ((byte)StackBehaviour.Push0 << 24));
public static readonly OpCode Bge_Un_S = new((0xff << 0) | (0x34 << 8) | ((byte)Code.Bge_Un_S << 16) | ((byte)FlowControl.Cond_Branch << 24), ((byte)OpCodeType.Macro << 0) | ((byte)OperandType.ShortInlineBrTarget << 8) | ((byte)StackBehaviour.Pop1_pop1 << 16) | ((byte)StackBehaviour.Push0 << 24));
public static readonly OpCode Bgt_Un_S = new((0xff << 0) | (0x35 << 8) | ((byte)Code.Bgt_Un_S << 16) | ((byte)FlowControl.Cond_Branch << 24), ((byte)OpCodeType.Macro << 0) | ((byte)OperandType.ShortInlineBrTarget << 8) | ((byte)StackBehaviour.Pop1_pop1 << 16) | ((byte)StackBehaviour.Push0 << 24));
public static readonly OpCode Ble_Un_S = new((0xff << 0) | (0x36 << 8) | ((byte)Code.Ble_Un_S << 16) | ((byte)FlowControl.Cond_Branch << 24), ((byte)OpCodeType.Macro << 0) | ((byte)OperandType.ShortInlineBrTarget << 8) | ((byte)StackBehaviour.Pop1_pop1 << 16) | ((byte)StackBehaviour.Push0 << 24));
public static readonly OpCode Blt_Un_S = new((0xff << 0) | (0x37 << 8) | ((byte)Code.Blt_Un_S << 16) | ((byte)FlowControl.Cond_Branch << 24), ((byte)OpCodeType.Macro << 0) | ((byte)OperandType.ShortInlineBrTarget << 8) | ((byte)StackBehaviour.Pop1_pop1 << 16) | ((byte)StackBehaviour.Push0 << 24));
public static readonly OpCode Br = new((0xff << 0) | (0x38 << 8) | ((byte)Code.Br << 16) | ((byte)FlowControl.Branch << 24), ((byte)OpCodeType.Primitive << 0) | ((byte)OperandType.InlineBrTarget << 8) | ((byte)StackBehaviour.Pop0 << 16) | ((byte)StackBehaviour.Push0 << 24));
public static readonly OpCode Brfalse = new((0xff << 0) | (0x39 << 8) | ((byte)Code.Brfalse << 16) | ((byte)FlowControl.Cond_Branch << 24), ((byte)OpCodeType.Primitive << 0) | ((byte)OperandType.InlineBrTarget << 8) | ((byte)StackBehaviour.Popi << 16) | ((byte)StackBehaviour.Push0 << 24));
public static readonly OpCode Brtrue = new((0xff << 0) | (0x3a << 8) | ((byte)Code.Brtrue << 16) | ((byte)FlowControl.Cond_Branch << 24), ((byte)OpCodeType.Primitive << 0) | ((byte)OperandType.InlineBrTarget << 8) | ((byte)StackBehaviour.Popi << 16) | ((byte)StackBehaviour.Push0 << 24));
public static readonly OpCode Beq = new((0xff << 0) | (0x3b << 8) | ((byte)Code.Beq << 16) | ((byte)FlowControl.Cond_Branch << 24), ((byte)OpCodeType.Macro << 0) | ((byte)OperandType.InlineBrTarget << 8) | ((byte)StackBehaviour.Pop1_pop1 << 16) | ((byte)StackBehaviour.Push0 << 24));
public static readonly OpCode Bge = new((0xff << 0) | (0x3c << 8) | ((byte)Code.Bge << 16) | ((byte)FlowControl.Cond_Branch << 24), ((byte)OpCodeType.Macro << 0) | ((byte)OperandType.InlineBrTarget << 8) | ((byte)StackBehaviour.Pop1_pop1 << 16) | ((byte)StackBehaviour.Push0 << 24));
public static readonly OpCode Bgt = new((0xff << 0) | (0x3d << 8) | ((byte)Code.Bgt << 16) | ((byte)FlowControl.Cond_Branch << 24), ((byte)OpCodeType.Macro << 0) | ((byte)OperandType.InlineBrTarget << 8) | ((byte)StackBehaviour.Pop1_pop1 << 16) | ((byte)StackBehaviour.Push0 << 24));
public static readonly OpCode Ble = new((0xff << 0) | (0x3e << 8) | ((byte)Code.Ble << 16) | ((byte)FlowControl.Cond_Branch << 24), ((byte)OpCodeType.Macro << 0) | ((byte)OperandType.InlineBrTarget << 8) | ((byte)StackBehaviour.Pop1_pop1 << 16) | ((byte)StackBehaviour.Push0 << 24));
public static readonly OpCode Blt = new((0xff << 0) | (0x3f << 8) | ((byte)Code.Blt << 16) | ((byte)FlowControl.Cond_Branch << 24), ((byte)OpCodeType.Macro << 0) | ((byte)OperandType.InlineBrTarget << 8) | ((byte)StackBehaviour.Pop1_pop1 << 16) | ((byte)StackBehaviour.Push0 << 24));
public static readonly OpCode Bne_Un = new((0xff << 0) | (0x40 << 8) | ((byte)Code.Bne_Un << 16) | ((byte)FlowControl.Cond_Branch << 24), ((byte)OpCodeType.Macro << 0) | ((byte)OperandType.InlineBrTarget << 8) | ((byte)StackBehaviour.Pop1_pop1 << 16) | ((byte)StackBehaviour.Push0 << 24));
public static readonly OpCode Bge_Un = new((0xff << 0) | (0x41 << 8) | ((byte)Code.Bge_Un << 16) | ((byte)FlowControl.Cond_Branch << 24), ((byte)OpCodeType.Macro << 0) | ((byte)OperandType.InlineBrTarget << 8) | ((byte)StackBehaviour.Pop1_pop1 << 16) | ((byte)StackBehaviour.Push0 << 24));
public static readonly OpCode Bgt_Un = new((0xff << 0) | (0x42 << 8) | ((byte)Code.Bgt_Un << 16) | ((byte)FlowControl.Cond_Branch << 24), ((byte)OpCodeType.Macro << 0) | ((byte)OperandType.InlineBrTarget << 8) | ((byte)StackBehaviour.Pop1_pop1 << 16) | ((byte)StackBehaviour.Push0 << 24));
public static readonly OpCode Ble_Un = new((0xff << 0) | (0x43 << 8) | ((byte)Code.Ble_Un << 16) | ((byte)FlowControl.Cond_Branch << 24), ((byte)OpCodeType.Macro << 0) | ((byte)OperandType.InlineBrTarget << 8) | ((byte)StackBehaviour.Pop1_pop1 << 16) | ((byte)StackBehaviour.Push0 << 24));
public static readonly OpCode Blt_Un = new((0xff << 0) | (0x44 << 8) | ((byte)Code.Blt_Un << 16) | ((byte)FlowControl.Cond_Branch << 24), ((byte)OpCodeType.Macro << 0) | ((byte)OperandType.InlineBrTarget << 8) | ((byte)StackBehaviour.Pop1_pop1 << 16) | ((byte)StackBehaviour.Push0 << 24));
public static readonly OpCode Switch = new((0xff << 0) | (0x45 << 8) | ((byte)Code.Switch << 16) | ((byte)FlowControl.Cond_Branch << 24), ((byte)OpCodeType.Primitive << 0) | ((byte)OperandType.InlineSwitch << 8) | ((byte)StackBehaviour.Popi << 16) | ((byte)StackBehaviour.Push0 << 24));
public static readonly OpCode Ldind_I1 = new((0xff << 0) | (0x46 << 8) | ((byte)Code.Ldind_I1 << 16) | ((byte)FlowControl.Next << 24), ((byte)OpCodeType.Primitive << 0) | ((byte)OperandType.InlineNone << 8) | ((byte)StackBehaviour.Popi << 16) | ((byte)StackBehaviour.Pushi << 24));
public static readonly OpCode Ldind_U1 = new((0xff << 0) | (0x47 << 8) | ((byte)Code.Ldind_U1 << 16) | ((byte)FlowControl.Next << 24), ((byte)OpCodeType.Primitive << 0) | ((byte)OperandType.InlineNone << 8) | ((byte)StackBehaviour.Popi << 16) | ((byte)StackBehaviour.Pushi << 24));
public static readonly OpCode Ldind_I2 = new((0xff << 0) | (0x48 << 8) | ((byte)Code.Ldind_I2 << 16) | ((byte)FlowControl.Next << 24), ((byte)OpCodeType.Primitive << 0) | ((byte)OperandType.InlineNone << 8) | ((byte)StackBehaviour.Popi << 16) | ((byte)StackBehaviour.Pushi << 24));
public static readonly OpCode Ldind_U2 = new((0xff << 0) | (0x49 << 8) | ((byte)Code.Ldind_U2 << 16) | ((byte)FlowControl.Next << 24), ((byte)OpCodeType.Primitive << 0) | ((byte)OperandType.InlineNone << 8) | ((byte)StackBehaviour.Popi << 16) | ((byte)StackBehaviour.Pushi << 24));
public static readonly OpCode Ldind_I4 = new((0xff << 0) | (0x4a << 8) | ((byte)Code.Ldind_I4 << 16) | ((byte)FlowControl.Next << 24), ((byte)OpCodeType.Primitive << 0) | ((byte)OperandType.InlineNone << 8) | ((byte)StackBehaviour.Popi << 16) | ((byte)StackBehaviour.Pushi << 24));
public static readonly OpCode Ldind_U4 = new((0xff << 0) | (0x4b << 8) | ((byte)Code.Ldind_U4 << 16) | ((byte)FlowControl.Next << 24), ((byte)OpCodeType.Primitive << 0) | ((byte)OperandType.InlineNone << 8) | ((byte)StackBehaviour.Popi << 16) | ((byte)StackBehaviour.Pushi << 24));
public static readonly OpCode Ldind_I8 = new((0xff << 0) | (0x4c << 8) | ((byte)Code.Ldind_I8 << 16) | ((byte)FlowControl.Next << 24), ((byte)OpCodeType.Primitive << 0) | ((byte)OperandType.InlineNone << 8) | ((byte)StackBehaviour.Popi << 16) | ((byte)StackBehaviour.Pushi8 << 24));
public static readonly OpCode Ldind_I = new((0xff << 0) | (0x4d << 8) | ((byte)Code.Ldind_I << 16) | ((byte)FlowControl.Next << 24), ((byte)OpCodeType.Primitive << 0) | ((byte)OperandType.InlineNone << 8) | ((byte)StackBehaviour.Popi << 16) | ((byte)StackBehaviour.Pushi << 24));
public static readonly OpCode Ldind_R4 = new((0xff << 0) | (0x4e << 8) | ((byte)Code.Ldind_R4 << 16) | ((byte)FlowControl.Next << 24), ((byte)OpCodeType.Primitive << 0) | ((byte)OperandType.InlineNone << 8) | ((byte)StackBehaviour.Popi << 16) | ((byte)StackBehaviour.Pushr4 << 24));
public static readonly OpCode Ldind_R8 = new((0xff << 0) | (0x4f << 8) | ((byte)Code.Ldind_R8 << 16) | ((byte)FlowControl.Next << 24), ((byte)OpCodeType.Primitive << 0) | ((byte)OperandType.InlineNone << 8) | ((byte)StackBehaviour.Popi << 16) | ((byte)StackBehaviour.Pushr8 << 24));
public static readonly OpCode Ldind_Ref = new((0xff << 0) | (0x50 << 8) | ((byte)Code.Ldind_Ref << 16) | ((byte)FlowControl.Next << 24), ((byte)OpCodeType.Primitive << 0) | ((byte)OperandType.InlineNone << 8) | ((byte)StackBehaviour.Popi << 16) | ((byte)StackBehaviour.Pushref << 24));
public static readonly OpCode Stind_Ref = new((0xff << 0) | (0x51 << 8) | ((byte)Code.Stind_Ref << 16) | ((byte)FlowControl.Next << 24), ((byte)OpCodeType.Primitive << 0) | ((byte)OperandType.InlineNone << 8) | ((byte)StackBehaviour.Popi_popi << 16) | ((byte)StackBehaviour.Push0 << 24));
public static readonly OpCode Stind_I1 = new((0xff << 0) | (0x52 << 8) | ((byte)Code.Stind_I1 << 16) | ((byte)FlowControl.Next << 24), ((byte)OpCodeType.Primitive << 0) | ((byte)OperandType.InlineNone << 8) | ((byte)StackBehaviour.Popi_popi << 16) | ((byte)StackBehaviour.Push0 << 24));
public static readonly OpCode Stind_I2 = new((0xff << 0) | (0x53 << 8) | ((byte)Code.Stind_I2 << 16) | ((byte)FlowControl.Next << 24), ((byte)OpCodeType.Primitive << 0) | ((byte)OperandType.InlineNone << 8) | ((byte)StackBehaviour.Popi_popi << 16) | ((byte)StackBehaviour.Push0 << 24));
public static readonly OpCode Stind_I4 = new((0xff << 0) | (0x54 << 8) | ((byte)Code.Stind_I4 << 16) | ((byte)FlowControl.Next << 24), ((byte)OpCodeType.Primitive << 0) | ((byte)OperandType.InlineNone << 8) | ((byte)StackBehaviour.Popi_popi << 16) | ((byte)StackBehaviour.Push0 << 24));
public static readonly OpCode Stind_I8 = new((0xff << 0) | (0x55 << 8) | ((byte)Code.Stind_I8 << 16) | ((byte)FlowControl.Next << 24), ((byte)OpCodeType.Primitive << 0) | ((byte)OperandType.InlineNone << 8) | ((byte)StackBehaviour.Popi_popi8 << 16) | ((byte)StackBehaviour.Push0 << 24));
public static readonly OpCode Stind_R4 = new((0xff << 0) | (0x56 << 8) | ((byte)Code.Stind_R4 << 16) | ((byte)FlowControl.Next << 24), ((byte)OpCodeType.Primitive << 0) | ((byte)OperandType.InlineNone << 8) | ((byte)StackBehaviour.Popi_popr4 << 16) | ((byte)StackBehaviour.Push0 << 24));
public static readonly OpCode Stind_R8 = new((0xff << 0) | (0x57 << 8) | ((byte)Code.Stind_R8 << 16) | ((byte)FlowControl.Next << 24), ((byte)OpCodeType.Primitive << 0) | ((byte)OperandType.InlineNone << 8) | ((byte)StackBehaviour.Popi_popr8 << 16) | ((byte)StackBehaviour.Push0 << 24));
public static readonly OpCode Add = new((0xff << 0) | (0x58 << 8) | ((byte)Code.Add << 16) | ((byte)FlowControl.Next << 24), ((byte)OpCodeType.Primitive << 0) | ((byte)OperandType.InlineNone << 8) | ((byte)StackBehaviour.Pop1_pop1 << 16) | ((byte)StackBehaviour.Push1 << 24));
public static readonly OpCode Sub = new((0xff << 0) | (0x59 << 8) | ((byte)Code.Sub << 16) | ((byte)FlowControl.Next << 24), ((byte)OpCodeType.Primitive << 0) | ((byte)OperandType.InlineNone << 8) | ((byte)StackBehaviour.Pop1_pop1 << 16) | ((byte)StackBehaviour.Push1 << 24));
public static readonly OpCode Mul = new((0xff << 0) | (0x5a << 8) | ((byte)Code.Mul << 16) | ((byte)FlowControl.Next << 24), ((byte)OpCodeType.Primitive << 0) | ((byte)OperandType.InlineNone << 8) | ((byte)StackBehaviour.Pop1_pop1 << 16) | ((byte)StackBehaviour.Push1 << 24));
public static readonly OpCode Div = new((0xff << 0) | (0x5b << 8) | ((byte)Code.Div << 16) | ((byte)FlowControl.Next << 24), ((byte)OpCodeType.Primitive << 0) | ((byte)OperandType.InlineNone << 8) | ((byte)StackBehaviour.Pop1_pop1 << 16) | ((byte)StackBehaviour.Push1 << 24));
public static readonly OpCode Div_Un = new((0xff << 0) | (0x5c << 8) | ((byte)Code.Div_Un << 16) | ((byte)FlowControl.Next << 24), ((byte)OpCodeType.Primitive << 0) | ((byte)OperandType.InlineNone << 8) | ((byte)StackBehaviour.Pop1_pop1 << 16) | ((byte)StackBehaviour.Push1 << 24));
public static readonly OpCode Rem = new((0xff << 0) | (0x5d << 8) | ((byte)Code.Rem << 16) | ((byte)FlowControl.Next << 24), ((byte)OpCodeType.Primitive << 0) | ((byte)OperandType.InlineNone << 8) | ((byte)StackBehaviour.Pop1_pop1 << 16) | ((byte)StackBehaviour.Push1 << 24));
public static readonly OpCode Rem_Un = new((0xff << 0) | (0x5e << 8) | ((byte)Code.Rem_Un << 16) | ((byte)FlowControl.Next << 24), ((byte)OpCodeType.Primitive << 0) | ((byte)OperandType.InlineNone << 8) | ((byte)StackBehaviour.Pop1_pop1 << 16) | ((byte)StackBehaviour.Push1 << 24));
public static readonly OpCode And = new((0xff << 0) | (0x5f << 8) | ((byte)Code.And << 16) | ((byte)FlowControl.Next << 24), ((byte)OpCodeType.Primitive << 0) | ((byte)OperandType.InlineNone << 8) | ((byte)StackBehaviour.Pop1_pop1 << 16) | ((byte)StackBehaviour.Push1 << 24));
public static readonly OpCode Or = new((0xff << 0) | (0x60 << 8) | ((byte)Code.Or << 16) | ((byte)FlowControl.Next << 24), ((byte)OpCodeType.Primitive << 0) | ((byte)OperandType.InlineNone << 8) | ((byte)StackBehaviour.Pop1_pop1 << 16) | ((byte)StackBehaviour.Push1 << 24));
public static readonly OpCode Xor = new((0xff << 0) | (0x61 << 8) | ((byte)Code.Xor << 16) | ((byte)FlowControl.Next << 24), ((byte)OpCodeType.Primitive << 0) | ((byte)OperandType.InlineNone << 8) | ((byte)StackBehaviour.Pop1_pop1 << 16) | ((byte)StackBehaviour.Push1 << 24));
public static readonly OpCode Shl = new((0xff << 0) | (0x62 << 8) | ((byte)Code.Shl << 16) | ((byte)FlowControl.Next << 24), ((byte)OpCodeType.Primitive << 0) | ((byte)OperandType.InlineNone << 8) | ((byte)StackBehaviour.Pop1_pop1 << 16) | ((byte)StackBehaviour.Push1 << 24));
public static readonly OpCode Shr = new((0xff << 0) | (0x63 << 8) | ((byte)Code.Shr << 16) | ((byte)FlowControl.Next << 24), ((byte)OpCodeType.Primitive << 0) | ((byte)OperandType.InlineNone << 8) | ((byte)StackBehaviour.Pop1_pop1 << 16) | ((byte)StackBehaviour.Push1 << 24));
public static readonly OpCode Shr_Un = new((0xff << 0) | (0x64 << 8) | ((byte)Code.Shr_Un << 16) | ((byte)FlowControl.Next << 24), ((byte)OpCodeType.Primitive << 0) | ((byte)OperandType.InlineNone << 8) | ((byte)StackBehaviour.Pop1_pop1 << 16) | ((byte)StackBehaviour.Push1 << 24));
public static readonly OpCode Neg = new((0xff << 0) | (0x65 << 8) | ((byte)Code.Neg << 16) | ((byte)FlowControl.Next << 24), ((byte)OpCodeType.Primitive << 0) | ((byte)OperandType.InlineNone << 8) | ((byte)StackBehaviour.Pop1 << 16) | ((byte)StackBehaviour.Push1 << 24));
public static readonly OpCode Not = new((0xff << 0) | (0x66 << 8) | ((byte)Code.Not << 16) | ((byte)FlowControl.Next << 24), ((byte)OpCodeType.Primitive << 0) | ((byte)OperandType.InlineNone << 8) | ((byte)StackBehaviour.Pop1 << 16) | ((byte)StackBehaviour.Push1 << 24));
public static readonly OpCode Conv_I1 = new((0xff << 0) | (0x67 << 8) | ((byte)Code.Conv_I1 << 16) | ((byte)FlowControl.Next << 24), ((byte)OpCodeType.Primitive << 0) | ((byte)OperandType.InlineNone << 8) | ((byte)StackBehaviour.Pop1 << 16) | ((byte)StackBehaviour.Pushi << 24));
public static readonly OpCode Conv_I2 = new((0xff << 0) | (0x68 << 8) | ((byte)Code.Conv_I2 << 16) | ((byte)FlowControl.Next << 24), ((byte)OpCodeType.Primitive << 0) | ((byte)OperandType.InlineNone << 8) | ((byte)StackBehaviour.Pop1 << 16) | ((byte)StackBehaviour.Pushi << 24));
public static readonly OpCode Conv_I4 = new((0xff << 0) | (0x69 << 8) | ((byte)Code.Conv_I4 << 16) | ((byte)FlowControl.Next << 24), ((byte)OpCodeType.Primitive << 0) | ((byte)OperandType.InlineNone << 8) | ((byte)StackBehaviour.Pop1 << 16) | ((byte)StackBehaviour.Pushi << 24));
public static readonly OpCode Conv_I8 = new((0xff << 0) | (0x6a << 8) | ((byte)Code.Conv_I8 << 16) | ((byte)FlowControl.Next << 24), ((byte)OpCodeType.Primitive << 0) | ((byte)OperandType.InlineNone << 8) | ((byte)StackBehaviour.Pop1 << 16) | ((byte)StackBehaviour.Pushi8 << 24));
public static readonly OpCode Conv_R4 = new((0xff << 0) | (0x6b << 8) | ((byte)Code.Conv_R4 << 16) | ((byte)FlowControl.Next << 24), ((byte)OpCodeType.Primitive << 0) | ((byte)OperandType.InlineNone << 8) | ((byte)StackBehaviour.Pop1 << 16) | ((byte)StackBehaviour.Pushr4 << 24));
public static readonly OpCode Conv_R8 = new((0xff << 0) | (0x6c << 8) | ((byte)Code.Conv_R8 << 16) | ((byte)FlowControl.Next << 24), ((byte)OpCodeType.Primitive << 0) | ((byte)OperandType.InlineNone << 8) | ((byte)StackBehaviour.Pop1 << 16) | ((byte)StackBehaviour.Pushr8 << 24));
public static readonly OpCode Conv_U4 = new((0xff << 0) | (0x6d << 8) | ((byte)Code.Conv_U4 << 16) | ((byte)FlowControl.Next << 24), ((byte)OpCodeType.Primitive << 0) | ((byte)OperandType.InlineNone << 8) | ((byte)StackBehaviour.Pop1 << 16) | ((byte)StackBehaviour.Pushi << 24));
public static readonly OpCode Conv_U8 = new((0xff << 0) | (0x6e << 8) | ((byte)Code.Conv_U8 << 16) | ((byte)FlowControl.Next << 24), ((byte)OpCodeType.Primitive << 0) | ((byte)OperandType.InlineNone << 8) | ((byte)StackBehaviour.Pop1 << 16) | ((byte)StackBehaviour.Pushi8 << 24));
public static readonly OpCode Callvirt = new((0xff << 0) | (0x6f << 8) | ((byte)Code.Callvirt << 16) | ((byte)FlowControl.Call << 24), ((byte)OpCodeType.Objmodel << 0) | ((byte)OperandType.InlineMethod << 8) | ((byte)StackBehaviour.Varpop << 16) | ((byte)StackBehaviour.Varpush << 24));
public static readonly OpCode Cpobj = new((0xff << 0) | (0x70 << 8) | ((byte)Code.Cpobj << 16) | ((byte)FlowControl.Next << 24), ((byte)OpCodeType.Objmodel << 0) | ((byte)OperandType.InlineType << 8) | ((byte)StackBehaviour.Popi_popi << 16) | ((byte)StackBehaviour.Push0 << 24));
public static readonly OpCode Ldobj = new((0xff << 0) | (0x71 << 8) | ((byte)Code.Ldobj << 16) | ((byte)FlowControl.Next << 24), ((byte)OpCodeType.Objmodel << 0) | ((byte)OperandType.InlineType << 8) | ((byte)StackBehaviour.Popi << 16) | ((byte)StackBehaviour.Push1 << 24));
public static readonly OpCode Ldstr = new((0xff << 0) | (0x72 << 8) | ((byte)Code.Ldstr << 16) | ((byte)FlowControl.Next << 24), ((byte)OpCodeType.Objmodel << 0) | ((byte)OperandType.InlineString << 8) | ((byte)StackBehaviour.Pop0 << 16) | ((byte)StackBehaviour.Pushref << 24));
public static readonly OpCode Newobj = new((0xff << 0) | (0x73 << 8) | ((byte)Code.Newobj << 16) | ((byte)FlowControl.Call << 24), ((byte)OpCodeType.Objmodel << 0) | ((byte)OperandType.InlineMethod << 8) | ((byte)StackBehaviour.Varpop << 16) | ((byte)StackBehaviour.Pushref << 24));
public static readonly OpCode Castclass = new((0xff << 0) | (0x74 << 8) | ((byte)Code.Castclass << 16) | ((byte)FlowControl.Next << 24), ((byte)OpCodeType.Objmodel << 0) | ((byte)OperandType.InlineType << 8) | ((byte)StackBehaviour.Popref << 16) | ((byte)StackBehaviour.Pushref << 24));
public static readonly OpCode Isinst = new((0xff << 0) | (0x75 << 8) | ((byte)Code.Isinst << 16) | ((byte)FlowControl.Next << 24), ((byte)OpCodeType.Objmodel << 0) | ((byte)OperandType.InlineType << 8) | ((byte)StackBehaviour.Popref << 16) | ((byte)StackBehaviour.Pushi << 24));
public static readonly OpCode Conv_R_Un = new((0xff << 0) | (0x76 << 8) | ((byte)Code.Conv_R_Un << 16) | ((byte)FlowControl.Next << 24), ((byte)OpCodeType.Primitive << 0) | ((byte)OperandType.InlineNone << 8) | ((byte)StackBehaviour.Pop1 << 16) | ((byte)StackBehaviour.Pushr8 << 24));
public static readonly OpCode Unbox = new((0xff << 0) | (0x79 << 8) | ((byte)Code.Unbox << 16) | ((byte)FlowControl.Next << 24), ((byte)OpCodeType.Primitive << 0) | ((byte)OperandType.InlineType << 8) | ((byte)StackBehaviour.Popref << 16) | ((byte)StackBehaviour.Pushi << 24));
public static readonly OpCode Throw = new((0xff << 0) | (0x7a << 8) | ((byte)Code.Throw << 16) | ((byte)FlowControl.Throw << 24), ((byte)OpCodeType.Objmodel << 0) | ((byte)OperandType.InlineNone << 8) | ((byte)StackBehaviour.Popref << 16) | ((byte)StackBehaviour.Push0 << 24));
public static readonly OpCode Ldfld = new((0xff << 0) | (0x7b << 8) | ((byte)Code.Ldfld << 16) | ((byte)FlowControl.Next << 24), ((byte)OpCodeType.Objmodel << 0) | ((byte)OperandType.InlineField << 8) | ((byte)StackBehaviour.Popref << 16) | ((byte)StackBehaviour.Push1 << 24));
public static readonly OpCode Ldflda = new((0xff << 0) | (0x7c << 8) | ((byte)Code.Ldflda << 16) | ((byte)FlowControl.Next << 24), ((byte)OpCodeType.Objmodel << 0) | ((byte)OperandType.InlineField << 8) | ((byte)StackBehaviour.Popref << 16) | ((byte)StackBehaviour.Pushi << 24));
public static readonly OpCode Stfld = new((0xff << 0) | (0x7d << 8) | ((byte)Code.Stfld << 16) | ((byte)FlowControl.Next << 24), ((byte)OpCodeType.Objmodel << 0) | ((byte)OperandType.InlineField << 8) | ((byte)StackBehaviour.Popref_pop1 << 16) | ((byte)StackBehaviour.Push0 << 24));
public static readonly OpCode Ldsfld = new((0xff << 0) | (0x7e << 8) | ((byte)Code.Ldsfld << 16) | ((byte)FlowControl.Next << 24), ((byte)OpCodeType.Objmodel << 0) | ((byte)OperandType.InlineField << 8) | ((byte)StackBehaviour.Pop0 << 16) | ((byte)StackBehaviour.Push1 << 24));
public static readonly OpCode Ldsflda = new((0xff << 0) | (0x7f << 8) | ((byte)Code.Ldsflda << 16) | ((byte)FlowControl.Next << 24), ((byte)OpCodeType.Objmodel << 0) | ((byte)OperandType.InlineField << 8) | ((byte)StackBehaviour.Pop0 << 16) | ((byte)StackBehaviour.Pushi << 24));
public static readonly OpCode Stsfld = new((0xff << 0) | (0x80 << 8) | ((byte)Code.Stsfld << 16) | ((byte)FlowControl.Next << 24), ((byte)OpCodeType.Objmodel << 0) | ((byte)OperandType.InlineField << 8) | ((byte)StackBehaviour.Pop1 << 16) | ((byte)StackBehaviour.Push0 << 24));
public static readonly OpCode Stobj = new((0xff << 0) | (0x81 << 8) | ((byte)Code.Stobj << 16) | ((byte)FlowControl.Next << 24), ((byte)OpCodeType.Objmodel << 0) | ((byte)OperandType.InlineType << 8) | ((byte)StackBehaviour.Popi_pop1 << 16) | ((byte)StackBehaviour.Push0 << 24));
public static readonly OpCode Conv_Ovf_I1_Un = new((0xff << 0) | (0x82 << 8) | ((byte)Code.Conv_Ovf_I1_Un << 16) | ((byte)FlowControl.Next << 24), ((byte)OpCodeType.Primitive << 0) | ((byte)OperandType.InlineNone << 8) | ((byte)StackBehaviour.Pop1 << 16) | ((byte)StackBehaviour.Pushi << 24));
public static readonly OpCode Conv_Ovf_I2_Un = new((0xff << 0) | (0x83 << 8) | ((byte)Code.Conv_Ovf_I2_Un << 16) | ((byte)FlowControl.Next << 24), ((byte)OpCodeType.Primitive << 0) | ((byte)OperandType.InlineNone << 8) | ((byte)StackBehaviour.Pop1 << 16) | ((byte)StackBehaviour.Pushi << 24));
public static readonly OpCode Conv_Ovf_I4_Un = new((0xff << 0) | (0x84 << 8) | ((byte)Code.Conv_Ovf_I4_Un << 16) | ((byte)FlowControl.Next << 24), ((byte)OpCodeType.Primitive << 0) | ((byte)OperandType.InlineNone << 8) | ((byte)StackBehaviour.Pop1 << 16) | ((byte)StackBehaviour.Pushi << 24));
public static readonly OpCode Conv_Ovf_I8_Un = new((0xff << 0) | (0x85 << 8) | ((byte)Code.Conv_Ovf_I8_Un << 16) | ((byte)FlowControl.Next << 24), ((byte)OpCodeType.Primitive << 0) | ((byte)OperandType.InlineNone << 8) | ((byte)StackBehaviour.Pop1 << 16) | ((byte)StackBehaviour.Pushi8 << 24));
public static readonly OpCode Conv_Ovf_U1_Un = new((0xff << 0) | (0x86 << 8) | ((byte)Code.Conv_Ovf_U1_Un << 16) | ((byte)FlowControl.Next << 24), ((byte)OpCodeType.Primitive << 0) | ((byte)OperandType.InlineNone << 8) | ((byte)StackBehaviour.Pop1 << 16) | ((byte)StackBehaviour.Pushi << 24));
public static readonly OpCode Conv_Ovf_U2_Un = new((0xff << 0) | (0x87 << 8) | ((byte)Code.Conv_Ovf_U2_Un << 16) | ((byte)FlowControl.Next << 24), ((byte)OpCodeType.Primitive << 0) | ((byte)OperandType.InlineNone << 8) | ((byte)StackBehaviour.Pop1 << 16) | ((byte)StackBehaviour.Pushi << 24));
public static readonly OpCode Conv_Ovf_U4_Un = new((0xff << 0) | (0x88 << 8) | ((byte)Code.Conv_Ovf_U4_Un << 16) | ((byte)FlowControl.Next << 24), ((byte)OpCodeType.Primitive << 0) | ((byte)OperandType.InlineNone << 8) | ((byte)StackBehaviour.Pop1 << 16) | ((byte)StackBehaviour.Pushi << 24));
public static readonly OpCode Conv_Ovf_U8_Un = new((0xff << 0) | (0x89 << 8) | ((byte)Code.Conv_Ovf_U8_Un << 16) | ((byte)FlowControl.Next << 24), ((byte)OpCodeType.Primitive << 0) | ((byte)OperandType.InlineNone << 8) | ((byte)StackBehaviour.Pop1 << 16) | ((byte)StackBehaviour.Pushi8 << 24));
public static readonly OpCode Conv_Ovf_I_Un = new((0xff << 0) | (0x8a << 8) | ((byte)Code.Conv_Ovf_I_Un << 16) | ((byte)FlowControl.Next << 24), ((byte)OpCodeType.Primitive << 0) | ((byte)OperandType.InlineNone << 8) | ((byte)StackBehaviour.Pop1 << 16) | ((byte)StackBehaviour.Pushi << 24));
public static readonly OpCode Conv_Ovf_U_Un = new((0xff << 0) | (0x8b << 8) | ((byte)Code.Conv_Ovf_U_Un << 16) | ((byte)FlowControl.Next << 24), ((byte)OpCodeType.Primitive << 0) | ((byte)OperandType.InlineNone << 8) | ((byte)StackBehaviour.Pop1 << 16) | ((byte)StackBehaviour.Pushi << 24));
public static readonly OpCode Box = new((0xff << 0) | (0x8c << 8) | ((byte)Code.Box << 16) | ((byte)FlowControl.Next << 24), ((byte)OpCodeType.Primitive << 0) | ((byte)OperandType.InlineType << 8) | ((byte)StackBehaviour.Pop1 << 16) | ((byte)StackBehaviour.Pushref << 24));
public static readonly OpCode Newarr = new((0xff << 0) | (0x8d << 8) | ((byte)Code.Newarr << 16) | ((byte)FlowControl.Next << 24), ((byte)OpCodeType.Objmodel << 0) | ((byte)OperandType.InlineType << 8) | ((byte)StackBehaviour.Popi << 16) | ((byte)StackBehaviour.Pushref << 24));
public static readonly OpCode Ldlen = new((0xff << 0) | (0x8e << 8) | ((byte)Code.Ldlen << 16) | ((byte)FlowControl.Next << 24), ((byte)OpCodeType.Objmodel << 0) | ((byte)OperandType.InlineNone << 8) | ((byte)StackBehaviour.Popref << 16) | ((byte)StackBehaviour.Pushi << 24));
public static readonly OpCode Ldelema = new((0xff << 0) | (0x8f << 8) | ((byte)Code.Ldelema << 16) | ((byte)FlowControl.Next << 24), ((byte)OpCodeType.Objmodel << 0) | ((byte)OperandType.InlineType << 8) | ((byte)StackBehaviour.Popref_popi << 16) | ((byte)StackBehaviour.Pushi << 24));
public static readonly OpCode Ldelem_I1 = new((0xff << 0) | (0x90 << 8) | ((byte)Code.Ldelem_I1 << 16) | ((byte)FlowControl.Next << 24), ((byte)OpCodeType.Objmodel << 0) | ((byte)OperandType.InlineNone << 8) | ((byte)StackBehaviour.Popref_popi << 16) | ((byte)StackBehaviour.Pushi << 24));
public static readonly OpCode Ldelem_U1 = new((0xff << 0) | (0x91 << 8) | ((byte)Code.Ldelem_U1 << 16) | ((byte)FlowControl.Next << 24), ((byte)OpCodeType.Objmodel << 0) | ((byte)OperandType.InlineNone << 8) | ((byte)StackBehaviour.Popref_popi << 16) | ((byte)StackBehaviour.Pushi << 24));
public static readonly OpCode Ldelem_I2 = new((0xff << 0) | (0x92 << 8) | ((byte)Code.Ldelem_I2 << 16) | ((byte)FlowControl.Next << 24), ((byte)OpCodeType.Objmodel << 0) | ((byte)OperandType.InlineNone << 8) | ((byte)StackBehaviour.Popref_popi << 16) | ((byte)StackBehaviour.Pushi << 24));
public static readonly OpCode Ldelem_U2 = new((0xff << 0) | (0x93 << 8) | ((byte)Code.Ldelem_U2 << 16) | ((byte)FlowControl.Next << 24), ((byte)OpCodeType.Objmodel << 0) | ((byte)OperandType.InlineNone << 8) | ((byte)StackBehaviour.Popref_popi << 16) | ((byte)StackBehaviour.Pushi << 24));
public static readonly OpCode Ldelem_I4 = new((0xff << 0) | (0x94 << 8) | ((byte)Code.Ldelem_I4 << 16) | ((byte)FlowControl.Next << 24), ((byte)OpCodeType.Objmodel << 0) | ((byte)OperandType.InlineNone << 8) | ((byte)StackBehaviour.Popref_popi << 16) | ((byte)StackBehaviour.Pushi << 24));
public static readonly OpCode Ldelem_U4 = new((0xff << 0) | (0x95 << 8) | ((byte)Code.Ldelem_U4 << 16) | ((byte)FlowControl.Next << 24), ((byte)OpCodeType.Objmodel << 0) | ((byte)OperandType.InlineNone << 8) | ((byte)StackBehaviour.Popref_popi << 16) | ((byte)StackBehaviour.Pushi << 24));
public static readonly OpCode Ldelem_I8 = new((0xff << 0) | (0x96 << 8) | ((byte)Code.Ldelem_I8 << 16) | ((byte)FlowControl.Next << 24), ((byte)OpCodeType.Objmodel << 0) | ((byte)OperandType.InlineNone << 8) | ((byte)StackBehaviour.Popref_popi << 16) | ((byte)StackBehaviour.Pushi8 << 24));
public static readonly OpCode Ldelem_I = new((0xff << 0) | (0x97 << 8) | ((byte)Code.Ldelem_I << 16) | ((byte)FlowControl.Next << 24), ((byte)OpCodeType.Objmodel << 0) | ((byte)OperandType.InlineNone << 8) | ((byte)StackBehaviour.Popref_popi << 16) | ((byte)StackBehaviour.Pushi << 24));
public static readonly OpCode Ldelem_R4 = new((0xff << 0) | (0x98 << 8) | ((byte)Code.Ldelem_R4 << 16) | ((byte)FlowControl.Next << 24), ((byte)OpCodeType.Objmodel << 0) | ((byte)OperandType.InlineNone << 8) | ((byte)StackBehaviour.Popref_popi << 16) | ((byte)StackBehaviour.Pushr4 << 24));
public static readonly OpCode Ldelem_R8 = new((0xff << 0) | (0x99 << 8) | ((byte)Code.Ldelem_R8 << 16) | ((byte)FlowControl.Next << 24), ((byte)OpCodeType.Objmodel << 0) | ((byte)OperandType.InlineNone << 8) | ((byte)StackBehaviour.Popref_popi << 16) | ((byte)StackBehaviour.Pushr8 << 24));
public static readonly OpCode Ldelem_Ref = new((0xff << 0) | (0x9a << 8) | ((byte)Code.Ldelem_Ref << 16) | ((byte)FlowControl.Next << 24), ((byte)OpCodeType.Objmodel << 0) | ((byte)OperandType.InlineNone << 8) | ((byte)StackBehaviour.Popref_popi << 16) | ((byte)StackBehaviour.Pushref << 24));
public static readonly OpCode Stelem_I = new((0xff << 0) | (0x9b << 8) | ((byte)Code.Stelem_I << 16) | ((byte)FlowControl.Next << 24), ((byte)OpCodeType.Objmodel << 0) | ((byte)OperandType.InlineNone << 8) | ((byte)StackBehaviour.Popref_popi_popi << 16) | ((byte)StackBehaviour.Push0 << 24));
public static readonly OpCode Stelem_I1 = new((0xff << 0) | (0x9c << 8) | ((byte)Code.Stelem_I1 << 16) | ((byte)FlowControl.Next << 24), ((byte)OpCodeType.Objmodel << 0) | ((byte)OperandType.InlineNone << 8) | ((byte)StackBehaviour.Popref_popi_popi << 16) | ((byte)StackBehaviour.Push0 << 24));
public static readonly OpCode Stelem_I2 = new((0xff << 0) | (0x9d << 8) | ((byte)Code.Stelem_I2 << 16) | ((byte)FlowControl.Next << 24), ((byte)OpCodeType.Objmodel << 0) | ((byte)OperandType.InlineNone << 8) | ((byte)StackBehaviour.Popref_popi_popi << 16) | ((byte)StackBehaviour.Push0 << 24));
public static readonly OpCode Stelem_I4 = new((0xff << 0) | (0x9e << 8) | ((byte)Code.Stelem_I4 << 16) | ((byte)FlowControl.Next << 24), ((byte)OpCodeType.Objmodel << 0) | ((byte)OperandType.InlineNone << 8) | ((byte)StackBehaviour.Popref_popi_popi << 16) | ((byte)StackBehaviour.Push0 << 24));
public static readonly OpCode Stelem_I8 = new((0xff << 0) | (0x9f << 8) | ((byte)Code.Stelem_I8 << 16) | ((byte)FlowControl.Next << 24), ((byte)OpCodeType.Objmodel << 0) | ((byte)OperandType.InlineNone << 8) | ((byte)StackBehaviour.Popref_popi_popi8 << 16) | ((byte)StackBehaviour.Push0 << 24));
public static readonly OpCode Stelem_R4 = new((0xff << 0) | (0xa0 << 8) | ((byte)Code.Stelem_R4 << 16) | ((byte)FlowControl.Next << 24), ((byte)OpCodeType.Objmodel << 0) | ((byte)OperandType.InlineNone << 8) | ((byte)StackBehaviour.Popref_popi_popr4 << 16) | ((byte)StackBehaviour.Push0 << 24));
public static readonly OpCode Stelem_R8 = new((0xff << 0) | (0xa1 << 8) | ((byte)Code.Stelem_R8 << 16) | ((byte)FlowControl.Next << 24), ((byte)OpCodeType.Objmodel << 0) | ((byte)OperandType.InlineNone << 8) | ((byte)StackBehaviour.Popref_popi_popr8 << 16) | ((byte)StackBehaviour.Push0 << 24));
public static readonly OpCode Stelem_Ref = new((0xff << 0) | (0xa2 << 8) | ((byte)Code.Stelem_Ref << 16) | ((byte)FlowControl.Next << 24), ((byte)OpCodeType.Objmodel << 0) | ((byte)OperandType.InlineNone << 8) | ((byte)StackBehaviour.Popref_popi_popref << 16) | ((byte)StackBehaviour.Push0 << 24));
public static readonly OpCode Ldelem_Any = new((0xff << 0) | (0xa3 << 8) | ((byte)Code.Ldelem_Any << 16) | ((byte)FlowControl.Next << 24), ((byte)OpCodeType.Objmodel << 0) | ((byte)OperandType.InlineType << 8) | ((byte)StackBehaviour.Popref_popi << 16) | ((byte)StackBehaviour.Push1 << 24));
public static readonly OpCode Stelem_Any = new((0xff << 0) | (0xa4 << 8) | ((byte)Code.Stelem_Any << 16) | ((byte)FlowControl.Next << 24), ((byte)OpCodeType.Objmodel << 0) | ((byte)OperandType.InlineType << 8) | ((byte)StackBehaviour.Popref_popi_popref << 16) | ((byte)StackBehaviour.Push0 << 24));
public static readonly OpCode Unbox_Any = new((0xff << 0) | (0xa5 << 8) | ((byte)Code.Unbox_Any << 16) | ((byte)FlowControl.Next << 24), ((byte)OpCodeType.Objmodel << 0) | ((byte)OperandType.InlineType << 8) | ((byte)StackBehaviour.Popref << 16) | ((byte)StackBehaviour.Push1 << 24));
public static readonly OpCode Conv_Ovf_I1 = new((0xff << 0) | (0xb3 << 8) | ((byte)Code.Conv_Ovf_I1 << 16) | ((byte)FlowControl.Next << 24), ((byte)OpCodeType.Primitive << 0) | ((byte)OperandType.InlineNone << 8) | ((byte)StackBehaviour.Pop1 << 16) | ((byte)StackBehaviour.Pushi << 24));
public static readonly OpCode Conv_Ovf_U1 = new((0xff << 0) | (0xb4 << 8) | ((byte)Code.Conv_Ovf_U1 << 16) | ((byte)FlowControl.Next << 24), ((byte)OpCodeType.Primitive << 0) | ((byte)OperandType.InlineNone << 8) | ((byte)StackBehaviour.Pop1 << 16) | ((byte)StackBehaviour.Pushi << 24));
public static readonly OpCode Conv_Ovf_I2 = new((0xff << 0) | (0xb5 << 8) | ((byte)Code.Conv_Ovf_I2 << 16) | ((byte)FlowControl.Next << 24), ((byte)OpCodeType.Primitive << 0) | ((byte)OperandType.InlineNone << 8) | ((byte)StackBehaviour.Pop1 << 16) | ((byte)StackBehaviour.Pushi << 24));
public static readonly OpCode Conv_Ovf_U2 = new((0xff << 0) | (0xb6 << 8) | ((byte)Code.Conv_Ovf_U2 << 16) | ((byte)FlowControl.Next << 24), ((byte)OpCodeType.Primitive << 0) | ((byte)OperandType.InlineNone << 8) | ((byte)StackBehaviour.Pop1 << 16) | ((byte)StackBehaviour.Pushi << 24));
public static readonly OpCode Conv_Ovf_I4 = new((0xff << 0) | (0xb7 << 8) | ((byte)Code.Conv_Ovf_I4 << 16) | ((byte)FlowControl.Next << 24), ((byte)OpCodeType.Primitive << 0) | ((byte)OperandType.InlineNone << 8) | ((byte)StackBehaviour.Pop1 << 16) | ((byte)StackBehaviour.Pushi << 24));
public static readonly OpCode Conv_Ovf_U4 = new((0xff << 0) | (0xb8 << 8) | ((byte)Code.Conv_Ovf_U4 << 16) | ((byte)FlowControl.Next << 24), ((byte)OpCodeType.Primitive << 0) | ((byte)OperandType.InlineNone << 8) | ((byte)StackBehaviour.Pop1 << 16) | ((byte)StackBehaviour.Pushi << 24));
public static readonly OpCode Conv_Ovf_I8 = new((0xff << 0) | (0xb9 << 8) | ((byte)Code.Conv_Ovf_I8 << 16) | ((byte)FlowControl.Next << 24), ((byte)OpCodeType.Primitive << 0) | ((byte)OperandType.InlineNone << 8) | ((byte)StackBehaviour.Pop1 << 16) | ((byte)StackBehaviour.Pushi8 << 24));
public static readonly OpCode Conv_Ovf_U8 = new((0xff << 0) | (0xba << 8) | ((byte)Code.Conv_Ovf_U8 << 16) | ((byte)FlowControl.Next << 24), ((byte)OpCodeType.Primitive << 0) | ((byte)OperandType.InlineNone << 8) | ((byte)StackBehaviour.Pop1 << 16) | ((byte)StackBehaviour.Pushi8 << 24));
public static readonly OpCode Refanyval = new((0xff << 0) | (0xc2 << 8) | ((byte)Code.Refanyval << 16) | ((byte)FlowControl.Next << 24), ((byte)OpCodeType.Primitive << 0) | ((byte)OperandType.InlineType << 8) | ((byte)StackBehaviour.Pop1 << 16) | ((byte)StackBehaviour.Pushi << 24));
public static readonly OpCode Ckfinite = new((0xff << 0) | (0xc3 << 8) | ((byte)Code.Ckfinite << 16) | ((byte)FlowControl.Next << 24), ((byte)OpCodeType.Primitive << 0) | ((byte)OperandType.InlineNone << 8) | ((byte)StackBehaviour.Pop1 << 16) | ((byte)StackBehaviour.Pushr8 << 24));
public static readonly OpCode Mkrefany = new((0xff << 0) | (0xc6 << 8) | ((byte)Code.Mkrefany << 16) | ((byte)FlowControl.Next << 24), ((byte)OpCodeType.Primitive << 0) | ((byte)OperandType.InlineType << 8) | ((byte)StackBehaviour.Popi << 16) | ((byte)StackBehaviour.Push1 << 24));
public static readonly OpCode Ldtoken = new((0xff << 0) | (0xd0 << 8) | ((byte)Code.Ldtoken << 16) | ((byte)FlowControl.Next << 24), ((byte)OpCodeType.Primitive << 0) | ((byte)OperandType.InlineTok << 8) | ((byte)StackBehaviour.Pop0 << 16) | ((byte)StackBehaviour.Pushi << 24));
public static readonly OpCode Conv_U2 = new((0xff << 0) | (0xd1 << 8) | ((byte)Code.Conv_U2 << 16) | ((byte)FlowControl.Next << 24), ((byte)OpCodeType.Primitive << 0) | ((byte)OperandType.InlineNone << 8) | ((byte)StackBehaviour.Pop1 << 16) | ((byte)StackBehaviour.Pushi << 24));
public static readonly OpCode Conv_U1 = new((0xff << 0) | (0xd2 << 8) | ((byte)Code.Conv_U1 << 16) | ((byte)FlowControl.Next << 24), ((byte)OpCodeType.Primitive << 0) | ((byte)OperandType.InlineNone << 8) | ((byte)StackBehaviour.Pop1 << 16) | ((byte)StackBehaviour.Pushi << 24));
public static readonly OpCode Conv_I = new((0xff << 0) | (0xd3 << 8) | ((byte)Code.Conv_I << 16) | ((byte)FlowControl.Next << 24), ((byte)OpCodeType.Primitive << 0) | ((byte)OperandType.InlineNone << 8) | ((byte)StackBehaviour.Pop1 << 16) | ((byte)StackBehaviour.Pushi << 24));
public static readonly OpCode Conv_Ovf_I = new((0xff << 0) | (0xd4 << 8) | ((byte)Code.Conv_Ovf_I << 16) | ((byte)FlowControl.Next << 24), ((byte)OpCodeType.Primitive << 0) | ((byte)OperandType.InlineNone << 8) | ((byte)StackBehaviour.Pop1 << 16) | ((byte)StackBehaviour.Pushi << 24));
public static readonly OpCode Conv_Ovf_U = new((0xff << 0) | (0xd5 << 8) | ((byte)Code.Conv_Ovf_U << 16) | ((byte)FlowControl.Next << 24), ((byte)OpCodeType.Primitive << 0) | ((byte)OperandType.InlineNone << 8) | ((byte)StackBehaviour.Pop1 << 16) | ((byte)StackBehaviour.Pushi << 24));
public static readonly OpCode Add_Ovf = new((0xff << 0) | (0xd6 << 8) | ((byte)Code.Add_Ovf << 16) | ((byte)FlowControl.Next << 24), ((byte)OpCodeType.Primitive << 0) | ((byte)OperandType.InlineNone << 8) | ((byte)StackBehaviour.Pop1_pop1 << 16) | ((byte)StackBehaviour.Push1 << 24));
public static readonly OpCode Add_Ovf_Un = new((0xff << 0) | (0xd7 << 8) | ((byte)Code.Add_Ovf_Un << 16) | ((byte)FlowControl.Next << 24), ((byte)OpCodeType.Primitive << 0) | ((byte)OperandType.InlineNone << 8) | ((byte)StackBehaviour.Pop1_pop1 << 16) | ((byte)StackBehaviour.Push1 << 24));
public static readonly OpCode Mul_Ovf = new((0xff << 0) | (0xd8 << 8) | ((byte)Code.Mul_Ovf << 16) | ((byte)FlowControl.Next << 24), ((byte)OpCodeType.Primitive << 0) | ((byte)OperandType.InlineNone << 8) | ((byte)StackBehaviour.Pop1_pop1 << 16) | ((byte)StackBehaviour.Push1 << 24));
public static readonly OpCode Mul_Ovf_Un = new((0xff << 0) | (0xd9 << 8) | ((byte)Code.Mul_Ovf_Un << 16) | ((byte)FlowControl.Next << 24), ((byte)OpCodeType.Primitive << 0) | ((byte)OperandType.InlineNone << 8) | ((byte)StackBehaviour.Pop1_pop1 << 16) | ((byte)StackBehaviour.Push1 << 24));
public static readonly OpCode Sub_Ovf = new((0xff << 0) | (0xda << 8) | ((byte)Code.Sub_Ovf << 16) | ((byte)FlowControl.Next << 24), ((byte)OpCodeType.Primitive << 0) | ((byte)OperandType.InlineNone << 8) | ((byte)StackBehaviour.Pop1_pop1 << 16) | ((byte)StackBehaviour.Push1 << 24));
public static readonly OpCode Sub_Ovf_Un = new((0xff << 0) | (0xdb << 8) | ((byte)Code.Sub_Ovf_Un << 16) | ((byte)FlowControl.Next << 24), ((byte)OpCodeType.Primitive << 0) | ((byte)OperandType.InlineNone << 8) | ((byte)StackBehaviour.Pop1_pop1 << 16) | ((byte)StackBehaviour.Push1 << 24));
public static readonly OpCode Endfinally = new((0xff << 0) | (0xdc << 8) | ((byte)Code.Endfinally << 16) | ((byte)FlowControl.Return << 24), ((byte)OpCodeType.Primitive << 0) | ((byte)OperandType.InlineNone << 8) | ((byte)StackBehaviour.Pop0 << 16) | ((byte)StackBehaviour.Push0 << 24));
public static readonly OpCode Leave = new((0xff << 0) | (0xdd << 8) | ((byte)Code.Leave << 16) | ((byte)FlowControl.Branch << 24), ((byte)OpCodeType.Primitive << 0) | ((byte)OperandType.InlineBrTarget << 8) | ((byte)StackBehaviour.PopAll << 16) | ((byte)StackBehaviour.Push0 << 24));
public static readonly OpCode Leave_S = new((0xff << 0) | (0xde << 8) | ((byte)Code.Leave_S << 16) | ((byte)FlowControl.Branch << 24), ((byte)OpCodeType.Macro << 0) | ((byte)OperandType.ShortInlineBrTarget << 8) | ((byte)StackBehaviour.PopAll << 16) | ((byte)StackBehaviour.Push0 << 24));
public static readonly OpCode Stind_I = new((0xff << 0) | (0xdf << 8) | ((byte)Code.Stind_I << 16) | ((byte)FlowControl.Next << 24), ((byte)OpCodeType.Primitive << 0) | ((byte)OperandType.InlineNone << 8) | ((byte)StackBehaviour.Popi_popi << 16) | ((byte)StackBehaviour.Push0 << 24));
public static readonly OpCode Conv_U = new((0xff << 0) | (0xe0 << 8) | ((byte)Code.Conv_U << 16) | ((byte)FlowControl.Next << 24), ((byte)OpCodeType.Primitive << 0) | ((byte)OperandType.InlineNone << 8) | ((byte)StackBehaviour.Pop1 << 16) | ((byte)StackBehaviour.Pushi << 24));
public static readonly OpCode Arglist = new((0xfe << 0) | (0x00 << 8) | ((byte)Code.Arglist << 16) | ((byte)FlowControl.Next << 24), ((byte)OpCodeType.Primitive << 0) | ((byte)OperandType.InlineNone << 8) | ((byte)StackBehaviour.Pop0 << 16) | ((byte)StackBehaviour.Pushi << 24));
public static readonly OpCode Ceq = new((0xfe << 0) | (0x01 << 8) | ((byte)Code.Ceq << 16) | ((byte)FlowControl.Next << 24), ((byte)OpCodeType.Primitive << 0) | ((byte)OperandType.InlineNone << 8) | ((byte)StackBehaviour.Pop1_pop1 << 16) | ((byte)StackBehaviour.Pushi << 24));
public static readonly OpCode Cgt = new((0xfe << 0) | (0x02 << 8) | ((byte)Code.Cgt << 16) | ((byte)FlowControl.Next << 24), ((byte)OpCodeType.Primitive << 0) | ((byte)OperandType.InlineNone << 8) | ((byte)StackBehaviour.Pop1_pop1 << 16) | ((byte)StackBehaviour.Pushi << 24));
public static readonly OpCode Cgt_Un = new((0xfe << 0) | (0x03 << 8) | ((byte)Code.Cgt_Un << 16) | ((byte)FlowControl.Next << 24), ((byte)OpCodeType.Primitive << 0) | ((byte)OperandType.InlineNone << 8) | ((byte)StackBehaviour.Pop1_pop1 << 16) | ((byte)StackBehaviour.Pushi << 24));
public static readonly OpCode Clt = new((0xfe << 0) | (0x04 << 8) | ((byte)Code.Clt << 16) | ((byte)FlowControl.Next << 24), ((byte)OpCodeType.Primitive << 0) | ((byte)OperandType.InlineNone << 8) | ((byte)StackBehaviour.Pop1_pop1 << 16) | ((byte)StackBehaviour.Pushi << 24));
public static readonly OpCode Clt_Un = new((0xfe << 0) | (0x05 << 8) | ((byte)Code.Clt_Un << 16) | ((byte)FlowControl.Next << 24), ((byte)OpCodeType.Primitive << 0) | ((byte)OperandType.InlineNone << 8) | ((byte)StackBehaviour.Pop1_pop1 << 16) | ((byte)StackBehaviour.Pushi << 24));
public static readonly OpCode Ldftn = new((0xfe << 0) | (0x06 << 8) | ((byte)Code.Ldftn << 16) | ((byte)FlowControl.Next << 24), ((byte)OpCodeType.Primitive << 0) | ((byte)OperandType.InlineMethod << 8) | ((byte)StackBehaviour.Pop0 << 16) | ((byte)StackBehaviour.Pushi << 24));
public static readonly OpCode Ldvirtftn = new((0xfe << 0) | (0x07 << 8) | ((byte)Code.Ldvirtftn << 16) | ((byte)FlowControl.Next << 24), ((byte)OpCodeType.Primitive << 0) | ((byte)OperandType.InlineMethod << 8) | ((byte)StackBehaviour.Popref << 16) | ((byte)StackBehaviour.Pushi << 24));
public static readonly OpCode Ldarg = new((0xfe << 0) | (0x09 << 8) | ((byte)Code.Ldarg << 16) | ((byte)FlowControl.Next << 24), ((byte)OpCodeType.Primitive << 0) | ((byte)OperandType.InlineArg << 8) | ((byte)StackBehaviour.Pop0 << 16) | ((byte)StackBehaviour.Push1 << 24));
public static readonly OpCode Ldarga = new((0xfe << 0) | (0x0a << 8) | ((byte)Code.Ldarga << 16) | ((byte)FlowControl.Next << 24), ((byte)OpCodeType.Primitive << 0) | ((byte)OperandType.InlineArg << 8) | ((byte)StackBehaviour.Pop0 << 16) | ((byte)StackBehaviour.Pushi << 24));
public static readonly OpCode Starg = new((0xfe << 0) | (0x0b << 8) | ((byte)Code.Starg << 16) | ((byte)FlowControl.Next << 24), ((byte)OpCodeType.Primitive << 0) | ((byte)OperandType.InlineArg << 8) | ((byte)StackBehaviour.Pop1 << 16) | ((byte)StackBehaviour.Push0 << 24));
public static readonly OpCode Ldloc = new((0xfe << 0) | (0x0c << 8) | ((byte)Code.Ldloc << 16) | ((byte)FlowControl.Next << 24), ((byte)OpCodeType.Primitive << 0) | ((byte)OperandType.InlineVar << 8) | ((byte)StackBehaviour.Pop0 << 16) | ((byte)StackBehaviour.Push1 << 24));
public static readonly OpCode Ldloca = new((0xfe << 0) | (0x0d << 8) | ((byte)Code.Ldloca << 16) | ((byte)FlowControl.Next << 24), ((byte)OpCodeType.Primitive << 0) | ((byte)OperandType.InlineVar << 8) | ((byte)StackBehaviour.Pop0 << 16) | ((byte)StackBehaviour.Pushi << 24));
public static readonly OpCode Stloc = new((0xfe << 0) | (0x0e << 8) | ((byte)Code.Stloc << 16) | ((byte)FlowControl.Next << 24), ((byte)OpCodeType.Primitive << 0) | ((byte)OperandType.InlineVar << 8) | ((byte)StackBehaviour.Pop1 << 16) | ((byte)StackBehaviour.Push0 << 24));
public static readonly OpCode Localloc = new((0xfe << 0) | (0x0f << 8) | ((byte)Code.Localloc << 16) | ((byte)FlowControl.Next << 24), ((byte)OpCodeType.Primitive << 0) | ((byte)OperandType.InlineNone << 8) | ((byte)StackBehaviour.Popi << 16) | ((byte)StackBehaviour.Pushi << 24));
public static readonly OpCode Endfilter = new((0xfe << 0) | (0x11 << 8) | ((byte)Code.Endfilter << 16) | ((byte)FlowControl.Return << 24), ((byte)OpCodeType.Primitive << 0) | ((byte)OperandType.InlineNone << 8) | ((byte)StackBehaviour.Popi << 16) | ((byte)StackBehaviour.Push0 << 24));
public static readonly OpCode Unaligned = new((0xfe << 0) | (0x12 << 8) | ((byte)Code.Unaligned << 16) | ((byte)FlowControl.Meta << 24), ((byte)OpCodeType.Prefix << 0) | ((byte)OperandType.ShortInlineI << 8) | ((byte)StackBehaviour.Pop0 << 16) | ((byte)StackBehaviour.Push0 << 24));
public static readonly OpCode Volatile = new((0xfe << 0) | (0x13 << 8) | ((byte)Code.Volatile << 16) | ((byte)FlowControl.Meta << 24), ((byte)OpCodeType.Prefix << 0) | ((byte)OperandType.InlineNone << 8) | ((byte)StackBehaviour.Pop0 << 16) | ((byte)StackBehaviour.Push0 << 24));
public static readonly OpCode Tail = new((0xfe << 0) | (0x14 << 8) | ((byte)Code.Tail << 16) | ((byte)FlowControl.Meta << 24), ((byte)OpCodeType.Prefix << 0) | ((byte)OperandType.InlineNone << 8) | ((byte)StackBehaviour.Pop0 << 16) | ((byte)StackBehaviour.Push0 << 24));
public static readonly OpCode Initobj = new((0xfe << 0) | (0x15 << 8) | ((byte)Code.Initobj << 16) | ((byte)FlowControl.Next << 24), ((byte)OpCodeType.Objmodel << 0) | ((byte)OperandType.InlineType << 8) | ((byte)StackBehaviour.Popi << 16) | ((byte)StackBehaviour.Push0 << 24));
public static readonly OpCode Constrained = new((0xfe << 0) | (0x16 << 8) | ((byte)Code.Constrained << 16) | ((byte)FlowControl.Next << 24), ((byte)OpCodeType.Prefix << 0) | ((byte)OperandType.InlineType << 8) | ((byte)StackBehaviour.Pop0 << 16) | ((byte)StackBehaviour.Push0 << 24));
public static readonly OpCode Cpblk = new((0xfe << 0) | (0x17 << 8) | ((byte)Code.Cpblk << 16) | ((byte)FlowControl.Next << 24), ((byte)OpCodeType.Primitive << 0) | ((byte)OperandType.InlineNone << 8) | ((byte)StackBehaviour.Popi_popi_popi << 16) | ((byte)StackBehaviour.Push0 << 24));
public static readonly OpCode Initblk = new((0xfe << 0) | (0x18 << 8) | ((byte)Code.Initblk << 16) | ((byte)FlowControl.Next << 24), ((byte)OpCodeType.Primitive << 0) | ((byte)OperandType.InlineNone << 8) | ((byte)StackBehaviour.Popi_popi_popi << 16) | ((byte)StackBehaviour.Push0 << 24));
public static readonly OpCode No = new((0xfe << 0) | (0x19 << 8) | ((byte)Code.No << 16) | ((byte)FlowControl.Next << 24), ((byte)OpCodeType.Prefix << 0) | ((byte)OperandType.ShortInlineI << 8) | ((byte)StackBehaviour.Pop0 << 16) | ((byte)StackBehaviour.Push0 << 24));
public static readonly OpCode Rethrow = new((0xfe << 0) | (0x1a << 8) | ((byte)Code.Rethrow << 16) | ((byte)FlowControl.Throw << 24), ((byte)OpCodeType.Objmodel << 0) | ((byte)OperandType.InlineNone << 8) | ((byte)StackBehaviour.Pop0 << 16) | ((byte)StackBehaviour.Push0 << 24));
public static readonly OpCode Sizeof = new((0xfe << 0) | (0x1c << 8) | ((byte)Code.Sizeof << 16) | ((byte)FlowControl.Next << 24), ((byte)OpCodeType.Primitive << 0) | ((byte)OperandType.InlineType << 8) | ((byte)StackBehaviour.Pop0 << 16) | ((byte)StackBehaviour.Pushi << 24));
public static readonly OpCode Refanytype = new((0xfe << 0) | (0x1d << 8) | ((byte)Code.Refanytype << 16) | ((byte)FlowControl.Next << 24), ((byte)OpCodeType.Primitive << 0) | ((byte)OperandType.InlineNone << 8) | ((byte)StackBehaviour.Pop1 << 16) | ((byte)StackBehaviour.Pushi << 24));
public static readonly OpCode Readonly = new((0xfe << 0) | (0x1e << 8) | ((byte)Code.Readonly << 16) | ((byte)FlowControl.Next << 24), ((byte)OpCodeType.Prefix << 0) | ((byte)OperandType.InlineNone << 8) | ((byte)StackBehaviour.Pop0 << 16) | ((byte)StackBehaviour.Push0 << 24));
}
}
@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 52c19a62321778c438d2f6b483f18e73
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 207815
packageName: 'FishNet: Networking Evolved'
packageVersion: 4.6.22R
assetPath: Assets/FishNet/CodeGenerating/cecil-0.11.4/Mono.Cecil.Cil/OpCodes.cs
uploadId: 866910
@@ -0,0 +1,600 @@
//
// Author:
// Jb Evain (jbevain@gmail.com)
//
// Copyright (c) 2008 - 2015 Jb Evain
// Copyright (c) 2008 - 2011 Novell, Inc.
//
// Licensed under the MIT/X11 license.
//
using MonoFN.Cecil.Metadata;
using MonoFN.Cecil.PE;
using System;
using System.Collections.Generic;
using System.IO;
using System.IO.Compression;
namespace MonoFN.Cecil.Cil
{
public sealed class PortablePdbReaderProvider : ISymbolReaderProvider
{
public ISymbolReader GetSymbolReader(ModuleDefinition module, string fileName)
{
Mixin.CheckModule(module);
Mixin.CheckFileName(fileName);
FileStream file = File.OpenRead(Mixin.GetPdbFileName(fileName));
return GetSymbolReader(module, Disposable.Owned(file as Stream), file.Name);
}
public ISymbolReader GetSymbolReader(ModuleDefinition module, Stream symbolStream)
{
Mixin.CheckModule(module);
Mixin.CheckStream(symbolStream);
return GetSymbolReader(module, Disposable.NotOwned(symbolStream), symbolStream.GetFileName());
}
private ISymbolReader GetSymbolReader(ModuleDefinition module, Disposable<Stream> symbolStream, string fileName)
{
return new PortablePdbReader(ImageReader.ReadPortablePdb(symbolStream, fileName), module);
}
}
public sealed class PortablePdbReader : ISymbolReader
{
private readonly Image image;
private readonly ModuleDefinition module;
private readonly MetadataReader reader;
private readonly MetadataReader debug_reader;
private bool IsEmbedded
{
get { return reader.image == debug_reader.image; }
}
internal PortablePdbReader(Image image, ModuleDefinition module)
{
this.image = image;
this.module = module;
reader = module.reader;
debug_reader = new(image, module, reader);
}
public ISymbolWriterProvider GetWriterProvider()
{
return new PortablePdbWriterProvider();
}
public bool ProcessDebugHeader(ImageDebugHeader header)
{
if (image == module.Image)
return true;
foreach (ImageDebugHeaderEntry entry in header.Entries)
{
if (!IsMatchingEntry(image.PdbHeap, entry))
continue;
ReadModule();
return true;
}
return false;
}
private static bool IsMatchingEntry(PdbHeap heap, ImageDebugHeaderEntry entry)
{
if (entry.Directory.Type != ImageDebugType.CodeView)
return false;
byte[] data = entry.Data;
if (data.Length < 24)
return false;
int magic = ReadInt32(data, 0);
if (magic != 0x53445352)
return false;
byte[] buffer = new byte [16];
Buffer.BlockCopy(data, 4, buffer, 0, 16);
Guid module_guid = new(buffer);
Buffer.BlockCopy(heap.Id, 0, buffer, 0, 16);
Guid pdb_guid = new(buffer);
return module_guid == pdb_guid;
}
private static int ReadInt32(byte[] bytes, int start)
{
return bytes[start] | (bytes[start + 1] << 8) | (bytes[start + 2] << 16) | (bytes[start + 3] << 24);
}
private void ReadModule()
{
module.custom_infos = debug_reader.GetCustomDebugInformation(module);
}
public MethodDebugInformation Read(MethodDefinition method)
{
MethodDebugInformation info = new(method);
ReadSequencePoints(info);
ReadScope(info);
ReadStateMachineKickOffMethod(info);
ReadCustomDebugInformations(info);
return info;
}
private void ReadSequencePoints(MethodDebugInformation method_info)
{
method_info.sequence_points = debug_reader.ReadSequencePoints(method_info.method);
}
private void ReadScope(MethodDebugInformation method_info)
{
method_info.scope = debug_reader.ReadScope(method_info.method);
}
private void ReadStateMachineKickOffMethod(MethodDebugInformation method_info)
{
method_info.kickoff_method = debug_reader.ReadStateMachineKickoffMethod(method_info.method);
}
private void ReadCustomDebugInformations(MethodDebugInformation info)
{
info.method.custom_infos = debug_reader.GetCustomDebugInformation(info.method);
}
public void Dispose()
{
if (IsEmbedded)
return;
image.Dispose();
}
}
public sealed class EmbeddedPortablePdbReaderProvider : ISymbolReaderProvider
{
public ISymbolReader GetSymbolReader(ModuleDefinition module, string fileName)
{
Mixin.CheckModule(module);
ImageDebugHeader header = module.GetDebugHeader();
ImageDebugHeaderEntry entry = header.GetEmbeddedPortablePdbEntry();
if (entry == null)
throw new InvalidOperationException();
return new EmbeddedPortablePdbReader((PortablePdbReader)new PortablePdbReaderProvider().GetSymbolReader(module, GetPortablePdbStream(entry)));
}
private static Stream GetPortablePdbStream(ImageDebugHeaderEntry entry)
{
MemoryStream compressed_stream = new(entry.Data);
BinaryStreamReader reader = new(compressed_stream);
reader.ReadInt32(); // signature
int length = reader.ReadInt32();
MemoryStream decompressed_stream = new(length);
using (DeflateStream deflate_stream = new(compressed_stream, CompressionMode.Decompress, leaveOpen: true))
{
deflate_stream.CopyTo(decompressed_stream);
}
return decompressed_stream;
}
public ISymbolReader GetSymbolReader(ModuleDefinition module, Stream symbolStream)
{
throw new NotSupportedException();
}
}
public sealed class EmbeddedPortablePdbReader : ISymbolReader
{
private readonly PortablePdbReader reader;
internal EmbeddedPortablePdbReader(PortablePdbReader reader)
{
if (reader == null)
throw new ArgumentNullException();
this.reader = reader;
}
public ISymbolWriterProvider GetWriterProvider()
{
return new EmbeddedPortablePdbWriterProvider();
}
public bool ProcessDebugHeader(ImageDebugHeader header)
{
return reader.ProcessDebugHeader(header);
}
public MethodDebugInformation Read(MethodDefinition method)
{
return reader.Read(method);
}
public void Dispose()
{
reader.Dispose();
}
}
public sealed class PortablePdbWriterProvider : ISymbolWriterProvider
{
public ISymbolWriter GetSymbolWriter(ModuleDefinition module, string fileName)
{
Mixin.CheckModule(module);
Mixin.CheckFileName(fileName);
FileStream file = File.OpenWrite(Mixin.GetPdbFileName(fileName));
return GetSymbolWriter(module, Disposable.Owned(file as Stream));
}
public ISymbolWriter GetSymbolWriter(ModuleDefinition module, Stream symbolStream)
{
Mixin.CheckModule(module);
Mixin.CheckStream(symbolStream);
return GetSymbolWriter(module, Disposable.NotOwned(symbolStream));
}
private ISymbolWriter GetSymbolWriter(ModuleDefinition module, Disposable<Stream> stream)
{
MetadataBuilder metadata = new(module, this);
ImageWriter writer = ImageWriter.CreateDebugWriter(module, metadata, stream);
return new PortablePdbWriter(metadata, module, writer);
}
}
public sealed class PortablePdbWriter : ISymbolWriter
{
private readonly MetadataBuilder pdb_metadata;
private readonly ModuleDefinition module;
private readonly ImageWriter writer;
private MetadataBuilder module_metadata;
private bool IsEmbedded
{
get { return writer == null; }
}
internal PortablePdbWriter(MetadataBuilder pdb_metadata, ModuleDefinition module)
{
this.pdb_metadata = pdb_metadata;
this.module = module;
module_metadata = module.metadata_builder;
if (module_metadata != pdb_metadata)
this.pdb_metadata.metadata_builder = module_metadata;
pdb_metadata.AddCustomDebugInformations(module);
}
internal PortablePdbWriter(MetadataBuilder pdb_metadata, ModuleDefinition module, ImageWriter writer) : this(pdb_metadata, module)
{
this.writer = writer;
}
public ISymbolReaderProvider GetReaderProvider()
{
return new PortablePdbReaderProvider();
}
public ImageDebugHeader GetDebugHeader()
{
if (IsEmbedded)
return new();
ImageDebugDirectory directory = new()
{
MajorVersion = 256,
MinorVersion = 20557,
Type = ImageDebugType.CodeView,
TimeDateStamp = (int)module.timestamp
};
ByteBuffer buffer = new();
// RSDS
buffer.WriteUInt32(0x53445352);
// Module ID
buffer.WriteBytes(module.Mvid.ToByteArray());
// PDB Age
buffer.WriteUInt32(1);
// PDB Path
string fileName = writer.BaseStream.GetFileName();
if (string.IsNullOrEmpty(fileName))
{
fileName = module.Assembly.Name.Name + ".pdb";
}
buffer.WriteBytes(System.Text.Encoding.UTF8.GetBytes(fileName));
buffer.WriteByte(0);
byte[] data = new byte [buffer.length];
Buffer.BlockCopy(buffer.buffer, 0, data, 0, buffer.length);
directory.SizeOfData = data.Length;
return new(new ImageDebugHeaderEntry(directory, data));
}
public void Write(MethodDebugInformation info)
{
CheckMethodDebugInformationTable();
pdb_metadata.AddMethodDebugInformation(info);
}
private void CheckMethodDebugInformationTable()
{
MethodDebugInformationTable mdi = pdb_metadata.table_heap.GetTable<MethodDebugInformationTable>(Table.MethodDebugInformation);
if (mdi.length > 0)
return;
// The MethodDebugInformation table has the same length as the Method table
mdi.rows = new Row<uint, uint> [module_metadata.method_rid - 1];
mdi.length = mdi.rows.Length;
}
public void Dispose()
{
if (IsEmbedded)
return;
WritePdbFile();
}
private void WritePdbFile()
{
WritePdbHeap();
WriteTableHeap();
writer.BuildMetadataTextMap();
writer.WriteMetadataHeader();
writer.WriteMetadata();
writer.Flush();
writer.stream.Dispose();
}
private void WritePdbHeap()
{
PdbHeapBuffer pdb_heap = pdb_metadata.pdb_heap;
pdb_heap.WriteBytes(module.Mvid.ToByteArray());
pdb_heap.WriteUInt32(module_metadata.timestamp);
pdb_heap.WriteUInt32(module_metadata.entry_point.ToUInt32());
TableHeapBuffer table_heap = module_metadata.table_heap;
MetadataTable[] tables = table_heap.tables;
ulong valid = 0;
for (int i = 0; i < tables.Length; i++)
{
if (tables[i] == null || tables[i].Length == 0)
continue;
valid |= 1UL << i;
}
pdb_heap.WriteUInt64(valid);
for (int i = 0; i < tables.Length; i++)
{
if (tables[i] == null || tables[i].Length == 0)
continue;
pdb_heap.WriteUInt32((uint)tables[i].Length);
}
}
private void WriteTableHeap()
{
pdb_metadata.table_heap.string_offsets = pdb_metadata.string_heap.WriteStrings();
pdb_metadata.table_heap.ComputeTableInformations();
pdb_metadata.table_heap.WriteTableHeap();
}
}
public sealed class EmbeddedPortablePdbWriterProvider : ISymbolWriterProvider
{
public ISymbolWriter GetSymbolWriter(ModuleDefinition module, string fileName)
{
Mixin.CheckModule(module);
Mixin.CheckFileName(fileName);
MemoryStream stream = new();
PortablePdbWriter pdb_writer = (PortablePdbWriter)new PortablePdbWriterProvider().GetSymbolWriter(module, stream);
return new EmbeddedPortablePdbWriter(stream, pdb_writer);
}
public ISymbolWriter GetSymbolWriter(ModuleDefinition module, Stream symbolStream)
{
throw new NotSupportedException();
}
}
public sealed class EmbeddedPortablePdbWriter : ISymbolWriter
{
private readonly Stream stream;
private readonly PortablePdbWriter writer;
internal EmbeddedPortablePdbWriter(Stream stream, PortablePdbWriter writer)
{
this.stream = stream;
this.writer = writer;
}
public ISymbolReaderProvider GetReaderProvider()
{
return new EmbeddedPortablePdbReaderProvider();
}
public ImageDebugHeader GetDebugHeader()
{
writer.Dispose();
ImageDebugDirectory directory = new()
{
Type = ImageDebugType.EmbeddedPortablePdb,
MajorVersion = 0x0100,
MinorVersion = 0x0100
};
MemoryStream data = new();
BinaryStreamWriter w = new(data);
w.WriteByte(0x4d);
w.WriteByte(0x50);
w.WriteByte(0x44);
w.WriteByte(0x42);
w.WriteInt32((int)stream.Length);
stream.Position = 0;
using (DeflateStream compress_stream = new(data, CompressionMode.Compress, leaveOpen: true))
{
stream.CopyTo(compress_stream);
}
directory.SizeOfData = (int)data.Length;
return new(new[]
{
writer.GetDebugHeader().Entries[0],
new ImageDebugHeaderEntry(directory, data.ToArray())
});
}
public void Write(MethodDebugInformation info)
{
writer.Write(info);
}
public void Dispose() { }
}
internal static class PdbGuidMapping
{
private static readonly Dictionary<Guid, DocumentLanguage> guid_language = new();
private static readonly Dictionary<DocumentLanguage, Guid> language_guid = new();
static PdbGuidMapping()
{
AddMapping(DocumentLanguage.C, new("63a08714-fc37-11d2-904c-00c04fa302a1"));
AddMapping(DocumentLanguage.Cpp, new("3a12d0b7-c26c-11d0-b442-00a0244a1dd2"));
AddMapping(DocumentLanguage.CSharp, new("3f5162f8-07c6-11d3-9053-00c04fa302a1"));
AddMapping(DocumentLanguage.Basic, new("3a12d0b8-c26c-11d0-b442-00a0244a1dd2"));
AddMapping(DocumentLanguage.Java, new("3a12d0b4-c26c-11d0-b442-00a0244a1dd2"));
AddMapping(DocumentLanguage.Cobol, new("af046cd1-d0e1-11d2-977c-00a0c9b4d50c"));
AddMapping(DocumentLanguage.Pascal, new("af046cd2-d0e1-11d2-977c-00a0c9b4d50c"));
AddMapping(DocumentLanguage.Cil, new("af046cd3-d0e1-11d2-977c-00a0c9b4d50c"));
AddMapping(DocumentLanguage.JScript, new("3a12d0b6-c26c-11d0-b442-00a0244a1dd2"));
AddMapping(DocumentLanguage.Smc, new("0d9b9f7b-6611-11d3-bd2a-0000f80849bd"));
AddMapping(DocumentLanguage.MCpp, new("4b35fde8-07c6-11d3-9053-00c04fa302a1"));
AddMapping(DocumentLanguage.FSharp, new("ab4f38c9-b6e6-43ba-be3b-58080b2ccce3"));
}
private static void AddMapping(DocumentLanguage language, Guid guid)
{
guid_language.Add(guid, language);
language_guid.Add(language, guid);
}
private static readonly Guid type_text = new("5a869d0b-6611-11d3-bd2a-0000f80849bd");
public static DocumentType ToType(this Guid guid)
{
if (guid == type_text)
return DocumentType.Text;
return DocumentType.Other;
}
public static Guid ToGuid(this DocumentType type)
{
if (type == DocumentType.Text)
return type_text;
return new();
}
private static readonly Guid hash_md5 = new("406ea660-64cf-4c82-b6f0-42d48172a799");
private static readonly Guid hash_sha1 = new("ff1816ec-aa5e-4d10-87f7-6f4963833460");
private static readonly Guid hash_sha256 = new("8829d00f-11b8-4213-878b-770e8597ac16");
public static DocumentHashAlgorithm ToHashAlgorithm(this Guid guid)
{
if (guid == hash_md5)
return DocumentHashAlgorithm.MD5;
if (guid == hash_sha1)
return DocumentHashAlgorithm.SHA1;
if (guid == hash_sha256)
return DocumentHashAlgorithm.SHA256;
return DocumentHashAlgorithm.None;
}
public static Guid ToGuid(this DocumentHashAlgorithm hash_algo)
{
if (hash_algo == DocumentHashAlgorithm.MD5)
return hash_md5;
if (hash_algo == DocumentHashAlgorithm.SHA1)
return hash_sha1;
if (hash_algo == DocumentHashAlgorithm.SHA256)
return hash_sha256;
return new();
}
public static DocumentLanguage ToLanguage(this Guid guid)
{
DocumentLanguage language;
if (!guid_language.TryGetValue(guid, out language))
return DocumentLanguage.Other;
return language;
}
public static Guid ToGuid(this DocumentLanguage language)
{
Guid guid;
if (!language_guid.TryGetValue(language, out guid))
return new();
return guid;
}
private static readonly Guid vendor_ms = new("994b45c4-e6e9-11d2-903f-00c04fa302a1");
public static DocumentLanguageVendor ToVendor(this Guid guid)
{
if (guid == vendor_ms)
return DocumentLanguageVendor.Microsoft;
return DocumentLanguageVendor.Other;
}
public static Guid ToGuid(this DocumentLanguageVendor vendor)
{
if (vendor == DocumentLanguageVendor.Microsoft)
return vendor_ms;
return new();
}
}
}
@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 34e2f5d4b9b9ea542bec15f2d9acc3ed
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 207815
packageName: 'FishNet: Networking Evolved'
packageVersion: 4.6.22R
assetPath: Assets/FishNet/CodeGenerating/cecil-0.11.4/Mono.Cecil.Cil/PortablePdb.cs
uploadId: 866910
@@ -0,0 +1,50 @@
//
// Author:
// Jb Evain (jbevain@gmail.com)
//
// Copyright (c) 2008 - 2015 Jb Evain
// Copyright (c) 2008 - 2011 Novell, Inc.
//
// Licensed under the MIT/X11 license.
//
using System;
namespace MonoFN.Cecil.Cil
{
public sealed class SequencePoint
{
internal InstructionOffset offset;
public int Offset
{
get { return offset.Offset; }
}
public int StartLine { get; set; }
public int StartColumn { get; set; }
public int EndLine { get; set; }
public int EndColumn { get; set; }
public bool IsHidden
{
get { return StartLine == 0xfeefee && StartLine == EndLine; }
}
public Document Document { get; set; }
internal SequencePoint(int offset, Document document)
{
if (document == null)
throw new ArgumentNullException("document");
this.offset = new(offset);
this.Document = document;
}
public SequencePoint(Instruction instruction, Document document)
{
if (document == null)
throw new ArgumentNullException("document");
offset = new(instruction);
this.Document = document;
}
}
}
@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 612e6675dca63a84b9e8aaeb3e3b9ec6
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 207815
packageName: 'FishNet: Networking Evolved'
packageVersion: 4.6.22R
assetPath: Assets/FishNet/CodeGenerating/cecil-0.11.4/Mono.Cecil.Cil/SequencePoint.cs
uploadId: 866910
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: de9ae158807f471449a81d9b8b3e3c4e
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 207815
packageName: 'FishNet: Networking Evolved'
packageVersion: 4.6.22R
assetPath: Assets/FishNet/CodeGenerating/cecil-0.11.4/Mono.Cecil.Cil/Symbols.cs
uploadId: 866910
@@ -0,0 +1,26 @@
//
// Author:
// Jb Evain (jbevain@gmail.com)
//
// Copyright (c) 2008 - 2015 Jb Evain
// Copyright (c) 2008 - 2011 Novell, Inc.
//
// Licensed under the MIT/X11 license.
//
namespace MonoFN.Cecil.Cil
{
public sealed class VariableDefinition : VariableReference
{
public bool IsPinned
{
get { return variable_type.IsPinned; }
}
public VariableDefinition(TypeReference variableType) : base(variableType) { }
public override VariableDefinition Resolve()
{
return this;
}
}
}
@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 1346fa5ba8ac9e8418cc20d2d7d0ad21
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 207815
packageName: 'FishNet: Networking Evolved'
packageVersion: 4.6.22R
assetPath: Assets/FishNet/CodeGenerating/cecil-0.11.4/Mono.Cecil.Cil/VariableDefinition.cs
uploadId: 866910
@@ -0,0 +1,42 @@
//
// Author:
// Jb Evain (jbevain@gmail.com)
//
// Copyright (c) 2008 - 2015 Jb Evain
// Copyright (c) 2008 - 2011 Novell, Inc.
//
// Licensed under the MIT/X11 license.
//
namespace MonoFN.Cecil.Cil
{
public abstract class VariableReference
{
internal int index = -1;
protected TypeReference variable_type;
public TypeReference VariableType
{
get { return variable_type; }
set { variable_type = value; }
}
public int Index
{
get { return index; }
}
internal VariableReference(TypeReference variable_type)
{
this.variable_type = variable_type;
}
public abstract VariableDefinition Resolve();
public override string ToString()
{
if (index >= 0)
return "V_" + index;
return string.Empty;
}
}
}
@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: b5dca1eaac23bfd4ba8e881302a72e33
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 207815
packageName: 'FishNet: Networking Evolved'
packageVersion: 4.6.22R
assetPath: Assets/FishNet/CodeGenerating/cecil-0.11.4/Mono.Cecil.Cil/VariableReference.cs
uploadId: 866910
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: cf18653914b5e6f429d4566a7897264c
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,52 @@
//
// Author:
// Jb Evain (jbevain@gmail.com)
//
// Copyright (c) 2008 - 2015 Jb Evain
// Copyright (c) 2008 - 2011 Novell, Inc.
//
// Licensed under the MIT/X11 license.
//
using System;
namespace MonoFN.Cecil.Metadata
{
internal sealed class BlobHeap : Heap
{
public BlobHeap(byte[] data) : base(data) { }
public byte[] Read(uint index)
{
if (index == 0 || index > data.Length - 1)
return Empty<byte>.Array;
int position = (int)index;
int length = (int)data.ReadCompressedUInt32(ref position);
if (length > data.Length - position)
return Empty<byte>.Array;
byte[] buffer = new byte [length];
Buffer.BlockCopy(data, position, buffer, 0, length);
return buffer;
}
public void GetView(uint signature, out byte[] buffer, out int index, out int length)
{
if (signature == 0 || signature > data.Length - 1)
{
buffer = null;
index = length = 0;
return;
}
buffer = data;
index = (int)signature;
length = (int)buffer.ReadCompressedUInt32(ref index);
}
}
}
@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 33eef67f4a74e1c40a6bdb3da9d22d00
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 207815
packageName: 'FishNet: Networking Evolved'
packageVersion: 4.6.22R
assetPath: Assets/FishNet/CodeGenerating/cecil-0.11.4/Mono.Cecil.Metadata/BlobHeap.cs
uploadId: 866910
@@ -0,0 +1,489 @@
//
// Author:
// Jb Evain (jbevain@gmail.com)
//
// Copyright (c) 2008 - 2015 Jb Evain
// Copyright (c) 2008 - 2011 Novell, Inc.
//
// Licensed under the MIT/X11 license.
//
using MonoFN.Cecil.PE;
using System;
using System.Collections.Generic;
using System.Text;
using RVA = System.UInt32;
namespace MonoFN.Cecil.Metadata
{
internal sealed class TableHeapBuffer : HeapBuffer
{
private readonly ModuleDefinition module;
private readonly MetadataBuilder metadata;
internal readonly TableInformation[] table_infos = new TableInformation [Mixin.TableCount];
internal readonly MetadataTable[] tables = new MetadataTable [Mixin.TableCount];
private bool large_string;
private bool large_blob;
private bool large_guid;
private readonly int[] coded_index_sizes = new int [Mixin.CodedIndexCount];
private readonly Func<Table, int> counter;
internal uint[] string_offsets;
public override bool IsEmpty
{
get { return false; }
}
public TableHeapBuffer(ModuleDefinition module, MetadataBuilder metadata) : base(24)
{
this.module = module;
this.metadata = metadata;
counter = GetTableLength;
}
private int GetTableLength(Table table)
{
return (int)table_infos[(int)table].Length;
}
public TTable GetTable<TTable>(Table table) where TTable : MetadataTable, new()
{
TTable md_table = (TTable)tables[(int)table];
if (md_table != null)
return md_table;
md_table = new();
tables[(int)table] = md_table;
return md_table;
}
public void WriteBySize(uint value, int size)
{
if (size == 4)
WriteUInt32(value);
else
WriteUInt16((ushort)value);
}
public void WriteBySize(uint value, bool large)
{
if (large)
WriteUInt32(value);
else
WriteUInt16((ushort)value);
}
public void WriteString(uint @string)
{
WriteBySize(string_offsets[@string], large_string);
}
public void WriteBlob(uint blob)
{
WriteBySize(blob, large_blob);
}
public void WriteGuid(uint guid)
{
WriteBySize(guid, large_guid);
}
public void WriteRID(uint rid, Table table)
{
WriteBySize(rid, table_infos[(int)table].IsLarge);
}
private int GetCodedIndexSize(CodedIndex coded_index)
{
int index = (int)coded_index;
int size = coded_index_sizes[index];
if (size != 0)
return size;
return coded_index_sizes[index] = coded_index.GetSize(counter);
}
public void WriteCodedRID(uint rid, CodedIndex coded_index)
{
WriteBySize(rid, GetCodedIndexSize(coded_index));
}
public void WriteTableHeap()
{
WriteUInt32(0); // Reserved
WriteByte(GetTableHeapVersion()); // MajorVersion
WriteByte(0); // MinorVersion
WriteByte(GetHeapSizes()); // HeapSizes
WriteByte(10); // Reserved2
WriteUInt64(GetValid()); // Valid
WriteUInt64(0xc416003301fa00); // Sorted
WriteRowCount();
WriteTables();
}
private void WriteRowCount()
{
for (int i = 0; i < tables.Length; i++)
{
MetadataTable table = tables[i];
if (table == null || table.Length == 0)
continue;
WriteUInt32((uint)table.Length);
}
}
private void WriteTables()
{
for (int i = 0; i < tables.Length; i++)
{
MetadataTable table = tables[i];
if (table == null || table.Length == 0)
continue;
table.Write(this);
}
}
private ulong GetValid()
{
ulong valid = 0;
for (int i = 0; i < tables.Length; i++)
{
MetadataTable table = tables[i];
if (table == null || table.Length == 0)
continue;
table.Sort();
valid |= 1UL << i;
}
return valid;
}
public void ComputeTableInformations()
{
if (metadata.metadata_builder != null)
ComputeTableInformations(metadata.metadata_builder.table_heap);
ComputeTableInformations(metadata.table_heap);
}
private void ComputeTableInformations(TableHeapBuffer table_heap)
{
MetadataTable[] tables = table_heap.tables;
for (int i = 0; i < tables.Length; i++)
{
MetadataTable table = tables[i];
if (table != null && table.Length > 0)
table_infos[i].Length = (uint)table.Length;
}
}
private byte GetHeapSizes()
{
byte heap_sizes = 0;
if (metadata.string_heap.IsLarge)
{
large_string = true;
heap_sizes |= 0x01;
}
if (metadata.guid_heap.IsLarge)
{
large_guid = true;
heap_sizes |= 0x02;
}
if (metadata.blob_heap.IsLarge)
{
large_blob = true;
heap_sizes |= 0x04;
}
return heap_sizes;
}
private byte GetTableHeapVersion()
{
switch (module.Runtime)
{
case TargetRuntime.Net_1_0:
case TargetRuntime.Net_1_1:
return 1;
default:
return 2;
}
}
public void FixupData(RVA data_rva)
{
FieldRVATable table = GetTable<FieldRVATable>(Table.FieldRVA);
if (table.length == 0)
return;
int field_idx_size = GetTable<FieldTable>(Table.Field).IsLarge ? 4 : 2;
int previous = position;
position = table.position;
for (int i = 0; i < table.length; i++)
{
uint rva = ReadUInt32();
position -= 4;
WriteUInt32(rva + data_rva);
position += field_idx_size;
}
position = previous;
}
}
internal sealed class ResourceBuffer : ByteBuffer
{
public ResourceBuffer() : base(0) { }
public uint AddResource(byte[] resource)
{
uint offset = (uint)position;
WriteInt32(resource.Length);
WriteBytes(resource);
return offset;
}
}
internal sealed class DataBuffer : ByteBuffer
{
public DataBuffer() : base(0) { }
public RVA AddData(byte[] data)
{
RVA rva = (RVA)position;
WriteBytes(data);
return rva;
}
}
internal abstract class HeapBuffer : ByteBuffer
{
public bool IsLarge
{
get { return length > 65535; }
}
public abstract bool IsEmpty { get; }
protected HeapBuffer(int length) : base(length) { }
}
internal sealed class GuidHeapBuffer : HeapBuffer
{
private readonly Dictionary<Guid, uint> guids = new();
public override bool IsEmpty
{
get { return length == 0; }
}
public GuidHeapBuffer() : base(16) { }
public uint GetGuidIndex(Guid guid)
{
uint index;
if (guids.TryGetValue(guid, out index))
return index;
index = (uint)guids.Count + 1;
WriteGuid(guid);
guids.Add(guid, index);
return index;
}
private void WriteGuid(Guid guid)
{
WriteBytes(guid.ToByteArray());
}
}
internal class StringHeapBuffer : HeapBuffer
{
protected Dictionary<string, uint> strings = new(StringComparer.Ordinal);
public sealed override bool IsEmpty
{
get { return length <= 1; }
}
public StringHeapBuffer() : base(1)
{
WriteByte(0);
}
public virtual uint GetStringIndex(string @string)
{
uint index;
if (strings.TryGetValue(@string, out index))
return index;
index = (uint)strings.Count + 1;
strings.Add(@string, index);
return index;
}
public uint[] WriteStrings()
{
List<KeyValuePair<string, uint>> sorted = SortStrings(strings);
strings = null;
// Add 1 for empty string whose index and offset are both 0
uint[] string_offsets = new uint [sorted.Count + 1];
string_offsets[0] = 0;
// Find strings that can be folded
string previous = string.Empty;
foreach (KeyValuePair<string, uint> entry in sorted)
{
string @string = entry.Key;
uint index = entry.Value;
int position = this.position;
if (previous.EndsWith(@string, StringComparison.Ordinal) && !IsLowSurrogateChar(entry.Key[0]))
{
// Map over the tail of prev string. Watch for null-terminator of prev string.
string_offsets[index] = (uint)(position - (Encoding.UTF8.GetByteCount(entry.Key) + 1));
}
else
{
string_offsets[index] = (uint)position;
WriteString(@string);
}
previous = entry.Key;
}
return string_offsets;
}
private static List<KeyValuePair<string, uint>> SortStrings(Dictionary<string, uint> strings)
{
List<KeyValuePair<string, uint>> sorted = new(strings);
sorted.Sort(new SuffixSort());
return sorted;
}
private static bool IsLowSurrogateChar(int c)
{
return unchecked((uint)(c - 0xDC00)) <= 0xDFFF - 0xDC00;
}
protected virtual void WriteString(string @string)
{
WriteBytes(Encoding.UTF8.GetBytes(@string));
WriteByte(0);
}
// Sorts strings such that a string is followed immediately by all strings
// that are a suffix of it.
private class SuffixSort : IComparer<KeyValuePair<string, uint>>
{
public int Compare(KeyValuePair<string, uint> xPair, KeyValuePair<string, uint> yPair)
{
string x = xPair.Key;
string y = yPair.Key;
for (int i = x.Length - 1, j = y.Length - 1; (i >= 0) & (j >= 0); i--, j--)
{
if (x[i] < y[j])
{
return -1;
}
if (x[i] > y[j])
{
return +1;
}
}
return y.Length.CompareTo(x.Length);
}
}
}
internal sealed class BlobHeapBuffer : HeapBuffer
{
private readonly Dictionary<ByteBuffer, uint> blobs = new(new ByteBufferEqualityComparer());
public override bool IsEmpty
{
get { return length <= 1; }
}
public BlobHeapBuffer() : base(1)
{
WriteByte(0);
}
public uint GetBlobIndex(ByteBuffer blob)
{
uint index;
if (blobs.TryGetValue(blob, out index))
return index;
index = (uint)position;
WriteBlob(blob);
blobs.Add(blob, index);
return index;
}
private void WriteBlob(ByteBuffer blob)
{
WriteCompressedUInt32((uint)blob.length);
WriteBytes(blob);
}
}
internal sealed class UserStringHeapBuffer : StringHeapBuffer
{
public override uint GetStringIndex(string @string)
{
uint index;
if (strings.TryGetValue(@string, out index))
return index;
index = (uint)position;
WriteString(@string);
strings.Add(@string, index);
return index;
}
protected override void WriteString(string @string)
{
WriteCompressedUInt32((uint)@string.Length * 2 + 1);
byte special = 0;
for (int i = 0; i < @string.Length; i++)
{
char @char = @string[i];
WriteUInt16(@char);
if (special == 1)
continue;
if (@char < 0x20 || @char > 0x7e)
{
if (@char > 0x7e || (@char >= 0x01 && @char <= 0x08) || (@char >= 0x0e && @char <= 0x1f) || @char == 0x27 || @char == 0x2d)
{
special = 1;
}
}
}
WriteByte(special);
}
}
internal sealed class PdbHeapBuffer : HeapBuffer
{
public override bool IsEmpty
{
get { return false; }
}
public PdbHeapBuffer() : base(0) { }
}
}
@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 4b1d0a81b66e78341ab77acdd3b15234
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 207815
packageName: 'FishNet: Networking Evolved'
packageVersion: 4.6.22R
assetPath: Assets/FishNet/CodeGenerating/cecil-0.11.4/Mono.Cecil.Metadata/Buffers.cs
uploadId: 866910
@@ -0,0 +1,30 @@
//
// Author:
// Jb Evain (jbevain@gmail.com)
//
// Copyright (c) 2008 - 2015 Jb Evain
// Copyright (c) 2008 - 2011 Novell, Inc.
//
// Licensed under the MIT/X11 license.
//
namespace MonoFN.Cecil.Metadata
{
internal enum CodedIndex
{
TypeDefOrRef,
HasConstant,
HasCustomAttribute,
HasFieldMarshal,
HasDeclSecurity,
MemberRefParent,
HasSemantics,
MethodDefOrRef,
MemberForwarded,
Implementation,
CustomAttributeType,
ResolutionScope,
TypeOrMethodDef,
HasCustomDebugInformation
}
}
@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: dd50ffa8272dac444831e33b1b9d7f56
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 207815
packageName: 'FishNet: Networking Evolved'
packageVersion: 4.6.22R
assetPath: Assets/FishNet/CodeGenerating/cecil-0.11.4/Mono.Cecil.Metadata/CodedIndex.cs
uploadId: 866910
@@ -0,0 +1,56 @@
//
// Author:
// Jb Evain (jbevain@gmail.com)
//
// Copyright (c) 2008 - 2015 Jb Evain
// Copyright (c) 2008 - 2011 Novell, Inc.
//
// Licensed under the MIT/X11 license.
//
namespace MonoFN.Cecil.Metadata
{
internal enum ElementType : byte
{
None = 0x00,
Void = 0x01,
Boolean = 0x02,
Char = 0x03,
I1 = 0x04,
U1 = 0x05,
I2 = 0x06,
U2 = 0x07,
I4 = 0x08,
U4 = 0x09,
I8 = 0x0a,
U8 = 0x0b,
R4 = 0x0c,
R8 = 0x0d,
String = 0x0e,
Ptr = 0x0f, // Followed by <type> token
ByRef = 0x10, // Followed by <type> token
ValueType = 0x11, // Followed by <type> token
Class = 0x12, // Followed by <type> token
Var = 0x13, // Followed by generic parameter number
Array = 0x14, // <type> <rank> <boundsCount> <bound1> <loCount> <lo1>
GenericInst = 0x15, // <type> <type-arg-count> <type-1> ... <type-n> */
TypedByRef = 0x16,
I = 0x18, // System.IntPtr
U = 0x19, // System.UIntPtr
FnPtr = 0x1b, // Followed by full method signature
Object = 0x1c, // System.Object
SzArray = 0x1d, // Single-dim array with 0 lower bound
MVar = 0x1e, // Followed by generic parameter number
CModReqD = 0x1f, // Required modifier : followed by a TypeDef or TypeRef token
CModOpt = 0x20, // Optional modifier : followed by a TypeDef or TypeRef token
Internal = 0x21, // Implemented within the CLI
Modifier = 0x40, // Or'd with following element types
Sentinel = 0x41, // Sentinel for varargs method signature
Pinned = 0x45, // Denotes a local variable that points at a pinned object
// special undocumented constants
Type = 0x50,
Boxed = 0x51,
Enum = 0x55
}
}
@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 94c4cb498ef60034d83bb60d3f743832
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 207815
packageName: 'FishNet: Networking Evolved'
packageVersion: 4.6.22R
assetPath: Assets/FishNet/CodeGenerating/cecil-0.11.4/Mono.Cecil.Metadata/ElementType.cs
uploadId: 866910
@@ -0,0 +1,33 @@
//
// Author:
// Jb Evain (jbevain@gmail.com)
//
// Copyright (c) 2008 - 2015 Jb Evain
// Copyright (c) 2008 - 2011 Novell, Inc.
//
// Licensed under the MIT/X11 license.
//
using System;
namespace MonoFN.Cecil.Metadata
{
internal sealed class GuidHeap : Heap
{
public GuidHeap(byte[] data) : base(data) { }
public Guid Read(uint index)
{
const int guid_size = 16;
if (index == 0 || index - 1 + guid_size > data.Length)
return new();
byte[] buffer = new byte [guid_size];
Buffer.BlockCopy(data, (int)((index - 1) * guid_size), buffer, 0, guid_size);
return new(buffer);
}
}
}
@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 4bb39ab6484eb114b91a85d4b53f0f28
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 207815
packageName: 'FishNet: Networking Evolved'
packageVersion: 4.6.22R
assetPath: Assets/FishNet/CodeGenerating/cecil-0.11.4/Mono.Cecil.Metadata/GuidHeap.cs
uploadId: 866910
@@ -0,0 +1,23 @@
//
// Author:
// Jb Evain (jbevain@gmail.com)
//
// Copyright (c) 2008 - 2015 Jb Evain
// Copyright (c) 2008 - 2011 Novell, Inc.
//
// Licensed under the MIT/X11 license.
//
namespace MonoFN.Cecil.Metadata
{
internal abstract class Heap
{
public int IndexSize;
internal readonly byte[] data;
protected Heap(byte[] data)
{
this.data = data;
}
}
}
@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: c343466f40d68574499155a2acd05e6b
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 207815
packageName: 'FishNet: Networking Evolved'
packageVersion: 4.6.22R
assetPath: Assets/FishNet/CodeGenerating/cecil-0.11.4/Mono.Cecil.Metadata/Heap.cs
uploadId: 866910
@@ -0,0 +1,91 @@
//
// Author:
// Jb Evain (jbevain@gmail.com)
//
// Copyright (c) 2008 - 2015 Jb Evain
// Copyright (c) 2008 - 2011 Novell, Inc.
//
// Licensed under the MIT/X11 license.
//
using System;
namespace MonoFN.Cecil
{
public struct MetadataToken : IEquatable<MetadataToken>
{
private readonly uint token;
public uint RID
{
get { return token & 0x00ffffff; }
}
public TokenType TokenType
{
get { return (TokenType)(token & 0xff000000); }
}
public static readonly MetadataToken Zero = new((uint)0);
public MetadataToken(uint token)
{
this.token = token;
}
public MetadataToken(TokenType type) : this(type, 0) { }
public MetadataToken(TokenType type, uint rid)
{
token = (uint)type | rid;
}
public MetadataToken(TokenType type, int rid)
{
token = (uint)type | (uint)rid;
}
public int ToInt32()
{
return (int)token;
}
public uint ToUInt32()
{
return token;
}
public override int GetHashCode()
{
return (int)token;
}
public bool Equals(MetadataToken other)
{
return other.token == token;
}
public override bool Equals(object obj)
{
if (obj is MetadataToken)
{
MetadataToken other = (MetadataToken)obj;
return other.token == token;
}
return false;
}
public static bool operator ==(MetadataToken one, MetadataToken other)
{
return one.token == other.token;
}
public static bool operator !=(MetadataToken one, MetadataToken other)
{
return one.token != other.token;
}
public override string ToString()
{
return string.Format("[{0}:0x{1}]", TokenType, RID.ToString("x4"));
}
}
}
@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 755d1954236c374458be77d93493faf8
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 207815
packageName: 'FishNet: Networking Evolved'
packageVersion: 4.6.22R
assetPath: Assets/FishNet/CodeGenerating/cecil-0.11.4/Mono.Cecil.Metadata/MetadataToken.cs
uploadId: 866910
@@ -0,0 +1,28 @@
//
// Author:
// Jb Evain (jbevain@gmail.com)
//
// Copyright (c) 2008 - 2015 Jb Evain
// Copyright (c) 2008 - 2011 Novell, Inc.
//
// Licensed under the MIT/X11 license.
//
using RID = System.UInt32;
namespace MonoFN.Cecil.Metadata
{
internal sealed class PdbHeap : Heap
{
public byte[] Id;
public RID EntryPoint;
public long TypeSystemTables;
public uint[] TypeSystemTableRows;
public PdbHeap(byte[] data) : base(data) { }
public bool HasTable(Table table)
{
return (TypeSystemTables & (1L << (int)table)) != 0;
}
}
}
@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: c64dd6e20a2b11c44ad424d29380c14c
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 207815
packageName: 'FishNet: Networking Evolved'
packageVersion: 4.6.22R
assetPath: Assets/FishNet/CodeGenerating/cecil-0.11.4/Mono.Cecil.Metadata/PdbHeap.cs
uploadId: 866910
@@ -0,0 +1,154 @@
//
// Author:
// Jb Evain (jbevain@gmail.com)
//
// Copyright (c) 2008 - 2015 Jb Evain
// Copyright (c) 2008 - 2011 Novell, Inc.
//
// Licensed under the MIT/X11 license.
//
using System.Collections.Generic;
namespace MonoFN.Cecil.Metadata
{
internal struct Row<T1, T2>
{
internal T1 Col1;
internal T2 Col2;
public Row(T1 col1, T2 col2)
{
Col1 = col1;
Col2 = col2;
}
}
internal struct Row<T1, T2, T3>
{
internal T1 Col1;
internal T2 Col2;
internal T3 Col3;
public Row(T1 col1, T2 col2, T3 col3)
{
Col1 = col1;
Col2 = col2;
Col3 = col3;
}
}
internal struct Row<T1, T2, T3, T4>
{
internal T1 Col1;
internal T2 Col2;
internal T3 Col3;
internal T4 Col4;
public Row(T1 col1, T2 col2, T3 col3, T4 col4)
{
Col1 = col1;
Col2 = col2;
Col3 = col3;
Col4 = col4;
}
}
internal struct Row<T1, T2, T3, T4, T5>
{
internal T1 Col1;
internal T2 Col2;
internal T3 Col3;
internal T4 Col4;
internal T5 Col5;
public Row(T1 col1, T2 col2, T3 col3, T4 col4, T5 col5)
{
Col1 = col1;
Col2 = col2;
Col3 = col3;
Col4 = col4;
Col5 = col5;
}
}
internal struct Row<T1, T2, T3, T4, T5, T6>
{
internal T1 Col1;
internal T2 Col2;
internal T3 Col3;
internal T4 Col4;
internal T5 Col5;
internal T6 Col6;
public Row(T1 col1, T2 col2, T3 col3, T4 col4, T5 col5, T6 col6)
{
Col1 = col1;
Col2 = col2;
Col3 = col3;
Col4 = col4;
Col5 = col5;
Col6 = col6;
}
}
internal struct Row<T1, T2, T3, T4, T5, T6, T7, T8, T9>
{
internal T1 Col1;
internal T2 Col2;
internal T3 Col3;
internal T4 Col4;
internal T5 Col5;
internal T6 Col6;
internal T7 Col7;
internal T8 Col8;
internal T9 Col9;
public Row(T1 col1, T2 col2, T3 col3, T4 col4, T5 col5, T6 col6, T7 col7, T8 col8, T9 col9)
{
Col1 = col1;
Col2 = col2;
Col3 = col3;
Col4 = col4;
Col5 = col5;
Col6 = col6;
Col7 = col7;
Col8 = col8;
Col9 = col9;
}
}
internal sealed class RowEqualityComparer : IEqualityComparer<Row<string, string>>, IEqualityComparer<Row<uint, uint>>, IEqualityComparer<Row<uint, uint, uint>>
{
public bool Equals(Row<string, string> x, Row<string, string> y)
{
return x.Col1 == y.Col1 && x.Col2 == y.Col2;
}
public int GetHashCode(Row<string, string> obj)
{
string x = obj.Col1, y = obj.Col2;
return (x != null ? x.GetHashCode() : 0) ^ (y != null ? y.GetHashCode() : 0);
}
public bool Equals(Row<uint, uint> x, Row<uint, uint> y)
{
return x.Col1 == y.Col1 && x.Col2 == y.Col2;
}
public int GetHashCode(Row<uint, uint> obj)
{
return (int)(obj.Col1 ^ obj.Col2);
}
public bool Equals(Row<uint, uint, uint> x, Row<uint, uint, uint> y)
{
return x.Col1 == y.Col1 && x.Col2 == y.Col2 && x.Col3 == y.Col3;
}
public int GetHashCode(Row<uint, uint, uint> obj)
{
return (int)(obj.Col1 ^ obj.Col2 ^ obj.Col3);
}
}
}
@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 89fd184bcc2b97840a2c0dfeec671be2
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 207815
packageName: 'FishNet: Networking Evolved'
packageVersion: 4.6.22R
assetPath: Assets/FishNet/CodeGenerating/cecil-0.11.4/Mono.Cecil.Metadata/Row.cs
uploadId: 866910
@@ -0,0 +1,56 @@
//
// Author:
// Jb Evain (jbevain@gmail.com)
//
// Copyright (c) 2008 - 2015 Jb Evain
// Copyright (c) 2008 - 2011 Novell, Inc.
//
// Licensed under the MIT/X11 license.
//
using System.Collections.Generic;
using System.Text;
namespace MonoFN.Cecil.Metadata
{
internal class StringHeap : Heap
{
private readonly Dictionary<uint, string> strings = new();
public StringHeap(byte[] data) : base(data) { }
public string Read(uint index)
{
if (index == 0)
return string.Empty;
string @string;
if (strings.TryGetValue(index, out @string))
return @string;
if (index > data.Length - 1)
return string.Empty;
@string = ReadStringAt(index);
if (@string.Length != 0)
strings.Add(index, @string);
return @string;
}
protected virtual string ReadStringAt(uint index)
{
int length = 0;
int start = (int)index;
for (int i = start;; i++)
{
if (data[i] == 0)
break;
length++;
}
return Encoding.UTF8.GetString(data, start, length);
}
}
}
@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: e0fc64863ca825b4e994640b0be9a938
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 207815
packageName: 'FishNet: Networking Evolved'
packageVersion: 4.6.22R
assetPath: Assets/FishNet/CodeGenerating/cecil-0.11.4/Mono.Cecil.Metadata/StringHeap.cs
uploadId: 866910
@@ -0,0 +1,97 @@
//
// Author:
// Jb Evain (jbevain@gmail.com)
//
// Copyright (c) 2008 - 2015 Jb Evain
// Copyright (c) 2008 - 2011 Novell, Inc.
//
// Licensed under the MIT/X11 license.
//
namespace MonoFN.Cecil.Metadata
{
internal enum Table : byte
{
Module = 0x00,
TypeRef = 0x01,
TypeDef = 0x02,
FieldPtr = 0x03,
Field = 0x04,
MethodPtr = 0x05,
Method = 0x06,
ParamPtr = 0x07,
Param = 0x08,
InterfaceImpl = 0x09,
MemberRef = 0x0a,
Constant = 0x0b,
CustomAttribute = 0x0c,
FieldMarshal = 0x0d,
DeclSecurity = 0x0e,
ClassLayout = 0x0f,
FieldLayout = 0x10,
StandAloneSig = 0x11,
EventMap = 0x12,
EventPtr = 0x13,
Event = 0x14,
PropertyMap = 0x15,
PropertyPtr = 0x16,
Property = 0x17,
MethodSemantics = 0x18,
MethodImpl = 0x19,
ModuleRef = 0x1a,
TypeSpec = 0x1b,
ImplMap = 0x1c,
FieldRVA = 0x1d,
EncLog = 0x1e,
EncMap = 0x1f,
Assembly = 0x20,
AssemblyProcessor = 0x21,
AssemblyOS = 0x22,
AssemblyRef = 0x23,
AssemblyRefProcessor = 0x24,
AssemblyRefOS = 0x25,
File = 0x26,
ExportedType = 0x27,
ManifestResource = 0x28,
NestedClass = 0x29,
GenericParam = 0x2a,
MethodSpec = 0x2b,
GenericParamConstraint = 0x2c,
Document = 0x30,
MethodDebugInformation = 0x31,
LocalScope = 0x32,
LocalVariable = 0x33,
LocalConstant = 0x34,
ImportScope = 0x35,
StateMachineMethod = 0x36,
CustomDebugInformation = 0x37
}
internal struct TableInformation
{
public uint Offset;
public uint Length;
public uint RowSize;
public bool IsLarge
{
get { return Length > ushort.MaxValue; }
}
}
internal sealed class TableHeap : Heap
{
public long Valid;
public long Sorted;
public readonly TableInformation[] Tables = new TableInformation [Mixin.TableCount];
public TableInformation this[Table table]
{
get { return Tables[(int)table]; }
}
public TableHeap(byte[] data) : base(data) { }
public bool HasTable(Table table)
{
return (Valid & (1L << (int)table)) != 0;
}
}
}
@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 978b1609b2ddc0c4baf628cc608456a9
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 207815
packageName: 'FishNet: Networking Evolved'
packageVersion: 4.6.22R
assetPath: Assets/FishNet/CodeGenerating/cecil-0.11.4/Mono.Cecil.Metadata/TableHeap.cs
uploadId: 866910
@@ -0,0 +1,48 @@
//
// Author:
// Jb Evain (jbevain@gmail.com)
//
// Copyright (c) 2008 - 2015 Jb Evain
// Copyright (c) 2008 - 2011 Novell, Inc.
//
// Licensed under the MIT/X11 license.
//
namespace MonoFN.Cecil
{
public enum TokenType : uint
{
Module = 0x00000000,
TypeRef = 0x01000000,
TypeDef = 0x02000000,
Field = 0x04000000,
Method = 0x06000000,
Param = 0x08000000,
InterfaceImpl = 0x09000000,
MemberRef = 0x0a000000,
CustomAttribute = 0x0c000000,
Permission = 0x0e000000,
Signature = 0x11000000,
Event = 0x14000000,
Property = 0x17000000,
ModuleRef = 0x1a000000,
TypeSpec = 0x1b000000,
Assembly = 0x20000000,
AssemblyRef = 0x23000000,
File = 0x26000000,
ExportedType = 0x27000000,
ManifestResource = 0x28000000,
GenericParam = 0x2a000000,
MethodSpec = 0x2b000000,
GenericParamConstraint = 0x2c000000,
Document = 0x30000000,
MethodDebugInformation = 0x31000000,
LocalScope = 0x32000000,
LocalVariable = 0x33000000,
LocalConstant = 0x34000000,
ImportScope = 0x35000000,
StateMachineMethod = 0x36000000,
CustomDebugInformation = 0x37000000,
String = 0x70000000
}
}
@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: dba0af6138c6a084b8787e88b20b142a
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 207815
packageName: 'FishNet: Networking Evolved'
packageVersion: 4.6.22R
assetPath: Assets/FishNet/CodeGenerating/cecil-0.11.4/Mono.Cecil.Metadata/TokenType.cs
uploadId: 866910
@@ -0,0 +1,33 @@
//
// Author:
// Jb Evain (jbevain@gmail.com)
//
// Copyright (c) 2008 - 2015 Jb Evain
// Copyright (c) 2008 - 2011 Novell, Inc.
//
// Licensed under the MIT/X11 license.
//
namespace MonoFN.Cecil.Metadata
{
internal sealed class UserStringHeap : StringHeap
{
public UserStringHeap(byte[] data) : base(data) { }
protected override string ReadStringAt(uint index)
{
int start = (int)index;
uint length = (uint)(data.ReadCompressedUInt32(ref start) & ~1);
if (length < 1)
return string.Empty;
char[] chars = new char [length / 2];
for (int i = start, j = 0; i < start + length; i += 2)
chars[j++] = (char)(data[i] | (data[i + 1] << 8));
return new(chars);
}
}
}
@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 2d89100b382ef8e4ea67917917d04db6
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 207815
packageName: 'FishNet: Networking Evolved'
packageVersion: 4.6.22R
assetPath: Assets/FishNet/CodeGenerating/cecil-0.11.4/Mono.Cecil.Metadata/UserStringHeap.cs
uploadId: 866910
@@ -0,0 +1,771 @@
//
// Author:
// Jb Evain (jbevain@gmail.com)
//
// Copyright (c) 2008 - 2015 Jb Evain
// Copyright (c) 2008 - 2011 Novell, Inc.
//
// Licensed under the MIT/X11 license.
//
using MonoFN.Cecil.Metadata;
using System;
namespace MonoFN.Cecil
{
internal static partial class Mixin
{
public const int TableCount = 58;
public const int CodedIndexCount = 14;
public static uint ReadCompressedUInt32(this byte[] data, ref int position)
{
uint integer;
if ((data[position] & 0x80) == 0)
{
integer = data[position];
position++;
}
else if ((data[position] & 0x40) == 0)
{
integer = (uint)(data[position] & ~0x80) << 8;
integer |= data[position + 1];
position += 2;
}
else
{
integer = (uint)(data[position] & ~0xc0) << 24;
integer |= (uint)data[position + 1] << 16;
integer |= (uint)data[position + 2] << 8;
integer |= (uint)data[position + 3];
position += 4;
}
return integer;
}
public static MetadataToken GetMetadataToken(this CodedIndex self, uint data)
{
uint rid;
TokenType token_type;
switch (self)
{
case CodedIndex.TypeDefOrRef:
rid = data >> 2;
switch (data & 3)
{
case 0:
token_type = TokenType.TypeDef;
goto ret;
case 1:
token_type = TokenType.TypeRef;
goto ret;
case 2:
token_type = TokenType.TypeSpec;
goto ret;
default:
goto exit;
}
case CodedIndex.HasConstant:
rid = data >> 2;
switch (data & 3)
{
case 0:
token_type = TokenType.Field;
goto ret;
case 1:
token_type = TokenType.Param;
goto ret;
case 2:
token_type = TokenType.Property;
goto ret;
default:
goto exit;
}
case CodedIndex.HasCustomAttribute:
rid = data >> 5;
switch (data & 31)
{
case 0:
token_type = TokenType.Method;
goto ret;
case 1:
token_type = TokenType.Field;
goto ret;
case 2:
token_type = TokenType.TypeRef;
goto ret;
case 3:
token_type = TokenType.TypeDef;
goto ret;
case 4:
token_type = TokenType.Param;
goto ret;
case 5:
token_type = TokenType.InterfaceImpl;
goto ret;
case 6:
token_type = TokenType.MemberRef;
goto ret;
case 7:
token_type = TokenType.Module;
goto ret;
case 8:
token_type = TokenType.Permission;
goto ret;
case 9:
token_type = TokenType.Property;
goto ret;
case 10:
token_type = TokenType.Event;
goto ret;
case 11:
token_type = TokenType.Signature;
goto ret;
case 12:
token_type = TokenType.ModuleRef;
goto ret;
case 13:
token_type = TokenType.TypeSpec;
goto ret;
case 14:
token_type = TokenType.Assembly;
goto ret;
case 15:
token_type = TokenType.AssemblyRef;
goto ret;
case 16:
token_type = TokenType.File;
goto ret;
case 17:
token_type = TokenType.ExportedType;
goto ret;
case 18:
token_type = TokenType.ManifestResource;
goto ret;
case 19:
token_type = TokenType.GenericParam;
goto ret;
case 20:
token_type = TokenType.GenericParamConstraint;
goto ret;
case 21:
token_type = TokenType.MethodSpec;
goto ret;
default:
goto exit;
}
case CodedIndex.HasFieldMarshal:
rid = data >> 1;
switch (data & 1)
{
case 0:
token_type = TokenType.Field;
goto ret;
case 1:
token_type = TokenType.Param;
goto ret;
default:
goto exit;
}
case CodedIndex.HasDeclSecurity:
rid = data >> 2;
switch (data & 3)
{
case 0:
token_type = TokenType.TypeDef;
goto ret;
case 1:
token_type = TokenType.Method;
goto ret;
case 2:
token_type = TokenType.Assembly;
goto ret;
default:
goto exit;
}
case CodedIndex.MemberRefParent:
rid = data >> 3;
switch (data & 7)
{
case 0:
token_type = TokenType.TypeDef;
goto ret;
case 1:
token_type = TokenType.TypeRef;
goto ret;
case 2:
token_type = TokenType.ModuleRef;
goto ret;
case 3:
token_type = TokenType.Method;
goto ret;
case 4:
token_type = TokenType.TypeSpec;
goto ret;
default:
goto exit;
}
case CodedIndex.HasSemantics:
rid = data >> 1;
switch (data & 1)
{
case 0:
token_type = TokenType.Event;
goto ret;
case 1:
token_type = TokenType.Property;
goto ret;
default:
goto exit;
}
case CodedIndex.MethodDefOrRef:
rid = data >> 1;
switch (data & 1)
{
case 0:
token_type = TokenType.Method;
goto ret;
case 1:
token_type = TokenType.MemberRef;
goto ret;
default:
goto exit;
}
case CodedIndex.MemberForwarded:
rid = data >> 1;
switch (data & 1)
{
case 0:
token_type = TokenType.Field;
goto ret;
case 1:
token_type = TokenType.Method;
goto ret;
default:
goto exit;
}
case CodedIndex.Implementation:
rid = data >> 2;
switch (data & 3)
{
case 0:
token_type = TokenType.File;
goto ret;
case 1:
token_type = TokenType.AssemblyRef;
goto ret;
case 2:
token_type = TokenType.ExportedType;
goto ret;
default:
goto exit;
}
case CodedIndex.CustomAttributeType:
rid = data >> 3;
switch (data & 7)
{
case 2:
token_type = TokenType.Method;
goto ret;
case 3:
token_type = TokenType.MemberRef;
goto ret;
default:
goto exit;
}
case CodedIndex.ResolutionScope:
rid = data >> 2;
switch (data & 3)
{
case 0:
token_type = TokenType.Module;
goto ret;
case 1:
token_type = TokenType.ModuleRef;
goto ret;
case 2:
token_type = TokenType.AssemblyRef;
goto ret;
case 3:
token_type = TokenType.TypeRef;
goto ret;
default:
goto exit;
}
case CodedIndex.TypeOrMethodDef:
rid = data >> 1;
switch (data & 1)
{
case 0:
token_type = TokenType.TypeDef;
goto ret;
case 1:
token_type = TokenType.Method;
goto ret;
default:
goto exit;
}
case CodedIndex.HasCustomDebugInformation:
rid = data >> 5;
switch (data & 31)
{
case 0:
token_type = TokenType.Method;
goto ret;
case 1:
token_type = TokenType.Field;
goto ret;
case 2:
token_type = TokenType.TypeRef;
goto ret;
case 3:
token_type = TokenType.TypeDef;
goto ret;
case 4:
token_type = TokenType.Param;
goto ret;
case 5:
token_type = TokenType.InterfaceImpl;
goto ret;
case 6:
token_type = TokenType.MemberRef;
goto ret;
case 7:
token_type = TokenType.Module;
goto ret;
case 8:
token_type = TokenType.Permission;
goto ret;
case 9:
token_type = TokenType.Property;
goto ret;
case 10:
token_type = TokenType.Event;
goto ret;
case 11:
token_type = TokenType.Signature;
goto ret;
case 12:
token_type = TokenType.ModuleRef;
goto ret;
case 13:
token_type = TokenType.TypeSpec;
goto ret;
case 14:
token_type = TokenType.Assembly;
goto ret;
case 15:
token_type = TokenType.AssemblyRef;
goto ret;
case 16:
token_type = TokenType.File;
goto ret;
case 17:
token_type = TokenType.ExportedType;
goto ret;
case 18:
token_type = TokenType.ManifestResource;
goto ret;
case 19:
token_type = TokenType.GenericParam;
goto ret;
case 20:
token_type = TokenType.GenericParamConstraint;
goto ret;
case 21:
token_type = TokenType.MethodSpec;
goto ret;
case 22:
token_type = TokenType.Document;
goto ret;
case 23:
token_type = TokenType.LocalScope;
goto ret;
case 24:
token_type = TokenType.LocalVariable;
goto ret;
case 25:
token_type = TokenType.LocalConstant;
goto ret;
case 26:
token_type = TokenType.ImportScope;
goto ret;
default:
goto exit;
}
default:
goto exit;
}
ret:
return new(token_type, rid);
exit:
return MetadataToken.Zero;
}
public static uint CompressMetadataToken(this CodedIndex self, MetadataToken token)
{
uint ret = 0;
if (token.RID == 0)
return ret;
switch (self)
{
case CodedIndex.TypeDefOrRef:
ret = token.RID << 2;
switch (token.TokenType)
{
case TokenType.TypeDef:
return ret | 0;
case TokenType.TypeRef:
return ret | 1;
case TokenType.TypeSpec:
return ret | 2;
default:
goto exit;
}
case CodedIndex.HasConstant:
ret = token.RID << 2;
switch (token.TokenType)
{
case TokenType.Field:
return ret | 0;
case TokenType.Param:
return ret | 1;
case TokenType.Property:
return ret | 2;
default:
goto exit;
}
case CodedIndex.HasCustomAttribute:
ret = token.RID << 5;
switch (token.TokenType)
{
case TokenType.Method:
return ret | 0;
case TokenType.Field:
return ret | 1;
case TokenType.TypeRef:
return ret | 2;
case TokenType.TypeDef:
return ret | 3;
case TokenType.Param:
return ret | 4;
case TokenType.InterfaceImpl:
return ret | 5;
case TokenType.MemberRef:
return ret | 6;
case TokenType.Module:
return ret | 7;
case TokenType.Permission:
return ret | 8;
case TokenType.Property:
return ret | 9;
case TokenType.Event:
return ret | 10;
case TokenType.Signature:
return ret | 11;
case TokenType.ModuleRef:
return ret | 12;
case TokenType.TypeSpec:
return ret | 13;
case TokenType.Assembly:
return ret | 14;
case TokenType.AssemblyRef:
return ret | 15;
case TokenType.File:
return ret | 16;
case TokenType.ExportedType:
return ret | 17;
case TokenType.ManifestResource:
return ret | 18;
case TokenType.GenericParam:
return ret | 19;
case TokenType.GenericParamConstraint:
return ret | 20;
case TokenType.MethodSpec:
return ret | 21;
default:
goto exit;
}
case CodedIndex.HasFieldMarshal:
ret = token.RID << 1;
switch (token.TokenType)
{
case TokenType.Field:
return ret | 0;
case TokenType.Param:
return ret | 1;
default:
goto exit;
}
case CodedIndex.HasDeclSecurity:
ret = token.RID << 2;
switch (token.TokenType)
{
case TokenType.TypeDef:
return ret | 0;
case TokenType.Method:
return ret | 1;
case TokenType.Assembly:
return ret | 2;
default:
goto exit;
}
case CodedIndex.MemberRefParent:
ret = token.RID << 3;
switch (token.TokenType)
{
case TokenType.TypeDef:
return ret | 0;
case TokenType.TypeRef:
return ret | 1;
case TokenType.ModuleRef:
return ret | 2;
case TokenType.Method:
return ret | 3;
case TokenType.TypeSpec:
return ret | 4;
default:
goto exit;
}
case CodedIndex.HasSemantics:
ret = token.RID << 1;
switch (token.TokenType)
{
case TokenType.Event:
return ret | 0;
case TokenType.Property:
return ret | 1;
default:
goto exit;
}
case CodedIndex.MethodDefOrRef:
ret = token.RID << 1;
switch (token.TokenType)
{
case TokenType.Method:
return ret | 0;
case TokenType.MemberRef:
return ret | 1;
default:
goto exit;
}
case CodedIndex.MemberForwarded:
ret = token.RID << 1;
switch (token.TokenType)
{
case TokenType.Field:
return ret | 0;
case TokenType.Method:
return ret | 1;
default:
goto exit;
}
case CodedIndex.Implementation:
ret = token.RID << 2;
switch (token.TokenType)
{
case TokenType.File:
return ret | 0;
case TokenType.AssemblyRef:
return ret | 1;
case TokenType.ExportedType:
return ret | 2;
default:
goto exit;
}
case CodedIndex.CustomAttributeType:
ret = token.RID << 3;
switch (token.TokenType)
{
case TokenType.Method:
return ret | 2;
case TokenType.MemberRef:
return ret | 3;
default:
goto exit;
}
case CodedIndex.ResolutionScope:
ret = token.RID << 2;
switch (token.TokenType)
{
case TokenType.Module:
return ret | 0;
case TokenType.ModuleRef:
return ret | 1;
case TokenType.AssemblyRef:
return ret | 2;
case TokenType.TypeRef:
return ret | 3;
default:
goto exit;
}
case CodedIndex.TypeOrMethodDef:
ret = token.RID << 1;
switch (token.TokenType)
{
case TokenType.TypeDef:
return ret | 0;
case TokenType.Method:
return ret | 1;
default:
goto exit;
}
case CodedIndex.HasCustomDebugInformation:
ret = token.RID << 5;
switch (token.TokenType)
{
case TokenType.Method:
return ret | 0;
case TokenType.Field:
return ret | 1;
case TokenType.TypeRef:
return ret | 2;
case TokenType.TypeDef:
return ret | 3;
case TokenType.Param:
return ret | 4;
case TokenType.InterfaceImpl:
return ret | 5;
case TokenType.MemberRef:
return ret | 6;
case TokenType.Module:
return ret | 7;
case TokenType.Permission:
return ret | 8;
case TokenType.Property:
return ret | 9;
case TokenType.Event:
return ret | 10;
case TokenType.Signature:
return ret | 11;
case TokenType.ModuleRef:
return ret | 12;
case TokenType.TypeSpec:
return ret | 13;
case TokenType.Assembly:
return ret | 14;
case TokenType.AssemblyRef:
return ret | 15;
case TokenType.File:
return ret | 16;
case TokenType.ExportedType:
return ret | 17;
case TokenType.ManifestResource:
return ret | 18;
case TokenType.GenericParam:
return ret | 19;
case TokenType.GenericParamConstraint:
return ret | 20;
case TokenType.MethodSpec:
return ret | 21;
case TokenType.Document:
return ret | 22;
case TokenType.LocalScope:
return ret | 23;
case TokenType.LocalVariable:
return ret | 24;
case TokenType.LocalConstant:
return ret | 25;
case TokenType.ImportScope:
return ret | 26;
default:
goto exit;
}
default:
goto exit;
}
exit:
throw new ArgumentException();
}
public static int GetSize(this CodedIndex self, Func<Table, int> counter)
{
int bits;
Table[] tables;
switch (self)
{
case CodedIndex.TypeDefOrRef:
bits = 2;
tables = new[] { Table.TypeDef, Table.TypeRef, Table.TypeSpec };
break;
case CodedIndex.HasConstant:
bits = 2;
tables = new[] { Table.Field, Table.Param, Table.Property };
break;
case CodedIndex.HasCustomAttribute:
bits = 5;
tables = new[]
{
Table.Method, Table.Field, Table.TypeRef, Table.TypeDef, Table.Param, Table.InterfaceImpl, Table.MemberRef,
Table.Module, Table.DeclSecurity, Table.Property, Table.Event, Table.StandAloneSig, Table.ModuleRef,
Table.TypeSpec, Table.Assembly, Table.AssemblyRef, Table.File, Table.ExportedType,
Table.ManifestResource, Table.GenericParam, Table.GenericParamConstraint, Table.MethodSpec
};
break;
case CodedIndex.HasFieldMarshal:
bits = 1;
tables = new[] { Table.Field, Table.Param };
break;
case CodedIndex.HasDeclSecurity:
bits = 2;
tables = new[] { Table.TypeDef, Table.Method, Table.Assembly };
break;
case CodedIndex.MemberRefParent:
bits = 3;
tables = new[] { Table.TypeDef, Table.TypeRef, Table.ModuleRef, Table.Method, Table.TypeSpec };
break;
case CodedIndex.HasSemantics:
bits = 1;
tables = new[] { Table.Event, Table.Property };
break;
case CodedIndex.MethodDefOrRef:
bits = 1;
tables = new[] { Table.Method, Table.MemberRef };
break;
case CodedIndex.MemberForwarded:
bits = 1;
tables = new[] { Table.Field, Table.Method };
break;
case CodedIndex.Implementation:
bits = 2;
tables = new[] { Table.File, Table.AssemblyRef, Table.ExportedType };
break;
case CodedIndex.CustomAttributeType:
bits = 3;
tables = new[] { Table.Method, Table.MemberRef };
break;
case CodedIndex.ResolutionScope:
bits = 2;
tables = new[] { Table.Module, Table.ModuleRef, Table.AssemblyRef, Table.TypeRef };
break;
case CodedIndex.TypeOrMethodDef:
bits = 1;
tables = new[] { Table.TypeDef, Table.Method };
break;
case CodedIndex.HasCustomDebugInformation:
bits = 5;
tables = new[]
{
Table.Method, Table.Field, Table.TypeRef, Table.TypeDef, Table.Param, Table.InterfaceImpl, Table.MemberRef,
Table.Module, Table.DeclSecurity, Table.Property, Table.Event, Table.StandAloneSig, Table.ModuleRef,
Table.TypeSpec, Table.Assembly, Table.AssemblyRef, Table.File, Table.ExportedType,
Table.ManifestResource, Table.GenericParam, Table.GenericParamConstraint, Table.MethodSpec,
Table.Document, Table.LocalScope, Table.LocalVariable, Table.LocalConstant, Table.ImportScope
};
break;
default:
throw new ArgumentException();
}
int max = 0;
for (int i = 0; i < tables.Length; i++)
{
max = Math.Max(counter(tables[i]), max);
}
return max < 1 << (16 - bits) ? 2 : 4;
}
}
}
@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 4785957c0c546de4680e1196a57f66d2
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 207815
packageName: 'FishNet: Networking Evolved'
packageVersion: 4.6.22R
assetPath: Assets/FishNet/CodeGenerating/cecil-0.11.4/Mono.Cecil.Metadata/Utilities.cs
uploadId: 866910
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: a1a250fa69b80b34c9ca9b9086296b97
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,50 @@
//
// Author:
// Jb Evain (jbevain@gmail.com)
//
// Copyright (c) 2008 - 2015 Jb Evain
// Copyright (c) 2008 - 2011 Novell, Inc.
//
// Licensed under the MIT/X11 license.
//
using System.IO;
namespace MonoFN.Cecil.PE
{
internal class BinaryStreamReader : BinaryReader
{
public int Position
{
get { return (int)BaseStream.Position; }
set { BaseStream.Position = value; }
}
public int Length
{
get { return (int)BaseStream.Length; }
}
public BinaryStreamReader(Stream stream) : base(stream) { }
public void Advance(int bytes)
{
BaseStream.Seek(bytes, SeekOrigin.Current);
}
public void MoveTo(uint position)
{
BaseStream.Seek(position, SeekOrigin.Begin);
}
public void Align(int align)
{
align--;
int position = Position;
Advance(((position + align) & ~align) - position);
}
public DataDirectory ReadDataDirectory()
{
return new(ReadUInt32(), ReadUInt32());
}
}
}
@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 7492ed3a048237443b99d7a25e806ce6
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 207815
packageName: 'FishNet: Networking Evolved'
packageVersion: 4.6.22R
assetPath: Assets/FishNet/CodeGenerating/cecil-0.11.4/Mono.Cecil.PE/BinaryStreamReader.cs
uploadId: 866910
@@ -0,0 +1,85 @@
//
// Author:
// Jb Evain (jbevain@gmail.com)
//
// Copyright (c) 2008 - 2015 Jb Evain
// Copyright (c) 2008 - 2011 Novell, Inc.
//
// Licensed under the MIT/X11 license.
//
using System.IO;
namespace MonoFN.Cecil.PE
{
internal class BinaryStreamWriter : BinaryWriter
{
public int Position
{
get { return (int)BaseStream.Position; }
set { BaseStream.Position = value; }
}
public BinaryStreamWriter(Stream stream) : base(stream) { }
public void WriteByte(byte value)
{
Write(value);
}
public void WriteUInt16(ushort value)
{
Write(value);
}
public void WriteInt16(short value)
{
Write(value);
}
public void WriteUInt32(uint value)
{
Write(value);
}
public void WriteInt32(int value)
{
Write(value);
}
public void WriteUInt64(ulong value)
{
Write(value);
}
public void WriteBytes(byte[] bytes)
{
Write(bytes);
}
public void WriteDataDirectory(DataDirectory directory)
{
Write(directory.VirtualAddress);
Write(directory.Size);
}
public void WriteBuffer(ByteBuffer buffer)
{
Write(buffer.buffer, 0, buffer.length);
}
protected void Advance(int bytes)
{
BaseStream.Seek(bytes, SeekOrigin.Current);
}
public void Align(int align)
{
align--;
int position = Position;
int bytes = ((position + align) & ~align) - position;
for (int i = 0; i < bytes; i++)
WriteByte(0);
}
}
}
@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 26d384e0dd0e44549a9faf09adbd0a41
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 207815
packageName: 'FishNet: Networking Evolved'
packageVersion: 4.6.22R
assetPath: Assets/FishNet/CodeGenerating/cecil-0.11.4/Mono.Cecil.PE/BinaryStreamWriter.cs
uploadId: 866910
@@ -0,0 +1,336 @@
//
// Author:
// Jb Evain (jbevain@gmail.com)
//
// Copyright (c) 2008 - 2015 Jb Evain
// Copyright (c) 2008 - 2011 Novell, Inc.
//
// Licensed under the MIT/X11 license.
//
using System;
namespace MonoFN.Cecil.PE
{
internal class ByteBuffer
{
internal byte[] buffer;
internal int length;
internal int position;
public ByteBuffer()
{
buffer = Empty<byte>.Array;
}
public ByteBuffer(int length)
{
buffer = new byte [length];
}
public ByteBuffer(byte[] buffer)
{
this.buffer = buffer ?? Empty<byte>.Array;
length = this.buffer.Length;
}
public void Advance(int length)
{
position += length;
}
public byte ReadByte()
{
return buffer[position++];
}
public sbyte ReadSByte()
{
return (sbyte)ReadByte();
}
public byte[] ReadBytes(int length)
{
byte[] bytes = new byte [length];
Buffer.BlockCopy(buffer, position, bytes, 0, length);
position += length;
return bytes;
}
public ushort ReadUInt16()
{
ushort value = (ushort)(buffer[position] | (buffer[position + 1] << 8));
position += 2;
return value;
}
public short ReadInt16()
{
return (short)ReadUInt16();
}
public uint ReadUInt32()
{
uint value = (uint)(buffer[position] | (buffer[position + 1] << 8) | (buffer[position + 2] << 16) | (buffer[position + 3] << 24));
position += 4;
return value;
}
public int ReadInt32()
{
return (int)ReadUInt32();
}
public ulong ReadUInt64()
{
uint low = ReadUInt32();
uint high = ReadUInt32();
return ((ulong)high << 32) | low;
}
public long ReadInt64()
{
return (long)ReadUInt64();
}
public uint ReadCompressedUInt32()
{
byte first = ReadByte();
if ((first & 0x80) == 0)
return first;
if ((first & 0x40) == 0)
return ((uint)(first & ~0x80) << 8) | ReadByte();
return ((uint)(first & ~0xc0) << 24) | ((uint)ReadByte() << 16) | ((uint)ReadByte() << 8) | ReadByte();
}
public int ReadCompressedInt32()
{
byte b = buffer[position];
int u = (int)ReadCompressedUInt32();
int v = u >> 1;
if ((u & 1) == 0)
return v;
switch (b & 0xc0)
{
case 0:
case 0x40:
return v - 0x40;
case 0x80:
return v - 0x2000;
default:
return v - 0x10000000;
}
}
public float ReadSingle()
{
if (!BitConverter.IsLittleEndian)
{
byte[] bytes = ReadBytes(4);
Array.Reverse(bytes);
return BitConverter.ToSingle(bytes, 0);
}
float value = BitConverter.ToSingle(buffer, position);
position += 4;
return value;
}
public double ReadDouble()
{
if (!BitConverter.IsLittleEndian)
{
byte[] bytes = ReadBytes(8);
Array.Reverse(bytes);
return BitConverter.ToDouble(bytes, 0);
}
double value = BitConverter.ToDouble(buffer, position);
position += 8;
return value;
}
public void WriteByte(byte value)
{
if (position == buffer.Length)
Grow(1);
buffer[position++] = value;
if (position > length)
length = position;
}
public void WriteSByte(sbyte value)
{
WriteByte((byte)value);
}
public void WriteUInt16(ushort value)
{
if (position + 2 > buffer.Length)
Grow(2);
buffer[position++] = (byte)value;
buffer[position++] = (byte)(value >> 8);
if (position > length)
length = position;
}
public void WriteInt16(short value)
{
WriteUInt16((ushort)value);
}
public void WriteUInt32(uint value)
{
if (position + 4 > buffer.Length)
Grow(4);
buffer[position++] = (byte)value;
buffer[position++] = (byte)(value >> 8);
buffer[position++] = (byte)(value >> 16);
buffer[position++] = (byte)(value >> 24);
if (position > length)
length = position;
}
public void WriteInt32(int value)
{
WriteUInt32((uint)value);
}
public void WriteUInt64(ulong value)
{
if (position + 8 > buffer.Length)
Grow(8);
buffer[position++] = (byte)value;
buffer[position++] = (byte)(value >> 8);
buffer[position++] = (byte)(value >> 16);
buffer[position++] = (byte)(value >> 24);
buffer[position++] = (byte)(value >> 32);
buffer[position++] = (byte)(value >> 40);
buffer[position++] = (byte)(value >> 48);
buffer[position++] = (byte)(value >> 56);
if (position > length)
length = position;
}
public void WriteInt64(long value)
{
WriteUInt64((ulong)value);
}
public void WriteCompressedUInt32(uint value)
{
if (value < 0x80)
{
WriteByte((byte)value);
}
else if (value < 0x4000)
{
WriteByte((byte)(0x80 | (value >> 8)));
WriteByte((byte)(value & 0xff));
}
else
{
WriteByte((byte)((value >> 24) | 0xc0));
WriteByte((byte)((value >> 16) & 0xff));
WriteByte((byte)((value >> 8) & 0xff));
WriteByte((byte)(value & 0xff));
}
}
public void WriteCompressedInt32(int value)
{
if (value >= 0)
{
WriteCompressedUInt32((uint)(value << 1));
return;
}
if (value > -0x40)
value = 0x40 + value;
else if (value >= -0x2000)
value = 0x2000 + value;
else if (value >= -0x20000000)
value = 0x20000000 + value;
WriteCompressedUInt32((uint)((value << 1) | 1));
}
public void WriteBytes(byte[] bytes)
{
int length = bytes.Length;
if (position + length > buffer.Length)
Grow(length);
Buffer.BlockCopy(bytes, 0, buffer, position, length);
position += length;
if (position > this.length)
this.length = position;
}
public void WriteBytes(int length)
{
if (position + length > buffer.Length)
Grow(length);
position += length;
if (position > this.length)
this.length = position;
}
public void WriteBytes(ByteBuffer buffer)
{
if (position + buffer.length > this.buffer.Length)
Grow(buffer.length);
Buffer.BlockCopy(buffer.buffer, 0, this.buffer, position, buffer.length);
position += buffer.length;
if (position > length)
length = position;
}
public void WriteSingle(float value)
{
byte[] bytes = BitConverter.GetBytes(value);
if (!BitConverter.IsLittleEndian)
Array.Reverse(bytes);
WriteBytes(bytes);
}
public void WriteDouble(double value)
{
byte[] bytes = BitConverter.GetBytes(value);
if (!BitConverter.IsLittleEndian)
Array.Reverse(bytes);
WriteBytes(bytes);
}
private void Grow(int desired)
{
byte[] current = this.buffer;
int current_length = current.Length;
byte[] buffer = new byte [Math.Max(current_length + desired, current_length * 2)];
Buffer.BlockCopy(current, 0, buffer, 0, current_length);
this.buffer = buffer;
}
}
}
@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 3752816249ea16e4aba70adb03f01673
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 207815
packageName: 'FishNet: Networking Evolved'
packageVersion: 4.6.22R
assetPath: Assets/FishNet/CodeGenerating/cecil-0.11.4/Mono.Cecil.PE/ByteBuffer.cs
uploadId: 866910
@@ -0,0 +1,47 @@
//
// Author:
// Jb Evain (jbevain@gmail.com)
//
// Copyright (c) 2008 - 2015 Jb Evain
// Copyright (c) 2008 - 2011 Novell, Inc.
//
// Licensed under the MIT/X11 license.
//
using System.Collections.Generic;
namespace MonoFN.Cecil.PE
{
internal sealed class ByteBufferEqualityComparer : IEqualityComparer<ByteBuffer>
{
public bool Equals(ByteBuffer x, ByteBuffer y)
{
if (x.length != y.length)
return false;
byte[] x_buffer = x.buffer;
byte[] y_buffer = y.buffer;
for (int i = 0; i < x.length; i++)
if (x_buffer[i] != y_buffer[i])
return false;
return true;
}
public int GetHashCode(ByteBuffer buffer)
{
// See http://en.wikipedia.org/wiki/Fowler%E2%80%93Noll%E2%80%93Vo_hash_function
const int fnv_offset_bias = unchecked((int)2166136261);
const int fnv_prime = 16777619;
int hash_code = fnv_offset_bias;
byte[] bytes = buffer.buffer;
for (int i = 0; i < buffer.length; i++)
hash_code = unchecked((hash_code ^ bytes[i]) * fnv_prime);
return hash_code;
}
}
}
@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 0db5f2f7f9a349d4d89e2329ffd563b2
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 207815
packageName: 'FishNet: Networking Evolved'
packageVersion: 4.6.22R
assetPath: Assets/FishNet/CodeGenerating/cecil-0.11.4/Mono.Cecil.PE/ByteBufferEqualityComparer.cs
uploadId: 866910
@@ -0,0 +1,30 @@
//
// Author:
// Jb Evain (jbevain@gmail.com)
//
// Copyright (c) 2008 - 2015 Jb Evain
// Copyright (c) 2008 - 2011 Novell, Inc.
//
// Licensed under the MIT/X11 license.
//
using RVA = System.UInt32;
namespace MonoFN.Cecil.PE
{
internal struct DataDirectory
{
public readonly RVA VirtualAddress;
public readonly uint Size;
public bool IsZero
{
get { return VirtualAddress == 0 && Size == 0; }
}
public DataDirectory(RVA rva, uint size)
{
VirtualAddress = rva;
Size = size;
}
}
}
@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 7cd272a7ff953734bbacab398dfc9fe8
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 207815
packageName: 'FishNet: Networking Evolved'
packageVersion: 4.6.22R
assetPath: Assets/FishNet/CodeGenerating/cecil-0.11.4/Mono.Cecil.PE/DataDirectory.cs
uploadId: 866910
@@ -0,0 +1,158 @@
//
// Author:
// Jb Evain (jbevain@gmail.com)
//
// Copyright (c) 2008 - 2015 Jb Evain
// Copyright (c) 2008 - 2011 Novell, Inc.
//
// Licensed under the MIT/X11 license.
//
using MonoFN.Cecil.Cil;
using MonoFN.Cecil.Metadata;
using System;
using System.IO;
using RVA = System.UInt32;
namespace MonoFN.Cecil.PE
{
internal sealed class Image : IDisposable
{
public Disposable<Stream> Stream;
public string FileName;
public ModuleKind Kind;
public uint Characteristics;
public string RuntimeVersion;
public TargetArchitecture Architecture;
public ModuleCharacteristics DllCharacteristics;
public ushort LinkerVersion;
public ushort SubSystemMajor;
public ushort SubSystemMinor;
public ImageDebugHeader DebugHeader;
public Section[] Sections;
public Section MetadataSection;
public uint EntryPointToken;
public uint Timestamp;
public ModuleAttributes Attributes;
public DataDirectory Win32Resources;
public DataDirectory Debug;
public DataDirectory Resources;
public DataDirectory StrongName;
public StringHeap StringHeap;
public BlobHeap BlobHeap;
public UserStringHeap UserStringHeap;
public GuidHeap GuidHeap;
public TableHeap TableHeap;
public PdbHeap PdbHeap;
private readonly int[] coded_index_sizes = new int [14];
private readonly Func<Table, int> counter;
public Image()
{
counter = GetTableLength;
}
public bool HasTable(Table table)
{
return GetTableLength(table) > 0;
}
public int GetTableLength(Table table)
{
return (int)TableHeap[table].Length;
}
public int GetTableIndexSize(Table table)
{
return GetTableLength(table) < 65536 ? 2 : 4;
}
public int GetCodedIndexSize(CodedIndex coded_index)
{
int index = (int)coded_index;
int size = coded_index_sizes[index];
if (size != 0)
return size;
return coded_index_sizes[index] = coded_index.GetSize(counter);
}
public uint ResolveVirtualAddress(RVA rva)
{
Section section = GetSectionAtVirtualAddress(rva);
if (section == null)
throw new ArgumentOutOfRangeException();
return ResolveVirtualAddressInSection(rva, section);
}
public uint ResolveVirtualAddressInSection(RVA rva, Section section)
{
return rva + section.PointerToRawData - section.VirtualAddress;
}
public Section GetSection(string name)
{
Section[] sections = Sections;
for (int i = 0; i < sections.Length; i++)
{
Section section = sections[i];
if (section.Name == name)
return section;
}
return null;
}
public Section GetSectionAtVirtualAddress(RVA rva)
{
Section[] sections = Sections;
for (int i = 0; i < sections.Length; i++)
{
Section section = sections[i];
if (rva >= section.VirtualAddress && rva < section.VirtualAddress + section.SizeOfRawData)
return section;
}
return null;
}
private BinaryStreamReader GetReaderAt(RVA rva)
{
Section section = GetSectionAtVirtualAddress(rva);
if (section == null)
return null;
BinaryStreamReader reader = new(Stream.value);
reader.MoveTo(ResolveVirtualAddressInSection(rva, section));
return reader;
}
public TRet GetReaderAt<TItem, TRet>(RVA rva, TItem item, Func<TItem, BinaryStreamReader, TRet> read) where TRet : class
{
long position = Stream.value.Position;
try
{
BinaryStreamReader reader = GetReaderAt(rva);
if (reader == null)
return null;
return read(item, reader);
}
finally
{
Stream.value.Position = position;
}
}
public bool HasDebugTables()
{
return HasTable(Table.Document) || HasTable(Table.MethodDebugInformation) || HasTable(Table.LocalScope) || HasTable(Table.LocalVariable) || HasTable(Table.LocalConstant) || HasTable(Table.StateMachineMethod) || HasTable(Table.CustomDebugInformation);
}
public void Dispose()
{
Stream.Dispose();
}
}
}
@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: be7f3ca6a9f5ad34db68702bd99778fd
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 207815
packageName: 'FishNet: Networking Evolved'
packageVersion: 4.6.22R
assetPath: Assets/FishNet/CodeGenerating/cecil-0.11.4/Mono.Cecil.PE/Image.cs
uploadId: 866910
@@ -0,0 +1,812 @@
//
// Author:
// Jb Evain (jbevain@gmail.com)
//
// Copyright (c) 2008 - 2015 Jb Evain
// Copyright (c) 2008 - 2011 Novell, Inc.
//
// Licensed under the MIT/X11 license.
//
using MonoFN.Cecil.Cil;
using MonoFN.Cecil.Metadata;
using System;
using System.IO;
namespace MonoFN.Cecil.PE
{
internal sealed class ImageReader : BinaryStreamReader
{
private readonly Image image;
private DataDirectory cli;
private DataDirectory metadata;
private uint table_heap_offset;
public ImageReader(Disposable<Stream> stream, string file_name) : base(stream.value)
{
image = new();
image.Stream = stream;
image.FileName = file_name;
}
private void MoveTo(DataDirectory directory)
{
BaseStream.Position = image.ResolveVirtualAddress(directory.VirtualAddress);
}
private void ReadImage()
{
if (BaseStream.Length < 128)
throw new BadImageFormatException();
// - DOSHeader
// PE 2
// Start 58
// Lfanew 4
// End 64
if (ReadUInt16() != 0x5a4d)
throw new BadImageFormatException();
Advance(58);
MoveTo(ReadUInt32());
if (ReadUInt32() != 0x00004550)
throw new BadImageFormatException();
// - PEFileHeader
// Machine 2
image.Architecture = ReadArchitecture();
// NumberOfSections 2
ushort sections = ReadUInt16();
// TimeDateStamp 4
image.Timestamp = ReadUInt32();
// PointerToSymbolTable 4
// NumberOfSymbols 4
// OptionalHeaderSize 2
Advance(10);
// Characteristics 2
ushort characteristics = ReadUInt16();
ushort subsystem, dll_characteristics;
ReadOptionalHeaders(out subsystem, out dll_characteristics);
ReadSections(sections);
ReadCLIHeader();
ReadMetadata();
ReadDebugHeader();
image.Characteristics = characteristics;
image.Kind = GetModuleKind(characteristics, subsystem);
image.DllCharacteristics = (ModuleCharacteristics)dll_characteristics;
}
private TargetArchitecture ReadArchitecture()
{
return (TargetArchitecture)ReadUInt16();
}
private static ModuleKind GetModuleKind(ushort characteristics, ushort subsystem)
{
if ((characteristics & 0x2000) != 0) // ImageCharacteristics.Dll
return ModuleKind.Dll;
if (subsystem == 0x2 || subsystem == 0x9) // SubSystem.WindowsGui || SubSystem.WindowsCeGui
return ModuleKind.Windows;
return ModuleKind.Console;
}
private void ReadOptionalHeaders(out ushort subsystem, out ushort dll_characteristics)
{
// - PEOptionalHeader
// - StandardFieldsHeader
// Magic 2
bool pe64 = ReadUInt16() == 0x20b;
// pe32 || pe64
image.LinkerVersion = ReadUInt16();
// CodeSize 4
// InitializedDataSize 4
// UninitializedDataSize4
// EntryPointRVA 4
// BaseOfCode 4
// BaseOfData 4 || 0
// - NTSpecificFieldsHeader
// ImageBase 4 || 8
// SectionAlignment 4
// FileAlignement 4
// OSMajor 2
// OSMinor 2
// UserMajor 2
// UserMinor 2
// SubSysMajor 2
// SubSysMinor 2
Advance(44);
image.SubSystemMajor = ReadUInt16();
image.SubSystemMinor = ReadUInt16();
// Reserved 4
// ImageSize 4
// HeaderSize 4
// FileChecksum 4
Advance(16);
// SubSystem 2
subsystem = ReadUInt16();
// DLLFlags 2
dll_characteristics = ReadUInt16();
// StackReserveSize 4 || 8
// StackCommitSize 4 || 8
// HeapReserveSize 4 || 8
// HeapCommitSize 4 || 8
// LoaderFlags 4
// NumberOfDataDir 4
// - DataDirectoriesHeader
// ExportTable 8
// ImportTable 8
Advance(pe64 ? 56 : 40);
// ResourceTable 8
image.Win32Resources = ReadDataDirectory();
// ExceptionTable 8
// CertificateTable 8
// BaseRelocationTable 8
Advance(24);
// Debug 8
image.Debug = ReadDataDirectory();
// Copyright 8
// GlobalPtr 8
// TLSTable 8
// LoadConfigTable 8
// BoundImport 8
// IAT 8
// DelayImportDescriptor8
Advance(56);
// CLIHeader 8
cli = ReadDataDirectory();
if (cli.IsZero)
throw new BadImageFormatException();
// Reserved 8
Advance(8);
}
private string ReadAlignedString(int length)
{
int read = 0;
char[] buffer = new char [length];
while (read < length)
{
byte current = ReadByte();
if (current == 0)
break;
buffer[read++] = (char)current;
}
Advance(-1 + ((read + 4) & ~3) - read);
return new(buffer, 0, read);
}
private string ReadZeroTerminatedString(int length)
{
int read = 0;
char[] buffer = new char [length];
byte[] bytes = ReadBytes(length);
while (read < length)
{
byte current = bytes[read];
if (current == 0)
break;
buffer[read++] = (char)current;
}
return new(buffer, 0, read);
}
private void ReadSections(ushort count)
{
Section[] sections = new Section [count];
for (int i = 0; i < count; i++)
{
Section section = new();
// Name
section.Name = ReadZeroTerminatedString(8);
// VirtualSize 4
Advance(4);
// VirtualAddress 4
section.VirtualAddress = ReadUInt32();
// SizeOfRawData 4
section.SizeOfRawData = ReadUInt32();
// PointerToRawData 4
section.PointerToRawData = ReadUInt32();
// PointerToRelocations 4
// PointerToLineNumbers 4
// NumberOfRelocations 2
// NumberOfLineNumbers 2
// Characteristics 4
Advance(16);
sections[i] = section;
}
image.Sections = sections;
}
private void ReadCLIHeader()
{
MoveTo(cli);
// - CLIHeader
// Cb 4
// MajorRuntimeVersion 2
// MinorRuntimeVersion 2
Advance(8);
// Metadata 8
metadata = ReadDataDirectory();
// Flags 4
image.Attributes = (ModuleAttributes)ReadUInt32();
// EntryPointToken 4
image.EntryPointToken = ReadUInt32();
// Resources 8
image.Resources = ReadDataDirectory();
// StrongNameSignature 8
image.StrongName = ReadDataDirectory();
// CodeManagerTable 8
// VTableFixups 8
// ExportAddressTableJumps 8
// ManagedNativeHeader 8
}
private void ReadMetadata()
{
MoveTo(metadata);
if (ReadUInt32() != 0x424a5342)
throw new BadImageFormatException();
// MajorVersion 2
// MinorVersion 2
// Reserved 4
Advance(8);
image.RuntimeVersion = ReadZeroTerminatedString(ReadInt32());
// Flags 2
Advance(2);
ushort streams = ReadUInt16();
Section section = image.GetSectionAtVirtualAddress(metadata.VirtualAddress);
if (section == null)
throw new BadImageFormatException();
image.MetadataSection = section;
for (int i = 0; i < streams; i++)
ReadMetadataStream(section);
if (image.PdbHeap != null)
ReadPdbHeap();
if (image.TableHeap != null)
ReadTableHeap();
}
private void ReadDebugHeader()
{
if (image.Debug.IsZero)
{
image.DebugHeader = new(Empty<ImageDebugHeaderEntry>.Array);
return;
}
MoveTo(image.Debug);
ImageDebugHeaderEntry[] entries = new ImageDebugHeaderEntry [(int)image.Debug.Size / ImageDebugDirectory.Size];
for (int i = 0; i < entries.Length; i++)
{
ImageDebugDirectory directory = new()
{
Characteristics = ReadInt32(),
TimeDateStamp = ReadInt32(),
MajorVersion = ReadInt16(),
MinorVersion = ReadInt16(),
Type = (ImageDebugType)ReadInt32(),
SizeOfData = ReadInt32(),
AddressOfRawData = ReadInt32(),
PointerToRawData = ReadInt32()
};
if (directory.PointerToRawData == 0 || directory.SizeOfData < 0)
{
entries[i] = new(directory, Empty<byte>.Array);
continue;
}
int position = Position;
try
{
MoveTo((uint)directory.PointerToRawData);
byte[] data = ReadBytes(directory.SizeOfData);
entries[i] = new(directory, data);
}
finally
{
Position = position;
}
}
image.DebugHeader = new(entries);
}
private void ReadMetadataStream(Section section)
{
// Offset 4
uint offset = metadata.VirtualAddress - section.VirtualAddress + ReadUInt32(); // relative to the section start
// Size 4
uint size = ReadUInt32();
byte[] data = ReadHeapData(offset, size);
string name = ReadAlignedString(16);
switch (name)
{
case "#~":
case "#-":
image.TableHeap = new(data);
table_heap_offset = offset;
break;
case "#Strings":
image.StringHeap = new(data);
break;
case "#Blob":
image.BlobHeap = new(data);
break;
case "#GUID":
image.GuidHeap = new(data);
break;
case "#US":
image.UserStringHeap = new(data);
break;
case "#Pdb":
image.PdbHeap = new(data);
break;
}
}
private byte[] ReadHeapData(uint offset, uint size)
{
long position = BaseStream.Position;
MoveTo(offset + image.MetadataSection.PointerToRawData);
byte[] data = ReadBytes((int)size);
BaseStream.Position = position;
return data;
}
private void ReadTableHeap()
{
TableHeap heap = image.TableHeap;
MoveTo(table_heap_offset + image.MetadataSection.PointerToRawData);
// Reserved 4
// MajorVersion 1
// MinorVersion 1
Advance(6);
// HeapSizes 1
byte sizes = ReadByte();
// Reserved2 1
Advance(1);
// Valid 8
heap.Valid = ReadInt64();
// Sorted 8
heap.Sorted = ReadInt64();
if (image.PdbHeap != null)
{
for (int i = 0; i < Mixin.TableCount; i++)
{
if (!image.PdbHeap.HasTable((Table)i))
continue;
heap.Tables[i].Length = image.PdbHeap.TypeSystemTableRows[i];
}
}
for (int i = 0; i < Mixin.TableCount; i++)
{
if (!heap.HasTable((Table)i))
continue;
heap.Tables[i].Length = ReadUInt32();
}
SetIndexSize(image.StringHeap, sizes, 0x1);
SetIndexSize(image.GuidHeap, sizes, 0x2);
SetIndexSize(image.BlobHeap, sizes, 0x4);
ComputeTableInformations();
}
private static void SetIndexSize(Heap heap, uint sizes, byte flag)
{
if (heap == null)
return;
heap.IndexSize = (sizes & flag) > 0 ? 4 : 2;
}
private int GetTableIndexSize(Table table)
{
return image.GetTableIndexSize(table);
}
private int GetCodedIndexSize(CodedIndex index)
{
return image.GetCodedIndexSize(index);
}
private void ComputeTableInformations()
{
uint offset = (uint)BaseStream.Position - table_heap_offset - image.MetadataSection.PointerToRawData; // header
int stridx_size = image.StringHeap != null ? image.StringHeap.IndexSize : 2;
int guididx_size = image.GuidHeap != null ? image.GuidHeap.IndexSize : 2;
int blobidx_size = image.BlobHeap != null ? image.BlobHeap.IndexSize : 2;
TableHeap heap = image.TableHeap;
TableInformation[] tables = heap.Tables;
for (int i = 0; i < Mixin.TableCount; i++)
{
Table table = (Table)i;
if (!heap.HasTable(table))
continue;
int size;
switch (table)
{
case Table.Module:
size = 2 // Generation
+ stridx_size // Name
+ guididx_size * 3; // Mvid, EncId, EncBaseId
break;
case Table.TypeRef:
size = GetCodedIndexSize(CodedIndex.ResolutionScope) // ResolutionScope
+ stridx_size * 2; // Name, Namespace
break;
case Table.TypeDef:
size = 4 // Flags
+ stridx_size * 2 // Name, Namespace
+ GetCodedIndexSize(CodedIndex.TypeDefOrRef) // BaseType
+ GetTableIndexSize(Table.Field) // FieldList
+ GetTableIndexSize(Table.Method); // MethodList
break;
case Table.FieldPtr:
size = GetTableIndexSize(Table.Field); // Field
break;
case Table.Field:
size = 2 // Flags
+ stridx_size // Name
+ blobidx_size; // Signature
break;
case Table.MethodPtr:
size = GetTableIndexSize(Table.Method); // Method
break;
case Table.Method:
size = 8 // Rva 4, ImplFlags 2, Flags 2
+ stridx_size // Name
+ blobidx_size // Signature
+ GetTableIndexSize(Table.Param); // ParamList
break;
case Table.ParamPtr:
size = GetTableIndexSize(Table.Param); // Param
break;
case Table.Param:
size = 4 // Flags 2, Sequence 2
+ stridx_size; // Name
break;
case Table.InterfaceImpl:
size = GetTableIndexSize(Table.TypeDef) // Class
+ GetCodedIndexSize(CodedIndex.TypeDefOrRef); // Interface
break;
case Table.MemberRef:
size = GetCodedIndexSize(CodedIndex.MemberRefParent) // Class
+ stridx_size // Name
+ blobidx_size; // Signature
break;
case Table.Constant:
size = 2 // Type
+ GetCodedIndexSize(CodedIndex.HasConstant) // Parent
+ blobidx_size; // Value
break;
case Table.CustomAttribute:
size = GetCodedIndexSize(CodedIndex.HasCustomAttribute) // Parent
+ GetCodedIndexSize(CodedIndex.CustomAttributeType) // Type
+ blobidx_size; // Value
break;
case Table.FieldMarshal:
size = GetCodedIndexSize(CodedIndex.HasFieldMarshal) // Parent
+ blobidx_size; // NativeType
break;
case Table.DeclSecurity:
size = 2 // Action
+ GetCodedIndexSize(CodedIndex.HasDeclSecurity) // Parent
+ blobidx_size; // PermissionSet
break;
case Table.ClassLayout:
size = 6 // PackingSize 2, ClassSize 4
+ GetTableIndexSize(Table.TypeDef); // Parent
break;
case Table.FieldLayout:
size = 4 // Offset
+ GetTableIndexSize(Table.Field); // Field
break;
case Table.StandAloneSig:
size = blobidx_size; // Signature
break;
case Table.EventMap:
size = GetTableIndexSize(Table.TypeDef) // Parent
+ GetTableIndexSize(Table.Event); // EventList
break;
case Table.EventPtr:
size = GetTableIndexSize(Table.Event); // Event
break;
case Table.Event:
size = 2 // Flags
+ stridx_size // Name
+ GetCodedIndexSize(CodedIndex.TypeDefOrRef); // EventType
break;
case Table.PropertyMap:
size = GetTableIndexSize(Table.TypeDef) // Parent
+ GetTableIndexSize(Table.Property); // PropertyList
break;
case Table.PropertyPtr:
size = GetTableIndexSize(Table.Property); // Property
break;
case Table.Property:
size = 2 // Flags
+ stridx_size // Name
+ blobidx_size; // Type
break;
case Table.MethodSemantics:
size = 2 // Semantics
+ GetTableIndexSize(Table.Method) // Method
+ GetCodedIndexSize(CodedIndex.HasSemantics); // Association
break;
case Table.MethodImpl:
size = GetTableIndexSize(Table.TypeDef) // Class
+ GetCodedIndexSize(CodedIndex.MethodDefOrRef) // MethodBody
+ GetCodedIndexSize(CodedIndex.MethodDefOrRef); // MethodDeclaration
break;
case Table.ModuleRef:
size = stridx_size; // Name
break;
case Table.TypeSpec:
size = blobidx_size; // Signature
break;
case Table.ImplMap:
size = 2 // MappingFlags
+ GetCodedIndexSize(CodedIndex.MemberForwarded) // MemberForwarded
+ stridx_size // ImportName
+ GetTableIndexSize(Table.ModuleRef); // ImportScope
break;
case Table.FieldRVA:
size = 4 // RVA
+ GetTableIndexSize(Table.Field); // Field
break;
case Table.EncLog:
size = 8;
break;
case Table.EncMap:
size = 4;
break;
case Table.Assembly:
size = 16 // HashAlgId 4, Version 4 * 2, Flags 4
+ blobidx_size // PublicKey
+ stridx_size * 2; // Name, Culture
break;
case Table.AssemblyProcessor:
size = 4; // Processor
break;
case Table.AssemblyOS:
size = 12; // Platform 4, Version 2 * 4
break;
case Table.AssemblyRef:
size = 12 // Version 2 * 4 + Flags 4
+ blobidx_size * 2 // PublicKeyOrToken, HashValue
+ stridx_size * 2; // Name, Culture
break;
case Table.AssemblyRefProcessor:
size = 4 // Processor
+ GetTableIndexSize(Table.AssemblyRef); // AssemblyRef
break;
case Table.AssemblyRefOS:
size = 12 // Platform 4, Version 2 * 4
+ GetTableIndexSize(Table.AssemblyRef); // AssemblyRef
break;
case Table.File:
size = 4 // Flags
+ stridx_size // Name
+ blobidx_size; // HashValue
break;
case Table.ExportedType:
size = 8 // Flags 4, TypeDefId 4
+ stridx_size * 2 // Name, Namespace
+ GetCodedIndexSize(CodedIndex.Implementation); // Implementation
break;
case Table.ManifestResource:
size = 8 // Offset, Flags
+ stridx_size // Name
+ GetCodedIndexSize(CodedIndex.Implementation); // Implementation
break;
case Table.NestedClass:
size = GetTableIndexSize(Table.TypeDef) // NestedClass
+ GetTableIndexSize(Table.TypeDef); // EnclosingClass
break;
case Table.GenericParam:
size = 4 // Number, Flags
+ GetCodedIndexSize(CodedIndex.TypeOrMethodDef) // Owner
+ stridx_size; // Name
break;
case Table.MethodSpec:
size = GetCodedIndexSize(CodedIndex.MethodDefOrRef) // Method
+ blobidx_size; // Instantiation
break;
case Table.GenericParamConstraint:
size = GetTableIndexSize(Table.GenericParam) // Owner
+ GetCodedIndexSize(CodedIndex.TypeDefOrRef); // Constraint
break;
case Table.Document:
size = blobidx_size // Name
+ guididx_size // HashAlgorithm
+ blobidx_size // Hash
+ guididx_size; // Language
break;
case Table.MethodDebugInformation:
size = GetTableIndexSize(Table.Document) // Document
+ blobidx_size; // SequencePoints
break;
case Table.LocalScope:
size = GetTableIndexSize(Table.Method) // Method
+ GetTableIndexSize(Table.ImportScope) // ImportScope
+ GetTableIndexSize(Table.LocalVariable) // VariableList
+ GetTableIndexSize(Table.LocalConstant) // ConstantList
+ 4 * 2; // StartOffset, Length
break;
case Table.LocalVariable:
size = 2 // Attributes
+ 2 // Index
+ stridx_size; // Name
break;
case Table.LocalConstant:
size = stridx_size // Name
+ blobidx_size; // Signature
break;
case Table.ImportScope:
size = GetTableIndexSize(Table.ImportScope) // Parent
+ blobidx_size;
break;
case Table.StateMachineMethod:
size = GetTableIndexSize(Table.Method) // MoveNextMethod
+ GetTableIndexSize(Table.Method); // KickOffMethod
break;
case Table.CustomDebugInformation:
size = GetCodedIndexSize(CodedIndex.HasCustomDebugInformation) // Parent
+ guididx_size // Kind
+ blobidx_size; // Value
break;
default:
throw new NotSupportedException();
}
tables[i].RowSize = (uint)size;
tables[i].Offset = offset;
offset += (uint)size * tables[i].Length;
}
}
private void ReadPdbHeap()
{
PdbHeap heap = image.PdbHeap;
ByteBuffer buffer = new(heap.data);
heap.Id = buffer.ReadBytes(20);
heap.EntryPoint = buffer.ReadUInt32();
heap.TypeSystemTables = buffer.ReadInt64();
heap.TypeSystemTableRows = new uint [Mixin.TableCount];
for (int i = 0; i < Mixin.TableCount; i++)
{
Table table = (Table)i;
if (!heap.HasTable(table))
continue;
heap.TypeSystemTableRows[i] = buffer.ReadUInt32();
}
}
public static Image ReadImage(Disposable<Stream> stream, string file_name)
{
try
{
ImageReader reader = new(stream, file_name);
reader.ReadImage();
return reader.image;
}
catch (EndOfStreamException e)
{
throw new BadImageFormatException(stream.value.GetFileName(), e);
}
}
public static Image ReadPortablePdb(Disposable<Stream> stream, string file_name)
{
try
{
ImageReader reader = new(stream, file_name);
uint length = (uint)stream.value.Length;
reader.image.Sections = new[]
{
new Section
{
PointerToRawData = 0,
SizeOfRawData = length,
VirtualAddress = 0,
VirtualSize = length
}
};
reader.metadata = new(0, length);
reader.ReadMetadata();
return reader.image;
}
catch (EndOfStreamException e)
{
throw new BadImageFormatException(stream.value.GetFileName(), e);
}
}
}
}
@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: ba04d4e3389423e47b35aaccee205576
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 207815
packageName: 'FishNet: Networking Evolved'
packageVersion: 4.6.22R
assetPath: Assets/FishNet/CodeGenerating/cecil-0.11.4/Mono.Cecil.PE/ImageReader.cs
uploadId: 866910
@@ -0,0 +1,874 @@
//
// Author:
// Jb Evain (jbevain@gmail.com)
//
// Copyright (c) 2008 - 2015 Jb Evain
// Copyright (c) 2008 - 2011 Novell, Inc.
//
// Licensed under the MIT/X11 license.
//
using MonoFN.Cecil.Cil;
using MonoFN.Cecil.Metadata;
using System;
using System.IO;
using RVA = System.UInt32;
namespace MonoFN.Cecil.PE
{
internal sealed class ImageWriter : BinaryStreamWriter
{
private readonly ModuleDefinition module;
private readonly MetadataBuilder metadata;
private readonly TextMap text_map;
internal readonly Disposable<Stream> stream;
private readonly string runtime_version;
private ImageDebugHeader debug_header;
private ByteBuffer win32_resources;
private const uint pe_header_size = 0x98u;
private const uint section_header_size = 0x28u;
private const uint file_alignment = 0x200;
private const uint section_alignment = 0x2000;
private const ulong image_base = 0x00400000;
internal const RVA text_rva = 0x2000;
private readonly bool pe64;
private readonly bool has_reloc;
internal Section text;
internal Section rsrc;
internal Section reloc;
private ushort sections;
private ImageWriter(ModuleDefinition module, string runtime_version, MetadataBuilder metadata, Disposable<Stream> stream, bool metadataOnly = false) : base(stream.value)
{
this.module = module;
this.runtime_version = runtime_version;
text_map = metadata.text_map;
this.stream = stream;
this.metadata = metadata;
if (metadataOnly)
return;
pe64 = module.Architecture == TargetArchitecture.AMD64 || module.Architecture == TargetArchitecture.IA64 || module.Architecture == TargetArchitecture.ARM64;
has_reloc = module.Architecture == TargetArchitecture.I386;
GetDebugHeader();
GetWin32Resources();
BuildTextMap();
sections = (ushort)(has_reloc ? 2 : 1); // text + reloc?
}
private void GetDebugHeader()
{
ISymbolWriter symbol_writer = metadata.symbol_writer;
if (symbol_writer != null)
debug_header = symbol_writer.GetDebugHeader();
if (module.HasDebugHeader)
{
ImageDebugHeader header = module.GetDebugHeader();
ImageDebugHeaderEntry deterministic = header.GetDeterministicEntry();
if (deterministic == null)
return;
debug_header = debug_header.AddDeterministicEntry();
}
}
private void GetWin32Resources()
{
if (!module.HasImage)
return;
DataDirectory win32_resources_directory = module.Image.Win32Resources;
uint size = win32_resources_directory.Size;
if (size > 0)
{
win32_resources = module.Image.GetReaderAt(win32_resources_directory.VirtualAddress, size, (s, reader) => new ByteBuffer(reader.ReadBytes((int)s)));
}
}
public static ImageWriter CreateWriter(ModuleDefinition module, MetadataBuilder metadata, Disposable<Stream> stream)
{
ImageWriter writer = new(module, module.runtime_version, metadata, stream);
writer.BuildSections();
return writer;
}
public static ImageWriter CreateDebugWriter(ModuleDefinition module, MetadataBuilder metadata, Disposable<Stream> stream)
{
ImageWriter writer = new(module, "PDB v1.0", metadata, stream, metadataOnly: true);
uint length = metadata.text_map.GetLength();
writer.text = new() { SizeOfRawData = length, VirtualSize = length };
return writer;
}
private void BuildSections()
{
bool has_win32_resources = win32_resources != null;
if (has_win32_resources)
sections++;
text = CreateSection(".text", text_map.GetLength(), null);
Section previous = text;
if (has_win32_resources)
{
rsrc = CreateSection(".rsrc", (uint)win32_resources.length, previous);
PatchWin32Resources(win32_resources);
previous = rsrc;
}
if (has_reloc)
reloc = CreateSection(".reloc", 12u, previous);
}
private Section CreateSection(string name, uint size, Section previous)
{
return new()
{
Name = name,
VirtualAddress = previous != null ? previous.VirtualAddress + Align(previous.VirtualSize, section_alignment) : text_rva,
VirtualSize = size,
PointerToRawData = previous != null ? previous.PointerToRawData + previous.SizeOfRawData : Align(GetHeaderSize(), file_alignment),
SizeOfRawData = Align(size, file_alignment)
};
}
private static uint Align(uint value, uint align)
{
align--;
return (value + align) & ~align;
}
private void WriteDOSHeader()
{
Write(new byte[]
{
// dos header start
0x4d, 0x5a, 0x90, 0x00, 0x03, 0x00, 0x00,
0x00, 0x04, 0x00, 0x00, 0x00, 0xff, 0xff,
0x00, 0x00, 0xb8, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
// lfanew
0x80, 0x00, 0x00, 0x00,
// dos header end
0x0e, 0x1f, 0xba, 0x0e, 0x00, 0xb4, 0x09,
0xcd, 0x21, 0xb8, 0x01, 0x4c, 0xcd, 0x21,
0x54, 0x68, 0x69, 0x73, 0x20, 0x70, 0x72,
0x6f, 0x67, 0x72, 0x61, 0x6d, 0x20, 0x63,
0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x20, 0x62,
0x65, 0x20, 0x72, 0x75, 0x6e, 0x20, 0x69,
0x6e, 0x20, 0x44, 0x4f, 0x53, 0x20, 0x6d,
0x6f, 0x64, 0x65, 0x2e, 0x0d, 0x0d, 0x0a,
0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00
});
}
private ushort SizeOfOptionalHeader()
{
return (ushort)(!pe64 ? 0xe0 : 0xf0);
}
private void WritePEFileHeader()
{
WriteUInt32(0x00004550); // Magic
WriteUInt16((ushort)module.Architecture); // Machine
WriteUInt16(sections); // NumberOfSections
WriteUInt32(metadata.timestamp);
WriteUInt32(0); // PointerToSymbolTable
WriteUInt32(0); // NumberOfSymbols
WriteUInt16(SizeOfOptionalHeader()); // SizeOfOptionalHeader
const ushort LargeAddressAware = 0x0020;
// ExecutableImage | (!pe64 ? 32BitsMachine : LargeAddressAware)
ushort characteristics = (ushort)(0x0002 | (!pe64 ? 0x0100 : LargeAddressAware));
if (module.Kind == ModuleKind.Dll || module.Kind == ModuleKind.NetModule)
characteristics |= 0x2000;
if (module.Image != null && (module.Image.Characteristics & LargeAddressAware) != 0)
characteristics |= LargeAddressAware;
WriteUInt16(characteristics); // Characteristics
}
private Section LastSection()
{
if (reloc != null)
return reloc;
if (rsrc != null)
return rsrc;
return text;
}
private void WriteOptionalHeaders()
{
WriteUInt16((ushort)(!pe64 ? 0x10b : 0x20b)); // Magic
WriteUInt16(module.linker_version);
WriteUInt32(text.SizeOfRawData); // CodeSize
WriteUInt32((reloc != null ? reloc.SizeOfRawData : 0) + (rsrc != null ? rsrc.SizeOfRawData : 0)); // InitializedDataSize
WriteUInt32(0); // UninitializedDataSize
Range startub_stub = text_map.GetRange(TextSegment.StartupStub);
WriteUInt32(startub_stub.Length > 0 ? startub_stub.Start : 0); // EntryPointRVA
WriteUInt32(text_rva); // BaseOfCode
if (!pe64)
{
WriteUInt32(0); // BaseOfData
WriteUInt32((uint)image_base); // ImageBase
}
else
{
WriteUInt64(image_base); // ImageBase
}
WriteUInt32(section_alignment); // SectionAlignment
WriteUInt32(file_alignment); // FileAlignment
WriteUInt16(4); // OSMajor
WriteUInt16(0); // OSMinor
WriteUInt16(0); // UserMajor
WriteUInt16(0); // UserMinor
WriteUInt16(module.subsystem_major); // SubSysMajor
WriteUInt16(module.subsystem_minor); // SubSysMinor
WriteUInt32(0); // Reserved
Section last_section = LastSection();
WriteUInt32(last_section.VirtualAddress + Align(last_section.VirtualSize, section_alignment)); // ImageSize
WriteUInt32(text.PointerToRawData); // HeaderSize
WriteUInt32(0); // Checksum
WriteUInt16(GetSubSystem()); // SubSystem
WriteUInt16((ushort)module.Characteristics); // DLLFlags
if (!pe64)
{
const uint stack_reserve = 0x100000;
const uint stack_commit = 0x1000;
const uint heap_reserve = 0x100000;
const uint heap_commit = 0x1000;
WriteUInt32(stack_reserve);
WriteUInt32(stack_commit);
WriteUInt32(heap_reserve);
WriteUInt32(heap_commit);
}
else
{
const ulong stack_reserve = 0x400000;
const ulong stack_commit = 0x4000;
const ulong heap_reserve = 0x100000;
const ulong heap_commit = 0x2000;
WriteUInt64(stack_reserve);
WriteUInt64(stack_commit);
WriteUInt64(heap_reserve);
WriteUInt64(heap_commit);
}
WriteUInt32(0); // LoaderFlags
WriteUInt32(16); // NumberOfDataDir
WriteZeroDataDirectory(); // ExportTable
WriteDataDirectory(text_map.GetDataDirectory(TextSegment.ImportDirectory)); // ImportTable
if (rsrc != null)
{
// ResourceTable
WriteUInt32(rsrc.VirtualAddress);
WriteUInt32(rsrc.VirtualSize);
}
else
{
WriteZeroDataDirectory();
}
WriteZeroDataDirectory(); // ExceptionTable
WriteZeroDataDirectory(); // CertificateTable
WriteUInt32(reloc != null ? reloc.VirtualAddress : 0); // BaseRelocationTable
WriteUInt32(reloc != null ? reloc.VirtualSize : 0);
if (text_map.GetLength(TextSegment.DebugDirectory) > 0)
{
WriteUInt32(text_map.GetRVA(TextSegment.DebugDirectory));
WriteUInt32((uint)(debug_header.Entries.Length * ImageDebugDirectory.Size));
}
else
{
WriteZeroDataDirectory();
}
WriteZeroDataDirectory(); // Copyright
WriteZeroDataDirectory(); // GlobalPtr
WriteZeroDataDirectory(); // TLSTable
WriteZeroDataDirectory(); // LoadConfigTable
WriteZeroDataDirectory(); // BoundImport
WriteDataDirectory(text_map.GetDataDirectory(TextSegment.ImportAddressTable)); // IAT
WriteZeroDataDirectory(); // DelayImportDesc
WriteDataDirectory(text_map.GetDataDirectory(TextSegment.CLIHeader)); // CLIHeader
WriteZeroDataDirectory(); // Reserved
}
private void WriteZeroDataDirectory()
{
WriteUInt32(0);
WriteUInt32(0);
}
private ushort GetSubSystem()
{
switch (module.Kind)
{
case ModuleKind.Console:
case ModuleKind.Dll:
case ModuleKind.NetModule:
return 0x3;
case ModuleKind.Windows:
return 0x2;
default:
throw new ArgumentOutOfRangeException();
}
}
private void WriteSectionHeaders()
{
WriteSection(text, 0x60000020);
if (rsrc != null)
WriteSection(rsrc, 0x40000040);
if (reloc != null)
WriteSection(reloc, 0x42000040);
}
private void WriteSection(Section section, uint characteristics)
{
byte[] name = new byte [8];
string sect_name = section.Name;
for (int i = 0; i < sect_name.Length; i++)
name[i] = (byte)sect_name[i];
WriteBytes(name);
WriteUInt32(section.VirtualSize);
WriteUInt32(section.VirtualAddress);
WriteUInt32(section.SizeOfRawData);
WriteUInt32(section.PointerToRawData);
WriteUInt32(0); // PointerToRelocations
WriteUInt32(0); // PointerToLineNumbers
WriteUInt16(0); // NumberOfRelocations
WriteUInt16(0); // NumberOfLineNumbers
WriteUInt32(characteristics);
}
private uint GetRVAFileOffset(Section section, RVA rva)
{
return section.PointerToRawData + rva - section.VirtualAddress;
}
private void MoveTo(uint pointer)
{
BaseStream.Seek(pointer, SeekOrigin.Begin);
}
private void MoveToRVA(Section section, RVA rva)
{
BaseStream.Seek(GetRVAFileOffset(section, rva), SeekOrigin.Begin);
}
private void MoveToRVA(TextSegment segment)
{
MoveToRVA(text, text_map.GetRVA(segment));
}
private void WriteRVA(RVA rva)
{
if (!pe64)
WriteUInt32(rva);
else
WriteUInt64(rva);
}
private void PrepareSection(Section section)
{
MoveTo(section.PointerToRawData);
const int buffer_size = 4096;
if (section.SizeOfRawData <= buffer_size)
{
Write(new byte [section.SizeOfRawData]);
MoveTo(section.PointerToRawData);
return;
}
int written = 0;
byte[] buffer = new byte [buffer_size];
while (written != section.SizeOfRawData)
{
int write_size = Math.Min((int)section.SizeOfRawData - written, buffer_size);
Write(buffer, 0, write_size);
written += write_size;
}
MoveTo(section.PointerToRawData);
}
private void WriteText()
{
PrepareSection(text);
// ImportAddressTable
if (has_reloc)
{
WriteRVA(text_map.GetRVA(TextSegment.ImportHintNameTable));
WriteRVA(0);
}
// CLIHeader
WriteUInt32(0x48);
WriteUInt16(2);
WriteUInt16((ushort)(module.Runtime <= TargetRuntime.Net_1_1 ? 0 : 5));
WriteUInt32(text_map.GetRVA(TextSegment.MetadataHeader));
WriteUInt32(GetMetadataLength());
WriteUInt32((uint)module.Attributes);
WriteUInt32(metadata.entry_point.ToUInt32());
WriteDataDirectory(text_map.GetDataDirectory(TextSegment.Resources));
WriteDataDirectory(text_map.GetDataDirectory(TextSegment.StrongNameSignature));
WriteZeroDataDirectory(); // CodeManagerTable
WriteZeroDataDirectory(); // VTableFixups
WriteZeroDataDirectory(); // ExportAddressTableJumps
WriteZeroDataDirectory(); // ManagedNativeHeader
// Code
MoveToRVA(TextSegment.Code);
WriteBuffer(metadata.code);
// Resources
MoveToRVA(TextSegment.Resources);
WriteBuffer(metadata.resources);
// Data
if (metadata.data.length > 0)
{
MoveToRVA(TextSegment.Data);
WriteBuffer(metadata.data);
}
// StrongNameSignature
// stays blank
// MetadataHeader
MoveToRVA(TextSegment.MetadataHeader);
WriteMetadataHeader();
WriteMetadata();
// DebugDirectory
if (text_map.GetLength(TextSegment.DebugDirectory) > 0)
{
MoveToRVA(TextSegment.DebugDirectory);
WriteDebugDirectory();
}
if (!has_reloc)
return;
// ImportDirectory
MoveToRVA(TextSegment.ImportDirectory);
WriteImportDirectory();
// StartupStub
MoveToRVA(TextSegment.StartupStub);
WriteStartupStub();
}
private uint GetMetadataLength()
{
return text_map.GetRVA(TextSegment.DebugDirectory) - text_map.GetRVA(TextSegment.MetadataHeader);
}
public void WriteMetadataHeader()
{
WriteUInt32(0x424a5342); // Signature
WriteUInt16(1); // MajorVersion
WriteUInt16(1); // MinorVersion
WriteUInt32(0); // Reserved
byte[] version = GetZeroTerminatedString(runtime_version);
WriteUInt32((uint)version.Length);
WriteBytes(version);
WriteUInt16(0); // Flags
WriteUInt16(GetStreamCount());
uint offset = text_map.GetRVA(TextSegment.TableHeap) - text_map.GetRVA(TextSegment.MetadataHeader);
WriteStreamHeader(ref offset, TextSegment.TableHeap, "#~");
WriteStreamHeader(ref offset, TextSegment.StringHeap, "#Strings");
WriteStreamHeader(ref offset, TextSegment.UserStringHeap, "#US");
WriteStreamHeader(ref offset, TextSegment.GuidHeap, "#GUID");
WriteStreamHeader(ref offset, TextSegment.BlobHeap, "#Blob");
WriteStreamHeader(ref offset, TextSegment.PdbHeap, "#Pdb");
}
private ushort GetStreamCount()
{
return (ushort)(1 // #~
+ 1 // #Strings
+ (metadata.user_string_heap.IsEmpty ? 0 : 1) // #US
+ (metadata.guid_heap.IsEmpty ? 0 : 1) // GUID
+ (metadata.blob_heap.IsEmpty ? 0 : 1) + (metadata.pdb_heap == null ? 0 : 1)); // #Blob
}
private void WriteStreamHeader(ref uint offset, TextSegment heap, string name)
{
uint length = (uint)text_map.GetLength(heap);
if (length == 0)
return;
WriteUInt32(offset);
WriteUInt32(length);
WriteBytes(GetZeroTerminatedString(name));
offset += length;
}
private static int GetZeroTerminatedStringLength(string @string)
{
return (@string.Length + 1 + 3) & ~3;
}
private static byte[] GetZeroTerminatedString(string @string)
{
return GetString(@string, GetZeroTerminatedStringLength(@string));
}
private static byte[] GetSimpleString(string @string)
{
return GetString(@string, @string.Length);
}
private static byte[] GetString(string @string, int length)
{
byte[] bytes = new byte [length];
for (int i = 0; i < @string.Length; i++)
bytes[i] = (byte)@string[i];
return bytes;
}
public void WriteMetadata()
{
WriteHeap(TextSegment.TableHeap, metadata.table_heap);
WriteHeap(TextSegment.StringHeap, metadata.string_heap);
WriteHeap(TextSegment.UserStringHeap, metadata.user_string_heap);
WriteHeap(TextSegment.GuidHeap, metadata.guid_heap);
WriteHeap(TextSegment.BlobHeap, metadata.blob_heap);
WriteHeap(TextSegment.PdbHeap, metadata.pdb_heap);
}
private void WriteHeap(TextSegment heap, HeapBuffer buffer)
{
if (buffer == null || buffer.IsEmpty)
return;
MoveToRVA(heap);
WriteBuffer(buffer);
}
private void WriteDebugDirectory()
{
int data_start = (int)BaseStream.Position + debug_header.Entries.Length * ImageDebugDirectory.Size;
for (int i = 0; i < debug_header.Entries.Length; i++)
{
ImageDebugHeaderEntry entry = debug_header.Entries[i];
ImageDebugDirectory directory = entry.Directory;
WriteInt32(directory.Characteristics);
WriteInt32(directory.TimeDateStamp);
WriteInt16(directory.MajorVersion);
WriteInt16(directory.MinorVersion);
WriteInt32((int)directory.Type);
WriteInt32(directory.SizeOfData);
WriteInt32(directory.AddressOfRawData);
WriteInt32(data_start);
data_start += entry.Data.Length;
}
for (int i = 0; i < debug_header.Entries.Length; i++)
{
ImageDebugHeaderEntry entry = debug_header.Entries[i];
WriteBytes(entry.Data);
}
}
private void WriteImportDirectory()
{
WriteUInt32(text_map.GetRVA(TextSegment.ImportDirectory) + 40); // ImportLookupTable
WriteUInt32(0); // DateTimeStamp
WriteUInt32(0); // ForwarderChain
WriteUInt32(text_map.GetRVA(TextSegment.ImportHintNameTable) + 14);
WriteUInt32(text_map.GetRVA(TextSegment.ImportAddressTable));
Advance(20);
// ImportLookupTable
WriteUInt32(text_map.GetRVA(TextSegment.ImportHintNameTable));
// ImportHintNameTable
MoveToRVA(TextSegment.ImportHintNameTable);
WriteUInt16(0); // Hint
WriteBytes(GetRuntimeMain());
WriteByte(0);
WriteBytes(GetSimpleString("mscoree.dll"));
WriteUInt16(0);
}
private byte[] GetRuntimeMain()
{
return module.Kind == ModuleKind.Dll || module.Kind == ModuleKind.NetModule ? GetSimpleString("_CorDllMain") : GetSimpleString("_CorExeMain");
}
private void WriteStartupStub()
{
switch (module.Architecture)
{
case TargetArchitecture.I386:
WriteUInt16(0x25ff);
WriteUInt32((uint)image_base + text_map.GetRVA(TextSegment.ImportAddressTable));
return;
default:
throw new NotSupportedException();
}
}
private void WriteRsrc()
{
PrepareSection(rsrc);
WriteBuffer(win32_resources);
}
private void WriteReloc()
{
PrepareSection(reloc);
uint reloc_rva = text_map.GetRVA(TextSegment.StartupStub);
reloc_rva += module.Architecture == TargetArchitecture.IA64 ? 0x20u : 2;
uint page_rva = reloc_rva & ~0xfffu;
WriteUInt32(page_rva); // PageRVA
WriteUInt32(0x000c); // Block Size
switch (module.Architecture)
{
case TargetArchitecture.I386:
WriteUInt32(0x3000 + reloc_rva - page_rva);
break;
default:
throw new NotSupportedException();
}
}
public void WriteImage()
{
WriteDOSHeader();
WritePEFileHeader();
WriteOptionalHeaders();
WriteSectionHeaders();
WriteText();
if (rsrc != null)
WriteRsrc();
if (reloc != null)
WriteReloc();
Flush();
}
private void BuildTextMap()
{
TextMap map = text_map;
map.AddMap(TextSegment.Code, metadata.code.length, !pe64 ? 4 : 16);
map.AddMap(TextSegment.Resources, metadata.resources.length, 8);
map.AddMap(TextSegment.Data, metadata.data.length, 4);
if (metadata.data.length > 0)
metadata.table_heap.FixupData(map.GetRVA(TextSegment.Data));
map.AddMap(TextSegment.StrongNameSignature, GetStrongNameLength(), 4);
BuildMetadataTextMap();
int debug_dir_len = 0;
if (debug_header != null && debug_header.HasEntries)
{
int directories_len = debug_header.Entries.Length * ImageDebugDirectory.Size;
int data_address = (int)map.GetNextRVA(TextSegment.BlobHeap) + directories_len;
int data_len = 0;
for (int i = 0; i < debug_header.Entries.Length; i++)
{
ImageDebugHeaderEntry entry = debug_header.Entries[i];
ImageDebugDirectory directory = entry.Directory;
directory.AddressOfRawData = entry.Data.Length == 0 ? 0 : data_address;
entry.Directory = directory;
data_len += entry.Data.Length;
data_address += data_len;
}
debug_dir_len = directories_len + data_len;
}
map.AddMap(TextSegment.DebugDirectory, debug_dir_len, 4);
if (!has_reloc)
{
uint start = map.GetNextRVA(TextSegment.DebugDirectory);
map.AddMap(TextSegment.ImportDirectory, new Range(start, 0));
map.AddMap(TextSegment.ImportHintNameTable, new Range(start, 0));
map.AddMap(TextSegment.StartupStub, new Range(start, 0));
return;
}
RVA import_dir_rva = map.GetNextRVA(TextSegment.DebugDirectory);
RVA import_hnt_rva = import_dir_rva + 48u;
import_hnt_rva = (import_hnt_rva + 15u) & ~15u;
uint import_dir_len = import_hnt_rva - import_dir_rva + 27u;
RVA startup_stub_rva = import_dir_rva + import_dir_len;
startup_stub_rva = module.Architecture == TargetArchitecture.IA64 ? (startup_stub_rva + 15u) & ~15u : 2 + ((startup_stub_rva + 3u) & ~3u);
map.AddMap(TextSegment.ImportDirectory, new Range(import_dir_rva, import_dir_len));
map.AddMap(TextSegment.ImportHintNameTable, new Range(import_hnt_rva, 0));
map.AddMap(TextSegment.StartupStub, new Range(startup_stub_rva, GetStartupStubLength()));
}
public void BuildMetadataTextMap()
{
TextMap map = text_map;
map.AddMap(TextSegment.MetadataHeader, GetMetadataHeaderLength(module.RuntimeVersion));
map.AddMap(TextSegment.TableHeap, metadata.table_heap.length, 4);
map.AddMap(TextSegment.StringHeap, metadata.string_heap.length, 4);
map.AddMap(TextSegment.UserStringHeap, metadata.user_string_heap.IsEmpty ? 0 : metadata.user_string_heap.length, 4);
map.AddMap(TextSegment.GuidHeap, metadata.guid_heap.length, 4);
map.AddMap(TextSegment.BlobHeap, metadata.blob_heap.IsEmpty ? 0 : metadata.blob_heap.length, 4);
map.AddMap(TextSegment.PdbHeap, metadata.pdb_heap == null ? 0 : metadata.pdb_heap.length, 4);
}
private uint GetStartupStubLength()
{
switch (module.Architecture)
{
case TargetArchitecture.I386:
return 6;
default:
throw new NotSupportedException();
}
}
private int GetMetadataHeaderLength(string runtimeVersion)
{
return
// MetadataHeader
20 + GetZeroTerminatedStringLength(runtimeVersion)
// #~ header
+ 12
// #Strings header
+ 20
// #US header
+ (metadata.user_string_heap.IsEmpty ? 0 : 12)
// #GUID header
+ 16
// #Blob header
+ (metadata.blob_heap.IsEmpty ? 0 : 16)
//
+ (metadata.pdb_heap == null ? 0 : 16);
}
private int GetStrongNameLength()
{
if (module.kind == ModuleKind.NetModule || module.Assembly == null)
return 0;
byte[] public_key = module.Assembly.Name.PublicKey;
if (public_key.IsNullOrEmpty())
return 0;
// in fx 2.0 the key may be from 384 to 16384 bits
// so we must calculate the signature size based on
// the size of the public key (minus the 32 byte header)
int size = public_key.Length;
if (size > 32)
return size - 32;
// note: size == 16 for the ECMA "key" which is replaced
// by the runtime with a 1024 bits key (128 bytes)
return 128; // default strongname signature size
}
public DataDirectory GetStrongNameSignatureDirectory()
{
return text_map.GetDataDirectory(TextSegment.StrongNameSignature);
}
public uint GetHeaderSize()
{
return pe_header_size + SizeOfOptionalHeader() + sections * section_header_size;
}
private void PatchWin32Resources(ByteBuffer resources)
{
PatchResourceDirectoryTable(resources);
}
private void PatchResourceDirectoryTable(ByteBuffer resources)
{
resources.Advance(12);
int entries = resources.ReadUInt16() + resources.ReadUInt16();
for (int i = 0; i < entries; i++)
PatchResourceDirectoryEntry(resources);
}
private void PatchResourceDirectoryEntry(ByteBuffer resources)
{
resources.Advance(4);
uint child = resources.ReadUInt32();
int position = resources.position;
resources.position = (int)child & 0x7fffffff;
if ((child & 0x80000000) != 0)
PatchResourceDirectoryTable(resources);
else
PatchResourceDataEntry(resources);
resources.position = position;
}
private void PatchResourceDataEntry(ByteBuffer resources)
{
uint rva = resources.ReadUInt32();
resources.position -= 4;
resources.WriteUInt32(rva - module.Image.Win32Resources.VirtualAddress + rsrc.VirtualAddress);
}
}
}
@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 88ebae078ed1c8346be0a945ce3b03b0
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 207815
packageName: 'FishNet: Networking Evolved'
packageVersion: 4.6.22R
assetPath: Assets/FishNet/CodeGenerating/cecil-0.11.4/Mono.Cecil.PE/ImageWriter.cs
uploadId: 866910
@@ -0,0 +1,23 @@
//
// Author:
// Jb Evain (jbevain@gmail.com)
//
// Copyright (c) 2008 - 2015 Jb Evain
// Copyright (c) 2008 - 2011 Novell, Inc.
//
// Licensed under the MIT/X11 license.
//
using RVA = System.UInt32;
namespace MonoFN.Cecil.PE
{
internal sealed class Section
{
public string Name;
public RVA VirtualAddress;
public uint VirtualSize;
public uint SizeOfRawData;
public uint PointerToRawData;
}
}
@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: dc33915bdaaf42a428f8a4694e9611a8
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 207815
packageName: 'FishNet: Networking Evolved'
packageVersion: 4.6.22R
assetPath: Assets/FishNet/CodeGenerating/cecil-0.11.4/Mono.Cecil.PE/Section.cs
uploadId: 866910
@@ -0,0 +1,106 @@
//
// Author:
// Jb Evain (jbevain@gmail.com)
//
// Copyright (c) 2008 - 2015 Jb Evain
// Copyright (c) 2008 - 2011 Novell, Inc.
//
// Licensed under the MIT/X11 license.
//
using RVA = System.UInt32;
namespace MonoFN.Cecil.PE
{
internal enum TextSegment
{
ImportAddressTable,
CLIHeader,
Code,
Resources,
Data,
StrongNameSignature,
// Metadata
MetadataHeader,
TableHeap,
StringHeap,
UserStringHeap,
GuidHeap,
BlobHeap,
PdbHeap,
// End Metadata
DebugDirectory,
ImportDirectory,
ImportHintNameTable,
StartupStub
}
internal sealed class TextMap
{
private readonly Range[] map = new Range [17 /*Enum.GetValues (typeof (TextSegment)).Length*/];
public void AddMap(TextSegment segment, int length)
{
map[(int)segment] = new(GetStart(segment), (uint)length);
}
public void AddMap(TextSegment segment, int length, int align)
{
align--;
AddMap(segment, (length + align) & ~align);
}
public void AddMap(TextSegment segment, Range range)
{
map[(int)segment] = range;
}
public Range GetRange(TextSegment segment)
{
return map[(int)segment];
}
public DataDirectory GetDataDirectory(TextSegment segment)
{
Range range = map[(int)segment];
return new(range.Length == 0 ? 0 : range.Start, range.Length);
}
public RVA GetRVA(TextSegment segment)
{
return map[(int)segment].Start;
}
public RVA GetNextRVA(TextSegment segment)
{
int i = (int)segment;
return map[i].Start + map[i].Length;
}
public int GetLength(TextSegment segment)
{
return (int)map[(int)segment].Length;
}
private RVA GetStart(TextSegment segment)
{
int index = (int)segment;
return index == 0 ? ImageWriter.text_rva : ComputeStart(index);
}
private RVA ComputeStart(int index)
{
index--;
return map[index].Start + map[index].Length;
}
public uint GetLength()
{
Range range = map[(int)TextSegment.StartupStub];
return range.Start - ImageWriter.text_rva + range.Length;
}
}
}
@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 1d36ca0589eb8014fa28bc58a88ae85f
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 207815
packageName: 'FishNet: Networking Evolved'
packageVersion: 4.6.22R
assetPath: Assets/FishNet/CodeGenerating/cecil-0.11.4/Mono.Cecil.PE/TextMap.cs
uploadId: 866910
@@ -0,0 +1,16 @@
<Project>
<PropertyGroup>
<IsTestProject>true</IsTestProject>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="NUnit">
<Version>3.11.0</Version>
</PackageReference>
<PackageReference Include="Microsoft.NET.Test.Sdk">
<Version>15.9.0</Version>
</PackageReference>
<PackageReference Include="NUnit3TestAdapter">
<Version>3.12.0</Version>
</PackageReference>
</ItemGroup>
</Project>
@@ -0,0 +1,14 @@
fileFormatVersion: 2
guid: 4304d9110a6c73049a70f3d001e1ac37
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 207815
packageName: 'FishNet: Networking Evolved'
packageVersion: 4.6.22R
assetPath: Assets/FishNet/CodeGenerating/cecil-0.11.4/Mono.Cecil.Tests.props
uploadId: 866910
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 08f20128864a55d45abd8a30563f2f5c
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,9 @@
<NUnitProject>
<Settings activeconfig="Debug" />
<Config name="Debug" runtimeFramework="v4.0.30319" domainUsage="Single">
<assembly path="./Test/bin/Debug/net40/Mono.Cecil.Tests.dll" />
<assembly path="./rocks/Test/bin/Debug/net40/Mono.Cecil.Rocks.Tests.dll" />
<assembly path="./symbols/mdb/Test/bin/Debug/net40/Mono.Cecil.Mdb.Tests.dll" />
<assembly path="./symbols/pdb/Test/bin/Debug/net40/Mono.Cecil.Pdb.Tests.dll" />
</Config>
</NUnitProject>
@@ -0,0 +1,14 @@
fileFormatVersion: 2
guid: 70249fc3714c2ba43bb69eeceaf02171
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 207815
packageName: 'FishNet: Networking Evolved'
packageVersion: 4.6.22R
assetPath: Assets/FishNet/CodeGenerating/cecil-0.11.4/Mono.Cecil.nunit
uploadId: 866910
@@ -0,0 +1,42 @@
<?xml version="1.0"?>
<package xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<metadata xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<id>Mono.Cecil</id>
<version>0.11.4.0</version>
<title>Mono.Cecil</title>
<authors>Jb Evain</authors>
<owners>Jb Evain</owners>
<license type="expression">MIT</license>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<projectUrl>http://github.com/jbevain/cecil/</projectUrl>
<summary>Cecil is a library written by Jb Evain to generate and inspect programs and libraries in the ECMA CIL format.</summary>
<description>Cecil is a library written by Jb Evain to generate and inspect programs and libraries in the ECMA CIL format. It has full support for generics, and support some debugging symbol format. In simple English, with Cecil, you can load existing managed assemblies, browse all the contained types, modify them on the fly and save back to the disk the modified assembly.</description>
<language>en-US</language>
<tags>assembly assemblies module modules il cil msil bytecode reflection injection cecil mono aop</tags>
<dependencies>
<group targetFramework=".NETFramework4.0" />
<group targetFramework=".NETStandard2.0" />
</dependencies>
</metadata>
<files>
<file src="bin\Release\net40\Mono.Cecil.dll" target="lib/net40" />
<file src="bin\Release\net40\Mono.Cecil.pdb" target="lib/net40" />
<file src="bin\Release\netstandard2.0\Mono.Cecil.dll" target="lib/netstandard2.0" />
<file src="bin\Release\netstandard2.0\Mono.Cecil.pdb" target="lib/netstandard2.0" />
<file src="rocks\bin\Release\net40\Mono.Cecil.Rocks.dll" target="lib/net40" />
<file src="rocks\bin\Release\net40\Mono.Cecil.Rocks.pdb" target="lib/net40" />
<file src="rocks\bin\Release\netstandard2.0\Mono.Cecil.Rocks.dll" target="lib/netstandard2.0" />
<file src="rocks\bin\Release\netstandard2.0\Mono.Cecil.Rocks.pdb" target="lib/netstandard2.0" />
<file src="symbols\mdb\bin\Release\net40\Mono.Cecil.Mdb.dll" target="lib/net40" />
<file src="symbols\mdb\bin\Release\net40\Mono.Cecil.Mdb.pdb" target="lib/net40" />
<file src="symbols\mdb\bin\Release\netstandard2.0\Mono.Cecil.Mdb.dll" target="lib/netstandard2.0" />
<file src="symbols\mdb\bin\Release\netstandard2.0\Mono.Cecil.Mdb.pdb" target="lib/netstandard2.0" />
<file src="symbols\pdb\bin\Release\net40\Mono.Cecil.Pdb.dll" target="lib/net40" />
<file src="symbols\pdb\bin\Release\net40\Mono.Cecil.Pdb.pdb" target="lib/net40" />
<file src="symbols\pdb\bin\Release\netstandard2.0\Mono.Cecil.Pdb.dll" target="lib/netstandard2.0" />
<file src="symbols\pdb\bin\Release\netstandard2.0\Mono.Cecil.Pdb.pdb" target="lib/netstandard2.0" />
</files>
</package>
@@ -0,0 +1,14 @@
fileFormatVersion: 2
guid: 9ab5a3af6caf6d14da0bad821a809a27
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 207815
packageName: 'FishNet: Networking Evolved'
packageVersion: 4.6.22R
assetPath: Assets/FishNet/CodeGenerating/cecil-0.11.4/Mono.Cecil.nuspec
uploadId: 866910
@@ -0,0 +1,67 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.28516.95
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Mono.Cecil", "Mono.Cecil.csproj", "{16C3FA32-4775-497F-8794-DD5AF13CFE22}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Mono.Cecil.Pdb", "symbols\pdb\Mono.Cecil.Pdb.csproj", "{4D22D51C-4230-46AF-8657-4FD757D9C8BC}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Mono.Cecil.Mdb", "symbols\mdb\Mono.Cecil.Mdb.csproj", "{5A5F84B1-DD1A-4134-932C-C3AF5BDAD391}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Mono.Cecil.Tests", "Test\Mono.Cecil.Tests.csproj", "{EA7ADB7D-9FC1-4B4C-BBE9-359DD5B2E345}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Mono.Cecil.Mdb.Tests", "symbols\mdb\Test\Mono.Cecil.Mdb.Tests.csproj", "{901E005D-CD64-4DC5-8CD0-4A49A7B0AF71}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Mono.Cecil.Pdb.Tests", "symbols\pdb\Test\Mono.Cecil.Pdb.Tests.csproj", "{50FC1815-A653-48D0-95E2-DB48CB01F4E1}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Mono.Cecil.Rocks", "rocks\Mono.Cecil.Rocks.csproj", "{70E05599-64EE-4C11-A2F8-EE4113309039}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Mono.Cecil.Rocks.Tests", "rocks\Test\Mono.Cecil.Rocks.Tests.csproj", "{EF768F7A-3C08-45EE-8A7E-BB5A81BADB7B}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{16C3FA32-4775-497F-8794-DD5AF13CFE22}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{16C3FA32-4775-497F-8794-DD5AF13CFE22}.Debug|Any CPU.Build.0 = Debug|Any CPU
{16C3FA32-4775-497F-8794-DD5AF13CFE22}.Release|Any CPU.ActiveCfg = Release|Any CPU
{16C3FA32-4775-497F-8794-DD5AF13CFE22}.Release|Any CPU.Build.0 = Release|Any CPU
{4D22D51C-4230-46AF-8657-4FD757D9C8BC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4D22D51C-4230-46AF-8657-4FD757D9C8BC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4D22D51C-4230-46AF-8657-4FD757D9C8BC}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4D22D51C-4230-46AF-8657-4FD757D9C8BC}.Release|Any CPU.Build.0 = Release|Any CPU
{5A5F84B1-DD1A-4134-932C-C3AF5BDAD391}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5A5F84B1-DD1A-4134-932C-C3AF5BDAD391}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5A5F84B1-DD1A-4134-932C-C3AF5BDAD391}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5A5F84B1-DD1A-4134-932C-C3AF5BDAD391}.Release|Any CPU.Build.0 = Release|Any CPU
{EA7ADB7D-9FC1-4B4C-BBE9-359DD5B2E345}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{EA7ADB7D-9FC1-4B4C-BBE9-359DD5B2E345}.Debug|Any CPU.Build.0 = Debug|Any CPU
{EA7ADB7D-9FC1-4B4C-BBE9-359DD5B2E345}.Release|Any CPU.ActiveCfg = Release|Any CPU
{EA7ADB7D-9FC1-4B4C-BBE9-359DD5B2E345}.Release|Any CPU.Build.0 = Release|Any CPU
{901E005D-CD64-4DC5-8CD0-4A49A7B0AF71}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{901E005D-CD64-4DC5-8CD0-4A49A7B0AF71}.Debug|Any CPU.Build.0 = Debug|Any CPU
{901E005D-CD64-4DC5-8CD0-4A49A7B0AF71}.Release|Any CPU.ActiveCfg = Release|Any CPU
{901E005D-CD64-4DC5-8CD0-4A49A7B0AF71}.Release|Any CPU.Build.0 = Release|Any CPU
{50FC1815-A653-48D0-95E2-DB48CB01F4E1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{50FC1815-A653-48D0-95E2-DB48CB01F4E1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{50FC1815-A653-48D0-95E2-DB48CB01F4E1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{50FC1815-A653-48D0-95E2-DB48CB01F4E1}.Release|Any CPU.Build.0 = Release|Any CPU
{70E05599-64EE-4C11-A2F8-EE4113309039}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{70E05599-64EE-4C11-A2F8-EE4113309039}.Debug|Any CPU.Build.0 = Debug|Any CPU
{70E05599-64EE-4C11-A2F8-EE4113309039}.Release|Any CPU.ActiveCfg = Release|Any CPU
{70E05599-64EE-4C11-A2F8-EE4113309039}.Release|Any CPU.Build.0 = Release|Any CPU
{EF768F7A-3C08-45EE-8A7E-BB5A81BADB7B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{EF768F7A-3C08-45EE-8A7E-BB5A81BADB7B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{EF768F7A-3C08-45EE-8A7E-BB5A81BADB7B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{EF768F7A-3C08-45EE-8A7E-BB5A81BADB7B}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {97A7013A-E1DE-4D11-93C5-212D0A7E85C9}
EndGlobalSection
EndGlobal
@@ -0,0 +1,14 @@
fileFormatVersion: 2
guid: 246f31a0e00fea74a93125fec6d80da8
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 207815
packageName: 'FishNet: Networking Evolved'
packageVersion: 4.6.22R
assetPath: Assets/FishNet/CodeGenerating/cecil-0.11.4/Mono.Cecil.sln
uploadId: 866910
@@ -0,0 +1,145 @@
//
// Author:
// Jb Evain (jbevain@gmail.com)
//
// Copyright (c) 2008 - 2015 Jb Evain
// Copyright (c) 2008 - 2011 Novell, Inc.
//
// Licensed under the MIT/X11 license.
//
using MonoFN.Collections.Generic;
using System;
using System.Text;
using System.Threading;
using MD = MonoFN.Cecil.Metadata;
namespace MonoFN.Cecil
{
public struct ArrayDimension
{
private int? lower_bound;
private int? upper_bound;
public int? LowerBound
{
get { return lower_bound; }
set { lower_bound = value; }
}
public int? UpperBound
{
get { return upper_bound; }
set { upper_bound = value; }
}
public bool IsSized
{
get { return lower_bound.HasValue || upper_bound.HasValue; }
}
public ArrayDimension(int? lowerBound, int? upperBound)
{
lower_bound = lowerBound;
upper_bound = upperBound;
}
public override string ToString()
{
return !IsSized ? string.Empty : lower_bound + "..." + upper_bound;
}
}
public sealed class ArrayType : TypeSpecification
{
private Collection<ArrayDimension> dimensions;
public Collection<ArrayDimension> Dimensions
{
get
{
if (dimensions != null)
return dimensions;
Collection<ArrayDimension> empty_dimensions = new();
empty_dimensions.Add(new());
Interlocked.CompareExchange(ref dimensions, empty_dimensions, null);
return dimensions;
}
}
public int Rank
{
get { return dimensions == null ? 1 : dimensions.Count; }
}
public bool IsVector
{
get
{
if (dimensions == null)
return true;
if (dimensions.Count > 1)
return false;
ArrayDimension dimension = dimensions[0];
return !dimension.IsSized;
}
}
public override bool IsValueType
{
get { return false; }
set { throw new InvalidOperationException(); }
}
public override string Name
{
get { return base.Name + Suffix; }
}
public override string FullName
{
get { return base.FullName + Suffix; }
}
private string Suffix
{
get
{
if (IsVector)
return "[]";
StringBuilder suffix = new();
suffix.Append("[");
for (int i = 0; i < dimensions.Count; i++)
{
if (i > 0)
suffix.Append(",");
suffix.Append(dimensions[i].ToString());
}
suffix.Append("]");
return suffix.ToString();
}
}
public override bool IsArray
{
get { return true; }
}
public ArrayType(TypeReference type) : base(type)
{
Mixin.CheckType(type);
etype = MD.ElementType.Array;
}
public ArrayType(TypeReference type, int rank) : this(type)
{
Mixin.CheckType(type);
if (rank == 1)
return;
dimensions = new(rank);
for (int i = 0; i < rank; i++)
dimensions.Add(new());
etype = MD.ElementType.Array;
}
}
}
@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 7add098db82a032428c139b59f0878be
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 207815
packageName: 'FishNet: Networking Evolved'
packageVersion: 4.6.22R
assetPath: Assets/FishNet/CodeGenerating/cecil-0.11.4/Mono.Cecil/ArrayType.cs
uploadId: 866910
@@ -0,0 +1,185 @@
//
// Author:
// Jb Evain (jbevain@gmail.com)
//
// Copyright (c) 2008 - 2015 Jb Evain
// Copyright (c) 2008 - 2011 Novell, Inc.
//
// Licensed under the MIT/X11 license.
//
using MonoFN.Collections.Generic;
using System;
using System.IO;
using System.Threading;
namespace MonoFN.Cecil
{
public sealed class AssemblyDefinition : ICustomAttributeProvider, ISecurityDeclarationProvider, IDisposable
{
internal ModuleDefinition main_module;
private Collection<ModuleDefinition> modules;
private Collection<CustomAttribute> custom_attributes;
private Collection<SecurityDeclaration> security_declarations;
public AssemblyNameDefinition Name { get; set; }
public string FullName
{
get { return Name != null ? Name.FullName : string.Empty; }
}
public MetadataToken MetadataToken
{
get { return new(TokenType.Assembly, 1); }
set { }
}
public Collection<ModuleDefinition> Modules
{
get
{
if (modules != null)
return modules;
if (main_module.HasImage)
return main_module.Read(ref modules, this, (_, reader) => reader.ReadModules());
Interlocked.CompareExchange(ref modules, new(1) { main_module }, null);
return modules;
}
}
public ModuleDefinition MainModule
{
get { return main_module; }
}
public MethodDefinition EntryPoint
{
get { return main_module.EntryPoint; }
set { main_module.EntryPoint = value; }
}
public bool HasCustomAttributes
{
get
{
if (custom_attributes != null)
return custom_attributes.Count > 0;
return this.GetHasCustomAttributes(main_module);
}
}
public Collection<CustomAttribute> CustomAttributes
{
get { return custom_attributes ?? this.GetCustomAttributes(ref custom_attributes, main_module); }
}
public bool HasSecurityDeclarations
{
get
{
if (security_declarations != null)
return security_declarations.Count > 0;
return this.GetHasSecurityDeclarations(main_module);
}
}
public Collection<SecurityDeclaration> SecurityDeclarations
{
get { return security_declarations ?? this.GetSecurityDeclarations(ref security_declarations, main_module); }
}
internal AssemblyDefinition() { }
public void Dispose()
{
if (this.modules == null)
{
main_module.Dispose();
return;
}
Collection<ModuleDefinition> modules = Modules;
for (int i = 0; i < modules.Count; i++)
modules[i].Dispose();
}
public static AssemblyDefinition CreateAssembly(AssemblyNameDefinition assemblyName, string moduleName, ModuleKind kind)
{
return CreateAssembly(assemblyName, moduleName, new ModuleParameters { Kind = kind });
}
public static AssemblyDefinition CreateAssembly(AssemblyNameDefinition assemblyName, string moduleName, ModuleParameters parameters)
{
if (assemblyName == null)
throw new ArgumentNullException("assemblyName");
if (moduleName == null)
throw new ArgumentNullException("moduleName");
Mixin.CheckParameters(parameters);
if (parameters.Kind == ModuleKind.NetModule)
throw new ArgumentException("kind");
AssemblyDefinition assembly = ModuleDefinition.CreateModule(moduleName, parameters).Assembly;
assembly.Name = assemblyName;
return assembly;
}
public static AssemblyDefinition ReadAssembly(string fileName)
{
return ReadAssembly(ModuleDefinition.ReadModule(fileName));
}
public static AssemblyDefinition ReadAssembly(string fileName, ReaderParameters parameters)
{
return ReadAssembly(ModuleDefinition.ReadModule(fileName, parameters));
}
public static AssemblyDefinition ReadAssembly(Stream stream)
{
return ReadAssembly(ModuleDefinition.ReadModule(stream));
}
public static AssemblyDefinition ReadAssembly(Stream stream, ReaderParameters parameters)
{
return ReadAssembly(ModuleDefinition.ReadModule(stream, parameters));
}
private static AssemblyDefinition ReadAssembly(ModuleDefinition module)
{
AssemblyDefinition assembly = module.Assembly;
if (assembly == null)
throw new ArgumentException();
return assembly;
}
public void Write(string fileName)
{
Write(fileName, new());
}
public void Write(string fileName, WriterParameters parameters)
{
main_module.Write(fileName, parameters);
}
public void Write()
{
main_module.Write();
}
public void Write(WriterParameters parameters)
{
main_module.Write(parameters);
}
public void Write(Stream stream)
{
Write(stream, new());
}
public void Write(Stream stream, WriterParameters parameters)
{
main_module.Write(stream, parameters);
}
public override string ToString()
{
return FullName;
}
}
}
@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 1c1ac0fc48f2d424f9c0d9fa74b16b07
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 207815
packageName: 'FishNet: Networking Evolved'
packageVersion: 4.6.22R
assetPath: Assets/FishNet/CodeGenerating/cecil-0.11.4/Mono.Cecil/AssemblyDefinition.cs
uploadId: 866910
@@ -0,0 +1,25 @@
//
// Author:
// Jb Evain (jbevain@gmail.com)
//
// Copyright (c) 2008 - 2015 Jb Evain
// Copyright (c) 2008 - 2011 Novell, Inc.
//
// Licensed under the MIT/X11 license.
//
using System;
namespace MonoFN.Cecil
{
[Flags]
public enum AssemblyAttributes : uint
{
PublicKey = 0x0001,
SideBySideCompatible = 0x0000,
Retargetable = 0x0100,
WindowsRuntime = 0x0200,
DisableJITCompileOptimizer = 0x4000,
EnableJITCompileTracking = 0x8000
}
}
@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 257c8151138cda34dafbe0ca56ebedf4
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 207815
packageName: 'FishNet: Networking Evolved'
packageVersion: 4.6.22R
assetPath: Assets/FishNet/CodeGenerating/cecil-0.11.4/Mono.Cecil/AssemblyFlags.cs
uploadId: 866910

Some files were not shown because too many files have changed in this diff Show More