Last active
October 12, 2023 17:54
-
-
Save opsJson/eaec76e05f5d305255887ab69041cc29 to your computer and use it in GitHub Desktop.
needs to be compiled on the same DLL architecture. (32bit or 64bit)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <stdio.h> | |
| #include <windows.h> | |
| void *GetFunctionFromDll(LPCSTR DLL, LPCSTR procName) { | |
| HMODULE hModule; | |
| void *function; | |
| if ((hModule = LoadLibrary(DLL)) == NULL) | |
| { | |
| fwprintf(stderr, L"ERROR: could not load DLL.\n"); | |
| return NULL; | |
| } | |
| if ((function = GetProcAddress(hModule, procName)) == NULL) | |
| { | |
| fwprintf(stderr, L"ERROR: could not find function.\n"); | |
| return NULL; | |
| } | |
| return function; | |
| } | |
| /*/////////////////////////////////// | |
| Testing: | |
| ///////////////////////////////////*/ | |
| int main(void) { | |
| typedef BOOL (*BLOCKINPUT)(BOOL blockIt); | |
| BLOCKINPUT BlockInput = GetFunctionFromDll("user32.dll", "BlockInput"); | |
| BlockInput(1); | |
| Sleep(3000); | |
| BlockInput(0); | |
| while (1); | |
| return 0; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment