Please Help!

i would like to access the 'c' string manipulation routines located in CRTDLL.DLL or MSVCRT.DLL, both of which, i believe, come standard with all windows OS's. i don't need invoke: push and call is fine. i read Iczelion's tutorial but could not get this to work with masm :mad: :

c:\masm32\bin\dumpbin /EXPORTS CRTDLL.DLL > crtdll.def

then i altered crtdll.def to contain:


then i ran:

c:\masm32\bin\lib /DEF:crtdll.def

inside my .asm file i have:

includelib \masm32\lib\crtdll.lib
push whatever
call strlen

i get 'error: undefined symbol strlen'... what am i doing wrong? :confused: do i need more switches like /machine or /subsystem ? protos?

thanks in advance! :alright:
phil :)
Posted on 2001-08-13 16:44:54 by phil
Afternoon, phil.

You still need to declare the proc somewhere in your '*.asm' file (or in an '*.inc' file).

If the declaration is in an external '*.obj' file, then use 'EXTERNDEF' in your *.asm' or '*.inc' file, and link the '*.obj' file.

Otherwise, just declare the proc yourself:

Hope this helps.

Posted on 2001-08-13 17:44:51 by Scronty
hi Scronty!

thanks for replying. i am pretty clueless about this process. from the original .dll file i made the .def file (dumpbin), .lib file (lib), and an .inc file consisting of:

_strlen PROTO :DWORD

i also tried it without the leading underscore.

i am unfamiliar with the syntax of EXTERNDEF.

when i tried declaring:

i got back 'unresolved external symbol _strlen@4'

phil :confused:
Posted on 2001-08-13 18:11:55 by phil
I think it should be:

strlen proto :dword

w/o the leading "_" Masm will add underscores and decorate the name for you according to the language you specify (cdecl, stdcall etc.). In this case you did'nt specify a language in the PROTO, so Masm will use the cuurent one (inherited from the .MODEL directive) which is STDCALL.

For instance wsprintf is a C function not STDCALL and it's proto is

wsprintf proto C, :dword, :dword, :vararg

Posted on 2001-08-13 18:28:48 by gfalen

What you are after can be done with standard MASM syntax. You must create
the library in the way you have mentioned and this is fine but it will not
have parameter information as this is not contained in the DLL.

It means you will have to know the parameter count and size for each one
and you then write a prototype for each function call you need from the DLL.

My_Function_Paramaters typedef PROTO C :DWORD,:WORD,:BYTE etc ....
externdef _imp__The_Correct_Function_Name:PTR My_Function_Paramaters
The_Function_Name_I_Want equ <_imp__The_Correct_Function_Name>

This format will allow you to use "invoke" in the normal manner so that your
coding style is a lot more even and easier to read.

I have this method tested on PowerBASIC DLLs and it works fine, I cannot see
any reason why it will not work in the C runtime DLLs as long as you spoecify
the corret calling convention which will be "C".

Posted on 2001-08-13 19:04:00 by hutch--
thanks Scronty, gfalen, and hutch-- !!! :grin:


it compiled after i used 'proto c' and dumped all use of the underscore. i was using STDCALL... forgot all about that. next step is to test the call... i believe most of the c values pushed will be 32-bit... i hope so... i shall see :).


thanks for the information on getting it work with invoke, i will try it out! i believe i've seen your posts over at PowerBASIC! i like PB's string routines and inline asm ability. ironically the syntax is closer to masm than it is to c. i'd like to look closer at the code PB spits out with a disassembler for curiosity sake. i believe you've 'been there, done that'. as far as i know PB was written using a borland compiler (been a while since i looked at the executable).

you guys are great :alright:
dr phil :)

ps glad i found this board... glad it was here to find :grin:
Posted on 2001-08-13 19:42:22 by phil