-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
149 additions
and
0 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
EXPORTS | ||
DllMain@12 @1 | ||
RemoveHook @2 | ||
SetHook @3 |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
EXPORTS | ||
DllMain @1 | ||
RemoveHook @2 | ||
SetHook @3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?> | ||
<CodeBlocks_project_file> | ||
<FileVersion major="1" minor="6" /> | ||
<Project> | ||
<Option title="hook" /> | ||
<Option pch_mode="2" /> | ||
<Option compiler="gcc" /> | ||
<Build> | ||
<Target title="Release"> | ||
<Option output="bin/Release/hook" prefix_auto="1" extension_auto="1" /> | ||
<Option working_dir="bin/Release" /> | ||
<Option object_output="obj/Release/" /> | ||
<Option type="3" /> | ||
<Option compiler="gcc" /> | ||
<Option createDefFile="1" /> | ||
<Compiler> | ||
<Add option="-O2" /> | ||
<Add option="-Wall" /> | ||
<Add option="-DBUILD_DLL" /> | ||
</Compiler> | ||
<Linker> | ||
<Add option="-s" /> | ||
<Add library="user32" /> | ||
<Add library="dwmapi" /> | ||
</Linker> | ||
</Target> | ||
</Build> | ||
<ExtraCommands> | ||
<Add after="upx --lzma $(TARGET_OUTPUT_FILE)" /> | ||
</ExtraCommands> | ||
<Unit filename="main.cpp" /> | ||
<Unit filename="main.h" /> | ||
<Extensions> | ||
<lib_finder disable_auto="1" /> | ||
</Extensions> | ||
</Project> | ||
</CodeBlocks_project_file> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?> | ||
<CodeBlocks_layout_file> | ||
<FileVersion major="1" minor="0" /> | ||
<ActiveTarget name="Release" /> | ||
<File name="main.h" open="1" top="0" tabpos="2" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0"> | ||
<Cursor> | ||
<Cursor1 position="281" topLine="0" /> | ||
</Cursor> | ||
</File> | ||
<File name="main.cpp" open="1" top="1" tabpos="1" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0"> | ||
<Cursor> | ||
<Cursor1 position="399" topLine="0" /> | ||
</Cursor> | ||
</File> | ||
</CodeBlocks_layout_file> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
#include <dwmapi.h> | ||
#include "main.h" | ||
// Declarar la sección compartida | ||
HHOOK hhk = NULL; | ||
HINSTANCE hInst = NULL; | ||
LRESULT CALLBACK GetWinProc(int cCode, WPARAM wParam, LPARAM lParam) { | ||
if (cCode == HSHELL_WINDOWCREATED) { | ||
HWND hwnd = (HWND)wParam; | ||
//politica de renderizado y transisiones | ||
DWMNCRENDERINGPOLICY NCRP = DWMNCRP_DISABLED; | ||
BOOL lpol = TRUE; | ||
DwmSetWindowAttribute(hwnd, DWMWA_NCRENDERING_POLICY, &NCRP, sizeof(NCRP)); | ||
DwmSetWindowAttribute(hwnd, DWMWA_TRANSITIONS_FORCEDISABLED, &lpol, sizeof(lpol)); | ||
} | ||
// Llama al siguiente gancho en la cadena | ||
return CallNextHookEx(hhk, cCode, wParam, lParam); | ||
} | ||
|
||
|
||
|
||
extern "C" DLL_EXPORT BOOL APIENTRY DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) | ||
{ | ||
switch (fdwReason) | ||
{ | ||
case DLL_PROCESS_ATTACH: | ||
hInst = (HINSTANCE) hinstDLL; | ||
// attach from process | ||
break; | ||
|
||
case DLL_PROCESS_DETACH: | ||
// detach from process | ||
break; | ||
|
||
case DLL_THREAD_ATTACH: | ||
// attach to thread | ||
break; | ||
|
||
case DLL_THREAD_DETACH: | ||
// detach from thread | ||
break; | ||
} | ||
return TRUE; // succesful | ||
} | ||
|
||
void SetHook() | ||
{ | ||
hhk = SetWindowsHookEx(WH_SHELL, (HOOKPROC)GetWinProc, hInst, 0); | ||
// Verificar si se estableció correctamente | ||
if (hhk == NULL) | ||
{ | ||
MessageBox(0, "Failed to implement hook", "Failed", MB_OK | MB_ICONERROR); | ||
} | ||
} | ||
|
||
void RemoveHook() | ||
{ | ||
UnhookWindowsHookEx(hhk); | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#ifndef __MAIN_H__ | ||
#define __MAIN_H__ | ||
|
||
#include <windows.h> | ||
|
||
/* To use this exported function of dll, include this header | ||
* in your project. | ||
*/ | ||
|
||
#ifdef BUILD_DLL | ||
#define DLL_EXPORT __declspec(dllexport) | ||
#else | ||
#define DLL_EXPORT __declspec(dllimport) | ||
#endif | ||
|
||
|
||
#ifdef __cplusplus | ||
extern "C" | ||
{ | ||
#endif | ||
|
||
void DLL_EXPORT SetHook(); | ||
void DLL_EXPORT RemoveHook(); | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif | ||
|
||
#endif // __MAIN_H__ |
Binary file not shown.