jamiehighfield / windowscredentialprovider

A .NET implementation of the authentication mechanism used within Windows 7, 7, 10 & 11.
6 stars 2 forks source link

No Documentation on how can I use this library #1

Open arshiamohammdii opened 6 months ago

arshiamohammdii commented 6 months ago

hey Jamie thanks for this awesome library does this code work the same as a credential written in C++? cause i haven't seen any references to credentialprovider.h header and there is no document? can you help on how can i use this to write a custom provider?

jamiehighfield commented 4 months ago

Hey, so sort of. This uses something called the Interface Definition Language (IDL) - this is language agnostic. The credentialprovider.h (and other headers) are defined as IDL which is available as part of the Windows SDK. This can then be compiled into the equivalent C# form. It's possible to write the interface definitions directly in C# if you want, but COM is very specific and the smallest mistake will prevent it from working.

This is where the Component Object Model (COM) interop kicks in and acts as the boundary between managed code and the native Winlogon process that hosts the credential providers). In this case, we're using in-process COM hosting (as opposed to out-of-process COM server).

I'm working on the credential provider slowly, but worth checking out the net6-upgrade branch which is a near complete re-write of the library with various improvements. In short, you'll need to create a credential provider using the managed interfaces, compile it as either x64 or x86, stick it in system32 folder, and then register the COM DLL using regsvr32. You'll also need to add <EnableComHosting>true</EnableComHosting> in your csproj file. I'll write up some proper docs when I've got some more time.