Exetools

Exetools (https://forum.exetools.com/index.php)
-   General Discussion (https://forum.exetools.com/forumdisplay.php?f=2)
-   -   CTRL + ALT + DEL Disable (https://forum.exetools.com/showthread.php?t=15201)

BoB 09-03-2013 08:15

Hi, you can create a new desktop object, which avoids Alt + Tab, Ctrl + Alt + Del ..

Code:

hOldThreadDesktop := GetThreadDesktop(GetCurrentThreadId);
hOldInputDesktop := OpenInputDesktop(0, FALSE, DESKTOP_CREATEWINDOW + DESKTOP_SWITCHDESKTOP);
hLockedDesktop := CreateDesktop('LockedDesktop', nil, nil, 0, DESKTOP_CREATEWINDOW + DESKTOP_SWITCHDESKTOP, nil);
SetThreadDesktop(hLockedDesktop);
SwitchDesktop(hLockedDesktop);

..Then run your application within that new desktop ..

Code:

SI.cb := SizeOf(StartupInfo);
SI.lpDesktop := PChar('LockedDesktop');
If CreateProcess(nil, 'YourApp.exe', nil, nil, True, 0, nil, nil, SI, PI) Then
  WaitForSingleObject(PI.hProcess, INFINITE);

..And when your app exits, return to 'real' desktop ..

Code:

if hOldInputDesktop <> 0 then SwitchDesktop(hOldInputDesktop);
if hOldThreadDesktop <> 0 then SetThreadDesktop(hOldThreadDesktop);
if hLockedDesktop <> 0 then CloseDesktop(hLockedDesktop);


See Desktops @ MSDN

Have fun!
BoB

ontryit 09-03-2013 10:41

Quote:

Originally Posted by wilson bibe (Post 86513)
Private Type NOTIFYICONDATA
cbSize As Long
hWnd As Long
uId As Long
uFlags As Long
ucallbackMessage As Long
hIcon As Long
szTip As String * 64
End Type
Private Const NIM_DELETE = &H2
Private Declare Function Shell_NotifyIcon Lib "shell32" Alias "Shell_NotifyIconA" (ByVal dwMessage As Long, pnid As NOTIFYICONDATA) As Boolean
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long

Private Sub Form_Load()
Dim tskWin As Long
Dim t As NOTIFYICONDATA
Shell "taskmgr.exe", vbHide
Do Until tskWin <> 0
tskWin = FindWindow("#32770", "the name of window of takmager.exe in your language")
Loop
t.hWnd = tskWin
Shell_NotifyIcon NIM_DELETE, t
End Sub

Create an .dll file with this code, call it by inserting a code in the code cave of your app, work in all the files that I develope to sell when I need to lock the sequence crtl+alt+del.
*you don't need admin previlegies to run it
**translate this code to the language that you used in your app
BR

This isn't real solution to disable ctrl+alt+del keys but only hidden the "taskmgr.exe" from shown. This will only affect on xp but not on w7 when the ctrl+alt+del key was pressed.

Alternate way just like your code do, you can also do this:

Code:

Open "C:\Windows\System32\Taskmgr.exe" For Input Lock Read Write As #1

ontryit 09-03-2013 10:49

Quote:

Originally Posted by BoB (Post 86556)
Hi, you can create a new desktop object, which avoids Alt + Tab, Ctrl + Alt + Del ..

Code:

hOldThreadDesktop := GetThreadDesktop(GetCurrentThreadId);
hOldInputDesktop := OpenInputDesktop(0, FALSE, DESKTOP_CREATEWINDOW + DESKTOP_SWITCHDESKTOP);
hLockedDesktop := CreateDesktop('LockedDesktop', nil, nil, 0, DESKTOP_CREATEWINDOW + DESKTOP_SWITCHDESKTOP, nil);
SetThreadDesktop(hLockedDesktop);
SwitchDesktop(hLockedDesktop);

..Then run your application within that new desktop ..

Code:

SI.cb := SizeOf(StartupInfo);
SI.lpDesktop := PChar('LockedDesktop');
If CreateProcess(nil, 'YourApp.exe', nil, nil, True, 0, nil, nil, SI, PI) Then
  WaitForSingleObject(PI.hProcess, INFINITE);

..And when your app exits, return to 'real' desktop ..

Code:

if hOldInputDesktop <> 0 then SwitchDesktop(hOldInputDesktop);
if hOldThreadDesktop <> 0 then SetThreadDesktop(hOldThreadDesktop);
if hLockedDesktop <> 0 then CloseDesktop(hLockedDesktop);


See Desktops @ MSDN

Have fun!
BoB

This solution was recommended by Microsoft but only for XP, you need to add a code to avoid taskmgr from shown on the default desktop when the the ctrl+alt+del/ctrl+shift+esc keys was pressed on xp in order to not make it suspiously looking. on W7 this solution can't be disable ctrl+alt+del keys

wilson bibe 09-03-2013 11:47

@ontryit
Did You really see the code?

Quote:

Private Declare Function Shell_NotifyIcon Lib "shell32" Alias "Shell_NotifyIconA" (ByVal dwMessage As Long, pnid As NOTIFYICONDATA) As Boolean
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
You wrote Open "C:\Windows\System32\Taskmgr.exe" For Input Lock Read Write As #1, for what this instruction? I believe that you wanted to write
Quote:

Open "C:\Windows\System32\Taskmgr.exe" For Random As #1
useless too, Maybe you need to study a little more about VB6. I work with this language a long time :-), If this dll file works or not in another OS except XP, really I don't know because I lock all my apps to another versions of windows, obvious using VB6 too ok?
BR

ontryit 09-06-2013 13:38

wilson bibe: sorry, i not an expert on vb but i know how your code works, its only run hidden the taskmgr.exe and delete the icon on the systray. But with this methode, you are not really disable ctl+alt+del keys (i mean, if you have some code that will BlockInput, it will be free when these keys was pressed - http://msdn.microsoft.com/en-us/libr...=vs.85%29.aspx)

The real way to disable these keys on XP was replaced msgina.dll with your own or hook the SAS Window (undocumented) but on Vista above there are another way that i was not found yet :).

wilson bibe 09-06-2013 19:52

@ontryit
No need "sorry" mate, believe the code works, I use it there are 05 years, always in the code cave.
All the best


All times are GMT +8. The time now is 03:10.

Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2026, vBulletin Solutions, Inc.
Always Your Best Friend: Aaron, JMI, ahmadmansoor, ZeNiX