1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980 |
- /* Copyright Yann Weber <asmsh@yannweb.net>
- This file is part of asmsh.
-
- asmsh is free software: you can redistribute it and/or modify it under the
- terms of the GNU General Public License as published by the Free Software
- Foundation, either version 3 of the License, or any later version.
-
- asmsh is distributed in the hope that it will be useful, but WITHOUT ANY
- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
- details.
-
- You should have received a copy of the GNU General Public License along
- with asmsh. If not, see <https://www.gnu.org/licenses/>.
- */
- #ifndef ASMSH_MMAP_PARSE_H
- #define ASMSH_MMAP_PARSE_H
-
- #include "config.h"
-
- #include <sys/mman.h>
- #include <sys/types.h>
- #include <sys/stat.h>
- #include <errno.h>
- #include <fcntl.h>
- #include <limits.h>
- #include <stdlib.h>
- #include <stdio.h>
- #include <string.h>
- #include <unistd.h>
-
-
- extern int errno;
-
- typedef struct child_mmap_s child_mmap_t;
- typedef struct child_mmap_list child_mmap_l;
-
- struct child_mmap_s
- {
- char *start;
- char *stop;
- int perm;
- size_t offset;
- dev_t device;
- ino_t inode;
- char *pathname;
- };
-
- struct child_mmap_list
- {
- child_mmap_t *maps;
- size_t size;
- };
-
- /** Initialize a child_mmap_l */
- void child_mmap_init(child_mmap_l *maps);
-
- /** Parse /proc/[pid]/map file
- *
- * @param pid_t The pid of the child process we ptrace attached
- * @param child_mmap_l A child map that will be filled with child's mmaps
- * @return 0 if no error else -1
- */
- int child_mmap_get(pid_t child_pid, child_mmap_l *maps);
-
- /** Parse an opened /proc/[pid]/map file
- *
- * @param int opened file descriptor
- * @param child_mmap_l A child map that will be filled with child's mmaps
- * @return 0 if no error else -1
- */
- int child_mmap_get_fd(int maps_fd, child_mmap_l *maps);
-
- void child_mmap_free(child_mmap_l *maps);
-
- int child_mmap_parseline(char *line, child_mmap_t *map);
-
- int _child_mmap_alloc(size_t curmap, child_mmap_l *maps);
-
- #endif
|