Skip to content

Commit

Permalink
Merge pull request #3 from mrfearless/master
Browse files Browse the repository at this point in the history
Update to NewProcessWatcher
  • Loading branch information
therealdreg authored Apr 4, 2017
2 parents 0cd5837 + f409b07 commit 9149e4d
Show file tree
Hide file tree
Showing 7 changed files with 92 additions and 5 deletions.
69 changes: 68 additions & 1 deletion NewProcessWatcher/NewProcessWatcher/NewProcessWatcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,44 @@ SOFTWARE.
#include "NewProcessWatcher.h"

#ifdef _WIN64
#error "This program cant works fine compiled in x64 mode. use only x32 version"
#error "This program does not support being compiled in x64 mode. Compile for the x32 version only."
#endif


// Definition for undocumented function in kernel32:SetConsoleIcon
typedef void (WINAPI *pSetConsoleIcon)(HICON);
pSetConsoleIcon ProcSetConsoleIcon = NULL;

// Constants for resources used for eye blink
CONST INT ICO_EYEOPEN = 102;
CONST INT ICO_EYEHALF = 103;
CONST INT ICO_EYECLOSED = 104;

// Handles for icons for eye blink
HICON hIcoEyeOpen;
HICON hIcoEyeHalf;
HICON hIcoEyeClosed;

// Used to blink the eye icon
VOID CALLBACK NewProcessWatcherTimerProc(PVOID lpParam, BOOLEAN TimerOrWaitFired)
{

DWORD dwBlinkDuration = 100;
ProcSetConsoleIcon(hIcoEyeOpen);
SleepEx(dwBlinkDuration, FALSE);
ProcSetConsoleIcon(hIcoEyeHalf);
SleepEx(dwBlinkDuration, FALSE);
ProcSetConsoleIcon(hIcoEyeClosed);
SleepEx(dwBlinkDuration, FALSE);
ProcSetConsoleIcon(hIcoEyeClosed);
SleepEx(dwBlinkDuration, FALSE);
ProcSetConsoleIcon(hIcoEyeHalf);
SleepEx(dwBlinkDuration, FALSE);
ProcSetConsoleIcon(hIcoEyeOpen);
return;
}


