Subversion Repositories Aucun

Rev

Rev 216 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
100 ixe013 1
/*
2
 Copyright (c) 2008, Guillaume Seguin ([email protected])
3
 All rights reserved.
4
 
5
 Redistribution and use in source and binary forms, with or without
6
 modification, are permitted provided that the following conditions
7
 are met:
8
 
9
 1. Redistributions of source code must retain the above copyright
10
    notice, this list of conditions and the following disclaimer.
11
 
12
 2. Redistributions in binary form must reproduce the above copyright
13
    notice, this list of conditions and the following disclaimer in the
14
    documentation and/or other materials provided with the distribution.
15
 
16
 THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
17
 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18
 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19
 ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
20
 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21
 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22
 OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23
 HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24
 LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25
 OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26
 SUCH DAMAGE.
27
*/
28
 
2 ixe013 29
#include <windows.h>
30
#include <winwlx.h>
31
 
32
#include "Ginahook.h"
112 ixe013 33
#include "trace.h"
2 ixe013 34
 
108 ixe013 35
#include "dlgdefs.h"
112 ixe013 36
#include "loggedon_dlg.h"
37
#include "loggedout_dlg.h"
38
#include "locked_dlg.h"
2 ixe013 39
 
40 ixe013 40
 
2 ixe013 41
//
42
// Pointers to redirected functions.
43
//
44
static PWLX_DIALOG_BOX_PARAM pfWlxDialogBoxParam = NULL;
45
 
216 ixe013 46
const wchar_t gAucunWinlogonContext[] = L"Paralint.com_Aucun_WinlogonContext";
217 ixe013 47
 
2 ixe013 48
//
49
// Local functions.
50
//
23 ixe013 51
int WINAPI MyWlxDialogBoxParam(HANDLE, HANDLE, LPWSTR, HWND, DLGPROC, LPARAM);
2 ixe013 52
 
53
 
54
//
55
// Hook WlxDialogBoxParam() dispatch function.
56
//
23 ixe013 57
void HookWlxDialogBoxParam(PVOID pWinlogonFunctions, DWORD dwWlxVersion)
2 ixe013 58
{
215 ixe013 59
    //WlxDialogBoxParam
60
    pfWlxDialogBoxParam = ((PWLX_DISPATCH_VERSION_1_0) pWinlogonFunctions)->WlxDialogBoxParam;
61
    ((PWLX_DISPATCH_VERSION_1_0) pWinlogonFunctions)->WlxDialogBoxParam = MyWlxDialogBoxParam;
2 ixe013 62
}
63
 
64
 
216 ixe013 65
// DelPropProc is an application-defined callback function
66
// that deletes a window property.
67
BOOL CALLBACK DelPropProc(HWND hwndSubclass, LPTSTR lpszString, HANDLE hData, ULONG_PTR x)       // data handle
68
{
69
    RemoveProp(hwndSubclass, lpszString);
70
    return TRUE;
71
}
72
 
2 ixe013 73
//
74
// Redirected WlxDialogBoxParam() function.
75
//
23 ixe013 76
int WINAPI MyWlxDialogBoxParam(HANDLE hWlx, HANDLE hInst, LPWSTR lpszTemplate, HWND hwndOwner, DLGPROC dlgprc, LPARAM dwInitParam)
2 ixe013 77
{
215 ixe013 78
    DLGPROC proc2use = dlgprc;
217 ixe013 79
    LPARAM lparam2use = dwInitParam;
80
    DialogLParamHook myInitParam = {0};
215 ixe013 81
    DWORD dlgid = 0;
217 ixe013 82
    int result = 0;
83
 
84
    //We might doint this for nothing (if dialog is not hooked)
85
    myInitParam.HookedLPARAM = dwInitParam;
86
    myInitParam.Winlogon = hWlx;
87
 
215 ixe013 88
    TRACE(eERROR, L"About to create the dialog");
2 ixe013 89
 
215 ixe013 90
    //
91
    // We only know MSGINA dialogs by identifiers.
92
    //
93
    if (!HIWORD(lpszTemplate))
94
    {
95
        // Hook appropriate dialog boxes as necessary.
96
        int i;
97
        dlgid = LOWORD(lpszTemplate);    //Cast to remove warning C4311
2 ixe013 98
 
215 ixe013 99
        //Try to find the dialog
100
        for (i = 0; i < nbDialogsAndProcs; ++i)
101
        {
102
            //Is it one of the ID we know ?
103
            if (gDialogsProc[i].IDD == dlgid)
104
            {
105
                //The dialog that asks if you would like to change password, lock, taskmgr, etc.
106
                TRACEMORE(eERROR, L" IDD %d (index %d)\n", dlgid, i);
107
                proc2use = gDialogsProc[i].dlgproc;
108
                gDialogsProc[i].originalproc = dlgprc;
217 ixe013 109
                lparam2use = (LPARAM)&myInitParam;
215 ixe013 110
                break;
111
            }
112
        }
113
    }
40 ixe013 114
 
215 ixe013 115
    if (proc2use == dlgprc)
116
    {
117
        TRACE(eERROR, L" (%d). it was not hooked.\n", dlgid);
118
    }
40 ixe013 119
 
217 ixe013 120
    result = pfWlxDialogBoxParam(hWlx, hInst, lpszTemplate, hwndOwner, proc2use, lparam2use);
121
 
122
    TRACE(eDEBUG, L"Dialog id %d returned %d\n", dlgid, result);
123
 
124
    return result;
8 ixe013 125
}
217 ixe013 126