我正在尝试将已签名的 DLL 加载到 VBS 飞地中,但 LoadEnclaveImage
正在返回 A device attached to the system is not functioning
。
Hyper-V、安全启动和 TPM 2.0 都在运行,所以我不太确定错误指的是什么。
示例代码:
if (IsEnclaveTypeSupported(ENCLAVE_TYPE_VBS))
{
DWORD lpError = 0;
ENCLAVE_CREATE_INFO_VBS vci = { 0 };
vci.Flags = 1;
PVOID enclave = CreateEnclave(GetCurrentProcess(),
NULL,
1024 * 1024 * 2,
NULL,
ENCLAVE_TYPE_VBS,
&vci,
sizeof(ENCLAVE_CREATE_INFO_VBS),
&lpError);
if (enclave != NULL)
{
auto lib = LoadLibrary(L"kernelbase.dll");
auto addr = (__LoadEnclaveImage)GetProcAddress(lib, "LoadEnclaveImageW");
if (addr(enclave, L"...\testme.dll"))
{
printf("Worked!\n");
}
else {
printf("Failed to load image\n");
printf(GetLastErrorAsString().c_str());
}
}
else
{
printf(GetLastErrorAsString().c_str());
}
}
else {
printf("VBS not supported\n");
}
最佳答案
我在加载已签名的 DLL 时遇到了同样的一般错误,因此我使用 Static Import Finder 在其他系统二进制文件中查找 LoadEnclaveImageW
的用法| ,并在加载“SgrmEnclave_secure.dll”的 SgrmBroker.exe 中找到它。尝试对该 DLL 使用 LoadEnclaveImageW
成功。
深入挖掘“SgrmEnclave_secure.dll”文件的PE结构,我们可以看到在IMAGE_LOAD_CONFIG_DIRECTORY64
structure中为EnclaveConfigurationPointer
定义了一个值。 (参见 PE-bear 的 screenshot)。
这个指针指向一个IMAGE_ENCLAVE_CONFIG64
structure还有这个screenshot显示在 Ghidra 中解析时的样子。 ImportList
成员是一系列 IMAGE_ENCLAVE_IMPORT
structures 的 RVA .
所以看起来这些结构需要在PE中定义。这可以使用链接器中的 /ENCLAVE
选项来完成。不确定是否有额外要求。如果您对此有更深入的了解,我很想知道。
关于c++ - 加载飞 map 像 "A device attached to the system is not functioning",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50901125/