This source file includes following definitions.
- usage
- find_event_proc
- process_dump
- main
1
2
3 #include <stdio.h>
4 #include <stdint.h>
5 #include <string.h>
6 #include <stdlib.h>
7 #include "dumputil.h"
8
9 void usage()
10 {
11 fprintf(stderr,"find_eventproc <dumpfile.bin> <base address> <name1> <name1> ...\n");
12 exit(1);
13 }
14
15 int find_event_proc(dump_t *dump,char *name)
16 {
17 unsigned str_offset=0;
18 unsigned str_addr=0;
19 unsigned found=0;
20 while(find_cstring(dump,&str_offset,name)) {
21 str_addr=offset_to_ptr(dump,str_offset);
22 unsigned i=0;
23 while(find_word_aligned(dump,&i,str_addr)) {
24 uint32_t pfunc = dump->pw[i+1];
25
26 if(pfunc > dump->base && deref_word_ptr(dump,i*4+4) != 0) {
27
28 printf("NHSTUB(%s,0x%08X) // by find_eventproc name @ 0x%08X\n",name,pfunc,offset_to_ptr(dump,i*4));
29 found++;
30 }
31 i++;
32 }
33 str_offset+=strlen(name);
34 }
35 return found;
36 }
37
38 int process_dump(dump_t *dump,char **names,unsigned num_procs)
39 {
40 unsigned i;
41 unsigned found;
42 for(i=0,found=0; i<num_procs; i++) {
43
44 if(find_event_proc(dump,names[i]))
45 found++;
46 }
47 return found;
48 }
49
50 int main(int argc, char **argv)
51 {
52
53 dump_t dump;
54 int i;
55 const char *dumpname=NULL;
56 const char *base=NULL;
57 unsigned num_procs=0;
58
59 for(i = 1; i < argc; i++) {
60 if ( argv[i][0] == '-' ) {
61 fprintf(stderr,"%s unknown option %s\n",argv[0],argv[i]);
62 usage();
63 }
64 else {
65 if (!dumpname) {
66 dumpname=argv[i];
67 } else if(!base) {
68 base=argv[i];
69 }
70 }
71 }
72 num_procs = argc-3;
73
74 if(!dumpname || !base || !num_procs) {
75 usage();
76 }
77
78 if(!load_dump(dumpname,base,&dump))
79 return 1;
80
81 if(!process_dump(&dump,argv+3,num_procs))
82 return 1;
83
84 return 0;
85 }
86