Author Topic: Is it printf or _printf?  (Read 11545 times)

Gunther

  • Member
  • *****
  • Posts: 3585
  • Forgive your enemies, but never forget their names
Is it printf or _printf?
« on: October 01, 2012, 12:48:35 AM »
I need some help for the Windows 64 bit environment. Since I haven't running a 64 bit windows, I hope one of the members can answer. If one would call the LIBC from an assembly language application, is it:
Code: [Select]
call printfor
Code: [Select]
call _printf
Thank you.

Gunther

Get your facts first, and then you can distort them.

qWord

  • Member
  • *****
  • Posts: 1473
  • The base type of a type is the type itself
    • SmplMath macros
Re: Is it printf or _printf?
« Reply #1 on: October 01, 2012, 01:17:47 AM »
it is printf.
MREAL macros - when you need floating point arithmetic while assembling!

Vortex

  • Member
  • *****
  • Posts: 2336
Re: Is it printf or _printf?
« Reply #2 on: October 01, 2012, 03:53:56 AM »
Also, the same is true for msvcrt.dll. The function is exported as printf

Gunther

  • Member
  • *****
  • Posts: 3585
  • Forgive your enemies, but never forget their names
Re: Is it printf or _printf?
« Reply #3 on: October 01, 2012, 09:22:00 AM »
Thank you for the information. In the 32 bit world it's _printf.

Gunther
Get your facts first, and then you can distort them.

jj2007

  • Member
  • *****
  • Posts: 10544
  • Assembler is fun ;-)
    • MasmBasic
Re: Is it printf or _printf?
« Reply #4 on: October 01, 2012, 03:27:47 PM »
Thank you for the information. In the 32 bit world it's _printf.

Gunther

In the Masm32 world it seems to be printf: call crt_printf ;)

MichaelW

  • Global Moderator
  • Member
  • *****
  • Posts: 1209
Re: Is it printf or _printf?
« Reply #5 on: October 01, 2012, 03:31:05 PM »
In the 32 bit world it's _printf.

I know for some CRTs it is, the lcclibc.dll that I tested recently for example, but for MSVCRT.dll, on my Windows 2000 system and on my Windows XP system, it’s “printf”.
Code: [Select]
;==============================================================================
; Build as a console app.
;==============================================================================
include \masm32\include\masm32rt.inc
;==============================================================================
.data
    hMod dd 0
.code
;==============================================================================
start:
;==============================================================================
    invoke LoadLibrary, chr$("msvcrt.dll")
    mov hMod, eax
    printf("%Xh\n",hMod)
    invoke GetProcAddress, hMod, chr$("printf")
    mov ebx, eax
    printf("%Xh\n\n",ebx)

    push ebx
    push cfm$("%Xh\n\n")
    call ebx
    add esp, 8

    inkey
    exit
;==============================================================================
end start
Code: [Select]
78000000h
78023626h

78023626h
Well Microsoft, here’s another nice mess you’ve gotten us into.