McAfee Avert Labs Blog
Windows 7 – Kernel API Refactoring」より
January 5,2010 Posted by Bing Sun

 米マイクロソフトが最新版クライアントOS「Windows 7」を一般発売してから、多くの人が「MinWin」と呼ばれる新たなカーネルに興味を示すようになった。ところが、MinWinを正しく理解して説明できる人はまずいないし、「MinWin」と「Server Core」を混同している場合が多い。そこで「MinWin」という用語をきちんと説明しよう(関連記事:「Windows 7」は数え切れないブラッシュアップで見違えるほど洗練されている/Windows 7:それほど新しくないMicrosoftの新MinWinカーネル)。

 マイクロソフトがサーバーOS「Windows Server 2008」で実現したものの一つに「Server Core」(旧名称は「Server Foundation」)がある。これは、Active Directory(AD)やDNS、DHCPサーバー、Internet Information Services(IIS)といった一般的なサーバー機能の提供に必要なコンポーネントで構成されたWindowsのサブセット版製品だ。これに対し「MinWin」は、上位層のコンポーネントに依存しない小規模な自己完結型OSそのもので、ミニマリスト(最小主義)プログラムとしてよく知られる、Windows 7付属の自己完結型Windowsコンポーネントである。

 マイクロソフトのあるWindows開発者は、「MinWin」を「アーキテクチャの階層に沿ったコード作り直し」と称している。この説明の通り、初の「MinWin」ベースOSといわれる「Windows Vista」以降(Windows Vistaは若干のコンポーネント化と修正が施された)、Windowsのコンポーネントには漏れなくほかのコンポーネントとの依存関係を表す「階層番号」を割り振ってあり、Windowsの中核に近いコンポーネントほど小さな階層番号を付ける。「コード修正」は、コア・アーキテクチャ・チームが上位層のコンポーネントが作動時に下位層のコンポーネントを要求する、という依存関係の問題解決を目指して取り組んだ。続いてWindows 7における「階層化」と「コード修正」の実施方法を、例を使って説明する。

 上の図は、依存関係確認ツール「Dependency Walker」で「kernel32.dll」を開いたところだ。この情報から、Windows 7が多くの有名なWin32 APIをエクスポートする一連の新たなDLLファイルを導入しており、これら新DLLの中に「kernelbase.dll」(Windows NT BASE API Client DLL)と(以下に示した)34個の隠しApiSet Stub DLLがあると読み取れる。各スタブDLLは、名前から分かる通り機能別に分類されている。例えば「api-ms-win-core-processthreads-l1-1-0.dll」は(「CreateProcessA/W」「CreateRemoteThread」などの)プロセス/スレッド関係のAPI、「api-ms-win-core-heap-l1-1-0.dll」は(「HeapCreate」「HeapAlloc」などの)ユーザーモード/ヒープ管理関係のAPIをエクスポートする。

ApiSet Stub DLL一覧:

api-ms-win-core-console-l1-1-0.dll
api-ms-win-core-datetime-l1-1-0.dll
api-ms-win-core-debug-l1-1-0.dll
api-ms-win-core-delayload-l1-1-0.dll
api-ms-win-core-errorhandling-l1-1-0.dll
api-ms-win-core-fibers-l1-1-0.dll
api-ms-win-core-file-l1-1-0.dll
api-ms-win-core-handle-l1-1-0.dll
api-ms-win-core-heap-l1-1-0.dll
api-ms-win-core-interlocked-l1-1-0.dll
api-ms-win-core-io-l1-1-0.dll
api-ms-win-core-libraryloader-l1-1-0.dll
api-ms-win-core-localization-l1-1-0.dll
api-ms-win-core-localregistry-l1-1-0.dll
api-ms-win-core-memory-l1-1-0.dll
api-ms-win-core-misc-l1-1-0.dll
api-ms-win-core-namedpipe-l1-1-0.dll
api-ms-win-core-processenvironment-l1-1-0.dll
api-ms-win-core-processthreads-l1-1-0.dll
api-ms-win-core-profile-l1-1-0.dll
api-ms-win-core-rtlsupport-l1-1-0.dll
api-ms-win-core-string-l1-1-0.dll
api-ms-win-core-synch-l1-1-0.dll
api-ms-win-core-sysinfo-l1-1-0.dll
api-ms-win-core-threadpool-l1-1-0.dll
api-ms-win-core-util-l1-1-0.dll
api-ms-win-core-xstate-l1-1-0.dll
api-ms-win-security-base-l1-1-0.dll
api-ms-win-security-lsalookup-l1-1-0.dll
api-ms-win-security-sddl-l1-1-0.dll
api-ms-win-service-core-l1-1-0.dll
api-ms-win-service-management-l1-1-0.dll
api-ms-win-service-management-l2-1-0.dll
api-ms-win-service-winsvc-l1-1-0.dll