TianoCore EDK2 master
Loading...
Searching...
No Matches
WinHost.c File Reference
#include "WinHost.h"

Go to the source code of this file.

Data Structures

struct  PDB_NAME_TO_MOD_HANDLE
 

Macros

#define SE_TIME_ZONE_NAME   TEXT("SeTimeZonePrivilege")
 
#define MAX_PDB_NAME_TO_MOD_HANDLE_ARRAY_SIZE   0x100
 

Functions

EFI_STATUS WinPeiAutoScan (IN UINTN Index, OUT EFI_PHYSICAL_ADDRESS *MemoryBase, OUT UINT64 *MemorySize)
 
EFI_STATUS WinFdAddress (IN UINTN Index, IN OUT EFI_PHYSICAL_ADDRESS *FdBase, IN OUT UINT64 *FdSize, IN OUT EFI_PHYSICAL_ADDRESS *FixUp)
 
VOID * WinThunk (VOID)
 
VOID SecPrint (CHAR8 *Format,...)
 
VOID EFIAPI WinReset (IN EFI_RESET_TYPE ResetType, IN EFI_STATUS ResetStatus, IN UINTN DataSize, IN VOID *ResetData OPTIONAL)
 
BOOLEAN EfiSystemMemoryRange (IN VOID *MemoryAddress)
 
EFI_STATUS WinNtOpenFile (IN CHAR16 *FileName OPTIONAL, IN UINT32 MapSize, IN DWORD CreationDisposition, IN OUT VOID **BaseAddress, OUT UINTN *Length)
 
INTN EFIAPI main (IN INT Argc, IN CHAR8 **Argv, IN CHAR8 **Envp)
 
VOID SecLoadSecCore (IN UINTN TemporaryRam, IN UINTN TemporaryRamSize, IN VOID *BootFirmwareVolumeBase, IN UINTN BootFirmwareVolumeSize, IN VOID *SecCorePe32File)
 
RETURN_STATUS EFIAPI SecPeCoffGetEntryPoint (IN VOID *Pe32Data, IN OUT VOID **EntryPoint)
 
EFI_STATUS EFIAPI SecImageRead (IN VOID *FileHandle, IN UINTN FileOffset, IN OUT UINTN *ReadSize, OUT VOID *Buffer)
 
CHAR16 * AsciiToUnicode (IN CHAR8 *Ascii, IN UINTN *StrLen OPTIONAL)
 
UINTN CountSeparatorsInString (IN CONST CHAR16 *String, IN CHAR16 Separator)
 
EFI_STATUS AddModHandle (IN PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext, IN VOID *ModHandle)
 
VOID * RemoveModHandle (IN PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext)
 
VOID EFIAPI PeCoffLoaderRelocateImageExtraAction (IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext)
 
VOID EFIAPI PeCoffLoaderUnloadImageExtraAction (IN PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext)
 
VOID _ModuleEntryPoint (VOID)
 

Variables

PDB_NAME_TO_MOD_HANDLEmPdbNameModHandleArray = NULL
 
UINTN mPdbNameModHandleArraySize = 0
 
UINTN gFdInfoCount = 0
 
NT_FD_INFOgFdInfo
 
UINTN gSystemMemoryCount = 0
 
NT_SYSTEM_MEMORYgSystemMemory
 
BASE_LIBRARY_JUMP_BUFFER mResetJumpBuffer
 
CHAR8 * mResetTypeStr []
 
EMU_THUNK_PPI mSecEmuThunkPpi
 
EFI_PEI_RESET2_PPI mEmuReset2Ppi
 

Detailed Description

WinNt emulator of pre-SEC phase. It's really a Win32 application, but this is Ok since all the other modules for NT32 are NOT Win32 applications.

This program gets NT32 PCD setting and figures out what the memory layout will be, how may FD's will be loaded and also what the boot mode is.

This code produces 128 K of temporary memory for the SEC stack by directly allocate memory space with ReadWrite and Execute attribute.

Copyright (c) 2006 - 2022, Intel Corporation. All rights reserved.
(C) Copyright 2016-2020 Hewlett Packard Enterprise Development LP
SPDX-License-Identifier: BSD-2-Clause-Patent

