inpout32.dll的MASM问题

时间:2012-03-24 06:30:33

标签: dll assembly masm

我正在尝试制作一个汇编程序来读取端口0x379的输入。不幸的是,我无法使用ESI寄存器执行此任务,因为我正在运行Windows 7.我将inpout32.dll导入到我的程序中,但遗憾的是我不知道如何将它传递给端口。我正在尝试使用的函数是接受端口作为参数的Inp32函数。到目前为止,我只能在dll中调用Inp32的位置地址。顺便说一句,while循环尚未完成。这是我的源代码:

.386
.model flat, stdcall
option casemap :none

include \masm32\include\windows.inc
include \masm32\include\kernel32.inc
include \masm32\include\user32.inc
includelib \masm32\lib\kernel32.lib
includelib \masm32\lib\user32.lib

.data
    LibName db "inpout32.dll", 0
    OutName db "Out32", 0
    InpName db "Inp32", 0
    DllNotFound db "Cannot load the library", 0
    AppName db "Load Library", 0
    FunctionNotFoundInp db "Inp32 function not found", 0
    FunctionNotFoundOut db "Out32 function not found", 0

.data?
    libHandle dd ? ; handle of the dll
    outAddress dd ? ; address of the out function
    inpAddress dd ? ; address of the inp function

.code
start:
    invoke LoadLibrary, offset LibName

    .if (eax == NULL)
        invoke MessageBox, NULL, addr DllNotFound, addr AppName, MB_OK
    .else
        mov libHandle,eax
        invoke GetProcAddress, libHandle, offset OutName

        .if (eax == NULL)
            invoke MessageBox, NULL, addr FunctionNotFoundOut, addr AppName, MB_OK
        .else
            mov outAddress, eax

        .endif

        invoke GetProcAddress, libHandle, offset InpName

        .if (eax == NULL)
            invoke MessageBox, NULL, addr FunctionNotFoundInp, addr AppName, MB_OK
        .else
            mov inpAddress, eax

        .endif

    .endif

    WhileLp:
        cmp eax, 223d ;compare eax to 223, which is up and down combined
        je WhileDone
        jmp WhileLp ;jump back to the while loop
 
    WhileDone:
        invoke ExitProcess, 0

end start

0 个答案:

没有答案