initial oogynize check in _ this actually used to work!

This commit is contained in:
2016-02-14 21:16:31 -08:00
parent b183af5d55
commit 532ea133bc
337 changed files with 30692 additions and 0 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,17 @@
// ButtonHook.h
#pragma once
#include "CWHPaccess.h"
#ifdef DLLAPI_BUTTON_HOOK
#define ENTRY_FUNCTION extern "C" _declspec(dllexport)
#else
#define ENTRY_FUNCTION extern "C" _declspec(dllimport)
#endif
////
// Entry-Point (Exposed)Functions
////
ENTRY_FUNCTION BOOL WINAPI StartButtonHook(void);
ENTRY_FUNCTION BOOL WINAPI StopButtonHook(void);
ENTRY_FUNCTION BOOL WINAPI IsButtonHookSet(void);
ENTRY_FUNCTION int WINAPI GetAllHookedWindowHandles(int* pBuf);

View File

@@ -0,0 +1,236 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="9.00"
Name="ButtonHook"
ProjectGUID="{5E8EB95C-9C4F-4DE3-A5E4-827268AF4E9B}"
RootNamespace="ButtonHook"
Keyword="Win32Proj"
TargetFrameworkVersion="196613"
>
<Platforms>
<Platform
Name="Win32"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="$(InputDir)Target\$(ConfigurationName)"
IntermediateDirectory="$(InputDir)Target\$(ConfigurationName)"
ConfigurationType="2"
CharacterSet="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;BUTTONHOOK_EXPORTS"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="3"
UsePrecompiledHeader="0"
WarningLevel="3"
DebugInformationFormat="4"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="Psapi.lib"
LinkIncremental="2"
DelayLoadDLLs=""
GenerateDebugInformation="true"
SubSystem="2"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
CommandLine="copy $(InputDir)Target\$(ConfigurationName)\ButtonHook.dll $(SolutionDir)Target\$(ConfigurationName) /Y&#x0D;&#x0A;copy $(InputDir)Target\$(ConfigurationName)\ButtonHook.pdb $(SolutionDir)Target\$(ConfigurationName) /Y"
/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="$(InputDir)Target\$(ConfigurationName)"
IntermediateDirectory="$(InputDir)Target\$(ConfigurationName)"
ConfigurationType="2"
CharacterSet="1"
WholeProgramOptimization="0"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="2"
EnableIntrinsicFunctions="true"
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;BUTTONHOOK_EXPORTS"
RuntimeLibrary="0"
EnableFunctionLevelLinking="true"
UsePrecompiledHeader="0"
WarningLevel="3"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="Psapi.lib"
LinkIncremental="1"
GenerateManifest="true"
DelayLoadDLLs=""
GenerateDebugInformation="true"
SubSystem="2"
OptimizeReferences="2"
EnableCOMDATFolding="2"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
CommandLine="copy $(InputDir)Target\$(ConfigurationName)\ButtonHook.dll $(SolutionDir)Target\$(ConfigurationName) /Y"
/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="Source Files"
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
>
<File
RelativePath=".\ButtonHook.cpp"
>
</File>
<File
RelativePath=".\CWHPaccess.cpp"
>
</File>
<File
RelativePath=".\Stdafx.cpp"
>
</File>
<File
RelativePath=".\WPFCaller.cpp"
>
</File>
</Filter>
<Filter
Name="Header Files"
Filter="h;hpp;hxx;hm;inl;inc;xsd"
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
>
<File
RelativePath=".\ButtonHook.h"
>
</File>
<File
RelativePath=".\CWHPaccess.h"
>
</File>
<File
RelativePath=".\resource.h"
>
</File>
<File
RelativePath=".\Stdafx.h"
>
</File>
<File
RelativePath=".\thread.h"
>
</File>
<File
RelativePath=".\WPFCaller.h"
>
</File>
</Filter>
<Filter
Name="Resource Files"
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
>
</Filter>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

View File

@@ -0,0 +1,390 @@
#include "StdAfx.h"
#include "ButtonStrategy.h"
//#include "HiddenWindow.h" // for Some Strategies we need to create
// a hidden window and draw the buttons on it
////
// We are delay-loading the UXTheme.dll. In case we are running on
// a system where the dll doesn't exist, we'll only load it we know
// that this is a system where it should exist
////
#include "uxtheme.h"
////
// We are delay-loading the DWMapi.dll. In case we are running on
// a system where the dll doesn't exist, we'll only load it we know
// that this is a system where it should exist
////
#include "dwmapi.h"
using namespace Ooganizer;
//********************************************************************
// Clss ButtonStrategy
//
// Programmer Daniel Romischer
// Ooganizer Development Team
//
// Description Base/Abstract Class for all Button Strategies
//
// Note CalcCaptionRect() and CalcCaptionButtonRect()
// is implemented in the base class for now (as it appears
// to be the same calculation for all Button Strategies).
//
// Created 06-01-2008
//********************************************************************
//////////////////////////////////////////////////////////////////////
//********************************************************************
// Construction / Destruction
//********************************************************************
//////////////////////////////////////////////////////////////////////
ButtonStrategy::ButtonStrategy(void)
{
}
ButtonStrategy::~ButtonStrategy(void)
{
}
//////////////////////////////////////////////////////////////////////
// Func: CalcCaptionRect()
// Desc: Calculates the dimensions of the Caption Bar
//
// Prms: +hWnd, handle to a Windows
// +-Rect, returns the x,y RECT area dimension coordinates of the caption bar
// +-SIZE, returns the width and height of the Caption bar
//////////////////////////////////////////////////////////////////////
void ButtonStrategy::CalcCaptionRect(HWND hWnd, RECT &RectCaption, SIZE &heightNwidth)const
{
RECT Rect;
SIZE sFrame;
DWORD dStyle = GetWindowLong( hWnd, GWL_STYLE );
// Get frame size of window
// (x and y height width dim of the resizable or non-resizable windows frame)
sFrame.cy = GetSystemMetrics( ( dStyle & WS_THICKFRAME ) ? SM_CYSIZEFRAME : SM_CYFIXEDFRAME );
sFrame.cx = GetSystemMetrics( ( dStyle & WS_THICKFRAME ) ? SM_CXSIZEFRAME : SM_CXFIXEDFRAME );
// Gets the location of the Window
GetWindowRect( hWnd, &Rect );
// Height and Width of the Window
LONG height = Rect.bottom - Rect.top; // Window height not intersting to us (not used)
LONG width = Rect.right - Rect.left;
// Pass the CaptionBar Dimension out
RectCaption.top = sFrame.cy; // 4, 8
RectCaption.left = sFrame.cx; // 4, 8
RectCaption.right = width - sFrame.cy; // 771
// SM_CYCAPTION = The height of a caption area, in pixels
// SM_CYBORDER = The height of a window border
int heightCaption = GetSystemMetrics( SM_CYCAPTION ); // 20
int heightWindowBorder = GetSystemMetrics( SM_CYBORDER ); // 1
RectCaption.bottom = heightCaption;
//heightCaption gives us the correct caption height, but in order to get the exact RECT location,
//calculated from top left, we need to add sFrame.cy to it. ~we substract the bottom border because,
//otherwise the height will be too long
//sFrame.cy + heightCaption - heightWindowBorder;
// sample return
// top = 4, left = 4, bottom = 23, right = 771
// Pass out the height & Width of the CaptionBar
heightNwidth.cx = heightCaption;
heightNwidth.cy = width;
}
//********************************************************************
// Clss ClassicButtonStrategy
//
// Description Implementation for our Windows Classic Theme Strategy
//
// Note Uses DrawFrameControl() to draw the Button. This will
// Only work in Windows2000/XP without theme (classic View)
//
// Created 06-01-2008
//********************************************************************
//////////////////////////////////////////////////////////////////////
//********************************************************************
// Construction / Destruction
//********************************************************************
//////////////////////////////////////////////////////////////////////
ClassicButtonStrategy::ClassicButtonStrategy()
{
}
ClassicButtonStrategy::~ClassicButtonStrategy()
{
}
//////////////////////////////////////////////////////////////////////
// Func: draw()
// Desc: generic draw function - called for all default messages
//////////////////////////////////////////////////////////////////////
void ClassicButtonStrategy::draw(HWND hWnd, const HDC &hDc, const RECT &rPos) const
{
// Use the regular Frame Control *Windows Classic*
// DrawFrameControl( hDc, const_cast<LPRECT>(&rPos), DFC_BUTTON, DFCS_BUTTONPUSH );
HICON hIcon = (HICON) LoadImage(NULL, L"C:\\bridge.ico", IMAGE_ICON, 0, 0, LR_LOADFROMFILE);
DrawIcon(hDc, rPos.left, rPos.top, hIcon);
}
//////////////////////////////////////////////////////////////////////
// Func: drawButtonUp()
// Desc: draw the button in an up state
//////////////////////////////////////////////////////////////////////
void ClassicButtonStrategy::drawButtonUp(HWND hWnd, const HDC &hDc, const RECT &rPos) const
{
// Use the regular Frame Control *Windows Classic*
// DrawFrameControl( hDc, const_cast<LPRECT>(&rPos), DFC_BUTTON, DFCS_BUTTONPUSH );
HICON hIcon = (HICON) LoadImage(NULL, L"C:\\bridge.ico", IMAGE_ICON, 0, 0, LR_LOADFROMFILE);
DrawIcon(hDc, rPos.left, rPos.top, hIcon);
}
//////////////////////////////////////////////////////////////////////
// Func: drawButtonDown()
// Desc: draw the button in a down state
//////////////////////////////////////////////////////////////////////
void ClassicButtonStrategy::drawButtonDown(HWND hWnd, const HDC &hDc, const RECT &rPos) const
{
// Use the regular Frame Control *Windows Classic*
// DrawFrameControl( hDc, const_cast<LPRECT>(&rPos), DFC_BUTTON, DFCS_BUTTONPUSH | DFCS_PUSHED );
HICON hIcon = (HICON) LoadImage(NULL, L"C:\\bridge.ico", IMAGE_ICON, 0, 0, LR_LOADFROMFILE);
DrawIcon(hDc, rPos.left, rPos.top, hIcon);
}
//********************************************************************
// Clss AeroButtonStrategy
//
// Description Implementation for our Windows Aero Theme Strategy
//
// Note
//
//
// Created 06-01-2008
//********************************************************************
//////////////////////////////////////////////////////////////////////
//********************************************************************
// Construction / Destruction
//********************************************************************
//////////////////////////////////////////////////////////////////////
AeroButtonStrategy::AeroButtonStrategy()
{
}
AeroButtonStrategy::~AeroButtonStrategy()
{
}
//////////////////////////////////////////////////////////////////////
// Func: CalcCaptionButtonRect()
// Desc: Calculates the dimensions of the Caption Button. Takes into
// account the number of caption buttons on the window and returns
// the pos (RECT) where to draw the Caption Button.
//
// Prms: +hWnd, handle to a Windows
// +-RectButtonPos, returns the x,y dimension of where to place the Button
//////////////////////////////////////////////////////////////////////
void AeroButtonStrategy::CalcCaptionButtonRect(HWND hWnd, RECT& RectButtonPos) const
{
// Button Constants
const LONG BUTTON_MARGIN = 2; // The Margin Space between the Buttons
//The width of a button in a window caption or title bar, in pixels
const LONG CAPTION_WIDTH = GetSystemMetrics(SM_CXSIZE); // should be 28
log(LOGGING_HIGH, "Caption Width = %i", CAPTION_WIDTH);
RECT rect;
SIZE size;
// Get The dimensions of the CaptionBar
CalcCaptionRect(hWnd,rect,size);
// sample return from CalcCaptionRect()
// top = 4, left = 4, bottom = 23, right = 771
// On Aero the distance of the Button is 10 not 6. Calculating by multiplying top * 2 (=8)
// ~this makes sense because our Rect start at the top most location (not where vista wants to draw the button
const LONG TOP_PLACEMENT = (2 * rect.top) + BUTTON_MARGIN;
const LONG BOTTOM_PLACEMENT = rect.bottom - BUTTON_MARGIN;
// Left and Right Placement has to be calculated using the spacing on the right, the caption button widths,
// of (close, max, min) and the margins in between the buttons. (RECT includes all caption buttons),
// we also subtract rect.top from the left because a window border on right is not considered (+ another margin)
const LONG RIGHT_PLACEMENT = rect.right - (CAPTION_WIDTH * 3) - (BUTTON_MARGIN * 3) - (rect.top + BUTTON_MARGIN);
const LONG LEFT_PLACEMENT = RIGHT_PLACEMENT - CAPTION_WIDTH; // - BUTTON_MARGIN?
////
// Pass out the dimension of the CaptionButton
////
RectButtonPos.top = TOP_PLACEMENT;
RectButtonPos.bottom = BOTTOM_PLACEMENT;
RectButtonPos.right = RIGHT_PLACEMENT;
RectButtonPos.left = LEFT_PLACEMENT;
}
//////////////////////////////////////////////////////////////////////
// Func: draw()
// Desc: generic draw function - called for all default messages
//////////////////////////////////////////////////////////////////////
void AeroButtonStrategy::draw(HWND hWnd, const HDC &hDc, const RECT &rPos) const
{
// HTHEME hTheme = OpenThemeData(hWnd, L"OkButton;Button;Window");
// HTHEME hTheme = OpenThemeData(hWnd, L"Button");
// DrawThemeParentBackground(hWnd,hDc,&rPos);
// DrawThemeBackground(hTheme,hDc,0,0,&rPos,0);
HICON hIcon = (HICON) LoadImage(NULL, L"C:\\VistaNoAero.ico", IMAGE_ICON, 0, 0, LR_LOADFROMFILE);
DrawIcon(hDc, rPos.left, rPos.top, hIcon);
}
//////////////////////////////////////////////////////////////////////
// Func: drawButtonUp()
// Desc: draw the button in an up state
//////////////////////////////////////////////////////////////////////
void AeroButtonStrategy::drawButtonUp(HWND hWnd, const HDC &hDc, const RECT &rPos) const
{
HICON hIcon = (HICON) LoadImage(NULL, L"C:\\bridge.ico", IMAGE_ICON, 0, 0, LR_LOADFROMFILE);
DrawIcon(hDc, rPos.left, rPos.top, hIcon);
}
//////////////////////////////////////////////////////////////////////
// Func: drawButtonDown()
// Desc: draw the button in a down state
//////////////////////////////////////////////////////////////////////
void AeroButtonStrategy::drawButtonDown(HWND hWnd, const HDC &hDc, const RECT &rPos) const
{
HICON hIcon = (HICON) LoadImage(NULL, L"C:\\bridge.ico", IMAGE_ICON, 0, 0, LR_LOADFROMFILE);
DrawIcon(hDc, rPos.left, rPos.top, hIcon);
}
//********************************************************************
// Clss VistaNoAeroStrategy
//
// Description Implementation for Vista when Aero (Glass) is not running
//
// Note
//
//
// Created 06-01-2008
//********************************************************************
//////////////////////////////////////////////////////////////////////
//********************************************************************
// Construction / Destruction
//********************************************************************
//////////////////////////////////////////////////////////////////////
VistaNoAeroStrategy::VistaNoAeroStrategy()
{
}
VistaNoAeroStrategy::~VistaNoAeroStrategy()
{
}
//////////////////////////////////////////////////////////////////////
// Func: CalcCaptionButtonRect()
// Desc: Calculates the dimensions of the Caption Button. Takes into
// account the number of caption buttons on the window and returns
// the pos (RECT) where to draw the Caption Button.
//
// Prms: +hWnd, handle to a Windows
// +-RectButtonPos, returns the x,y dimension of where to place the Button
//////////////////////////////////////////////////////////////////////
void VistaNoAeroStrategy::CalcCaptionButtonRect(HWND hWnd, RECT& RectButtonPos) const
{
// Button Constants
const LONG BUTTON_MARGIN = 2; // The Margin Space between the Buttons
//The width of a button in a window caption or title bar, in pixels
const LONG CAPTION_WIDTH = GetSystemMetrics(SM_CXSIZE); // 32 (appears to include left and righ Margin)
RECT rect;
SIZE size;
// Get The dimensions of the CaptionBar
CalcCaptionRect(hWnd,rect,size);
log(LOGGING_HIGH, "rect is top %i, bottom %i, left %i, right %i", rect.top, rect.bottom, rect.left, rect.right);
// sample return from CalcCaptionRect()
// Vista Aero
// top = 4, left = 4, bottom = 23, right = 771
// Vista NoAero
// rect is top 8, bottom 27, left 8, right 831
// On Aero the distance of the Button is 10 not 6. Calculating by multiplying top * 2 (=8)
// ~this makes sense because our Rect start at the top most location (not where vista wants to draw the button
const LONG TOP_PLACEMENT = 10; //(2 * rect.top) + BUTTON_MARGIN;
const LONG BOTTOM_PLACEMENT = rect.bottom - BUTTON_MARGIN;
// Left and Right Placement has to be calculated using the spacing on the right, the caption button widths,
// of (close, max, min) and the margins in between the buttons. (RECT includes all caption buttons),
// we also subtract rect.top from the left because a window border on right is not considered (+ another margin)
// 96
const LONG RIGHT_PLACEMENT = rect.right - 96;
const LONG LEFT_PLACEMENT = RIGHT_PLACEMENT - 28; // - BUTTON_MARGIN?
////
// Pass out the dimension of the CaptionButton
////
RectButtonPos.top = TOP_PLACEMENT;
RectButtonPos.bottom = BOTTOM_PLACEMENT;
RectButtonPos.right = RIGHT_PLACEMENT;
RectButtonPos.left = LEFT_PLACEMENT;
}
//////////////////////////////////////////////////////////////////////
// Func: draw()
// Desc: generic draw function - called for all default messages
//////////////////////////////////////////////////////////////////////
void VistaNoAeroStrategy::draw(HWND hWnd, const HDC &hDc, const RECT &rPos) const
{
HICON hIcon = (HICON) LoadImage(NULL, L"C:\\VistaNoAero.ico", IMAGE_ICON, 28, 15, LR_LOADFROMFILE);
DrawIcon(hDc, rPos.left, rPos.top, hIcon);
}
//////////////////////////////////////////////////////////////////////
// Func: drawButtonUp()
// Desc: draw the button in an up state
//////////////////////////////////////////////////////////////////////
void VistaNoAeroStrategy::drawButtonUp(HWND hWnd, const HDC &hDc, const RECT &rPos) const
{
}
//////////////////////////////////////////////////////////////////////
// Func: drawButtonDown()
// Desc: draw the button in a down state
//////////////////////////////////////////////////////////////////////
void VistaNoAeroStrategy::drawButtonDown(HWND hWnd, const HDC &hDc, const RECT &rPos) const
{
}
//********************************************************************
// Clss XPButtonStrategy
//
// Description Implementation for Windows XP Themed Strategy
//
// Note
//
//
// Created 06-01-2008
//********************************************************************
//////////////////////////////////////////////////////////////////////
//********************************************************************
// Construction / Destruction
//********************************************************************
//////////////////////////////////////////////////////////////////////
XPButtonStrategy::XPButtonStrategy()
{
}
XPButtonStrategy::~XPButtonStrategy()
{
}
//////////////////////////////////////////////////////////////////////
// Func: draw()
// Desc: generic draw function - called for all default messages
//////////////////////////////////////////////////////////////////////
void XPButtonStrategy::draw(HWND hWnd, const HDC &hDc, const RECT &rPos) const
{
}
//////////////////////////////////////////////////////////////////////
// Func: drawButtonUp()
// Desc: draw the button in an up state
//////////////////////////////////////////////////////////////////////
void XPButtonStrategy::drawButtonUp(HWND hWnd, const HDC &hDc, const RECT &rPos) const
{
}
//////////////////////////////////////////////////////////////////////
// Func: drawButtonDown()
// Desc: draw the button in a down state
//////////////////////////////////////////////////////////////////////
void XPButtonStrategy::drawButtonDown(HWND hWnd, const HDC &hDc, const RECT &rPos) const
{
}

View File

@@ -0,0 +1,102 @@
#pragma once
namespace Ooganizer
{
//////////////////////////////////////////////////////////////////////
// Itce: ButtonStrategy
// Desc: This interface allows us to abstract out specific implementations
// for different caption buttons with different Themes.
//
// Note: following functions will be called from the windows messages to
// be implemented directly here independently and draw only the button.
//
// Note2: Each Button Strategy is directly tied to a C
//////////////////////////////////////////////////////////////////////
class ButtonStrategy
{
public:
// generic draw function - called for all default messages
virtual void draw(HWND hWnd, const HDC &hdc, const RECT &rpos) const = 0;
// draw the button in an up state
virtual void drawButtonUp(HWND hWnd, const HDC &hDc, const RECT &rPos) const = 0;
// draw the button in a down state
virtual void drawButtonDown(HWND hWnd, const HDC &hDc, const RECT &rPos) const = 0;
// returns the RECT position of the the CaptionButton
virtual void CalcCaptionButtonRect(HWND hWnd, RECT& RectButtonPos) const = 0;
////
// returns the dimension / size of the caption / title bar (impl. in base)
////
void CalcCaptionRect(HWND hWnd, RECT& RectCaption, SIZE &heightNwidth) const;
ButtonStrategy(void);
virtual ~ButtonStrategy(void);
};
//////////////////////////////////////////////////////////////////////
// Clss: ClassicButtonStrategy
// Desc: Implementation for our Windows Classic Theme Strategy
//////////////////////////////////////////////////////////////////////
class ClassicButtonStrategy : public ButtonStrategy
{
public:
void draw(HWND hWnd, const HDC &hdc, const RECT &rpos) const;
void drawButtonUp(HWND hWnd, const HDC &hDc, const RECT &rPos) const;
void drawButtonDown(HWND hWnd, const HDC &hDc, const RECT &rPos) const;
void CalcCaptionButtonRect(HWND hWnd, RECT& RectButtonPos) const {};
ClassicButtonStrategy();
virtual ~ClassicButtonStrategy();
};
//////////////////////////////////////////////////////////////////////
// Clss: AeroButtonStrategy
// Desc: Implementation for our Windows Aero (Glass) Strategy
//////////////////////////////////////////////////////////////////////
class AeroButtonStrategy : public ButtonStrategy
{
public:
virtual void draw(HWND hWnd, const HDC &hdc, const RECT &rpos) const;
void drawButtonUp(HWND hWnd, const HDC &hDc, const RECT &rPos) const;
void drawButtonDown(HWND hWnd, const HDC &hDc, const RECT &rPos) const;
void CalcCaptionButtonRect(HWND hWnd, RECT& RectButtonPos) const;
AeroButtonStrategy();
virtual ~AeroButtonStrategy();
};
//////////////////////////////////////////////////////////////////////
// Clss: VistaNoAeroStrategy
// Desc: Implementation for Vista when Aero (Glass) is not running
//////////////////////////////////////////////////////////////////////
class VistaNoAeroStrategy : public ButtonStrategy
{
public:
virtual void draw(HWND hWnd, const HDC &hdc, const RECT &rpos) const;
void drawButtonUp(HWND hWnd, const HDC &hDc, const RECT &rPos) const;
void drawButtonDown(HWND hWnd, const HDC &hDc, const RECT &rPos) const;
void CalcCaptionButtonRect(HWND hWnd, RECT& RectButtonPos) const;
// Uses Hidden Window Strategy
VistaNoAeroStrategy();
virtual ~VistaNoAeroStrategy();
};
//////////////////////////////////////////////////////////////////////
// Clss: XPButtonStrategy
// Desc: Implementation for Windows XP Themed Strategy
//////////////////////////////////////////////////////////////////////
class XPButtonStrategy : public ButtonStrategy
{
public:
virtual void draw(HWND hWnd, const HDC &hdc, const RECT &rpos) const;
void drawButtonUp(HWND hWnd, const HDC &hDc, const RECT &rPos) const;
void drawButtonDown(HWND hWnd, const HDC &hDc, const RECT &rPos) const;
void CalcCaptionButtonRect(HWND hWnd, RECT& RectButtonPos) const{};
XPButtonStrategy();
virtual ~XPButtonStrategy();
};
}

View File

