mirror of
https://github.com/ZuneDev/ZuneShell.dll.git
synced 2026-07-27 13:11:51 -07:00
Fixed incorrect decompilation in UIX
This commit is contained in:
@@ -12,7 +12,7 @@ using System.Runtime.InteropServices;
|
|||||||
|
|
||||||
namespace Microsoft.Iris.Markup
|
namespace Microsoft.Iris.Markup
|
||||||
{
|
{
|
||||||
internal class ByteCodeReader : DisposableObject
|
internal class ManagedByteCodeReader : DisposableObject
|
||||||
{
|
{
|
||||||
private static char[] s_scratchCharArray = new char[100];
|
private static char[] s_scratchCharArray = new char[100];
|
||||||
private BinaryReader _reader;
|
private BinaryReader _reader;
|
||||||
@@ -20,13 +20,13 @@ namespace Microsoft.Iris.Markup
|
|||||||
private byte[] _bytes;
|
private byte[] _bytes;
|
||||||
private bool _inFixedMemory;
|
private bool _inFixedMemory;
|
||||||
|
|
||||||
public unsafe ByteCodeReader(IntPtr buffer, long size, bool ownsAllocation)
|
public unsafe ManagedByteCodeReader(IntPtr buffer, long size, bool ownsAllocation)
|
||||||
{
|
{
|
||||||
byte[] bytes = new byte[size];
|
byte[] bytes = new byte[size];
|
||||||
Marshal.Copy(buffer, bytes, 0, (int)size);
|
Marshal.Copy(buffer, bytes, 0, (int)size);
|
||||||
_bytes = bytes;
|
_bytes = bytes;
|
||||||
|
|
||||||
this._reader = new BinaryReader(new MemoryStream(_bytes));
|
_reader = new BinaryReader(new MemoryStream(_bytes));
|
||||||
_buffer = buffer;
|
_buffer = buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -42,9 +42,9 @@ namespace Microsoft.Iris.Markup
|
|||||||
|
|
||||||
public unsafe IntPtr CurrentAddress => new IntPtr(_buffer.ToInt64() + _reader.BaseStream.Position);
|
public unsafe IntPtr CurrentAddress => new IntPtr(_buffer.ToInt64() + _reader.BaseStream.Position);
|
||||||
|
|
||||||
public bool IsInFixedMemory => this._inFixedMemory;
|
public bool IsInFixedMemory => _inFixedMemory;
|
||||||
|
|
||||||
public void MarkAsInFixedMemory() => this._inFixedMemory = true;
|
public void MarkAsInFixedMemory() => _inFixedMemory = true;
|
||||||
|
|
||||||
public bool ReadBool() => _reader.ReadBoolean();
|
public bool ReadBool() => _reader.ReadBoolean();
|
||||||
|
|
||||||
@@ -80,7 +80,7 @@ namespace Microsoft.Iris.Markup
|
|||||||
|
|
||||||
public unsafe string ReadString()
|
public unsafe string ReadString()
|
||||||
{
|
{
|
||||||
uint num1 = this.ReadUInt16();
|
uint num1 = ReadUInt16();
|
||||||
if (num1 == ushort.MaxValue)
|
if (num1 == ushort.MaxValue)
|
||||||
return null;
|
return null;
|
||||||
bool flag;
|
bool flag;
|
||||||
@@ -96,10 +96,10 @@ namespace Microsoft.Iris.Markup
|
|||||||
flag = false;
|
flag = false;
|
||||||
num2 = num1 * 2U;
|
num2 = num1 * 2U;
|
||||||
}
|
}
|
||||||
if (this.CurrentOffset + num2 > this.Size)
|
if (CurrentOffset + num2 > Size)
|
||||||
this.ThrowReadError();
|
ThrowReadError();
|
||||||
char[] chArray = num1 >= s_scratchCharArray.Length ? new char[num1] : s_scratchCharArray;
|
char[] chArray = num1 >= s_scratchCharArray.Length ? new char[num1] : s_scratchCharArray;
|
||||||
byte* numPtr1 = (byte*)(_buffer.ToInt32() + (int)CurrentOffset);
|
byte* numPtr1 = (byte*)(_buffer.ToInt64() + CurrentOffset);
|
||||||
if (flag)
|
if (flag)
|
||||||
{
|
{
|
||||||
for (int index = 0; index < num1; ++index)
|
for (int index = 0; index < num1; ++index)
|
||||||
@@ -139,4 +139,176 @@ namespace Microsoft.Iris.Markup
|
|||||||
_buffer = IntPtr.Zero;
|
_buffer = IntPtr.Zero;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal class ByteCodeReader : DisposableObject
|
||||||
|
{
|
||||||
|
private static char[] s_scratchCharArray = new char[100];
|
||||||
|
private unsafe byte* _buffer;
|
||||||
|
private uint _offset;
|
||||||
|
private uint _size;
|
||||||
|
private bool _ownsAllocation;
|
||||||
|
private bool _inFixedMemory;
|
||||||
|
|
||||||
|
public unsafe ByteCodeReader(IntPtr buffer, uint size, bool ownsAllocation)
|
||||||
|
{
|
||||||
|
_buffer = (byte*)buffer.ToPointer();
|
||||||
|
_size = size;
|
||||||
|
_offset = 0U;
|
||||||
|
_ownsAllocation = ownsAllocation;
|
||||||
|
int num = _ownsAllocation ? 1 : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public uint Size => _size;
|
||||||
|
|
||||||
|
public uint CurrentOffset
|
||||||
|
{
|
||||||
|
get => _offset;
|
||||||
|
set => _offset = value <= _size ? value : throw new Exception("Invalid offset");
|
||||||
|
}
|
||||||
|
|
||||||
|
public unsafe IntPtr CurrentAddress => new IntPtr(_buffer + (int)_offset);
|
||||||
|
|
||||||
|
public void MarkAsInFixedMemory() => _inFixedMemory = true;
|
||||||
|
|
||||||
|
public bool IsInFixedMemory => _inFixedMemory;
|
||||||
|
|
||||||
|
public bool ReadBool() => ReadByte() != 0;
|
||||||
|
|
||||||
|
public unsafe byte ReadByte()
|
||||||
|
{
|
||||||
|
if (_offset >= _size)
|
||||||
|
ThrowReadError();
|
||||||
|
byte num = _buffer[(int)_offset];
|
||||||
|
++_offset;
|
||||||
|
return num;
|
||||||
|
}
|
||||||
|
|
||||||
|
public char ReadChar() => (char)ReadUInt16();
|
||||||
|
|
||||||
|
public unsafe ushort ReadUInt16()
|
||||||
|
{
|
||||||
|
if (_offset + 2U > _size)
|
||||||
|
ThrowReadError();
|
||||||
|
byte* numPtr = _buffer + (int)_offset;
|
||||||
|
byte num1 = *numPtr;
|
||||||
|
byte num2 = numPtr[1];
|
||||||
|
_offset += 2U;
|
||||||
|
return (ushort)(num1 | (uint)num2 << 8);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int ReadInt32() => (int)ReadUInt32();
|
||||||
|
|
||||||
|
public unsafe uint ReadUInt32()
|
||||||
|
{
|
||||||
|
if (_offset + 4U > _size)
|
||||||
|
ThrowReadError();
|
||||||
|
byte* numPtr = _buffer + (int)_offset;
|
||||||
|
byte num1 = *numPtr;
|
||||||
|
byte num2 = numPtr[1];
|
||||||
|
byte num3 = numPtr[2];
|
||||||
|
byte num4 = numPtr[3];
|
||||||
|
_offset += 4U;
|
||||||
|
return (uint)(num1 | num2 << 8 | num3 << 16 | num4 << 24);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static unsafe ushort ReadUInt16(IntPtr pData)
|
||||||
|
{
|
||||||
|
byte* pointer = (byte*)pData.ToPointer();
|
||||||
|
return (ushort)(*pointer | (uint)pointer[1] << 8);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static unsafe uint ReadUInt32(IntPtr pData)
|
||||||
|
{
|
||||||
|
byte* pointer = (byte*)pData.ToPointer();
|
||||||
|
return (uint)(*pointer | pointer[1] << 8 | pointer[2] << 16 | pointer[3] << 24);
|
||||||
|
}
|
||||||
|
|
||||||
|
public long ReadInt64() => (long)ReadUInt64();
|
||||||
|
|
||||||
|
public unsafe ulong ReadUInt64()
|
||||||
|
{
|
||||||
|
if (_offset + 8U > _size)
|
||||||
|
ThrowReadError();
|
||||||
|
byte* numPtr = _buffer + (int)_offset;
|
||||||
|
byte num1 = *numPtr;
|
||||||
|
byte num2 = numPtr[1];
|
||||||
|
byte num3 = numPtr[2];
|
||||||
|
byte num4 = numPtr[3];
|
||||||
|
byte num5 = numPtr[4];
|
||||||
|
byte num6 = numPtr[5];
|
||||||
|
byte num7 = numPtr[6];
|
||||||
|
byte num8 = numPtr[7];
|
||||||
|
_offset += 8U;
|
||||||
|
uint num9 = (uint)(num1 | num2 << 8 | num3 << 16 | num4 << 24);
|
||||||
|
return (ulong)(uint)(num5 | num6 << 8 | num7 << 16 | num8 << 24) << 32 | num9;
|
||||||
|
}
|
||||||
|
|
||||||
|
//public unsafe float ReadSingle() => *(float*)&ReadUInt32();
|
||||||
|
public unsafe float ReadSingle() => BitConverter.ToSingle(BitConverter.GetBytes(ReadUInt32()), 0);
|
||||||
|
|
||||||
|
//public unsafe double ReadDouble() => *(double*)&ReadInt64();
|
||||||
|
public unsafe double ReadDouble() => BitConverter.ToSingle(BitConverter.GetBytes(ReadUInt64()), 0);
|
||||||
|
|
||||||
|
public unsafe string ReadString()
|
||||||
|
{
|
||||||
|
uint num1 = ReadUInt16();
|
||||||
|
if (num1 == ushort.MaxValue)
|
||||||
|
return null;
|
||||||
|
bool flag;
|
||||||
|
uint num2;
|
||||||
|
if (((int)num1 & 32768) != 0)
|
||||||
|
{
|
||||||
|
flag = true;
|
||||||
|
num1 &= (uint)short.MaxValue;
|
||||||
|
num2 = num1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
flag = false;
|
||||||
|
num2 = num1 * 2U;
|
||||||
|
}
|
||||||
|
if (_offset + num2 > _size)
|
||||||
|
ThrowReadError();
|
||||||
|
char[] chArray = num1 >= s_scratchCharArray.Length ? new char[num1] : ByteCodeReader.s_scratchCharArray;
|
||||||
|
byte* numPtr1 = _buffer + (int)_offset;
|
||||||
|
if (flag)
|
||||||
|
{
|
||||||
|
for (int index = 0; index < num1; ++index)
|
||||||
|
chArray[index] = (char)*numPtr1++;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for (int index = 0; index < num1; ++index)
|
||||||
|
{
|
||||||
|
byte* numPtr2 = numPtr1;
|
||||||
|
byte* numPtr3 = numPtr2 + 1;
|
||||||
|
byte num3 = *numPtr2;
|
||||||
|
byte* numPtr4 = numPtr3;
|
||||||
|
numPtr1 = numPtr4 + 1;
|
||||||
|
byte num4 = *numPtr4;
|
||||||
|
chArray[index] = (char)(num3 | (uint)num4 << 8);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_offset += num2;
|
||||||
|
return new string(chArray, 0, (int)num1);
|
||||||
|
}
|
||||||
|
|
||||||
|
public unsafe IntPtr ToIntPtr(out uint size)
|
||||||
|
{
|
||||||
|
size = _size;
|
||||||
|
return new IntPtr(_buffer);
|
||||||
|
}
|
||||||
|
|
||||||
|
public unsafe IntPtr GetAddress(uint offset) => new IntPtr(_buffer + (int)offset);
|
||||||
|
|
||||||
|
private void ThrowReadError() => throw new Exception("Attempted to read past the end of the buffer.");
|
||||||
|
|
||||||
|
protected override unsafe void OnDispose()
|
||||||
|
{
|
||||||
|
base.OnDispose();
|
||||||
|
if (_ownsAllocation)
|
||||||
|
NativeApi.MemFree(new IntPtr(_buffer));
|
||||||
|
_buffer = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -153,7 +153,7 @@ namespace Microsoft.Iris.Markup
|
|||||||
|
|
||||||
public unsafe void Write(ByteCodeReader value, uint offset)
|
public unsafe void Write(ByteCodeReader value, uint offset)
|
||||||
{
|
{
|
||||||
IntPtr intPtr = value.ToIntPtr(out long size);
|
IntPtr intPtr = value.ToIntPtr(out uint size);
|
||||||
if (offset > size)
|
if (offset > size)
|
||||||
throw new ArgumentOutOfRangeException(nameof(offset));
|
throw new ArgumentOutOfRangeException(nameof(offset));
|
||||||
this.Write(new IntPtr(intPtr.ToInt64() + offset), (uint)(size - offset));
|
this.Write(new IntPtr(intPtr.ToInt64() + offset), (uint)(size - offset));
|
||||||
|
|||||||
@@ -542,7 +542,8 @@ namespace Microsoft.Iris.Markup
|
|||||||
if (this._reader.IsInFixedMemory)
|
if (this._reader.IsInFixedMemory)
|
||||||
{
|
{
|
||||||
typeExport.SetAddressOfInheritableSymbolTable(this._reader.CurrentAddress);
|
typeExport.SetAddressOfInheritableSymbolTable(this._reader.CurrentAddress);
|
||||||
this._reader.CurrentOffset += this._reader.ReadUInt32();
|
uint num = this._reader.ReadUInt32();
|
||||||
|
this._reader.CurrentOffset += num;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
DecodeInheritableSymbolTable(typeExport, this._reader, IntPtr.Zero);
|
DecodeInheritableSymbolTable(typeExport, this._reader, IntPtr.Zero);
|
||||||
|
|||||||
@@ -91,10 +91,10 @@ namespace Microsoft.Iris.Markup
|
|||||||
ErrorManager.ReportError("Unable to open output file '{0}'. Error code {1}", outputFile, Marshal.GetLastWin32Error());
|
ErrorManager.ReportError("Unable to open output file '{0}'. Error code {1}", outputFile, Marshal.GetLastWin32Error());
|
||||||
if (!watermark.ErrorsDetected)
|
if (!watermark.ErrorsDetected)
|
||||||
{
|
{
|
||||||
long size = 0;
|
uint size = 0;
|
||||||
IntPtr intPtr = reader.ToIntPtr(out size);
|
IntPtr intPtr = reader.ToIntPtr(out size);
|
||||||
uint lpNumberOfBytesWritten = 0;
|
uint lpNumberOfBytesWritten = 0;
|
||||||
if (!Win32Api.WriteFile(file, intPtr, (uint)size, out lpNumberOfBytesWritten, IntPtr.Zero))
|
if (!Win32Api.WriteFile(file, intPtr, size, out lpNumberOfBytesWritten, IntPtr.Zero))
|
||||||
ErrorManager.ReportError("An error occurred while saving data to output file '{0}'. Error code {1}", outputFile, Marshal.GetLastWin32Error());
|
ErrorManager.ReportError("An error occurred while saving data to output file '{0}'. Error code {1}", outputFile, Marshal.GetLastWin32Error());
|
||||||
}
|
}
|
||||||
if (file != Win32Api.INVALID_HANDLE_VALUE)
|
if (file != Win32Api.INVALID_HANDLE_VALUE)
|
||||||
@@ -487,7 +487,7 @@ namespace Microsoft.Iris.Markup
|
|||||||
{
|
{
|
||||||
this._writer.Overwrite(this._objectSectionStartFixup, this._writer.DataSize);
|
this._writer.Overwrite(this._objectSectionStartFixup, this._writer.DataSize);
|
||||||
this._writer.Write(this._loadResult.ObjectSection);
|
this._writer.Write(this._loadResult.ObjectSection);
|
||||||
this._loadResult.ObjectSection.ToIntPtr(out long _);
|
this._loadResult.ObjectSection.ToIntPtr(out uint _);
|
||||||
this._writer.Overwrite(this._objectSectionEndFixup, this._writer.DataSize);
|
this._writer.Overwrite(this._objectSectionEndFixup, this._writer.DataSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -31,16 +31,16 @@ namespace Microsoft.Iris.Markup
|
|||||||
{
|
{
|
||||||
DynamicMethod dynamicMethod = new DynamicMethod("MethodInvoker", typeof(object), new Type[2]
|
DynamicMethod dynamicMethod = new DynamicMethod("MethodInvoker", typeof(object), new Type[2]
|
||||||
{
|
{
|
||||||
typeof (object),
|
typeof (object),
|
||||||
typeof (object[])
|
typeof (object[])
|
||||||
}, s_irisModule, true);
|
}, s_irisModule, true);
|
||||||
ILGenerator ilGenerator = dynamicMethod.GetILGenerator();
|
ILGenerator ilGenerator = dynamicMethod.GetILGenerator();
|
||||||
ParameterInfo[] parameters = methodBase.GetParameters();
|
ParameterInfo[] parameters = methodBase.GetParameters();
|
||||||
Type[] typeArray = new Type[parameters.Length];
|
Type[] typeArray = new Type[parameters.Length];
|
||||||
for (int index = 0; index < parameters.Length; ++index)
|
for (int index = 0; index < parameters.Length; ++index)
|
||||||
typeArray[index] = parameters[index].ParameterType;
|
typeArray[index] = parameters[index].ParameterType;
|
||||||
MethodInfo methodInfo = null;
|
MethodInfo methodInfo = methodBase as MethodInfo;
|
||||||
if (methodBase is MethodInfo && !methodInfo.IsStatic)
|
if (methodInfo != null && !methodInfo.IsStatic)
|
||||||
{
|
{
|
||||||
methodInfo = (MethodInfo)methodBase;
|
methodInfo = (MethodInfo)methodBase;
|
||||||
ilGenerator.Emit(OpCodes.Ldarg_0);
|
ilGenerator.Emit(OpCodes.Ldarg_0);
|
||||||
|
|||||||
+4
-4
@@ -40,6 +40,10 @@
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Reference Include="System" />
|
<Reference Include="System" />
|
||||||
<Reference Include="System.Xml" />
|
<Reference Include="System.Xml" />
|
||||||
|
<Reference Include="UIXcontrols, Version=4.8.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||||
|
<SpecificVersion>False</SpecificVersion>
|
||||||
|
<HintPath>C:\Program Files\Zune\UIXcontrols.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
<Reference Include="ZuneDBApi">
|
<Reference Include="ZuneDBApi">
|
||||||
<HintPath>lib\ZuneDBApi.dll</HintPath>
|
<HintPath>lib\ZuneDBApi.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
@@ -869,10 +873,6 @@
|
|||||||
<Compile Include="AssemblyInfo.cs" />
|
<Compile Include="AssemblyInfo.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="UIXControls\UIXControls.csproj">
|
|
||||||
<Project>{56ae007d-b441-4294-8582-d5c63cc1c206}</Project>
|
|
||||||
<Name>UIXControls</Name>
|
|
||||||
</ProjectReference>
|
|
||||||
<ProjectReference Include="UIX\UIX.csproj">
|
<ProjectReference Include="UIX\UIX.csproj">
|
||||||
<Project>{5681a1bd-b3ec-450b-bf6e-38187204b6be}</Project>
|
<Project>{5681a1bd-b3ec-450b-bf6e-38187204b6be}</Project>
|
||||||
<Name>UIX</Name>
|
<Name>UIX</Name>
|
||||||
|
|||||||
Reference in New Issue
Block a user