Skip to content

Instantly share code, notes, and snippets.

@ProfAvery
Created October 2, 2025 07:55
Show Gist options
  • Save ProfAvery/c82c6e7d670dfa6f4f46768fd0823701 to your computer and use it in GitHub Desktop.
Save ProfAvery/c82c6e7d670dfa6f4f46768fd0823701 to your computer and use it in GitHub Desktop.
Example: Hello, DLL
#include <stdio.h>
__declspec(dllexport)
void hello(void)
{
printf("Hello, DLL\n");
}
#include <windows.h>
int main(void)
{
HMODULE h = LoadLibraryA("hello.dll");
void (*hello)(void) = (void (*)(void)) GetProcAddress(h, "hello");
hello();
FreeLibrary(h);
return 0;
}
all: main.exe hello.dll
main.exe: main.c
x86_64-w64-mingw32-gcc -o main.exe main.c
hello.dll: hello.c
x86_64-w64-mingw32-gcc -shared -o hello.dll hello.c
clean:
rm -f main.exe hello.dll
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment