从VB Com +应用程序调用c ++ Dll时堆损坏 [英] Heap Corruption while calling c++ Dll from VB Com+ Application

查看:70
本文介绍了从VB Com +应用程序调用c ++ Dll时堆损坏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



从VB Com +应用程序调用C ++ Dll时遇到堆损坏问题在Windows 2008 R2 Server窗口中.

我正在从COM +应用程序调用下面的函数. Com +激活类型设置为服务器应用程序",身份"设置为此用户(管理员)

char * __stdcall EncryptString(char * lpPlain)
{
    
    CRijndael oRijndael;
    char lpKey [17] =" 1234567890123456" ;;
    char * lpCipher = NULL;
    char * lpHexCipher = NULL;
    int nLength = strlen(lpPlain);
    char * pszPlain = NULL;
    int nLengthMultiple = nLength +(16-(nLength%16));

    if(strlen(lpPlain)== 0)
    {
       return(");
    }
    
    pszPlain =(char *)malloc(nLengthMultiple + 1);
    memset(pszPlain,32,nLengthMultiple);
    memcpy(pszPlain,lpPlain,nLength);

    pszPlain [nLengthMultiple] ='\ 0';

    lpCipher =(char *)malloc(nLengthMultiple);
    oRijndael.MakeKey(lpKey,"\ 0 \ 0 \ 0 \ 0 \ 0 \ 0 \ 0 \ 0 \ 0 \ 0 \ 0 \ 0 \ 0 \ 0 \ 0 \ 0",16,16);
    oRijndael.Encrypt(pszPlain,lpCipher,nLengthMultiple,1);

    lpHexCipher =(char *)malloc(2 * nLengthMultiple);

    CharStr2HexStr(((unsigned char *)lpCipher,lpHexCipher,nLengthMultiple);
    lpHexCipher [nLengthMultiple * 2] ='\ 0';

   免费(lpCipher);
   免费(pszPlain);

   返回lpHexCipher;
   
}

我已经在调试模式下检查了上面的函数,并且该函数正在返回加密的值,但是在返回该值之后,堆变得损坏了.

如果我将Com +应用程序激活类型更改为库",则应用程序功能正常,但我需要在服务器端运行Com +应用程序.

在Windows 2003 Server上可以正常使用.

如果有人知道此问题,请提供帮助.

谢谢

Girja Pandey

Hi,

I'm Getting Heap Corruption while calling C++ Dll from VB Com+ application  in window 2008 R2 Server.

I'm calling below function from COM+ application. Com+ Activation Type is set as Server application and Identity is set to this User (administrator)

char * __stdcall EncryptString (char *lpPlain)
{
    
    CRijndael oRijndael;
    char lpKey[17] = "1234567890123456";
    char *lpCipher = NULL;
    char *lpHexCipher = NULL;
    int nLength = strlen(lpPlain);
    char *pszPlain = NULL;
    int nLengthMultiple = nLength + (16 - (nLength % 16));

    if ( strlen(lpPlain) == 0 )
    {
        return ("");
    }
    
    pszPlain = (char *) malloc ( nLengthMultiple + 1);
    memset (pszPlain, 32, nLengthMultiple);
    memcpy (pszPlain, lpPlain, nLength);

    pszPlain[nLengthMultiple] = '\0';

    lpCipher = (char *)malloc(nLengthMultiple);
    oRijndael.MakeKey(lpKey, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0", 16, 16);
    oRijndael.Encrypt (pszPlain, lpCipher, nLengthMultiple, 1);

    lpHexCipher = (char *) malloc(2 * nLengthMultiple);

    CharStr2HexStr ((unsigned char *)lpCipher, lpHexCipher, nLengthMultiple);
    lpHexCipher[nLengthMultiple * 2] = '\0';

    free (lpCipher);
    free (pszPlain);

    return lpHexCipher;
   
}

I have checked the above function in debug mode and function is returning encrypted value, but after returning the value, heap is getting corrupt.

If I change the Com+ application activation type to Library application function is working fine but I need to run Com+ application on Server Side.

This working fine with windows 2003 server.

If some is aware with this issue please help.

Thanks

Girja Pandey

推荐答案

您好,您可以在一般的VC ++论坛中发布此问题吗(
Hi could you post this question in the general VC++ forum (http://social.msdn.microsoft.com/Forums/vstudio/en-US/home?forum=vcgeneral)


这篇关于从VB Com +应用程序调用c ++ Dll时堆损坏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