Files
whitemagic/WhiteMagicTest/ThreadEnvironment/ManagedTebTests.cs
T
kbe 3f0bea6bd4 Implement core diagnostic memory layer, execution helpers, and high-level facade slices
Implemented:
- Core: UTF-16 ReadString boundary/alignment fix, target bitness and process id on MemoryBase
- function interception: PatchManager, DetourManager, InstructionAnalyzer, MainThreadDispatcher
- Execution: BackgroundTaskExecutor, InProcessInvoker
- High-level: Magic facade, RemotePointer, async wrappers
- Discovery/external code loading/Window groundwork (PEB/TEB, pattern scanning, raw allocations, DLL external code loading, window/input)

Tests: 180 passing, 4 integration/interactive tests skipped.
2026-07-21 23:43:14 +02:00

24 lines
755 B
C#

using WhiteMagic;
using WhiteMagic.Native;
using WhiteMagic.ThreadEnvironment;
using Xunit;
namespace WhiteMagicTest.ThreadEnvironment;
public sealed class ManagedTebTests
{
[Fact]
public void Read_current_thread_teb_fields_returns_plausible_values()
{
using var magic = Magic.OpenInProcess();
using var teb = new ManagedTeb(magic.Memory, (int)NativeMethods.GetCurrentThreadId());
Assert.NotEqual(IntPtr.Zero, teb.ReadTebAddress());
Assert.NotEqual(IntPtr.Zero, teb.ReadStackBase());
Assert.NotEqual(IntPtr.Zero, teb.ReadStackLimit());
// The stack grows down, so the base is above the limit on x86/x64.
Assert.True((nuint)teb.ReadStackBase() > (nuint)teb.ReadStackLimit());
}
}