2011年6月28日 星期二

Device Path and Image Information of the OS Loader

下列的程式片段會秀出OS Loader自己取得Device Path以及File Path的步驟. 首先會呼叫到HandleProtocol()去取得LOADED_IMAGE_PROTOCOL的介面. 其中ImageHandle會透過Dispater傳給OS Loader. 再來會呼叫HandleProtocol()去取得DEVICE_PATH_PROTOCOL的介面給OS Loader使用. 這兩個呼叫是用來將OS Loader的Device Path, File Path以及其他Image的資訊傳給OS Loader自己.

BS->HandleProtocol(
             ImageHandle,
             &LoadedImageProtocol,
             LoadedImage);

BS->HandleProtocol(
             LoadedImage->DeviceHandle,
             &DevicePathProtocol,
             &DevicePath);

Print (
   L"Image device : %s\n",
   DevicePathToStr (DevicePath));

Print (
   L"Image file : %s\n",
   DevicePathToStr (LoadedImage->FilePath));

Print (
   L"Image Base : %X\n",
   LoadedImage->ImageBase);

Print (
   L"Image Size : %X\n",
   LoadedImage->ImageSize);

沒有留言:

張貼留言