openDecal/Managed/Decal.Adapter/Decal.Adapter.Wrappers/DecalWrapper.cs
erik d1442e3747 Initial commit: Complete open-source Decal rebuild
All 5 phases of the open-source Decal rebuild:

Phase 1: 14 decompiled .NET projects (Interop.*, Adapter, FileService, DecalUtil)
Phase 2: 10 native DLLs rewritten as C# COM servers with matching GUIDs
  - DecalDat, DHS, SpellFilter, DecalInput, DecalNet, DecalFilters
  - Decal.Core, DecalControls, DecalRender, D3DService
Phase 3: C++ shims for Inject.DLL (D3D9 hooking) and LauncherHook.DLL
Phase 4: DenAgent WinForms tray application
Phase 5: WiX installer and build script

25 C# projects building with 0 errors.
Native C++ projects require VS 2022 + Windows SDK (x86).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-08 18:27:56 +01:00

84 lines
1.6 KiB
C#

using System;
using System.ComponentModel;
using System.Runtime.InteropServices;
using Decal.Adapter.Support;
using Decal.Interop.Core;
namespace Decal.Adapter.Wrappers;
[CLSCompliant(true)]
public class DecalWrapper : MarshalByRefObject, IDisposable
{
internal static Guid IID_IDISPATCH = new Guid("{00020400-0000-0000-C000-000000000046}");
internal static Guid IID_IUNKNOWN = new Guid("{00000000-0000-0000-C000-000000000046}");
private DecalCore myDecal;
private bool isDisposed;
[CLSCompliant(false)]
[EditorBrowsable(EditorBrowsableState.Never)]
public DecalCore Underlying => myDecal;
public IntPtr Hwnd => new IntPtr(myDecal.HWND);
public bool Focus => myDecal.Focus;
internal DecalWrapper(DecalCore decal)
{
myDecal = decal;
}
~DecalWrapper()
{
Dispose(disposing: false);
}
public void Dispose()
{
Dispose(disposing: true);
GC.SuppressFinalize(this);
}
private void Dispose(bool disposing)
{
if (!isDisposed)
{
}
if (myDecal != null)
{
Marshal.ReleaseComObject(myDecal);
myDecal = null;
}
isDisposed = true;
}
public object GetObject(string path)
{
return GetObject(path, IID_IDISPATCH);
}
public object GetObject(string path, string iid)
{
return GetObject(path, new Guid(iid));
}
public object GetObject(string path, Guid iid)
{
try
{
return ((dynamic)(IDecalCore)myDecal).get_Object(path, ref iid);
}
catch (Exception ex)
{
Util.WriteLine("Exception for {0} during get_Object: {1}", path, ex);
return null;
}
}
public string MapPath(string path)
{
return myDecal.MapPath(path);
}
}