Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit adcadb8

Browse files
authoredApr 13, 2024
Add files via upload
1 parent 8dc17cb commit adcadb8

File tree

14 files changed

+279
-0
lines changed

14 files changed

+279
-0
lines changed
 

‎dwmbsc64/bin/Release/dwmbsc64.exe

10.5 KB
Binary file not shown.

‎dwmbsc64/dwmbsc.cbp

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
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="dwmbsc64" />
6+
<Option pch_mode="2" />
7+
<Option compiler="gcc" />
8+
<Build>
9+
<Target title="Release">
10+
<Option output="bin/Release/dwmbsc64" prefix_auto="1" extension_auto="1" />
11+
<Option object_output="obj/Release/" />
12+
<Option type="1" />
13+
<Option compiler="gcc" />
14+
<Compiler>
15+
<Add option="-O2" />
16+
</Compiler>
17+
<Linker>
18+
<Add option="-s" />
19+
</Linker>
20+
</Target>
21+
</Build>
22+
<Compiler>
23+
<Add option="-Wall" />
24+
</Compiler>
25+
<ExtraCommands>
26+
<Add after="upx --lzma $(TARGET_OUTPUT_FILE)" />
27+
</ExtraCommands>
28+
<Unit filename="dwmbsc64.cpp" />
29+
<Extensions>
30+
<lib_finder disable_auto="1" />
31+
</Extensions>
32+
</Project>
33+
</CodeBlocks_project_file>

‎dwmbsc64/dwmbsc.depend

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# depslib dependency file v1.0
2+
1712961391 source:e:\documentos\codeblocks\dwmbsc\dwmbsc.cpp
3+
<Windows.h>
4+
<dwmapi.h>
5+
6+
1712786937 e:\documentos\codeblocks\dwmbsc\res.h
7+
8+
1712801679 e:\documentos\codeblocks\dwmbsc\resource.h
9+
10+
1712961387 source:e:\documentos\codeblocks\dwmbsc\dwmbsc32.cpp
11+
<Windows.h>
12+
13+
1712988940 source:e:\documentos\codeblocks\dwmbsc64\dwmbsc64.cpp
14+
<Windows.h>
15+
<dwmapi.h>
16+

‎dwmbsc64/dwmbsc.layout

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
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="dwmbsc64.cpp" open="1" top="1" tabpos="1" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
6+
<Cursor>
7+
<Cursor1 position="396" topLine="3" />
8+
</Cursor>
9+
</File>
10+
</CodeBlocks_layout_file>
10.5 KB
Binary file not shown.

‎dwmbsc64/dwmbsc32/dwmbsc32.cbp

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
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="dwmbsc32" />
6+
<Option pch_mode="2" />
7+
<Option compiler="gcc" />
8+
<Build>
9+
<Target title="Release">
10+
<Option output="bin/Release/dwmbsc32" prefix_auto="1" extension_auto="1" />
11+
<Option object_output="obj/Release/" />
12+
<Option type="1" />
13+
<Option compiler="gcc" />
14+
<Compiler>
15+
<Add option="-O2" />
16+
</Compiler>
17+
<Linker>
18+
<Add option="-s" />
19+
</Linker>
20+
</Target>
21+
</Build>
22+
<Compiler>
23+
<Add option="-Wall" />
24+
</Compiler>
25+
<Linker>
26+
<Add library="dwmapi" />
27+
</Linker>
28+
<ExtraCommands>
29+
<Add after="upx --lzma $(TARGET_OUTPUT_FILE)" />
30+
</ExtraCommands>
31+
<Unit filename="dwmbsc32.cpp" />
32+
<Extensions />
33+
</Project>
34+
</CodeBlocks_project_file>

