|
RDFU
1.0
|
Functions for gathering, parsing and finding handles and images. More...
#include "EfiScannerHeaders.h"
Go to the source code of this file.
Macros | |
| #define | check_flag(flag, text) if (HandleList->HandleEntry[i].Flags & flag) PRINT_FUNC_ASCII(text); WriteLogFile(text) |
| #define | check_modification(val1, val2, text) |
Functions | |
| VOID | GetHandleTypeStringAscii (CHAR8 *HandleTypeBuff, UINTN HandleTypeBuffSize, UINT16 Flags) |
| CHAR16 *EFIAPI | GetDevicePathTextForHandle (EFI_DEVICE_PATH_PROTOCOL *DevicePath) |
| EFI_STATUS | CloseLoadedImageProtocol (EFI_HANDLE Handle) |
| EFI_STATUS | GetLoadedImageProtocol (EFI_HANDLE Handle, EFI_LOADED_IMAGE_PROTOCOL **OutLoadedImage) |
| EFI_STATUS | GetAllHandles (EFI_HANDLE **OutHandles) |
| CHAR16 *EFIAPI | GetStringFromHandle2 (EFI_HANDLE Handle, CHAR8 *Language) |
| CHAR16 *EFIAPI | GetStringFromHandle (EFI_HANDLE Handle, CHAR8 *Language) |
| VOID | FreeHandles (handle_entry_list *HandleList) |
| handle_entry_list * | GetAllHandlesWithDescription (VOID) |
| EFI_STATUS | DumpAllHandles (handle_entry_list *HandleList) |
| VOID | GetImagePathAndName (image_entry *ImageEntry, EFI_HANDLE Handle, EFI_LOADED_IMAGE_PROTOCOL *LoadedImageProt) |
| image_entry * | AddImageToList (image_entry_list *ImageList, EFI_HANDLE Handle, EFI_LOADED_IMAGE_PROTOCOL *LoadedImageProt, BOOLEAN CalculateCrc) |
| image_entry_list * | GetAllImagesWithDescription (handle_entry_list *HandleList, BOOLEAN CalculateCrc) |
| image_entry * | FindImageByAddr (image_entry_list *ImageList, C_PTR Address) |
| image_entry * | FindImageByHandle (image_entry_list *ImageList, EFI_HANDLE Handle) |
| EFI_STATUS | DumpImageToDisk (image_entry *ImageEntry) |
| EFI_STATUS | DumpAllImages (image_entry_list *ImageList, BOOLEAN DumpToDisk) |
| EFI_STATUS | CheckImagesFunctionPointers (image_entry_list *ImageList) |
| VOID | FreeImages (image_entry_list *ImageList) |
| VOID | MyNewImageNotify (image_entry_list *OrgImageList, image_entry *NewImage) |
| VOID | MyModImageNotify (image_entry_list *OrgImageList, image_entry *NewImage) |
| VOID | MyNewEventCallback (event_entry_list *OrgEventList, event_entry *NewEvent) |
| VOID | TestDumpHandles (VOID) |
Variables | |
| EFI_DEVICE_PATH_TO_TEXT_PROTOCOL * | gDevPathToText |
Functions for gathering, parsing and finding handles and images.
From the Intel manuals:
Definition in file Images.c.
| #define check_flag | ( | flag, | |
| text | |||
| ) | if (HandleList->HandleEntry[i].Flags & flag) PRINT_FUNC_ASCII(text); WriteLogFile(text) |
| #define check_modification | ( | val1, | |
| val2, | |||
| text | |||
| ) |
Referenced by CheckImagesFunctionPointers().
| image_entry* AddImageToList | ( | image_entry_list * | ImageList, |
| EFI_HANDLE | Handle, | ||
| EFI_LOADED_IMAGE_PROTOCOL * | LoadedImageProt, | ||
| BOOLEAN | CalculateCrc | ||
| ) |
Function creates the new ImageEntry list (based on the old one) it also adds one new image entry to it.
| ImageList | Pointer to selected ImageEntry |
| Handle | Image handle |
| LoadedImageProt | Pointer to openned LOADED_IMAGE_PROTOCOL |
| CalculateCrc | Indicates whether function should calculate the crc32 value of the image code. |
| image_entry* | On success a pointer to newly created image_entry is returned |
| NULL | On error |
Definition at line 642 of file Images.c.
References _image_entry::Crc32, GetImagePathAndName(), GetPECodeChecksum(), _image_entry::Handle, _image_entry::ImageBase, _image_entry_list::ImageEntry, _image_entry::ImageSize, _image_entry::LoadedImageProtocol, MemAllocate(), MemCopy(), MemFree(), and _image_entry_list::NumOfEntries.
Referenced by hooked_LoadImage().


