D语言 GetProcAddress 向 function 转化

阅读更多
cast(typeof(Function Poiner Name))

sample


/*==========================================
             NtCreateFile
==========================================*/

extern(Windows) NTSTATUS function
(
    PHANDLE             FileHandle,
ACCESS_MASK         DesiredAccess,
POBJECT_ATTRIBUTES  ObjectAttributes,
    PIO_STATUS_BLOCK    IoStatusBlock,
PLARGE_INTEGER      AllocationSize,
ULONG               FileAttributes,
    ULONG               ShareAccess,
    ULONG               CreateDisposition,
    ULONG               CreateOptions,
    PVOID               EaBuffer,
    ULONG               EaLength
) NtCreateFile;

NtCreateFile = cast(typeof(NtCreateFile)) GetProcAddress ( GetModuleHandleA ("ntdll.dll"), "NtCreateFile");

你可能感兴趣的:(d语言)