What i wanted to ask here is that is it possible for me to create Static Library Using vc++ ( coz its a lot Easy :grin: )
and then use those static (dynamic will also do ;) ) with MASM to compile and use those functions in My asm
module???
and then use those static (dynamic will also do ;) ) with MASM to compile and use those functions in My asm
module???
Here is a small example:
Building the executable:
int addnumbs(int x,int y)
{
return (x+y);
}
char *lcase(char *str)
{
char *temp=str;
while(*str)
{
if (*str>64 && *str<91) *str|=32;
++str;
}
return temp;
}
.386
.model flat,stdcall
option casemap:none
include \masm32\include\windows.inc
include \masm32\include\kernel32.inc
include \masm32\include\masm32.inc
includelib \masm32\lib\kernel32.lib
includelib \masm32\lib\masm32.lib
includelib \masm32\lib\user32.lib
includelib sample.lib
addnumbs PROTO :DWORD,:DWORD
lcase PROTO :DWORD
.data
format1 db '80+20=%d',13,10,0
msg db 'HELLO WORLD!',0
.data?
temp db 100 dup(?)
.code
start:
invoke addnumbs,80,20
invoke wsprintf,ADDR temp,ADDR format1,eax
invoke StdOut,ADDR temp
invoke lcase,ADDR msg
invoke StdOut,eax
invoke ExitProcess,0
END start
Building the executable:
Cl /Ic:\progra~1\micros~2\vc98\include /c /Zl /Ogtyb2 /Gs /G6 /Gz /Zp1 /Foaddnumbs.obj addnumbs.c
Cl /Ic:\progra~1\micros~2\vc98\include /c /Zl /Ogtyb2 /Gs /G6 /Gz /Zp1 /Folcase.obj lcase.c
\masm32\bin\link -lib addnumbs.obj lcase.obj /out:sample.lib
\masm32\bin\ml /c /coff Masmvc.asm
\masm32\bin\link /SUBSYSTEM:CONSOLE Masmvc.obj
but still one question is hanging in my head cant i straight forward create a staic library by selecting the WIN32
Static Library option in the wizard itself.
Also my vc++ code includes WIN32 Api's like MessageBox, CreateFileA etc...
so can it stil work out??
Static Library option in the wizard itself.
Also my vc++ code includes WIN32 Api's like MessageBox, CreateFileA etc...
so can it stil work out??
Hi telophase,
You can create a static library by selecting the WIN32 Static Library option in the wizard.
About Win32 API functions, you can use any of them with your Asm&VC project. The only trick is to specify the required import libraries at the linking stage. Another thing, be carefull with the MS libraries libc.lib and oldnames.lib, it might be possible to use other libraries with these ones. You can use easily the C run-time DLLs crtdll.dll and msvcrt.dll
You can create a static library by selecting the WIN32 Static Library option in the wizard.
About Win32 API functions, you can use any of them with your Asm&VC project. The only trick is to specify the required import libraries at the linking stage. Another thing, be carefull with the MS libraries libc.lib and oldnames.lib, it might be possible to use other libraries with these ones. You can use easily the C run-time DLLs crtdll.dll and msvcrt.dll
I have attached my static lib and the .asm file which tries to call it but it dosent work can u tell me why?
Plz see the attached file thankyou :stupid:
the static1 folder in the zip file contains my vc++ project and static.am contains my calling procedure
when ever i try to compile using MASM i get linker error saying:
'Microsoft (R) Macro Assembler Version 6.14.8444
Copyright (C) Microsoft Corp 1981-1997. All rights reserved.
Assembling: F:\masm32\_MY_PROJECTS\Static_Lib_Tst\static.asm
Microsoft (R) Incremental Linker Version 5.12.8078
Copyright (C) Microsoft Corp 1992-1998. All rights reserved.
static.obj : error LNK2001: unresolved external symbol _Msg@0
static.exe : fatal error LNK1120: 1 unresolved externals
_
Link error
Press any key to continue . . .'
Plz see the attached file thankyou :stupid:
the static1 folder in the zip file contains my vc++ project and static.am contains my calling procedure
when ever i try to compile using MASM i get linker error saying:
'Microsoft (R) Macro Assembler Version 6.14.8444
Copyright (C) Microsoft Corp 1981-1997. All rights reserved.
Assembling: F:\masm32\_MY_PROJECTS\Static_Lib_Tst\static.asm
Microsoft (R) Incremental Linker Version 5.12.8078
Copyright (C) Microsoft Corp 1992-1998. All rights reserved.
static.obj : error LNK2001: unresolved external symbol _Msg@0
static.exe : fatal error LNK1120: 1 unresolved externals
_
Link error
Press any key to continue . . .'
Remember to declare your procedures as WINAPI, or use a .def file (if you are creating a dll) to create correct names for your export
I've made two little changes and now it links perfectly:
1. First I've changed the parameter passing convention to stdcall (Windows and MASM default)like this in StdAfx.cpp :
extern "C" int __stdcall Msg(void)
{
MessageBox(0,"Hello","World",MB_OK);
return 0;
}
2. I've replaced the start point like this so the linker don't complain anymore about not finding main:
main:
; ?????????????????????????????????????????????????????????????????????????
invoke Msg
invoke ExitProcess,0
; ?????????????????????????????????????????????????????????????????????????
end main
Regards,
Mariano.
:alright:
1. First I've changed the parameter passing convention to stdcall (Windows and MASM default)like this in StdAfx.cpp :
extern "C" int __stdcall Msg(void)
{
MessageBox(0,"Hello","World",MB_OK);
return 0;
}
2. I've replaced the start point like this so the linker don't complain anymore about not finding main:
main:
; ?????????????????????????????????????????????????????????????????????????
invoke Msg
invoke ExitProcess,0
; ?????????????????????????????????????????????????????????????????????????
end main
Regards,
Mariano.
:alright:
Thankyou for u r help but can i also impliment the below example using the above mentioned method
eg:
getentrypoint()
{
MapAndLoad();
return(entrypoint);
}
actually i want to use the PE file format functions which are available in
Header: Declared in imagehlp.h.
Import Library: Use imagehlp.lib.
so can this be implemented???????
eg:
getentrypoint()
{
MapAndLoad();
return(entrypoint);
}
actually i want to use the PE file format functions which are available in
Header: Declared in imagehlp.h.
Import Library: Use imagehlp.lib.
so can this be implemented???????
I don't know what you want to do exactly...
Do you want to set up the entry point in the C code? In the static library?
Do you want to call some functions dealing with imagehlp from assembly that are inside the C code?
I think that you can use the imagehlp both from the asm executable and from the C static library.
Regards,
Mariano.
:alright:
Do you want to set up the entry point in the C code? In the static library?
Do you want to call some functions dealing with imagehlp from assembly that are inside the C code?
I think that you can use the imagehlp both from the asm executable and from the C static library.
Regards,
Mariano.
:alright:
i want to use a inbuilt function MapAndLoad in the imagelib and then i wil return the entry point of the PE file
which i wil use in asm:grin:
which i wil use in asm:grin:
You shouldn't have any problem, remember that the getentrypoint() return value will be in the eax register.
Regards,
Mariano.
:alright:
Regards,
Mariano.
:alright:
Thankyou very much for your help.:alright:
No problem, you are welcome, by the way where are you from?
Regards,
Mariano.
:alright:
Regards,
Mariano.
:alright:
From India and U?
I'm from Argentina but I'm living in Spain right now :)
Regards,
Mariano.
:alright:
Regards,
Mariano.
:alright:
U got any yahoo! id or something for contacting u?
I'll send you a Private Message ;)
Regards,
Mariano.
:alright:
Regards,
Mariano.
:alright:
The method u specified didnt work for by modifying the function to extern "c" int __stdcall
The method u specified didnt work for me by modifying the function to extern "c" int __stdcall
when i compile it no probs but when i link it , cant link get i get linker erroe saying that some "libcd.lib" is missing