Shpongle
Shpongle

Reputation: 45

error A2008 when using winapi

I am learning Dennis Yurichev's "Reversing for beginners" book. One of the exercises has the following code:

.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 

However, when I run it in Visual Studio 2015 I receive the following error:

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

Upvotes: 2

Views: 321

Answers (1)

rkhb
rkhb

Reputation: 14409

You have to include the C runtime library. With MASM32:

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

and to remove the first underscore:

call DWORD PTR _imp__printf

Upvotes: 1

Related Questions