1 | """
|
---|
2 | Copyright (C) 2018-2024 Oracle and/or its affiliates.
|
---|
3 |
|
---|
4 | This file is part of VirtualBox base platform packages, as
|
---|
5 | available from https://www.virtualbox.org.
|
---|
6 |
|
---|
7 | This program is free software; you can redistribute it and/or
|
---|
8 | modify it under the terms of the GNU General Public License
|
---|
9 | as published by the Free Software Foundation, in version 3 of the
|
---|
10 | License.
|
---|
11 |
|
---|
12 | This program is distributed in the hope that it will be useful, but
|
---|
13 | WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
15 | General Public License for more details.
|
---|
16 |
|
---|
17 | You should have received a copy of the GNU General Public License
|
---|
18 | along with this program; if not, see <https://www.gnu.org/licenses>.
|
---|
19 |
|
---|
20 | SPDX-License-Identifier: GPL-3.0-only
|
---|
21 | """
|
---|
22 |
|
---|
23 | import sys
|
---|
24 |
|
---|
25 | def GeneratePfns():
|
---|
26 |
|
---|
27 | # Get list of functions.
|
---|
28 | exports_file = open(sys.argv[1], "r")
|
---|
29 | if not exports_file:
|
---|
30 | print("Error: couldn't open %s file!" % filename)
|
---|
31 | sys.exit()
|
---|
32 |
|
---|
33 | names = []
|
---|
34 | for line in exports_file.readlines():
|
---|
35 | line = line.strip()
|
---|
36 | if len(line) > 0 and line[0] != ';' and line != 'EXPORTS':
|
---|
37 | # Parse 'glAccum = glAccum@8'
|
---|
38 | words = line.split('=')
|
---|
39 |
|
---|
40 | # Function name
|
---|
41 | names.append(words[0].strip())
|
---|
42 |
|
---|
43 | exports_file.close()
|
---|
44 |
|
---|
45 |
|
---|
46 | #
|
---|
47 | # C loader data
|
---|
48 | #
|
---|
49 | c_file = open(sys.argv[2], "w")
|
---|
50 | if not c_file:
|
---|
51 | print("Error: couldn't open %s file!" % filename)
|
---|
52 | sys.exit()
|
---|
53 |
|
---|
54 | c_file.write('#include <iprt/win/windows.h>\n')
|
---|
55 | c_file.write('#include <VBoxWddmUmHlp.h>\n')
|
---|
56 | c_file.write('\n')
|
---|
57 |
|
---|
58 | for index in range(len(names)):
|
---|
59 | fn = names[index]
|
---|
60 | c_file.write('FARPROC pfn_%s;\n' % fn)
|
---|
61 | c_file.write('\n')
|
---|
62 |
|
---|
63 | c_file.write("struct VBOXWDDMDLLPROC aIcdProcs[] =\n")
|
---|
64 | c_file.write('{\n')
|
---|
65 | for index in range(len(names)):
|
---|
66 | fn = names[index]
|
---|
67 | c_file.write(' { "%s", &pfn_%s },\n' % (fn, fn) )
|
---|
68 | c_file.write(' { NULL, NULL }\n')
|
---|
69 | c_file.write('};\n')
|
---|
70 |
|
---|
71 | c_file.close()
|
---|
72 |
|
---|
73 | GeneratePfns()
|
---|