-1

I am trying to compile a tool for my project. I have solved all the problems so far, but i can't find the solution for this problem.

If anyone could give me help, i would appreciate it, Thank you.

NtlScriptEncrypter.cpp

#include "StdAfx.h"
#include "NtlScriptEncrypter.h"
#include "NtlXMLDoc.h"
#include "NtlFileSerializer.h"

#define CRYPT_PASSWORD "!@*&(agebreak"

CNtlScriptEncrypter::CNtlScriptEncrypter(void)
{
}

CNtlScriptEncrypter::~CNtlScriptEncrypter(void)
{
}

/**
 * ÄÁÇÇ±× ¼³Á¤ ÆÄÀÏÀ» ·ÎµåÇÑ´Ù. È®ÀåÀÚ·Î XML,EDF¸¦ ±¸º°ÇÑ´Ù.
 * \param pConfigData ·ÎµåÇÑ µ¥ÀÌÅ͸¦ ÀúÀåÇÒ Æ÷ÀÎÅÍ
 * \param szFileName ·ÎµåÇÒ ÆÄÀÏ À̸§
 * \return 
 */
BOOL CNtlScriptEncrypter::LoadConfigOption( OUT SConfigData* pConfigData, char* szFileName ) 
{
    if(!pConfigData || !szFileName)
        return FALSE;

    char szDrive[128]   = {0,};
    char szdir[128]     = {0,};
    char szfName[128]   = {0,};
    char szExt[128]     = {0,};
    _splitpath_s(szFileName, szDrive, szdir, szfName, szExt);    
    _strlwr_s(szExt);
    
    if(strcmp(szExt, ".xml") == 0)
    {
        return LoadConfigOptionXML(pConfigData, szFileName);
    }
    else if(strcmp(szExt, ".edf") == 0)
    {
        return LoadConfigOptionENC(pConfigData, szFileName);
    }

    return FALSE;
}

BOOL CNtlScriptEncrypter::LoadConfigOptionXML( OUT SConfigData* pConfigData, char* szFileName ) 
{
    CNtlXMLDoc doc;
    doc.Create();

    // xml doc load
    if(doc.Load( (char*)szFileName ) == false)
    {
        return FALSE;
    }

    char chBuffer[1024];

    // config operationÀ» ¾ò¾î¿Â´Ù.
    IXMLDOMNode* pNode = doc.SelectSingleNode((char*)"/config_options/op");

    if(!doc.GetTextWithAttributeName(pNode, "ver", chBuffer, 1024))
    {
        return FALSE;
    }

    if(!doc.GetTextWithAttributeName(pNode, "ip", chBuffer, 1024))
    {
        return FALSE;
    }

    pConfigData->strAddr = chBuffer;

    if(!doc.GetTextWithAttributeName(pNode, "port", chBuffer, 1024))
    {
        return FALSE;
    }

    pConfigData->dwPort = (DWORD)atoi(chBuffer);

    pNode->Release(); 

    // config localÀ» ¾ò¾î¿Â´Ù.

    pNode = doc.SelectSingleNode((char*)"/config_options/local");

    if(!doc.GetTextWithAttributeName(pNode, "ver", chBuffer, 1024))
    {
        return FALSE;
    }

    if(!doc.GetTextWithAttributeName(pNode, "local_dsp", chBuffer, 1024))
    {
        return FALSE;
    }

    pConfigData->strLocalDsp = chBuffer;

    if(!doc.GetTextWithAttributeName(pNode, "local_sync_dsp", chBuffer, 1024))
    {
        return FALSE;
    }

    pConfigData->strLocalSyncDsp = chBuffer;

    // Bug Trap
    pNode = doc.SelectSingleNode("/config_options/BUGTRAP");
    if(doc.GetTextWithAttributeName(pNode, "ip", chBuffer, 1024))
    {
        pConfigData->strBugTrapServerIP = chBuffer;
    }

    if(doc.GetTextWithAttributeName(pNode, "port", chBuffer, 1024))
    {
        pConfigData->dwBugTrapServerPort = atoi(chBuffer);        
    }

    pNode->Release(); 

    return TRUE;
}

BOOL CNtlScriptEncrypter::LoadConfigOptionENC( OUT SConfigData* pConfigData, char* szFileName ) 
{
    USES_CONVERSION;

    CNtlFileSerializer nsl(1024 * 1024, 1024 * 1024);

    WCHAR* wszFileName;
    WCHAR* wszCryptPassword;

    mbstowcs(wszFileName, szFileName, sizeof(szFileName));
    mbstowcs(wszCryptPassword, CRYPT_PASSWORD, sizeof(CRYPT_PASSWORD));

    if (!nsl.LoadFile(wszFileName, TRUE, wszCryptPassword))
        return FALSE;

    std::string strAddr = "";
    std::string strLocalDsp = "";
    std::string strLocalSyncDsp = "";
    std::string strBugTrapServerIP ="";

    nsl>>strAddr;
    nsl>>pConfigData->dwPort;
    nsl>>strLocalDsp;
    nsl>>strLocalSyncDsp;
    nsl>>strBugTrapServerIP;
    nsl>>pConfigData->dwBugTrapServerPort;

    pConfigData->strAddr = A2W(strAddr.c_str());
    pConfigData->strLocalDsp = A2W(strLocalDsp.c_str());
    pConfigData->strLocalSyncDsp = A2W(strLocalSyncDsp.c_str());
    pConfigData->strBugTrapServerIP = A2W(strBugTrapServerIP.c_str());

    return TRUE;
}

BOOL CNtlScriptEncrypter::SaveConfigOption(SConfigData* pConfigData, char* szFileName, BOOL bEncrypt /* = FALSE */)
{
    if(!pConfigData || !szFileName)
        return FALSE;

    if(bEncrypt)
    {
        return SaveConfigOptionENC(pConfigData, szFileName, CRYPT_PASSWORD);
    }
    else
    {
        return SaveConfigOptionXML(pConfigData, szFileName);
    }    
}

BOOL CNtlScriptEncrypter::SaveConfigOptionXML( SConfigData* pConfigData, char* szFileName ) 
{
    USES_CONVERSION;

    CNtlXMLDoc doc;
    doc.Create();

    IXMLDOMProcessingInstruction* pPI    = NULL;        

    doc.GetDocument()->createProcessingInstruction(L"xml", L"version=\"1.0\" encoding = \"UTF-8\"", &pPI);
    if(!pPI)
        return FALSE;
    doc.GetDocument()->appendChild(pPI, NULL);

    IXMLDOMElement*     pElemRoot = NULL;                ///< Root Element
    IXMLDOMElement*     pElemOp = NULL;
    IXMLDOMElement*     pElemLocal = NULL;
    IXMLDOMElement*     pElemBUGTrap = NULL;

    doc.GetDocument()->createElement(L"config_options", &pElemRoot);
    doc.GetDocument()->appendChild(pElemRoot, NULL);

    WCHAR wbuf[1204] = {0,};

    doc.GetDocument()->createElement(L"op", &pElemOp);
    pElemOp->setAttribute(L"ver", (_variant_t)L"0.1");
    pElemOp->setAttribute(L"ip", (_variant_t)pConfigData->strAddr);
    swprintf_s(wbuf, L"%d", pConfigData->dwPort);
    pElemOp->setAttribute(L"port", (_variant_t)wbuf);    

    doc.GetDocument()->createElement(L"local", &pElemLocal);
    pElemLocal->setAttribute(L"ver", (_variant_t)L"0.1");
    pElemLocal->setAttribute(L"local_dsp", (_variant_t)pConfigData->strLocalDsp);
    pElemLocal->setAttribute(L"local_sync_dsp", (_variant_t)pConfigData->strLocalSyncDsp);    

    doc.GetDocument()->createElement(L"BUGTRAP", &pElemBUGTrap);
    pElemBUGTrap->setAttribute(L"ip", (_variant_t)pConfigData->strBugTrapServerIP);
    swprintf_s(wbuf, L"%d", pConfigData->dwBugTrapServerPort);
    pElemBUGTrap->setAttribute(L"port", (_variant_t)wbuf);

    pElemRoot->appendChild(pElemOp, NULL);
    pElemRoot->appendChild(pElemLocal, NULL);
    pElemRoot->appendChild(pElemBUGTrap, NULL);

    doc.SetIndent(L"indent.xsl");
    HRESULT hr = doc.GetDocument()->save((_variant_t)szFileName);
    if(hr != S_OK)
        return FALSE;

    return TRUE;
}

BOOL CNtlScriptEncrypter::SaveConfigOptionENC( SConfigData* pConfigData, char* szFileName, char* szCryptPassword ) 
{
    USES_CONVERSION;

    CNtlFileSerializer nsl(1024 * 1024, 1024 * 1024);

    std::string strAddr = W2A(pConfigData->strAddr);
    std::string strLocalDsp = W2A(pConfigData->strLocalDsp);
    std::string strLocalSyncDsp = W2A(pConfigData->strLocalSyncDsp);
    std::string strBugTrapServerIP = W2A(pConfigData->strBugTrapServerIP);

    nsl<<strAddr;
    nsl<<pConfigData->dwPort;
    nsl<<strLocalDsp;
    nsl<<strLocalSyncDsp;
    nsl<<strBugTrapServerIP;
    nsl<<pConfigData->dwBugTrapServerPort;

    return nsl.SaveFile(szFileName, TRUE, szCryptPassword);

    return TRUE;
}

NtlScriptEncrypter.h

class CNtlScriptEncrypter
{
public:
    CNtlScriptEncrypter(void);
    ~CNtlScriptEncrypter(void);

    static BOOL LoadConfigOption(OUT SConfigData* pConfigData, char* szFileName);             
    static BOOL SaveConfigOption(SConfigData* pConfigData, char* szFileName, BOOL bEncrypt = FALSE); 

protected:
    static BOOL LoadConfigOptionXML(OUT SConfigData* pConfigData, char* szFileName);
    static BOOL LoadConfigOptionENC(OUT SConfigData* pConfigData, char* szFileName);
    static BOOL SaveConfigOptionXML(SConfigData* pConfigData, char* szFileName);
    static BOOL SaveConfigOptionENC(SConfigData* pConfigData, char* szFileName, char* szCryptPassword);
}; 

NtlXMLDoc.cpp


#include "StdAfx.h"
#include <comdef.h>
#include <atlbase.h>
#include "NtlXMLDoc.h"
//#include "NtlAssert.h"


class CCoInit
{
public:
    CCoInit( void )
    {
        ::CoInitialize( NULL );
    }

    ~CCoInit( void )
    {
        ::CoUninitialize();
    }
};

CCoInit g_CoInit;

CNtlXMLDoc::CNtlXMLDoc(void)
{
    Init();
}

CNtlXMLDoc::~CNtlXMLDoc(void)
{
    Destroy();
}

bool CNtlXMLDoc::Create()
{
    if (NULL != m_pXMLDocument)
        return false;

    HRESULT hResult;

    hResult = ::CoCreateInstance(__uuidof(DOMDocument30), NULL, CLSCTX_INPROC_SERVER, __uuidof(IXMLDOMDocument), (void**)&m_pXMLDocument);
    if (FAILED(hResult))
    {
        ::CoInitialize( NULL );
        hResult = ::CoCreateInstance(__uuidof(DOMDocument30), NULL, CLSCTX_INPROC_SERVER, __uuidof(IXMLDOMDocument), (void**)&m_pXMLDocument);
        if (FAILED(hResult))
        {
            Destroy();
            return false;
        }
    }

    if (NULL == m_pXMLDocument)
    {
        Destroy();
        return false;
    }

    hResult = m_pXMLDocument->put_async(VARIANT_FALSE);
    if (FAILED(hResult))
    {
        Destroy();
        return false;
    }

    hResult = m_pXMLDocument->put_validateOnParse(VARIANT_FALSE);
    if (FAILED(hResult))
    {
        Destroy();
        return false;
    }

    hResult = m_pXMLDocument->put_resolveExternals(VARIANT_FALSE);
    if (FAILED(hResult))
    {
        Destroy();
        return false;
    }

    return true;
}

bool CNtlXMLDoc::Destroy()
{
    if (NULL != m_pXMLDocument)
    {
        m_pXMLDocument->Release();
        m_pXMLDocument = NULL;
    }

    m_bIsFileLoaded = false;

    return true;
}

void CNtlXMLDoc::Init()
{
    m_pXMLDocument = NULL;
    m_bIsFileLoaded = false;
}
bool CNtlXMLDoc::Load(WCHAR* pwszFileName, LONG* lLineNumber, BSTR* bstrErrorReasonString )
{
    if (false != m_bIsFileLoaded)
        return false;

    VARIANT_BOOL status = VARIANT_FALSE;
    HRESULT hResult = m_pXMLDocument->load((_variant_t)pwszFileName, &status);
    if (FAILED(hResult))
    {
        return false;
    }

    if (VARIANT_FALSE == status)
    {
        IXMLDOMParseError* pXMLError = NULL;
        m_pXMLDocument->get_parseError(&pXMLError);

        //BSTR bstrErrorReasonString;
        //LONG lLineNumber = 0;
        BSTR bstrSrcText;
        LONG lLinePosition = 0;

        pXMLError->get_srcText(&bstrSrcText);
        pXMLError->get_reason(bstrErrorReasonString);
        pXMLError->get_line(lLineNumber);
        pXMLError->get_linepos(&lLinePosition);

        //::SysFreeString(*bstrErrorReasonString);

        pXMLError->Release();

        return false;
    }

    m_bIsFileLoaded = true;

    return true;
}

bool CNtlXMLDoc::Load(WCHAR* pwszFileName )
{
    if (false != m_bIsFileLoaded)
        return false;

    VARIANT_BOOL status = VARIANT_FALSE;
    HRESULT hResult = m_pXMLDocument->load((_variant_t)pwszFileName, &status);
    if (FAILED(hResult))
    {
        return false;
    }

    if (VARIANT_FALSE == status)
    {
        IXMLDOMParseError* pXMLError = NULL;
        m_pXMLDocument->get_parseError(&pXMLError);

        BSTR bstrErrorReasonString;
        LONG lLineNumber = 0;
        BSTR bstrSrcText;
        LONG lLinePosition = 0;

        pXMLError->get_srcText(&bstrSrcText);
        pXMLError->get_reason(&bstrErrorReasonString);
        pXMLError->get_line(&lLineNumber);
        pXMLError->get_linepos(&lLinePosition);

        ::SysFreeString(bstrErrorReasonString);

        pXMLError->Release();

        return false;
    }

    m_bIsFileLoaded = true;

    return true;
}

bool CNtlXMLDoc::Load(char* pszFileName)
{
    if (false != m_bIsFileLoaded)
        return false;

    WCHAR wszUnicodeFileName[MAX_UNICODE_FILE_NAME_LENGTH + 1];
    ZeroMemory(wszUnicodeFileName, sizeof(WCHAR) * (MAX_UNICODE_FILE_NAME_LENGTH + 1));

    int iWrittenChars = ::MultiByteToWideChar(GetACP(), 0, pszFileName, -1, wszUnicodeFileName, MAX_UNICODE_FILE_NAME_LENGTH);
    wszUnicodeFileName[MAX_UNICODE_FILE_NAME_LENGTH] = L'\0';

    if (0 == iWrittenChars)
        return false;

    return Load(wszUnicodeFileName);
}

bool CNtlXMLDoc::LoadXML( char* szXMLBuffer ) 
{
    USES_CONVERSION;

    if(false != m_bIsFileLoaded)
        return false;

    return LoadXML(A2W(szXMLBuffer));
}

bool CNtlXMLDoc::LoadXML( WCHAR* wszXMLBuffer ) 
{
    if (false != m_bIsFileLoaded)
        return false;

    VARIANT_BOOL status;    
    HRESULT hResult = m_pXMLDocument->loadXML(wszXMLBuffer, &status);

    if (FAILED(hResult))
    {
        return false;
    }

    if (VARIANT_FALSE == status)
    {
        IXMLDOMParseError* pXMLError = NULL;
        m_pXMLDocument->get_parseError(&pXMLError);

        BSTR bstrErrorReasonString;
        pXMLError->get_reason(&bstrErrorReasonString);
        ::SysFreeString(bstrErrorReasonString);

        pXMLError->Release();

        return false;
    }

    m_bIsFileLoaded = true;

    return true;
}


IXMLDOMNode* CNtlXMLDoc::SelectSingleNode(WCHAR* pwszXPath)
{
    if (false == m_bIsFileLoaded)
        return NULL;
    if (NULL == pwszXPath)
        return NULL;

    IXMLDOMNode* pXMLNode = NULL;

    BSTR bstrXPath = ::SysAllocString(pwszXPath);
    HRESULT hResult = m_pXMLDocument->selectSingleNode(bstrXPath, &pXMLNode);
    if (FAILED(hResult))
    {
        ::SysFreeString(bstrXPath);
        return NULL;
    }

    ::SysFreeString(bstrXPath);
    return pXMLNode;
}

IXMLDOMNode* CNtlXMLDoc::SelectSingleNode(char* pszXPath)
{
    if (false == m_bIsFileLoaded)
        return NULL;

    WCHAR wszUnicodeXPath[MAX_UNICODE_XPATH_LENGTH + 1];
    ZeroMemory(wszUnicodeXPath, sizeof(WCHAR) * (MAX_UNICODE_XPATH_LENGTH + 1));

    int iWrittenChars = ::MultiByteToWideChar(GetACP(), 0, pszXPath, -1, wszUnicodeXPath, MAX_UNICODE_XPATH_LENGTH);
    wszUnicodeXPath[MAX_UNICODE_XPATH_LENGTH] = L'\0';

    if (0 == iWrittenChars)
        return NULL;

    return SelectSingleNode(wszUnicodeXPath);
}

IXMLDOMNodeList* CNtlXMLDoc::SelectNodeList(WCHAR* pwszXPath)
{
    if (false == m_bIsFileLoaded)
        return NULL;
    if (NULL == pwszXPath)
        return NULL;

    IXMLDOMNodeList* pXMLNodeList = NULL;

    BSTR bstrXPath = ::SysAllocString(pwszXPath);
    HRESULT hResult = m_pXMLDocument->selectNodes(bstrXPath, &pXMLNodeList);
    if (FAILED(hResult))
    {
        ::SysFreeString(bstrXPath);
        return NULL;
    }

    ::SysFreeString(bstrXPath);
    return pXMLNodeList;
}

IXMLDOMNodeList* CNtlXMLDoc::SelectNodeList(char* pszXPath)
{
    if (false == m_bIsFileLoaded)
        return NULL;

    WCHAR wszUnicodeXPath[MAX_UNICODE_XPATH_LENGTH + 1];
    ZeroMemory(wszUnicodeXPath, sizeof(WCHAR) * (MAX_UNICODE_XPATH_LENGTH + 1));

    int iWrittenChars = ::MultiByteToWideChar(GetACP(), 0, pszXPath, -1, wszUnicodeXPath, MAX_UNICODE_XPATH_LENGTH);
    wszUnicodeXPath[MAX_UNICODE_XPATH_LENGTH] = L'\0';

    if (0 == iWrittenChars)
        return NULL;

    return SelectNodeList(wszUnicodeXPath);
}

