Introduces ApplicationFinder (by name/title/handle), Magic.Open overloads, and Magic.Threads/Regions/QueryRegion accessors. Closes section 3 of add-thread-region-finder and updates tasks/comparison doc.
45 lines
1.1 KiB
C#
45 lines
1.1 KiB
C#
using System.Linq;
|
|
using WhiteMagic;
|
|
using WhiteMagic.Memory;
|
|
using WhiteMagic.Native;
|
|
using WhiteMagic.Thread;
|
|
using Xunit;
|
|
|
|
namespace WhiteMagicTest;
|
|
|
|
/// <summary>
|
|
/// Tests for the convenience accessors exposed directly on <see cref="Magic"/>.
|
|
/// </summary>
|
|
public sealed class MagicFacadeTests
|
|
{
|
|
[Fact]
|
|
public void QueryRegion_returns_region_containing_image_base()
|
|
{
|
|
using var magic = Magic.OpenInProcess();
|
|
MemoryRegion region = magic.QueryRegion(magic.Memory.ImageBase);
|
|
Assert.True(region.Contains(magic.Memory.ImageBase));
|
|
}
|
|
|
|
[Fact]
|
|
public void Regions_enumerates_region_containing_image_base()
|
|
{
|
|
using var magic = Magic.OpenInProcess();
|
|
|
|
bool found = magic.Regions.Any(r => r.Contains(magic.Memory.ImageBase));
|
|
|
|
Assert.True(found);
|
|
}
|
|
|
|
[Fact]
|
|
public void Threads_factory_enumerates_current_thread()
|
|
{
|
|
using var magic = Magic.OpenInProcess();
|
|
ThreadFactory factory = magic.Threads;
|
|
|
|
int currentOsId = (int)NativeMethods.GetCurrentThreadId();
|
|
bool found = factory.Enumerate().Any(t => t.Id == currentOsId);
|
|
|
|
Assert.True(found);
|
|
}
|
|
}
|