Fix VS 2005 compatibility issue
[mirror_edk2.git] / EdkNt32Pkg / Sec / WinNtThunk.c
1 /*++
2
3 Copyright (c) 2006, Intel Corporation
4 All rights reserved. This program and the accompanying materials
5 are licensed and made available under the terms and conditions of the BSD License
6 which accompanies this distribution. The full text of the license may be found at
7 http://opensource.org/licenses/bsd-license.php
8
9 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
11
12 Module Name:
13
14 WinNtThunk.c
15
16 Abstract:
17
18 Since the SEC is the only windows program in our emulation we
19 must use a Tiano mechanism to export Win32 APIs to other modules.
20 This is the role of the EFI_WIN_NT_THUNK_PROTOCOL.
21
22 The mWinNtThunkTable exists so that a change to EFI_WIN_NT_THUNK_PROTOCOL
23 will cause an error in initializing the array if all the member functions
24 are not added. It looks like adding a element to end and not initializing
25 it may cause the table to be initaliized with the members at the end being
26 set to zero. This is bad as jumping to zero will case the NT32 to crash.
27
28 All the member functions in mWinNtThunkTable are Win32
29 API calls, so please reference Microsoft documentation.
30
31
32 gWinNt is a a public exported global that contains the initialized
33 data.
34
35 --*/
36
37 #include "SecMain.h"
38
39 //
40 // This pragma is needed for all the DLL entry points to be asigned to the array.
41 // if warning 4232 is not dissabled a warning will be generated as a DLL entry
42 // point could be modified dynamically. The SEC does not do that, so we must
43 // disable the warning so we can compile the SEC. The previous method was to
44 // asign each element in code. The disadvantage to that approach is it's harder
45 // to tell if all the elements have been initailized properly.
46 //
47 #pragma warning(disable : 4232)
48 #pragma warning(disable : 4996)
49
50 EFI_WIN_NT_THUNK_PROTOCOL mWinNtThunkTable = {
51 EFI_WIN_NT_THUNK_PROTOCOL_SIGNATURE,
52 GetProcAddress,
53 GetTickCount,
54 LoadLibraryEx,
55 FreeLibrary,
56 SetPriorityClass,
57 SetThreadPriority,
58 Sleep,
59 SuspendThread,
60 GetCurrentThread,
61 GetCurrentThreadId,
62 GetCurrentProcess,
63 CreateThread,
64 TerminateThread,
65 SendMessage,
66 ExitThread,
67 ResumeThread,
68 DuplicateHandle,
69 InitializeCriticalSection,
70 EnterCriticalSection,
71 LeaveCriticalSection,
72 DeleteCriticalSection,
73 TlsAlloc,
74 TlsFree,
75 TlsSetValue,
76 TlsGetValue,
77 CreateSemaphore,
78 WaitForSingleObject,
79 ReleaseSemaphore,
80 CreateConsoleScreenBuffer,
81 FillConsoleOutputAttribute,
82 FillConsoleOutputCharacter,
83 GetConsoleCursorInfo,
84 GetNumberOfConsoleInputEvents,
85 PeekConsoleInput,
86 ScrollConsoleScreenBuffer,
87 ReadConsoleInput,
88 SetConsoleActiveScreenBuffer,
89 SetConsoleCursorInfo,
90 SetConsoleCursorPosition,
91 SetConsoleScreenBufferSize,
92 SetConsoleTitleW,
93 WriteConsoleInput,
94 WriteConsoleOutput,
95 CreateFile,
96 DeviceIoControl,
97 CreateDirectory,
98 RemoveDirectory,
99 GetFileAttributes,
100 SetFileAttributes,
101 CreateFileMapping,
102 CloseHandle,
103 DeleteFile,
104 FindFirstFile,
105 FindNextFile,
106 FindClose,
107 FlushFileBuffers,
108 GetEnvironmentVariable,
109 GetLastError,
110 SetErrorMode,
111 GetStdHandle,
112 MapViewOfFileEx,
113 ReadFile,
114 SetEndOfFile,
115 SetFilePointer,
116 WriteFile,
117 GetFileInformationByHandle,
118 GetDiskFreeSpace,
119 GetDiskFreeSpaceEx,
120 MoveFile,
121 SetFileTime,
122 SystemTimeToFileTime,
123 FileTimeToLocalFileTime,
124 FileTimeToSystemTime,
125 GetSystemTime,
126 SetSystemTime,
127 GetLocalTime,
128 SetLocalTime,
129 GetTimeZoneInformation,
130 SetTimeZoneInformation,
131 timeSetEvent,
132 timeKillEvent,
133 ClearCommError,
134 EscapeCommFunction,
135 GetCommModemStatus,
136 GetCommState,
137 SetCommState,
138 PurgeComm,
139 SetCommTimeouts,
140 ExitProcess,
141 _snwprintf,
142 GetDesktopWindow,
143 GetForegroundWindow,
144 CreateWindowEx,
145 ShowWindow,
146 UpdateWindow,
147 DestroyWindow,
148 InvalidateRect,
149 GetWindowDC,
150 GetClientRect,
151 AdjustWindowRect,
152 SetDIBitsToDevice,
153 BitBlt,
154 GetDC,
155 ReleaseDC,
156 RegisterClassEx,
157 UnregisterClass,
158 BeginPaint,
159 EndPaint,
160 PostQuitMessage,
161 DefWindowProc,
162 LoadIcon,
163 LoadCursor,
164 GetStockObject,
165 SetViewportOrgEx,
166 SetWindowOrgEx,
167 MoveWindow,
168 GetWindowRect,
169 GetMessage,
170 TranslateMessage,
171 DispatchMessage,
172 GetProcessHeap,
173 HeapAlloc,
174 HeapFree
175 };
176
177 #pragma warning(default : 4996)
178 #pragma warning(default : 4232)
179
180 EFI_WIN_NT_THUNK_PROTOCOL *gWinNt = &mWinNtThunkTable;