Skip to content

Instantly share code, notes, and snippets.

@opsJson
Last active October 12, 2023 17:54
Show Gist options
  • Select an option

  • Save opsJson/eaec76e05f5d305255887ab69041cc29 to your computer and use it in GitHub Desktop.

Select an option

Save opsJson/eaec76e05f5d305255887ab69041cc29 to your computer and use it in GitHub Desktop.
needs to be compiled on the same DLL architecture. (32bit or 64bit)
#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