Skip to content

Commit

Permalink
Oops, almost forgot to update HookWindows_x64 to use Unload() instead…
Browse files Browse the repository at this point in the history
… of ClearSettings().

Altup is blocked for all keys again, not only left alt. It is a good idea for Winkey too, for example.
Removing es-ES and gl-ES translations from config since they have not been submitted in time.
  • Loading branch information
stefansundin committed Dec 29, 2014
1 parent e1c297e commit 3d1e686
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 15 deletions.
Binary file modified AltDrag.ini
Binary file not shown.
13 changes: 9 additions & 4 deletions altdrag.c
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ int HookSystem() {
wcscat(path, L"\\hooks.dll");
hinstDLL = LoadLibrary(path);
if (hinstDLL == NULL) {
Error(L"LoadLibrary('hooks.dll')", L"This probably means that the file hooks.dll is missing.\nYou can try to download "APP_NAME" again from the website.", GetLastError(), TEXT(__FILE__), __LINE__);
Error(L"LoadLibrary('hooks.dll')", L"This probably means that the file hooks.dll is missing. You can try to download "APP_NAME" again from the website.", GetLastError(), TEXT(__FILE__), __LINE__);
return 1;
}
}
Expand All @@ -173,7 +173,7 @@ int HookSystem() {
//Get address to keyboard hook (beware name mangling)
procaddr = (HOOKPROC)GetProcAddress(hinstDLL, "LowLevelKeyboardProc@12");
if (procaddr == NULL) {
Error(L"GetProcAddress('LowLevelKeyboardProc@12')", L"This probably means that the file hooks.dll is from an old version or corrupt.\nYou can try to download "APP_NAME" again from the website.", GetLastError(), TEXT(__FILE__), __LINE__);
Error(L"GetProcAddress('LowLevelKeyboardProc@12')", L"This probably means that the file hooks.dll is from an old version or corrupt. You can try to download "APP_NAME" again from the website.", GetLastError(), TEXT(__FILE__), __LINE__);
return 1;
}
//Set up the keyboard hook
Expand All @@ -188,7 +188,7 @@ int HookSystem() {
//Get address to message hook (beware name mangling)
procaddr = (HOOKPROC)GetProcAddress(hinstDLL, "CallWndProc@12");
if (procaddr == NULL) {
Error(L"GetProcAddress('CallWndProc@12')", L"This probably means that the file hooks.dll is from an old version or corrupt.\nYou can try to download "APP_NAME" again from the website.", GetLastError(), TEXT(__FILE__), __LINE__);
Error(L"GetProcAddress('CallWndProc@12')", L"This probably means that the file hooks.dll is from an old version or corrupt. You can try to download "APP_NAME" again from the website.", GetLastError(), TEXT(__FILE__), __LINE__);
return 1;
}
//Set up the message hook
Expand Down Expand Up @@ -254,7 +254,12 @@ int UnhookSystem() {

//Tell dll file that we are unloading
void (*Unload)() = (void*)GetProcAddress(hinstDLL, "Unload");
Unload();
if (Unload == NULL) {
Error(L"GetProcAddress('Unload')", L"This probably means that the file hooks.dll is from an old version or corrupt. You can try to download "APP_NAME" again from the website.", GetLastError(), TEXT(__FILE__), __LINE__);
}
else {
Unload();
}

//Unload library
if (hinstDLL) {
Expand Down
4 changes: 3 additions & 1 deletion hooks.c
Original file line number Diff line number Diff line change
Expand Up @@ -945,7 +945,7 @@ __declspec(dllexport) LRESULT CALLBACK LowLevelKeyboardProc(int nCode, WPARAM wP

//Block the alt keyup to prevent the window menu to be selected.
//The way this works is that the alt key is "disguised" by sending ctrl keydown/keyup events just before the altup (see issue 20).
if (vkey == VK_LMENU && (state.blockaltup || sharedstate.action)) {
if (state.blockaltup || sharedstate.action) {
state.ignorectrl = 1;
KEYBDINPUT ctrl[2] = {{VK_CONTROL,0,0,0}, {VK_CONTROL,0,KEYEVENTF_KEYUP,0}};
ctrl[0].dwExtraInfo = ctrl[1].dwExtraInfo = GetMessageExtraInfo();
Expand Down Expand Up @@ -1701,13 +1701,15 @@ __declspec(dllexport) LRESULT CALLBACK CallWndProc(int nCode, WPARAM wParam, LPA

__declspec(dllexport) void Unload() {
sharedsettings_loaded = 0;
#ifndef _WIN64
DestroyWindow(g_hwnd);
if (scrollhook) {
if (UnhookWindowsHookEx(scrollhook) == 0) {
Error(L"UnhookWindowsHookEx(scrollhook)", L"Could not unhook mouse. Try restarting "APP_NAME".", GetLastError(), TEXT(__FILE__), __LINE__);
}
scrollhook = NULL;
}
#endif
}

BOOL APIENTRY DllMain(HINSTANCE hInst, DWORD reason, LPVOID reserved) {
Expand Down
17 changes: 11 additions & 6 deletions hookwindows_x64.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ int HookSystem() {
wcscat(path, L"\\hooks_x64.dll");
hinstDLL = LoadLibrary(path);
if (hinstDLL == NULL) {
Error(L"LoadLibrary('hooks_x64.dll')", L"This probably means that the file hooks_x64.dll is missing.\nYou can try to download "APP_NAME" again from the website.", GetLastError(), TEXT(__FILE__), __LINE__);
Error(L"LoadLibrary('hooks_x64.dll')", L"This probably means that the file hooks_x64.dll is missing. You can try to download "APP_NAME" again from the website.", GetLastError(), TEXT(__FILE__), __LINE__);
return 1;
}
}
Expand All @@ -98,7 +98,7 @@ int HookSystem() {
//Get address to keyboard hook (beware name mangling)
procaddr = (HOOKPROC)GetProcAddress(hinstDLL, "LowLevelKeyboardProc");
if (procaddr == NULL) {
Error(L"GetProcAddress('LowLevelKeyboardProc')", L"This probably means that the file hooks_x64.dll is from an old version or corrupt.\nYou can try to download "APP_NAME" again from the website.", GetLastError(), TEXT(__FILE__), __LINE__);
Error(L"GetProcAddress('LowLevelKeyboardProc')", L"This probably means that the file hooks_x64.dll is from an old version or corrupt. You can try to download "APP_NAME" again from the website.", GetLastError(), TEXT(__FILE__), __LINE__);
return 1;
}
//Set up the keyboard hook
Expand All @@ -113,7 +113,7 @@ int HookSystem() {
if (!msghook) {
procaddr = (HOOKPROC)GetProcAddress(hinstDLL, "CallWndProc");
if (procaddr == NULL) {
Error(L"GetProcAddress('CallWndProc')", L"This probably means that the file hooks_x64.dll is from an old version or corrupt.\nYou can try to download "APP_NAME" again from the website.", GetLastError(), TEXT(__FILE__), __LINE__);
Error(L"GetProcAddress('CallWndProc')", L"This probably means that the file hooks_x64.dll is from an old version or corrupt. You can try to download "APP_NAME" again from the website.", GetLastError(), TEXT(__FILE__), __LINE__);
return 1;
}
//Set up the message hook
Expand Down Expand Up @@ -148,9 +148,14 @@ int UnhookSystem() {
}
msghook = NULL;

//Clear sharedsettings_loaded flag in dll (sometimes it isn't cleared because msghook keeps it alive somehow)
void (*ClearSettings)() = (void*)GetProcAddress(hinstDLL, "ClearSettings");
ClearSettings();
//Tell dll file that we are unloading
void (*Unload)() = (void*)GetProcAddress(hinstDLL, "Unload");
if (Unload == NULL) {
Error(L"GetProcAddress('Unload')", L"This probably means that the file hooks_x64.dll is from an old version or corrupt. You can try to download "APP_NAME" again from the website.", GetLastError(), TEXT(__FILE__), __LINE__);
}
else {
Unload();
}

if (hinstDLL) {
//Unload library
Expand Down
8 changes: 4 additions & 4 deletions localization/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ struct strings {
};

#include "../localization/en-US/config.h"
#include "../localization/es-ES/config.h"
#include "../localization/gl-ES/config.h"
//#include "../localization/es-ES/config.h"
//#include "../localization/gl-ES/config.h"
#include "../localization/zh-CN/config.h"

struct {
Expand All @@ -70,8 +70,8 @@ struct {
wchar_t *language;
} languages[] = {
{L"en-US", &en_US, L"English"},
{L"es-ES", &es_ES, L"Spanish"},
{L"gl-ES", &gl_ES, L"Galician"},
//{L"es-ES", &es_ES, L"Spanish"},
//{L"gl-ES", &gl_ES, L"Galician"},
{L"zh-CN", &zh_CN, L"Chinese"},
{NULL}
};
Expand Down

0 comments on commit 3d1e686

Please sign in to comment.