【发布时间】:2017-04-29 14:42:29
【问题描述】:
我正在使用UEFI驱动程序相关代码,我遇到了这个:
/* EFI headers define EFI_HANDLE as a void pointer, which renders type
* checking somewhat useless. Work around this bizarre sabotage
* attempt by redefining EFI_HANDLE as a pointer to an anonymous
* structure.
*/
#define EFI_HANDLE STUPID_EFI_HANDLE
#include <ipxe/efi/Uefi/UefiBaseType.h>
#undef EFI_HANDLE
typedef struct {} *EFI_HANDLE;
完整的源代码在这个路径中 http://dox.ipxe.org/include_2ipxe_2efi_2efi_8h_source.html
这是我第一次接触匿名结构,我无法理解将void * 重新定义为指向匿名结构的指针的逻辑。 “奇怪的破坏企图”暗示了什么样的黑客行为?
【问题讨论】:
-
有趣的细节也是
#include周围的#define和#undef。它会建议标头使用#define而不是typedef,这可能暗示代码中还有其他WTF。这可以解释评论的被动攻击语气......