Created
December 6, 2017 02:15
-
-
Save laijs/10a9ec476cf5875d2ba75c3071769128 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define _GNU_SOURCE | |
#include <sys/types.h> | |
#include <unistd.h> | |
#include <stdio.h> | |
#include <stdlib.h> | |
void main(void) { | |
int pid = getpid(); | |
char *cmd; | |
// asprintf(&cmd, "cat /proc/%d/maps", pid); | |
asprintf(&cmd, "pmap -x %d", pid); | |
system(cmd); | |
free(cmd); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
/* | |
#cgo CFLAGS: -Wall | |
#define _GNU_SOURCE | |
#include <sys/types.h> | |
#include <unistd.h> | |
#include <stdio.h> | |
#include <stdlib.h> | |
void __attribute__((constructor)) contructor_map(void) { | |
int pid = getpid(); | |
char *cmd; | |
// asprintf(&cmd, "cat /proc/%d/maps", pid); | |
asprintf(&cmd, "pmap -x %d", pid); | |
system(cmd); | |
free(cmd); | |
} | |
*/ | |
import "C" | |
//import "io" | |
import "os" | |
import "fmt" | |
import "os/exec" | |
import "syscall" | |
func main() { | |
//maps, _ := os.Open("/proc/self/maps") | |
//io.Copy(os.Stdout, maps) | |
cmd := exec.Command("pmap", "-x", fmt.Sprintf("%d", syscall.Getpid())) | |
cmd.Stdout = os.Stdout | |
cmd.Run() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment