Musa.CoreLite
1.1.0
Requires NuGet 2.5 or higher.
dotnet add package Musa.CoreLite --version 1.1.0
NuGet\Install-Package Musa.CoreLite -Version 1.1.0
<PackageReference Include="Musa.CoreLite" Version="1.1.0" />
<PackageVersion Include="Musa.CoreLite" Version="1.1.0" />
<PackageReference Include="Musa.CoreLite" />
paket add Musa.CoreLite --version 1.1.0
#r "nuget: Musa.CoreLite, 1.1.0"
#:package Musa.CoreLite@1.1.0
#addin nuget:?package=Musa.CoreLite&version=1.1.0
#tool nuget:?package=Musa.CoreLite&version=1.1.0
Musa.CoreLite
Musa.CoreLite is a lightweight core library extracted from the Musa.Core project, providing complete support for calling all Zw* system routines for Windows developers.
This project aims to solve the problem of incomplete export symbols for Zw* system routines, allowing developers to directly call all Zw* system routines in both user mode and kernel mode without worrying about missing symbols.
Usage
Right-click your project, select "Manage NuGet Packages", search for Musa.CoreLite, choose the appropriate version, and click "Install".
The NuGet package depends on Musa.Veil. You can directly include
<Veil.h>.
Header-only Mode
Add the following code to your .vcxproj file. In this mode, the lib file will not be automatically linked.
<PropertyGroup>
<MusaCoreOnlyHeader>true</MusaCoreOnlyHeader>
</PropertyGroup>
Code Example
Kernel Mode (Driver)
Musa.CoreLite.TestForDriver.cpp
EXTERN_C NTSTATUS DriverEntry(
_In_ PDRIVER_OBJECT DriverObject,
_In_ PUNICODE_STRING RegistryPath
)
{
PAGED_CODE();
UNREFERENCED_PARAMETER(DriverObject);
UNREFERENCED_PARAMETER(RegistryPath);
NTSTATUS Status;
do {
DriverObject->DriverUnload = Main::DriverUnload;
Status = MusaCoreLiteStartup();
if (!NT_SUCCESS(Status)) {
MusaLOG("Failed to initialize MusaCoreLite, 0x%08lX", Status);
break;
}
MusaLOG("Test ZwGetCurrentProcessorNumber() return %lu",
ZwGetCurrentProcessorNumber());
} while (false);
if (!NT_SUCCESS(Status)) {
Main::DriverUnload(DriverObject);
}
return Status;
}
// In DriverUnload:
(void)MusaCoreLiteShutdown();
User Mode
#include <Veil.h>
#include <Musa.CoreLite/Musa.CoreLite.h>
int main()
{
NTSTATUS Status = MusaCoreLiteStartup();
if (!NT_SUCCESS(Status)) {
return Status;
}
// Call any Zw* system routine
auto ZwGetCurrentProcessorNumber =
reinterpret_cast<decltype(&::ZwGetCurrentProcessorNumber)>(
MusaCoreLiteGetSystemRoutine("ZwGetCurrentProcessorNumber"));
if (ZwGetCurrentProcessorNumber) {
printf("Current processor number: %lu\n", ZwGetCurrentProcessorNumber());
}
(void)MusaCoreLiteShutdown();
return 0;
}
API Usage Convention
- Parameter validity is the caller's responsibility. The library does not validate input parameters for performance reasons. Passing invalid pointers or mismatched hash values results in undefined behavior.
MusaCoreLiteStartup()must be called exactly once before any other API, and must not be called concurrently.MusaCoreLiteShutdown()is the reverse.MusaCoreLiteGetSystemRoutine/MusaCoreLiteGetSystemRoutineByNameHashare safe to call concurrently afterMusaCoreLiteStartup()returns successfully.
License
This project is licensed under the MIT License. See LICENSE for details.
Contributing
Contributions are welcome! Please read the Code of Conduct before submitting issues or pull requests.
Acknowledgements
- Thanks: The implementation was provided by @xiaobfly.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| native | native is compatible. |
-
- Musa.Veil (>= 1.7.0)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Musa.CoreLite:
| Package | Downloads |
|---|---|
|
Musa.Core
Musa.Core - 用 ntdll/ntoskrnl 实现 Kernel32、Advapi32 等API。 * 它包括用户模式和内核模式两种。 Musa.Core - Use ntdll/ntoskrnl to implement Kernel32, Advapi32 and other APIs. * It includes user-mode and kernel-mode. |
GitHub repositories
This package is not used by any popular GitHub repositories.
- Support boot-start drivers (SERVICE_BOOT_START): disk fallback for ntdll mapping when KnownDlls is unavailable
- MusaCoreLiteStartup() returns STATUS_RETRY when filesystem is not yet mounted, enabling drivers to use IoRegisterBootDriverReinitialization for deferred initialization
- Zw* stubs fall back to ntoskrnl RtlFindExportedRoutineByName during boot-start phase
- Added MusaCoreLiteGetNtdllBase() for lazy-init ntdll base address retrieval
- Removed direct export of MusaCoreLiteNtBase/MusaCoreLiteNtdllBase globals (use API instead)
- Startup error handling and SystemCall improvements
- Replaced TestWithMT with GoogleTest integration
- Expanded kernel-mode test driver to cover all public APIs
- Musa.Veil 1.5.0 -> 1.7.0
- Dynamic WDK detection and conditional install matching SDK version
- Fixed WDK availability on windows-2025 runner