Added UIX library

This commit is contained in:
Yoshi Askharoun
2021-07-12 00:40:39 -05:00
parent c2a463bd0e
commit dd63b8d273
962 changed files with 116709 additions and 3 deletions
@@ -0,0 +1,18 @@
// Decompiled with JetBrains decompiler
// Type: Microsoft.Iris.OS.CLR.NativeMethods
// Assembly: UIX, Version=4.8.0.0, Culture=neutral, PublicKeyToken=ddd0da4d3e678217
// MVID: A56C6C9D-B7F6-46A9-8BDE-B3D9B8D60B11
// Assembly location: C:\Program Files\Zune\UIX.dll
using System.Security.Permissions;
namespace Microsoft.Iris.OS.CLR
{
[HostProtection(SecurityAction.LinkDemand, MayLeakOnAbort = true)]
internal static class NativeMethods
{
public const int S_OK = 0;
public const int E_ABORT = -2147467260;
public const int E_NOTIMPL = -2147467263;
}
}
@@ -0,0 +1,120 @@
// Decompiled with JetBrains decompiler
// Type: Microsoft.Iris.OS.CLR.StandardOleMarshalObject
// Assembly: UIX, Version=4.8.0.0, Culture=neutral, PublicKeyToken=ddd0da4d3e678217
// MVID: A56C6C9D-B7F6-46A9-8BDE-B3D9B8D60B11
// Assembly location: C:\Program Files\Zune\UIX.dll
using System;
using System.Runtime.InteropServices;
using System.Security.Permissions;
namespace Microsoft.Iris.OS.CLR
{
[ComVisible(true)]
public class StandardOleMarshalObject : MarshalByRefObject, UnsafeNativeMethods.IMarshal
{
protected StandardOleMarshalObject()
{
}
[SecurityPermission(SecurityAction.Demand, Flags = SecurityPermissionFlag.UnmanagedCode)]
private IntPtr GetStdMarshaller(ref Guid riid, int dwDestContext, int mshlflags)
{
IntPtr ppMarshal = IntPtr.Zero;
IntPtr iunknownForObject = Marshal.GetIUnknownForObject(this);
if (iunknownForObject != IntPtr.Zero)
{
try
{
if (UnsafeNativeMethods.CoGetStandardMarshal(ref riid, iunknownForObject, dwDestContext, IntPtr.Zero, mshlflags, out ppMarshal) == 0)
return ppMarshal;
}
finally
{
Marshal.Release(iunknownForObject);
}
}
throw new InvalidOperationException();
}
[SecurityPermission(SecurityAction.Demand, Flags = SecurityPermissionFlag.UnmanagedCode)]
int UnsafeNativeMethods.IMarshal.GetUnmarshalClass(
ref Guid riid,
IntPtr pv,
int dwDestContext,
IntPtr pvDestContext,
int mshlflags,
out Guid pCid)
{
pCid = typeof(UnsafeNativeMethods.IStdMarshal).GUID;
return 0;
}
[SecurityPermission(SecurityAction.Demand, Flags = SecurityPermissionFlag.UnmanagedCode)]
int UnsafeNativeMethods.IMarshal.GetMarshalSizeMax(
ref Guid riid,
IntPtr pv,
int dwDestContext,
IntPtr pvDestContext,
int mshlflags,
out int pSize)
{
Guid riid1 = riid;
IntPtr stdMarshaller = GetStdMarshaller(ref riid1, dwDestContext, mshlflags);
try
{
return UnsafeNativeMethods.CoGetMarshalSizeMax(out pSize, ref riid1, stdMarshaller, dwDestContext, pvDestContext, mshlflags);
}
finally
{
Marshal.Release(stdMarshaller);
}
}
[SecurityPermission(SecurityAction.Demand, Flags = SecurityPermissionFlag.UnmanagedCode)]
int UnsafeNativeMethods.IMarshal.MarshalInterface(
object pStm,
ref Guid riid,
IntPtr pv,
int dwDestContext,
IntPtr pvDestContext,
int mshlflags)
{
Guid riid1 = riid;
IntPtr stdMarshaller = GetStdMarshaller(ref riid1, dwDestContext, mshlflags);
try
{
return UnsafeNativeMethods.CoMarshalInterface(pStm, ref riid1, stdMarshaller, dwDestContext, pvDestContext, mshlflags);
}
finally
{
Marshal.Release(stdMarshaller);
if (pStm != null)
Marshal.ReleaseComObject(pStm);
}
}
[SecurityPermission(SecurityAction.Demand, Flags = SecurityPermissionFlag.UnmanagedCode)]
int UnsafeNativeMethods.IMarshal.UnmarshalInterface(
object pStm,
ref Guid riid,
out IntPtr ppv)
{
ppv = IntPtr.Zero;
if (pStm != null)
Marshal.ReleaseComObject(pStm);
return -2147467263;
}
[SecurityPermission(SecurityAction.Demand, Flags = SecurityPermissionFlag.UnmanagedCode)]
int UnsafeNativeMethods.IMarshal.ReleaseMarshalData(object pStm)
{
if (pStm != null)
Marshal.ReleaseComObject(pStm);
return -2147467263;
}
[SecurityPermission(SecurityAction.Demand, Flags = SecurityPermissionFlag.UnmanagedCode)]
int UnsafeNativeMethods.IMarshal.DisconnectObject(int dwReserved) => -2147467263;
}
}
@@ -0,0 +1,95 @@
// Decompiled with JetBrains decompiler
// Type: Microsoft.Iris.OS.CLR.UnsafeNativeMethods
// Assembly: UIX, Version=4.8.0.0, Culture=neutral, PublicKeyToken=ddd0da4d3e678217
// MVID: A56C6C9D-B7F6-46A9-8BDE-B3D9B8D60B11
// Assembly location: C:\Program Files\Zune\UIX.dll
using System;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Security;
using System.Security.Permissions;
namespace Microsoft.Iris.OS.CLR
{
[SuppressUnmanagedCodeSecurity]
[HostProtection(SecurityAction.LinkDemand, MayLeakOnAbort = true)]
internal static class UnsafeNativeMethods
{
[DllImport("Ole32.dll")]
internal static extern int CoMarshalInterface(
[MarshalAs(UnmanagedType.Interface)] object pStm,
ref Guid riid,
IntPtr pv,
int dwDestContext,
IntPtr pvDestContext,
int mshlflags);
[DllImport("Ole32.dll")]
internal static extern int CoGetStandardMarshal(
ref Guid riid,
IntPtr pv,
int dwDestContext,
IntPtr pvDestContext,
int mshlflags,
out IntPtr ppMarshal);
[DllImport("Ole32.dll")]
internal static extern int CoGetMarshalSizeMax(
out int pulSize,
ref Guid riid,
IntPtr pv,
int dwDestContext,
IntPtr pvDestContext,
int mshlflags);
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
[Guid("00000017-0000-0000-c000-000000000046")]
[ComImport]
internal interface IStdMarshal
{
}
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
[Guid("00000003-0000-0000-C000-000000000046")]
[ComImport]
internal interface IMarshal
{
[MethodImpl(MethodImplOptions.PreserveSig)]
int GetUnmarshalClass(
ref Guid riid,
IntPtr pv,
int dwDestContext,
IntPtr pvDestContext,
int mshlflags,
out Guid pCid);
[MethodImpl(MethodImplOptions.PreserveSig)]
int GetMarshalSizeMax(
ref Guid riid,
IntPtr pv,
int dwDestContext,
IntPtr pvDestContext,
int mshlflags,
out int pSize);
[MethodImpl(MethodImplOptions.PreserveSig)]
int MarshalInterface(
[MarshalAs(UnmanagedType.Interface)] object pStm,
ref Guid riid,
IntPtr pv,
int dwDestContext,
IntPtr pvDestContext,
int mshlflags);
[MethodImpl(MethodImplOptions.PreserveSig)]
int UnmarshalInterface([MarshalAs(UnmanagedType.Interface)] object pStm, ref Guid riid, out IntPtr ppv);
[MethodImpl(MethodImplOptions.PreserveSig)]
int ReleaseMarshalData([MarshalAs(UnmanagedType.Interface)] object pStm);
[MethodImpl(MethodImplOptions.PreserveSig)]
int DisconnectObject(int dwReserved);
}
}
}
+21
View File
@@ -0,0 +1,21 @@
// Decompiled with JetBrains decompiler
// Type: Microsoft.Iris.OS.COMResult
// Assembly: UIX, Version=4.8.0.0, Culture=neutral, PublicKeyToken=ddd0da4d3e678217
// MVID: A56C6C9D-B7F6-46A9-8BDE-B3D9B8D60B11
// Assembly location: C:\Program Files\Zune\UIX.dll
using System.Security;
namespace Microsoft.Iris.OS
{
[SuppressUnmanagedCodeSecurity]
internal static class COMResult
{
public const int S_OK = 0;
public const int S_FALSE = 1;
public const int E_NOTIMPL = -2147467263;
public const int E_FAIL = -2147467259;
public const int E_INVALIDARG = -2147024809;
public const int STG_E_INVALIDFUNCTION = -2147287039;
}
}
+57
View File
@@ -0,0 +1,57 @@
// Decompiled with JetBrains decompiler
// Type: Microsoft.Iris.OS.DataObject
// Assembly: UIX, Version=4.8.0.0, Culture=neutral, PublicKeyToken=ddd0da4d3e678217
// MVID: A56C6C9D-B7F6-46A9-8BDE-B3D9B8D60B11
// Assembly location: C:\Program Files\Zune\UIX.dll
using Microsoft.Iris.RenderAPI;
using System;
using System.Runtime.InteropServices;
namespace Microsoft.Iris.OS
{
internal class DataObject : IDisposable
{
private IntPtr _dataStream;
private string[] _data;
public DataObject(IntPtr dataStream) => _dataStream = dataStream;
public object GetExternalData()
{
object obj = null;
if (_dataStream != IntPtr.Zero)
{
try
{
_data = null;
RendererApi.IFC(new HRESULT(NativeApi.SpExtractDroppedFileNames(_dataStream, new NativeApi.ExtractDroppedFileNamesCallback(ExtractDroppedFileNamesCallback))));
obj = _data;
}
catch (COMException ex)
{
}
}
_data = null;
return obj;
}
private void ExtractDroppedFileNamesCallback(
uint totalCount,
uint currentIndex,
string filename)
{
if (currentIndex == 0U)
_data = new string[totalCount];
_data[currentIndex] = filename;
}
public void Dispose()
{
if (!(_dataStream != IntPtr.Zero))
return;
Marshal.Release(_dataStream);
_dataStream = IntPtr.Zero;
}
}
}
+42
View File
@@ -0,0 +1,42 @@
// Decompiled with JetBrains decompiler
// Type: Microsoft.Iris.OS.DllResource
// Assembly: UIX, Version=4.8.0.0, Culture=neutral, PublicKeyToken=ddd0da4d3e678217
// MVID: A56C6C9D-B7F6-46A9-8BDE-B3D9B8D60B11
// Assembly location: C:\Program Files\Zune\UIX.dll
using Microsoft.Iris.Data;
using System;
namespace Microsoft.Iris.OS
{
internal class DllResource : Resource
{
private string _dll;
private string _identifier;
private IntPtr _buffer;
private uint _length;
internal DllResource(string uri, string dll, string identifier)
: base(uri, true)
{
_dll = dll;
_identifier = identifier;
}
public override string Identifier => _identifier;
protected override void StartAcquisition(bool forceSynchronous)
{
string errorDetails = null;
if (_buffer == IntPtr.Zero && !NativeApi.SpLoadBinaryResource(_dll, _identifier, !DllResources.StaticDllResourcesOnly, out _buffer, out _length))
errorDetails = string.Format("Resource not found: res://{0}!{1}", _dll, _identifier);
NotifyAcquisitionComplete(_buffer, _length, false, errorDetails);
}
protected override void CancelAcquisition()
{
}
public override string ToString() => _dll + "|" + _identifier.ToLowerInvariant();
}
}
@@ -0,0 +1,92 @@
// Decompiled with JetBrains decompiler
// Type: Microsoft.Iris.OS.DllResources
// Assembly: UIX, Version=4.8.0.0, Culture=neutral, PublicKeyToken=ddd0da4d3e678217
// MVID: A56C6C9D-B7F6-46A9-8BDE-B3D9B8D60B11
// Assembly location: C:\Program Files\Zune\UIX.dll
using Microsoft.Iris.Data;
using Microsoft.Iris.Library;
using Microsoft.Iris.Markup;
using Microsoft.Iris.Session;
using System;
using System.Collections.Generic;
using System.IO;
using System.Reflection;
using System.Runtime.InteropServices;
namespace Microsoft.Iris.OS
{
internal class DllResources : IResourceProvider
{
private static DllResources s_instance = new DllResources();
private static bool s_staticDllResourcesOnly = true;
private Dictionary<string, string> _shortNameToFullPath;
private DllResources() => _shortNameToFullPath = new Dictionary<string, string>(InvariantString.OrdinalIgnoreCaseComparer);
public static DllResources Instance => s_instance;
public static bool StaticDllResourcesOnly
{
get => s_staticDllResourcesOnly;
set => s_staticDllResourcesOnly = value;
}
public Resource GetResource(string hierarchicalPart, string uri, bool forceSynchronous)
{
Resource resource = null;
string host;
string identifier;
ParseResource(hierarchicalPart, out host, out identifier);
if (host != null)
{
string fullPath = GetFullPath(host);
if (fullPath != null)
resource = new DllResource(uri, fullPath, identifier);
}
if (resource == null)
ErrorManager.ReportError("Invalid resource uri: '{0}'", uri);
return resource;
}
public string GetFullPath(string moduleName)
{
string str = null;
if (!_shortNameToFullPath.TryGetValue(moduleName, out str))
{
AssemblyName name = null;
try
{
name = new AssemblyName(moduleName);
}
catch (COMException ex)
{
}
catch (IOException ex)
{
}
Assembly assembly = null;
if (name != null)
assembly = AssemblyLoadResult.FindAssembly(name, out Exception _);
str = assembly == null ? moduleName : assembly.Location;
_shortNameToFullPath[moduleName] = str;
}
return str;
}
internal static void ParseResource(string resource, out string host, out string identifier)
{
int length = resource.IndexOf('!');
if (length == -1)
{
host = null;
identifier = resource;
}
else
{
host = resource.Substring(0, length);
identifier = resource.Substring(length + 1);
}
}
}
}
@@ -0,0 +1,90 @@
// Decompiled with JetBrains decompiler
// Type: Microsoft.Iris.OS.FileResource
// Assembly: UIX, Version=4.8.0.0, Culture=neutral, PublicKeyToken=ddd0da4d3e678217
// MVID: A56C6C9D-B7F6-46A9-8BDE-B3D9B8D60B11
// Assembly location: C:\Program Files\Zune\UIX.dll
using Microsoft.Iris.Data;
using System;
namespace Microsoft.Iris.OS
{
internal class FileResource : Resource
{
private string _filePath;
private IntPtr _handle;
private NativeApi.DownloadCompleteHandler _pendingCallback;
public FileResource(string uri, string filePath, bool forceSynchronous)
: base(uri, forceSynchronous)
=> _filePath = filePath;
public override string Identifier => _filePath;
protected override void StartAcquisition(bool forceSynchronous)
{
if (forceSynchronous)
SynchronousDownload();
else
AsynchronousDownload();
}
private void AsynchronousDownload()
{
_pendingCallback = new NativeApi.DownloadCompleteHandler(OnFileDownloadComplete);
int num = (int)NativeApi.SpFileDownload(_filePath, _pendingCallback, IntPtr.Zero, out _handle);
}
private void OnFileDownloadComplete(IntPtr handle, int error, uint length, IntPtr context)
{
IntPtr buffer = IntPtr.Zero;
string errorDetails = null;
if (error == 0)
buffer = NativeApi.DownloadGetBuffer(_handle);
else
errorDetails = string.Format("Failed to complete download from '{0}'", _filePath);
int num = (int)NativeApi.SpDownloadClose(_handle);
_handle = IntPtr.Zero;
_pendingCallback = null;
NotifyAcquisitionComplete(buffer, length, true, errorDetails);
}
private void SynchronousDownload()
{
IntPtr num1 = IntPtr.Zero;
uint num2 = 0;
string errorDetails = null;
IntPtr file = Win32Api.CreateFile(_filePath, 2147483648U, 1U, IntPtr.Zero, 3U, 0U, IntPtr.Zero);
if (file == Win32Api.INVALID_HANDLE_VALUE)
{
errorDetails = string.Format("File not found: '{0}'", _filePath);
}
else
{
num2 = Win32Api.GetFileSize(file, IntPtr.Zero);
if (num2 != uint.MaxValue)
{
num1 = AllocNativeBuffer(num2);
uint lpNumberOfBytesRead;
if (!(num1 == IntPtr.Zero) && (!Win32Api.ReadFile(file, num1, num2, out lpNumberOfBytesRead, IntPtr.Zero) || (int)lpNumberOfBytesRead != (int)num2))
{
FreeNativeBuffer(num1);
num1 = IntPtr.Zero;
}
}
}
if (file != IntPtr.Zero)
Win32Api.CloseHandle(file);
NotifyAcquisitionComplete(num1, num2, true, errorDetails);
}
protected override void CancelAcquisition()
{
if (!(_handle != IntPtr.Zero))
return;
int num = (int)NativeApi.SpDownloadClose(_handle);
_handle = IntPtr.Zero;
_pendingCallback = null;
}
}
}
@@ -0,0 +1,19 @@
// Decompiled with JetBrains decompiler
// Type: Microsoft.Iris.OS.FileResources
// Assembly: UIX, Version=4.8.0.0, Culture=neutral, PublicKeyToken=ddd0da4d3e678217
// MVID: A56C6C9D-B7F6-46A9-8BDE-B3D9B8D60B11
// Assembly location: C:\Program Files\Zune\UIX.dll
using Microsoft.Iris.Data;
namespace Microsoft.Iris.OS
{
internal class FileResources : IResourceProvider
{
private static FileResources s_instance = new FileResources();
public static FileResources Instance => s_instance;
public Resource GetResource(string hierarchicalPart, string uri, bool forceSynchronous) => new FileResource(uri, hierarchicalPart, forceSynchronous);
}
}
@@ -0,0 +1,64 @@
// Decompiled with JetBrains decompiler
// Type: Microsoft.Iris.OS.HttpResource
// Assembly: UIX, Version=4.8.0.0, Culture=neutral, PublicKeyToken=ddd0da4d3e678217
// MVID: A56C6C9D-B7F6-46A9-8BDE-B3D9B8D60B11
// Assembly location: C:\Program Files\Zune\UIX.dll
using Microsoft.Iris.Data;
using System;
namespace Microsoft.Iris.OS
{
internal class HttpResource : Resource
{
private IntPtr _handle;
private NativeApi.DownloadCompleteHandler _pendingCallback;
public HttpResource(string uri, bool forceSynchronous)
: base(uri, forceSynchronous)
{
}
public override string Identifier => _uri;
protected override void StartAcquisition(bool forceSynchronous)
{
_pendingCallback = new NativeApi.DownloadCompleteHandler(OnHttpDownloadComplete);
int num = (int)NativeApi.SpHttpDownload(_uri, _pendingCallback, IntPtr.Zero, out _handle);
}
private void OnHttpDownloadComplete(IntPtr handle, int error, uint length, IntPtr context)
{
IntPtr buffer = IntPtr.Zero;
string errorDetails = null;
switch (error)
{
case 0:
buffer = NativeApi.DownloadGetBuffer(_handle);
break;
case 1:
errorDetails = string.Format("Invalid URI: '{0}'", _uri);
break;
case 2:
errorDetails = string.Format("Unable to connect to web host: '{0}'", _uri);
break;
default:
errorDetails = string.Format("Failed to complete download from '{0}'", _uri);
break;
}
int num = (int)NativeApi.SpDownloadClose(_handle);
_handle = IntPtr.Zero;
_pendingCallback = null;
NotifyAcquisitionComplete(buffer, length, true, errorDetails);
}
protected override void CancelAcquisition()
{
if (!(_handle != IntPtr.Zero))
return;
int num = (int)NativeApi.SpDownloadClose(_handle);
_handle = IntPtr.Zero;
_pendingCallback = null;
}
}
}
@@ -0,0 +1,43 @@
// Decompiled with JetBrains decompiler
// Type: Microsoft.Iris.OS.HttpResources
// Assembly: UIX, Version=4.8.0.0, Culture=neutral, PublicKeyToken=ddd0da4d3e678217
// MVID: A56C6C9D-B7F6-46A9-8BDE-B3D9B8D60B11
// Assembly location: C:\Program Files\Zune\UIX.dll
using Microsoft.Iris.Data;
using Microsoft.Iris.Session;
using System;
namespace Microsoft.Iris.OS
{
internal class HttpResources : IResourceProvider
{
private static HttpResources s_instance = new HttpResources();
private static EventHandler s_activationChangeHandler;
public static void Startup()
{
ResourceManager.Instance.RegisterSource("http", s_instance);
NativeApi.SpHttpStartup();
}
public static void Shutdown()
{
if (s_activationChangeHandler != null)
UISession.Default.Form.ActivationChange -= s_activationChangeHandler;
NativeApi.SpHttpShutdown();
}
private static void OnActivationChanged(object sender, EventArgs args) => NativeApi.SpHttpFlushProxyCache();
public Resource GetResource(string hierarchicalPart, string url, bool forceSynchronous)
{
if (s_activationChangeHandler == null)
{
s_activationChangeHandler = new EventHandler(OnActivationChanged);
UISession.Default.Form.ActivationChange += s_activationChangeHandler;
}
return new HttpResource(url, forceSynchronous);
}
}
}
@@ -0,0 +1,21 @@
// Decompiled with JetBrains decompiler
// Type: Microsoft.Iris.OS.IImeCallbacks
// Assembly: UIX, Version=4.8.0.0, Culture=neutral, PublicKeyToken=ddd0da4d3e678217
// MVID: A56C6C9D-B7F6-46A9-8BDE-B3D9B8D60B11
// Assembly location: C:\Program Files\Zune\UIX.dll
using Microsoft.Iris.RenderAPI;
using System;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
namespace Microsoft.Iris.OS
{
[Guid("A851425E-61FE-4D1A-9680-F2617089F403")]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
internal interface IImeCallbacks
{
[MethodImpl(MethodImplOptions.PreserveSig)]
HRESULT OnImeMessageReceived(uint msg, UIntPtr wParam, UIntPtr lParam);
}
}
@@ -0,0 +1,76 @@
// Decompiled with JetBrains decompiler
// Type: Microsoft.Iris.OS.IRawUIXServices
// Assembly: UIX, Version=4.8.0.0, Culture=neutral, PublicKeyToken=ddd0da4d3e678217
// MVID: A56C6C9D-B7F6-46A9-8BDE-B3D9B8D60B11
// Assembly location: C:\Program Files\Zune\UIX.dll
using Microsoft.Iris.CodeModel.Cpp;
using Microsoft.Iris.RenderAPI;
using System;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
namespace Microsoft.Iris.OS
{
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
[Guid("5DFE83AF-CE94-4f3b-96A5-8B076F4469A4")]
internal interface IRawUIXServices
{
[MethodImpl(MethodImplOptions.PreserveSig)]
void Crash([MarshalAs(UnmanagedType.LPWStr)] string message);
[MethodImpl(MethodImplOptions.PreserveSig)]
HRESULT NotifyChangeForObject(IntPtr nativeObject, uint changedID);
[MethodImpl(MethodImplOptions.PreserveSig)]
unsafe ulong AllocateString(char* value, out int length);
[MethodImpl(MethodImplOptions.PreserveSig)]
unsafe void CopyString(ulong handle, char* target, uint targetSize);
[MethodImpl(MethodImplOptions.PreserveSig)]
unsafe char* PinString(ulong handle);
[MethodImpl(MethodImplOptions.PreserveSig)]
void UnpinString(ulong handle);
[MethodImpl(MethodImplOptions.PreserveSig)]
void ReleaseString(ulong handle);
[MethodImpl(MethodImplOptions.PreserveSig)]
unsafe ulong AllocateImageFromUri([MarshalAs(UnmanagedType.LPWStr)] string uri, NativeApi.IMAGE_DECODE_PARAMS* constructParams);
[MethodImpl(MethodImplOptions.PreserveSig)]
unsafe ulong AllocateImageFromBits(
[MarshalAs(UnmanagedType.LPWStr)] string ID,
NativeApi.UIX_RAW_IMAGE_INFO* imageInfo,
NativeApi.IMAGE_DECODE_PARAMS* decodeParams);
[MethodImpl(MethodImplOptions.PreserveSig)]
unsafe void RemoveCachedImage([MarshalAs(UnmanagedType.LPWStr)] string ID, NativeApi.IMAGE_DECODE_PARAMS* decodeParams);
[MethodImpl(MethodImplOptions.PreserveSig)]
void ReleaseImage(ulong handle);
[MethodImpl(MethodImplOptions.PreserveSig)]
void RegisterDataProvider([MarshalAs(UnmanagedType.LPWStr)] string providerName, IntPtr nativeFactoryCallback);
[MethodImpl(MethodImplOptions.PreserveSig)]
void GetDataMapping([MarshalAs(UnmanagedType.LPWStr)] string providerName, ulong typeHandle, IntPtr nativeCallback);
[MethodImpl(MethodImplOptions.PreserveSig)]
void NotifyChangeForDataObject(
ulong frameworkObjectHandle,
[MarshalAs(UnmanagedType.LPWStr)] string propertyName,
UIXVariant.VariantType variantType);
[MethodImpl(MethodImplOptions.PreserveSig)]
IntPtr GetAppWindowHandle();
[MethodImpl(MethodImplOptions.PreserveSig)]
void ReportError(bool isWarning, [MarshalAs(UnmanagedType.LPWStr)] string message);
[MethodImpl(MethodImplOptions.PreserveSig)]
void LowPriorityDeferredInvoke(IntPtr pfnCallback, IntPtr pvCallbackData);
}
}
@@ -0,0 +1,69 @@
// Decompiled with JetBrains decompiler
// Type: Microsoft.Iris.OS.IRichTextCallbacks
// Assembly: UIX, Version=4.8.0.0, Culture=neutral, PublicKeyToken=ddd0da4d3e678217
// MVID: A56C6C9D-B7F6-46A9-8BDE-B3D9B8D60B11
// Assembly location: C:\Program Files\Zune\UIX.dll
using Microsoft.Iris.Drawing;
using Microsoft.Iris.Render;
using Microsoft.Iris.RenderAPI;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
namespace Microsoft.Iris.OS
{
[Guid("3AC74642-83C9-4548-871E-6A37F600673D")]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
internal interface IRichTextCallbacks
{
[MethodImpl(MethodImplOptions.PreserveSig)]
HRESULT InvalidateContent();
[MethodImpl(MethodImplOptions.PreserveSig)]
HRESULT SelectionChanged(int begin, int end);
[MethodImpl(MethodImplOptions.PreserveSig)]
HRESULT CreateCaret(int width, int height);
[MethodImpl(MethodImplOptions.PreserveSig)]
HRESULT SetCaretPos(int x, int y);
[MethodImpl(MethodImplOptions.PreserveSig)]
HRESULT ShowCaret(bool visible);
[MethodImpl(MethodImplOptions.PreserveSig)]
HRESULT SetCursor(EditCursorType type);
[MethodImpl(MethodImplOptions.PreserveSig)]
HRESULT TextChanged();
[MethodImpl(MethodImplOptions.PreserveSig)]
HRESULT MaxLengthExceeded();
[MethodImpl(MethodImplOptions.PreserveSig)]
HRESULT SetTimer(uint id, uint timeout);
[MethodImpl(MethodImplOptions.PreserveSig)]
HRESULT KillTimer(uint id);
[MethodImpl(MethodImplOptions.PreserveSig)]
HRESULT SetScrollRange(
int whichBar,
int minPosition,
int extent,
int viewExtent,
int scrollPosition);
[MethodImpl(MethodImplOptions.PreserveSig)]
HRESULT EnableScrollbar(int whichBar, ScrollbarEnableFlags value);
[MethodImpl(MethodImplOptions.PreserveSig)]
HRESULT ClientToWindow(Point pt, out Point ppt);
[MethodImpl(MethodImplOptions.PreserveSig)]
HRESULT ClientToScreen(Point pt, out Point ppt);
[MethodImpl(MethodImplOptions.PreserveSig)]
HRESULT LinkClicked(int start, int end);
}
}
@@ -0,0 +1,22 @@
// Decompiled with JetBrains decompiler
// Type: Microsoft.Iris.OS.IUIXListCallbacks
// Assembly: UIX, Version=4.8.0.0, Culture=neutral, PublicKeyToken=ddd0da4d3e678217
// MVID: A56C6C9D-B7F6-46A9-8BDE-B3D9B8D60B11
// Assembly location: C:\Program Files\Zune\UIX.dll
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
namespace Microsoft.Iris.OS
{
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
[Guid("0C0FFEE0-06BB-4DCE-8471-D180BF37002D")]
internal interface IUIXListCallbacks
{
[MethodImpl(MethodImplOptions.PreserveSig)]
void ListChanged(int type, int oldIndex, int newIndex, int count);
[MethodImpl(MethodImplOptions.PreserveSig)]
void SlowDataAcquireComplete(int index);
}
}
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,31 @@
// Decompiled with JetBrains decompiler
// Type: Microsoft.Iris.OS.NativeXmlException
// Assembly: UIX, Version=4.8.0.0, Culture=neutral, PublicKeyToken=ddd0da4d3e678217
// MVID: A56C6C9D-B7F6-46A9-8BDE-B3D9B8D60B11
// Assembly location: C:\Program Files\Zune\UIX.dll
using System;
namespace Microsoft.Iris.OS
{
internal class NativeXmlException : SystemException
{
private uint _hr;
private int _lineNumber;
private int _linePosition;
public NativeXmlException(string message, uint hr, int lineNumber, int linePosition)
: base(message)
{
_hr = hr;
_lineNumber = lineNumber;
_linePosition = linePosition;
}
public uint HR => _hr;
public int LineNumber => _lineNumber;
public int LinePosition => _linePosition;
}
}
@@ -0,0 +1,23 @@
// Decompiled with JetBrains decompiler
// Type: Microsoft.Iris.OS.NativeXmlNodeType
// Assembly: UIX, Version=4.8.0.0, Culture=neutral, PublicKeyToken=ddd0da4d3e678217
// MVID: A56C6C9D-B7F6-46A9-8BDE-B3D9B8D60B11
// Assembly location: C:\Program Files\Zune\UIX.dll
namespace Microsoft.Iris.OS
{
internal enum NativeXmlNodeType
{
None = 0,
Element = 1,
Attribute = 2,
Text = 3,
CDATA = 4,
ProcessingInstruction = 7,
Comment = 8,
DocumentType = 10, // 0x0000000A
Whitespace = 13, // 0x0000000D
EndElement = 15, // 0x0000000F
XmlDeclaration = 17, // 0x00000011
}
}
@@ -0,0 +1,456 @@
// Decompiled with JetBrains decompiler
// Type: Microsoft.Iris.OS.NativeXmlReader
// Assembly: UIX, Version=4.8.0.0, Culture=neutral, PublicKeyToken=ddd0da4d3e678217
// MVID: A56C6C9D-B7F6-46A9-8BDE-B3D9B8D60B11
// Assembly location: C:\Program Files\Zune\UIX.dll
using Microsoft.Iris.Data;
using Microsoft.Iris.Markup;
using System;
using System.Runtime.InteropServices;
namespace Microsoft.Iris.OS
{
internal struct NativeXmlReader : IDisposable
{
private IntPtr _reader;
private GCHandle _gcHandle;
private NativeXmlNodeType _prevNodeType;
private NativeXmlNodeType _curNodeType;
private int _lineNumber;
private int _linePosition;
private bool _beforeFirstAttribute;
public NativeXmlReader(Resource resource)
: this(false)
=> Init(resource.Buffer, (int)resource.Length, false);
public NativeXmlReader(string content, bool isFragment)
: this(false)
{
_gcHandle = GCHandle.Alloc(content, GCHandleType.Pinned);
Init(_gcHandle.AddrOfPinnedObject(), content.Length * 2, isFragment);
}
private NativeXmlReader(bool placeHolder)
{
_lineNumber = -1;
_linePosition = -1;
_beforeFirstAttribute = true;
_reader = IntPtr.Zero;
_gcHandle = new GCHandle();
_curNodeType = NativeXmlNodeType.None;
_prevNodeType = NativeXmlNodeType.None;
}
private void Init(IntPtr buffer, int length, bool isFragment)
{
int xmlReader = (int)NativeApi.SpXmlLiteCreateXmlReader(buffer, length, isFragment, out _reader);
}
public void Dispose()
{
NativeApi.SpXmlLiteDeleteXmlReader(_reader);
_reader = IntPtr.Zero;
if (!_gcHandle.IsAllocated)
return;
_gcHandle.Free();
}
public bool Read(out NativeXmlNodeType nodeType)
{
_beforeFirstAttribute = true;
_lineNumber = InternalLineNumber;
_linePosition = InternalLinePosition;
bool flag = SUCCEEDED(NativeApi.SpXmlLiteRead(_reader, out nodeType));
_prevNodeType = _curNodeType;
_curNodeType = nodeType;
return flag;
}
public bool ReadAttribute()
{
if (_beforeFirstAttribute)
return MoveToFirstAttribute();
bool nextAttribute = MoveToNextAttribute();
if (!nextAttribute)
_beforeFirstAttribute = true;
return nextAttribute;
}
private bool MoveToFirstAttribute()
{
_beforeFirstAttribute = false;
_lineNumber = InternalLineNumber;
_linePosition = InternalLinePosition;
return SUCCEEDED(NativeApi.SpXmlLiteMoveToFirstAttribute(_reader));
}
private bool MoveToNextAttribute()
{
_lineNumber = InternalLineNumber;
_linePosition = InternalLinePosition;
return SUCCEEDED(NativeApi.SpXmlLiteMoveToNextAttribute(_reader));
}
public bool IsEmptyElement => NativeApi.SpXmlLiteIsEmptyElement(_reader);
public string Name
{
get
{
IntPtr name;
uint length;
IFC(NativeApi.SpXmlLiteGetQualifiedName(_reader, out name, out length));
return NativeApi.PtrToStringUni(name, (int)length);
}
}
public string LocalName
{
get
{
IntPtr name;
uint length;
IFC(NativeApi.SpXmlLiteGetLocalName(_reader, out name, out length));
return NativeApi.PtrToStringUni(name, (int)length);
}
}
public string Prefix
{
get
{
IntPtr prefix;
uint length;
IFC(NativeApi.SpXmlLiteGetPrefix(_reader, out prefix, out length));
return NativeApi.PtrToStringUni(prefix, (int)length);
}
}
public string Value
{
get
{
IntPtr psz;
uint length;
IFC(NativeApi.SpXmlLiteGetValue(_reader, out psz, out length));
return NativeApi.PtrToStringUni(psz, (int)length);
}
}
public unsafe bool IsInlineExpression
{
get
{
IntPtr num;
uint length;
IFC(NativeApi.SpXmlLiteGetValue(_reader, out num, out length));
char* pointer = (char*)num.ToPointer();
return length > 0U && *pointer == '{' && pointer[length - 1U] == '}';
}
}
public SSLexUnicodeBufferConsumer LexConsumerForValueWithPrefix(string prefix)
{
IntPtr buffer;
uint length;
IFC(NativeApi.SpXmlLiteGetValue(_reader, out buffer, out length));
SSLexUnicodeBufferConsumer unicodeBufferConsumer = new SSLexUnicodeBufferConsumer(buffer, length, prefix);
int lineNumber = _lineNumber;
int column = _linePosition - prefix.Length + 1;
if (_curNodeType == NativeXmlNodeType.CDATA && _prevNodeType != NativeXmlNodeType.Whitespace)
column += 9;
unicodeBufferConsumer.SetDocumentOffset(lineNumber, column);
return unicodeBufferConsumer;
}
public int LineNumber => _lineNumber;
public int LinePosition => _linePosition;
private int InternalLineNumber
{
get
{
uint lineNumber;
IFC(NativeApi.SpXmlLiteGetLineNumber(_reader, out lineNumber));
return (int)lineNumber;
}
}
private int InternalLinePosition
{
get
{
uint linePosition;
IFC(NativeApi.SpXmlLiteGetLinePosition(_reader, out linePosition));
return (int)linePosition;
}
}
private void IFC(uint hr) => SUCCEEDED(hr);
private bool SUCCEEDED(uint hr)
{
if (hr == 0U)
return true;
if (hr == 1U)
return false;
ThrowXmlException(hr);
return false;
}
private void ThrowXmlException(uint hr)
{
string message = null;
switch (hr)
{
case 3222069277:
message = "Character in character entity is not a decimal digit as was expected.";
break;
case 3222069278:
message = "Character in character entity is not a hexadecimal digit as was expected.";
break;
case 3222069279:
message = "Character entity has invalid Unicode value.";
break;
case 3222072833:
message = "Unexpected end of input";
break;
case 3222072834:
message = "Unrecognized encoding";
break;
case 3222072835:
message = "Unable to switch the encoding";
break;
case 3222072836:
message = "Unrecognized input signature";
break;
case 3222072865:
message = "Whitespace expected";
break;
case 3222072866:
message = "Semicolon expected";
break;
case 3222072867:
message = "'>' expected";
break;
case 3222072868:
message = "Quote expected";
break;
case 3222072869:
message = "Equal expected";
break;
case 3222072870:
message = "Well-formedness constraint: no '<' in attribute value";
break;
case 3222072871:
message = "Hexadecimal digit expected";
break;
case 3222072872:
message = "Decimal digit expected";
break;
case 3222072873:
message = "'[' expected";
break;
case 3222072874:
message = "'(' expected";
break;
case 3222072875:
message = "Illegal xml character";
break;
case 3222072876:
message = "Illegal name character";
break;
case 3222072877:
message = "Incorrect document syntax";
break;
case 3222072878:
message = "Incorrect CDATA section syntax";
break;
case 3222072879:
message = "Incorrect comment syntax";
break;
case 3222072880:
message = "Incorrect conditional section syntax";
break;
case 3222072881:
message = "Incorrect ATTLIST declaration syntax";
break;
case 3222072882:
message = "Incorrect DOCTYPE declaration syntax";
break;
case 3222072883:
message = "Incorrect ELEMENT declaration syntax";
break;
case 3222072884:
message = "Incorrect ENTITY declaration syntax";
break;
case 3222072885:
message = "Incorrect NOTATION declaration syntax";
break;
case 3222072886:
message = "NDATA expected";
break;
case 3222072887:
message = "PUBLIC expected";
break;
case 3222072888:
message = "SYSTEM expected";
break;
case 3222072889:
message = "Name expected";
break;
case 3222072890:
message = "One root element";
break;
case 3222072891:
message = "Well-formedness constraint: element type match";
break;
case 3222072892:
message = "Well-formedness constraint: unique attribute spec";
break;
case 3222072893:
message = "Text/xmldecl not at the beginning of input";
break;
case 3222072894:
message = "Leading \"xml\"";
break;
case 3222072895:
message = "Incorrect text declaration syntax";
break;
case 3222072896:
message = "Incorrect xml declaration syntax";
break;
case 3222072897:
message = "Incorrect encoding name syntax";
break;
case 3222072898:
message = "Incorrect public identifier syntax";
break;
case 3222072899:
message = "Well-formedness constraint: pes in internal subset";
break;
case 3222072900:
message = "Well-formedness constraint: pes between declarations";
break;
case 3222072901:
message = "Well-formedness constraint: no recursion";
break;
case 3222072902:
message = "Entity content not well formed";
break;
case 3222072903:
message = "Well-formedness constraint: undeclared entity ";
break;
case 3222072904:
message = "Well-formedness constraint: parsed entity";
break;
case 3222072905:
message = "Well-formedness constraint: no external entity references";
break;
case 3222072906:
message = "Incorrect processing instruction syntax";
break;
case 3222072907:
message = "Incorrect system identifier syntax";
break;
case 3222072908:
message = "'?' expected";
break;
case 3222072909:
message = "No ']]>' in element content";
break;
case 3222072910:
message = "Not all chunks of value have been read";
break;
case 3222072911:
message = "DTD was found but is prohibited";
break;
case 3222072912:
message = "xml:space attribute with invalid value";
break;
case 3222072929:
message = "Illegal qualified name character";
break;
case 3222072930:
message = "Multiple colons in qualified name";
break;
case 3222072931:
message = "Colon in name";
break;
case 3222072932:
message = "Declared prefix";
break;
case 3222072933:
message = "Undeclared prefix";
break;
case 3222072934:
message = "Non default namespace with empty uri";
break;
case 3222072935:
message = "\"xml\" prefix is reserved and must have the http://www.w3.org/XML/1998/namespace URI";
break;
case 3222072936:
message = "\"xmlns\" prefix is reserved for use by XML";
break;
case 3222072937:
message = "xml namespace URI (http://www.w3.org/XML/1998/namespace) must be assigned only to prefix \"xml\"";
break;
case 3222072938:
message = "xmlns namespace URI (http://www.w3.org/2000/xmlns/) is reserved and must not be used";
break;
case 3222072961:
message = "Element depth exceeds limit in XmlReaderProperty_MaxElementDepth";
break;
case 3222072962:
message = "Entity expansion exceeds limit in XmlReaderProperty_MaxEntityExpansion";
break;
case 3222073089:
message = "Writer: specified string is not whitespace";
break;
case 3222073090:
message = "Writer: namespace prefix is already declared with a different namespace";
break;
case 3222073091:
message = "Writer: It is not allowed to declare a namespace prefix with empty URI (for example xmlns:p=””).";
break;
case 3222073092:
message = "Writer: duplicate attribute";
break;
case 3222073093:
message = "Writer: can not redefine the xmlns prefix";
break;
case 3222073094:
message = "Writer: xml prefix must have the http://www.w3.org/XML/1998/namespace URI";
break;
case 3222073095:
message = "Writer: xml namespace URI (http://www.w3.org/XML/1998/namespace) must be assigned only to prefix \"xml\"";
break;
case 3222073096:
message = "Writer: xmlns namespace URI (http://www.w3.org/2000/xmlns/) is reserved and must not be used";
break;
case 3222073097:
message = "Writer: namespace is not declared";
break;
case 3222073098:
message = "Writer: invalid value of xml:space attribute (allowed values are \"default\" and \"preserve\")";
break;
case 3222073099:
message = "Writer: performing the requested action would result in invalid XML document";
break;
case 3222073100:
message = "Writer: input contains invalid or incomplete surrogate pair";
break;
}
if (message != null)
{
int lineNumber = _reader == IntPtr.Zero ? -1 : InternalLineNumber;
int linePosition = _reader == IntPtr.Zero ? -1 : InternalLinePosition;
throw new NativeXmlException(message, hr, lineNumber, linePosition);
}
throw new NativeXmlException("Unknown error", hr, -1, -1);
}
}
}
+398
View File
@@ -0,0 +1,398 @@
// Decompiled with JetBrains decompiler
// Type: Microsoft.Iris.OS.Win32Api
// Assembly: UIX, Version=4.8.0.0, Culture=neutral, PublicKeyToken=ddd0da4d3e678217
// MVID: A56C6C9D-B7F6-46A9-8BDE-B3D9B8D60B11
// Assembly location: C:\Program Files\Zune\UIX.dll
using Microsoft.Iris.Library;
using System;
using System.ComponentModel;
using System.IO;
using System.Runtime.InteropServices;
using System.Security;
namespace Microsoft.Iris.OS
{
[SuppressUnmanagedCodeSecurity]
internal static class Win32Api
{
public const uint GENERIC_READ = 2147483648;
public const uint GENERIC_WRITE = 1073741824;
public const uint FILE_SHARE_READ = 1;
public const uint CREATE_ALWAYS = 2;
public const uint OPEN_EXISTING = 3;
public const uint INVALID_FILE_SIZE = 4294967295;
public const uint FILE_ATTRIBUTE_NORMAL = 128;
public const uint NONE = 0;
public const uint ERROR_SUCCESS = 0;
private const uint ERROR_FILE_NOT_FOUND = 2;
private const uint ERROR_PATH_NOT_FOUND = 3;
private const uint ERROR_ACCESS_DENIED = 5;
private const uint ERROR_INVALID_HANDLE = 6;
private const uint ERROR_NOT_ENOUGH_MEMORY = 8;
private const uint ERROR_OUTOFMEMORY = 14;
private const uint ERROR_NOT_SUPPORTED = 50;
private const uint ERROR_INVALID_PARAMETER = 87;
private const uint ERROR_CALL_NOT_IMPLEMENTED = 120;
private const uint ERROR_MORE_DATA = 234;
private const uint ERROR_SERVICE_ALREADY_RUNNING = 1056;
private const uint ERROR_NOT_FOUND = 1168;
private const uint ERROR_NO_MATCH = 1169;
private const uint ERROR_SET_NOT_FOUND = 1170;
private const uint ERROR_SERVICE_DATABASE_LOCKED = 1055;
public const int KEY_READ = 131097;
public const int REG_SZ = 1;
public const int REG_DWORD = 4;
public const uint WS_OVERLAPPED = 0;
public const uint WS_POPUP = 2147483648;
public const uint WS_CLIPSIBLINGS = 67108864;
public const uint WS_CLIPCHILDREN = 33554432;
public const uint WS_CAPTION = 12582912;
public const uint WS_BORDER = 8388608;
public const uint WS_SYSMENU = 524288;
public const uint WS_THICKFRAME = 262144;
public const uint WS_MINIMIZEBOX = 131072;
public const uint WS_MAXIMIZEBOX = 65536;
public const uint WS_EX_TOPMOST = 8;
public const uint WS_EX_CONTROLPARENT = 65536;
public const uint WS_EX_APPWINDOW = 262144;
public const uint WS_EX_TOOLWINDOW = 128;
public const uint SW_SHOWNORMAL = 1;
public const uint SW_SHOWMINIMIZED = 2;
public const uint SW_SHOWMAXIMIZED = 3;
public const int KEYEVENTF_KEYUP = 2;
public const uint APPCOMMAND_BROWSER_BACKWARD = 1;
public const uint APPCOMMAND_VOLUME_MUTE = 8;
public const uint APPCOMMAND_VOLUME_DOWN = 9;
public const uint APPCOMMAND_VOLUME_UP = 10;
public const uint APPCOMMAND_MEDIA_NEXTTRACK = 11;
public const uint APPCOMMAND_MEDIA_PREVIOUSTRACK = 12;
public const uint APPCOMMAND_MEDIA_STOP = 13;
public const uint APPCOMMAND_MEDIA_PLAY_PAUSE = 14;
public const uint APPCOMMAND_MEDIA_PLAY = 46;
public const uint APPCOMMAND_MEDIA_PAUSE = 47;
public const uint APPCOMMAND_MEDIA_RECORD = 48;
public const uint APPCOMMAND_MEDIA_FAST_FORWARD = 49;
public const uint APPCOMMAND_MEDIA_REWIND = 50;
public const uint WM_FORWARDMSG = 895;
public const int RT_RCDATA = 10;
public const int RT_HTML = 23;
public const int SM_CXSCREEN = 0;
public const int SM_CYSCREEN = 1;
public const int SM_CXDRAG = 68;
public const int SM_CYDRAG = 69;
public const int SPI_GETMENUDROPALIGNMENT = 27;
public const uint SPI_GETKEYBOARDSPEED = 10;
public const uint SPI_GETKEYBOARDDELAY = 22;
public const uint SPI_GETCARETWIDTH = 8198;
public const int INPUT_KEYBOARD = 1;
public const int LAYOUT_LTR = 0;
public const int LAYOUT_RTL = 1;
public static IntPtr INVALID_HANDLE_VALUE = new IntPtr(-1);
private static readonly string[] s_rgsMessageNames = new string[0];
static Win32Api() => InitMessageDump();
public static void IFWIN32(bool fResult)
{
if (fResult)
return;
uint lastWin32Error = (uint)Marshal.GetLastWin32Error();
switch (lastWin32Error)
{
case 0:
throw new Win32Exception(0, "Generic failure of Win32 function that did not provide error information");
case 2:
case 3:
throw new FileNotFoundException();
case 5:
throw new UnauthorizedAccessException();
case 6:
case 87:
throw new ArgumentException();
case 8:
case 14:
throw new OutOfMemoryException();
case 50:
case 120:
throw new NotImplementedException();
case 1168:
case 1169:
case 1170:
throw new ArgumentOutOfRangeException();
default:
Marshal.ThrowExceptionForHR((int)lastWin32Error & ushort.MaxValue | 458752 | int.MinValue);
break;
}
}
[DllImport("kernel32.dll", SetLastError = true)]
public static extern IntPtr CreateFile(
string lpFileName,
uint dwDesiredAccess,
uint dwShareMode,
IntPtr lpSecurityAttributes,
uint dwCreationDisposition,
uint dwFlagsAndAttributes,
IntPtr hTemplateFile);
[DllImport("kernel32.dll")]
public static extern uint GetFileSize(IntPtr hFile, IntPtr lpFileSizeHigh);
[DllImport("kernel32.dll")]
public static extern bool ReadFile(
IntPtr hFile,
IntPtr lpBuffer,
uint nNumberOfBytesToRead,
out uint lpNumberOfBytesRead,
IntPtr lpOverlapped);
[DllImport("kernel32.dll", SetLastError = true)]
public static extern bool WriteFile(
IntPtr hFile,
IntPtr lpBuffer,
uint nNumberOfBytesToWrite,
out uint lpNumberOfBytesWritten,
IntPtr lpOverlapped);
[DllImport("kernel32.dll")]
public static extern bool CloseHandle(IntPtr hObject);
[DllImport("kernel32.dll")]
public static extern void OutputDebugString(string lpOutputString);
[DllImport("kernel32.dll")]
public static extern bool IsDebuggerPresent();
[DllImport("kernel32.dll")]
public static extern void DebugBreak();
[DllImport("Advapi32.dll", CharSet = CharSet.Unicode)]
public static extern int RegOpenKeyExW(
IntPtr hkey,
string lpSubKey,
int options,
int securityMask,
out IntPtr result);
[DllImport("Advapi32.dll", CharSet = CharSet.Unicode)]
public static extern int RegQueryValueExW(
IntPtr hKey,
string lpValueName,
IntPtr reserved,
out int lpType,
char[] lpData,
ref int lpcbData);
[DllImport("Advapi32.dll", CharSet = CharSet.Unicode)]
public static extern int RegQueryValueExW(
IntPtr hKey,
string lpValueName,
IntPtr reserved,
out int lpType,
out int lpData,
ref int lpcbData);
[DllImport("Advapi32.dll")]
public static extern int RegCloseKey(IntPtr hkey);
[DllImport("user32.dll", CharSet = CharSet.Auto)]
public static extern bool IsClipboardFormatAvailable(uint format);
[DllImport("user32.dll", CharSet = CharSet.Unicode)]
public static extern IntPtr SendMessage(
IntPtr hWnd,
uint Msg,
IntPtr wParam,
IntPtr lParam);
public static string DumpMessage(uint uMsg) => DumpMessageWorker(uMsg) ?? "UNKNOWN MESSAGE";
private static string DumpMessageWorker(uint uMsg)
{
InitMessageDump();
if (uMsg >= s_rgsMessageNames.Length)
return null;
string rgsMessageName = s_rgsMessageNames[uMsg];
if (rgsMessageName != null)
return rgsMessageName;
uint num = uMsg;
while (uMsg > 0U)
{
--num;
rgsMessageName = s_rgsMessageNames[num];
if (rgsMessageName != null)
break;
}
return rgsMessageName == null ? null : InvariantString.Format("{0} + {1}", rgsMessageName, (uint)((int)uMsg - (int)num));
}
private static void InitMessageDump()
{
}
[DllImport("user32.dll")]
public static extern int GetSystemMetrics(int metric);
[DllImport("user32.dll", SetLastError = true)]
public static extern bool SystemParametersInfo(
uint uiAction,
uint uiParam,
out int pParam,
int nWinIni);
[DllImport("user32.dll", SetLastError = true)]
public static extern bool SystemParametersInfo(
uint uiAction,
uint uiParam,
out bool pParam,
int nWinIni);
public static int GetCaretWidth()
{
int pParam;
if (!SystemParametersInfo(8198U, 0U, out pParam, 0))
pParam = 1;
return pParam;
}
[DllImport("user32.dll", SetLastError = true)]
public static extern int GetCaretBlinkTime();
[DllImport("user32.dll")]
public static extern uint SendInput(uint nInputs, Win32Api.INPUT[] pInputs, int cbSize);
public static int GetDefaultKeyDelay()
{
int pParam;
if (!SystemParametersInfo(22U, 0U, out pParam, 0))
pParam = 1;
return (pParam + 1) * 250;
}
public static int GetDefaultKeyRepeat()
{
int pParam;
if (!SystemParametersInfo(10U, 0U, out pParam, 0))
pParam = 1;
return 31000 / (62 + 28 * pParam);
}
public static bool GetMenuDropAlignment()
{
bool pParam;
if (!SystemParametersInfo(27U, 0U, out pParam, 0))
pParam = false;
return pParam;
}
[DllImport("user32.dll")]
public static extern bool GetProcessDefaultLayout(out int pdwDefaultLayout);
[Serializable]
public struct HANDLE
{
public IntPtr h;
public static Win32Api.HANDLE NULL => new Win32Api.HANDLE()
{
h = IntPtr.Zero
};
public static bool operator ==(Win32Api.HANDLE hl, Win32Api.HANDLE hr) => hl.h == hr.h;
public static bool operator !=(Win32Api.HANDLE hl, Win32Api.HANDLE hr) => hl.h != hr.h;
public override bool Equals(object oCompare) => h == (IntPtr)oCompare;
public override int GetHashCode() => (int)h.ToInt64();
}
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
public struct LOGFONTW_STRUCT
{
public const int LF_FACESIZE = 32;
public int lfHeight;
public int lfWidth;
public int lfEscapement;
public int lfOrientation;
public int lfWeight;
public byte lfItalic;
public byte lfUnderline;
public byte lfStrikeOut;
public byte lfCharSet;
public byte lfOutPrecision;
public byte lfClipPrecision;
public byte lfQuality;
public byte lfPitchAndFamily;
public Win32Api.LOGFONTW_STRUCT.FACENAME lfFaceName;
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
public struct FACENAME
{
private char name00;
private char name01;
private char name02;
private char name03;
private char name04;
private char name05;
private char name06;
private char name07;
private char name08;
private char name09;
private char name10;
private char name11;
private char name12;
private char name13;
private char name14;
private char name15;
private char name16;
private char name17;
private char name18;
private char name19;
private char name20;
private char name21;
private char name22;
private char name23;
private char name24;
private char name25;
private char name26;
private char name27;
private char name28;
private char name29;
private char name30;
private char name31;
}
}
public struct MSG
{
public IntPtr hwnd;
public uint message;
public IntPtr wParam;
public IntPtr lParam;
public uint time;
public int pt_x;
public int pt_y;
public override string ToString() => InvariantString.Format("{0} -> {1}, wp=0x{2,0:x} lp=0x{3,0:x}", DumpMessage(message), hwnd, wParam, lParam);
}
public struct KEYBDINPUT
{
public ushort wVk;
public ushort wScan;
public uint dwFlags;
public uint time;
public IntPtr dwExtraInfo;
public uint Padding1;
public uint Padding2;
}
public struct INPUT
{
public int type;
public Win32Api.KEYBDINPUT data;
}
}
}