/*
TODO:
Refactorize
Expand All @@ -45,6 +80,38 @@ Consistent Variable Names

int main(int argc, char** argv)
{

HMODULE hModKernel32;
HINSTANCE hMod;
HANDLE hTimer = NULL;
HANDLE hQueue = NULL;
BOOL bSuccess;

// Get SetConsoleIcon procedure
hModKernel32 = GetModuleHandle(TEXT("Kernel32.dll"));
ProcSetConsoleIcon = (pSetConsoleIcon)GetProcAddress(hModKernel32, "SetConsoleIcon");

// If SetConsoleIcon is available we use it
if (ProcSetConsoleIcon != NULL)
{

// Get module handle and load icons for blinking eye
hMod = GetModuleHandle(NULL);
hIcoEyeOpen = LoadIcon(hMod, MAKEINTRESOURCE(ICO_EYEOPEN));
hIcoEyeHalf = LoadIcon(hMod, MAKEINTRESOURCE(ICO_EYEHALF));
hIcoEyeClosed = LoadIcon(hMod, MAKEINTRESOURCE(ICO_EYECLOSED));

// Set initial icon
ProcSetConsoleIcon(hIcoEyeOpen);

hQueue = CreateTimerQueue();
if (hQueue != NULL)
{
// Create timer to fire every 5 seconds for eye to blink
bSuccess = CreateTimerQueueTimer(&hTimer, hQueue, (WAITORTIMERCALLBACK) NewProcessWatcherTimerProc, 0, 5000, 5000, 0);
}
}

puts("\n"
"DbgChild - New Process Watcher\n"
"-\n"
Expand Down
Binary file modified NewProcessWatcher/NewProcessWatcher/NewProcessWatcher.rc
Binary file not shown.
14 changes: 10 additions & 4 deletions NewProcessWatcher/NewProcessWatcher/NewProcessWatcher.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
<CodeAnalysisRuleSet>C:\Program Files (x86)\Microsoft Visual Studio 14.0\Team Tools\Static Analysis Tools\Rule Sets\NativeRecommendedRules.ruleset</CodeAnalysisRuleSet>
<RunCodeAnalysis>true</RunCodeAnalysis>
<RunCodeAnalysis>false</RunCodeAnalysis>
<IncludePath>$(SolutionDir)..\common\includes\;$(VC_IncludePath);$(WindowsSDK_IncludePath);</IncludePath>
<LibraryPath>$(SolutionDir)..\common\libs\;$(VC_LibraryPath_x86);$(WindowsSDK_LibraryPath_x86);$(NETFXKitsDir)Lib\um\x86</LibraryPath>
<SourcePath>$(SolutionDir)..\common\sources\;$(VC_SourcePath);</SourcePath>
Expand All @@ -88,7 +88,7 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
<CodeAnalysisRuleSet>C:\Program Files (x86)\Microsoft Visual Studio 14.0\Team Tools\Static Analysis Tools\Rule Sets\NativeRecommendedRules.ruleset</CodeAnalysisRuleSet>
<RunCodeAnalysis>true</RunCodeAnalysis>
<RunCodeAnalysis>false</RunCodeAnalysis>
<IncludePath>$(SolutionDir)..\common\includes\;$(VC_IncludePath);$(WindowsSDK_IncludePath);</IncludePath>
<LibraryPath>$(SolutionDir)..\common\libs\;$(VC_LibraryPath_x86);$(WindowsSDK_LibraryPath_x86);$(NETFXKitsDir)Lib\um\x86</LibraryPath>
<SourcePath>$(SolutionDir)..\common\sources\;$(VC_SourcePath);</SourcePath>
Expand All @@ -109,7 +109,7 @@
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<EnablePREfast>true</EnablePREfast>
<EnablePREfast>false</EnablePREfast>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
Expand Down Expand Up @@ -143,7 +143,7 @@
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<EnablePREfast>true</EnablePREfast>
<EnablePREfast>false</EnablePREfast>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
Expand Down Expand Up @@ -176,6 +176,7 @@
<ItemGroup>
<ClInclude Include="..\..\common\includes\com_common.h" />
<ClInclude Include="NewProcessWatcher.h" />
<ClInclude Include="resource.h" />
<ClInclude Include="stdafx.h" />
<ClInclude Include="targetver.h" />
</ItemGroup>
Expand All @@ -192,6 +193,11 @@
<ItemGroup>
<ResourceCompile Include="NewProcessWatcher.rc" />
</ItemGroup>
<ItemGroup>
<Image Include="eye_close.ico" />
<Image Include="eye_half.ico" />
<Image Include="NewProcessWatcher.ico" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@
<ClInclude Include="..\..\common\includes\com_common.h">
<Filter>Header Files\common</Filter>
</ClInclude>
<ClInclude Include="resource.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="stdafx.cpp">
Expand All @@ -50,4 +53,15 @@
<Filter>Resource Files</Filter>
</ResourceCompile>
</ItemGroup>
<ItemGroup>
<Image Include="eye_half.ico">
<Filter>Resource Files</Filter>
</Image>
<Image Include="NewProcessWatcher.ico">
<Filter>Resource Files</Filter>
</Image>
<Image Include="eye_close.ico">
<Filter>Resource Files</Filter>
</Image>
</ItemGroup>
</Project>
Binary file added NewProcessWatcher/NewProcessWatcher/eye_close.ico
Binary file not shown.
Binary file added NewProcessWatcher/NewProcessWatcher/eye_half.ico
Binary file not shown.
Binary file modified NewProcessWatcher/NewProcessWatcher/resource.h
Binary file not shown.

0 comments on commit 9149e4d

Please sign in to comment.