Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- int main(int argc,char**argv)
- {
- char *ptr;
- if(argc<3){
- printf("Usage: %s <environment var> <target program name>\n", argv[0]);
- exit(0);
- }
- ptr = getenv(argv[1]);
- //there is an increment of 2 bytes for every bytes added to the name of the program (pg.141 ericson, or see example at the end)
- ptr += (strlen(argv[0]) - strlen(argv[2]))*2;
- printf("%s will be at %p\n",argv[1],ptr);
- // or this also work
- printf("%08x", getenv(argv[1]));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement