Hi people.
I have a problem with a custom compiled CyaSSL embedded SSL library. I'm using:
- CyaSSL embedded SSL package (v 2.0.2)
- Windows 7 64 bit platform
- Pelles C compiler RC4, the 32 bit version
- MASM32 project
I have been trying to compile the library so it would be linkable in my MASM project and where VC++ 6.0 and 8.0 Express have failed, Pelles C managed to give me a library with unmangled function names. Some of the project options I used to compile the library are:
- stcall function calls
- single threaded library
- undecorate exported functions option checked
- preprocessor directives: OPENSSL_EXTRA CYASSL_RIPEMD CYASSL_SHA512 NO_PSK WIN32 SINGLE_THREADED
The custom project was built following your guidelines from the manual, that is copy all the .c files in one folder and .h files into the other. I have changed a bit the directory structure, but the whole thing compiles without problems, I just get a few warnings
\Pelles C Projects\cyassl-barebone\cyassl\internal.h(1154): warning #2135: Static 'tls_client' is not referenced.
\Pelles C Projects\cyassl-barebone\cyassl\internal.h(1152): warning #2135: Static 'server' is not referenced.
The output is a 292kb cyassl.lib. Once I insert the library into my MASM project the only thing needed for a successful build is the crt.lib library.
This would be a part of the function flow I'm trying to create
invoke CyaSSL_library_init
cmp eax,SSL_SUCCESS
jne @quit
invoke CyaSSLv3_client_method
mov meth,eax
invoke CyaSSL_CTX_new,meth
mov ctx,eax
invoke CyaSSL_CTX_load_verify_locations,ctx,offset _cert,0
invoke CyaSSL_new,ctx
mov ssl,eax
Note: the function CyaSSL_Init according to the manual returns a "1" if successful, while in fact it returns a 0 if everything went OK.
int CyaSSL_library_init(void)
{
CYASSL_ENTER("SSL_library_init");
if (CyaSSL_Init() == 0)
return SSL_SUCCESS;
else
return SSL_FATAL_ERROR;
}
The function CyaSSLv3_client_method never returns and throws an exception in nt.dll. I have traced a bit the flow of the function.
Firstly the VirtualAlloc function is called with following parameters
Address=0
Size=0
AllocType=MEM_RESERVE
Protect=PAGE_NOACCESS
The return value iz NULL and the last error call gives "00000057 ERROR_INVALID_PARAMETER".
The execution crashes on an RtlHeapAlloc call, with "Access violation when reading [00000044]".
The RtlHeapAlloc function is invoked with following parameters
Heap= NULL
Flages= HEAP_NO_SERIALIZE
Size=7
Any light you may shed on this issue will be more then welcomed. If you need any of the sources I'll gladly attach them.