Musa.Runtime - Universal C++ RunTime Library

June 6, 2026 · View on GitHub

Actions Status Downloads LICENSE Visual Studio Windows Platform


Overview

Musa.Runtime is a Microsoft MSVC runtime library adapted for Windows kernel-mode development. Built on Musa.Core, it carries forward the architecture pioneered by ucxxrt.

Core goal: Give kernel developers the same C++ experience that application developers enjoy.

Design highlight: Inspired by Docker's layered filesystem, Musa.Runtime uses an overlay mechanism to selectively replace files on top of the original MSVC SDK source — no fork, no independent copy to maintain. See Architecture for details.

Quick Start

1. Install

NuGet (recommended):

<ItemGroup>
  <PackageReference Include="Musa.Runtime">
    <Version>1451.28000.0</Version>
  </PackageReference>
</ItemGroup>

Or right-click your project → Manage NuGet Packages → search Musa.Runtime → Install.

Manual import: Download from Releases and unzip:

<PropertyGroup>
  <MusaRuntimeOnlyHeader>false</MusaRuntimeOnlyHeader>
</PropertyGroup>
<Import Project="..\Musa.Runtime\config\Musa.Runtime.Config.props" />
<Import Project="..\Musa.Runtime\config\Musa.Runtime.Config.targets" />
<!-- place above Microsoft.Cpp.targets -->

2. Rename DriverEntryDriverMain

Musa.Runtime provides its own DriverEntry (which handles CRT initialization). Your driver entry point must be renamed to DriverMain:

EXTERN_C NTSTATUS DriverMain(PDRIVER_OBJECT DriverObject, PUNICODE_STRING RegistryPath)
{
    DriverObject->DriverUnload = [](auto obj) { MusaLOG("Unload."); };
    // Your code here
    return STATUS_SUCCESS;
}

3. Use C++ in Kernel

#include <vector>
#include <string>
#include "kext/kallocator.h"

void Example()
{
    std::vector<std::string, kallocator<std::string>> vec;
    vec.push_back("hello from kernel");
}

⚠️ kallocator defaults to PagedPool. When used at DISPATCH_LEVEL or above, specify NonPagedPool explicitly.

Features

FeatureStatusNotes
x64Primary platform
ARM64⚠️Experimental
New / DeleteBacked by ExAllocatePoolWithTag
C++ Exception (/EHa, /EHsc)IRQL ≤ APC_LEVEL
Static Object ConstructionRuns at driver load time
SAFESEH / GSBuffer security check
SEH (__try/__except)Access violation, finally, continue search
STL Containers / AlgorithmsFull OneCore / CoreCRT support
std::format / std::printC++23 formatted output
std::regexFull regular expression support
std::filesystemC++17 filesystem (Phase 1)
String Conversions (std::stoi/stod/etc.)stoi, stol, stoul, stoll, stoull, stod, stof
thread_localCompiler-level limitation (fs/gs register access)

Documentation

DocumentContent
📐 ArchitectureDesign philosophy (overlay pattern), component architecture, kernel-mode adaptations
📝 Developer GuideInstallation, STL usage, exception handling, kallocator, troubleshooting
🔧 Build SystemProject structure, build process, version management, publish pipeline
🔬 Overlay Diff ReportPer-file differential analysis of all overlay files

Build from Source

> git clone --recurse-submodules https://github.com/MiroKaku/Musa.Runtime.git
> cd Musa.Runtime
> .\BuildAllTargets.cmd

Prerequisites: Visual Studio 2026 (latest) + WDK

References