Is there a way to export a function with the stdcall convetion (including the number of parameteres) from MASM without using PROC?
I've been trying this:
PUBLIC STDCALL strlen
strlen:
...code
ret
But it only generates _strlen as the symbol because the assembler doesn't know the parameter list, I have it working appending @4 to the function, is there another way?
Regards,
Mariano.
I've been trying this:
PUBLIC STDCALL strlen
strlen:
...code
ret
But it only generates _strlen as the symbol because the assembler doesn't know the parameter list, I have it working appending @4 to the function, is there another way?
Regards,
Mariano.
Here is a quick example:
To build the example:
.386
.model flat, stdcall
option casemap :none
include \masm32\include\windows.inc
include \masm32\include\kernel32.inc
public StdOut@4
.code
StdOut@4:
push ebp
mov ebp,esp
add esp,-12 ;3 dwords
; LOCAL hOutPut :DWORD
; LOCAL bWritten :DWORD
; LOCAL sl :DWORD
invoke GetStdHandle,STD_OUTPUT_HANDLE
mov [ebp-4], eax ; hOutPut
invoke lstrlen,[ebp+8] ; lpszText
mov [ebp-12], eax
lea eax,[ebp-8] ; bWritten
invoke WriteFile,[ebp-4],[ebp+8],[ebp-12],eax,NULL ; [ebp-12] = sl
mov eax,[ebp-8]
leave
ret 4
end
.386
.model flat, stdcall
option casemap :none
include \masm32\include\windows.inc
include \masm32\include\kernel32.inc
includelib \masm32\lib\kernel32.lib
StdOut PROTO :DWORD
.data
Message db 'Hello my friend!',0
.code
start:
invoke StdOut,ADDR Message
invoke ExitProcess,0
END start
To build the example:
ml /c /coff Hello.asm
ml /c /coff func.asm
link /SUBSYSTEM:CONSOLE Hello.obj func.obj
how about this variant? :
export name is 'strlen'
and fully control variables
option prologue: none
option epilogue: none
PUBLIC STDCALL strlen
strlen: ; strlen(:DWORD)
push ebp
mov ebp, esp
;...
mov eax, [ebp+8] ; first param
add eax, "test"
;...
mov esp, ebp
pop ebp
ret
option prologue: PrologueDef
option epilogue: EpilogueDef
export name is 'strlen'
and fully control variables
Thanks Vortex but that's exactly what I was doing, I meant another way.
"But it only generates _strlen as the symbol because the assembler doesn't know the parameter list, I have it working appending @4 to the function, is there another way?"
"But it only generates _strlen as the symbol because the assembler doesn't know the parameter list, I have it working appending @4 to the function, is there another way?"
how about this variant? :
option prologue: none
option epilogue: none
PUBLIC STDCALL strlen
strlen: ; strlen(:DWORD)
push ebp
mov ebp, esp
;...
mov eax, [ebp+8] ; first param
add eax, "test"
;...
mov esp, ebp
pop ebp
ret
option prologue: PrologueDef
option epilogue: EpilogueDef
export name is 'strlen'
and fully control variables
I don't know if I'm making a mistake but it stills exports _strlen. Thanks anyway.
heh...
did u use .def file?
if not - u need to create it, like this (testdll.def):
LIBRARY testdll
EXPORTS strlen
and compile dll with this command line:
p:\masm32\bin\ml /c /coff testdll.asm
p:\masm32\bin\Link /SUBSYSTEM:WINDOWS /DLL /DEF:testdll.def testdll.obj
try
did u use .def file?
if not - u need to create it, like this (testdll.def):
LIBRARY testdll
EXPORTS strlen
and compile dll with this command line:
p:\masm32\bin\ml /c /coff testdll.asm
p:\masm32\bin\Link /SUBSYSTEM:WINDOWS /DLL /DEF:testdll.def testdll.obj
try
heh...
did u use .def file?
if not - u need to create it, like this (testdll.def):
LIBRARY mytestdll
EXPORTS strlen
and compile dll with this command line:
p:\masm32\bin\ml /c /coff testdll.asm
p:\masm32\bin\Link /SUBSYSTEM:WINDOWS /DLL /DEF:testdll.def testdll.obj
try
No, I didn't use a .def file and I'm building a static library, thanks anyway I've solved it.