Quantcast
Channel: WE MOVED to github.com/microsoft/cpprestsdk. This site is not monitored!
Viewing all articles
Browse latest Browse all 4845

New Post: Use of memcpy() function with file_buffer or fstream::istream

$
0
0
Thank you steve,

.then([=](pplx::task<http_response> response)
{
try{
        http_response response1 = response.get();
        std::cout << "\n" << "statuscode:";
        std::cout << response1.status_code();
        std::cout << "\n" << "response body: ";
        ucout << response1.to_string();
        container_buffer<std::vector<uint8_t>> container;
        response1.body().read_to_end(container);
        std::vector<uint8_t> body = std::move(container.collection());
        std::cout << "\n ***************";
        std::cout<<container.size();
        DWORD length = container.size();
        IStream *m_pStream;
        HGLOBAL hMem;
        LPVOID pData = NULL;
        hMem = GlobalAlloc(GMEM_MOVEABLE, length);

        pData = GlobalLock(hMem);
        memmove(pData, &body, length);    //application crash here with memmove or memcpy
        GlobalUnlock(hMem);
        std::cout << "done";
        HRESULT hr = CreateStreamOnHGlobal(hMem, TRUE, &m_pStream);
        if (hr == S_OK)
        {
            std::cout << "done";
        }
    }
    catch (const http_exception &e)
    {
        std::cout << "error";
    }
}).wait();

I tried the code you provided me, but my application just crash at memcpy or memmove !

Viewing all articles
Browse latest Browse all 4845

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>