Skip to content

Commit 6fc4273

Browse files
authored
Add files via upload
1 parent adcadb8 commit 6fc4273

File tree

11 files changed

+149
-0
lines changed

11 files changed

+149
-0
lines changed

hook/bin/Release/hook.dll

9.5 KB
Binary file not shown.

hook/bin/Release/hook64.dll

9.5 KB
Binary file not shown.

hook/bin/Release/libhook.a

9.58 KB
Binary file not shown.

hook/bin/Release/libhook.def

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
EXPORTS
2+
DllMain@12 @1
3+
RemoveHook @2
4+
SetHook @3

hook/bin/Release/libhook64.a

9.58 KB
Binary file not shown.

hook/bin/Release/libhook64.def

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
EXPORTS
2+
DllMain @1
3+
RemoveHook @2
4+
SetHook @3

hook/hook.cbp

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
2+
<CodeBlocks_project_file>
3+
<FileVersion major="1" minor="6" />
4+
<Project>
5+
<Option title="hook" />
6+
<Option pch_mode="2" />
7+
<Option compiler="gcc" />
8+
<Build>
9+
<Target title="Release">
10+
<Option output="bin/Release/hook" prefix_auto="1" extension_auto="1" />
11+
<Option working_dir="bin/Release" />
12+
<Option object_output="obj/Release/" />
13+
<Option type="3" />
14+
<Option compiler="gcc" />
15+
<Option createDefFile="1" />
16+
<Compiler>
17+
<Add option="-O2" />
18+
<Add option="-Wall" />
19+
<Add option="-DBUILD_DLL" />
20+
</Compiler>
21+
<Linker>
22+
<Add option="-s" />
23+
<Add library="user32" />
24+
<Add library="dwmapi" />
25+
</Linker>
26+
</Target>
27+
</Build>
28+
<ExtraCommands>
29+
<Add after="upx --lzma $(TARGET_OUTPUT_FILE)" />
30+
</ExtraCommands>
31+
<Unit filename="main.cpp" />
32+
<Unit filename="main.h" />
33+
<Extensions>
34+
<lib_finder disable_auto="1" />
35+
</Extensions>
36+
</Project>
37+
</CodeBlocks_project_file>

hook/hook.layout

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
2+
<CodeBlocks_layout_file>
3+
<FileVersion major="1" minor="0" />
4+
<ActiveTarget name="Release" />
5+
<File name="main.h" open="1" top="0" tabpos="2" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
6+
<Cursor>
7+
<Cursor1 position="281" topLine="0" />
8+
</Cursor>
9+
</File>
10+
<File name="main.cpp" open="1" top="1" tabpos="1" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
11+
<Cursor>
12+
<Cursor1 position="399" topLine="0" />
13+
</Cursor>
14+
</File>
15+
</CodeBlocks_layout_file>

hook/main.cpp

+60
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
#include <dwmapi.h>
2+
#include "main.h"
3+
// Declarar la sección compartida
4+
HHOOK hhk = NULL;
5+
HINSTANCE hInst = NULL;
6+
LRESULT CALLBACK GetWinProc(int cCode, WPARAM wParam, LPARAM lParam) {
7+
if (cCode == HSHELL_WINDOWCREATED) {
8+
HWND hwnd = (HWND)wParam;
9+
//politica de renderizado y transisiones
10+
DWMNCRENDERINGPOLICY NCRP = DWMNCRP_DISABLED;
11+
BOOL lpol = TRUE;
12+
DwmSetWindowAttribute(hwnd, DWMWA_NCRENDERING_POLICY, &NCRP, sizeof(NCRP));
13+
DwmSetWindowAttribute(hwnd, DWMWA_TRANSITIONS_FORCEDISABLED, &lpol, sizeof(lpol));
14+
}
15+
// Llama al siguiente gancho en la cadena
16+
return CallNextHookEx(hhk, cCode, wParam, lParam);
17+
}
18+
19+
20+
21+
extern "C" DLL_EXPORT BOOL APIENTRY DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
22+
{
23+
switch (fdwReason)
24+
{
25+
case DLL_PROCESS_ATTACH:
26+
hInst = (HINSTANCE) hinstDLL;
27+
// attach from process
28+
break;
29+
30+
case DLL_PROCESS_DETACH:
31+
// detach from process
32+
break;
33+
34+
case DLL_THREAD_ATTACH:
35+
// attach to thread
36+
break;
37+
38+
case DLL_THREAD_DETACH:
39+
// detach from thread
40+
break;
41+
}
42+
return TRUE; // succesful
43+
}
44+
45+
void SetHook()
46+
{
47+
hhk = SetWindowsHookEx(WH_SHELL, (HOOKPROC)GetWinProc, hInst, 0);
48+
// Verificar si se estableció correctamente
49+
if (hhk == NULL)
50+
{
51+
MessageBox(0, "Failed to implement hook", "Failed", MB_OK | MB_ICONERROR);
52+
}
53+
}
54+
55+
void RemoveHook()
56+
{
57+
UnhookWindowsHookEx(hhk);
58+
}
59+
60+

hook/main.h

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#ifndef __MAIN_H__
2+
#define __MAIN_H__
3+
4+
#include <windows.h>
5+
6+
/* To use this exported function of dll, include this header
7+
* in your project.
8+
*/
9+
10+
#ifdef BUILD_DLL
11+
#define DLL_EXPORT __declspec(dllexport)
12+
#else
13+
#define DLL_EXPORT __declspec(dllimport)
14+
#endif
15+
16+
17+
#ifdef __cplusplus
18+
extern "C"
19+
{
20+
#endif
21+
22+
void DLL_EXPORT SetHook();
23+
void DLL_EXPORT RemoveHook();
24+
25+
#ifdef __cplusplus
26+
}
27+
#endif
28+
29+
#endif // __MAIN_H__

hook/obj/Release/main.o

9.52 KB
Binary file not shown.

0 commit comments

Comments
 (0)