Skip to content

Latest commit

 

History

History
54 lines (44 loc) · 1.11 KB

README.md

File metadata and controls

54 lines (44 loc) · 1.11 KB

Windows_wrapper

Program to link functions to your wrapped function

/!\ Only 64 bits /!\

Example:

wrapped.c :

    #include <stdio.h>
    
    // wrapped function must start with wrap_, or any 5 caracteres before the real function name
    int wrap_puts(const char *s) {
      puts("WRAPPED PUTS");
      puts(s);
      return 2626;
    }

compile the wrapped.c as dll :

    $ x86_64-w64-mingw32-gcc -shared wrapped.c -o wrapped.dll

testprog.c :

    #include <stdio.h>

    int main(void)
    {
      int dummy;

      printf("testing wrapped function puts : \n");
      dummy = puts("Call to puts");
      printf("dummy = %d\n", dummy);
      return 0;
    }

compile the testprog.c as executable :

    $ x86_64-w64-mingw32-gcc -c testprog.c -o testprog.o
    $ x86_64-w64-mingw32-gcc testprog.o -o testprog.exe

Then just compile the actual wrapper program :

    $ make

Finally launch the programme like this :

    $ ./wrapper.exe wrapped.dll testprog.exe

WRAPPER