Hee folks
got a simple and short question
is it possible to use a ms vc++ 2010 .library file in winasm masm?
i got only the *.lib file generated by vc++ 2010.
just using the "uselib" macro won't work because of some missing *.obj files error or something, dont know because i dont have object files, just a *.lib.
The uselib macro requires two files:
include \masm32\include\*.inc
includelib \masm32\lib\*.lib
Do you have an inc file, too? Is it located in the right folder?
The best solution to get help would be to zip the library and include files together with a hello world example. You are not giving much information...
i would imagine you are missing a proper masm-syntax include file
masm does not understand C .h includes
which LIB are you trying to use ?
there may already be a masm INC file made for it, someplace
It depends on what the libraries are, if they are C++ libraries you will have problems with the name mangling where if they are plain C libraries, they can be used if you create a set of prototypes for it in MASM format. What you will normally find is if you use the C runtime libraries you pick up most of their overhead as well and there will be little if any gain by building the app in MASM. Alternately you can routinely use separate C object modules if you prototype them correctly and use the right calling convention for them.
thanks for the reply's guys.
i dont have a inc file. also i think it is a plain c++ library.
im trying to include the latest Crypto++ library.
use this to have the include file:
http://masm32.com/board/index.php?topic=576.0 (http://masm32.com/board/index.php?topic=576.0)
Just take care that a c++ library use a defaut prototype PROTO C.
You can have need to change "PROTO" to "PROTO C".
You can also find decorated functions names,use it on the translated header if it is the case.
It very work to convert the header *.h to include
I use tools for it h2incx or a translator from ToutEnMasm
and the rest of the converted Include make it per hand
need you more help post this crypto lib
or tell us what you need for a crypto many cryptos give allready masm includes
i do not understand.
i do not need inc files, i just want to use this library into masm
i uploaded the library here
http://rghost.net/46180829
true - you don't NEED inc files
but, it is the easiest way to prototype the functions in the lib
one of the guys may make an inc file for you
if not, i may do it, later
Erol (Vortex) has several nice tools for doing this automatically
http://vortex.masmcode.com/ (http://vortex.masmcode.com/)
Andreas (Japheth) also has a tool called h2incX
http://www.japheth.de/h2incX.html (http://www.japheth.de/h2incX.html)
it was designed for C, not C++, but it's worth a shot
by the way,
it would simplify creation of the inc file if you knew you were only using a few functions from the lib
you only need to prototype and typedef the symbols you are going to use
also, there are crypto routines written in masm
you may find that they are faster - and easier to use in a masm program :biggrin:
here is a quicky inc file
i used Erol's lib2def and def2inc
it only defines the prototypes for functions
not sure how well it will work, but you can give it a try
in your asm source
INCLUDE cryptlib.inc
INCLUDELIB cryptlib.lib
There is something wrong,
dumpbin find 2925 functions exported by the dll
probably a problem with dumpbin :biggrin:
i doubt it is set up to handle C++
and, i doubt the crypto library has that many functions - lol
you can find cryptlib.h online - it wouldn't be that hard to create an inc file by hand - it's pretty small
Quote from: dedndave on May 23, 2013, 02:11:58 AMand, i doubt the crypto library has that many functions
yes, instead it has several thousand methods: http://www.cryptopp.com/docs/ref/annotated.html
Quote
probably a problem with dumpbin
i doubt it is set up to handle C++
Of course it is the dumpbin of the c++,not the masm32 one.
Perhaps a use of the wincrypt (.h .sdk) will be more simple.
gracias dendedave and others!
i used the uselib to include the inc file dendedave made and included the library itself, now while compiling it will give serveral errrors, listed below.
and indeed i just need a few functions of it, maybe only 6-8.
Quote from: Redlabel on May 23, 2013, 02:49:02 AMi used the uselib to include the inc file dendedave made and included the library itself, now while compiling it will give serveral errrors, listed below.
forget that include file- its simply wrong.
What you need to do, is to write functions (extern "C") in the c++ source, which interacts with the needed objects. For calling these function, you need to define the prototypes in MASM:
e.g.
foo PROC C param1:ptr CHAR,param2:SDWORD ; extern "C" int foo(char* param1, int param2)
thanks for the help :eusa_clap: but i do not understand.
It could be something like this:
c++:
extern "C" void CalculateDigest(byte* hash_value, const byte* data, size_t length) {
CryptoPP::MD5 hash;
hash.CalculateDigest( hash_value, data, length);
}
MASM:
MD5 struct
bytes BYTE 16 dup (?)
MD5 ends
CalculateDigest proto C hash_value: ptr MD5,data:ptr BYTE, _length:DWORD
...
.data?
md5 MD5 <>
.data
foo BYTE "123456789"
.code
...
invoke CalculateDigest,ADDR md5,ADDR foo,SIZEOF foo
It's a C++ library. Not easy to extract the method names from the lib.
gracias qword!
just 1 problem i got an error while i include the library: LINK : fatal error LNK1196: invalid or corrupt import object: unknown version.
when i remove the includelib cryptlib.lib then the error is gone, but ofcourse the functions of this lib too.
Can you post the link where I get complete crypto lib with Header files and documentation?
so you write a wrapper function, then import the wrapper ?
or am i missing something ? :redface:
You can also use a dynamic link.
Here a test to see which functions are usable with getprocadress.
Put it on the same directory.
Open a dos windows use the > to have a full list of functions usable.
Quote from: Redlabel on May 23, 2013, 03:50:35 AMjust 1 problem i got an error while i include the library: LINK : fatal error LNK1196: invalid or corrupt import object: unknown version.
You maybe try to replace ( with backup ;-) ) ML.exe and LINK.exe in MASM32's bin folder with the one from your Visual studio installation. If I'm not wrong, you also need to copy: msobj100.dll, mspdb100.dll, mspdbcore.dll, mspdbsrv.exe. (search in the Visual Studio installation directories for this files).
ragdog, there is no dll or lib extension in the offical download, anyway i posted the generated lib by vc++ a few post earlier and here is the offical download to crypto++ library with headers>http://www.cryptopp.com/#download
ToutEnMasm, thank you. it found 2272 good ones and 660 bad ones.
qword, after replacing the vs++ files you metioned it still says the same error.
maybe this is too hard and i should use vc++ then instead of masm :eusa_boohoo:
Quoteragdog, there is no dll or lib extension in the offical download, anyway i posted the generated lib by vc++ a few post earlier
Yes i know
i use this setting to make a lib from a C source
copy mirdef.h32 mirdef.h
cl /c /O2 /W3 mrcore.c
cl /c /O2 /W3 mrflsh4.c
..
..
.
lib /OUT:miracl.lib mrflsh4.obj mrcore.obj ... .
Or you include the obj file to your project
omg nice work dude :greenclp:
no i do not include any obj.
i do not have the time and patient do did what you did
so i guess i should stick with vc++.
Anyway thanx for all the great help here at this forum! :greenclp: :t :icon14: :eusa_clap:
Quote from: Redlabel on May 23, 2013, 05:18:27 AMso i guess i should stick with vc++.
I've test it as descripted above and it does work: It is important that you replace \masm32\bin\LINK.exe with the one from ...\VC\bin\. Also you must add the /LIBPATH:"C:\...\VC\Lib" to the linker command line.
For the following code I get a running EXE - see attachment:
include \masm32\include\masm32rt.inc
includelib C:\<...>\crypt\Win32\Output\Release\cryptlib.lib
MD5 struct
data DWORD 4 dup (?)
MD5 ends
CalculateDigest proto C hash_value: ptr MD5,data:ptr BYTE, _length:DWORD
.data?
md5 MD5 <>
.data
foo BYTE "123456789"
.code
.code
main proc C
invoke CalculateDigest,ADDR md5,ADDR foo,SIZEOF foo
print "MD5(<123456789>) = 0x"
print hex$(DWORD ptr md5.data[3*4])
print hex$(DWORD ptr md5.data[2*4])
print hex$(DWORD ptr md5.data[1*4])
print hex$(DWORD ptr md5.data[0*4]),13,10
inkey
exit
main endp
end main
dammmnn! you guys are rocking! :greenclp: :greenclp:
nice work qword, now i can compile without any error!
just 1 thing; i dont know what you mean by this
Quotemust add the /LIBPATH:"C:\...\VC\Lib" to the linker command line
i guess i should open winasm studio>project>properties>release>command line? (my exe is a release version, not a debug).
so when i did this and added the directory to hte VC libs ( C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\lib )
i got this error:
error LNK2019: unresolved external symbol _CalculateDigest referenced in function _doHash@0this is my project
(http://i40.tinypic.com/2duviw.png)
Quote from: Redlabel on May 23, 2013, 06:31:20 AMi guess i should open winasm studio>project>properties>release>command line?
yes, you must add that option. Because the path contains spaces, it should be enclosed in double quotes:
/LIBPATH:"C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\lib"I hope you also had add the function to your library build. For that purpose I have add a new module (named C_interface.cpp) to the library:
#include "pch.h"
#include "md5.h"
extern "C" void CalculateDigest(byte* hash_value, const byte* data, size_t length) {
CryptoPP::MD5 hash;
hash.CalculateDigest( hash_value, data, length);
}
....
Redlabel,
The shown c++ file must be add to the project that is used to build the cryptlib (In other word: you must extend the crypto library by the adding the function CalculateDigest()).
...
You just need to add the file to the project (I'm talking about the c++-library!): for Visual Studio this could be: Project->Add Item->new c++ source.
BTW: It seems like that the whole topic is beyond your limits.
....
Redlabel,
Make a point of NOT deleting post contents, other members have responded and your deletions render their posts unintelligible.
Quote from: hutch-- on June 09, 2013, 05:04:18 PM
Make a point of NOT deleting post contents, other members have responded and your deletions render their posts unintelligible.
This habit is indeed extremely anti-social. I wonder whether one can block post edits for members below a certain post count; allowing as usual, one hour to correct typos etc.
just a question "Why?"..
never fell embarrassed of making mistakes in learning process.. my first source code was full of garbage, if I made mistake I don't delete them just comment them out and put a notice "this is mistakes.." and after the source finished I retype the right source in the new document, side by side with the old and possibly optimize it ... that way I can learn from my mistakes... and try to stay away from it..
Hutch, if I remember correctly in the old forum you have a notice about not deleting post, right? what about making it as a rule or a notice..?
Quote from: jj2007 on June 09, 2013, 07:51:43 PM
This habit is indeed extremely anti-social. I wonder whether one can block post edits for members below a certain post count; allowing as usual, one hour to correct typos etc.
Yes, indeed and very unfair.
Quote from: Dubby on June 09, 2013, 09:16:36 PM
Hutch, if I remember correctly in the old forum you have a notice about not deleting post, right? what about making it as a rule or a notice..?
That's a good proposal. We should think about it.
Gunther