Search code examples
windowswinapipragmavirtual-memory

#pragma alloc_text(PAGE, functionname)


#pragma alloc_text(PAGE, foo)

void foo() { }

This code is usually used in device drivers.
The foo function will be swapped whenever system needs.

Questions.

  • Does it work in user space code? Will the function be also paged?
  • Without the pragma, I mean by default, are all kernel level functions allocated nonpaged memory?
  • Does PE file loader decide where the functions are allocated?

Solution

  • User mode programs are swapped by default. It is unusual that you would need something else. Sounds like a device driver requirement to be resident to handle interrupts or such things. User mode programs don't do that.