[Autogenerated] Let's look at process address ranges using tools.
So first we can open Task manager, Task manager,
there's a column here called architecture that shows the bigness of the process.
If you don't see that column for whatever reason,
just right-click you select columns here and find the
architecture column and add that to the list by the way you
might notice here in newer task measure.
It also allows you to filter based on process named Pluralsight this,
this is a recent addition at the time of this recording Anyway,
you can see that most process of 64-bit there very few
32-bit processes on a typical 64-bit system still would
like to take a look at them as well.
So let's look at the address space of a 64-bit process first by opening VM app,
we'll discuss the VMs two in greater detail later on in
this module and discourse in fact,
but the basic premise is the ability to see the address space and
what it's used for in a particular process.
So if I select something like explore which is
definitely 64-bit we can click OK, he to see the address space of the process.
Now the addresses here are sorted by the address itself.
So it starts with a very low address that is used for something
and earlier addresses are simply not used.
They're completely free.
If we scroll all the way to the bottom,
we'll see that the last address here is roughly going to the 128 terabytes mark,
this is of course exactly what we expect,
we can see that in terms of free the free bytes here are
very close to 188 terabytes really because most of the
address space and explorer is unused,
which makes sense because most process today can't really use
much of that address space and perhaps don't even need that much
of an address space to use Anyway.
In any case, if you look at any 64-bit process,
you'll find something which is very similar Now.
What about 32-bit so one way we can look at that is by trying to come up with
one of these 32-bit processes and see what's going on there.
But let's try something else first.
So in general we know that on a 64 bit system that supports wow,
of course we have these separate directory called C window
CS wow 64 which contains 32 bit images.
DLS and executable essentially almost the same ones you are
bound to find on a true 32-bit system.
So for example, you'll find something like Notepad here.
So if I run Notepad let's run it and I get indication there's a newer Notepad
available from the starboard and don't care about that.
In fact, I would like to focus on the 32-bit Notepad here.
Let's open task Manager just to verify that indeed,
it's running in the three to be processed and it is,
it's X 86 here rather than X 64.
That's a 32-bit process running on a 64 bit system.
What about the address space it consumes let's go back to
VM app and open note that now but of course the note that
we have we're using right now,
that's the 32-bit Notepad and if we do that we consider the addresses are much
smaller than in the Explorer case they start with a very low address and then
the maximum address is in the two gigabyte size so we have two gigabytes only
that are available in theory for that note but process this means that the note
but executable doesn't have the large address aware flag in its P let's verify
that by running some p viewing tools such as my own total P So if you open up
and go to 6 12 64 look for Notepad It's important to grab the correct one,
we'll see that this is in fact a 32-bit executable and there is no large address
aware here as a flag in the characteristics member here as part of the P Let's
try to find another executable which does have this address large address aware
flag that is still 32-bit so one of those it's actually not very easy to find
those is check disk so check this is a tool that is used to well check your disk
and can even do fixes and you can see that this executable is marked with a
large address aware flag which means that if we if we run an instance of that,
check that particular 32-bit variant of check disk we expect to find four
gigabytes of address space for that process while it's running,
that's the maximum address space it can use let's
see if we can make that happen.
So I'm going to launch a terminal here using control shift and And
click in order to run it with the mean privileges,
we have to do that because check this requires and mean
privileges in order to open a low level access to the disk
itself to the actual volume,
not to a particular file and I'm going to of course have to change the
directory to cease Wow 64 where that check this is and also have to
invoke check disk in this particular way just to make sure it doesn't
select the 64-bit variant by default,
which it would if I just write a check this without that prefix indicating,
I would like to get check this from this particular directory so
once I do that it would start churning and while it's doing that
I'm going to go back to VM app,
I have to click short processes to launch VM app again with that mean pretty
just otherwise check this will not be visible and then look up,
check this and click ok,
so if I do that fast enough and check this is not done with my disk we'll be
able to see what we expect that we have 32 bit addresses here,
not 64 but the highest address should be four gigabytes.
So it is possible.
And indeed this is the case for check disk to use the
entire four gigabytes of address space,
which is the entire usable address space for 32-bit process because 32-bit
pointers can only address for gigabytes at most now,
how can we do that programmatically if we're writing our own application now,
obviously it's better to run to write applications that are full 64-bit
but sometimes it is useful to write 32-bit applications if you intend
them to run a 32 bit system and so you can write this Single executable
that can run essentially the same way on 64-32 bit systems without
generating two versions.
So you can definitely do that.
But let's see how you handle that in code.
Let's create a simple application here.
It's just called that a simple and what I want to do here is
just to show how to manipulate these flags or this
particular flag using visual studio.
Now by default views to 2022 uses X 64 as the default configuration because
really this is what most applications should be doing today.
However,
it is possible to move over to x 86 to build a 32 bit version for the
executable So if you want to change large address aware to be able to
access four gigabytes of address space and not just two gigabytes when
running on a 64 bit system.
We have to do something by going to the project
properties and then finding the linker tab.
So obviously I'm going to select win 32 here the X
86 really is just an old name,
I can select all configurations because I don't
really care about debugger release, I want all of them to behave in the same way.
Then we can go to linker and then system and here you might
find this flag called enable large addresses.
That's the one that's going to add the large address aware flag in the P image.
So that the loader will allow the process once launched
based on that executable to use the entire four gigabytes
of address space as as needed.
Now,
one of the common programs that was using that and still
is our visual studio before 20 2022, fact,
is the first version to the version that is pure 64-bit but videos
through 20 2019 versions are always 32-bit but they have this flag
large address aware in their p so that when they're running on a 64
bit system which is very common,
then they can use more address space they can use four gigabytes of address
space instead of just two gigabytes of address space,
which again makes sense,
but still today in verse 22 we don't have that limitation anymore because we
have the full 120 terabytes of potential address space to use.