2

I am currently attempting to integrate the AzureStorageCPP into Unreal Engine 4 by using this documentation page. What I am doing is to create a custom C++ DLL wrapper around AzureStorageCPP, and then have Unreal Link this DLL in Unreal Code.

I installed the AzureStorageCPP as DLLs, via vcpkg. On completion, wastorage.dll is one of the important DLLs that needs to be linked.

The C++ DLL wrapper I wrote around AzureStorageCPP is below:

#include "was/storage_account.h"
#include "was/blob.h"

void UploadFileToAzure(char* FileName)
{
    azure::storage::cloud_storage_account storage_account = azure::storage::cloud_storage_account::parse(U("DefaultEndpointsProtocol=https;AccountName=test;AccountKey=test"));

}

As far as I can tell, azure::storage::cloud_storage_account::parse lives in wastorage.dll

The issue is that when this parsing code is executed as a C++ Console, it runs just fine. The ConnectionString is passed correctly down the callstack to wastorage.dll, and the connection string is not garbage.

Here is the view one level down the callstack from the code above.

Image

However, if I put the code into the C++ wrapper DLL I made called AzureStorage.DLL, link it into Unreal, and call from there, with the same call stack the string becomes garbage when it gets passed into wastorage.dll to parse.

Image Image

I thought this might be related to this issue, but I still don't understand how to fix this, as I don't control the Parse method that is from AzureStorage.

Here is how I created the C++ DLL wrapper header, the source is already shown above:

AzureStorage.h

#pragma once

#define AZURESTORAGEDLL_API _declspec(dllexport)

#ifdef __cplusplus      //if C++ is used convert it to C to prevent C++'s name mangling of method names
extern "C"
{
#endif

    void AZURESTORAGEDLL_API UploadFileToAzure(char* FileName);

#ifdef __cplusplus
}
#endif
Community
  • 1
  • 1
Mantracker
  • 613
  • 10
  • 22
  • Figure out how `string_t` is defined. It appears to be defined as a narrow string (a sequence of `char`s) in the calling code, but as wide string (a sequence of `wchar_t`s) inside the DLL. It's probably controlled by some macro, which you have defined inconsistently in two places. – Igor Tandetnik Jun 18 '19 at 03:50
  • Hi Igor, it seems that string_t is just a standard std::basic_string defined as typedef std::basic_string string_t. I am not quite sure what you mean by string_t being defined as a wide string, and that it is being controlled by a macro. Can you elaborate? Would this be code written by the AzureStorage library that is causing this, since I have not written any macro myself to handle this – Mantracker Jun 18 '19 at 16:30
  • What's `CharT`? Looks like it's `char` sometimes and `wchar_t` other times. – Igor Tandetnik Jun 18 '19 at 22:10

0 Answers0