@@ -0,0 +1,414 @@
#include "stdafx.h"
#include "CWHPaccess.h"
using namespace Ooganizer;
//////////////////////////////////////////////////////////////////////
//********************************************************************
// Global variables - Shared Data Segment (Shared across all instances
// of this dll!)
//********************************************************************
//////////////////////////////////////////////////////////////////////
#pragma data_seg( ".CWHP" )
HHOOK CWHPaccess::hHook = NULL;
HookWndItem CWHPaccess::HList[MAX_PATH] = {NULL,NULL,NULL,NULL};
UINT CWHPaccess::HListI = 0;
wchar_t CWHPaccess::ALLOWED_PROCESS_NAMES[MAX_PATH][MAX_PATH] = {0};
UINT CWHPaccess::NUMBER_OF_ALLOWED_PROCESS_NAMES = 0;
wchar_t CWHPaccess::ALLOWED_WINDOW_TITLES[MAX_PATH][MAX_PATH] = {0};
UINT CWHPaccess::NUMBER_OF_ALLOWED_WINDOW_TITLES = 0;
wchar_t CWHPaccess::ALLOWED_WINDOW_CLASSES[MAX_PATH][MAX_PATH] = {0};
UINT CWHPaccess::NUMBER_OF_ALLOWED_WINDOW_CLASSES = 0;
UINT CWHPaccess::nLoggingDetail = LOGGING_NONE;
wchar_t CWHPaccess::LoggingPath[MAX_PATH] = {0};
#pragma data_seg()
#pragma comment( linker, "/SECTION:.CWHP,rws" )
//////////////////////////////////////////////////////////////////////
// Constructor / Destructor
//////////////////////////////////////////////////////////////////////
CWHPaccess::CWHPaccess()
{
InitializeCriticalSection(&cs);
}
CWHPaccess::~CWHPaccess()
{
DeleteCriticalSection(&cs);
}
// Set/Get hHook
void CWHPaccess::set_hHook(HHOOK hook)
{
EnterCS();
hHook = hook;
LeaveCS();
}
HHOOK CWHPaccess::get_hHook()
{
return hHook;
}
// Public CRITICAL_SECTION Accessors
void CWHPaccess::EnterCS()
{
EnterCriticalSection(&cs);
}
void CWHPaccess::LeaveCS()
{
LeaveCriticalSection(&cs);
}
//////////////////////////////////////////////////////////////////////
// Func: ClearHookItem()
// Desc: Clears a single Hook Item
//////////////////////////////////////////////////////////////////////
void CWHPaccess::ClearHookItem(UINT nItem)
{
if((nItem < 0) || (nItem >= MAX_PATH))
return;
HList[nItem].hWnd = NULL;
HList[nItem].DefWndProc = NULL;
HList[nItem].HookWndProc = NULL;
HList[nItem].wpfcaller = NULL;
}
//////////////////////////////////////////////////////////////////////
// Func: ClearHookSData()
// Desc: Clears all the data stored in the Shared DS segment's Hook List
//////////////////////////////////////////////////////////////////////
void CWHPaccess::ClearHookSData()
{
EnterCS();
hHook = NULL;
HListI = 0;
for (int i=0; i < MAX_PATH; ++i)
ClearHookItem(i);
LeaveCS();
}
//////////////////////////////////////////////////////////////////////
// Func: InsertHookedWndItem()
// Desc: Inserts a HookWndItem into the Shared DS's HookedList
//////////////////////////////////////////////////////////////////////
BOOL CWHPaccess::InsertHookedWndItem(HookWndItem &Item)
{
BOOL bRetVal = FALSE;
EnterCS();
for (UINT i = 0;i < MAX_PATH; ++i)
{
if(HList[i].hWnd == NULL)
{
HList[i] = Item;
log(LOGGING_DEBUG, L"Inserting HookedItem into DS index = %i", i);
// Keep track of the list top index *performance*
if(i > HListI)
{
HListI = i;
log(LOGGING_DEBUG, L"Inserting HookedItem setting HListI = %i", HListI);
}
bRetVal = TRUE;
break;
}
}
LeaveCS();
return bRetVal;
}
//////////////////////////////////////////////////////////////////////
// Func: FindHookedWnd()
// Desc: Finds Inserts a HookWndItem into the Shared DS's HookedList
//////////////////////////////////////////////////////////////////////
BOOL CWHPaccess::FindHookedWnd(HWND hWnd)
{
BOOL bRetVal = FALSE;
EnterCS();
for (UINT i = 0;i <= HListI;++i)
{
if(HList[i].hWnd == hWnd)
{
bRetVal = TRUE;
break;
}
}
LeaveCS();
return bRetVal;
}
//////////////////////////////////////////////////////////////////////
// Func: GetHookedWndItem()
// Desc: Returns a matchin HookWndItem (.hWnd will be NULL if not found)
//////////////////////////////////////////////////////////////////////
HookWndItem CWHPaccess::GetHookedWndItem(HWND hWnd)
{
BLANK_HookWndItem(retVal);
EnterCS();
for (UINT i = 0;i <= HListI;++i)
{
if(HList[i].hWnd == hWnd)
{
retVal = HList[i];
}
}
LeaveCS();
return(retVal);
}
//////////////////////////////////////////////////////////////////////
// Func: GetHookedWindowListNSize()
// Desc: Use this to get a copy of the hooked window buffer and size in the Shared DS
//////////////////////////////////////////////////////////////////////
void CWHPaccess::GetHookedWindowListNSize(int* nbuf, int* nsize)
{
EnterCS();
// write out the size
*nsize = HListI;
for (UINT i = 0;i <= HListI;++i)
{
// write out the actual buffer
*(nbuf + i) = (int) HList[i].hWnd;
}
LeaveCS();
}
//////////////////////////////////////////////////////////////////////
// Func: SetHookedWndItem()
// Desc: Use this to overwrite Hook information for a window in the Shared DS
//////////////////////////////////////////////////////////////////////
BOOL CWHPaccess::SetHookedWndItem(HWND hWnd, HookWndItem& Item)
{
BOOL bRetVal = FALSE;
EnterCS();
for (UINT i = 0;i <= HListI;++i)
{
if((HList[i].hWnd == hWnd) &&
(hWnd == Item.hWnd))
{
HList[i] = Item;
bRetVal = TRUE;
}
}
LeaveCS();
return bRetVal;
}
//////////////////////////////////////////////////////////////////////
// Func: DeleteHookedWnd()
// Desc: Finds Inserts a HookWndItem into the Shared DS's HookedList
//////////////////////////////////////////////////////////////////////
BOOL CWHPaccess::DeleteHookedWnd(HWND hWnd)
{
BOOL retVal = FALSE;
EnterCS();
// Is it the Last Item in the list?
if(HList[HListI].hWnd == hWnd)
{
ClearHookItem(HListI);
if(HListI > 0)
{
HListI = HListI - 1;
log(LOGGING_DEBUG, L"DeleteHookedWnd HListI set to %i", HListI);
}
retVal = TRUE;
}
else
{
for (UINT i = 0; i <= HListI; ++i)
{
if(HList[i].hWnd == hWnd)
{
ClearHookItem(i);
deltaListTopI(i);
retVal = TRUE;
break;
}
}
}
LeaveCS();
return retVal;
}
//////////////////////////////////////////////////////////////////////
// Func: deltaListTopI()
// Desc: *for performance * adjusts the Top index responding to a delete
//////////////////////////////////////////////////////////////////////
void CWHPaccess::deltaListTopI(int deletedIndex)
{
UINT i;
EnterCS();
for(i = deletedIndex + 1; i <= HListI; ++i)
{
if(HList[i].hWnd == NULL)
{
continue;
}
break;
}
if(i > HListI)
{
if(deletedIndex > 0)
{
HListI = deletedIndex - 1;
log(LOGGING_DEBUG, L"deltaListTopI HListI set to %i", HListI);
}
else
{
log(LOGGING_DEBUG, L"deltaListTopI HListI set to %i", HListI);
HListI = 0;
}
}
LeaveCS();
}
//////////////////////////////////////////////////////////////////////
// Func: AddAllowedProcessName()
// Desc: Add Allowed Process Name
//////////////////////////////////////////////////////////////////////
void CWHPaccess::AddAllowedProcessName(wchar_t* strProcessNameInUpperCase)
{
if(strProcessNameInUpperCase)
{
EnterCS();
int i = NUMBER_OF_ALLOWED_PROCESS_NAMES;
lstrcpyn(ALLOWED_PROCESS_NAMES[i], strProcessNameInUpperCase, MAX_PATH - 1);
NUMBER_OF_ALLOWED_PROCESS_NAMES = i + 1;
LeaveCS();
log(LOGGING_DEBUG, L"Allowing Process %s", strProcessNameInUpperCase);
}
}
//////////////////////////////////////////////////////////////////////
// Func: IsAllowedProcessName()
// Desc: Find Allowed Process Name
//////////////////////////////////////////////////////////////////////
BOOL CWHPaccess::IsAllowedProcessName(wchar_t* strProcessNameInUpperCase)
{
BOOL bRetVal = FALSE;
if(strProcessNameInUpperCase)
{
EnterCS();
for (UINT i = 0; i < NUMBER_OF_ALLOWED_PROCESS_NAMES; ++i)
{
if(wcsstr(strProcessNameInUpperCase, ALLOWED_PROCESS_NAMES[i]))
{
bRetVal = TRUE;
break;
}
}
LeaveCS();
}
return bRetVal;
}
//////////////////////////////////////////////////////////////////////
// Func: AddAllowedApplication()
// Desc: Add Allowed Windows Titles
//////////////////////////////////////////////////////////////////////
void CWHPaccess::AddAllowedWindowsTitle(wchar_t* strWindowsTitleInUpperCase)
{
if(strWindowsTitleInUpperCase)
{
EnterCS();
int i = NUMBER_OF_ALLOWED_WINDOW_TITLES;
lstrcpyn(ALLOWED_WINDOW_TITLES[i], strWindowsTitleInUpperCase, MAX_PATH - 1);
NUMBER_OF_ALLOWED_WINDOW_TITLES = i + 1;
LeaveCS();
log(LOGGING_DEBUG, L"Allowing Window %s", strWindowsTitleInUpperCase);
}
}
//////////////////////////////////////////////////////////////////////
// Func: IsAllowedWindowsTitle()
// Desc: Find Allowed Window Title
//////////////////////////////////////////////////////////////////////
BOOL CWHPaccess::IsAllowedWindowsTitle(wchar_t* strWindowsTitleInUpperCase)
{
BOOL bRetVal = FALSE;
if(strWindowsTitleInUpperCase)
{
EnterCS();
for (UINT i = 0; i < NUMBER_OF_ALLOWED_WINDOW_TITLES; ++i)
{
if(wcsstr(strWindowsTitleInUpperCase, ALLOWED_WINDOW_TITLES[i]))
{
bRetVal = TRUE;
break;
}
}
LeaveCS();
}
return bRetVal;
}
//////////////////////////////////////////////////////////////////////
// Func: AddAllowedWindowsClass()
// Desc: Add Allowed Windows Class
//////////////////////////////////////////////////////////////////////
void CWHPaccess::AddAllowedWindowsClass(wchar_t* strWindowsClassInUpperCase)
{
if(strWindowsClassInUpperCase)
{
EnterCS();
int i = NUMBER_OF_ALLOWED_WINDOW_CLASSES;
lstrcpyn(ALLOWED_WINDOW_CLASSES[i], strWindowsClassInUpperCase, MAX_PATH - 1);
NUMBER_OF_ALLOWED_WINDOW_CLASSES = i + 1;
LeaveCS();
log(LOGGING_DEBUG, L"Allowing Window Class %s", strWindowsClassInUpperCase);
}
}
//////////////////////////////////////////////////////////////////////
// Func: IsAllowedWindowsClass()
// Desc: Find Allowed Window Class
//////////////////////////////////////////////////////////////////////
BOOL CWHPaccess::IsAllowedWindowsClass(wchar_t* strWindowsClassInUpperCase)
{
BOOL bRetVal = FALSE;
if(strWindowsClassInUpperCase)
{
EnterCS();
for (UINT i = 0; i < NUMBER_OF_ALLOWED_WINDOW_CLASSES; ++i)
{
if(wcsstr(strWindowsClassInUpperCase, ALLOWED_WINDOW_CLASSES[i]))
{
bRetVal = TRUE;
break;
}
}
LeaveCS();
}
return bRetVal;
}
//////////////////////////////////////////////////////////////////////
// Func: SetLoggingDetail()
// Desc: Allows us to set a global used by all button hooks to log
//////////////////////////////////////////////////////////////////////
void CWHPaccess::SetLoggingDetail(LoggingDetail nLoggingDetailSetting)
{
EnterCS();
nLoggingDetail = nLoggingDetailSetting;
LeaveCS();
}
//////////////////////////////////////////////////////////////////////
// Desc: Returns the Detail of our Logging (high, medium, low, or none)
//////////////////////////////////////////////////////////////////////
LoggingDetail CWHPaccess::GetLoggingDetail()
{
return (static_cast<LoggingDetail>(nLoggingDetail));
}
//////////////////////////////////////////////////////////////////////
// Desc: Get Directory location where we should log to
//////////////////////////////////////////////////////////////////////
wchar_t* CWHPaccess::GetLogPath()
{
return reinterpret_cast<wchar_t*>(&LoggingPath);
}
//////////////////////////////////////////////////////////////////////
// Desc: Set Directory location where we should log to
//////////////////////////////////////////////////////////////////////
void CWHPaccess::SetLogPath(wchar_t* buf)
{
EnterCS();
lstrcpyn(LoggingPath,buf,MAX_PATH - 1);
EnterCS();
}

View File

@@ -0,0 +1,97 @@
// CWHPaccess.h
#pragma once
#include "WPFCaller.h"
namespace Ooganizer
{
//////////////////////////////////////////////////////////////////////
//********************************************************************
// DS access Class - Created to easily enforce critical sections and
// share the statically created DS
//********************************************************************
//////////////////////////////////////////////////////////////////////
class CWHPaccess
{
public:
////
// All these statics are put into the DS and shared accross all DLL instances
// ~Use accessor functions below to modify these
////
static HINSTANCE hModule;
static HHOOK hHook;
static HookWndItem HList[MAX_PATH];
static UINT HListI;
static wchar_t ALLOWED_PROCESS_NAMES[MAX_PATH][MAX_PATH];
static UINT NUMBER_OF_ALLOWED_PROCESS_NAMES;
static wchar_t ALLOWED_WINDOW_TITLES[MAX_PATH][MAX_PATH];
static UINT NUMBER_OF_ALLOWED_WINDOW_TITLES;
static wchar_t ALLOWED_WINDOW_CLASSES[MAX_PATH][MAX_PATH];
static UINT NUMBER_OF_ALLOWED_WINDOW_CLASSES;
static UINT nLoggingDetail;
static wchar_t LoggingPath[MAX_PATH];
// Hook Handle
void set_hHook(HHOOK);
HHOOK get_hHook();
// Clears all Shared DS segment's Hook List data
// (imp, when releasing the hook)
void ClearHookSData();
// Allows a Caller to get a copy of all hooked Window Handles
// and size of the hooked window list
void GetHookedWindowListNSize(int* nbuf, int* nsize);
////
// Find,Insert,Deletion of HookWnd
////
BOOL InsertHookedWndItem(HookWndItem& Item);
BOOL FindHookedWnd(HWND hWnd);
HookWndItem GetHookedWndItem(HWND hWnd);
BOOL SetHookedWndItem(HWND hWnd, HookWndItem& Item);
BOOL DeleteHookedWnd(HWND hWnd);
////
// Allowed ProcessNames & WindowTitles & Classes WhiteList
////
void AddAllowedProcessName(wchar_t* strProcessNameInUpperCase);
BOOL IsAllowedProcessName(wchar_t* strProcessNameInUpperCase);
void AddAllowedWindowsTitle(wchar_t* strWindowsTitleInUpperCase);
BOOL IsAllowedWindowsTitle(wchar_t* strWindowsTitleInUpperCase);
void AddAllowedWindowsClass(wchar_t* strWindowsClassInUpperCase);
BOOL IsAllowedWindowsClass(wchar_t* strWindowsClassInUpperCase);
////
// Get/Set and use Logging Detail Levels
////
void SetLoggingDetail(LoggingDetail nLoggingDetailSetting);
LoggingDetail GetLoggingDetail();
wchar_t* GetLogPath();
void SetLogPath(wchar_t* buf);
// CRITICAL_SECTION
void EnterCS();
void LeaveCS();
CWHPaccess();
~CWHPaccess();
private:
////
// Private functions to keep track of iteration
////
void deltaListTopI(int);
////
// Private Helper Functions
////
void ClearHookItem(UINT nItem);
//Many threads could update the DS.
CRITICAL_SECTION cs;
};
}

151
Hooks/ButtonHook/HookList.h Normal file
View File

@@ -0,0 +1,151 @@
//#pragma once
//
//#include "malloc.h"
//
//namespace Ooganizer
//{
//
// enum ButtonState{BUTTON_UP,BUTTON_DOWN};
//
// //////////////////////////////////////////////////////////////////////
// // Clss: HookItem
// // Desc: Hook Item is used in the HookList. Each HookItem keeps track
// // of all the addresses needed for each hook, as well as the
// // hookstate.
// //
// // Note: Add State Items for a Window as neccessary
// //////////////////////////////////////////////////////////////////////
// class HookItem
// {
// public:
// HWND m_hWnd;
// WNDPROC m_HookWndProc;
// WNDPROC m_DefWndProc;
// ButtonState m_btnState;
//
// // Constructor
// HookItem(HWND hWnd, WNDPROC hookWndProc, WNDPROC defWndProc):
// m_hWnd(hWnd),
// m_HookWndProc(hookWndProc),
// m_DefWndProc(defWndProc),
// m_btnState(BUTTON_UP)
// {
// }
// };
// //////////////////////////////////////////////////////////////////////
// // Clss: HookList
// // Desc: Generic List / Custom written list for the sake of speed.
// // Hook list is made up of individual HookItems.
// //
// // Note: You can use GetNext() to iterate thru all the items in the list.
// // ~adding or removing an item causes GetNext() to start over.
// //////////////////////////////////////////////////////////////////////
// class HookList
// {
// public:
// //////////////////////////////////////////////////////////////////////
// // Func: AddItem()
// // Desc: Adds a HookItem to the List
// //////////////////////////////////////////////////////////////////////
// void AddItem(HookItem* pItem)
// {
// m_NbrItems++;
//
// if ( m_pHookItem == NULL )
// m_pHookItem = (HookItem*) malloc( m_NbrItems * sizeof( HookItem ) );
// else
// m_pHookItem = (HookItem*) realloc( m_pHookItem, m_NbrItems * sizeof( HookItem ) );
//
// log(pItem->m_hWnd,"hase been added");
//
// memcpy( m_pHookItem+(m_NbrItems-1), pItem, sizeof( HookItem ) );
// }
// //////////////////////////////////////////////////////////////////////
// // Func: GetItem()
// // Desc: Get a HookItem from the List
// //////////////////////////////////////////////////////////////////////
// HookItem* GetItem(HWND hWnd)
// {
// UINT i;
// HookItem * pItem = m_pHookItem;
// for( i=0; i<m_NbrItems && pItem->m_hWnd!=hWnd; i++, pItem++ );
// return ( i < m_NbrItems ) ? pItem : NULL;
// }
// //////////////////////////////////////////////////////////////////////
// // Func: DelItem()
// // Desc: Deletes a HookItem from the List
// //////////////////////////////////////////////////////////////////////
// void DelItem(HWND hWnd)
// {
// UINT i;
// HookItem * pItem = m_pHookItem;
// for( i =0; i<m_NbrItems && pItem->m_hWnd!=hWnd; i++, pItem++ );
// if ( i < m_NbrItems )
// {
// m_NbrItems--;
// memcpy( pItem, pItem+1, ( m_NbrItems - i ) * sizeof( HookItem ) );
// m_pHookItem = (HookItem*) realloc( m_pHookItem, m_NbrItems * sizeof( HookItem ) );
//
// log(pItem->m_hWnd,"hase been deleted");
// }
// }
// //////////////////////////////////////////////////////////////////////
// // Func: DelAllItems()
// // Desc: Deletes all HookItems from the List
// //////////////////////////////////////////////////////////////////////
// void DelAllItems()
// {
// if ( m_pHookItem != NULL )
// free( m_pHookItem );
// m_pHookItem = NULL;
// m_NbrItems = 0;
// }
// //////////////////////////////////////////////////////////////////////
// // Func: UnhookAllItems()
// // Desc: Responsible for iterating through entire list and 'unhooking'
// // the WndProc function of every HookItem
// //
// // Note: has to be put in here since the list has to be iterated here
// //////////////////////////////////////////////////////////////////////
// void UnhookAllItems()
// {
// HookItem * pItem;
//
// while ( m_NbrItems > 0 )
// {
// pItem = m_pHookItem+(m_NbrItems-1);
//
// // Unhook window
// HWND hWnd = pItem->m_hWnd;
//
// log(hWnd,"Unhooking...");
// SetWindowLong( hWnd, GWL_WNDPROC, (LONG) pItem->m_DefWndProc );
// SendMessage( hWnd, WM_NCPAINT, 1, 0 );
// log(hWnd,"Sending WM_NCPAINT message...");
//
// // Delete item
// DelItem( hWnd );
// }
// }
// //////////////////////////////////////////////////////////////////////
// // Func: CleanUp()
// // Desc: Unhooks all HookItems in the list and deletes the list
// //////////////////////////////////////////////////////////////////////
// void CleanUp()
// {
// UnhookAllItems();
// DelAllItems();
// }
// //////////////////////////////////////////////////////////////////////
// //********************************************************************
// // Construction / Destruction
// //********************************************************************
// //////////////////////////////////////////////////////////////////////
// HookList():m_NbrItems(0),m_pHookItem(NULL){}
// ~HookList(){CleanUp();}
//
// protected:
// UINT m_NbrItems;
// HookItem* m_pHookItem;
// };
//}

View File

@@ -0,0 +1,20 @@
// HookWndItem.h
#pragma once
extern class CaptionButton;
//////////////////////////////////////////////////////////////////////
// Strc: HookWndItem
// Desc: Hook Item is used in the HookedWndList. Each HookWndItem keeps track
// of all the addresses needed for each hook for each Windows,
// as well as each Window's ButtonState.
//
// Note: Add State Items for a Window as neccessary
//////////////////////////////////////////////////////////////////////
struct HookWndItem
{
HWND hWnd;
WNDPROC HookWndProc;
WNDPROC DefWndProc;
ButtonState state;
CaptionButton* button;
};

153
Hooks/ButtonHook/Stdafx.cpp Normal file
View File

@@ -0,0 +1,153 @@
// stdafx.cpp : source file that includes just the standard includes
// Ooganizer-Hook.pch will be the pre-compiled header
// stdafx.obj will contain the pre-compiled type information
#include "stdafx.h"
#include "stdio.h"
#include "stdlib.h"
//////////////////////////////////////////////////////////////////////
// Func: SetLoggingDetail()
//////////////////////////////////////////////////////////////////////
void SetLoggingDetail(LoggingDetail detail, wchar_t* logPath)
{
#ifdef _DEBUG
g_LoggingDetail = LOGGING_DEBUG;
#else
g_LoggingDetail = detail;
#endif
// If the log path is set externally set it here internally
// else set the log path to %USERPROFILE%\AppData\Local\Temp
if(logPath && logPath[0] != 0)
{
lstrcpyn(g_LogPath, logPath, (MAX_PATH - lstrlen(g_LOG_FILE_NAME)));
}
else
{
size_t len = 0;
errno_t err = 0;
wchar_t* pValue = NULL;
if(err = _wdupenv_s( &pValue, &len, L"TMP"))
if(err = _wdupenv_s( &pValue, &len, L"TEMP"))
return;
if(pValue != NULL)
lstrcpyn(g_LogPath, pValue, (MAX_PATH - lstrlen(g_LOG_FILE_NAME)));
}
// Make sure Path ends with '\'
if(g_LogPath[lstrlen(g_LogPath) - 1] != L'\\')
lstrcat(g_LogPath, L"\\");
// Add the Log File name to the path variable (now we have everything)
// ~we are ready to do some serious logging
lstrcat(g_LogPath,g_LOG_FILE_NAME);
}
//////////////////////////////////////////////////////////////////////
// Func: GetLoggingDetail()
//////////////////////////////////////////////////////////////////////
_LoggingDetail GetLoggingDetail()
{
return g_LoggingDetail;
}
//////////////////////////////////////////////////////////////////////
// Func: log()
// Desc: Logs to Ooganizer.log in defined LogPath or temporary folder
// Prms: Variable # of params
//
// Usge: Log("%s %d %d %d", "test", 1, 2, 3)
//////////////////////////////////////////////////////////////////////
//void log( LoggingDetail detail, char * pFmt, ... )
//{
// if(g_LoggingDetail >= detail)
// {
// FILE* pFile = NULL;
// errno_t err = 0;
//
// if ( !( err = fopen_s( &pFile, g_LogPath, "at" ) ) )
// {
// fprintf( pFile, "ThreadId %i -", GetCurrentThreadId());
// va_list arg;
// va_start( arg, pFmt );
// vfprintf( pFile, pFmt, arg );
// va_end( arg );
//
// if ( pFmt[strlen( pFmt ) - 1] != '\n' )
// fprintf( pFile, "\n" );
// fclose( pFile );
// }
// }
//}
//////////////////////////////////////////////////////////////////////
// Func: log()
// Desc: Logs to Ooganizer.log in defined LogPath or temporary folder using Wide Char
// Prms: Variable # of params
//
// Usge: Log("%s %d %d %d", "test", 1, 2, 3)
//////////////////////////////////////////////////////////////////////
void log( LoggingDetail detail, wchar_t * pFmt, ... )
{
if(g_LoggingDetail >= detail)
{
FILE* pFile = NULL;
errno_t err = 0;
if ( !( err = _wfopen_s( &pFile, g_LogPath, L"at" ) ) )
{
if(detail == LOGGING_LOW)
fwprintf( pFile, L"ThreadId %i - [Imp] - ", GetCurrentThreadId()); // low == very important messages
else if(detail == LOGGING_MEDIUM)
fwprintf( pFile, L"ThreadId %i - {P/D} - ", GetCurrentThreadId()); // medium == program details
else if(detail == LOGGING_HIGH)
fwprintf( pFile, L"ThreadId %i - {X/D} - ", GetCurrentThreadId()); // high == more program details (extra}
else if(detail == LOGGING_DEBUG)
fwprintf( pFile, L"ThreadId %i - Debug - ", GetCurrentThreadId()); // debug == only show up in debug builds (Debug Only)
else
fwprintf( pFile, L"ThreadId %i - <N/A> - ", GetCurrentThreadId()); // should never happen
va_list arg;
va_start( arg, pFmt );
vfwprintf( pFile, pFmt, arg );
va_end( arg );
if ( pFmt[lstrlen( pFmt ) - 1] != '\n' )
fwprintf( pFile, L"\n" );
fclose( pFile );
}
}
}
//////////////////////////////////////////////////////////////////////
// Func: log()
// Desc: Logs the window title text to the Log File
// Prms: HWND, handle to a window
// str, custom string to log
//
// Note: GetWindowText doesn't always return TRUE, if this function
// gets called during the WndProc it will return False
//////////////////////////////////////////////////////////////////////
void log(LoggingDetail detail, HWND hWnd, wchar_t* str)
{
if(g_LoggingDetail >= detail)
{
wchar_t Title[MAX_PATH + 1] = {0};
if (GetWindowText(hWnd,Title,MAX_PATH))
log(detail, L"Window - %s - %s", Title, str);
}
}
//////////////////////////////////////////////////////////////////////
// Func: clearLog()
// Desc: clears the log file (used at startup) - Only Clears if Logging is enabled
//////////////////////////////////////////////////////////////////////
void clearLog()
{
if(g_LoggingDetail != LOGGING_NONE)
{
FILE* pFile = NULL;
errno_t err = 0;
if( !( err = _wfopen_s( &pFile, g_LogPath, L"w" ) ) )
fclose( pFile );
}
}

47
Hooks/ButtonHook/Stdafx.h Normal file
View File