Definition in file WinHost.c.

Macro Definition Documentation

◆ MAX_PDB_NAME_TO_MOD_HANDLE_ARRAY_SIZE

#define MAX_PDB_NAME_TO_MOD_HANDLE_ARRAY_SIZE   0x100

Definition at line 25 of file WinHost.c.

◆ SE_TIME_ZONE_NAME

#define SE_TIME_ZONE_NAME   TEXT("SeTimeZonePrivilege")

Definition at line 19 of file WinHost.c.

Function Documentation

◆ _ModuleEntryPoint()

VOID _ModuleEntryPoint ( VOID  )

Definition at line 1169 of file WinHost.c.

◆ AddModHandle()

EFI_STATUS AddModHandle ( IN PE_COFF_LOADER_IMAGE_CONTEXT ImageContext,
IN VOID *  ModHandle 
)

Store the ModHandle in an array indexed by the Pdb File name. The ModHandle is needed to unload the image.

Parameters
ImageContext- Input data returned from PE Laoder Library. Used to find the .PDB file name of the PE Image.
ModHandle- Returned from LoadLibraryEx() and stored for call to FreeLibrary().

@return return EFI_SUCCESS when ModHandle was stored.

Definition at line 953 of file WinHost.c.

◆ AsciiToUnicode()

CHAR16 * AsciiToUnicode ( IN CHAR8 *  Ascii,
IN UINTN *StrLen  OPTIONAL 
)

Definition at line 865 of file WinHost.c.

◆ CountSeparatorsInString()

UINTN CountSeparatorsInString ( IN CONST CHAR16 *  String,
IN CHAR16  Separator 
)

Definition at line 913 of file WinHost.c.

◆ EfiSystemMemoryRange()

BOOLEAN EfiSystemMemoryRange ( IN VOID *  MemoryAddress)

Definition at line 280 of file WinHost.c.

◆ main()

INTN EFIAPI main ( IN INT  Argc,
IN CHAR8 **  Argv,
IN CHAR8 **  Envp 
)

Definition at line 412 of file WinHost.c.

◆ PeCoffLoaderRelocateImageExtraAction()

VOID EFIAPI PeCoffLoaderRelocateImageExtraAction ( IN OUT PE_COFF_LOADER_IMAGE_CONTEXT ImageContext)

Performs additional actions after a PE/COFF image has been loaded and relocated.

If ImageContext is NULL, then ASSERT().

Parameters
ImageContextPointer to the image context structure that describes the PE/COFF image that has already been loaded and relocated.

Definition at line 1061 of file WinHost.c.

◆ PeCoffLoaderUnloadImageExtraAction()

VOID EFIAPI PeCoffLoaderUnloadImageExtraAction ( IN PE_COFF_LOADER_IMAGE_CONTEXT ImageContext)

Definition at line 1151 of file WinHost.c.

◆ RemoveModHandle()

VOID * RemoveModHandle ( IN PE_COFF_LOADER_IMAGE_CONTEXT ImageContext)

Return the ModHandle and delete the entry in the array.

Parameters
ImageContext- Input data returned from PE Laoder Library. Used to find the .PDB file name of the PE Image.
Returns
ModHandle - ModHandle assoicated with ImageContext is returned NULL - No ModHandle associated with ImageContext

Definition at line 1030 of file WinHost.c.

◆ SecImageRead()

EFI_STATUS EFIAPI SecImageRead ( IN VOID *  FileHandle,
IN UINTN  FileOffset,
IN OUT UINTN ReadSize,
OUT VOID *  Buffer 
)

Definition at line 827 of file WinHost.c.

◆ SecLoadSecCore()

VOID SecLoadSecCore ( IN UINTN  TemporaryRam,
IN UINTN  TemporaryRamSize,
IN VOID *  BootFirmwareVolumeBase,
IN UINTN  BootFirmwareVolumeSize,
IN VOID *  SecCorePe32File 
)

Definition at line 693 of file WinHost.c.

◆ SecPeCoffGetEntryPoint()

