Skip to content

Commit

Permalink
Disabled hooks for discord.exe and slack.exe processes.
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexanderPro committed Oct 16, 2018
1 parent f2d2b2d commit ced5818
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions SmartSystemMenuHook/dllmain.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
// dllmain.cpp : Defines the entry point for the DLL application.
#include "stdafx.h"
#include <string>
#include <vector>
#include <algorithm>

extern HINSTANCE g_appInstance;

bool array_contains(const std::string &value, const std::vector<std::string> &array)
{
return std::find(array.begin(), array.end(), value) != array.end();
}

BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved)
{
switch (ul_reason_for_call)
Expand All @@ -12,6 +20,20 @@ BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserv
{
g_appInstance = hModule;
}
WCHAR path[MAX_PATH];
if (GetModuleFileName(NULL, path, sizeof(path)) != 0)
{
std::vector<std::string> excludedProcessNames{ "discord.exe", "slack.exe" };
std::wstring tempPath(&path[0]);
std::string processPath(tempPath.begin(), tempPath.end());
std::size_t index = processPath.find_last_of("/\\");
std::string processName = processPath.substr(index + 1);
std::transform(processName.begin(), processName.end(), processName.begin(), ::tolower);
if (array_contains(processName, excludedProcessNames))
{
return FALSE;
}
}
break;

case DLL_THREAD_ATTACH:
Expand Down

0 comments on commit ced5818

Please sign in to comment.