Created
October 2, 2025 07:55
-
-
Save ProfAvery/c82c6e7d670dfa6f4f46768fd0823701 to your computer and use it in GitHub Desktop.
Example: Hello, DLL
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> | |
__declspec(dllexport) | |
void hello(void) | |
{ | |
printf("Hello, DLL\n"); | |
} |
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 <windows.h> | |
int main(void) | |
{ | |
HMODULE h = LoadLibraryA("hello.dll"); | |
void (*hello)(void) = (void (*)(void)) GetProcAddress(h, "hello"); | |
hello(); | |
FreeLibrary(h); | |
return 0; | |
} |
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
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