1 | ; $Id: nt3fakesA-r0drv-nt.asm 98103 2023-01-17 14:15:46Z vboxsync $
|
---|
2 | ;; @file
|
---|
3 | ; IPRT - Companion to nt3fakes-r0drv-nt.cpp that provides import stuff to satisfy the linker.
|
---|
4 | ;
|
---|
5 |
|
---|
6 | ;
|
---|
7 | ; Copyright (C) 2006-2023 Oracle and/or its affiliates.
|
---|
8 | ;
|
---|
9 | ; This file is part of VirtualBox base platform packages, as
|
---|
10 | ; available from https://www.virtualbox.org.
|
---|
11 | ;
|
---|
12 | ; This program is free software; you can redistribute it and/or
|
---|
13 | ; modify it under the terms of the GNU General Public License
|
---|
14 | ; as published by the Free Software Foundation, in version 3 of the
|
---|
15 | ; License.
|
---|
16 | ;
|
---|
17 | ; This program is distributed in the hope that it will be useful, but
|
---|
18 | ; WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
19 | ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
20 | ; General Public License for more details.
|
---|
21 | ;
|
---|
22 | ; You should have received a copy of the GNU General Public License
|
---|
23 | ; along with this program; if not, see <https://www.gnu.org/licenses>.
|
---|
24 | ;
|
---|
25 | ; The contents of this file may alternatively be used under the terms
|
---|
26 | ; of the Common Development and Distribution License Version 1.0
|
---|
27 | ; (CDDL), a copy of it is provided in the "COPYING.CDDL" file included
|
---|
28 | ; in the VirtualBox distribution, in which case the provisions of the
|
---|
29 | ; CDDL are applicable instead of those of the GPL.
|
---|
30 | ;
|
---|
31 | ; You may elect to license modified versions of this file under the
|
---|
32 | ; terms and conditions of either the GPL or the CDDL or both.
|
---|
33 | ;
|
---|
34 | ; SPDX-License-Identifier: GPL-3.0-only OR CDDL-1.0
|
---|
35 | ;
|
---|
36 |
|
---|
37 | ;*******************************************************************************
|
---|
38 | ;* Header Files *
|
---|
39 | ;*******************************************************************************
|
---|
40 | %include "iprt/asmdefs.mac"
|
---|
41 |
|
---|
42 | %undef NAME
|
---|
43 | %define NAME(name) NAME_OVERLOAD(name)
|
---|
44 |
|
---|
45 | BEGINCODE
|
---|
46 |
|
---|
47 | ;;
|
---|
48 | ; Called from rtR0Nt3InitSymbols after symbols have been resolved.
|
---|
49 | BEGINPROC _rtNt3InitSymbolsAssembly
|
---|
50 | push ebp
|
---|
51 | mov ebp, esp
|
---|
52 |
|
---|
53 | ;;
|
---|
54 | ; @param 1 The fastcall name.
|
---|
55 | ; @param 2 Byte size of arguments.
|
---|
56 | %macro DefineImportDataAndInitCode 3
|
---|
57 | extern $%1 %+ Nt3Fb_ %+ %2 %+ @ %+ %3
|
---|
58 | BEGINDATA
|
---|
59 | extern _g_pfnrt %+ %2
|
---|
60 | GLOBALNAME __imp_ %+ %1 %+ %2 %+ @ %+ %3
|
---|
61 | dd $%1 %+ Nt3Fb_ %+ %2 %+ @ %+ %3
|
---|
62 | BEGINCODE
|
---|
63 | mov eax, [_g_pfnrt %+ %2]
|
---|
64 | test eax, eax
|
---|
65 | jz %%next
|
---|
66 | mov [__imp_ %+ %1 %+ %2 %+ @ %+ %3], eax
|
---|
67 | %%next:
|
---|
68 | %endmacro
|
---|
69 |
|
---|
70 | DefineImportDataAndInitCode _,PsGetVersion, 16
|
---|
71 | DefineImportDataAndInitCode _,ZwQuerySystemInformation, 16
|
---|
72 | DefineImportDataAndInitCode _,KeSetTimerEx, 20
|
---|
73 | DefineImportDataAndInitCode _,IoAttachDeviceToDeviceStack, 8
|
---|
74 | DefineImportDataAndInitCode _,PsGetCurrentProcessId, 0
|
---|
75 | DefineImportDataAndInitCode _,ZwYieldExecution, 0
|
---|
76 | DefineImportDataAndInitCode @,ExAcquireFastMutex, 4
|
---|
77 | DefineImportDataAndInitCode @,ExReleaseFastMutex, 4
|
---|
78 |
|
---|
79 | xor eax, eax
|
---|
80 | leave
|
---|
81 | ret
|
---|
82 | ENDPROC _rtNt3InitSymbolsAssembly
|
---|
83 |
|
---|
84 |
|
---|
85 | ;;
|
---|
86 | ; @param 1 The fastcall name.
|
---|
87 | ; @param 2 The stdcall name.
|
---|
88 | ; @param 3 Byte size of arguments.
|
---|
89 | ; @param 4 Zero if 1:1 mapping;
|
---|
90 | ; One if 2nd parameter is a byte pointer that the farcall version
|
---|
91 | ; instead returns in al.
|
---|
92 | %macro FastOrStdCallWrapper 4
|
---|
93 | BEGINCODE
|
---|
94 | extern _g_pfnrt %+ %1
|
---|
95 | extern _g_pfnrt %+ %2
|
---|
96 | BEGINPROC_EXPORTED $@ %+ %1 %+ @ %+ %3
|
---|
97 | mov eax, [_g_pfnrt %+ %1]
|
---|
98 | cmp eax, 0
|
---|
99 | jnz .got_fast_call
|
---|
100 | mov eax, .stdcall_wrapper
|
---|
101 | mov [__imp_@ %+ %1 %+ @ %+ %3], eax
|
---|
102 |
|
---|
103 | .stdcall_wrapper:
|
---|
104 | push ebp
|
---|
105 | mov ebp, esp
|
---|
106 | %if %4 == 1
|
---|
107 | push dword 0
|
---|
108 | push esp
|
---|
109 | %else
|
---|
110 | push edx
|
---|
111 | %endif
|
---|
112 | push ecx
|
---|
113 | call [_g_pfnrt %+ %2]
|
---|
114 | %if %4 == 1
|
---|
115 | movzx eax, byte [ebp - 4]
|
---|
116 | %endif
|
---|
117 | leave
|
---|
118 | ret
|
---|
119 |
|
---|
120 | .got_fast_call:
|
---|
121 | mov [__imp_@ %+ %1 %+ @ %+ %3], eax
|
---|
122 | jmp eax
|
---|
123 | ENDPROC $@ %+ %1 %+ @ %+ %3
|
---|
124 |
|
---|
125 | BEGINDATA
|
---|
126 | GLOBALNAME __imp_@ %+ %1 %+ @ %+ %3
|
---|
127 | dd $@ %+ %1 %+ @ %+ %3
|
---|
128 | %endmacro
|
---|
129 |
|
---|
130 | FastOrStdCallWrapper IofCompleteRequest, IoCompleteRequest, 8, 0
|
---|
131 | FastOrStdCallWrapper IofCallDriver, IoCallDriver, 8, 0
|
---|
132 | FastOrStdCallWrapper ObfDereferenceObject, ObDereferenceObject, 4, 0
|
---|
133 | FastOrStdCallWrapper KfAcquireSpinLock, KeAcquireSpinLock, 4, 1
|
---|
134 | FastOrStdCallWrapper KfReleaseSpinLock, KeReleaseSpinLock, 8, 0
|
---|
135 | FastOrStdCallWrapper KfRaiseIrql, KeRaiseIrql, 4, 1
|
---|
136 | FastOrStdCallWrapper KfLowerIrql, KeLowerIrql, 4, 0
|
---|
137 | FastOrStdCallWrapper KefAcquireSpinLockAtDpcLevel, KeAcquireSpinLockAtDpcLevel, 4, 0
|
---|
138 | FastOrStdCallWrapper KefReleaseSpinLockFromDpcLevel,KeReleaseSpinLockFromDpcLevel, 4, 0
|
---|
139 |
|
---|
140 |
|
---|
141 | BEGINCODE
|
---|
142 | ; LONG FASTCALL InterlockedExchange(LONG volatile *,LONG );
|
---|
143 | BEGINPROC_EXPORTED $@InterlockedExchange@8
|
---|
144 | mov eax, edx
|
---|
145 | xchg [ecx], eax
|
---|
146 | ret
|
---|
147 |
|
---|
148 | BEGINDATA
|
---|
149 | GLOBALNAME __imp_@InterlockedExchange@8
|
---|
150 | dd $@InterlockedExchange@8
|
---|
151 |
|
---|
152 |
|
---|
153 | BEGINDATA
|
---|
154 | GLOBALNAME __imp__KeTickCount
|
---|
155 | GLOBALNAME _KeTickCount
|
---|
156 | dd 0
|
---|
157 |
|
---|