June 4th Thursday (六月 四日 木曜日)
2009-06-26 20:43
429 查看
The program can show auxiliary vectors hidden after environment and arguments.
//showall.c
#include <stdio.h>
#include <elf.h>
int main(int argc, char* argv[]) {
int *p= (int*) argv;
int i;
Elf32_auxv_t* aux;
printf("Argument count: %d/n", *(p-1));
for (i = 0; i < *(p-1); ++i) {
printf("Argument %d: %s/n", i, *(p+1));
}
p += i;
p++; // skip 0
printf("Environment:/n");
while(*p) {
printf("%s/n", *p);
p++;
}
p++;
printf("Auxiliary Vectors: /n");
aux = (Elf32_auxv_t*)p;
while(aux->a_type != AT_NULL) {
printf("Type: %02d Value: %x/n", aux->a_type, aux->a_un.a_val);
aux++;
}
return 0;
}
//showall.c
#include <stdio.h>
#include <elf.h>
int main(int argc, char* argv[]) {
int *p= (int*) argv;
int i;
Elf32_auxv_t* aux;
printf("Argument count: %d/n", *(p-1));
for (i = 0; i < *(p-1); ++i) {
printf("Argument %d: %s/n", i, *(p+1));
}
p += i;
p++; // skip 0
printf("Environment:/n");
while(*p) {
printf("%s/n", *p);
p++;
}
p++;
printf("Auxiliary Vectors: /n");
aux = (Elf32_auxv_t*)p;
while(aux->a_type != AT_NULL) {
printf("Type: %02d Value: %x/n", aux->a_type, aux->a_un.a_val);
aux++;
}
return 0;
}
相关文章推荐
- June 25th Thursday (六月 二十五日 木曜日)
- June 4th Monday (六月 四日 日曜日)
- June 14th Thursday (六月 十四日 木曜日)
- June 28th Thursday (六月 二十八日 木曜日)
- 2008 September 4th Thursday (九月 四日 木曜日)
- June 7th Thursday (六月 七日 木曜日)
- June 11th Thursday (六月 十一日 木曜日)
- June 18th Tuesday (六月 十八日 木曜日)
- June 19th Friday (六月 十九日 木曜日)
- June 21th Thursday (六月 二十一日 木曜日)
- June 12th Tuesday (六月 十二日 火曜日)
- June 25th Monday (六月 二十五日 月曜日)
- July 5th Thursday (七月 五日 木曜日)
- September 4th Tuesday (九月 四日 火曜日)
- 2008 January 17th Thursday (一月 十七日 木曜日)
- 2008 March 14th Thursday (三月 十四日 木曜日)
- 2008 April 3th Thursday (四月 三日 木曜日)
- 2008 July 3th Thursday (七月 三日 木曜日)
- 2008 October 30th Thursday (十月 三十日 木曜日)
- 2009 March 12th Thursday (三月 十二日 木曜日)