1 | """
|
---|
2 | Copyright (C) 2018 Oracle Corporation
|
---|
3 |
|
---|
4 | This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
5 | available from http://www.virtualbox.org. This file is free software;
|
---|
6 | you can redistribute it and/or modify it under the terms of the GNU
|
---|
7 | General Public License (GPL) as published by the Free Software
|
---|
8 | Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
9 | VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
10 | hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
11 | """
|
---|
12 |
|
---|
13 | import sys
|
---|
14 |
|
---|
15 | def GeneratePfns():
|
---|
16 |
|
---|
17 | # Get list of functions.
|
---|
18 | exports_file = open(sys.argv[1], "r")
|
---|
19 | if not exports_file:
|
---|
20 | print("Error: couldn't open %s file!" % filename)
|
---|
21 | sys.exit()
|
---|
22 |
|
---|
23 | names = []
|
---|
24 | for line in exports_file.readlines():
|
---|
25 | line = line.strip()
|
---|
26 | if len(line) > 0 and line[0] != ';' and line != 'EXPORTS':
|
---|
27 | # Parse 'glAccum = glAccum@8'
|
---|
28 | words = line.split('=')
|
---|
29 |
|
---|
30 | # Function name
|
---|
31 | names.append(words[0].strip())
|
---|
32 |
|
---|
33 | exports_file.close()
|
---|
34 |
|
---|
35 |
|
---|
36 | #
|
---|
37 | # C loader data
|
---|
38 | #
|
---|
39 | c_file = open(sys.argv[2], "w")
|
---|
40 | if not c_file:
|
---|
41 | print("Error: couldn't open %s file!" % filename)
|
---|
42 | sys.exit()
|
---|
43 |
|
---|
44 | c_file.write('#include <iprt/win/windows.h>\n')
|
---|
45 | c_file.write('#include <VBoxWddmUmHlp.h>\n')
|
---|
46 | c_file.write('\n')
|
---|
47 |
|
---|
48 | for index in range(len(names)):
|
---|
49 | fn = names[index]
|
---|
50 | c_file.write('FARPROC pfn_%s;\n' % fn)
|
---|
51 | c_file.write('\n')
|
---|
52 |
|
---|
53 | c_file.write("struct VBOXWDDMDLLPROC aIcdProcs[] =\n")
|
---|
54 | c_file.write('{\n')
|
---|
55 | for index in range(len(names)):
|
---|
56 | fn = names[index]
|
---|
57 | c_file.write(' { "%s", &pfn_%s },\n' % (fn, fn) )
|
---|
58 | c_file.write(' { NULL, NULL }\n')
|
---|
59 | c_file.write('};\n')
|
---|
60 |
|
---|
61 | c_file.close()
|
---|
62 |
|
---|
63 | GeneratePfns()
|
---|