Write IIS Native Module In Rust

can i develop a iis native module in iis with Rust Langugae? a interface in c++ language is like this:

#include "pch.h"
#include <Windows.h>
#include <httpserv.h>
#include "HttpFactory.h"

CMyHttpModuleFactory * pFactory = NULL;

HRESULT __stdcall RegisterModule(DWORD dwServerVersion, IHttpModuleRegistrationInfo * pModuleInfo, IHttpServer * pHttpServer)

    HRESULT hr = S_OK;
    // Factory class is responsible for manufacturing instance of our module for each request.
    pFactory = new CMyHttpModuleFactory(); 

    // Register for the server events.
    hr = pModuleInfo->SetRequestNotifications(pFactory, RQ_SEND_RESPONSE, 0);
    return hr;

but i want to develop this dll in rust. haw can i do that? thx

Rust does not have built in support for using C++ APIs, and since IIS doesn’t appear to use COM, you don’t have the shortcut of using that, either. I've read about a few external tools to help, which are nicely summarised at https://blog.tetrane.com/2022/Rust-Cxx-interop.html.

You’ll need to learn a bit about how IIS, C++ and Rust work at at fairly low level to use any of them, it seems, but it will be possible.

(I haven’t used any of them, or IIS, but I did get a “Hello, world” example going with the HTTP Server API.)

Technically speaking, anything you can write in C can be written in Rust.

Interoperating with C++ classes is a bit more complicated, but the cxx project provides a way for Rust code to pass around C++ objects and call methods on them. That means even if there aren't any existing crates which provide an interface to IIS's APIs, you can still call the C++ code directly.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.