‎dwmbsc64/dwmbsc32/dwmbsc32.cpp

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
#pragma once
2+
#define WIN32_LEAN_AND_MEAN
3+
#define HK_ID 1
4+
#include <Windows.h>
5+
#include <dwmapi.h>
6+
7+
typedef void (*SetHookFunc)();
8+
typedef void (*RemoveHookFunc)();
9+
10+
BOOL CALLBACK PolWinProc(HWND hwnd, LPARAM lParam) {
11+
//politica de renderizado y transisiones
12+
DWMNCRENDERINGPOLICY NCRP = DWMNCRP_DISABLED;
13+
BOOL lpol = TRUE;
14+
DwmSetWindowAttribute(hwnd, DWMWA_NCRENDERING_POLICY, &NCRP, sizeof(NCRP));
15+
DwmSetWindowAttribute(hwnd, DWMWA_TRANSITIONS_FORCEDISABLED, &lpol, sizeof(lpol));
16+
return TRUE;
17+
}
18+
19+
BOOL CALLBACK dPolWinProc(HWND hwnd, LPARAM lParam) {
20+
//politica de renderizado y transisiones
21+
DWMNCRENDERINGPOLICY rNCRP = DWMNCRP_ENABLED;
22+
BOOL tpol = FALSE;
23+
DwmSetWindowAttribute(hwnd, DWMWA_NCRENDERING_POLICY, &rNCRP, sizeof(rNCRP));
24+
DwmSetWindowAttribute(hwnd, DWMWA_TRANSITIONS_FORCEDISABLED, &tpol, sizeof(tpol));
25+
return TRUE;
26+
}
27+
28+
29+
int main() {
30+
31+
HANDLE hMutex = CreateMutex(NULL, TRUE, "dwmbsc32");
32+
if (GetLastError() == ERROR_ALREADY_EXISTS)
33+
{
34+
//Ya hay una instancia
35+
CloseHandle(hMutex);
36+
MessageBox(0, "Ya hay una instancia de dwmbsc ejecutandose", "Error", MB_ICONERROR | MB_OK);
37+
ExitProcess(NULL);
38+
}
39+
40+
//ocultar consola
41+
FreeConsole();
42+
43+
// Enumerar todas las ventanas existentes y aplicar politicas
44+
EnumWindows(PolWinProc, NULL);
45+
46+
HINSTANCE hDll = LoadLibrary("hook.dll");
47+
if (hDll == NULL) {
48+
MessageBox(NULL, "Failed to load DLL 32", "Error", MB_OK | MB_ICONERROR);
49+
return 1;
50+
}
51+
52+
// Obtener puntero a para registrar el gancho de 32 bits
53+
SetHookFunc setHook = (SetHookFunc)GetProcAddress(hDll, "SetHook");
54+
RemoveHookFunc removeHook = (RemoveHookFunc)GetProcAddress(hDll, "RemoveHook");
55+
if (setHook == NULL || removeHook == NULL) {
56+
MessageBox(NULL, "Failed to get function pointers 32", "Error", MB_OK | MB_ICONERROR);
57+
FreeLibrary(hDll);
58+
return 1;
59+
}
60+
61+
//instalar el gancho
62+
setHook();
63+
64+
//informacion del proceso resultante
65+
PROCESS_INFORMATION pi = {0};
66+
STARTUPINFO si = {0};
67+
si.cb = sizeof(si);
68+
69+
//crear subproceso de dwmbsc64
70+
if (!CreateProcess(
71+
"dwmbsc64.exe", // Ruta al ejecutable
72+
NULL, // Argumentos de la línea de comandos
73+
NULL, // Atributos del proceso (predeterminado)
74+
NULL, // Atributos del hilo (predeterminado)
75+
FALSE, // Herencia de manijas (falso para no heredar)
76+
CREATE_NO_WINDOW, // Crear sin ventana de consola
77+
NULL, // Medio ambiente del proceso (predeterminado)
78+
NULL, // Directorio base (predeterminado)
79+
&si, // Información de inicio del proceso
80+
&pi)) { // Información del proceso resultante
81+
return 1;
82+
}
83+
84+
//registrar HotKey
85+
RegisterHotKey(NULL, HK_ID, MOD_CONTROL | MOD_SHIFT, VK_F1);
86+
87+
MSG msg;
88+
while (GetMessage(&msg, NULL, 0, 0)) {
89+
switch (msg.message)
90+
case WM_HOTKEY:
91+
{
92+
if(msg.wParam == HK_ID) {
93+
94+
// Enumerar todas las ventanas existentes y restaurar politicas
95+
EnumWindows(dPolWinProc, NULL);
96+
97+
//remover gancho
98+
removeHook();
99+
100+
//liberar la DLL
101+
FreeLibrary(hDll);
102+
103+
// Desregistra el atajo de teclado al salir
104+
UnregisterHotKey(NULL, HK_ID);
105+
106+
// matar proceso
107+
TerminateProcess(pi.hProcess, 0);
108+
109+
// Cerrar los manejadores
110+
CloseHandle(pi.hProcess);
111+
CloseHandle(pi.hThread);
112+
return 0;
113+
114+
}
115+
break;
116+
} //end switch
117+
TranslateMessage(&msg);
118+
DispatchMessage(&msg);
119+
}
120+
121+
return 0;
122+
}

