// Copyright (C) 2026 SharpEmu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later namespace SharpEmu.HLE.Host; /// /// Host page-allocation primitives used by the native execution engine. /// Allocate/Reserve/Commit are deliberately separate members (rather than a /// flags parameter) so every call site maps 1:1 onto the exact native call it /// replaced, keeping the Windows behavior byte-for-byte identical. /// public interface IHostMemory { /// /// Reserves and commits pages in one step. of 0 /// lets the OS choose the address. Returns the base address, or 0 on failure. /// The OS may satisfy the request at a different address than desired; callers /// that require an exact placement must check the result themselves. /// ulong Allocate(ulong desiredAddress, ulong size, HostPageProtection protection); /// Reserves address space without committing pages (lazy regions). ulong Reserve(ulong desiredAddress, ulong size, HostPageProtection protection); /// Commits pages inside a previously reserved range (fault-path lazy commit). bool Commit(ulong address, ulong size, HostPageProtection protection); /// Releases an entire allocation or reservation by its base address. bool Free(ulong address); /// /// Changes protection on committed pages. is the /// untranslated previous OS protection value (see ). /// bool Protect(ulong address, ulong size, HostPageProtection protection, out uint rawOldProtection); /// /// Restores a raw protection value previously returned by or /// on this same platform. Raw values are opaque to callers and /// must never cross platforms; this exists so save/restore protection sequences /// round-trip OS-specific modifier bits the neutral enum cannot represent. /// bool ProtectRaw(ulong address, ulong size, uint rawProtection, out uint rawOldProtection); bool Query(ulong address, out HostRegionInfo info); void FlushInstructionCache(ulong address, ulong size); }