Is there any way, without using DLL injection, services, and whatnot, to unlock the local computer using .net? The windows username and password is available to my program.
I think there is no .NET function that you can use to unlock your computer and there is no short way to achieve it. But there is a way.
You need to implement your custom ICredentialProvider componet, hook it into the windows authentication mechanism, and implement communication between it and your application.
The Windows 7 authentication mechanism consists of two parts. They are WinLogon and LogonUI. LogonUI is responsible for displaying a login window and notification of WinLogon about users’ actions. Winlogon reacts for events from LogonUI and performs required actions to log-in users, log-off users, lock sessions, and unlock sessions.
Microsoft provides a mechanism to hook a custom behavior into LogonUI. To do this you need to create a COM object that implements ICredentialProvider and register it with a system. You component can tell LogonUI to tell WinLogon to unlock a session.
Here are couple examples of how to build custom credential providers: How to Build Custom Logon UI’s in Windows Vista, Create Custom Login Experiences With Credential Providers For Windows Vista
This mechanism will work for Windows Vista and Windows 7. You need to use similar mechanism called GINA if you want to achieve the same result for Windows XP. Here you can read more about GINA: Winlogon and GINA
There was a hack that you could kind of “unlock” a session in Windows XP.
WinLogon in Windows XP created an additional desktop and switched to it when user chose to lock a session. It was possible to switch back to a “normal” desktop using Windows API. Everything worked fine except WinLogon still though that system is locked and did not react for Ctrl-Alt-Del. I believe that it will not work for Windows Vista and 7. But you could try. It can be simple than implementing a custom credential provider.
Here is an example of how to do that: Remotely Unlock a Windows Workstation
I hope this answered your question.
No there isn't, at least not within the context specified in your question. But i have to ask - why do you want it unlocked? If you need an application to run, the machine doesn't have to be unlocked for that to happen.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With