| EFI_STATUS CheckImagesFunctionPointers | ( | image_entry_list * | ImageList | ) |
Function enumerates the entire image list and it checks whether pointers to RuntimeServices, BootServices and SystemTables are different across different images. Everything is reported to the screen, log file or serial port depending on the framework policy.
| ImageList | Pointer to image list |
| EFI_SUCCESS | On success |
| EFI_ERROR* | On error |
Definition at line 961 of file Images.c.
References check_modification, _image_entry::Crc32, _image_entry::FilePath, _image_entry::Handle, _image_entry::ImageBase, _image_entry_list::ImageEntry, _image_entry::ImageSize, _image_entry::LoadedImageProtocol, LogFullAscii(), _image_entry::Name, and _image_entry_list::NumOfEntries.
Referenced by DrawBoxAndMenu(), and TestDumpHandles().


| EFI_STATUS CloseLoadedImageProtocol | ( | EFI_HANDLE | Handle | ) |
Function closes the previously opended LoadedImageProtocol for specified handle.
| Handle | Specified handle |
| EFI_SUCCESS | On success |
| EFI_ERROR* | On error |
Definition at line 124 of file Images.c.
References EFI_STATUS(), and gImageHandle.
Referenced by FreeImages().


| EFI_STATUS DumpAllHandles | ( | handle_entry_list * | HandleList | ) |
Function enumarates and dumps all handles found in the handle list. The output is shown on the screen, written to the log file or serial port depending on the current library policy.
| HandleList | Pointer to the handle list gathered from GetAllHandlesWithDescription function |
| EFI_SUCCESS | On success |
| EFI_ERROR* | On error |
Definition at line 530 of file Images.c.
References _handle_entry::Flags, GetHandleTypeStringAscii(), _handle_entry::Handle, _handle_entry_list::HandleEntry, LogFullAscii(), and _handle_entry_list::NumOfEntries.
Referenced by DrawBoxAndMenu(), and TestDumpHandles().


| EFI_STATUS DumpAllImages | ( | image_entry_list * | ImageList, |
| BOOLEAN | DumpToDisk | ||
| ) |
Function dumps all image on the ImageList either just to screen or to disk also (to "dump\ImageBase.dmp")
| ImageList | Pointer to image list |
| DumpToDisk | Indicates whether images will be dumped to disk or not |
| EFI_SUCCESS | On success |
| EFI_ERROR* | On error |
Definition at line 906 of file Images.c.
References _image_entry::Crc32, DumpImageToDisk(), _image_entry::FilePath, _image_entry::Handle, _image_entry::ImageBase, _image_entry_list::ImageEntry, _image_entry::ImageSize, LogFullAscii(), _image_entry::Name, and _image_entry_list::NumOfEntries.
Referenced by CommandDriverInfo(), DrawBoxAndMenu(), and TestDumpHandles().


| EFI_STATUS DumpImageToDisk | ( | image_entry * | ImageEntry | ) |
Function dumps selected image to disk (to "dump\ImageBase.dmp")
| ImageEntry | Pointer to the image entry which will be dumped |
| EFI_SUCCESS | On success |
| EFI_ERROR* | On error |
Definition at line 869 of file Images.c.
References DumpMemoryToFile(), _image_entry::ImageBase, _image_entry::ImageSize, and LogFullAscii().
Referenced by DumpAllImages().


