Skip to main content

Module declared

Module declared 

Source
Expand description

The declared aspects: WOW64 filesystem redirection, memory priority, and I/O priority.

These are declared, not captured. A declared aspect has nothing to collect from the calling thread, so it is not part of any capture set: the caller states the value it wants installed, and leaving it unspecified means the running thread’s own value is untouched.

§Why each one is declared, and the reasons differ

Stating this per aspect rather than as one blanket claim matters, because the reasons are not the same and only one of them is absolute.

  • WOW64 filesystem redirection has no getter at all. Wow64DisableWow64FsRedirection yields an OldValue only as a side effect of disabling redirection, and there is no way to observe the current state without changing it. An aspect that cannot be read cannot be transplanted; this is a mechanical impossibility, not a preference.
  • Memory priority is readable, through GetThreadInformation(ThreadMemoryPriority), so this one is a choice. Priority is a policy about how work should compete for resources, not something a caller implicitly consents to having remoted – and silently transplanting it is not the safe default either way, since a caller in a background mode would have its remoted work quietly promoted or demoted without saying so.
  • I/O priority has no documented getter, and does not move on its own: it changes only in lockstep with CPU and memory priority, through background mode. So there is no independent value to capture even in principle, and declaring background mode declares all three together, which the type says out loud rather than hiding.

§Redirection only does anything in a 32-bit process

Wow64DisableWow64FsRedirection is meaningful only for a 32-bit process on 64-bit Windows. In a 64-bit process there is no redirector to disable and the call fails. That failure is reported rather than swallowed, because a caller that asked for redirection to be disabled and silently did not get it would be reading a different filesystem than it believes.

§Example

use windows_thread_ambient_sys::Declared;
use windows_thread_ambient_sys::declared::MemoryPriority;

let entry = MemoryPriority::current()?;

// Only what is named is installed; every other aspect is left alone.
let declared = Declared::none().with_memory_priority(MemoryPriority::Low);

let during = declared.with_applied(MemoryPriority::current)?;
assert_eq!(during?, MemoryPriority::Low);

// The thread is returned to whatever it had, not to an assumed default.
assert_eq!(MemoryPriority::current()?, entry);

Structs§

Declared
The declared aspects a caller wants installed.
DeclaredError
A declared aspect could not be installed or restored.
DeclaredGuard
Holds declared aspects installed until released.

Enums§

BackgroundMode
Whether the thread runs in background processing mode.
DeclaredAspect
Which declared aspect an operation concerned.
MemoryPriority
How a thread’s memory pages compete for physical memory.
Wow64Redirection
What to do with WOW64 filesystem redirection.