The MASM Forum Archive 2004 to 2012

Project Support Forums => MASM32 => Topic started by: ToutEnMasm on August 04, 2006, 09:31:41 AM

Title: Msvcrt.inc in the masm32 libraries
Post by: ToutEnMasm on August 04, 2006, 09:31:41 AM

Hello,
The msvcrt.inc seems to use complex calls.
I have tried to extract the functions of the mscvrt.lib,with protolib.
Big surprise,this one, who knows only functions written in the standard pecoff format,extract the functions without problems.
There is only some names conflicts with masm.
I tried the _getch without problem (getch is deprecated).

I have not enough informations to try some others.
joined is the include file.
                             ToutEnMasm






[attachment deleted by admin]
Title: Re: Msvcrt.inc in the masm32 libraries
Post by: Vortex on August 04, 2006, 10:03:34 AM
ToutEnMasm,

Your include file looks fine. The name conflict problem exists because some of the C functions like fabs are reserved MASM keywords. Plus, character handling functions like isalpha are already defined in masm32.inc ( They are a part of masm32.lib ) Hutch's msvcrt.inc has a nice method to solve the problem, all the exported function names are prefixed with crt_ :

crt_printf
etc.
Title: Re: Msvcrt.inc in the masm32 libraries
Post by: ToutEnMasm on February 17, 2008, 05:28:11 PM
Hello,
I am a little after the battle,but i have some things to say.

Incompatible name as fabs,can be solve linking dynamically to the function.
Quote
;declare
Pcrt_fabs TYPEDEF PROTO C :QWORD
Fcrt_fabs TYPEDEF PTR Pcrt_fabs
crt_fabs TEXTEQU <Fcrt_fabs ptr Acrt_fabs>
.data
s db " -2309.12E-15",0
x QWORD -5.6798
y QWORD 0
;Main Main_DATA <>   
Hlibrairie dd 0
format db "fabs( %lf ) = %lf",13,10,0
Acrt_fabs dd 0
.code
main PROC C un:DWORD,deux:DWORD
   invoke LoadLibrary,SADR("ntdll.dll")
   mov Hlibrairie,eax
   invoke GetProcAddress,Hlibrairie,SADR("fabs")
   mov Acrt_fabs,eax
               ;------------------------------------------------------------------------------------
   invoke crt_fabs,x
   fstp y
   invoke printf,addr format,x,y
ret

Stay some redifinition of proto in the masm library
Quote
atol PROTO :DWORD                          ;can be renamed
ltoa PROTO :DWORD,:DWORD
isalpha  PROTO :BYTE
isupper  PROTO :BYTE
islower  PROTO :BYTE

The big problem with rebuilding the crt library is that this one isn't compatible with other SDK
To other APi have been renamed and are searched by other SDK lib.