| image_entry* FindImageByAddr | ( | image_entry_list * | ImageList, |
| C_PTR | Address | ||
| ) |
Function finds image entry in the image list by address. Function checks if the selected address points somewhere inside the image body.
| ImageList | Pointer to the image list gathered from GetAllImagesWithDescription function |
| Address | Address of wanted image (doesn't have to be exact image base) |
| Pointer | On success function returns pointer to the located image_entry |
| NULL | On error |
Definition at line 804 of file Images.c.
References _image_entry::ImageBase, _image_entry_list::ImageEntry, _image_entry::ImageSize, and _image_entry_list::NumOfEntries.
Referenced by BruteFind_gEventSignalQueueAddr(), CommandDriverInfo(), DumpAllEvents(), DumpEFITables(), and ScanMemoryForExecutables().

| image_entry* FindImageByHandle | ( | image_entry_list * | ImageList, |
| EFI_HANDLE | Handle | ||
| ) |
Function finds image entry in the image list by handle value
| ImageList | Pointer to the image list gathered from GetAllImagesWithDescription function |
| Handle | Value of wanted handle |
| Pointer | On success function returns pointer to the located image_entry |
| NULL | On error |
Definition at line 838 of file Images.c.
References _image_entry::Handle, _image_entry_list::ImageEntry, and _image_entry_list::NumOfEntries.
Referenced by NotifyExitBootServices().

| VOID FreeHandles | ( | handle_entry_list * | HandleList | ) |
Function frees the handle list
| HandleList | Pointer to the handle list gathered from GetAllHandlesWithDescription function |
| NONE |
Definition at line 400 of file Images.c.
References _handle_entry_list::HandleEntry, and MemFree().
Referenced by DrawBoxAndMenu(), GetAllImagesWithDescription(), and TestDumpHandles().


| VOID FreeImages | ( | image_entry_list * | ImageList | ) |
Function frees the image list
| ImageList | Pointer to the image list gathered from GetAllImagesWithDescription function |
| NONE |
Definition at line 1051 of file Images.c.
References CloseLoadedImageProtocol(), _image_entry::Handle, _image_entry_list::ImageEntry, _image_entry::LoadedImageProtocol, MemFree(), and _image_entry_list::NumOfEntries.
Referenced by BruteFind_gEventSignalQueueAddr(), CommandDriverInfo(), DrawBoxAndMenu(), DumpAllEvents(), InstallSniffImage(), NotifyExitBootServices(), ScanMemoryForExecutables(), TestDumpHandles(), and UnInstallSniffImage().


| EFI_STATUS GetAllHandles | ( | EFI_HANDLE ** | OutHandles | ) |
Function gets all system handles and writes them to the allocated memory. Pointer to this allocated memory with handles list is returned in OutHandles variable. (last entry is null)
| OutHandles | Returned pointer to system handles list |
| EFI_SUCCESS | On success |
| EFI_ERROR* | On error |
Definition at line 195 of file Images.c.
References EFI_STATUS(), LogFullAscii(), MemAllocate(), and MemFree().
Referenced by GetAllHandlesWithDescription().


| handle_entry_list* GetAllHandlesWithDescription | ( | VOID | ) |
Function is responsible for gathering all system handles. Requestor is responsible for deallocating the memory through FreeHandles function.
| Pointer | On success pointer to handle_entry_list |
| NULL | On error |
Definition at line 419 of file Images.c.
References EFI_STATUS(), GetAllHandles(), _handle_entry::Handle, _handle_entry_list::HandleEntry, LogFullAscii(), MemAllocate(), MemFree(), _handle_entry_list::NumOfEntries, setHANDLE_TYPE_COMPONENT_NAME_HANDLE(), setHANDLE_TYPE_DEVICE_HANDLE(), setHANDLE_TYPE_DRIVER_BINDING_HANDLE(), setHANDLE_TYPE_DRIVER_CONFIGURATION_HANDLE(), setHANDLE_TYPE_DRIVER_DIAGNOSTICS_HANDLE(), and setHANDLE_TYPE_IMAGE_HANDLE().
Referenced by DrawBoxAndMenu(), GetAllImagesWithDescription(), and TestDumpHandles().


| image_entry_list* GetAllImagesWithDescription | ( | handle_entry_list * | HandleList, |
| BOOLEAN | CalculateCrc | ||
| ) |
Function creates the image list based on the system handles. Requestor is responsible for deallocating the memory through FreeImages function.
| HandleList | Pointer to handle list (can be null) |
| CalculateCrc | Indicates whether function should calculate the crc32 value of the image code. |
| image_entry_list* | On success a pointer to created image_entry_list |
| NULL | On error |
Definition at line 701 of file Images.c.
References _image_entry::Crc32, EFI_STATUS(), FreeHandles(), GetAllHandlesWithDescription(), GetImagePathAndName(), GetLoadedImageProtocol(), GetPECodeChecksum(), _handle_entry::Handle, _image_entry::Handle, _handle_entry_list::HandleEntry, _image_entry::ImageBase, _image_entry_list::ImageEntry, _image_entry::ImageSize, _image_entry::LoadedImageProtocol, MAX_IMAGE_TEXTBUFF_LEN, MemAllocate(), MemFree(), _handle_entry_list::NumOfEntries, and _image_entry_list::NumOfEntries.
Referenced by BruteFind_gEventSignalQueueAddr(), CommandDriverInfo(), DrawBoxAndMenu(), DumpAllEvents(), DumpEFITables(), InstallSniffImage(), NotifyExitBootServices(), ScanMemoryForExecutables(), and TestDumpHandles().


| CHAR16* EFIAPI GetDevicePathTextForHandle | ( | EFI_DEVICE_PATH_PROTOCOL * | DevicePath | ) |
Function converts DevicePath to text. (caller needs to free the allocated memory)
| DevicePath |
| CHAR16* | Pointer to unicode path |
Definition at line 86 of file Images.c.
References EFI_STATUS(), and gDevPathToText.
Referenced by GetImagePathAndName(), and GetLoadedImageProtocol().


| VOID GetHandleTypeStringAscii | ( | CHAR8 * | HandleTypeBuff, |
| UINTN | HandleTypeBuffSize, | ||
| UINT16 | Flags | ||
| ) |
Function converts HandleType to text representation.
| HandleTypeBuff | Pointer to output buffer |
| HandleTypeBuffSize | Size of the output buffer |
| Flags | Value of the selected handle type |
| NONE |
Definition at line 39 of file Images.c.
References isHANDLE_TYPE_BUS_DRIVER(), isHANDLE_TYPE_CHILD_HANDLE(), isHANDLE_TYPE_COMPONENT_NAME_HANDLE(), isHANDLE_TYPE_CONTROLLER_HANDLE(), isHANDLE_TYPE_DEVICE_DRIVER(), isHANDLE_TYPE_DEVICE_HANDLE(), isHANDLE_TYPE_DRIVER_BINDING_HANDLE(), isHANDLE_TYPE_DRIVER_CONFIGURATION_HANDLE(), isHANDLE_TYPE_DRIVER_DIAGNOSTICS_HANDLE(), isHANDLE_TYPE_IMAGE_HANDLE(), isHANDLE_TYPE_PARENT_HANDLE(), and isHANDLE_TYPE_UNKNOWN().
Referenced by DumpAllHandles().


| VOID GetImagePathAndName | ( | image_entry * | ImageEntry, |
| EFI_HANDLE | Handle, | ||
| EFI_LOADED_IMAGE_PROTOCOL * | LoadedImageProt | ||
| ) |
Function get path and file name associated with selected image entry. Both path and file name will be stored to the ImageEntry structure.
| ImageEntry | Pointer to selected ImageEntry |
| Handle | Image handle |
| LoadedImageProt | Pointer to openned LOADED_IMAGE_PROTOCOL |
| NONE |
Definition at line 590 of file Images.c.
References _image_entry::FilePath, GetDevicePathTextForHandle(), GetStringFromHandle(), MAX_IMAGE_TEXTBUFF_LEN, MemFree(), and _image_entry::Name.
Referenced by AddImageToList(), and GetAllImagesWithDescription().


| EFI_STATUS GetLoadedImageProtocol | ( | EFI_HANDLE | Handle, |
| EFI_LOADED_IMAGE_PROTOCOL ** | OutLoadedImage | ||
| ) |
Function returns pointer to EFI_LOADED_IMAGE_PROTOCOL for specified Handle. HandleProtocol queries a handle to determine if it supports a specified protocol.
| Handle | Specified handle |
| OutLoadedImage | Pointer to variable that will hold the EFI_LOADED_IMAGE_PROTOCOL |
| EFI_SUCCESS | On success |
| EFI_ERROR* | On error |
Definition at line 151 of file Images.c.
References EFI_STATUS(), GetDevicePathTextForHandle(), and LogFullAscii().
Referenced by GetAllImagesWithDescription(), and hooked_LoadImage().


| CHAR16* EFIAPI GetStringFromHandle | ( | EFI_HANDLE | Handle, |
| CHAR8 * | Language | ||
| ) |
Function tries to get the name associated with handle through the component name2 protocol and component name protocol. Selected handle needs to support it.
| Handle | Specified handle |
| Language | Ascii string defining the language ("en") |
| Pointer | On success pointer to unicode name |
| NULL | On error |
Definition at line 328 of file Images.c.
References EFI_STATUS(), gImageHandle, and LogFullAscii().
Referenced by GetImagePathAndName().


| CHAR16* EFIAPI GetStringFromHandle2 | ( | EFI_HANDLE | Handle, |
| CHAR8 * | Language | ||
| ) |
Function tries to get the name associated with handle through the component name protocol. Selected handle needs to support it.
| Handle | Specified handle |
| Language | Ascii string defining the language ("en") |
| Pointer | On success pointer to unicode name |
| NULL | On error |
Definition at line 267 of file Images.c.
References EFI_STATUS(), gImageHandle, and LogFullAscii().

| VOID MyModImageNotify | ( | image_entry_list * | OrgImageList, |
| image_entry * | NewImage | ||
| ) |
Definition at line 1082 of file Images.c.
References _image_entry::FilePath, LogFileAscii(), and _image_entry::Name.
Referenced by TestDumpHandles().


| VOID MyNewEventCallback | ( | event_entry_list * | OrgEventList, |
| event_entry * | NewEvent | ||
| ) |
Definition at line 1089 of file Images.c.
References LogFileAscii().
Referenced by TestDumpHandles().


| VOID MyNewImageNotify | ( | image_entry_list * | OrgImageList, |
| image_entry * | NewImage | ||
| ) |
Definition at line 1074 of file Images.c.
References _image_entry::FilePath, LogFileAscii(), and _image_entry::Name.
Referenced by TestDumpHandles().


| VOID TestDumpHandles | ( | VOID | ) |
Definition at line 1097 of file Images.c.
References CheckImagesFunctionPointers(), ContextX64Test(), DumpAllEvents(), DumpAllHandles(), DumpAllImages(), DumpGDT(), DumpIDT(), FreeHandles(), FreeImages(), GetAllEvents(), GetAllHandlesWithDescription(), GetAllImagesWithDescription(), InstallEventScanner(), InstallSniffImage(), MyModImageNotify(), MyNewEventCallback(), MyNewImageNotify(), PRINT_FUNC, ScanMemoryForExecutables(), and ScreenShowSplashLogo().

| EFI_DEVICE_PATH_TO_TEXT_PROTOCOL* gDevPathToText |
global variable that hold the DEVICE_PATH_TO_TEXT protocol pointer.
Definition at line 24 of file Images.c.
Referenced by GetDevicePathTextForHandle().