Skip to content

Commit

Permalink
Added a command line flag "startDisabled" that can be used to disable
Browse files Browse the repository at this point in the history
the key suppression hook on startup.

#1
  • Loading branch information
clangen committed Oct 29, 2017
1 parent 17fb874 commit e3f86b3
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 13 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
**/debug
**/release
**/bin
**/*.aps
.vs
ipch
*.VC.db
*.VC.opendb
*.VC.opendb
8 changes: 4 additions & 4 deletions WinKill/WinKill.vcxproj
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
Expand All @@ -14,18 +14,18 @@
<ProjectGuid>{092BD9BF-9E3B-4374-AA38-EA19C9A09DD4}</ProjectGuid>
<RootNamespace>WinKill</RootNamespace>
<Keyword>MFCProj</Keyword>
<WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion>
<WindowsTargetPlatformVersion>10.0.16299.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<PlatformToolset>v140</PlatformToolset>
<PlatformToolset>v141_xp</PlatformToolset>
<UseOfMfc>Dynamic</UseOfMfc>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<PlatformToolset>v140</PlatformToolset>
<PlatformToolset>v141_xp</PlatformToolset>
<UseOfMfc>Dynamic</UseOfMfc>
<CharacterSet>Unicode</CharacterSet>
<WholeProgramOptimization>false</WholeProgramOptimization>
Expand Down
6 changes: 5 additions & 1 deletion WinKill/WinKill.vcxproj.user
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LocalDebuggerCommandArguments>
</LocalDebuggerCommandArguments>
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
</PropertyGroup>
</Project>
26 changes: 23 additions & 3 deletions WinKill/WinKillDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,31 @@
#define MENU_ITEM_EXIT 1979
#define MENU_ITEM_TOGGLE_CAPTION L"Toggle"
#define MENU_ITEM_EXIT_CAPTION L"Exit"
#define TRAY_ICON_TIP L"WinKill v0.2"
#define TRAY_ICON_TIP L"WinKill v0.3"

BEGIN_MESSAGE_MAP(WinKillDialog, CDialog)
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_WM_WINDOWPOSCHANGING()
END_MESSAGE_MAP()

class MyCommandLineInfo : public CCommandLineInfo {
public:
MyCommandLineInfo() : CCommandLineInfo() {
startDisabled = false;
}

virtual void ParseParam(const TCHAR* param, BOOL flag, BOOL last) {
if (param) {
if (CString(param) == L"startDisabled") {
startDisabled = !!flag;
}
}
}

bool startDisabled;
};

WinKillDialog::WinKillDialog(CWnd* parent)
: CDialog(WinKillDialog::IDD, parent)
, mActiveIcon(AfxGetApp()->LoadIcon(IDR_MAINFRAME))
Expand All @@ -42,7 +59,7 @@ void WinKillDialog::ShowTrayIcon() {
mTrayIcon.uID = 0;
mTrayIcon.uFlags = NIF_ICON | NIF_MESSAGE | NIF_TIP;
mTrayIcon.uCallbackMessage = WM_MYTRAYICON;
mTrayIcon.hIcon = mKilledIcon;
mTrayIcon.hIcon = mHooked ? mKilledIcon : mActiveIcon;
::wcscpy_s(mTrayIcon.szTip, 255, TRAY_ICON_TIP);

mTrayIconVisible = (Shell_NotifyIcon(NIM_ADD, &mTrayIcon) != 0);
Expand Down Expand Up @@ -96,7 +113,10 @@ BOOL WinKillDialog::OnInitDialog() {
menuItem.fType = MFT_STRING;
mTrayMenu.InsertMenuItem(MENU_ITEM_EXIT, &menuItem);

StartHook();
MyCommandLineInfo commandLine;
AfxGetApp()->ParseCommandLine(commandLine);
commandLine.startDisabled ? StopHook() : StartHook();

ShowTrayIcon();

return TRUE;
Expand Down
8 changes: 4 additions & 4 deletions WinKillHook/WinKillHook.vcxproj
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
Expand All @@ -13,18 +13,18 @@
<PropertyGroup Label="Globals">
<ProjectGuid>{D5D6353E-2C3A-4B54-880C-B2FAC3FDC739}</ProjectGuid>
<RootNamespace>WinKillHook</RootNamespace>
<WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion>
<WindowsTargetPlatformVersion>10.0.16299.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<PlatformToolset>v140</PlatformToolset>
<PlatformToolset>v141_xp</PlatformToolset>
<UseOfMfc>false</UseOfMfc>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<PlatformToolset>v140</PlatformToolset>
<PlatformToolset>v141_xp</PlatformToolset>
<UseOfMfc>false</UseOfMfc>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
Expand Down

0 comments on commit e3f86b3

Please sign in to comment.