GtkD slows down visual D keyboard

Alex AJ at gmail.com
Wed May 15 11:36:42 UTC 2019


A hack:

On Tue, 14 May 2019 19:44:01 +0200, Mike Wey wrote:
> On 14-05-2019 05:10, Alex X wrote:
>> Any news on this?
>> 
>> https://forum.dlang.org/thread/bznpylcjostbrrwzhmst@forum.dlang.org
>> 
>> It's severely cramping my style ;/
>> 
> 
> Unfortunately no.
> 

	// The following code bypasses GTK windows hooking that causes 
problems with visual studio debugging(slow keyboard, it is a hack 
and may not work in general)
	debug {
		import core.sys.windows.windows, core.stdc.string;
		alias HHOOK function(int, HOOKPROC, HINSTANCE, DWORD) 
SetWindowsHookExAProc;
		alias HHOOK function(int, HOOKPROC, HINSTANCE, DWORD) 
SetWindowsHookExWProc;
		static extern (Windows) HHOOK KBHook(int, HOOKPROC, HINSTANCE, 
DWORD)
		{
			asm
			{
				naked;
				ret;
			}
		}

		DWORD old;
		auto err = GetLastError();

		auto hModule = LoadLibrary("User32.dll");
		auto proc = cast(SetWindowsHookExAProc)GetProcAddress(hModule, 
"SetWindowsHookExA");
		err = GetLastError();
		VirtualProtect(proc, 40, PAGE_EXECUTE_READWRITE, &old);
		err = GetLastError();

		memcpy(proc, &KBHook, 7);
		// Cleanup	
		//FreeLibrary(hModule);
	}


The code above is based on the idea from

https://github.com/microsoft/Detours

I didn't feel like investing the time to integrate it in to my 
code.

The code I've included is a hack that simply bypasses all hooking 
routines and hence the screwed up keyboard hook.

It only works for x64 since ret works to return properly(x86 
messages with the stack and requires a bit more code).






More information about the Digitalmars-d-learn mailing list