source: EcnlProtoTool/trunk/ntshell/shellif.rb@ 279

Last change on this file since 279 was 279, checked in by coas-nagasima, 7 years ago

ファイルを追加、更新。

  • Property svn:eol-style set to native
  • Property svn:mime-type set to text/x-ruby
File size: 1.2 KB
Line 
1
2def ReadSymbolFile(symbolFileName)
3 begin
4 symbolFile = File.open(symbolFileName)
5 rescue Errno::ENOENT, Errno::EACCES => ex
6 abort(ex.message)
7 end
8
9 symbolAddress = {}
10 symbolFile.each do |line|
11 # スペース区切りで分解
12 fields = line.split(/\s+/)
13
14 # 3列になっていない行は除外
15 if fields.size == 3 && fields[2].start_with?("__exp_")
16 symbolAddress[fields[2].gsub("__exp_", "")] = fields[0].hex
17 end
18 end
19 symbolFile.close
20 return(symbolAddress)
21end
22
23symbolsInfo = ReadSymbolFile("ntshell.syms")
24
25begin
26 outFile = File.open("../ntshell/shellif.h", "w")
27rescue Errno::ENOENT, Errno::EACCES => ex
28 abort(ex.message)
29end
30
31symbolsInfo.each do |k, v|
32 outFile.printf("#define __imp_%s ((%s_t)0x%08x)\n", k, k, v)
33end
34
35outFile.close
36
37begin
38 outFile = File.open("../ntshell/shellif_stub.c", "w")
39rescue Errno::ENOENT, Errno::EACCES => ex
40 abort(ex.message)
41end
42
43symbolsInfo.each do |k, v|
44 outFile.printf("typedef int (*%s_t)(void);\n", k)
45end
46
47outFile.print("\n")
48
49symbolsInfo.each do |k, v|
50 outFile.printf("int %s(void)\n", k)
51 outFile.print("{\n")
52 outFile.printf("\treturn __imp_%s();\n", k)
53 outFile.print("}\n")
54 outFile.print("\n")
55end
56
57outFile.close
Note: See TracBrowser for help on using the repository browser.