Home | History | Annotate | Download | only in Sec
      1 /**@file
      2 
      3 Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>
      4 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 #if __INTEL_COMPILER
     51 #pragma warning ( disable : 144 )
     52 #endif
     53 
     54 EFI_WIN_NT_THUNK_PROTOCOL mWinNtThunkTable = {
     55   EFI_WIN_NT_THUNK_PROTOCOL_SIGNATURE,
     56   GetProcAddress,
     57   GetTickCount,
     58   LoadLibraryEx,
     59   FreeLibrary,
     60   SetPriorityClass,
     61   SetThreadPriority,
     62   Sleep,
     63   SuspendThread,
     64   GetCurrentThread,
     65   GetCurrentThreadId,
     66   GetCurrentProcess,
     67   CreateThread,
     68   TerminateThread,
     69   SendMessage,
     70   ExitThread,
     71   ResumeThread,
     72   DuplicateHandle,
     73   InitializeCriticalSection,
     74   EnterCriticalSection,
     75   LeaveCriticalSection,
     76   DeleteCriticalSection,
     77   TlsAlloc,
     78   TlsFree,
     79   TlsSetValue,
     80   TlsGetValue,
     81   CreateSemaphore,
     82   WaitForSingleObject,
     83   ReleaseSemaphore,
     84   CreateConsoleScreenBuffer,
     85   FillConsoleOutputAttribute,
     86   FillConsoleOutputCharacter,
     87   GetConsoleCursorInfo,
     88   GetNumberOfConsoleInputEvents,
     89   PeekConsoleInput,
     90   ScrollConsoleScreenBuffer,
     91   ReadConsoleInput,
     92   SetConsoleActiveScreenBuffer,
     93   SetConsoleCursorInfo,
     94   SetConsoleCursorPosition,
     95   SetConsoleScreenBufferSize,
     96   SetConsoleTitleW,
     97   WriteConsoleInput,
     98   WriteConsoleOutput,
     99   CreateFile,
    100   DeviceIoControl,
    101   CreateDirectory,
    102   RemoveDirectory,
    103   GetFileAttributes,
    104   SetFileAttributes,
    105   CreateFileMapping,
    106   CloseHandle,
    107   DeleteFile,
    108   FindFirstFile,
    109   FindNextFile,
    110   FindClose,
    111   FlushFileBuffers,
    112   GetEnvironmentVariable,
    113   GetLastError,
    114   SetErrorMode,
    115   GetStdHandle,
    116   MapViewOfFileEx,
    117   ReadFile,
    118   SetEndOfFile,
    119   SetFilePointer,
    120   WriteFile,
    121   GetFileInformationByHandle,
    122   GetDiskFreeSpace,
    123   GetDiskFreeSpaceEx,
    124   MoveFile,
    125   SetFileTime,
    126   SystemTimeToFileTime,
    127   LocalFileTimeToFileTime,
    128   FileTimeToLocalFileTime,
    129   FileTimeToSystemTime,
    130   GetSystemTime,
    131   SetSystemTime,
    132   GetLocalTime,
    133   SetLocalTime,
    134   GetTimeZoneInformation,
    135   SetTimeZoneInformation,
    136   timeSetEvent,
    137   timeKillEvent,
    138   ClearCommError,
    139   EscapeCommFunction,
    140   GetCommModemStatus,
    141   GetCommState,
    142   SetCommState,
    143   PurgeComm,
    144   SetCommTimeouts,
    145   ExitProcess,
    146   _snwprintf,
    147   GetDesktopWindow,
    148   GetForegroundWindow,
    149   CreateWindowEx,
    150   ShowWindow,
    151   UpdateWindow,
    152   DestroyWindow,
    153   InvalidateRect,
    154   GetWindowDC,
    155   GetClientRect,
    156   AdjustWindowRect,
    157   SetDIBitsToDevice,
    158   BitBlt,
    159   GetDC,
    160   ReleaseDC,
    161   RegisterClassEx,
    162   UnregisterClass,
    163   BeginPaint,
    164   EndPaint,
    165   PostQuitMessage,
    166   DefWindowProc,
    167   LoadIcon,
    168   LoadCursor,
    169   GetStockObject,
    170   SetViewportOrgEx,
    171   SetWindowOrgEx,
    172   MoveWindow,
    173   GetWindowRect,
    174   GetMessage,
    175   TranslateMessage,
    176   DispatchMessage,
    177   GetProcessHeap,
    178   HeapAlloc,
    179   HeapFree,
    180   QueryPerformanceCounter,
    181   QueryPerformanceFrequency
    182 };
    183 
    184 #pragma warning(default : 4996)
    185 #pragma warning(default : 4232)
    186 
    187 EFI_WIN_NT_THUNK_PROTOCOL *gWinNt = &mWinNtThunkTable;
    188