RETURN_STATUS EFIAPI SecPeCoffGetEntryPoint ( IN VOID *  Pe32Data,
IN OUT VOID **  EntryPoint 
)

Definition at line 787 of file WinHost.c.

◆ SecPrint()

VOID SecPrint ( CHAR8 *  Format,
  ... 
)

Definition at line 182 of file WinHost.c.

◆ WinFdAddress()

EFI_STATUS WinFdAddress ( IN UINTN  Index,
IN OUT EFI_PHYSICAL_ADDRESS FdBase,
IN OUT UINT64 *  FdSize,
IN OUT EFI_PHYSICAL_ADDRESS FixUp 
)

Definition at line 122 of file WinHost.c.

◆ WinNtOpenFile()

EFI_STATUS WinNtOpenFile ( IN CHAR16 *FileName  OPTIONAL,
IN UINT32  MapSize,
IN DWORD  CreationDisposition,
IN OUT VOID **  BaseAddress,
OUT UINTN Length 
)

Definition at line 300 of file WinHost.c.

◆ WinPeiAutoScan()

EFI_STATUS WinPeiAutoScan ( IN UINTN  Index,
OUT EFI_PHYSICAL_ADDRESS MemoryBase,
OUT UINT64 *  MemorySize 
)

Definition at line 88 of file WinHost.c.

◆ WinReset()

VOID EFIAPI WinReset ( IN EFI_RESET_TYPE  ResetType,
IN EFI_STATUS  ResetStatus,
IN UINTN  DataSize,
IN VOID *ResetData  OPTIONAL 
)

Resets the entire platform.

Parameters
[in]ResetTypeThe type of reset to perform.
[in]ResetStatusThe status code for the reset.
[in]DataSizeThe size, in bytes, of ResetData.
[in]ResetDataFor a ResetType of EfiResetCold, EfiResetWarm, or EfiResetShutdown the data buffer starts with a Null-terminated string, optionally followed by additional binary data. The string is a description that the caller may use to further indicate the reason for the system reset.

Definition at line 222 of file WinHost.c.

◆ WinThunk()

VOID * WinThunk ( VOID  )

Definition at line 168 of file WinHost.c.

Variable Documentation

◆ gFdInfo

NT_FD_INFO* gFdInfo

Definition at line 48 of file WinHost.c.

◆ gFdInfoCount

UINTN gFdInfoCount = 0

Definition at line 47 of file WinHost.c.

◆ gSystemMemory

NT_SYSTEM_MEMORY* gSystemMemory

Definition at line 57 of file WinHost.c.

◆ gSystemMemoryCount

UINTN gSystemMemoryCount = 0

Definition at line 56 of file WinHost.c.

◆ mEmuReset2Ppi

EFI_PEI_RESET2_PPI mEmuReset2Ppi
Initial value:
= {
}
VOID EFIAPI WinReset(IN EFI_RESET_TYPE ResetType, IN EFI_STATUS ResetStatus, IN UINTN DataSize, IN VOID *ResetData OPTIONAL)
Definition: WinHost.c:222

Definition at line 256 of file WinHost.c.

◆ mPdbNameModHandleArray

PDB_NAME_TO_MOD_HANDLE* mPdbNameModHandleArray = NULL

Definition at line 38 of file WinHost.c.

◆ mPdbNameModHandleArraySize

UINTN mPdbNameModHandleArraySize = 0

Definition at line 39 of file WinHost.c.

◆ mResetJumpBuffer

BASE_LIBRARY_JUMP_BUFFER mResetJumpBuffer

Definition at line 59 of file WinHost.c.

◆ mResetTypeStr

CHAR8* mResetTypeStr[]
Initial value:
= {
"EfiResetCold",
"EfiResetWarm",
"EfiResetShutdown",
"EfiResetPlatformSpecific"
}

Definition at line 60 of file WinHost.c.

◆ mSecEmuThunkPpi

EMU_THUNK_PPI mSecEmuThunkPpi
Initial value:
= {
WinPeiAutoScan,
WinFdAddress,
WinThunk
}

Definition at line 175 of file WinHost.c.