VirtualBox

source: vbox/trunk/src/VBox/Additions/3D/win/VBoxICD/icd_forwarders.py@ 75562

Last change on this file since 75562 was 75562, checked in by vboxsync, 6 years ago

Additions/3D/win: ICD forwarder dll. bugref:9296

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 2.8 KB
Line 
1"""
2Copyright (C) 2018 Oracle Corporation
3
4This file is part of VirtualBox Open Source Edition (OSE), as
5available from http://www.virtualbox.org. This file is free software;
6you can redistribute it and/or modify it under the terms of the GNU
7General Public License (GPL) as published by the Free Software
8Foundation, in version 2 as it comes in the "COPYING" file of the
9VirtualBox OSE distribution. VirtualBox OSE is distributed in the
10hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
11"""
12
13import sys
14
15def GenerateForwarders():
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 names.append(line)
28
29 exports_file.close()
30
31
32 #
33 # Assembler forwarders
34 #
35 asm_file = open(sys.argv[2], "w")
36 if not asm_file:
37 print("Error: couldn't open %s file!" % filename)
38 sys.exit()
39
40 asm_file.write('%include "iprt/asmdefs.mac"\n')
41 asm_file.write('\n')
42 asm_file.write(';;;; %define ICD_LAZY_LOAD ; Enable this to lazy load the ICD DLL (does not work on Win64)\n')
43 asm_file.write('\n')
44 asm_file.write('%ifdef RT_ARCH_AMD64\n')
45 asm_file.write('%define PTR_SIZE_PREFIX qword\n')
46 asm_file.write('%else ; X86\n')
47 asm_file.write('%define PTR_SIZE_PREFIX dword\n')
48 asm_file.write('%endif\n')
49 asm_file.write('\n')
50 asm_file.write('%ifdef ICD_LAZY_LOAD\n')
51 asm_file.write('extern NAME(VBoxLoadICD)\n')
52 asm_file.write('%endif\n')
53 asm_file.write('extern NAME(g_hmodICD)\n')
54
55 for index in range(len(names)):
56 fn = names[index]
57 asm_file.write('\n')
58 asm_file.write('BEGINPROC_EXPORTED %s\n' % fn)
59 asm_file.write(' extern NAME(pfn_%s)\n' % fn)
60 asm_file.write('; int3\n')
61 asm_file.write('%ifdef ICD_LAZY_LOAD\n')
62 asm_file.write(' mov xAX, PTR_SIZE_PREFIX NAME(g_hmodICD)\n')
63 asm_file.write(' mov xAX, [xAX]\n')
64 asm_file.write(' or xAX, xAX\n')
65 asm_file.write(' jnz l_icd_loaded_%s\n' % fn)
66 asm_file.write(' call NAME(VBoxLoadICD)\n')
67 asm_file.write('l_icd_loaded_%s:\n' % fn)
68 asm_file.write('%endif\n')
69 asm_file.write(' mov xAX, PTR_SIZE_PREFIX NAME(pfn_%s)\n' % fn)
70 asm_file.write(' mov xAX, [xAX]\n')
71 asm_file.write(' or xAX, xAX\n')
72 asm_file.write(' jnz l_jmp_to_%s\n' % fn)
73 asm_file.write(' ret\n')
74 asm_file.write('l_jmp_to_%s:\n' % fn)
75 asm_file.write(' jmp xAX\n')
76 asm_file.write('ENDPROC %s\n' % fn)
77
78 asm_file.close()
79
80GenerateForwarders()
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette