[Project] An extensible (plugin based) windows service that performs actions for NFC events
-
So I've just made a C# .Net project using MEF that runs as a windows service, checks a USB nfc reader and triggers events "NFCTagDown" and "NFCTagUp" respectively, passing the ID of the ring across to the set of plugins. It is possible to run multiple plugins / actions for each event (you'd probably want to have some way to register an NFC tag to a plugin).
The first attempt I made was to lock the PC with a swipe of the NFC ring (to go with my credentialprovider unlock project) but it seems that the new Session 0 isolation security measure blocks the service from performing this action. Even when I have marked the service as "Allow service to interact with desktop".
Call to action:
-
Does anyone have any ideas for how to lock a windows 8 / 10 pc from a service in C#? I've tried
[DllImport("user32.dll")]
public static extern bool LockWorkStation();
and
Process.Start(@"C:\WINDOWS\system32\rundll32.exe", "user32.dll,LockWorkStation"); -
What other plugins / actions would people want to perform?
-
What events are developers interested in for their own plugins?
Apparently I can't upload files here so I've shared it off my website in case people wanted the code. When I have a plugin that works I'll push it to github. The code is under an MIT license. Go nuts with it.
http://maz.net.au/Files/Public/NFCRingServiceCore.zipNote: this is for developers only at the moment. You need to use installutil.exe to install the service.
-
-
Got the lock workstation working. It's a bit more complicated than i had hoped but thats the advantage of a plugin framework. You put an 8kb dll into the plugins folder and it just works.
-
Code at the link above has been updated. New video showing it working is..
What's next?
-
Wow, that's looking excellent!
So the next step would be providing an easy to use interface for getting started.
The basic startup interface should just handle registering of cards to accounts (so they can be used to unlock the current logged in user).
Did we check to see if this works with accounts linked to Microsoft online accounts?
-
@maz_net_au Looking great :) cant wait to get the finished product
-
I don't know how much time I'm going to have in the short term. I am getting ready to move countries. I was hoping that the kickstarter would be run and that could be used for polishing / making installers / making it user friendly.
I'll still try and work on this in my evenings and I'm definitely available to help other people get up to speed on what I've done.
Maz -
Yea that's the plan @maz_net_au
We didn't launch the KS yet as I'm waiting on Reader supplier confirmation from Lokki / our suppliers
-
One to go, I believe...
-
I found a memory leak in the service (in the sense that I noticed it was consuming 18gb of ram after 8 days. Hopefully that is now fixed but I'll have to keep an eye on it for a while to make sure.
Maz -
@maz_net_au Good spot!
-
It doesn't leak on the polling for NFC data (I need to remember to upload that code too) but it still uses about 300k - 500k for each lock / unlock cycle. On the upside, that is probably in the C# side of things so should be much easier to find.
Next time I get a chance, I'll look at linking the service and the credential provider (I have to extend the plugin framework to add events for PluginAdded, RegisterRing (to a particular plugin), DeregisterRing. I'm hoping to (or that someone else does) make a plugin that uses the data section of the ring to perform various tasks, almost like encoding a set of preferences into a tiny data structure.
As I get closer to moving overseas, I might actually have a few days to work on my own projects (once I've packed up my house and cancelled internet and stuff I'm limited as to how much work I can do before I fly out). Maybe I'll get to those features then if no one else has.
I've also looked at making an installer package and it shouldn't be too hard when it only has to support windows. 7, 8, 8.1 and 10 should be achievable (Vista may or may not work but in theory I've not used any features introduced since then) but I'll need help testing.
-
Code updated at that same link (fixing the memory leak which was in the WinAPIWrapper.dll). It's now 5mb and includes my WinAPIWrapper c++ project that I'm using to talk to the nfc reader.
Anyone who has installed the service, I'd at least recommend that you copy the latest x64 release WinAPIWrapper.dll into your service directory. -
In the interest of supporting more devices. Could people post what USB NFC readers they have? I'm using an ACS ACR122U and i've been told about the HID-OMNIKEY 6321 having issues. If people can tell me what devices they're using then I can buy them to test with. Thanks
Maz -
Maybe try to add ACR1252U, ACR122T, SCM SCL3711 devices to the compatibility list
-
The problem w/ the 6321 is that it shows up as two smart card readers. You could replicate this problem by having 2x ACR122Us plugged in :)
-
I am temporarily unable to buy any hardware due to relocating across the world in a week and a bit. My plan is to order all of the readers listed once i get there. Until then, my involvement in this project is basically on hold although I'll do bug fixes for anything I can replicate with my current hardware.
Maz -
Just after I wrote that I went back through the code and found what might be causing the 6321 and multiple reader failure. So... expect an update tomorrow (about 12 hours from now).
Maz -
Awesome! I'm using the software now and it's working a treat w/ ACR122
-
Also working well w/OMNIKEY 5021 CL (Win10 x64)
-
I'm really excited about this software. I cannot wait until there is an installer for it. Also how is the kick starter going ? is that still happening ? @johnyma22 since it seems so close already have you considered to just sell it in the NFC ring store any bypass the kick starter ? This may save time in getting it to all the punters.