3 # Signature-du-Terroir module to handle /proc/modules
8 modulelist: List of module names
9 moduledict: Dictionary of [module-name] = {'size', 'loadnum', 'dependencies', 'state', 'offset'}
10 moduledict['video']['offset'] -> offset adress in kernel of the 'video' module
11 min_address: Lowest offset address
12 max_load: Highest offset address
13 max_address: max_load + size-of-last-module
14 sum_sizes: sum of all module sizes
15 memory_range: max_address - min_address
18 sorted_sizes_table(): Alphabetically sorted table of modules+sizes as a string
19 sorted_offset_table(): Alphabetically sorted table of modules+offset as a string
20 sorted_loadnum_table(): Alphabetically sorted table of modules+loadnum as a string
21 sorted_dependencies_table(): Alphabetically sorted table of modules+dependencies as a string
22 sorted_state_table(): Alphabetically sorted table of modules+state as a string
28 min_address
= 10**100;
32 with
open('/proc/modules') as m
:
34 module_value
= re
.split(r
'\s+', l
.rstrip('\s\n'));
35 (module
, size
, loadnum
, dependencies
, state
, offset
) = module_value
[0:6];
36 modulelist
.append(module
);
38 loadnum
= int(loadnum
);
39 offset
= int(offset
, 16);
40 module_entry
= {'size':size
, 'loadnum':loadnum
, 'dependencies':dependencies
, 'state':state
, 'offset':offset
};
41 moduledict
[module
] = module_entry
;
42 if min_address
> offset
: min_address
= offset
;
43 if max_address
< offset
+size
: max_address
= offset
+ size
;
44 if max_load
< offset
: max_load
= offset
;
47 memory_range
= max_address
- min_address
49 def sorted_sizes_table():
53 s
+= m
+"\t"+str(moduledict
[m
]['size'])+"\n";
56 def sorted_offset_table():
60 s
+= m
+"\t"+str(moduledict
[m
]['offset'])+"\n";
63 def sorted_loadnum_table():
67 s
+= m
+"\t"+str(moduledict
[m
]['loadnum'])+"\n";
70 def sorted_dependencies_table():
74 s
+= m
+"\t"+str(moduledict
[m
]['dependencies'])+"\n";
77 def sorted_state_table ():
81 s
+= m
+"\t"+str(moduledict
[m
]['state'])+"\n";
84 def dump_module_binary (name
):
85 module_binary
= open('/proc/kcore');
87 if __name__
== "__main__":