News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Manipulate page tables in Windows application

Started by xenon, August 23, 2005, 08:49:24 AM

Previous topic - Next topic

xenon

I'm coding a Windows application program. Can I get access to the pages tables?
Here is what i'm trying to do:
I want a modulo buffer.
8192 bytes of buffer.
When the offset pointer overshoots >=8192, it will wrap back and access from the beginning of the buffer.
(The offset pointer will always be < 12*1024)

I just need to reserved 3 pages of contiguous memory space, with the 3rd page map back to the same place as 1st page.

Tedd

You can get pages of memory with VirtualAlloc, but this doesn't give you the option of remapping them to wherever you like.
I don't think that would/should be allowed :bdg
No snowflake in an avalanche feels responsible.

QvasiModo

I think you'd have to code a driver to do that. Usermode apps can't access the page tables directly, for stability and security reasons.

hutch--

xenon,

Is there any reason why you don't write a simple wrap around to go back to the start of the buffer ?
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

xenon

Sorry for missing for a long time.

It was just a random thought of playing with page tables. I was thinking of saving some clock cycles on a simple wrap around. The experimental program is supposed to be a Mersenne number factoring program. The buffer is a sieve that each bit represent a candidate factor. Then thousands of small prime numbers are run through one by one to clear many bits in the sieve, eliminating the need to test those factors (because those factors are divisible by that small prime). Anyway, I don't think I can explain why is there a need for the wrap around. That time I was experimenting to get it run faster, but now, I've put it aside. Thanks for your help.

drizz

if you set 3rd page as PAGE_GUARD (or PAGE_NO_ACCESS), and you set up an exception handler,
maybe that will work for you?.. (adjusting CONTEXT to start of first page).
but performance will suffer..
The truth cannot be learned ... it can only be recognized.

mnemonic

Maybe I'm missing something essentially, but anyway, here is my idea.

If you have your pointer in e.g. EAX, you could try
and EAX, 00000000000000000001111111111111b
after each iteration.
That way your pointer will always stay between 0 and 8191.
If you have some register spare you can even put that constant in there and speed things up. That way it should be even faster than some "page fault wraparound" by the OS.

Regards
Be kind. Everyone you meet is fighting a hard battle.--Plato
-------
How To Ask Questions The Smart Way