I am a VB coder, and I taugh myself that... I really have had very little exposure to VC++ or any C lang to be honest... I am trying to implement the following code using the MSFT Visual C++ 2005 Express app that is avialable online and I just don't know enough about C to begin to understand how everything works, or how to actually utilize the code that is provided. Any assistance would be greatly appreciated. I have assigned 500 points however if someone is willing to walk me through the coding process (Since I am only using C this one time) I will create another points question for the individual that answers the question. I just want this to be an EXE to be executed without any interface (If possible)...
Code I want to use...
Here is a slightly modified LOCKWS.CPP from the "Locking a window station" example which emulates C-A-D if you run LOCK.EXE:
// lockws.cpp
#define STRICT
#include <windows.h>
#include <fstream.h>
HINSTANCE hDll;
CHAR libName[MAX_PATH];
HDESK hWinlogon;
HANDLE hThread=0;
DWORD dwThreadId;
HWND hGeneric,hDialog;
PSECURITY_DESCRIPTOR psd;
// Log files
//ofstream o("C:\\out");
//ofstream o2("C:\\out2");
DWORD WINAPI threadProc(LPVOID);
//------------------------
----------
----------
----------
----------
----------
-
//
// Finds Winlogon generic control dialog
//
BOOL CALLBACK findGeneric(HWND hwnd,LPARAM)
{
CHAR text[1024];
GetWindowText(hwnd,text,si
zeof(text)
);
if(!strcmp(text,"Winlogon generic control dialog")) {
hGeneric=hwnd;
return FALSE;
}
return TRUE;
}
//------------------------
----------
----------
----------
----------
----------
-
//
// Finds Windows NT security dialog
//
BOOL CALLBACK findDialog(HWND hwnd,LPARAM)
{
CHAR text[1024];
GetWindowText(hwnd,text,si
zeof(text)
);
//o2<<text<<' '<<hwnd<<endl;
if(!strcmp(text,"Windows NT Security")) {
hDialog=hwnd;
return FALSE;
}
return TRUE;
}
//------------------------
----------
----------
----------
----------
----------
-
BOOL WINAPI DllEntryPoint(HINSTANCE hinstDLL,DWORD fdwReason,LPVOID)
{
if(fdwReason==DLL_PROCESS_
ATTACH) {
//MessageBeep(-1);
hDll=hinstDLL;
GetModuleFileName(hDll,lib
Name,sizeo
f(libName)
);
hWinlogon=OpenDesktop("Win
logon",0,F
ALSE,
//DESKTOP_CREATEMENU |
//DESKTOP_CREATEWINDOW |
DESKTOP_ENUMERATE |
//DESKTOP_HOOKCONTROL |
//DESKTOP_JOURNALPLAYBACK |
//DESKTOP_JOURNALRECORD |
DESKTOP_READOBJECTS
//DESKTOP_SWITCHDESKTOP |
//DESKTOP_WRITEOBJECTS
);
//o<<"hWinlogon="<<hWinlog
on<<endl;
hThread=CreateThread(0,0,t
hreadProc,
0,0,&dwThr
eadId);
//o<<"hThread="<<hThread<<
endl;
//if(hThread) {
// Make sure we are remain after NINJLIB.EXE
//LoadLibrary(libName);
//}
}
else if(fdwReason==DLL_PROCESS_
DETACH) {
//MessageBeep(-1);
if(hThread) {
TerminateThread(hThread,0)
;
CloseHandle(hThread);
}
CloseDesktop(hWinlogon);
}
return TRUE;
}
//------------------------
----------
----------
----------
----------
----------
-
DWORD WINAPI threadProc(LPVOID)
{
psd=(PSECURITY_DESCRIPTOR)
LocalAlloc(LPTR,
SECURITY_DESCRIPTOR_MIN_LE
NGTH);
InitializeSecurityDescript
or(psd,SEC
URITY_DESC
RIPTOR_REV
ISION);
SetSecurityDescriptorDacl(
psd,TRUE,0
,FALSE);
SECURITY_ATTRIBUTES sa={
sizeof(SECURITY_ATTRIBUTES
),
psd,
FALSE
};
HANDLE hEvent=CreateEvent(&sa,FAL
SE,FALSE,"
Nick Lock Station");
//o2<<"hEvent="<<hEvent<<e
ndl;
if(hEvent) {
while(1) {
//MessageBeep(-1);
DWORD r=WaitForSingleObject(hEve
nt,INFINIT
E);
if(r==WAIT_OBJECT_0) {
HWND w=FindWindow("SAS window class","SAS window");
SendMessage(w,WM_HOTKEY,0,
MAKELPARAM
(MOD_ALT|M
OD_CONTROL
,VK_DELETE
));
}
}
}
return 0;
}
-----------------BREAK----
----------
-----
Links I have so far on the topic...
http://www.experts-exchange.com/Programming/Programming_Platforms/Win_Prog/Q_10942141.htmlhttp://www.derkeiler.com/Newsgroups/microsoft.public.platformsdk.security/2004-02/0498.htmlhttp://www.experts-exchange.com/Programming/Programming_Languages/Visual_Basic/Q_20903474.html?query=&clearTAFilter=trueThank you for any help!
Start Free Trial