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 8dc17cb commit adcadb8
Show file tree
Hide file tree
Showing 14 changed files with 279 additions and 0 deletions.
Binary file added dwmbsc64/bin/Release/dwmbsc64.exe
Binary file not shown.
33 changes: 33 additions & 0 deletions dwmbsc64/dwmbsc.cbp
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<CodeBlocks_project_file>
<FileVersion major="1" minor="6" />
<Project>
<Option title="dwmbsc64" />
<Option pch_mode="2" />
<Option compiler="gcc" />
<Build>
<Target title="Release">
<Option output="bin/Release/dwmbsc64" prefix_auto="1" extension_auto="1" />
<Option object_output="obj/Release/" />
<Option type="1" />
<Option compiler="gcc" />
<Compiler>
<Add option="-O2" />
</Compiler>
<Linker>
<Add option="-s" />
</Linker>
</Target>
</Build>
<Compiler>
<Add option="-Wall" />
</Compiler>
<ExtraCommands>
<Add after="upx --lzma $(TARGET_OUTPUT_FILE)" />
</ExtraCommands>
<Unit filename="dwmbsc64.cpp" />
<Extensions>
<lib_finder disable_auto="1" />
</Extensions>
</Project>
</CodeBlocks_project_file>
16 changes: 16 additions & 0 deletions dwmbsc64/dwmbsc.depend
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# depslib dependency file v1.0
1712961391 source:e:\documentos\codeblocks\dwmbsc\dwmbsc.cpp
<Windows.h>
<dwmapi.h>

1712786937 e:\documentos\codeblocks\dwmbsc\res.h

1712801679 e:\documentos\codeblocks\dwmbsc\resource.h

1712961387 source:e:\documentos\codeblocks\dwmbsc\dwmbsc32.cpp
<Windows.h>

1712988940 source:e:\documentos\codeblocks\dwmbsc64\dwmbsc64.cpp
<Windows.h>
<dwmapi.h>

10 changes: 10 additions & 0 deletions dwmbsc64/dwmbsc.layout
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<CodeBlocks_layout_file>
<FileVersion major="1" minor="0" />
<ActiveTarget name="Release" />
<File name="dwmbsc64.cpp" open="1" top="1" tabpos="1" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="396" topLine="3" />
</Cursor>
</File>
</CodeBlocks_layout_file>
Binary file added dwmbsc64/dwmbsc32/bin/Release/dwmbsc32.exe
Binary file not shown.
34 changes: 34 additions & 0 deletions dwmbsc64/dwmbsc32/dwmbsc32.cbp
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<CodeBlocks_project_file>
<FileVersion major="1" minor="6" />
<Project>
<Option title="dwmbsc32" />
<Option pch_mode="2" />
<Option compiler="gcc" />
<Build>
<Target title="Release">
<Option output="bin/Release/dwmbsc32" prefix_auto="1" extension_auto="1" />
<Option object_output="obj/Release/" />
<Option type="1" />
<Option compiler="gcc" />
<Compiler>
<Add option="-O2" />
</Compiler>
<Linker>
<Add option="-s" />
</Linker>
</Target>
</Build>
<Compiler>
<Add option="-Wall" />
</Compiler>
<Linker>
<Add library="dwmapi" />
</Linker>
<ExtraCommands>
<Add after="upx --lzma $(TARGET_OUTPUT_FILE)" />
</ExtraCommands>
<Unit filename="dwmbsc32.cpp" />
<Extensions />
</Project>
</CodeBlocks_project_file>
122 changes: 122 additions & 0 deletions dwmbsc64/dwmbsc32/dwmbsc32.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
#pragma once
#define WIN32_LEAN_AND_MEAN
#define HK_ID 1
#include <Windows.h>
#include <dwmapi.h>

typedef void (*SetHookFunc)();
typedef void (*RemoveHookFunc)();

BOOL CALLBACK PolWinProc(HWND hwnd, LPARAM lParam) {
//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));
return TRUE;
}

BOOL CALLBACK dPolWinProc(HWND hwnd, LPARAM lParam) {
//politica de renderizado y transisiones
DWMNCRENDERINGPOLICY rNCRP = DWMNCRP_ENABLED;
BOOL tpol = FALSE;
DwmSetWindowAttribute(hwnd, DWMWA_NCRENDERING_POLICY, &rNCRP, sizeof(rNCRP));
DwmSetWindowAttribute(hwnd, DWMWA_TRANSITIONS_FORCEDISABLED, &tpol, sizeof(tpol));
return TRUE;
}


