Skip to content
This repository was archived by the owner on Feb 24, 2026. It is now read-only.

Commit 865eb6b

Browse files
committed
Refactor search context struct; add MemSearch cancel tests
Refactored VMMDLL_MEM_SEARCH_CONTEXT to use a fixed-size filler array and removed explicit struct packing. Added unit tests to verify that MemSearch methods correctly throw OperationCanceledException when a canceled CancellationToken is provided.
1 parent c202b6e commit 865eb6b

2 files changed

Lines changed: 15 additions & 3 deletions

File tree

src/VmmSharpEx/Internal/Vmmi.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -885,12 +885,11 @@ public struct VMMDLL_MEM_SEARCH_CONTEXT_SEARCHENTRY
885885
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
886886
public delegate bool SearchResultCallback(VMMDLL_MEM_SEARCH_CONTEXT ctx, ulong va, uint iSearch);
887887

888-
[StructLayout(LayoutKind.Sequential, Pack = 8)]
888+
[StructLayout(LayoutKind.Sequential)]
889889
public unsafe struct VMMDLL_MEM_SEARCH_CONTEXT
890890
{
891891
public uint dwVersion;
892-
private readonly uint _Filler01;
893-
private readonly uint _Filler02;
892+
private fixed uint _filler[2];
894893
public int fAbortRequested;
895894
public uint cMaxResult;
896895
public uint cSearch;

src/VmmSharpEx_Tests/CI/VmmSharpEx_VmmSearchTests.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,4 +119,17 @@ public void VmmSearch_EmptySearch()
119119
Assert.False(result.IsSuccess);
120120
Assert.Empty(result.Results);
121121
}
122+
123+
[Fact]
124+
public async Task VmmSearch_Cancellation()
125+
{
126+
using var cts = new CancellationTokenSource();
127+
cts.Cancel();
128+
129+
Assert.Throws<OperationCanceledException>(() =>
130+
_vmm.MemSearch(_pid, Array.Empty<VmmSearch.SearchItem>(), ct: cts.Token));
131+
132+
await Assert.ThrowsAsync<OperationCanceledException>(() =>
133+
_vmm.MemSearchAsync(_pid, Array.Empty<VmmSearch.SearchItem>(), ct: cts.Token));
134+
}
122135
}

0 commit comments

Comments
 (0)