‎dwmbsc64/dwmbsc32/dwmbsc32.depend

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# depslib dependency file v1.0
2+
1712964783 source:e:\documentos\codeblocks\dwmbsc\dwmbsc32\dwmbsc32.cpp
3+
<Windows.h>
4+
5+
1712989938 source:e:\documentos\codeblocks\dwmbsc64\dwmbsc32\dwmbsc32.cpp
6+
<Windows.h>
7+
<dwmapi.h>
8+

‎dwmbsc64/dwmbsc32/dwmbsc32.layout

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
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="dwmbsc32.cpp" open="1" top="0" tabpos="3" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
6+
<Cursor>
7+
<Cursor1 position="228" topLine="0" />
8+
</Cursor>
9+
</File>
10+
</CodeBlocks_layout_file>
14.4 KB
Binary file not shown.

‎dwmbsc64/dwmbsc64.cpp

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
#pragma once
2+
#define WIN32_LEAN_AND_MEAN
3+
#include <Windows.h>
4+
5+
typedef void (*SetHookFunc)();
6+
typedef void (*RemoveHookFunc)();
7+
8+
int main() {
9+
10+
// ocultar shell cmd
11+
FreeConsole();
12+
13+
// Cargar la DLL
14+
HINSTANCE hDll = LoadLibrary("hook64.dll");
15+
if (hDll == NULL) {
16+
MessageBox(NULL, "Failed to load DLL 64", "Error", MB_OK | MB_ICONERROR);
17+
return 1;
18+
}
19+
20+
// Obtener puntero a para registrar el gancho de 64 bits
21+
SetHookFunc setHook = (SetHookFunc)GetProcAddress(hDll, "SetHook");
22+
RemoveHookFunc removeHook = (RemoveHookFunc)GetProcAddress(hDll, "RemoveHook");
23+
if (setHook == NULL || removeHook == NULL) {
24+
MessageBox(NULL, "Failed to get function pointers 64", "Error", MB_OK | MB_ICONERROR);
25+
FreeLibrary(hDll);
26+
return 1;
27+
}
28+
29+
// Instalar el gancho
30+
setHook();
31+
32+
// Mantener el programa en ejecución
33+
MSG msg;
34+
while (GetMessage(&msg, NULL, 0, 0)) {
35+
TranslateMessage(&msg);
36+
DispatchMessage(&msg);
37+
}
38+
39+
//remover gancho
40+
removeHook();
41+
42+
//liberar la DLL
43+
FreeLibrary(hDll);
44+
45+
return 0;
46+
}

‎dwmbsc64/obj/Release/dwmbsc.o

13.9 KB
Binary file not shown.

‎dwmbsc64/obj/Release/dwmbsc32.o

7.34 KB
Binary file not shown.

‎dwmbsc64/obj/Release/dwmbsc64.o

7.41 KB
Binary file not shown.

0 commit comments

Comments
 (0)
Please sign in to comment.