I have a memory I allocated with VirtualAlloc and I have cast the type to some struct I created:
struct SomeStruct
{
    uint32 SomeInt;
    Class SomeClass;
};
like this:
MemoryBlock = VirtualAlloc(0, SizeInBytes, MEM_RESERVE|MEM_COMMIT, PAGE_READWRITE);
SomeStruct* NewPointer = (SomeStruct*)MemoryBlock ;
All the memory is initalized to zero BUT I have a problem with that, in the Class class I created, there is member of type std::unordered_map<std::string, int32>.
The problem is, when I try to use NewPointer->SomeClass it wont work and throw read access violation exception, which is right, but when I try to do this:
*NewPointer = {};
To initialize the struct (Including NewPointer->SomeClass) I get another exception about moving the std::unordered_map<std::string, int32> (again, read access violation exception).
(On the line where I initialize)
I don't really get what happens but I think it has something to do with moving the data or destructing it.
What can I do to make the above code work and for me to use SomeClass without causing exceptions?
By the way, I have to use the the allocated memory so I can't remove it. (I am sending the allocated memory to another .dll so I don't know the struct type when allocating the memory)


 
     
    