I’ve recently been taking an interest in MinWin,
especially as it’s now visible in Windows 7, and I want to bring up the
possibility of introducing something similar into ReactOS.
I know some of you will be familiar with WinWin and I know
at least one of you will know quite a bit more about it than I do, but for
those who don’t here’s an overview.
What is WinMin?
MinWin is an internal project at Microsoft that manifested
around the time of the Vista rewrite. Very basically explained, the aim is to
detangle the very core components from the full operating system, resulting in
something which can be built separately and leaving just enough components for
a working system. This minimal operating system can then boot and be tested
separately or be built as part of the full OS and tested in internally as
before.
The main problem in doing this, and one of the main benefits
in solving it, is module dependencies. By simply cutting out the bottom part of
the OS you’re left with modules which potentially call out to other
modules which may now be missing. If these dependencies aren’t understood
you have the possibility of an unstable OS as you never know where a code path
may lead. It also means you need to build more components to get the thing to
link, which also undermines one of the reasons for doing it.
What Microsoft did is to draw up a dependency tree and
structure it in a layered hierarchy. Modules were then rearranged to make
architectural sense according to the NT design and a top layer was decided
upon. API call were then rewritten within this hierarchy such that anything in
one layer would only call API’s in the layers below it. Therefore if
something in layer 8 called something in layer 7 which then called something in
layer 12, the APIs would be fixed to only use APIs at or below its level
according to the hierarchy. You’re then left with a clean line where
nothing calls out and you have a tightly bound core OS which is completely
independent from anything.
What is essentially left in Microsoft’s WinMin is what
people class as Cutlers NT along with supporting components to get a bootable
system. The main components are:
The kernel (main kernel, not the full ntoskrnl module),
parts of the executive, memory manager, networking, a file system driver and
core drivers (basc IO and Bus, etc)
This is then exposed in usermode by 2 dlls, ntdll.dll and
the new kernelbase.dll. On top of this you have a console for issuing commands.
This comprises of the full OS and amounts to about 25Mb on
disk and has around a 40Mb working set.
Let’s quickly explain the new kernelbase dll.
As many of the API’s in the lower level dlls such as
kernel32 and advapi32 were targeting functionality which wasn’t in
WinMin, it was decided to pull out any of the API’s which were required
to exercise WinMin and put them into kernelbase. This dll could then be used
when building a running WinMin to provide all the functionality this kernel
offered. The dlls which had their APIs removed now forwarded their call onto
kernelbase so from a user perspective, nothing had changed.
Microsoft went a step further and designed a new technology
around virtual dlls. They split functionality of dlls into ‘api
sets’ These can now be seen in Win 7 in the system32 dir with the
prefix ‘api-ms-win-core-<function>-<num of>-1-0.dll’.
WinMin components now link against these virtual dlls which load up the real
libs listed in apisetschema.dll.
However this involves modification to the loader and I
don’t think it’s something worth us considering right now.
What are the reasons for doing this?
For a start, it’s a much better design from an
engineering perspective.
The more software you have running on a system the more noise
is created and the more things can interfere with each other.
It gives us a base to innovate with without worrying about
affecting anything outside.
It gives us a more reliable base for the OS and a better
platform to run comprehensive and efficient tests.
It makes us more attractive to external companies as we
would have a slick NT compatible kernel ready for companies to build their
products on, especially embedded applications.
With a few more additional items such as the base win32
subsystem, we’d have something along the lines of a stripped out
ServerCore or Windows PE.
This is only a quick overview for discussion purposes, but
it outlines the main design and goals of WinMin.
Comments, questions, concerns and gripes welcome J
Ged.