0
|
1 from pydc import *
|
5
|
2 import sys
|
|
3 import platform
|
0
|
4
|
5
|
5 if sys.platform == "win32":
|
0
|
6 libc = load("msvcrt")
|
5
|
7 elif sys.platform == "darwin":
|
0
|
8 libc = load("/usr/lib/libc.dylib")
|
5
|
9 elif "bsd" in sys.platform:
|
28
|
10 #libc = load("/usr/lib/libc.so")
|
|
11 libc = load("/lib/libc.so.7")
|
5
|
12 elif platform.architecture()[0] == "64bit":
|
|
13 libc = load("/lib64/libc.so.6")
|
0
|
14 else:
|
|
15 libc = load("/lib/libc.so.6")
|
|
16
|
|
17 fp_atoi = find(libc,"atoi")
|
|
18 fp_atof = find(libc,"atof")
|
48
|
19 fp_printf = find(libc,"printf")
|
0
|
20
|
5
|
21
|
|
22
|
28
|
23 def atoi(s): return call(fp_atoi,"Z)i",s)
|
|
24 def atod(s): return call(fp_atof,"Z)d",s)
|
0
|
25
|
28
|
26 print(atoi("3".join(["12","45"])))
|
|
27 print(atod("3".join(["12","45"])))
|
0
|
28
|
48
|
29 # w/ some text - tests vararg callconv switch
|
|
30 call(fp_printf,"_eZ_.id)i", "and again: %d %f\n", atoi("31245"), atod("31245"))
|
|
31
|