DirectInputCreate Hinstance

Тема в разделе "WASM.DirectX", создана пользователем Llirik, 12 май 2010.

  1. Llirik

    Llirik Member

    Публикаций:
    0
    Регистрация:
    18 июл 2008
    Сообщения:
    468
    Обязательно ли получать Хендл приложения, чтобы его использовать в функции DirectInputCreate? если да, то как можно перевести всю виндоус в режим DirectInput?

    .386p
    option casemap:none
    .model flat, stdcall
    includelib C:\masm32\lib\kernel32.lib
    includelib C:\masm32\lib\user32.lib
    includelib C:\masm32\lib\gdi32.lib
    includelib C:\masm32\lib\dinput.lib
    includelib C:\masm32\lib\dxguid.lib
    includelib C:\masm32\lib\Uuid.Lib
    includelib C:\masm32\lib\oldnames.lib
    include c:\masm32\include\windows.inc
    include c:\masm32\include\user32.inc
    include c:\masm32\include\kernel32.inc
    include c:\masm32\include\gdi32.inc
    include C:\masm32\include\dinput.inc
    include C:\masm32\include\Protos.inc

    PUBLIC lpdi

    .data
    lpdi LPDIRECTINPUT 0
    lpdimouse LPDIRECTINPUTDEVICE ? ; dinput mouse
    mouse_state DIMOUSESTATE <> ; contains state of mouse
    titleprog db "CrackMe 1",0
    msbtxt1 db "Выполнено успешно",0
    dinputerr db "Ошибка при иницилизации DirectInputCreate",0
    msgmouseerr db "Ошибка при иницилизации мыши",0
    FALSE equ 0
    TRUE equ 1
    .code
    main:
    invoke DirectInputCreate, 0, DIRECTINPUT_VERSION, ADDR lpdi,0

    ;=============================
    ; Test for an error creating
    ;=============================
    .if eax != DI_OK
    jmp err
    .endif
    invoke DI_Init_Mouse
    .IF EAX == FALSE
    JMP errmouss
    .ENDIF

    done:
    ;===================
    ; Выполнено успешно
    ;===================

    push 0
    push offset titleprog
    push offset msbtxt1
    push 0
    call MessageBoxA
    push 0
    call ExitProcess
    err:

    ;===================
    ; Вывести сообщение об ошибке
    ;===================

    push 0
    push offset titleprog
    push offset dinputerr
    push 0
    call MessageBoxA
    push 0
    call ExitProcess

    errmouss:
    ;===================
    ; Вывести сообщение об ошибке
    ;===================

    push 0
    push offset titleprog
    push offset msgmouseerr
    push 0
    call MessageBoxA
    push 0
    call ExitProcess


    DI_Init_Mouse proc
    ; Now try and create it
    ;===========================
    DIINVOKE CreateDevice, lpdi, ADDR GUID_SysMouse, ADDR lpdimouse, 0

    ;============================
    ; Test for an error creating
    ;============================
    .if eax != DI_OK
    jmp errmouss
    .endif

    ;==========================
    ; Set the coop level
    ;==========================
    DIDEVINVOKE SetCooperativeLevel, lpdimouse, NULL, \
    DISCL_NONEXCLUSIVE or DISCL_BACKGROUND

    ;============================
    ; Test for an error querying
    ;============================
    .if eax != DI_OK
    jmp errmouss
    .endif

    ;==========================
    ; Set the data format
    ;==========================
    DIDEVINVOKE SetDataFormat, lpdimouse, ADDR c_dfDIMouse

    ;============================
    ; Test for an error querying
    ;============================
    .if eax != DI_OK
    jmp errmouss
    .endif

    ;===================================
    ; Now try and acquire the mouse
    ;===================================
    DIDEVINVOKE Acquire, lpdimouse

    ;============================
    ; Test for an error acquiring
    ;============================
    .if eax != DI_OK
    jmp errmouss
    .endif

    DI_Init_Mouse ENDP

    ; DI_Init ENDP

    end main