WIL
During NDIS internals research something suspicious was found

ndis!_NDIS_MINIPORT_BLOCK
Something like:
wil::unique_any_t<wil::details::unique_storage<wil::details::resource_policy<NDISWATCHDOG__ *,void (cdecl*)(NDISWATCHDOG *),&ndisFreeWatchdog,wistd::integral_constant<unsigned int64,1>,NDISWATCHDOG *,-1,std::nullptr_t> > >
This is from Windows Implementation Libraries (WIL), it is a header only library, just download and use:
#include "wil\resource.h"
Usage:
NTSTATUS example_1()
{
lock_acquire(&lock);
lock->owner = KeGetCurrentThread();
auto guard = wil::scope_exit([&]() {
lock->owner = nullptr;
lock_release(&lock);
});
if ( . . . failure . . .)
return STATUS_UNSUCCESSFUL; // lock is released via wil::scope_exit
return STATUS_SUCCESS; // lock is released via wil::scope_exit
}
NTSTATUS example_2()
{
RETURN_IF_NTSTATUS_FAILED(ZwCreateFile(. . . ));
return STATUS_SUCCESS;
}
So, if someone want to use C++ in the drivers, WIL can be considered for sure:

C++ driver configuration (MSVC)