bool CNtlXMLDoc::GetTextWithAttributeName(IXMLDOMNode* pNode, WCHAR* pwszAttributeName, WCHAR* pwszResultText, int nBufferSizeInWChars)
{
    if (NULL == pNode || NULL == pwszAttributeName || NULL == pwszResultText)
    {
        //      NtlAssertFail("NULL == pNode || NULL == pwszAttributeName || NULL == pwszResultText");
        return false;
    }
    if (0 >= nBufferSizeInWChars)
    {
        //      NtlAssertFail("0 >= nBufferSizeInWChars");
        return false;
    }

    IXMLDOMNamedNodeMap* pMap = NULL;
    pNode->get_attributes(&pMap);
    if (NULL == pMap)
    {
        //      NtlAssertFail("Couldn't get the attribute list from the given IXMLDOMNode.");
        return false;
    }

    IXMLDOMNode* pVirtualNode = NULL;
    pMap->getNamedItem(pwszAttributeName, &pVirtualNode);
    if (NULL == pVirtualNode)
    {
        //      NtlAssertFail("Couldn't find the given attribute name.");
        return false;
    }

    VARIANT var;
    VariantInit(&var);
    pVirtualNode->get_nodeValue(&var);

    if (wcslen(V_BSTR(&var)) >= (size_t)nBufferSizeInWChars)
    {
        //      NtlAssertFail("The buffer size is not enough to take the whole attribute value.");
        return false;
    }

    wcscpy_s(pwszResultText, nBufferSizeInWChars, V_BSTR(&var));

    return true;
}

bool CNtlXMLDoc::GetTextWithAttributeName(IXMLDOMNode* pNode, char* pszAttributeName, char* pszResultText, int nBufferSizeInBytes)
{
    if (NULL == pNode || NULL == pszAttributeName || NULL == pszResultText)
    {
        //      NtlAssertFail("NULL == pNode || NULL == pszAttributeName || NULL == pszResultText");
        return false;
    }
    if (0 >= nBufferSizeInBytes)
    {
        //      NtlAssertFail("0 >= nBufferSizeInBytes");
        return false;
    }

    int nRequiredBytes = 0;
    nRequiredBytes = MultiByteToWideChar(GetACP(), 0, pszAttributeName, -1, NULL, 0);
    if (0 == nRequiredBytes)
    {
        //      NtlAssertFail("The given attribute name can't be converted into WCHAR type for some reason.");
        return false;
    }
    if (nRequiredBytes > (CNtlXMLDoc::MAX_ATTRIBUTE_NAME_IN_WCHAR + 1))
    {
        //      NtlAssertFail("The given attribute name is too long.");
        return false;
    }

    WCHAR pwszAttributeNameInWChar[CNtlXMLDoc::MAX_ATTRIBUTE_NAME_IN_WCHAR + 1];

    int nUsedBufferSize = MultiByteToWideChar(GetACP(), 0, pszAttributeName, -1, pwszAttributeNameInWChar, (CNtlXMLDoc::MAX_ATTRIBUTE_NAME_IN_WCHAR + 1));
    if (0 == nUsedBufferSize)
    {
        //      NtlAssertFail("The given attribute name couldn't be converted into WCHAR type for some reason.");
        return false;
    }

    IXMLDOMNamedNodeMap* pMap = NULL;
    pNode->get_attributes(&pMap);
    if (NULL == pMap)
    {
        //      NtlAssertFail("Couldn't get the attribute list from the given IXMLDOMNode.");
        return false;
    }

    IXMLDOMNode* pVirtualNode = NULL;
    pMap->getNamedItem(pwszAttributeNameInWChar, &pVirtualNode);
    if (NULL == pVirtualNode)
    {
        //      NtlAssertFail("Couldn't find the given attribute name.");
        return false;
    }

    VARIANT var;
    VariantInit(&var);
    pVirtualNode->get_nodeValue(&var);

    nRequiredBytes = WideCharToMultiByte(::GetACP(), 0, V_BSTR(&var), -1, pszResultText, 0, NULL, NULL);
    if (nRequiredBytes > nBufferSizeInBytes)
    {
        //      NtlAssertFail("The buffer size is not enough to take the whole attribute value.");
        return false;
    }

    WideCharToMultiByte(GetACP(), 0, V_BSTR(&var), -1, pszResultText, nBufferSizeInBytes, NULL, NULL);
    return true;
}

bool CNtlXMLDoc::GetDataWithXPath(WCHAR* pwszXPath, WCHAR* pwszResultData, int nBufferSizeInWChars)
{
    if (NULL == pwszXPath || NULL == pwszResultData || 0 >= nBufferSizeInWChars)
        return false;

    IXMLDOMNode* pNode = NULL;    
    m_pXMLDocument->selectSingleNode(pwszXPath, &pNode);

    if(!pNode)
        return false;

    BSTR bstr = NULL;
    if (FAILED(pNode->get_text(&bstr)))
    {
        ::SysFreeString(bstr);
        pNode->Release();           
        return false;
    }

    wcscpy_s(pwszResultData, nBufferSizeInWChars, bstr);

    ::SysFreeString(bstr);
    pNode->Release();

    return true;
}

bool CNtlXMLDoc::GetDataWithXPath(char* pszXPath, char* pszResultData, int nBufferSizeInBytes)
{
    if (NULL == pszXPath || NULL == pszResultData || 0 >= nBufferSizeInBytes)
        return false;

    WCHAR wszUnicodeXPath[1024 + 1];

    int iRequiredChars = ::MultiByteToWideChar(GetACP(), 0, pszXPath, -1, NULL, 0);
    if (_countof(wszUnicodeXPath) < iRequiredChars)
        return false;

    int iWrittenChars = ::MultiByteToWideChar(GetACP(), 0, pszXPath, -1, wszUnicodeXPath, _countof(wszUnicodeXPath));
    if (0 == iWrittenChars)
        return false;
    wszUnicodeXPath[_countof(wszUnicodeXPath) - 1] = L'\0';

    WCHAR wszUnicodeResultData[1024 + 1];
    if (false == GetDataWithXPath(wszUnicodeXPath, wszUnicodeResultData, _countof(wszUnicodeResultData)))
        return false;

    iRequiredChars = ::WideCharToMultiByte(GetACP(), 0, wszUnicodeResultData, -1, NULL, 0, NULL, NULL);
    if (nBufferSizeInBytes < iRequiredChars)
        return false;

    iWrittenChars = ::WideCharToMultiByte(GetACP(), 0, wszUnicodeResultData, -1, pszResultData, nBufferSizeInBytes, NULL, NULL);
    if (0 == iWrittenChars)
        return false;
    pszResultData[nBufferSizeInBytes - 1] = '\0';

    return true;
}

/**
* XML ÆÄÀÏÀÇ ÇüŸ¦ TabÀ» ÀÌ¿ëÇØ¼­ º¸±â ÁÁ°Ô Á¤·ÄÇÑ´Ù.
* \param szIndentFileName Á¤·Ä¿¡ »ç¿ëÇÒ ½ºÅ¸ÀÏ ½ÃÆ® ÆÄÀϸí
* return ¼º°ø À¯¹«
*/
bool CNtlXMLDoc::SetIndent(WCHAR* szIndentFileName)
{
    IXMLDOMDocument* pXSL = NULL;
    CoCreateInstance(__uuidof(DOMDocument30), NULL, CLSCTX_INPROC_SERVER, __uuidof(IXMLDOMDocument), (void**)&pXSL);
    if(!pXSL)
        return false;

    VARIANT_BOOL vBool;
    pXSL->put_async(VARIANT_FALSE);
    pXSL->load((_variant_t)szIndentFileName, &vBool);

    VARIANT vObject;
    VariantInit(&vObject);
    vObject.vt = VT_DISPATCH;
    vObject.pdispVal = m_pXMLDocument;

    m_pXMLDocument->transformNodeToObject(pXSL, vObject);

    if(pXSL)
    {
        pXSL->Release();
        pXSL = NULL;
    }

    return true;
}

