Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
LuSlower authored Apr 13, 2024
1 parent adcadb8 commit 6fc4273
Show file tree
Hide file tree
Showing 11 changed files with 149 additions and 0 deletions.
Binary file added hook/bin/Release/hook.dll
Binary file not shown.
Binary file added hook/bin/Release/hook64.dll
Binary file not shown.
Binary file added hook/bin/Release/libhook.a
Binary file not shown.
4 changes: 4 additions & 0 deletions hook/bin/Release/libhook.def
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
EXPORTS
DllMain@12 @1
RemoveHook @2
SetHook @3
Binary file added hook/bin/Release/libhook64.a
Binary file not shown.
4 changes: 4 additions & 0 deletions hook/bin/Release/libhook64.def
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
EXPORTS
DllMain @1
RemoveHook @2
SetHook @3
37 changes: 37 additions & 0 deletions hook/hook.cbp
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>
15 changes: 15 additions & 0 deletions hook/hook.layout
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>
60 changes: 60 additions & 0 deletions hook/main.cpp
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);
}


29 changes: 29 additions & 0 deletions hook/main.h
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 added hook/obj/Release/main.o
Binary file not shown.

0 comments on commit 6fc4273

Please sign in to comment.