为什么D2D1CreateFactory在程序集中发送错误消息

问题描述 投票:1回答:1

我到目前为止有一个程序,它所做的全部都是尝试创建一个D2D1Factory,但是我收到了错误消息E_NOINTERFACE,我以为我拥有正确的IID_ID2D1Factory,并且已经在多个地方进行了多次检查。有人可以告诉我为什么它失败和/或如何解决它。

我的代码

include externals.asm
include wincons.asm
include vtable.asm
.data
include variables.asm
;include pic.asm
include riid.asm
.code
start proc frame
    DB 48h
    push rbx
    .pushreg rbx
    push r13
    .pushreg r13
    push rbp
    .pushreg rbp
    sub rsp, 80
    .allocstack 80
    lea rbp, [rsp + 80]
    .setframe rbp, 80
    .endprolog
    mov rcx, D2D1_FACTORY_TYPE_SINGLE_THREADED
    lea rdx, IID_ID2D1Factory
    mov r8, D2D1_DEBUG_LEVEL_NONE
    lea r9, ID2D1Factory
    call __imp_D2D1CreateFactory
drawscreen:

    jnc drawscreen
    xor rcx, rcx
    call __imp_ExitProcess
    mov rsp, rbp
    pop rbp
    pop r13
    pop rbx
    ret
start endp
end

Externals.asm

extern __imp_GetDC:qword
extern __imp_ReleaseDC:qword
extern __imp_GetDesktopWindow:qword
extern __imp_ExitProcess:QWORD
extern __imp_SetDIBits:qword
extern __imp_BitBlt:qword
extern __imp_CreateDIBitmap:qword
extern __imp_DeleteObject:qword
extern __imp_DeleteDC:qword
extern __imp_CreateCompatibleBitmap:qword
extern __imp_SelectObject:qword
extern __imp_CreateCompatibleDC:qword
extern __imp_GetDesktopWindow:qword
extern __imp_GetLastError:qword
extern __imp_GetAsyncKeyState:word
extern __imp_D2D1CreateFactory:qword

Variables.asm

align qword
screendc qword ?
picdc qword ?
ID2D1Factory qword ?

Wincons.asm

DIB_RGB_COLORS equ <0>
SRCCOPY equ <0CC0020h>
D2D1_DEBUG_LEVEL_NONE equ <0>
D2D1_FACTORY_TYPE_SINGLE_THREADED equ <0>

最后是riid.asm

IID_IUnknown    Dword   000000000h
                word    00000h
                word    00000h
                word    0C000h
                byte    000h
                byte    000h
                byte    000h
                byte    000h
                byte    000h
                byte    046h

IID_ID2D1RenderTarget   Dword   02cd90694h
                        word    012e2h
                        word    011dch
                        byte    09fh
                        byte    0edh
                        byte    000h
                        byte    011h
                        byte    043h
                        byte    0a0h
                        byte    055h
                        byte    0f9h

IID_ID2D1Factory    Dword   006152247h
                    word    06f50h
                    word    0465ah
                    word    09245h
                    byte    011h
                    byte    08bh
                    byte    0fdh
                    byte    03bh
                    byte    060h
                    byte    007h
windows winapi assembly directx x86-64
1个回答
5
投票
您没有为IID_ID2D1Factory正确定义UUID。问题是Microsoft的UUID二进制编码要求UUID {06152247-6f50-465a-9245-118bfd3b6007}的后两个组件采用大端格式,这与前三个按小端顺序排列的组件不同。所以应该是:

IID_ID2D1Factory Dword 006152247h word 06f50h word 0465ah byte 092h byte 045h byte 011h byte 08bh byte 0fdh byte 03bh byte 060h byte 007h

代替您自己定义此UUID,使用Windows SDK中包含的uuid.lib中的定义会更容易并且更容易出错。
© www.soinside.com 2019 - 2024. All rights reserved.