IXMLDOMDocument* CNtlXMLDoc::GetDocument(void)
{
    return m_pXMLDocument;
} 

Some errors that the console shows me:


 LNK2019    símbolo externo "public: bool __thiscall CNtlXMLDoc::GetTextWithAttributeName(struct IXMLDOMNode *,char *,char *,int)" (?GetTextWithAttributeName@CNtlXMLDoc@@QAE_NPAUIXMLDOMNode@@PAD1H@Z) sin resolver al que se hace referencia en la función "protected: static int __cdecl CNtlScriptEncrypter::LoadConfigOptionXML(struct _SConfigData *,char *)" (?LoadConfigOptionXML@CNtlScriptEncrypter@@KAHPAU_SConfigData@@PAD@Z)

I'm compiling it in VS 2019 with MFC and VC Compiler 2010. I think I linked all the libraries and headers in the project properties.

I have about 23 errors almost identical to the one above, all in the same obj file and referring to NtlXMLDoc functions.

If you can give me some advice that would be great. Thanks!

The project isn't created by me, it was a code released a time ago and I am trying to fix it

WhozCraig
  • 65,258
  • 11
  • 75
  • 141
player1
  • 1
  • 1
  • 2
    Why did you tag this "C#"? This seems to be C++. – Klaus Gütter Jun 05 '21 at 04:19
  • @KlausGütter Sorry, miss click. Thanks for edit – player1 Jun 05 '21 at 05:00
  • 1
    Does this answer your question? [What is an undefined reference/unresolved external symbol error and how do I fix it?](https://stackoverflow.com/questions/12573816/what-is-an-undefined-reference-unresolved-external-symbol-error-and-how-do-i-fix) – Ulrich Eckhardt Jun 05 '21 at 05:14
  • You probably forgot to add NtlXMLDoc.cpp to the project. – n. m. could be an AI Jun 05 '21 at 06:48
  • @UlrichEckhardt I tried all the solutions suggested by the post you shared with me, but I still have the same problem – player1 Jun 05 '21 at 07:05
  • @n.1.8e9-where's-my-sharem. The project has hundreds of cpp files,so i can't add all cpp to each project, it's divided into different projects. I included the header reference and linked it from c ++ project properties. – player1 Jun 05 '21 at 07:08
  • "and linked it". Or maybe not. I can't see your project from here so it's hard to tell. – n. m. could be an AI Jun 05 '21 at 08:05
  • Yes, sorry, i added the folder path what contains NtlXMLDoc.h to my project property in c/c++, and also i added the .lib of project what contains NtlXMLDoc.cpp to my Linker options in the project what i'm trying compile, any other idea? – player1 Jun 05 '21 at 08:28
  • "i added the folder path what contains NtlXMLDoc.h to my project property in c/c++, and also i added the .lib of project what contains NtlXMLDoc.cpp to my Linker options" These are all the right words but I cannot verify that NtlXMLDoc.cpp was indeed compiled and was indeed added to a library and that said library was indeed linked. All I can see is fragments of the source code, and I can see the function in question in the source code. The only reason why it is not found is that it was not linked. Why it was not linked I don't know, because I cannot see your project in its entirety. – n. m. could be an AI Jun 05 '21 at 10:00
  • Here I have an image that shows the file explorer of my solution, both projects are imbued. I can assure you that I'd what I described above, but I don't know if I'm missing a step so that it is correctly linked. https://pasteboard.co/K5g1WSF.png – player1 Jun 05 '21 at 21:50

1 Answers1

0

The solution was: add the project that contains NtlXMLDoc.cpp to my references in explorer of my project, because, they are in the same solution, but are a different project, and idk why through properties didn't worked

player1
  • 1
  • 1