BlackBox-dl.c 777 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. #include <dlfcn.h>
  2. #include <stdio.h>
  3. int main (int argc, char *argv[])
  4. {
  5. void * h;
  6. /*
  7. void * h1;
  8. void (*SetKernelBaseStack) (int);
  9. void (*Init) (void);
  10. */
  11. int res;
  12. h = dlopen("libBB.so", RTLD_LAZY | RTLD_GLOBAL);
  13. if (h != NULL) {
  14. /*
  15. h1 = dlsym(h, "SetKernelBaseStack");
  16. if (h1 != NULL) {
  17. *(void **) (&SetKernelBaseStack) = h1;
  18. h1 = dlsym(h, "Init");
  19. if (h1 != NULL) {
  20. *(void **) (&Init) = h1;
  21. asm ("movl %%esp, %[res]" : [res] "=m" (res) );
  22. SetKernelBaseStack(res - 8);
  23. printf("before Init()\n");
  24. Init();
  25. printf("after Init()\n");
  26. res = 0;
  27. } else {
  28. perror(dlerror());
  29. res = 3;
  30. }
  31. } else {
  32. perror(dlerror());
  33. res = 2;
  34. }
  35. */
  36. res = 0;
  37. } else {
  38. perror(dlerror());
  39. res = 1;
  40. }
  41. return res;
  42. }