Click here to Skip to main content
15,915,800 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
Questionconnect to website Pin
Girish60110-Mar-06 19:28
Girish60110-Mar-06 19:28 
QuestionDLL Compile Help Pin
nimishsudan10-Mar-06 18:08
nimishsudan10-Mar-06 18:08 
AnswerRe: DLL Compile Help Pin
ThatsAlok10-Mar-06 18:27
ThatsAlok10-Mar-06 18:27 
GeneralRe: DLL Compile Help Pin
nimishsudan11-Mar-06 10:07
nimishsudan11-Mar-06 10:07 
GeneralRe: DLL Compile Help Pin
ThatsAlok11-Mar-06 16:52
ThatsAlok11-Mar-06 16:52 
GeneralRe: DLL Compile Help Pin
nimishsudan11-Mar-06 17:01
nimishsudan11-Mar-06 17:01 
GeneralRe: DLL Compile Help Pin
ThatsAlok11-Mar-06 19:48
ThatsAlok11-Mar-06 19:48 
GeneralRe: DLL Compile Help Pin
nimishsudan12-Mar-06 4:29
nimishsudan12-Mar-06 4:29 
Well, I finally got the project to compile. I had to add the typedef struct for _WLX_NOTIFICATION_INFO and PFNMSGECALLBACK in order for it to compile without errors. But now my question is why doesn't it work? I have compiled the following code, and copied newNotif.exp and newNotif.dll to C:\Windows\System32\ and added the below registry entry to my registry. When I reboot, it doesn't do anything, not even the messagebox is displayed.

REGISTRY FILE:
Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\Notify\newNotif]
"Asynchronous"=dword:00000000
"Impersonate"=dword:00000000
"DllName"=hex(2):6e,00,65,00,77,00,4e,00,6f,00,74,00,69,00,66,00,2e,00,64,00,\
6c,00,6c,00,00,00
"Logon"="StartProcessAtWinLogon"
"Logoff"="StopProcessAtWinLogoff"


CPP FILE:
// newNotif.cpp : Defines the initialization routines for the DLL.
//

#include <windows.h>
#include <winwlx.h>
#include "stdafx.h"
#include "newNotif.h"


#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

typedef DWORD(* PFNMSGECALLBACK )(BOOL bVerbose, LPWSTR lpMessage);
typedef struct _WLX_NOTIFICATION_INFO { ULONG Size; ULONG Flags; PWSTR UserName; PWSTR Domain; PWSTR WindowStation; HANDLE hToken; HDESK hDesktop; PFNMSGECALLBACK pStatusCallback;
} WLX_NOTIFICATION_INFO, *PWLX_NOTIFICATION_INFO;

SafeTerminateProcess(HANDLE hProcess, UINT uExitCode);

/////////////////////////////////////////////////////////////////////////////
// CNewNotifApp

BEGIN_MESSAGE_MAP(CNewNotifApp, CWinApp)
//{{AFX_MSG_MAP(CNewNotifApp)
// NOTE - the ClassWizard will add and remove mapping macros here.
// DO NOT EDIT what you see in these blocks of generated code!
//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CNewNotifApp construction

CNewNotifApp::CNewNotifApp()
{
// TODO: add construction code here,
// Place all significant initialization in InitInstance
}

/////////////////////////////////////////////////////////////////////////////
// The one and only CNewNotifApp object

CNewNotifApp theApp;


PROCESS_INFORMATION g_pi;

TCHAR g_szPath[] = TEXT("C:\\Windows\\Notepad.exe");

//Entrance function for the DLL
BOOL WINAPI LibMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
{
switch (dwReason)
{
case DLL_PROCESS_ATTACH:
{
DisableThreadLibraryCalls (hInstance);
}
break;
}
return TRUE;
}

//Event handler for the Winlogon Logon event
VOID APIENTRY StartProcessAtWinLogon (PWLX_NOTIFICATION_INFO pInfo)
{

TCHAR szText[MAX_PATH];

STARTUPINFO si;
si.cb = sizeof(STARTUPINFO);
si.lpReserved = NULL;
si.lpTitle = NULL;
si.lpDesktop = TEXT("WinSta0\\Default");
si.dwX = si.dwY = si.dwXSize = si.dwYSize = 0L;
si.dwFlags = 0;;
si.wShowWindow = SW_SHOW;
si.lpReserved2 = NULL;
si.cbReserved2 = 0;

DWORD dwWritten;

HANDLE hFile = CreateFile(TEXT("c:\\TSP.txt"), GENERIC_ALL, NULL, NULL, OPEN_ALWAYS, NULL, NULL);
strcpy(szText, TEXT("StartProcessAtWinLogon \r\n"));
WriteFile(hFile, szText, strlen(szText), &dwWritten, NULL);
CloseHandle(hFile);

CreateProcess(NULL, g_szPath, NULL, NULL, FALSE, CREATE_NEW_CONSOLE,
NULL, NULL, &si, &g_pi);

MessageBox(NULL, "Winlogon Test", "Winlogon Test", MB_OK);
}

