使用winapi

时间:2015-12-26 19:00:10

标签: assembly masm masm32

我正在学习Dennis Yurichev" Reversing for beginners"书。其中一个练习有以下代码:

.386
.model flat,stdcall
option casemap:none
include \masm32\include\windows.inc 
include \masm32\include\kernel32.inc 
includelib \masm32\lib\kernel32.lib 
include \masm32\include\user32.inc 
includelib \masm32\lib\user32.lib 


.data
    $SG3103 DB  '%d', 0aH, 00H
.code
main PROC
    push    0
    call    DWORD PTR __imp___time64
    push    edx
    push    eax
    push    OFFSET $SG3103 ; '%d'
    call    DWORD PTR __imp__printf
    add esp, 16
    xor eax, eax
    ret 0
main ENDP
END main 

但是,当我在Visual Studio 2015中运行它时,收到以下错误:

1>Addtwo.asm(16): error A2006: undefined symbol : __imp___time64
1>Addtwo.asm(20): error A2006: undefined symbol : __imp__printf

1 个答案:

答案 0 :(得分:1)

您必须包含C运行时库。使用MASM32:

include \masm32\include\msvcrt.inc
includelib \masm32\lib\msvcrt.lib

并删除第一个下划线:

call DWORD PTR _imp__printf