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>
70 lines
1.7 KiB
C#
70 lines
1.7 KiB
C#
using System;
|
|
using System.Runtime.InteropServices;
|
|
using Decal.Interop.Dat;
|
|
|
|
namespace Decal.DecalDat
|
|
{
|
|
[ComVisible(true)]
|
|
[Guid("9F7F6CD9-D164-418D-8CB5-3B9ACD70BEAF")]
|
|
[ClassInterface(ClassInterfaceType.None)]
|
|
[ProgId("DecalDat.DatStream")]
|
|
public class DatStreamImpl : IDatStream
|
|
{
|
|
private DatFileEntry _file;
|
|
|
|
internal void Load(DatFileEntry file)
|
|
{
|
|
_file = file;
|
|
}
|
|
|
|
public int Size => _file?.Size ?? 0;
|
|
|
|
public int Tell => _file?.Tell ?? 0;
|
|
|
|
public void Skip(int Bytes)
|
|
{
|
|
_file?.Skip(Bytes);
|
|
}
|
|
|
|
public void Restart()
|
|
{
|
|
_file?.Reset();
|
|
}
|
|
|
|
public void ReadBinary(int Bytes, ref byte Buffer)
|
|
{
|
|
if (_file == null) return;
|
|
|
|
var buf = new byte[Bytes];
|
|
_file.Read(buf, 0, Bytes);
|
|
|
|
// Copy to unmanaged buffer starting at ref Buffer
|
|
Marshal.Copy(buf, 0, GetBufferPtr(ref Buffer), Bytes);
|
|
}
|
|
|
|
public string Read(int Bytes)
|
|
{
|
|
if (_file == null) return string.Empty;
|
|
|
|
var buf = new byte[Bytes];
|
|
int read = _file.Read(buf, 0, Bytes);
|
|
|
|
// Return as binary BSTR (same as SysAllocStringByteLen in C++)
|
|
unsafe
|
|
{
|
|
fixed (byte* p = buf)
|
|
{
|
|
return Marshal.PtrToStringAnsi(new IntPtr(p), read);
|
|
}
|
|
}
|
|
}
|
|
|
|
private static unsafe IntPtr GetBufferPtr(ref byte buffer)
|
|
{
|
|
fixed (byte* p = &buffer)
|
|
{
|
|
return new IntPtr(p);
|
|
}
|
|
}
|
|
}
|
|
}
|