Git Product home page Git Product logo

wsl-sdk-com's Introduction

Out-of-process COM server style WSL SDK

한국어 버전의 README는 이곳에서 읽으실 수 있습니다.

WSL COM SDK Build Pipeline

SDK Sample Application

This project contains the out-of-process style COM server-based WSL APIs, which overcome the CoInitializeSecurity issues and still maintain ease of code management with the .NET Framework.

You can use this OOP-style COM server to query and run WSL commands via the Windows PowerShell, LINQPad, and all COM-supported clients. Once registered, every time you call the COM interface, the executable file automatically called and launched on-demand. If the reference count reaches zero, the process is automatically closed.

How to build and test

  1. You can start building this project with the .NET Framework SDK v4.0 or higher and the Windows 10, at least 1903 or higher release.
  2. Build a release of the WslSdk project, and register the OOP COM server via elevated permission with the Install.cmd batch file.
  3. You can run the unit test from now on or run the sample PowerShell script to test.
    $ErrorActionPreference = "Stop"
    $obj = New-Object -ComObject 'WslSdk.WslService'
    
    Write-Output 'A WslSdk.WslService object is created'
    
    # Distro Register Check
    $distroName = 'Ubuntu-20.04'
    Write-Output $obj.IsDistroRegistered($distroName)
    
    # Metadata Query
    $o = $obj.GetDefaultDistro()
    Write-Output "Distro ID: $($o.DistroId())"
    Write-Output "Distro Name: $($o.DistroName())"
    
    $list = $obj.GetDistroList()
    Write-Output $list
    
    # Run WSL command
    $res = $obj.RunWslCommand($o.DistroName(), "cat /etc/os-release")
    Write-Output $res
    
    $obj = $null
  4. If you uninstall the OOP COM server, call the Uninstall.cmd batch file via the elevated permission.

Code Samples

Some caveats

  • Due to the lack of official WSL COM interface specification, I currently made this SDK with the limited WSL Win32 APIs.
  • Due to the lack of a full COM integration feature, I do not choose the .NET Core and .NET 5+ to develop this SDK. Currently, .NET Core and .NET 5+ makes it very complicated to build an OOP COM server. However, if there are any improvements, I'll try migrating to .NET Core or .NET 5+ runtime.
  • I tried to make this OOP COM server a registration-free module but failed. If anyone contributes to this enhancement, it makes even more flexibility to use this SDK.

Things-to-do

  • Make v1 COM Interface documentation
  • Add ARM64 Support

Open Source License Information

This project uses the MIT license. Please refer LICENSE.txt.

wsl-sdk-com's People

Contributors

rkttu avatar xeppetto avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.