[Autogenerated] here's the code you might want to use in
order to allocate with large pages.
So the first thing you need to do is to enable the lock memory
privilege if you have it and as I mentioned,
no user or group has that by default today,
but if you had it you need to enable it first and there is some
piece of code here that allows you to enable any privilege as
long as you have that in your token,
not going to go over this code because it's mostly security related code,
you can find more details in the Microsoft documentation and
then once you have that privilege enabled,
you need to call the mutual lock function.
Use the same flags we've seen earlier and then just add the large pages
flag and of course you have to make sure the size you are allocating is a
multiple of a large page size in this example.
I'm using 100 megabyte so if you shift by 20 bits,
that's going to be a mega, so you have 100 and then shifted 20 beats to the left,
that's 100 megabyte which is a multiple size of two megabytes
which is the large page size and then you can display that and
even look at tools such as VM app and the current debugger and
see what that looks like there.
You will find that in VMs The memory is shown as locked because it is always
in physical memory can never go out of physical memory.
Another thing that I didn't mention the previous clip is that
large pages are always protected with read write.
There is no way to protect them any differently.
And so that's another one of the limitations,
so to speak, of large pages in order to see exactly what's going on.
In terms of security here,
we can use the local security policy tool to load up the
list of privileges that you can find here.
The local privileges and you can see see that there's the lock privilege,
locked pages in memory privilege which has no security settings here,
which means there's no user group that has this particular privilege.
And if you're an administrator on this machine, you can definitely add that.
So you can add a user such as me.
Well, it's actually not really me here, but some alternate ego of me here.
If you have a user you can add, then you can restart the system.
In fact,
it's good enough to to actually sign out and sign back in and then new
tokens created with that user will have that privilege in their token and
then you'll be able to perform that experiment.
So I'm going to leave that to you as an exercise for when you
have some time to do this kind of thing.