A shell that runs x86_64 assembly
c
x86-64
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

mmap_parse.h 2.0KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. /* Copyright Yann Weber <asmsh@yannweb.net>
  2. This file is part of asmsh.
  3. asmsh is free software: you can redistribute it and/or modify it under the
  4. terms of the GNU General Public License as published by the Free Software
  5. Foundation, either version 3 of the License, or any later version.
  6. asmsh is distributed in the hope that it will be useful, but WITHOUT ANY
  7. WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  8. FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  9. details.
  10. You should have received a copy of the GNU General Public License along
  11. with asmsh. If not, see <https://www.gnu.org/licenses/>.
  12. */
  13. #ifndef ASMSH_MMAP_PARSE_H
  14. #define ASMSH_MMAP_PARSE_H
  15. #include "config.h"
  16. #include <sys/mman.h>
  17. #include <sys/types.h>
  18. #include <sys/stat.h>
  19. #include <errno.h>
  20. #include <fcntl.h>
  21. #include <limits.h>
  22. #include <stdlib.h>
  23. #include <stdio.h>
  24. #include <string.h>
  25. #include <unistd.h>
  26. extern int errno;
  27. typedef struct child_mmap_s child_mmap_t;
  28. typedef struct child_mmap_list child_mmap_l;
  29. struct child_mmap_s
  30. {
  31. char *start;
  32. char *stop;
  33. int perm;
  34. size_t offset;
  35. dev_t device;
  36. ino_t inode;
  37. char *pathname;
  38. };
  39. struct child_mmap_list
  40. {
  41. child_mmap_t *maps;
  42. size_t size;
  43. };
  44. /** Initialize a child_mmap_l */
  45. void child_mmap_init(child_mmap_l *maps);
  46. /** Parse /proc/[pid]/map file
  47. *
  48. * @param pid_t The pid of the child process we ptrace attached
  49. * @param child_mmap_l A child map that will be filled with child's mmaps
  50. * @return 0 if no error else -1
  51. */
  52. int child_mmap_get(pid_t child_pid, child_mmap_l *maps);
  53. /** Parse an opened /proc/[pid]/map file
  54. *
  55. * @param int opened file descriptor
  56. * @param child_mmap_l A child map that will be filled with child's mmaps
  57. * @return 0 if no error else -1
  58. */
  59. int child_mmap_get_fd(int maps_fd, child_mmap_l *maps);
  60. void child_mmap_free(child_mmap_l *maps);
  61. int child_mmap_parseline(char *line, child_mmap_t *map);
  62. int _child_mmap_alloc(size_t curmap, child_mmap_l *maps);
  63. #endif