@@ -0,0 +1,47 @@
// stdafx.h : include file for standard system include files,
// or project specific include files that are used frequently,
// but are changed infrequently
#pragma once
// Compiler Error Messages that we want to disable:
#pragma warning ( disable : 4793 ) // Compiling functions as native code
#pragma warning ( disable : 4996 ) // 'strncpy': This function or variable may be unsafe
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
#include <windows.h>
//////////////////////////////////////////////////////////////////////
//********************************************************************
// Global Enums
//********************************************************************
//////////////////////////////////////////////////////////////////////
// Logging Detail Settings
typedef enum _LoggingDetail{LOGGING_NONE,LOGGING_LOW,LOGGING_MEDIUM,LOGGING_HIGH,LOGGING_DEBUG} LoggingDetail;
// Enable Logging and if so, which detail (default = none)
static LoggingDetail g_LoggingDetail = LOGGING_NONE;
static wchar_t g_LogPath[MAX_PATH + 1] = {0};
static const wchar_t g_LOG_FILE_NAME[] = L"ButtonHook.log"; // Log File for now is just hardcoded
//////////////////////////////////////////////////////////////////////
//********************************************************************
// Global Functions
//********************************************************************
//////////////////////////////////////////////////////////////////////
// Logs to Ooganizer.log in temporary folder if no log path is set
// %USERPROFILE%\AppData\Local\Temp\Ooganizer.log
//void log(LoggingDetail detail, char * pFmt, ... );
void log( LoggingDetail detail, HWND hWnd, wchar_t* str); // Logs Window Text
void log( LoggingDetail detail, wchar_t * pFmt, ... );
// At Startup we clear the log
void clearLog();
// Set the global (for this dll instance) Logging Detail Setting
void SetLoggingDetail(LoggingDetail detail, wchar_t* logPath);
// Get Logging Detail for custom debug behavior
_LoggingDetail GetLoggingDetail();

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,171 @@
#pragma once
#include "thread.h"
#ifdef _DEBUG
#import "..\\..\\Target\\Debug\\ButtonWPForm.tlb"
#else
#import "..\\..\\Target\\Release\\ButtonWPForm.tlb"
#endif
using namespace ButtonWPForm;
namespace Ooganizer
{
enum BUTTON_STATE
{
// These are the states that coincide with the states defined
// in ButtonWPFormCCW
BUTTON_NONE = 1,
BUTTON_DOWN = 2, // BUTTON_ADD
BUTTON_TOGGLED = 3, // BUTTON_DELETE
// Button Up is the Hover image (Used on Mouse Over),
// it is NOT DEFINED in BHInteracter
BUTTON_UP = 1000
};
////
// ButtonThemeSetting, this static holds our current Button Theme Setting
// ~This structure can be reloaded when a ThemeChange occured (WM_THEMECHANGED)
////
struct ButtonThemeSetting
{
// Init Flags
bool bIsInitialized;
bool bIsChanged;
// Int Button Dimension/Location
long Top;
long Right;
long Height;
long Width;
// String Button Locations
_bstr_t bstrBUTTON_UP;
_bstr_t bstrBUTTON_DOWN;
_bstr_t bstrTOGGLE_UP;
ButtonThemeSetting()
{
Top = 0;
Right = 0;
Height = 0;
Width = 0;
bIsInitialized = false;
bIsChanged = false;
}
};
class CWHPaccess;
class WPFCaller;
#define BLANK_HookWndItem(n) HookWndItem n = {NULL,NULL,NULL,NULL}
//////////////////////////////////////////////////////////////////////
// Strc: HookWndItem
// Desc: Hook Item is used in the HookedWndList. Each HookWndItem keeps track
// of all the addresses needed for each hook for each Windows,
// as well as each Window's WPFCaller.
//////////////////////////////////////////////////////////////////////
struct HookWndItem
{
HWND hWnd;
WNDPROC HookWndProc;
WNDPROC DefWndProc;
WPFCaller* wpfcaller;
};
//////////////////////////////////////////////////////////////////////
// Clss: WPFCaller
// Desc: This class is responsible for overriding wndproc draw routines
// and communicate to the WPF COM object
//////////////////////////////////////////////////////////////////////
class WPFCaller : Thread
{
public:
// All Windows Messages *Except NCDestroy & UnHook* enter here
virtual LRESULT OnDefault (HWND hWnd,UINT Msg,WPARAM wParam,LPARAM lParam);
WPFCaller(HookWndItem Item, HINSTANCE hInstance);
~WPFCaller();
// Each WPFCaller is mapped to a HookWndItem (Hooked Window)
HWND m_hWnd;
WNDPROC m_HookWndProc;
WNDPROC m_DefWndProc;
HINSTANCE m_hInst;
// Window W32 State Settings
// ~we are keeping track of the Hooked W32 sizes
int m_wndHeight;
int m_wndWidth;
RECT m_wndRECT;
// We need to keep track of the Button State in order
// to know what to draw
BUTTON_STATE m_ButtonState;
BUTTON_STATE m_ButtonToggledState; // We can overwrite buttonDown state
// with another state. this allows us to
// specify which state to use to overwrite.
BUTTON_STATE m_ButtonStateLastSaved;
BUTTON_STATE m_ButtonToggledStateLastSaved;
bool m_bButtonIsArtificiallyHidden_MOVE;
bool m_bButtonIsMinimized;
bool m_bButtonIsBeingRestored;
// Transparency / Fade Effect
BYTE GetAlpha();
void SetAlpha(BYTE bAlpha);
void StartRestoreEventFadeTimer();
// Client Events
void StartCloseButNotDestroyTimer();
int m_StartCloseButNotDestroyTimerCount;
// Drag N' Dropped Files
int m_nDragDroppedFilesCount;
_bstr_t m_bstrDragDroppedFilesSemiColonSep;
// OpenFile or FileSaveAs Dialog Prms Passing
wchar_t m_strFileNameLocationBuf[MAX_PATH + 1];
wchar_t m_strFileTypesBuf[MAX_PATH + 1];
// WPFProc Will load the Button Settings via COM which
// we'll use to draw the Icon
ButtonThemeSetting m_ButtonThemeSetting;
// Window Handles
HWND m_hwndWPForm; // passed back to us by ButtonWPForm
HWND m_hwndW32Window; // our w32 Button
// ThreadStuff (WPFComThread)
bool m_bThreadIsReady;
HANDLE m_thread;
DWORD m_threadID;
private:
// OnDefault() uses this function to possible send messages
// to the EventDispatcher in C# for further processing
void EventDispatcherHandler(HWND hWnd,UINT Msg,WPARAM wParam,LPARAM lParam);
// We don't need to right now, but we may need it more in the future.
// Office passes in startup file prms via DDE (other apps may too)
void HandleDDEMessages(HWND hWnd, UINT Msg,WPARAM wParam,LPARAM lParam);
// Win32 Button Window * Created for better speed *
// Responsible for setting up the WNDCLASSEX struct and register the Window
BOOL InitApplication(HINSTANCE hInstance);
// Responsible for Creating and Showing a new Window Class Instance
BOOL InitInstance(HINSTANCE hInstance, int nCmdShow);
// Thread Entry
int WINAPI threadproc(HINSTANCE hinstance, HINSTANCE hPrevInstance, void* vArg, int nCmdShow);
// Thread Entry
virtual DWORD Run(LPVOID vArg)
{
return(threadproc(m_hInst,NULL,vArg,TRUE));
}
};
}

View File

@@ -0,0 +1,15 @@
//{{NO_DEPENDENCIES}}
// Microsoft Visual C++ generated include file.
// Used by ButtonHook.rc
//
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 105
#define _APS_NEXT_COMMAND_VALUE 40001
#define _APS_NEXT_CONTROL_VALUE 1001
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif

100
Hooks/ButtonHook/thread.h Normal file
View File

@@ -0,0 +1,100 @@
#pragma once
namespace Ooganizer
{
// Generic Thread Class!
class Thread
{
public:
// Starts the thread
// This function starts the thread pointed by m_pThreadFunc with default attributes
DWORD Start( void* arg = NULL )
{
m_ThreadCtx.m_pUserData = arg;
m_ThreadCtx.m_hThread = CreateThread(NULL, 0, m_pThreadFunc, this, 0, &m_ThreadCtx.m_dwTID);
m_ThreadCtx.m_dwExitCode = (DWORD)-1;
return GetLastError();
}
// Stops the thread.
// This function stops the current thread
DWORD Stop ( bool bForceKill = false )
{
log(LOGGING_HIGH, L"Hidden Wnd Thread Stopped()");
if ( m_ThreadCtx.m_hThread )
{
GetExitCodeThread(m_ThreadCtx.m_hThread, &m_ThreadCtx.m_dwExitCode);
if ( m_ThreadCtx.m_dwExitCode == STILL_ACTIVE && bForceKill )
TerminateThread(m_ThreadCtx.m_hThread, DWORD(-1));
m_ThreadCtx.m_hThread = NULL;
}
return m_ThreadCtx.m_dwExitCode;
}
// Returns Thread Exit Code
DWORD GetExitCode() const
{
if ( m_ThreadCtx.m_hThread )
GetExitCodeThread(m_ThreadCtx.m_hThread, (LPDWORD)&m_ThreadCtx.m_dwExitCode);
return m_ThreadCtx.m_dwExitCode;
}
// Attaches a Thread Function
// Used primarily for porting but can serve in developing generic thread objects
void Attach( LPTHREAD_START_ROUTINE lpThreadFunc ){
m_pThreadFunc = lpThreadFunc;
}
// Detaches the Attached Thread Function
// Detaches the Attached Thread Function, If any.
void Detach( void ){
m_pThreadFunc = Thread::EntryPoint;
}
Thread(){ m_pThreadFunc = Thread::EntryPoint; /*Can call Detach Also*/ }
//plug-in constructor
Thread(PTHREAD_START_ROUTINE lpExternalRoutine){Attach(lpExternalRoutine);}
~Thread(){ if(m_ThreadCtx.m_hThread) Stop(true);}
protected:
// Std Template: Override if you are sure of what you are doing
static DWORD WINAPI EntryPoint( LPVOID pArg)
{
Thread *pParent = reinterpret_cast<Thread*>(pArg);
pParent->ThreadCtor();
pParent->Run( pParent->m_ThreadCtx.m_pUserData );
pParent->ThreadDtor();
return STILL_ACTIVE;
}
// Override this method with the body/code of your thread
virtual DWORD Run( LPVOID /*arg */){return m_ThreadCtx.m_dwExitCode;}
// override this function to provide your extra initialization
virtual void ThreadCtor(){}
// Override this function to provide your extra destruction
virtual void ThreadDtor(){}
////
// Thread Context Inner Class (UserData Pointer, Handle, Thread ID)
////
class CThreadContext
{
public:
CThreadContext(){memset(this, 0, sizeof(this));}
// Attributes
public:
HANDLE m_hThread; // The Thread Handle
DWORD m_dwTID; // The Thread ID
LPVOID m_pUserData; // The user data pointer
LPVOID m_pParent; // The this pointer of the parent CThread object
DWORD m_dwExitCode; // The Exit Code of the thread
} m_ThreadCtx; // The Thread Context Member
LPTHREAD_START_ROUTINE m_pThreadFunc; // The Worker Thread Function Pointer
};
}

View File

@@ -0,0 +1,57 @@
namespace Foo.Hooks.CaptionButton
{
partial class CaptionButton
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.SuspendLayout();
//
// CaptionButton
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.BackColor = System.Drawing.SystemColors.ControlText;
this.ClientSize = new System.Drawing.Size(10, 10);
this.ControlBox = false;
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "CaptionButton";
this.Opacity = 0.0;
this.ShowIcon = false;
this.ShowInTaskbar = false;
this.WindowState = System.Windows.Forms.FormWindowState.Minimized;
this.Load += new System.EventHandler(this.CaptionButton_Load);
this.HandleCreated += new System.EventHandler(CaptionButton_HandleCreated);
this.Shown += new System.EventHandler(CaptionButton_Shown);
this.ResumeLayout(false);
}
#endregion
}
}

View File

@@ -0,0 +1,107 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using System.Reflection;
using Foo.Platform;
using Foo.Platform.Interacters;
namespace Foo.Hooks.CaptionButton
{
public partial class CaptionButton : Form
{
// Declare the Log4net Variable
private static log4net.ILog Log = Logger.GetLog4NetInterface(MethodBase.GetCurrentMethod().DeclaringType);
[DllImport("user32.dll")]
public static extern Int32 GetWindowLong(IntPtr hwnd, int nIndex);
[DllImport("user32.dll")]
public static extern Int32 SetWindowLong(IntPtr hwnd, int nIndex, Int32 dwNewLong);
[DllImport("user32.dll")]
public static extern bool SetLayeredWindowAttributes(IntPtr hwnd, Int32 crKey, int bAlpha, uint dwFlags);
public const int GWL_EXSTYLE = -20;
public const int LWA_COLORKEY = 0x00000001;
public const int WS_EX_LAYERED = 0x00080000;
[StructLayout(LayoutKind.Sequential)]
struct COLORREF
{
public byte R;
public byte G;
public byte B;
}
public CaptionButton()
{
InitializeComponent();
}
~CaptionButton()
{
}
protected override void WndProc(ref Message m)
{
// Debug Only *Allows us to step right into buttonhook starting *
if (Program.DEBUG_ONLY_SETTING_STARTBUTTONHOOK &&
!Program.DEBUG_ONLY_SETTING_STARTBUTTONHOOK_IS_STARTED)
{
Log.Info(string.Format("{0}() - * Debug Only Option * Starting ButtonHook", MethodBase.GetCurrentMethod().Name));
BHInteracter.StartButtonHookDLLEntryW();
Program.DEBUG_ONLY_SETTING_STARTBUTTONHOOK_IS_STARTED = true;
}
if (m.Msg == BHInteracter.WM_CAPTIONBUTTON_START)
{
Log.Info(string.Format("{0}() - Received CAPTIONBUTTON_START Message", MethodBase.GetCurrentMethod().Name));
BHInteracter.StartButtonHookDLLEntryW();
}
else if (m.Msg == BHInteracter.WM_CAPTIONBUTTON_STOP)
{
Log.Info(string.Format("{0}() - Received CAPTIONBUTTON_STOP Message", MethodBase.GetCurrentMethod().Name));
BHInteracter.StopButtonHookDLLEntryW();
}
// force opacity at all times
if (Opacity == 1.0)
Opacity = 0.0;
// force minimized at all times
if (WindowState != FormWindowState.Minimized)
WindowState = FormWindowState.Minimized;
// force Not to be seen in taskbar
if (ShowInTaskbar == true)
ShowInTaskbar = false;
base.WndProc(ref m);
}
void CaptionButton_Shown(object sender, System.EventArgs e)
{
Hide();
}
private void CaptionButton_HandleCreated(object sender, EventArgs e)
{
IntPtr hWnd = this.Handle;
SetWindowLong(hWnd, GWL_EXSTYLE, GetWindowLong(hWnd, GWL_EXSTYLE) | WS_EX_LAYERED);
SetLayeredWindowAttributes(hWnd, 0x00000000, 0, LWA_COLORKEY);
}
void CaptionButton_Load(object sender, System.EventArgs e)
{
Log.Info(string.Format("{0}() - CaptionButton Load Called! - passing out hWnd Handle {1}", MethodBase.GetCurrentMethod().Name,Handle.ToInt32()));
TemporaryVal.SetValI(Handle.ToInt32());
}
}
}

View File

@@ -0,0 +1,115 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>9.0.30729</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{3854981D-5F6B-4AC5-A3F9-5C3761838821}</ProjectGuid>
<OutputType>WinExe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Foo.Hooks.CaptionButton</RootNamespace>
<AssemblyName>CaptionButton</AssemblyName>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<SccProjectName>
</SccProjectName>
<SccLocalPath>
</SccLocalPath>
<SccAuxPath>
</SccAuxPath>
<SccProvider>
</SccProvider>
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>MyKeyFile.SNK</AssemblyOriginatorKeyFile>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>..\..\Target\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>..\..\Target\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="log4net, Version=1.2.10.0, Culture=neutral, PublicKeyToken=1b44e1d426115821, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\Components\log4net.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Xml.Linq">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Data.DataSetExtensions">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Data" />
<Reference Include="System.Deployment" />
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="CaptionButton.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="CaptionButton.Designer.cs">
<DependentUpon>CaptionButton.cs</DependentUpon>
</Compile>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<EmbeddedResource Include="CaptionButton.resx">
<DependentUpon>CaptionButton.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
<SubType>Designer</SubType>
</EmbeddedResource>
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
<DesignTime>True</DesignTime>
</Compile>
<None Include="MyKeyFile.SNK" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\Platform\Platform.csproj">
<Project>{F6929AFC-BF61-43A0-BABD-F807B65FFFA1}</Project>
<Name>Platform</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
<PropertyGroup>
<PostBuildEvent>
</PostBuildEvent>
</PropertyGroup>
</Project>

View File

@@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

Binary file not shown.

View File

@@ -0,0 +1,49 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
// Ooganizer Namespaces
using Foo.Platform;
using Foo.Platform.Interacters;
namespace Foo.Hooks.CaptionButton
{
static class Program
{
static string DEBUG_ONLY_SETTING_STARTBUTTONHOOK_CMD_STRING = "/StartButtonHook";
static internal bool DEBUG_ONLY_SETTING_STARTBUTTONHOOK = false;
static internal bool DEBUG_ONLY_SETTING_STARTBUTTONHOOK_IS_STARTED = false;
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
////
// We want to make sure that we are getting the correct command line params
// otherwise we won't allow this .exe to start
////
bool bStartButtonHook = false;
string[] args = Environment.GetCommandLineArgs();
foreach (string arg in args)
{
if(!bStartButtonHook)
bStartButtonHook = (arg == BHInteracter.CAPTIONBUTTON_CMDLINE);
if(!DEBUG_ONLY_SETTING_STARTBUTTONHOOK)
DEBUG_ONLY_SETTING_STARTBUTTONHOOK = (arg == DEBUG_ONLY_SETTING_STARTBUTTONHOOK_CMD_STRING);
}
// Should only start if this exe is called through Platform's BHInteracter
if (bStartButtonHook)
{
Application.Run(new CaptionButton());
}
}
}
}

View File

@@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("OogyCaptionButton")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("OogyCaptionButton")]
[assembly: AssemblyCopyright("Copyright © 2009")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("3696fc3e-e32a-4a2a-bff3-bd99ce83090f")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View File

@@ -0,0 +1,63 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:2.0.50727.4200
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace Foo.Hooks.CaptionButton.Properties {
using System;
/// <summary>
/// A strongly-typed resource class, for looking up localized strings, etc.
/// </summary>
// This class was auto-generated by the StronglyTypedResourceBuilder
// class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "2.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources {
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources() {
}
/// <summary>
/// Returns the cached ResourceManager instance used by this class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager {
get {
if (object.ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Foo.Hooks.CaptionButton.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// Overrides the current thread's CurrentUICulture property for all
/// resource lookups using this strongly typed resource class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture {
get {
return resourceCulture;
}
set {
resourceCulture = value;
}
}
}
}

View File

@@ -0,0 +1,117 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@@ -0,0 +1,26 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:2.0.50727.4200
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace Foo.Hooks.CaptionButton.Properties {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "9.0.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
public static Settings Default {
get {
return defaultInstance;
}
}
}
}

View File

@@ -0,0 +1,7 @@
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)">
<Profiles>
<Profile Name="(Default)" />
</Profiles>
<Settings />
</SettingsFile>