当前位置: 代码迷 >> 汇编语言 >> 请教怎么使用函数指针
  详细解决方案

请教怎么使用函数指针

热度:5736   发布时间:2013-02-26 00:00:00.0
请问如何使用函数指针。
我定义了一下的指针
_subFunc typedef PROTO :DWORD,:DWORD,:DWORD
_psubFunc typedef ptr _subFunc
函数声明
_md5Loop PROTO :DWORD,:DWORD,:DWORD,:DWORD,:_psubFunc,:DWORD,:DWORD,:DWORD
第5个参数是函数指针,但是在编译的时候就出错了

如果把第5个参数_psubFunc改成DWORD,就能通过,但是没声明参数,在_md5Loop调用这个参数中函数指针的时候,怎么用invoke呢,没有地方显示传进的参数是个指针啊。

------解决方案--------------------------------------------------------
呃,上面三行在 Masm32 里好像没有问题的哎
Assembly code
                .386                .model  flat, stdcall                option  casemap:none                include         windows.inc                include         kernel32.inc                include        user32.inc        include        gdi32.inc                includelib      kernel32.lib                includelib    user32.lib        includelib    gdi32.lib_subFunc    typedef PROTO :DWORD,:DWORD,:DWORD_psubFunc    typedef ptr _subFunc_subFunc2    PROTO :DWORD,:DWORD,:DWORD_md5Loop PROTO :DWORD,:DWORD,:DWORD,:DWORD,:_psubFunc,:DWORD,:DWORD,:DWORD                .codemain        proc        invoke    _md5Loop, 1, 2, 3, 4, _subFunc2, 6, 7, 8        invoke    ExitProcess, NULL        retmain        endp_subFunc2    proc    arg1:DWORD, arg2:DWORD, arg3:DWORD        ret_subFunc2    endp_md5Loop    proc    arg1:DWORD, arg2:DWORD, arg3:DWORD, arg4:DWORD, arg5:_psubFunc,arg6:DWORD, arg7:DWORD, arg8:DWORD        invoke    arg5, 1, 2, 3        ret_md5Loop    endp        end    mainM:\>ml /c /coff 0.asmMicrosoft (R) Macro Assembler Version 6.14.8444Copyright (C) Microsoft Corp 1981-1997.  All rights reserved. Assembling: 0.asmM:\>link /subsystem:windows 0.objMicrosoft (R) Incremental Linker Version 5.12.8078Copyright (C) Microsoft Corp 1992-1998. All rights reserved.M:\>dir 0* Volume in drive M is RAMDISK Volume Serial Number is 3C4A-F68F Directory of M:\2012-08-28  12:52             1,025 0.ASM2012-08-28  12:54               732 0.obj2012-08-28  12:54             1,536 0.exe
  相关解决方案