Advertisement
Guest User

Untitled

a guest
Sep 17th, 2019
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <unistd.h>
  3. #include <sys/sysctl.h>
  4. #include <stdlib.h>
  5. #include <string.h>
  6.  
  7. int main(int argc, char *argv[])
  8. {
  9. strncpy(argv[0], "lol", 4);
  10. printf("argv[0]: %s\n", argv[0]);
  11.  
  12. static char procdata[4096];
  13. int mib[3] = { CTL_KERN, KERN_PROCARGS, getpid() };
  14. procdata[0] = '\0'; // clear
  15. size_t size = sizeof(procdata);
  16. if (sysctl(mib, 3, procdata, &size, NULL, 0)) {
  17. puts("Some error *shrugs*");
  18. }
  19. procdata[sizeof(procdata)-2] = ':';
  20. procdata[sizeof(procdata)-1] = '\0';
  21.  
  22. printf("procdata name: %s\n", procdata);
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement