Add process discovery helpers and Magic facade accessors
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.
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user