int main() {

HANDLE hMutex = CreateMutex(NULL, TRUE, "dwmbsc32");
if (GetLastError() == ERROR_ALREADY_EXISTS)
{
//Ya hay una instancia
CloseHandle(hMutex);
MessageBox(0, "Ya hay una instancia de dwmbsc ejecutandose", "Error", MB_ICONERROR | MB_OK);
ExitProcess(NULL);
}

//ocultar consola
FreeConsole();

// Enumerar todas las ventanas existentes y aplicar politicas
EnumWindows(PolWinProc, NULL);

HINSTANCE hDll = LoadLibrary("hook.dll");
if (hDll == NULL) {
MessageBox(NULL, "Failed to load DLL 32", "Error", MB_OK | MB_ICONERROR);
return 1;
}

// Obtener puntero a para registrar el gancho de 32 bits
SetHookFunc setHook = (SetHookFunc)GetProcAddress(hDll, "SetHook");
RemoveHookFunc removeHook = (RemoveHookFunc)GetProcAddress(hDll, "RemoveHook");
if (setHook == NULL || removeHook == NULL) {
MessageBox(NULL, "Failed to get function pointers 32", "Error", MB_OK | MB_ICONERROR);
FreeLibrary(hDll);
return 1;
}

//instalar el gancho
setHook();

//informacion del proceso resultante
PROCESS_INFORMATION pi = {0};
STARTUPINFO si = {0};
si.cb = sizeof(si);

//crear subproceso de dwmbsc64
if (!CreateProcess(
"dwmbsc64.exe", // Ruta al ejecutable
NULL, // Argumentos de la línea de comandos
NULL, // Atributos del proceso (predeterminado)
NULL, // Atributos del hilo (predeterminado)
FALSE, // Herencia de manijas (falso para no heredar)
CREATE_NO_WINDOW, // Crear sin ventana de consola
NULL, // Medio ambiente del proceso (predeterminado)
NULL, // Directorio base (predeterminado)
&si, // Información de inicio del proceso
&pi)) { // Información del proceso resultante
return 1;
}

//registrar HotKey
RegisterHotKey(NULL, HK_ID, MOD_CONTROL | MOD_SHIFT, VK_F1);

MSG msg;
while (GetMessage(&msg, NULL, 0, 0)) {
switch (msg.message)
case WM_HOTKEY:
{
if(msg.wParam == HK_ID) {

// Enumerar todas las ventanas existentes y restaurar politicas
EnumWindows(dPolWinProc, NULL);

//remover gancho
removeHook();

//liberar la DLL
FreeLibrary(hDll);

// Desregistra el atajo de teclado al salir
UnregisterHotKey(NULL, HK_ID);

// matar proceso
TerminateProcess(pi.hProcess, 0);

// Cerrar los manejadores
CloseHandle(pi.hProcess);
CloseHandle(pi.hThread);
return 0;

}
break;
} //end switch
TranslateMessage(&msg);
DispatchMessage(&msg);
}

return 0;
}
8 changes: 8 additions & 0 deletions dwmbsc64/dwmbsc32/dwmbsc32.depend
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# depslib dependency file v1.0
1712964783 source:e:\documentos\codeblocks\dwmbsc\dwmbsc32\dwmbsc32.cpp
<Windows.h>

1712989938 source:e:\documentos\codeblocks\dwmbsc64\dwmbsc32\dwmbsc32.cpp
<Windows.h>
<dwmapi.h>

10 changes: 10 additions & 0 deletions dwmbsc64/dwmbsc32/dwmbsc32.layout
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<CodeBlocks_layout_file>
<FileVersion major="1" minor="0" />
<ActiveTarget name="Release" />
<File name="dwmbsc32.cpp" open="1" top="0" tabpos="3" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="228" topLine="0" />
</Cursor>
</File>
</CodeBlocks_layout_file>
Binary file added dwmbsc64/dwmbsc32/obj/Release/dwmbsc32.o
Binary file not shown.
46 changes: 46 additions & 0 deletions dwmbsc64/dwmbsc64.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#pragma once
#define WIN32_LEAN_AND_MEAN
#include <Windows.h>

typedef void (*SetHookFunc)();
typedef void (*RemoveHookFunc)();

int main() {

// ocultar shell cmd
FreeConsole();

// Cargar la DLL
HINSTANCE hDll = LoadLibrary("hook64.dll");
if (hDll == NULL) {
MessageBox(NULL, "Failed to load DLL 64", "Error", MB_OK | MB_ICONERROR);
return 1;
}

// Obtener puntero a para registrar el gancho de 64 bits
SetHookFunc setHook = (SetHookFunc)GetProcAddress(hDll, "SetHook");
RemoveHookFunc removeHook = (RemoveHookFunc)GetProcAddress(hDll, "RemoveHook");
if (setHook == NULL || removeHook == NULL) {
MessageBox(NULL, "Failed to get function pointers 64", "Error", MB_OK | MB_ICONERROR);
FreeLibrary(hDll);
return 1;
}

// Instalar el gancho
setHook();

// Mantener el programa en ejecución
MSG msg;
while (GetMessage(&msg, NULL, 0, 0)) {
TranslateMessage(&msg);
DispatchMessage(&msg);
}

//remover gancho
removeHook();

//liberar la DLL
FreeLibrary(hDll);

return 0;
}
Binary file added dwmbsc64/obj/Release/dwmbsc.o
Binary file not shown.
Binary file added dwmbsc64/obj/Release/dwmbsc32.o
Binary file not shown.
Binary file added dwmbsc64/obj/Release/dwmbsc64.o
Binary file not shown.

0 comments on commit adcadb8

Please sign in to comment.