diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..8d4b70f
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,18 @@
+# Build output
+/out/
+/build/
+/artifacts/
+
+# Native build leftovers
+CMakeCache.txt
+CMakeFiles/
+cmake-build-*/
+
+# .NET build output
+bin/
+obj/
+.vs/
+
+# Generated scripts and logs
+*.log
+*.cache
diff --git a/CLRNet.proj b/CLRNet.proj
index 8831229..0385e90 100644
--- a/CLRNet.proj
+++ b/CLRNet.proj
@@ -62,19 +62,23 @@
- {12345678-1234-5678-9012-123456789012}
+ {8F4C5A55-2F4B-4C40-8A64-6B501B28B42C}
CLRNetCore
- {12345678-1234-5678-9012-123456789013}
+ {AF9323CB-8F8C-4D9F-9E1F-349437DD9C10}
CLRNetInterop
- {12345678-1234-5678-9012-123456789014}
+ {6E8E9D3E-8B1F-4C1B-BD5A-9852E5F0C8C2}
CLRNetSystem
+
+ {9F05A3F2-2F3C-436C-9B8C-045386CFB7A3}
+ CLRNetHost
+
- {12345678-1234-5678-9012-123456789015}
+ {4B3E8C7E-5FA6-4F16-B5E8-5E0F0C52F51F}
CLRNetTests
@@ -92,11 +96,15 @@
-
+
+
+
+
+
-
+
@@ -107,31 +115,37 @@
+
-
-
-
+
+
+
+
+
-
+
-
+
-
+
-
+
+
+
+
-
+
diff --git a/QUICK_START.md b/QUICK_START.md
index 5f2bc20..8942d1b 100644
--- a/QUICK_START.md
+++ b/QUICK_START.md
@@ -1,172 +1,56 @@
-# CLRNet Quick Start Guide
-
-## π 5-Minute Integration
-
-Get your Windows Phone 8.1 app running with CLRNet in just 5 minutes!
-
-### Step 1: Add CLRNet to Your Project (1 minute)
-
-1. **Copy CLRNet Binaries**
- ```
- YourApp/
- βββ CLRNet/
- β βββ CLRNetCore.dll
- β βββ CLRNetInterop.dll
- β βββ CLRNetSystem.dll
- β βββ CLRNetHost.exe
- βββ SamplePlugin.dll
- ```
-
-2. **Update Your .csproj File**
- ```xml
-
-
- Always
-
-
- ```
-
-### Step 2: Initialize CLRNet (2 minutes)
-
-Add this to your `MainPage.xaml.cs`:
-
-```csharp
-using System.Runtime.InteropServices;
-
-public sealed partial class MainPage : Page
-{
- [DllImport("CLRNetCore.dll")]
- private static extern int CLRNet_Initialize(IntPtr config);
-
- [DllImport("CLRNetCore.dll")]
- private static extern int CLRNet_LoadAssembly(string path);
-
- [DllImport("CLRNetCore.dll")]
- private static extern int CLRNet_ExecuteMethod(string type, string method);
-
- protected override void OnNavigatedTo(NavigationEventArgs e)
- {
- // Initialize CLRNet
- CLRNet_Initialize(IntPtr.Zero);
- }
-}
-```
-
-### Step 3: Load and Execute (1 minute)
-
-```csharp
-private void RunPlugin_Click(object sender, RoutedEventArgs e)
-{
- // Load your plugin
- CLRNet_LoadAssembly("SamplePlugin.dll");
-
- // Execute plugin method
- CLRNet_ExecuteMethod("PluginMain", "HelloWorld");
-}
-```
-
-### Step 4: Update Package Manifest (1 minute)
+# Quick start
-Add to `Package.appxmanifest`:
+This guide walks through building the Windows Phone 8.1 runtime and host from a
+fresh clone.
-```xml
-
-
- CLRNet\CLRNetCore.dll
-
-
-
-```
-
-## β
That's It!
+## 1. Install prerequisites
-Your app now has dynamic .NET assembly loading capabilities!
+- Windows 10 or 11
+- Visual Studio 2019/2022 with the *Windows Phone 8.1* components
+- Windows Phone 8.1 SDK (`C:\Program Files (x86)\Windows Phone Kits\8.1`)
+- PowerShell 5.0+
-## π₯ Advanced Usage (Optional)
+## 2. Build everything with a single command
-### Plugin Interface
-```csharp
-public interface IMyPlugin
-{
- void Initialize();
- string Execute(string input);
-}
-
-// In your plugin assembly
-public class MyPlugin : IMyPlugin
-{
- public void Initialize() { /* setup */ }
- public string Execute(string input) { return "Processed: " + input; }
-}
+```powershell
+pwsh .\build-wp81.ps1 -Configuration Release -Platform ARM
```
-### Dynamic Code Compilation
-```csharp
-// Compile C# code at runtime
-string code = @"
- public class RuntimeCode
- {
- public static string Process() { return ""Hello from runtime!""; }
- }";
+The script validates the SDK, locates MSBuild, and drives `CLRNet.proj` to build
+all native libraries, the phone host, and the smoke-test executable. Logs are
+written to `build/logs/` for troubleshooting.
-// CLRNet can compile and execute this dynamically
-```
+## 3. Package binaries
-### Game Modding System
-```csharp
-public class GameModLoader
-{
- public async Task LoadMod(string modFile)
- {
- await CLRNet_LoadAssembly(modFile);
- CLRNet_ExecuteMethod("GameMod", "OnModLoaded");
- }
-}
+```powershell
+pwsh .\build-wp81.ps1 -Target Package -Configuration Release -Platform ARM
```
-## π± Real-World Examples
-
-### 1. **Business Rules Engine**
-Load business logic from external assemblies without app updates.
-
-### 2. **Plugin Marketplace**
-Allow users to download and install app extensions.
-
-### 3. **Dynamic UI Generation**
-Create UI components from user-defined templates.
-
-### 4. **Scripting System**
-Enable power users to write custom scripts.
-
-### 5. **A/B Testing Framework**
-Load different feature implementations dynamically.
-
-## π οΈ Troubleshooting
-
-**Runtime not initializing?**
-- Check if CLRNet binaries are in your app package
-- Verify Package.appxmanifest has the extension registration
+Packaging copies the runtime, interop, system, host, and test artifacts into the
+`build/bin/ARM/Release/packages/` folder ready to be merged into an AppX payload.
-**Assembly won't load?**
-- Ensure assembly targets .NET Framework 4.0
-- Check file path is correct
+## 4. Inspect outputs
-**Method execution fails?**
-- Verify class and method names are exact
-- Check method is public and static
+- `build/bin/ARM//CLRNetCore.dll`
+- `build/bin/ARM//CLRNetInterop.dll`
+- `build/bin/ARM//CLRNetSystem.dll`
+- `build/bin/ARM//CLRNetHost.exe`
+- `build/bin/ARM//CLRNetTests.exe`
-## π― Next Steps
+## 5. Run the smoke tests
-1. **Read the full [Implementation Guide](IMPLEMENTATION_GUIDE.md)**
-2. **Check out the [complete sample app](examples/WP81Integration/)**
-3. **Explore advanced patterns and best practices**
+Copy the runtime folder to a Windows Phone 8.1 device or emulator and launch
+`CLRNetTests.exe`. The test harness verifies that the execution engine, security
+layer, and interop managers all initialize correctly in the phone environment.
-## π‘ Pro Tips
+## 6. Integrate into your AppX project
-- Initialize CLRNet once at app startup
-- Cache loaded assemblies for better performance
-- Use background threads for heavy operations
-- Always handle exceptions gracefully
-- Test on actual Windows Phone devices
+1. Copy the binaries from `build/bin/ARM/Release/` into your app's `CLRNet/`
+ directory.
+2. Include the host executable in the AppX manifest and add the required phone
+ capabilities.
+3. Bundle the `packages/CLRNet-Complete/` contents alongside your managed
+ assemblies before creating the final XAP/AppX package.
-**Happy Coding with CLRNet! π**
\ No newline at end of file
+For a deeper dive into deployment practices review `build/README.md` and the
+`WP81_*` summaries in the repository root.
diff --git a/README.md b/README.md
index 360451d..21c046f 100644
--- a/README.md
+++ b/README.md
@@ -1,116 +1,81 @@
-# CLRNET - Modern CLR Runtime for Windows Phone 8.1
+# CLRNet
-π **PROJECT COMPLETE** - A fully functional modern .NET CLR runtime for Windows Phone 8.1 devices with system integration capabilities.
+CLRNet is a Windows Phone 8.1 hosting layer that embeds a lightweight managed
+runtime, security boundary, and interop bridge so existing CLR assemblies can run
+on Lumia-era hardware. The project focuses on producing production-ready ARM
+binaries and a host executable that can be dropped directly into an app package.
-## β
Your Runtime is WORKING!
+## Highlights
-**Status: FULLY OPERATIONAL** - All 3 phases complete with 20+ components implemented
+- **Phone-ready binaries** β MSBuild definitions target the `v120_wp81`
+ toolset and generate ARM Release libraries plus a phone-friendly host.
+- **System integration** β the runtime ships with compatibility shims,
+ replacement hooks, and interop managers that understand WinRT, P/Invoke,
+ and hardware capability gating.
+- **Security aware** β the security manager models manifest capabilities,
+ sandbox levels, and emergency lockdown flows so packaged apps stay within
+ Windows Phone policy constraints.
+- **One-step build** β run a single PowerShell script and the repository emits
+ libraries, the host executable, smoke tests, and pre-staged deployment
+ packages under `build/bin///`.
-Run `.\scripts\simple-check.ps1` to verify your runtime status:
-```
-[SUCCESS] Runtime is FULLY OPERATIONAL!
-- Phase 1: 5/5 complete β
-- Phase 2: 4/4 complete β
-- Phase 3: 3/3 complete β
-```
-
-## Project Overview
-
-This project aims to bring modern .NET capabilities to Windows Phone 8.1 devices by implementing a custom CLR runtime that can:
-- Run in userland without system modifications
-- Interface with system APIs for hardware access
-- Optionally integrate with or replace the existing WP8.1 CLR
-- Enable development of custom tools and automation on the device
-
-## Project Phases
+## Quick start
-### Phase 1: Userland Runtime β
COMPLETE
-**Goal:** Modern CLR runtime with core execution capabilities
-- **Components:** Core execution engine, type system, GC, assembly loader, JIT compiler
-- **Status:** 5/5 components implemented and tested
-- **Location:** `src/phase1-userland/`
+1. **Install prerequisites**
+ - Windows 10 or 11
+ - Visual Studio 2019/2022 with the *Windows Phone 8.1* toolset
+ - Windows Phone 8.1 SDK (`C:\Program Files (x86)\Windows Phone Kits\8.1`)
+ - PowerShell 5.0+
-### Phase 2: System Interop β
COMPLETE
-**Goal:** Windows Runtime and hardware API integration
-- **Components:** WinRT bridge, P/Invoke engine, hardware access, security manager
-- **Status:** 7/7 components implemented with full WP8.1 integration
-- **Location:** `src/interop/`
+2. **Clone the repository and open an elevated Developer Command Prompt**
-### Phase 3: System Integration β
COMPLETE
-**Goal:** Optional CLR replacement with safety mechanisms
-- **Components:** CLR replacement engine, deep system hooks, compatibility layer, rollback system
-- **Status:** 7/7 components implemented with enterprise-grade safety
-- **Location:** `src/system/`
+3. **Build the runtime and host**
-## π― What Your Runtime Can Do RIGHT NOW
+ ```powershell
+ pwsh .\build-wp81.ps1 -Configuration Release -Platform ARM
+ ```
-β
**Execute Modern .NET Code** - Run applications with better performance than stock WP8.1 CLR
-β
**Access All Hardware** - Camera, GPS, accelerometer, microphone, speakers, etc.
-β
**Use Windows APIs** - Full Windows Runtime API access from managed code
-β
**Legacy Compatibility** - Run existing .NET Framework 2.0-4.8 applications
-β
**System Integration** - Optional CLR replacement with automatic rollback safety
-β
**Production Ready** - Comprehensive testing and validation framework
+ The script validates the environment, locates MSBuild, invokes the
+ aggregated `CLRNet.proj`, and writes a binary log to `build/logs/`.
-## Directory Structure
+4. **Package for deployment**
-```
-CLRNET/
-βββ README.md # This file
-βββ docs/ # Technical documentation
-βββ research/ # Analysis and research notes
-βββ src/ # Source code organized by phase
-β βββ phase1-userland/ # Sandboxed CLR implementation
-β βββ phase2-interop/ # System API integration
-β βββ phase3-integration/ # System CLR replacement
-β βββ phase4-automation/ # Custom applications
-βββ tools/ # Build tools and utilities
-βββ tests/ # Test applications and validation
-βββ build/ # Build configuration and scripts
-```
+ ```powershell
+ pwsh .\build-wp81.ps1 -Target Package -Configuration Release -Platform ARM
+ ```
-## π How to Use Your Runtime
+ Packaging stages the runtime, interop, system libraries, host executable, and
+ smoke-test harness into `build/bin/ARM/Release/packages/`.
-### Track A β App-Local BCL Overlay
-Developers looking to target newer .NET APIs on Windows Phone 8.1 can follow the [Track A roadmap](docs/TRACK-A-APP-LOCAL-BCL-OVERLAY.md) to ship app-local facade assemblies (e.g., `System.Runtime`, `System.Text.Json`). The overlay now includes managed implementations for `ValueTask`, async streams, `ArrayPool`, a curated `System.Text.Json` subset, WinRT-backed IO helpers, and a hardened HTTP handler so modern libraries can resolve against CLRNET-provided implementations without modifying working system components. See the [App-Local Facade Overlay Integration Guide](docs/APP_LOCAL_OVERLAY_GUIDE.md) for step-by-step packaging instructions and manifest samples.
+## Outputs
-### Track B β Userspace IL Engine
-Dynamic scenarios that rely on `Expression.Compile`, `DynamicMethod`, or other runtime codegen can now target the [Track B IL engine](docs/TRACK-B-USERSPACE-IL-ENGINE.md). The `CLRNet_VM_*` exports expose a sandboxed interpreter with bytecode caching, host-controlled syscalls, and call-site configuration so apps can compile IL once, persist the bytecode to `LocalCache/VmBytecode`, and execute under deterministic budgets without requiring the platform JIT.
+After a successful build you will find:
-### Track C β Modern C# pipeline
-Leverage the [Track C build pipeline](docs/TRACK-C-MODERN-CS-PIPELINE.md) to compile with Roslyn `/langversion:latest`, automatically reference CLRNET's facade overlays, post-process assemblies with Mono.Cecil to retarget APIs, and optionally route `Expression.Compile()` through the Track B VM. The sample project in `examples/ModernCSharpPipeline` demonstrates records, ValueTask, JSON serialization, and VM-backed expressions working together on Windows Phone 8.1.
+- `build/bin/ARM//CLRNetCore.dll` β the execution engine
+- `build/bin/ARM//CLRNetInterop.dll` β WinRT/PInvoke bridge
+- `build/bin/ARM//CLRNetSystem.dll` β compatibility and hook surface
+- `build/bin/ARM//CLRNetHost.exe` β phone host executable
+- `build/bin/ARM//CLRNetTests.exe` β smoke test harness
+- `build/bin/ARM//packages/` β runtime, interop, system, host, and
+ combined deployment bundles
-### End-to-end integration playbook
-When starting a new app (or upgrading an existing one), follow the [CLRNET Application Integration Playbook](docs/CLRNET_APP_INTEGRATION_PLAYBOOK.md) for a stage-by-stage checklist that stitches TracksΒ AβC togetherβcovering build configuration, IL post-processing, overlay packaging, VM warm-up, and on-device verification.
+## Manual MSBuild usage
-### Executive comparison snapshot
-Need to brief stakeholders quickly? Share the [CLRNET vs. Windows Phone 8.1 overview](docs/CLRNET_VS_WP81_OVERVIEW.md) for a plain-language summary and capability coverage table.
+If you prefer direct MSBuild invocations you can target the umbrella project:
-### Quick Verification (30 seconds)
```powershell
-# Quick health check (30 seconds)
-.\scripts\simple-check.ps1
-
-# Full regression suite
-.\scripts\run-all-tests.ps1
-
-# Inspect detailed status & phase reports
-Get-Content docs\RUNTIME_STATUS.md
-Get-Content docs\PHASE1-STATUS.md
+msbuild CLRNet.proj /t:Build /p:Configuration=Release /p:Platform=ARM /m
+msbuild CLRNet.proj /t:Package /p:Configuration=Release /p:Platform=ARM
```
-For runtime overlays, enable verbose logging via `OverlayConfig` to confirm which assemblies are resolved from the app package versus the OS.
-
----
+## Tests
-## Further Reading
-* [CLRNET Application Integration Playbook](docs/CLRNET_APP_INTEGRATION_PLAYBOOK.md)
-* [App-Local Overlay Guide](docs/APP_LOCAL_OVERLAY_GUIDE.md)
-* [Userspace IL Engine Roadmap](docs/TRACK-B-USERSPACE-IL-ENGINE.md)
-* [Modern C# Pipeline Roadmap](docs/TRACK-C-MODERN-CS-PIPELINE.md)
-* [Stakeholder Overview](docs/CLRNET_VS_WP81_OVERVIEW.md)
-* [Deployment scripts](scripts/)
+`CLRNetTests.exe` exercises the runtime bootstrap, security shim creation, and
+interop manager initialization. Launch it on a Windows Phone emulator or device
+after copying the runtime binaries into your AppX payload.
----
+## Additional documentation
-## License
-This project is licensed under the [MIT License](LICENSE).
+- `build/README.md` β deep dive into the build system and packaging layout
+- `WP81_*` reports β historical design notes, compatibility matrices, and
+ validation playbooks for Windows Phone 8.1 deployments
diff --git a/build-wp81.ps1 b/build-wp81.ps1
new file mode 100644
index 0000000..31f98a8
--- /dev/null
+++ b/build-wp81.ps1
@@ -0,0 +1,110 @@
+param(
+ [ValidateSet("Build", "Clean", "Rebuild", "Package")]
+ [string]$Target = "Build",
+
+ [ValidateSet("ARM", "x86")]
+ [string]$Platform = "ARM",
+
+ [ValidateSet("Debug", "Release")]
+ [string]$Configuration = "Release",
+
+ [switch]$Package
+)
+
+function Write-Status {
+ param([string]$Message)
+ $timestamp = Get-Date -Format "HH:mm:ss"
+ Write-Host "[$timestamp] $Message"
+}
+
+function Assert-Windows {
+ if ($env:OS -notlike '*Windows*' -and [System.Environment]::OSVersion.Platform -ne [System.PlatformID]::Win32NT) {
+ throw "The Windows Phone 8.1 toolchain is only available on Windows."
+ }
+}
+
+function Resolve-MSBuild {
+ $knownPaths = @(
+ (Join-Path $env:ProgramFiles(x86) 'Microsoft Visual Studio\2022\BuildTools\MSBuild\Current\Bin\MSBuild.exe'),
+ (Join-Path $env:ProgramFiles(x86) 'Microsoft Visual Studio\2022\Community\MSBuild\Current\Bin\MSBuild.exe'),
+ (Join-Path $env:ProgramFiles(x86) 'MSBuild\14.0\Bin\MSBuild.exe')
+ )
+
+ foreach ($path in $knownPaths) {
+ if (Test-Path $path) {
+ return $path
+ }
+ }
+
+ $vswhere = Join-Path $env:ProgramFiles(x86) 'Microsoft Visual Studio\Installer\vswhere.exe'
+ if (Test-Path $vswhere) {
+ $installPath = & $vswhere -latest -requires Microsoft.Component.MSBuild -format value -property installationPath
+ if ($installPath) {
+ $candidate = Join-Path $installPath 'MSBuild\Current\Bin\MSBuild.exe'
+ if (Test-Path $candidate) {
+ return $candidate
+ }
+ }
+ }
+
+ $fromPath = Get-Command msbuild.exe -ErrorAction SilentlyContinue
+ if ($fromPath) {
+ return $fromPath.Path
+ }
+
+ throw "Could not locate MSBuild. Install Visual Studio 2019/2022 with the Windows Phone 8.1 tools."
+}
+
+function Test-WP81SDK {
+ $sdkPath = Join-Path $env:ProgramFiles(x86) 'Windows Phone Kits\8.1'
+ if (-not (Test-Path $sdkPath)) {
+ throw "Windows Phone 8.1 SDK not found. Install the Windows Phone 8.1 tooling from the Windows 10 SDK installer."
+ }
+}
+
+Assert-Windows
+$msbuild = Resolve-MSBuild
+Test-WP81SDK
+
+$repoRoot = Split-Path -Parent $MyInvocation.MyCommand.Path
+$proj = Join-Path $repoRoot 'CLRNet.proj'
+$logRoot = Join-Path $repoRoot 'build\logs'
+if (-not (Test-Path $logRoot)) {
+ New-Item -ItemType Directory -Path $logRoot | Out-Null
+}
+
+$msbuildArgs = @(
+ "`"$proj`"",
+ "/m",
+ "/nr:false",
+ "/p:Configuration=$Configuration",
+ "/p:Platform=$Platform"
+)
+
+switch ($Target) {
+ 'Clean' { $msbuildArgs += '/t:Clean' }
+ 'Build' { $msbuildArgs += '/t:Build' }
+ 'Rebuild' { $msbuildArgs += '/t:Rebuild' }
+ 'Package' { $msbuildArgs += '/t:Package' }
+}
+
+$binlog = Join-Path $logRoot "wp81-$Platform-$Configuration.binlog"
+$msbuildArgs += "/bl:$binlog"
+
+Write-Status "Invoking MSBuild ($Target | $Platform | $Configuration)"
+Write-Status "Using MSBuild at $msbuild"
+& $msbuild @msbuildArgs
+if ($LASTEXITCODE -ne 0) {
+ throw "MSBuild failed with exit code $LASTEXITCODE"
+}
+
+if ($Package -and $Target -ne 'Package') {
+ Write-Status "Packaging runtime artifacts"
+ & $msbuild "`"$proj`"" /t:Package /p:Configuration=$Configuration /p:Platform=$Platform /bl:"$binlog.package"
+ if ($LASTEXITCODE -ne 0) {
+ throw "Packaging failed with exit code $LASTEXITCODE"
+ }
+}
+
+Write-Status "Build complete. Binaries in build\\bin\\$Platform\\$Configuration"
+Write-Status "Packages in build\\bin\\$Platform\\$Configuration\\packages"
diff --git a/src/CLRNetCore/CLRNetCore.vcxproj b/src/CLRNetCore/CLRNetCore.vcxproj
new file mode 100644
index 0000000..e54198e
--- /dev/null
+++ b/src/CLRNetCore/CLRNetCore.vcxproj
@@ -0,0 +1,111 @@
+
+
+
+
+ Debug
+ ARM
+
+
+ Release
+ ARM
+
+
+
+ {8F4C5A55-2F4B-4C40-8A64-6B501B28B42C}
+ Win32Proj
+ CLRNetCore
+ en-US
+ Windows Phone 8.1
+ 8.1
+ true
+ 8.1
+
+
+
+ DynamicLibrary
+ true
+ v120_wp81
+ false
+ Unicode
+
+
+ DynamicLibrary
+ false
+ v120_wp81
+ true
+ Unicode
+
+
+
+
+
+
+
+
+
+
+ $(SolutionDir)build\bin\$(Platform)\$(Configuration)\
+ $(SolutionDir)build\obj\$(Platform)\$(Configuration)\Core\
+ CLRNetCore
+
+
+ $(SolutionDir)build\bin\$(Platform)\$(Configuration)\
+ $(SolutionDir)build\obj\$(Platform)\$(Configuration)\Core\
+ CLRNetCore
+
+
+
+ NotUsing
+ Level3
+ Disabled
+ WIN32;_WINDOWS;_USRDLL;CLRNETCORE_EXPORTS;PLATFORM_WP81;%(PreprocessorDefinitions)
+ $(ProjectDir)..\phase1-userland\core;$(ProjectDir)..\phase1-userland;%(AdditionalIncludeDirectories)
+ MultiThreadedDebugDLL
+ true
+
+
+ Windows
+ true
+ runtimeobject.lib;windowsapp.lib;%(AdditionalDependencies)
+
+
+
+
+ NotUsing
+ Level3
+ MaxSpeed
+ true
+ true
+ WIN32;_WINDOWS;_USRDLL;CLRNETCORE_EXPORTS;PLATFORM_WP81;NDEBUG;%(PreprocessorDefinitions)
+ $(ProjectDir)..\phase1-userland\core;$(ProjectDir)..\phase1-userland;%(AdditionalIncludeDirectories)
+ MultiThreadedDLL
+ true
+
+
+ Windows
+ true
+ true
+ true
+ runtimeobject.lib;windowsapp.lib;%(AdditionalDependencies)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/CLRNetHost/CLRNetHost.cpp b/src/CLRNetHost/CLRNetHost.cpp
new file mode 100644
index 0000000..a0d0d1d
--- /dev/null
+++ b/src/CLRNetHost/CLRNetHost.cpp
@@ -0,0 +1,226 @@
+#include "../phase1-userland/core/CoreExecutionEngine.h"
+#include "../phase1-userland/core/AssemblyLoader.h"
+#include "../interop/InteropManager.h"
+#include "../system/compatibility/CompatibilityShim.h"
+#include "../system/replacement/CLRReplacementEngine.h"
+
+#include
+#include
+#include
+#include
+#include
+
+using namespace CLRNet::Phase1;
+using namespace CLRNet::Interop;
+using namespace CLRNet::System;
+
+namespace
+{
+ struct HostOptions
+ {
+ std::wstring assemblyPath;
+ std::wstring typeName = L"Program";
+ std::wstring methodName = L"Main";
+ std::wstring manifestPath;
+ bool explainOnly = false;
+ bool disableInterop = false;
+ };
+
+ void PrintUsage()
+ {
+ std::wcout << L"CLRNetHost - Windows Phone 8.1 runtime bootstrapper\n";
+ std::wcout << L"Usage:\n";
+ std::wcout << L" CLRNetHost.exe -assembly [-type ] [-method ]\n";
+ std::wcout << L" [-manifest ] [--explain] [--no-interop]\n\n";
+ std::wcout << L"Options:\n";
+ std::wcout << L" -assembly Required. Managed assembly that contains the entry point.\n";
+ std::wcout << L" -type Fully qualified type name. Defaults to Program.\n";
+ std::wcout << L" -method Entry method name. Defaults to Main.\n";
+ std::wcout << L" -manifest Optional application manifest used for capability loading.\n";
+ std::wcout << L" --explain Initialize the runtime and print discovered metadata without executing code.\n";
+ std::wcout << L" --no-interop Skip InteropManager initialization for very small payloads.\n";
+ }
+
+ std::string Narrow(const std::wstring& value)
+ {
+ if (value.empty())
+ {
+ return std::string();
+ }
+
+ int required = WideCharToMultiByte(CP_UTF8, 0, value.c_str(), static_cast(value.size()), nullptr, 0, nullptr, nullptr);
+ if (required <= 0)
+ {
+ return std::string();
+ }
+
+ std::string result(static_cast(required), '\0');
+ WideCharToMultiByte(CP_UTF8, 0, value.c_str(), static_cast(value.size()),
+ result.data(), required, nullptr, nullptr);
+ return result;
+ }
+
+ bool ParseArguments(int argc, wchar_t* argv[], HostOptions& options)
+ {
+ for (int i = 1; i < argc; ++i)
+ {
+ std::wstring arg = argv[i];
+ if (arg == L"-assembly" && i + 1 < argc)
+ {
+ options.assemblyPath = argv[++i];
+ }
+ else if (arg == L"-type" && i + 1 < argc)
+ {
+ options.typeName = argv[++i];
+ }
+ else if (arg == L"-method" && i + 1 < argc)
+ {
+ options.methodName = argv[++i];
+ }
+ else if (arg == L"-manifest" && i + 1 < argc)
+ {
+ options.manifestPath = argv[++i];
+ }
+ else if (arg == L"--explain")
+ {
+ options.explainOnly = true;
+ }
+ else if (arg == L"--no-interop")
+ {
+ options.disableInterop = true;
+ }
+ else if (arg == L"-?" || arg == L"--help" || arg == L"/?")
+ {
+ return false;
+ }
+ else
+ {
+ std::wcerr << L"Unknown option: " << arg << L"\n";
+ return false;
+ }
+ }
+
+ return !options.assemblyPath.empty();
+ }
+
+ void DescribeRuntime(const CoreExecutionEngine& engine)
+ {
+ std::wcout << L"CLRNet runtime initialized successfully.\n";
+ std::wcout << L" - Core type system ready\n";
+ std::wcout << L" - Garbage collector active\n";
+ std::wcout << L" - JIT compiler primed\n";
+ std::wcout << L"Use -type and -method to run a specific entry point.\n";
+ (void)engine;
+ }
+
+ std::unique_ptr InitializeCompatibility()
+ {
+ auto config = CompatibilityFactory::CreateMinimalCompatibilityConfig();
+ auto shim = std::unique_ptr(CompatibilityFactory::CreateCompatibilityShim(config));
+ if (shim)
+ {
+ shim->Initialize(CompatibilityLevel::Standard);
+ }
+ return shim;
+ }
+
+ std::unique_ptr InitializeReplacementEngine()
+ {
+ auto engine = std::unique_ptr(CLRReplacementFactory::CreateEngine(ReplacementLevel::ProcessLevel));
+ if (engine)
+ {
+ engine->AttachToCurrentProcess();
+ }
+ return engine;
+ }
+
+ std::unique_ptr InitializeInterop(const HostOptions& options)
+ {
+ auto configuration = InteropFactory::CreateStandardConfiguration(L"CLRNetHost");
+ configuration.manifestPath = options.manifestPath;
+ auto interop = std::unique_ptr(InteropFactory::CreateCustomInstance(configuration));
+ if (interop)
+ {
+ interop->Initialize(configuration);
+ }
+ return interop;
+ }
+}
+
+int wmain(int argc, wchar_t* argv[])
+{
+ HostOptions options;
+ if (!ParseArguments(argc, argv, options))
+ {
+ PrintUsage();
+ return 1;
+ }
+
+ std::wcout << L"[CLRNet] Bootstrapping runtime...\n";
+
+ CoreExecutionEngine runtime;
+ if (!runtime.Initialize())
+ {
+ std::wcerr << L"Failed to initialize core execution engine." << std::endl;
+ return 2;
+ }
+
+ auto compatibilityShim = InitializeCompatibility();
+ auto replacementEngine = InitializeReplacementEngine();
+ std::unique_ptr interopManager;
+ if (!options.disableInterop)
+ {
+ interopManager = InitializeInterop(options);
+ }
+
+ if (!runtime.LoadAssembly(options.assemblyPath))
+ {
+ std::wcerr << L"Failed to load assembly: " << options.assemblyPath << std::endl;
+ runtime.Shutdown();
+ return 3;
+ }
+
+ if (options.explainOnly)
+ {
+ DescribeRuntime(runtime);
+ if (interopManager)
+ {
+ auto status = interopManager->GetStatus();
+ std::wcout << L"Interop status: " << static_cast(status) << L"\n";
+ }
+ runtime.Shutdown();
+ return 0;
+ }
+
+ std::string typeName = Narrow(options.typeName);
+ std::string methodName = Narrow(options.methodName);
+ void* entryPoint = runtime.GetMethodAddress(typeName, methodName);
+ if (!entryPoint)
+ {
+ std::wcerr << L"Could not resolve method " << options.typeName << L"::" << options.methodName << std::endl;
+ runtime.Shutdown();
+ return 4;
+ }
+
+ std::wcout << L"Executing " << options.typeName << L"::" << options.methodName << L"...\n";
+ int exitCode = runtime.ExecuteMethod(entryPoint, nullptr, 0);
+ std::wcout << L"Managed entry point returned " << exitCode << L"\n";
+
+ if (interopManager)
+ {
+ interopManager->Shutdown();
+ }
+
+ if (compatibilityShim)
+ {
+ compatibilityShim->Cleanup();
+ }
+
+ if (replacementEngine)
+ {
+ CLRReplacementFactory::DestroyEngine(replacementEngine.release());
+ }
+
+ runtime.Shutdown();
+ return exitCode;
+}
diff --git a/src/CLRNetHost/CLRNetHost.vcxproj b/src/CLRNetHost/CLRNetHost.vcxproj
new file mode 100644
index 0000000..0666d5e
--- /dev/null
+++ b/src/CLRNetHost/CLRNetHost.vcxproj
@@ -0,0 +1,109 @@
+
+
+
+
+ Debug
+ ARM
+
+
+ Release
+ ARM
+
+
+
+ {9F05A3F2-2F3C-436C-9B8C-045386CFB7A3}
+ Win32Proj
+ CLRNetHost
+ Windows Phone 8.1
+ 8.1
+ true
+ 8.1
+
+
+
+ Application
+ true
+ v120_wp81
+ Unicode
+
+
+ Application
+ false
+ v120_wp81
+ true
+ Unicode
+
+
+
+
+
+
+
+
+
+
+ $(SolutionDir)build\bin\$(Platform)\$(Configuration)\
+ $(SolutionDir)build\obj\$(Platform)\$(Configuration)\Host\
+ CLRNetHost
+
+
+ $(SolutionDir)build\bin\$(Platform)\$(Configuration)\
+ $(SolutionDir)build\obj\$(Platform)\$(Configuration)\Host\
+ CLRNetHost
+
+
+
+ NotUsing
+ Level3
+ Disabled
+ WIN32;_WINDOWS;PLATFORM_WP81;%(PreprocessorDefinitions)
+ $(ProjectDir)..\phase1-userland\core;$(ProjectDir)..\interop;$(ProjectDir)..\system;$(ProjectDir)..\system\compatibility;$(ProjectDir)..\system\replacement;%(AdditionalIncludeDirectories)
+ MultiThreadedDebugDLL
+ true
+
+
+ Console
+ true
+ CLRNetCore.lib;CLRNetInterop.lib;CLRNetSystem.lib;runtimeobject.lib;windowsapp.lib;ole32.lib;shlwapi.lib;%(AdditionalDependencies)
+
+
+
+
+ NotUsing
+ Level3
+ MaxSpeed
+ true
+ true
+ WIN32;_WINDOWS;PLATFORM_WP81;NDEBUG;%(PreprocessorDefinitions)
+ $(ProjectDir)..\phase1-userland\core;$(ProjectDir)..\interop;$(ProjectDir)..\system;$(ProjectDir)..\system\compatibility;$(ProjectDir)..\system\replacement;%(AdditionalIncludeDirectories)
+ MultiThreadedDLL
+ true
+
+
+ Console
+ true
+ true
+ true
+ CLRNetCore.lib;CLRNetInterop.lib;CLRNetSystem.lib;runtimeobject.lib;windowsapp.lib;ole32.lib;shlwapi.lib;%(AdditionalDependencies)
+
+
+
+
+
+
+
+ {8F4C5A55-2F4B-4C40-8A64-6B501B28B42C}
+ false
+
+
+ {AF9323CB-8F8C-4D9F-9E1F-349437DD9C10}
+ false
+
+
+ {6E8E9D3E-8B1F-4C1B-BD5A-9852E5F0C8C2}
+ false
+
+
+
+
+
diff --git a/src/CLRNetInterop/CLRNetInterop.vcxproj b/src/CLRNetInterop/CLRNetInterop.vcxproj
new file mode 100644
index 0000000..6ff4313
--- /dev/null
+++ b/src/CLRNetInterop/CLRNetInterop.vcxproj
@@ -0,0 +1,113 @@
+
+
+
+
+ Debug
+ ARM
+
+
+ Release
+ ARM
+
+
+
+ {AF9323CB-8F8C-4D9F-9E1F-349437DD9C10}
+ Win32Proj
+ CLRNetInterop
+ Windows Phone 8.1
+ 8.1
+ true
+ 8.1
+
+
+
+ DynamicLibrary
+ true
+ v120_wp81
+ Unicode
+
+
+ DynamicLibrary
+ false
+ v120_wp81
+ true
+ Unicode
+
+
+
+
+
+
+
+
+
+
+ $(SolutionDir)build\bin\$(Platform)\$(Configuration)\
+ $(SolutionDir)build\obj\$(Platform)\$(Configuration)\Interop\
+ CLRNetInterop
+
+
+ $(SolutionDir)build\bin\$(Platform)\$(Configuration)\
+ $(SolutionDir)build\obj\$(Platform)\$(Configuration)\Interop\
+ CLRNetInterop
+
+
+
+ NotUsing
+ Level3
+ Disabled
+ WIN32;_WINDOWS;_USRDLL;CLRNETINTEROP_EXPORTS;PLATFORM_WP81;%(PreprocessorDefinitions)
+ $(ProjectDir)..\interop;$(ProjectDir)..\interop\hardware;$(ProjectDir)..\interop\winrt;$(ProjectDir)..\interop\pinvoke;$(ProjectDir)..\interop\security;$(ProjectDir)..\phase1-userland\core;%(AdditionalIncludeDirectories)
+ MultiThreadedDebugDLL
+ true
+
+
+ Windows
+ true
+ CLRNetCore.lib;runtimeobject.lib;windowsapp.lib;%(AdditionalDependencies)
+
+
+
+
+ NotUsing
+ Level3
+ MaxSpeed
+ true
+ true
+ WIN32;_WINDOWS;_USRDLL;CLRNETINTEROP_EXPORTS;PLATFORM_WP81;NDEBUG;%(PreprocessorDefinitions)
+ $(ProjectDir)..\interop;$(ProjectDir)..\interop\hardware;$(ProjectDir)..\interop\winrt;$(ProjectDir)..\interop\pinvoke;$(ProjectDir)..\interop\security;$(ProjectDir)..\phase1-userland\core;%(AdditionalIncludeDirectories)
+ MultiThreadedDLL
+ true
+
+
+ Windows
+ true
+ true
+ true
+ CLRNetCore.lib;runtimeobject.lib;windowsapp.lib;%(AdditionalDependencies)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {8F4C5A55-2F4B-4C40-8A64-6B501B28B42C}
+ false
+
+
+
+
+
diff --git a/src/CLRNetSystem/CLRNetSystem.vcxproj b/src/CLRNetSystem/CLRNetSystem.vcxproj
new file mode 100644
index 0000000..c9805ac
--- /dev/null
+++ b/src/CLRNetSystem/CLRNetSystem.vcxproj
@@ -0,0 +1,113 @@
+
+
+
+
+ Debug
+ ARM
+
+
+ Release
+ ARM
+
+
+
+ {6E8E9D3E-8B1F-4C1B-BD5A-9852E5F0C8C2}
+ Win32Proj
+ CLRNetSystem
+ Windows Phone 8.1
+ 8.1
+ true
+ 8.1
+
+
+
+ DynamicLibrary
+ true
+ v120_wp81
+ Unicode
+
+
+ DynamicLibrary
+ false
+ v120_wp81
+ true
+ Unicode
+
+
+
+
+
+
+
+
+
+
+ $(SolutionDir)build\bin\$(Platform)\$(Configuration)\
+ $(SolutionDir)build\obj\$(Platform)\$(Configuration)\System\
+ CLRNetSystem
+
+
+ $(SolutionDir)build\bin\$(Platform)\$(Configuration)\
+ $(SolutionDir)build\obj\$(Platform)\$(Configuration)\System\
+ CLRNetSystem
+
+
+
+ NotUsing
+ Level3
+ Disabled
+ WIN32;_WINDOWS;_USRDLL;CLRNETSYSTEM_EXPORTS;PLATFORM_WP81;%(PreprocessorDefinitions)
+ $(ProjectDir)..\system;$(ProjectDir)..\system\compatibility;$(ProjectDir)..\system\hooks;$(ProjectDir)..\system\replacement;$(ProjectDir)..\system\safety;$(ProjectDir)..\phase1-userland\core;%(AdditionalIncludeDirectories)
+ MultiThreadedDebugDLL
+ true
+
+
+ Windows
+ true
+ CLRNetCore.lib;CLRNetInterop.lib;runtimeobject.lib;windowsapp.lib;%(AdditionalDependencies)
+
+
+
+
+ NotUsing
+ Level3
+ MaxSpeed
+ true
+ true
+ WIN32;_WINDOWS;_USRDLL;CLRNETSYSTEM_EXPORTS;PLATFORM_WP81;NDEBUG;%(PreprocessorDefinitions)
+ $(ProjectDir)..\system;$(ProjectDir)..\system\compatibility;$(ProjectDir)..\system\hooks;$(ProjectDir)..\system\replacement;$(ProjectDir)..\system\safety;$(ProjectDir)..\phase1-userland\core;%(AdditionalIncludeDirectories)
+ MultiThreadedDLL
+ true
+
+
+ Windows
+ true
+ true
+ true
+ CLRNetCore.lib;CLRNetInterop.lib;runtimeobject.lib;windowsapp.lib;%(AdditionalDependencies)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {8F4C5A55-2F4B-4C40-8A64-6B501B28B42C}
+ false
+
+
+ {AF9323CB-8F8C-4D9F-9E1F-349437DD9C10}
+ false
+
+
+
+
+
diff --git a/src/host/CLRNetHost.cpp b/src/host/CLRNetHost.cpp
deleted file mode 100644
index ec0735b..0000000
--- a/src/host/CLRNetHost.cpp
+++ /dev/null
@@ -1,345 +0,0 @@
-// CLRNet Runtime Host - Main Entry Point for CLR Runtime
-// This executable hosts the modern .NET runtime for Windows Phone 8.1
-
-#include
-#include
-#include
-#include
-
-// CLRNet Core Runtime Headers
-#ifdef CLRNET_CORE_AVAILABLE
-#include "../phase1-userland/core/CoreExecutionEngine.h"
-#include "../phase1-userland/core/TypeSystem.h"
-#include "../phase1-userland/core/GarbageCollector.h"
-#include "../phase1-userland/core/AssemblyLoader.h"
-#include "../phase1-userland/core/SimpleJIT.h"
-#endif
-
-// CLRNet Interop Headers
-#ifdef CLRNET_INTEROP_AVAILABLE
-#include "../interop/InteropManager.h"
-#include "../interop/winrt/WinRTBridge.h"
-#include "../interop/hardware/HardwareAccess.h"
-#endif
-
-// CLRNet System Headers
-#ifdef CLRNET_SYSTEM_AVAILABLE
-#include "../system/replacement/CLRReplacementEngine.h"
-#include "../system/hooks/DeepSystemHooks.h"
-#include "../system/compatibility/CompatibilityShim.h"
-#endif
-
-using namespace std;
-
-// Forward declarations
-int InitializeRuntime();
-int ExecuteAssembly(const wstring& assemblyPath);
-void DisplayRuntimeInfo();
-void DisplayUsage();
-void DisplayStartupBanner();
-
-// Global runtime components
-#ifdef CLRNET_CORE_AVAILABLE
-using namespace CLRNet::Core;
-static unique_ptr g_executionEngine;
-static unique_ptr g_typeSystem;
-static unique_ptr g_garbageCollector;
-static unique_ptr g_assemblyLoader;
-static unique_ptr g_jitCompiler;
-#endif
-
-int wmain(int argc, wchar_t* argv[])
-{
- DisplayStartupBanner();
-
- // Parse command line arguments
- if (argc < 2) {
- DisplayUsage();
- return 1;
- }
-
- wstring command = argv[1];
-
- if (command == L"--info" || command == L"-i") {
- DisplayRuntimeInfo();
- return 0;
- }
- else if (command == L"--help" || command == L"-h") {
- DisplayUsage();
- return 0;
- }
- else if (command == L"--execute" || command == L"-e") {
- if (argc < 3) {
- wcout << L"[ERROR] No assembly specified for execution" << endl;
- return 1;
- }
-
- // Initialize runtime
- if (InitializeRuntime() != 0) {
- wcout << L"[ERROR] Failed to initialize CLRNet runtime" << endl;
- return 1;
- }
-
- // Execute specified assembly
- wstring assemblyPath = argv[2];
- return ExecuteAssembly(assemblyPath);
- }
- else {
- wcout << L"[ERROR] Unknown command: " << command << endl;
- DisplayUsage();
- return 1;
- }
-}
-
-void DisplayStartupBanner()
-{
- wcout << L"===============================================" << endl;
- wcout << L" CLRNet Runtime Host v1.0.0 " << endl;
- wcout << L" Modern .NET Runtime for Windows Phone 8.1 " << endl;
- wcout << L"===============================================" << endl;
- wcout << endl;
-}
-
-void DisplayUsage()
-{
- wcout << L"Usage: CLRNetHost.exe [command] [options]" << endl;
- wcout << endl;
- wcout << L"Commands:" << endl;
- wcout << L" --execute, -e Execute a .NET assembly" << endl;
- wcout << L" --info, -i Display runtime information" << endl;
- wcout << L" --help, -h Display this help message" << endl;
- wcout << endl;
- wcout << L"Examples:" << endl;
- wcout << L" CLRNetHost.exe -e MyApp.exe" << endl;
- wcout << L" CLRNetHost.exe -i" << endl;
- wcout << endl;
-}
-
-void DisplayRuntimeInfo()
-{
- wcout << L"CLRNet Runtime Information:" << endl;
- wcout << L"===========================" << endl;
- wcout << endl;
-
-#ifdef CLRNET_CORE_AVAILABLE
- wcout << L"Core Runtime: AVAILABLE" << endl;
- wcout << L"- Execution Engine: Yes" << endl;
- wcout << L"- Type System: Yes" << endl;
- wcout << L"- Garbage Collector: Yes" << endl;
- wcout << L"- Assembly Loader: Yes" << endl;
- wcout << L"- JIT Compiler: Yes" << endl;
-#else
- wcout << L"Core Runtime: NOT AVAILABLE" << endl;
-#endif
-
-#ifdef CLRNET_INTEROP_AVAILABLE
- wcout << L"System Interop: AVAILABLE" << endl;
- wcout << L"- WinRT Bridge: Yes" << endl;
- wcout << L"- Hardware Access: Yes" << endl;
- wcout << L"- P/Invoke Engine: Yes" << endl;
-#else
- wcout << L"System Interop: NOT AVAILABLE" << endl;
-#endif
-
-#ifdef CLRNET_SYSTEM_AVAILABLE
- wcout << L"System Integration: AVAILABLE" << endl;
- wcout << L"- CLR Replacement: Yes" << endl;
- wcout << L"- System Hooks: Yes" << endl;
- wcout << L"- Compatibility: Yes" << endl;
-#else
- wcout << L"System Integration: NOT AVAILABLE" << endl;
-#endif
-
- wcout << endl;
- wcout << L"Runtime Features:" << endl;
- wcout << L"- Target Platform: Windows Phone 8.1 ARM" << endl;
- wcout << L"- Runtime Version: 1.0.0" << endl;
- wcout << L"- Build Date: " << __DATE__ << L" " << __TIME__ << endl;
- wcout << L"- Architecture: " <<
-#ifdef _M_ARM
- L"ARM"
-#elif defined(_M_X64)
- L"x64"
-#elif defined(_M_IX86)
- L"x86"
-#else
- L"Unknown"
-#endif
- << endl;
-
- wcout << endl;
- wcout << L"Performance Characteristics:" << endl;
- wcout << L"- Startup Time: <200ms (vs 500ms+ legacy CLR)" << endl;
- wcout << L"- Memory Usage: ~15MB base (vs 25MB+ legacy CLR)" << endl;
- wcout << L"- JIT Performance: 50+ methods/sec (vs 20-30 legacy CLR)" << endl;
- wcout << L"- GC Pause Times: <5ms (vs 10ms+ legacy CLR)" << endl;
- wcout << endl;
-}
-
-int InitializeRuntime()
-{
- wcout << L"[INFO] Initializing CLRNet Runtime..." << endl;
-
-#ifdef CLRNET_CORE_AVAILABLE
- try {
- // Initialize Core Execution Engine
- wcout << L"[INIT] Core Execution Engine..." << endl;
- g_executionEngine = make_unique();
- if (!g_executionEngine->Initialize()) {
- wcout << L"[ERROR] Failed to initialize Core Execution Engine" << endl;
- return 1;
- }
-
- // Initialize Type System
- wcout << L"[INIT] Type System..." << endl;
- g_typeSystem = make_unique();
- if (!g_typeSystem->Initialize()) {
- wcout << L"[ERROR] Failed to initialize Type System" << endl;
- return 1;
- }
-
- // Initialize Garbage Collector
- wcout << L"[INIT] Garbage Collector..." << endl;
- g_garbageCollector = make_unique();
- if (!g_garbageCollector->Initialize()) {
- wcout << L"[ERROR] Failed to initialize Garbage Collector" << endl;
- return 1;
- }
-
- // Initialize Assembly Loader
- wcout << L"[INIT] Assembly Loader..." << endl;
- g_assemblyLoader = make_unique(g_typeSystem.get());
- if (!g_assemblyLoader->Initialize()) {
- wcout << L"[ERROR] Failed to initialize Assembly Loader" << endl;
- return 1;
- }
-
- g_assemblyLoader->RefreshOverlayConfiguration();
-
- // Initialize JIT Compiler
- wcout << L"[INIT] JIT Compiler..." << endl;
- g_jitCompiler = make_unique();
- if (!g_jitCompiler->Initialize()) {
- wcout << L"[ERROR] Failed to initialize JIT Compiler" << endl;
- return 1;
- }
-
- wcout << L"[SUCCESS] Core runtime initialized successfully" << endl;
- }
- catch (const exception& e) {
- wcout << L"[ERROR] Exception during runtime initialization: " << e.what() << endl;
- return 1;
- }
-#else
- wcout << L"[WARNING] Core runtime not available in this build" << endl;
-#endif
-
-#ifdef CLRNET_INTEROP_AVAILABLE
- try {
- wcout << L"[INIT] System interop layer..." << endl;
- // Initialize interop components here
- wcout << L"[SUCCESS] Interop layer initialized" << endl;
- }
- catch (const exception& e) {
- wcout << L"[WARNING] Interop initialization failed: " << e.what() << endl;
- }
-#endif
-
-#ifdef CLRNET_SYSTEM_AVAILABLE
- try {
- wcout << L"[INIT] System integration layer..." << endl;
- // Initialize system integration components here
- wcout << L"[SUCCESS] System integration initialized" << endl;
- }
- catch (const exception& e) {
- wcout << L"[WARNING] System integration initialization failed: " << e.what() << endl;
- }
-#endif
-
- wcout << L"[SUCCESS] CLRNet Runtime initialization complete!" << endl;
- wcout << endl;
- return 0;
-}
-
-int ExecuteAssembly(const wstring& assemblyPath)
-{
- wcout << L"[EXEC] Loading assembly: " << assemblyPath << endl;
-
-#ifdef CLRNET_CORE_AVAILABLE
- if (!g_assemblyLoader || !g_executionEngine) {
- wcout << L"[ERROR] Runtime not properly initialized" << endl;
- return 1;
- }
-
- try {
- // Load the assembly
- wcout << L"[LOAD] Loading assembly..." << endl;
- auto assembly = g_assemblyLoader->LoadAssembly(assemblyPath);
- if (!assembly.IsValid()) {
- wcout << L"[ERROR] Failed to load assembly: " << assemblyPath << endl;
- return 1;
- }
-
- wcout << L"[SUCCESS] Assembly loaded successfully" << endl;
- wcout << L"[INFO] Assembly: " << assembly.GetName() << endl;
- wcout << L"[INFO] Version: " << assembly.GetVersion() << endl;
-
- // Find entry point
- wcout << L"[ENTRY] Locating entry point..." << endl;
- auto entryPoint = assembly.GetEntryPoint();
- if (!entryPoint.IsValid()) {
- wcout << L"[ERROR] No entry point found in assembly" << endl;
- return 1;
- }
-
- wcout << L"[SUCCESS] Entry point found: " << entryPoint.GetName() << endl;
-
- // Execute entry point
- wcout << L"[EXEC] Executing assembly..." << endl;
- wcout << L"===============================================" << endl;
-
- int result = g_executionEngine->ExecuteMethod(entryPoint);
-
- wcout << L"===============================================" << endl;
- wcout << L"[COMPLETE] Assembly execution finished with exit code: " << result << endl;
-
- // Display runtime statistics
- auto stats = g_executionEngine->GetRuntimeStatistics();
- wcout << endl;
- wcout << L"Runtime Statistics:" << endl;
- wcout << L"- Methods compiled: " << stats.methodsCompiled << endl;
- wcout << L"- Memory allocated: " << stats.totalMemoryAllocated << L" bytes" << endl;
- wcout << L"- GC collections: " << stats.gcCollections << endl;
- wcout << L"- Execution time: " << stats.executionTimeMs << L" ms" << endl;
-
- return result;
- }
- catch (const exception& e) {
- wcout << L"[ERROR] Exception during assembly execution: " << e.what() << endl;
- return 1;
- }
-#else
- wcout << L"[ERROR] Core runtime not available - cannot execute assemblies" << endl;
- wcout << L"[INFO] This build of CLRNet only supports runtime information display" << endl;
- return 1;
-#endif
-}
-
-// Entry point for DLL builds (if needed)
-#ifdef _USRDLL
-BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved)
-{
- switch (ul_reason_for_call)
- {
- case DLL_PROCESS_ATTACH:
- break;
- case DLL_THREAD_ATTACH:
- break;
- case DLL_THREAD_DETACH:
- break;
- case DLL_PROCESS_DETACH:
- break;
- }
- return TRUE;
-}
-#endif
\ No newline at end of file
diff --git a/src/interop/security/SecurityManager.cpp b/src/interop/security/SecurityManager.cpp
new file mode 100644
index 0000000..1657e95
--- /dev/null
+++ b/src/interop/security/SecurityManager.cpp
@@ -0,0 +1,1146 @@
+#include "SecurityManager.h"
+
+#include
+#include
+#include
+#include
+#include