}
}
- public struct UnwindInfo : BaseUnwindInfo
+ public class UnwindInfo : BaseUnwindInfo
{
private const int _sizeofUnwindCode = 2;
private const int _offsetofUnwindCode = 4;
public byte FrameOffset { get; set; } //4 bits
public UnwindCode[] UnwindCode { get; set; }
public uint PersonalityRoutineRVA { get; set; }
- public int Size { get; set; }
+
+ public UnwindInfo() { }
public UnwindInfo(byte[] image, int offset)
{
}
return data;
}
+
+ /// <summary>
+ /// Based on decodeUnsigned in gcdecoder.cpp, used by the x86 gcdump and unwindinfo
+ /// </summary>
+ public static uint DecodeUnsignedGc(byte[] image, ref int start)
+ {
+ int size = 1;
+ byte data = image[start++];
+ uint value = (uint)data & 0x7f;
+ while ((data & 0x80) != 0)
+ {
+ size++;
+ data = image[start++];
+ value <<= 7;
+ value += (uint)data & 0x7f;
+ }
+ return value;
+ }
}
}
namespace R2RDump
{
- public interface BaseUnwindInfo
+ public abstract class BaseUnwindInfo
{
-
+ public int Size { get; set; }
}
public class RuntimeFunction
{
Size = endRva - startRva;
}
+ else if (unwindInfo is x86.UnwindInfo)
+ {
+ Size = (int)((x86.UnwindInfo)unwindInfo).FunctionLength;
+ }
else if (gcInfo != null)
{
Size = gcInfo.CodeLength;
unwindInfo = new Amd64.UnwindInfo(Image, unwindOffset);
if (isEntryPoint[runtimeFunctionId])
{
- gcInfo = new GcInfo(Image, unwindOffset + ((Amd64.UnwindInfo)unwindInfo).Size, Machine, R2RHeader.MajorVersion);
+ gcInfo = new GcInfo(Image, unwindOffset + unwindInfo.Size, Machine, R2RHeader.MajorVersion);
+ }
+ }
+ else if (Machine == Machine.I386)
+ {
+ unwindInfo = new x86.UnwindInfo(Image, unwindOffset);
+ if (isEntryPoint[runtimeFunctionId])
+ {
+ //gcInfo = new GcInfo(Image, unwindOffset + unwindInfo.Size, Machine, R2RHeader.MajorVersion);
}
}
--- /dev/null
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System.Text;
+using System.Xml.Serialization;
+
+namespace R2RDump.x86
+{
+ public class UnwindInfo : BaseUnwindInfo
+ {
+ public uint FunctionLength { get; set; }
+
+ public UnwindInfo() { }
+
+ public UnwindInfo(byte[] image, int offset)
+ {
+ FunctionLength = NativeReader.DecodeUnsignedGc(image, ref offset);
+ Size = sizeof(int);
+ }
+
+ public override string ToString()
+ {
+ StringBuilder sb = new StringBuilder();
+ sb.AppendLine($"\tFunctionLength: {FunctionLength}");
+ return sb.ToString();
+ }
+ }
+}
<MethodRid>1</MethodRid>
<RuntimeFunction xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Index="0">
<StartAddress>10200</StartAddress>
- <Size>0</Size>
+ <Size>6</Size>
<UnwindRVA>10420</UnwindRVA>
<CodeOffset>0</CodeOffset>
</RuntimeFunction>
+ <UnwindInfo>
+ <UnwindInfo xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+ <Size>4</Size>
+ <FunctionLength>6</FunctionLength>
+ </UnwindInfo>
+ </UnwindInfo>
</RuntimeFunction>
</RuntimeFunctions>
</Method>
<MethodRid>2</MethodRid>
<RuntimeFunction xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Index="1">
<StartAddress>10208</StartAddress>
- <Size>0</Size>
+ <Size>127</Size>
<UnwindRVA>10424</UnwindRVA>
<CodeOffset>0</CodeOffset>
</RuntimeFunction>
+ <UnwindInfo>
+ <UnwindInfo xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+ <Size>4</Size>
+ <FunctionLength>127</FunctionLength>
+ </UnwindInfo>
+ </UnwindInfo>
</RuntimeFunction>
</RuntimeFunctions>
</Method>
<MethodRid>3</MethodRid>
<RuntimeFunction xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Index="2">
<StartAddress>10336</StartAddress>
- <Size>0</Size>
+ <Size>6</Size>
<UnwindRVA>10420</UnwindRVA>
<CodeOffset>0</CodeOffset>
</RuntimeFunction>
+ <UnwindInfo>
+ <UnwindInfo xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+ <Size>4</Size>
+ <FunctionLength>6</FunctionLength>
+ </UnwindInfo>
+ </UnwindInfo>
</RuntimeFunction>
</RuntimeFunctions>
</Method>
<MethodRid>1</MethodRid>
<RuntimeFunction xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Index="0">
<StartAddress>10380</StartAddress>
- <Size>0</Size>
+ <Size>8</Size>
<UnwindRVA>10528</UnwindRVA>
<CodeOffset>0</CodeOffset>
</RuntimeFunction>
+ <UnwindInfo>
+ <UnwindInfo xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+ <Size>4</Size>
+ <FunctionLength>8</FunctionLength>
+ </UnwindInfo>
+ </UnwindInfo>
</RuntimeFunction>
</RuntimeFunctions>
</Method>
<MethodRid>2</MethodRid>
<RuntimeFunction xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Index="1">
<StartAddress>10388</StartAddress>
- <Size>0</Size>
+ <Size>9</Size>
<UnwindRVA>10532</UnwindRVA>
<CodeOffset>0</CodeOffset>
</RuntimeFunction>
+ <UnwindInfo>
+ <UnwindInfo xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+ <Size>4</Size>
+ <FunctionLength>9</FunctionLength>
+ </UnwindInfo>
+ </UnwindInfo>
</RuntimeFunction>
</RuntimeFunctions>
</Method>
<MethodRid>4</MethodRid>
<RuntimeFunction xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Index="3">
<StartAddress>10412</StartAddress>
- <Size>0</Size>
+ <Size>19</Size>
<UnwindRVA>10542</UnwindRVA>
<CodeOffset>0</CodeOffset>
</RuntimeFunction>
+ <UnwindInfo>
+ <UnwindInfo xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+ <Size>4</Size>
+ <FunctionLength>19</FunctionLength>
+ </UnwindInfo>
+ </UnwindInfo>
</RuntimeFunction>
</RuntimeFunctions>
</Method>
<MethodRid>5</MethodRid>
<RuntimeFunction xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Index="4">
<StartAddress>10432</StartAddress>
- <Size>0</Size>
+ <Size>6</Size>
<UnwindRVA>10546</UnwindRVA>
<CodeOffset>0</CodeOffset>
</RuntimeFunction>
+ <UnwindInfo>
+ <UnwindInfo xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+ <Size>4</Size>
+ <FunctionLength>6</FunctionLength>
+ </UnwindInfo>
+ </UnwindInfo>
</RuntimeFunction>
</RuntimeFunctions>
</Method>
<MethodRid>3</MethodRid>
<RuntimeFunction xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Index="2">
<StartAddress>10400</StartAddress>
- <Size>0</Size>
+ <Size>10</Size>
<UnwindRVA>10536</UnwindRVA>
<CodeOffset>0</CodeOffset>
</RuntimeFunction>
+ <UnwindInfo>
+ <UnwindInfo xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+ <Size>4</Size>
+ <FunctionLength>10</FunctionLength>
+ </UnwindInfo>
+ </UnwindInfo>
</RuntimeFunction>
</RuntimeFunctions>
</Method>
<MethodRid>1</MethodRid>
<RuntimeFunction xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Index="0">
<StartAddress>10096</StartAddress>
- <Size>0</Size>
+ <Size>20</Size>
<UnwindRVA>10180</UnwindRVA>
<CodeOffset>0</CodeOffset>
</RuntimeFunction>
+ <UnwindInfo>
+ <UnwindInfo xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+ <Size>4</Size>
+ <FunctionLength>20</FunctionLength>
+ </UnwindInfo>
+ </UnwindInfo>
</RuntimeFunction>
</RuntimeFunctions>
</Method>
<MethodRid>2</MethodRid>
<RuntimeFunction xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Index="1">
<StartAddress>10116</StartAddress>
- <Size>0</Size>
+ <Size>6</Size>
<UnwindRVA>10184</UnwindRVA>
<CodeOffset>0</CodeOffset>
</RuntimeFunction>
+ <UnwindInfo>
+ <UnwindInfo xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+ <Size>4</Size>
+ <FunctionLength>6</FunctionLength>
+ </UnwindInfo>
+ </UnwindInfo>
</RuntimeFunction>
</RuntimeFunctions>
</Method>
<MethodRid>1</MethodRid>
<RuntimeFunction xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Index="0">
<StartAddress>10016</StartAddress>
- <Size>0</Size>
+ <Size>6</Size>
<UnwindRVA>10076</UnwindRVA>
<CodeOffset>0</CodeOffset>
</RuntimeFunction>
+ <UnwindInfo>
+ <UnwindInfo xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+ <Size>4</Size>
+ <FunctionLength>6</FunctionLength>
+ </UnwindInfo>
+ </UnwindInfo>
</RuntimeFunction>
</RuntimeFunctions>
</Method>
<MethodRid>2</MethodRid>
<RuntimeFunction xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Index="1">
<StartAddress>10024</StartAddress>
- <Size>0</Size>
+ <Size>6</Size>
<UnwindRVA>10076</UnwindRVA>
<CodeOffset>0</CodeOffset>
</RuntimeFunction>
+ <UnwindInfo>
+ <UnwindInfo xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+ <Size>4</Size>
+ <FunctionLength>6</FunctionLength>
+ </UnwindInfo>
+ </UnwindInfo>
</RuntimeFunction>
</RuntimeFunctions>
</Method>
<MethodRid>1</MethodRid>
<RuntimeFunction xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Index="0">
<StartAddress>10200</StartAddress>
- <Size>0</Size>
+ <Size>6</Size>
<UnwindRVA>10420</UnwindRVA>
<CodeOffset>0</CodeOffset>
</RuntimeFunction>
+ <UnwindInfo>
+ <UnwindInfo xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+ <Size>4</Size>
+ <FunctionLength>6</FunctionLength>
+ </UnwindInfo>
+ </UnwindInfo>
</RuntimeFunction>
</RuntimeFunctions>
</Method>
<MethodRid>2</MethodRid>
<RuntimeFunction xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Index="1">
<StartAddress>10208</StartAddress>
- <Size>0</Size>
+ <Size>127</Size>
<UnwindRVA>10424</UnwindRVA>
<CodeOffset>0</CodeOffset>
</RuntimeFunction>
+ <UnwindInfo>
+ <UnwindInfo xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+ <Size>4</Size>
+ <FunctionLength>127</FunctionLength>
+ </UnwindInfo>
+ </UnwindInfo>
</RuntimeFunction>
</RuntimeFunctions>
</Method>
<MethodRid>3</MethodRid>
<RuntimeFunction xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Index="2">
<StartAddress>10336</StartAddress>
- <Size>0</Size>
+ <Size>6</Size>
<UnwindRVA>10420</UnwindRVA>
<CodeOffset>0</CodeOffset>
</RuntimeFunction>
+ <UnwindInfo>
+ <UnwindInfo xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+ <Size>4</Size>
+ <FunctionLength>6</FunctionLength>
+ </UnwindInfo>
+ </UnwindInfo>
</RuntimeFunction>
</RuntimeFunctions>
</Method>
<MethodRid>1</MethodRid>
<RuntimeFunction xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Index="0">
<StartAddress>10380</StartAddress>
- <Size>0</Size>
+ <Size>8</Size>
<UnwindRVA>10528</UnwindRVA>
<CodeOffset>0</CodeOffset>
</RuntimeFunction>
+ <UnwindInfo>
+ <UnwindInfo xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+ <Size>4</Size>
+ <FunctionLength>8</FunctionLength>
+ </UnwindInfo>
+ </UnwindInfo>
</RuntimeFunction>
</RuntimeFunctions>
</Method>
<MethodRid>2</MethodRid>
<RuntimeFunction xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Index="1">
<StartAddress>10388</StartAddress>
- <Size>0</Size>
+ <Size>9</Size>
<UnwindRVA>10532</UnwindRVA>
<CodeOffset>0</CodeOffset>
</RuntimeFunction>
+ <UnwindInfo>
+ <UnwindInfo xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+ <Size>4</Size>
+ <FunctionLength>9</FunctionLength>
+ </UnwindInfo>
+ </UnwindInfo>
</RuntimeFunction>
</RuntimeFunctions>
</Method>
<MethodRid>4</MethodRid>
<RuntimeFunction xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Index="3">
<StartAddress>10412</StartAddress>
- <Size>0</Size>
+ <Size>19</Size>
<UnwindRVA>10542</UnwindRVA>
<CodeOffset>0</CodeOffset>
</RuntimeFunction>
+ <UnwindInfo>
+ <UnwindInfo xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+ <Size>4</Size>
+ <FunctionLength>19</FunctionLength>
+ </UnwindInfo>
+ </UnwindInfo>
</RuntimeFunction>
</RuntimeFunctions>
</Method>
<MethodRid>5</MethodRid>
<RuntimeFunction xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Index="4">
<StartAddress>10432</StartAddress>
- <Size>0</Size>
+ <Size>6</Size>
<UnwindRVA>10546</UnwindRVA>
<CodeOffset>0</CodeOffset>
</RuntimeFunction>
+ <UnwindInfo>
+ <UnwindInfo xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+ <Size>4</Size>
+ <FunctionLength>6</FunctionLength>
+ </UnwindInfo>
+ </UnwindInfo>
</RuntimeFunction>
</RuntimeFunctions>
</Method>
<MethodRid>3</MethodRid>
<RuntimeFunction xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Index="2">
<StartAddress>10400</StartAddress>
- <Size>0</Size>
+ <Size>10</Size>
<UnwindRVA>10536</UnwindRVA>
<CodeOffset>0</CodeOffset>
</RuntimeFunction>
+ <UnwindInfo>
+ <UnwindInfo xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+ <Size>4</Size>
+ <FunctionLength>10</FunctionLength>
+ </UnwindInfo>
+ </UnwindInfo>
</RuntimeFunction>
</RuntimeFunctions>
</Method>
<MethodRid>1</MethodRid>
<RuntimeFunction xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Index="0">
<StartAddress>10096</StartAddress>
- <Size>0</Size>
+ <Size>20</Size>
<UnwindRVA>10180</UnwindRVA>
<CodeOffset>0</CodeOffset>
</RuntimeFunction>
+ <UnwindInfo>
+ <UnwindInfo xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+ <Size>4</Size>
+ <FunctionLength>20</FunctionLength>
+ </UnwindInfo>
+ </UnwindInfo>
</RuntimeFunction>
</RuntimeFunctions>
</Method>
<MethodRid>2</MethodRid>
<RuntimeFunction xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Index="1">
<StartAddress>10116</StartAddress>
- <Size>0</Size>
+ <Size>6</Size>
<UnwindRVA>10184</UnwindRVA>
<CodeOffset>0</CodeOffset>
</RuntimeFunction>
+ <UnwindInfo>
+ <UnwindInfo xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+ <Size>4</Size>
+ <FunctionLength>6</FunctionLength>
+ </UnwindInfo>
+ </UnwindInfo>
</RuntimeFunction>
</RuntimeFunctions>
</Method>
<MethodRid>1</MethodRid>
<RuntimeFunction xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Index="0">
<StartAddress>10016</StartAddress>
- <Size>0</Size>
+ <Size>6</Size>
<UnwindRVA>10076</UnwindRVA>
<CodeOffset>0</CodeOffset>
</RuntimeFunction>
+ <UnwindInfo>
+ <UnwindInfo xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+ <Size>4</Size>
+ <FunctionLength>6</FunctionLength>
+ </UnwindInfo>
+ </UnwindInfo>
</RuntimeFunction>
</RuntimeFunctions>
</Method>
<MethodRid>2</MethodRid>
<RuntimeFunction xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Index="1">
<StartAddress>10024</StartAddress>
- <Size>0</Size>
+ <Size>6</Size>
<UnwindRVA>10076</UnwindRVA>
<CodeOffset>0</CodeOffset>
</RuntimeFunction>
+ <UnwindInfo>
+ <UnwindInfo xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+ <Size>4</Size>
+ <FunctionLength>6</FunctionLength>
+ </UnwindInfo>
+ </UnwindInfo>
</RuntimeFunction>
</RuntimeFunctions>
</Method>