checked in shellhook source code as backup

svn path=/trunk/; revision=5820
This commit is contained in:
Martin Fuchs 2003-08-24 12:20:20 +00:00
parent 26c230dd5a
commit 72898415e4
3 changed files with 271 additions and 0 deletions

View file

@ -0,0 +1,114 @@
/*
* Copyright 2003 Martin Fuchs
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
//
// Explorer clone
//
// shellhook.cpp
//
// Martin Fuchs, 17.08.2003
//
#include "../utility/utility.h"
#include "shellhook.h"
static HINSTANCE s_hInstance;
struct SharedMem {
HWND _callback_hwnd;
UINT _callback_msg;
HHOOK _hshellHook;
};
static HANDLE s_hMapObject;
static SharedMem* s_pSharedMem;
BOOL APIENTRY DllMain(HINSTANCE hInst, DWORD dwReason, LPVOID)
{
switch(dwReason) {
case DLL_PROCESS_ATTACH: {
s_hInstance = hInst;
DisableThreadLibraryCalls(hInst);
s_hMapObject = CreateFileMapping(INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE,
0, sizeof(SharedMem), _T("ROSExplorerShellHookSharedMem"));
if (!s_hMapObject)
return FALSE;
// The first process to attach initializes memory.
BOOL bInit = GetLastError()!=ERROR_ALREADY_EXISTS;
// Get a pointer to the file-mapped shared memory.
s_pSharedMem = (SharedMem*) MapViewOfFile(s_hMapObject, FILE_MAP_WRITE, 0, 0, 0);
if (!s_pSharedMem)
return FALSE;
// Initialize memory if this is the first process.
if (bInit)
memset(s_pSharedMem, 0, sizeof(SharedMem));
break;}
case DLL_PROCESS_DETACH:
UnmapViewOfFile(s_pSharedMem);
s_pSharedMem = NULL;
CloseHandle(s_hMapObject);
break;
}
return TRUE;
}
static void DoCallBack(int code, WPARAM wparam, LPARAM lparam)
{
UINT callback_msg = s_pSharedMem->_callback_msg;
HWND callback_hwnd = s_pSharedMem->_callback_hwnd;
if (callback_msg)
PostMessage(callback_hwnd, callback_msg, wparam, code); // lparam unused
}
LRESULT CALLBACK ShellHookProc(int code, WPARAM wparam, LPARAM lparam)
{
DoCallBack(code, wparam, lparam);
return CallNextHookEx(s_pSharedMem->_hshellHook, code, wparam, lparam);
}
void InstallShellHook(HWND callback_hwnd, UINT callback_msg)
{
s_pSharedMem->_callback_hwnd = callback_hwnd;
s_pSharedMem->_callback_msg = callback_msg;
s_pSharedMem->_hshellHook = SetWindowsHookEx(WH_SHELL, ShellHookProc, s_hInstance, 0);
}
void DeinstallShellHook()
{
s_pSharedMem->_callback_hwnd = 0;
s_pSharedMem->_callback_msg = 0;
UnhookWindowsHookEx(s_pSharedMem->_hshellHook);
s_pSharedMem->_hshellHook = 0;
}

View file

@ -0,0 +1,113 @@
# Microsoft Developer Studio Project File - Name="shellhook" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
CFG=shellhook - Win32 Debug
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
!MESSAGE use the Export Makefile command and run
!MESSAGE
!MESSAGE NMAKE /f "shellhook.mak".
!MESSAGE
!MESSAGE You can specify a configuration when running NMAKE
!MESSAGE by defining the macro CFG on the command line. For example:
!MESSAGE
!MESSAGE NMAKE /f "shellhook.mak" CFG="shellhook - Win32 Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "shellhook - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
!MESSAGE "shellhook - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
!MESSAGE
# Begin Project
# PROP AllowPerConfigDependencies 0
# PROP Scc_ProjName ""
# PROP Scc_LocalPath ""
CPP=cl.cmd
MTL=midl.exe
RSC=rc.exe
!IF "$(CFG)" == "shellhook - Win32 Release"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "shellhook___Win32_Release"
# PROP BASE Intermediate_Dir "shellhook___Win32_Release"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "Release"
# PROP Intermediate_Dir "Release"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c
# ADD CPP /nologo /MT /W3 /GX /O2 /D "NDEBUG" /D "WIN32" /D "_ROS_" /D _WIN32_IE=0x0501 /D _WIN32_WINNT=0x0501 /D "_SHELLHOOK_IMPL" /FD /c
# SUBTRACT CPP /YX
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x407 /d "NDEBUG"
# ADD RSC /l 0x407 /d "NDEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.cmd
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /machine:I386
# ADD LINK32 /nologo /subsystem:windows /dll /machine:I386
!ELSEIF "$(CFG)" == "shellhook - Win32 Debug"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "shellhook___Win32_Debug"
# PROP BASE Intermediate_Dir "shellhook___Win32_Debug"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "Debug"
# PROP Intermediate_Dir "Debug"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /GZ /c
# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "_DEBUG" /D "WIN32" /D "_ROS_" /D _WIN32_IE=0x0501 /D _WIN32_WINNT=0x0501 /D "_SHELLHOOK_IMPL" /FR /FD /GZ /c
# SUBTRACT CPP /YX
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x407 /d "_DEBUG"
# ADD RSC /l 0x407 /d "_DEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.cmd
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /debug /machine:I386 /pdbtype:sept
# ADD LINK32 /nologo /subsystem:windows /dll /debug /machine:I386 /pdbtype:sept
!ENDIF
# Begin Target
# Name "shellhook - Win32 Release"
# Name "shellhook - Win32 Debug"
# Begin Group "Header Files"
# PROP Default_Filter ""
# Begin Source File
SOURCE=.\taskbar\shellhook.h
# End Source File
# Begin Source File
SOURCE=.\utility\utility.h
# End Source File
# Begin Source File
SOURCE=.\utility\window.h
# End Source File
# End Group
# Begin Source File
SOURCE=.\taskbar\shellhook.cpp
# End Source File
# End Target
# End Project

View file

@ -0,0 +1,44 @@
/*
* Copyright 2003 Martin Fuchs
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
//
// Explorer and Desktop clone
//
// shellhook.h
//
// Martin Fuchs, 17.08.2003
//
#ifdef _SHELLHOOK_IMPL
#define DECL_SHELLHOOK __declspec(dllexport)
#else
#define DECL_SHELLHOOK __declspec(dllimport)
#endif
#ifdef __cplusplus
extern "C" {
#endif
DECL_SHELLHOOK void InstallShellHook(HWND callback_hwnd, UINT callback_msg);
DECL_SHELLHOOK void DeinstallShellHook();
#ifdef __cplusplus
};
#endif