//Event handler for the Winlogon Logoff event.
VOID APIENTRY StopProcessAtWinLogoff (PWLX_NOTIFICATION_INFO pInfo)
{
//terminates the process
//****************SafeTerminateProcess(g_pi.hProcess, 0xDEADBEEF);
}

//other event handlers
VOID APIENTRY YOUR_EVENT_HANDLERS (PWLX_NOTIFICATION_INFO pInfo)
{
//code
}


// Here is the event handler for the Winlogon Logon event.
VOID WLEventLogon (PWLX_NOTIFICATION_INFO pInfo)
{

// Print the name of the handler to debug output.
// You can replace this with more useful functionality.
OutputDebugString (TEXT("NOTIFY: Entering WLEventLogon.\r\n"));
}

// Here is the event handler for the Winlogon Logoff event.
VOID WLEventLogoff (PWLX_NOTIFICATION_INFO pInfo)
{

// Print the name of the handler to debug output.
// You can replace this with more useful functionality.
OutputDebugString (TEXT("NOTIFY: Entering WLEventLogff.\r\n"));
}



HEADER FILE:
// newNotif.h : main header file for the NEWNOTIF DLL
//

#if !defined(AFX_NEWNOTIF_H__CEECF57A_5EFB_4B19_A60F_E05203D4E73C__INCLUDED_)
#define AFX_NEWNOTIF_H__CEECF57A_5EFB_4B19_A60F_E05203D4E73C__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#ifndef __AFXWIN_H__
#error include 'stdafx.h' before including this file for PCH
#endif

#include <windows.h>
#include <winwlx.h>
#include "resource.h" // main symbols

/////////////////////////////////////////////////////////////////////////////
// CNewNotifApp
// See newNotif.cpp for the implementation of this class
//

class CNewNotifApp : public CWinApp
{
public:
CNewNotifApp();

// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CNewNotifApp)
//}}AFX_VIRTUAL

//{{AFX_MSG(CNewNotifApp)
// NOTE - the ClassWizard will add and remove member functions here.
// DO NOT EDIT what you see in these blocks of generated code !
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};


/////////////////////////////////////////////////////////////////////////////

//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.

#endif // !defined(AFX_NEWNOTIF_H__CEECF57A_5EFB_4B19_A60F_E05203D4E73C__INCLUDED_)
Question[OpenGL] Help needed!Listen to my problem please... Pin
carlsoncarlson10-Mar-06 16:46
carlsoncarlson10-Mar-06 16:46 
AnswerRe: [OpenGL] Help needed!Listen to my problem please... Pin
Hamid_RT10-Mar-06 17:35
Hamid_RT10-Mar-06 17:35 
GeneralRe: [OpenGL] Help needed!Listen to my problem please... Pin
carlsoncarlson11-Mar-06 14:12
carlsoncarlson11-Mar-06 14:12 
AnswerRe: [OpenGL] Help needed!Listen to my problem please... Pin
El Corazon11-Mar-06 14:02
El Corazon11-Mar-06 14:02 
GeneralRe: [OpenGL] Help needed!Listen to my problem please... Pin
carlsoncarlson11-Mar-06 14:11
carlsoncarlson11-Mar-06 14:11 
QuestionWindows Media Format Video Image 9 Problem Pin
Kin Tutnik10-Mar-06 16:41
Kin Tutnik10-Mar-06 16:41 
QuestionWhat are the differences between VC++ and .Net Pin
Sriram Suresh10-Mar-06 15:45
Sriram Suresh10-Mar-06 15:45 
AnswerRe: What are the differences between VC++ and .Net Pin
Hamid_RT10-Mar-06 18:12
Hamid_RT10-Mar-06 18:12 
AnswerRe: What are the differences between VC++ and .Net Pin
ThatsAlok10-Mar-06 18:24
ThatsAlok10-Mar-06 18:24 
QuestionAnother Error Pin
romuzu10-Mar-06 15:00
romuzu10-Mar-06 15:00 
AnswerRe: Another Error Pin
John M. Drescher10-Mar-06 15:25
John M. Drescher10-Mar-06 15:25 
Questionunexpected end of file while looking for precompiled header directive Pin
romuzu10-Mar-06 14:42
romuzu10-Mar-06 14:42 
AnswerRe: unexpected end of file while looking for precompiled header directive Pin
John M. Drescher10-Mar-06 15:21
John M. Drescher10-Mar-06 15:21 
GeneralRe: unexpected end of file while looking for precompiled header directive Pin
romuzu10-Mar-06 16:04
romuzu10-Mar-06 16:04 
GeneralRe: unexpected end of file while looking for precompiled header directive Pin
John M. Drescher10-Mar-06 16:32
John M. Drescher10-Mar-06 16:32 
AnswerRe: unexpected end of file while looking for precompiled header directive Pin
Intertherain10-Mar-06 16:01
Intertherain10-Mar-06 16:01 
AnswerRe: unexpected end of file while looking for precompiled header directive Pin
Michael Dunn10-Mar-06 16:15
sitebuilderMichael Dunn10-Mar-06 16:15 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.