|
-
Oct 7th, 2001, 04:13 PM
#1
Thread Starter
Member
Simulate CTLR + ALT + DEL
I am trying to simulate all sort of key presses, CTRL + ALT + DEL being one of them.
I have tried GetKeyboardState and SetKeyboardState to no avail. I'z prolly doing something wrong.
I am runing Win2K, if that makes a difference?
Anywayz, thanks in advance.
I ain't the best coder,
I ain't the worst coder
Messanger Handle : FBz
-
Oct 7th, 2001, 06:36 PM
#2
I read somewhere that as a safety feature, Ctrl+Alt+Del will only function when hardware interrupts are sent (e.g: when the physical keys are pressed).
-
Oct 7th, 2001, 07:23 PM
#3
Member
-
Oct 8th, 2001, 03:40 PM
#4
Thread Starter
Member
Cheerz guys.
I'll get there! I know it's possible, but just don't know how yet!!
I ain't the best coder,
I ain't the worst coder
Messanger Handle : FBz
-
Oct 8th, 2001, 04:21 PM
#5
Member
Have you taken a peek at these?
-
Oct 8th, 2001, 04:24 PM
#6
Addicted Member
AFAIK, in WinNT platforms the only way to simulate that key combination is to create your own "Graphical Identification and Authentication" module, or GINA for short.
Don't ask me how as I have no idea, but I believe there are some examples of GINAs in the Platform SDK (although I bet they are in C++).
-
Oct 8th, 2001, 04:31 PM
#7
PowerPoster
I don't think it's pos, certainly not in win2k. There's an option for the user to have to press CTRL+ALT+DEL to log on, change pwd etc, and it says this is a security feature because Windows will only respond to actual keystrokes
I tried on win98 and 2k, neither of which produced any joy.
-
Oct 8th, 2001, 04:37 PM
#8
Addicted Member
Originally posted by chrisjk
I don't think it's pos, certainly not in win2k. There's an option for the user to have to press CTRL+ALT+DEL to log on, change pwd etc, and it says this is a security feature because Windows will only respond to actual keystrokes
I tried on win98 and 2k, neither of which produced any joy.
Everything is possible, including this one. pcAnywhere does it so I believe us mortals can too (not very easy do).
-
Oct 8th, 2001, 04:42 PM
#9
PowerPoster
okay, but why would MS go to the bother of implementing this CTRL+ALT+DEL "safety feature" if it could easily be simulated?
-
Oct 8th, 2001, 04:49 PM
#10
Addicted Member
Originally posted by chrisjk
okay, but why would MS go to the bother of implementing this CTRL+ALT+DEL "safety feature" if it could easily be simulated?
Remove the "easily" from your sentence, and then I'd answer, Who the hell knows?
-
Oct 9th, 2001, 06:30 AM
#11
Black Cat
It's to guarantee that pressing Ctrl+Alt+Del before inputtung your password is done by the OS, not a Trojan horse program or something
Josh
Get these: Mozilla Opera OpenBSD
I have books for sale: "MCSD in a Nutshell" and "VB Distributed Exam Cram" - PM me for details. Will also trade for a decent ATX Pentium 2 MB/CPU/RAM combo.
-
Oct 9th, 2001, 12:47 PM
#12
Thread Starter
Member
Yer filburt1 I looked, cheerz. Didn't get the answer tho 
You can disable CTRL+ALT+DELETE, right?
I ain't the best coder,
I ain't the worst coder
Messanger Handle : FBz
-
Oct 9th, 2001, 12:52 PM
#13
PowerPoster
You can disable CTRL+ALT+DELETE, right?
only if you're using Win9x
-
Oct 9th, 2001, 05:13 PM
#14
Thread Starter
Member
Thanks a lot guys, you'z all been really helpful.
One other thing, can I disable and simulate all other keys and combinations tho? just not CTRL+ALT+DELETE
I ain't the best coder,
I ain't the worst coder
Messanger Handle : FBz
-
Oct 9th, 2001, 05:41 PM
#15
PowerPoster
Use SendKeys
% is ALT
^ is CTRL
+ is SHIFT
is ALT+ENTER
is CTRL+ALT+F10
-
Oct 9th, 2001, 05:48 PM
#16
Addicted Member
I wonder why people keep trying to stop users from switching to other programs
Anyway, disabling system shorcuts is only *possible* on Win9x (forget it in Win2k/XP). What you need to do is to cheat Windows telling it that the screen saver is running, this way Windows automatically disables those keys. Correct me if I'm wrong, but I believe SystemParametersInfo is the API function you need.
Live your own life, for you will die your own death.
-
Oct 11th, 2001, 07:43 AM
#17
Hyperactive Member
The way I understand it.....
The way I understand it, PC Anywhere paid a pretty penny to Microsoft to get the code they needed. I don't believe that code has been, is being, or will ever be released to the general programming public. Anyone know any employees of Symantec ? I think that is your best chance. Good Luck. If you somehow find out how, just email me at [email protected].
-
Oct 11th, 2001, 02:59 PM
#18
Lively Member
This is a programming community isn't it? No Net Admins? That is why VNC hasn't been mentioned! I strongly reccomend VNC as a replacement to PCAnywhere. Also it allows a CTRL+ALT+DEL to be sent, only it is installed as a service though, that might be the key. VNC can be found at http://www.uk.research.att.com/vnc/ , the SOURCE in C++ is there, if you have the patience to look through it ( or maybe email the authors) you might be able to find out what you need.
Zevlag
Josh -- Name
Zevlag13 -- AIM
www.WotsIt.org for all your file format spec questions!
-
Oct 11th, 2001, 03:08 PM
#19
Lively Member
helpful?
Here is the relevant code I could find:
Code:
// Static routine used to fool Winlogon into thinking CtrlAltDel was pressed
void *
SimulateCtrlAltDelThreadFn(void *context)
{
HDESK old_desktop = GetThreadDesktop(GetCurrentThreadId());
// Switch into the Winlogon desktop
if (!vncService::SelectDesktop("Winlogon"))
{
log.Print(LL_INTERR, VNCLOG("failed to select logon desktop\n"));
return FALSE;
}
log.Print(LL_ALL, VNCLOG("generating ctrl-alt-del\n"));
// Fake a hotkey event to any windows we find there.... :(
// Winlogon uses hotkeys to trap Ctrl-Alt-Del...
PostMessage(HWND_BROADCAST, WM_HOTKEY, 0, MAKELONG(MOD_ALT | MOD_CONTROL, VK_DELETE));
// Switch back to our original desktop
if (old_desktop != NULL)
vncService::SelectHDESK(old_desktop);
return NULL;
}
// Static routine to simulate Ctrl-Alt-Del locally
BOOL
vncService::SimulateCtrlAltDel()
{
log.Print(LL_ALL, VNCLOG("preparing to generate ctrl-alt-del\n"));
// Are we running on NT?
if (IsWinNT())
{
log.Print(LL_ALL, VNCLOG("spawn ctrl-alt-del thread...\n"));
// *** This is an unpleasant hack. Oh dear.
// I simulate CtrAltDel by posting a WM_HOTKEY message to all
// the windows on the Winlogon desktop.
// This requires that the current thread is part of the Winlogon desktop.
// But the current thread has hooks set & a window open, so it can't
// switch desktops, so I instead spawn a new thread & let that do the work...
omni_thread *thread = omni_thread::create(SimulateCtrlAltDelThreadFn);
if (thread == NULL)
return FALSE;
thread->join(NULL);
return TRUE;
}
return TRUE;
}
Josh -- Name
Zevlag13 -- AIM
www.WotsIt.org for all your file format spec questions!
-
Oct 11th, 2001, 03:52 PM
#20
Here is how to disable ALT-TAB, ALT-ESC, CTRL-ESC in NT4 SP3 and higher and Win2000. (Cant get the CTRL+ALT+DEL to work though). I converted this code from C++ code that was in MSDN.
Add a checkbox control to your form
Module code
VB Code:
Option Explicit
Public Type KBDLLHOOKSTRUCT
vkCode As Long
scanCode As Long
flags As Long
time As Long
dwExtraInfo As Long
End Type
Public Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (Destination As Any, Source As Any, ByVal Length As Long)
Public Declare Function GetKeyState Lib "user32" (ByVal nVirtKey As Long) As Integer
Public Declare Function SetWindowsHookEx Lib "user32" Alias "SetWindowsHookExA" (ByVal idHook As Long, ByVal lpfn As Long, ByVal hmod As Long, ByVal dwThreadId As Long) As Long
Public Declare Function CallNextHookEx Lib "user32" (ByVal hHook As Long, ByVal nCode As Long, ByVal wParam As Long, lParam As Any) As Long
Public Declare Function UnhookWindowsHookEx Lib "user32" (ByVal hHook As Long) As Long
Public Const HC_ACTION = 0
Public Const WM_KEYDOWN = &H100
Public Const WM_KEYUP = &H101
Public Const WM_SYSKEYDOWN = &H104
Public Const WM_SYSKEYUP = &H105
Public Const VK_TAB = &H9
Public Const VK_CONTROL = &H11
Public Const VK_ESCAPE = &H1B
Public Const VK_DELETE = &H2E
Public Const WH_KEYBOARD_LL = 13
Public Const LLKHF_ALTDOWN = &H20
Dim m_udtKEYBOARDHOOK As KBDLLHOOKSTRUCT
Public Function KeyboardProc(ByVal nCode As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Dim blnConsumeKey As Boolean
If (nCode = HC_ACTION) Then
If wParam = WM_KEYDOWN Or wParam = WM_SYSKEYDOWN Or wParam = WM_KEYUP Or wParam = WM_SYSKEYUP Then
CopyMemory m_udtKEYBOARDHOOK, ByVal lParam, Len(m_udtKEYBOARDHOOK)
With m_udtKEYBOARDHOOK
blnConsumeKey = _
((.vkCode = VK_TAB) And ((.flags And LLKHF_ALTDOWN) <> 0)) Or _
((.vkCode = VK_ESCAPE) And ((.flags And LLKHF_ALTDOWN) <> 0)) Or _
((.vkCode = VK_ESCAPE) And ((GetKeyState(VK_CONTROL) And &H8000) <> 0))
End With
End If
End If
If blnConsumeKey Then
KeyboardProc = -1
Else
KeyboardProc = CallNextHookEx(0, nCode, wParam, ByVal lParam)
End If
End Function
Form code
VB Code:
Dim m_lngKeyboad As Long
Private Sub chkDisable_Click()
If chkDisable = vbChecked Then
m_lngKeyboad = SetWindowsHookEx(WH_KEYBOARD_LL, AddressOf KeyboardProc, App.hInstance, 0)
Else
UnhookWindowsHookEx m_lngKeyboad
m_lngKeyboad = 0
End If
End Sub
Private Sub Form_Unload(Cancel As Integer)
If m_lngKeyboad <> 0 Then UnhookWindowsHookEx m_lngKeyboad
End Sub
Note Do not close the application while in IDE, but press X in the form's title bar. If you close it by pressing END button in IDE you wont be able to hook it again without restarting the IDE.
-
Oct 11th, 2001, 04:05 PM
#21
Addicted Member
way to go! I don't understand how the code works, but I'll surely add it to my library.
Live your own life, for you will die your own death.
-
Oct 11th, 2001, 04:37 PM
#22
Thread Starter
Member
Thanks alot guys. You've all been really helpfull.
Cheerz spec to Zevlag, I'll have a bash at figuring out that code (I know more Japanese than C ), and Serge
I ain't the best coder,
I ain't the worst coder
Messanger Handle : FBz
-
Oct 11th, 2001, 05:11 PM
#23
Lively Member
Well, umm, ok, your welcome
If you can't figure out what the code is doing I would recomend that you eMail the authors. I'm sure that they wouldn't mind answering your questions......
Zevlag
Josh -- Name
Zevlag13 -- AIM
www.WotsIt.org for all your file format spec questions!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|