Skip to content

Instantly share code, notes, and snippets.

@dancojocaru2000
Created February 6, 2021 13:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dancojocaru2000/8813679b5cd8225843905e7a11ff5ef6 to your computer and use it in GitHub Desktop.
Save dancojocaru2000/8813679b5cd8225843905e7a11ff5ef6 to your computer and use it in GitHub Desktop.
Dynamically Load printf
#include <dlfcn.h>
int main(void) {
// No error checking, use dlerror
void* current_proc = dlopen(0, 0);
int (*fp)() = dlsym(current_proc, "printf");
fp("Hello, World!\n");
return 0;
}
@dancojocaru2000
Copy link
Author

Make sure to compile using -l dl

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment