Load DLL exported data dynamically

南楼画角 提交于 2019-12-11 08:49:13

问题


Is there a version of GetProcAddress for exported data?

I would like to do something like:

Mydll.cpp:

MyDataType::MyDataType(long, wchar_t*)
{
    //Dummy code
    this->temp = 3;
}
__declspec(dllexport) MyDataType Here(50, L"random text");

MyClient.cpp:

int main(void)
{
    HINSTANCE hData = LoadLibrary("MyDll.dll");
    reinterpret_cast<MyDataType*>(GetDataAddress(hData, "Here"))->DoSomething();
}

That is, define an exported data ("Here") of UDT ("MyDataType"), and them obtain its address when the DLL is dynamically loaded. Is this possible?


回答1:


the msdn page says "Retrieves the address of an exported function or variable from the specified dynamic-link library (DLL)." - ie it should Just Work(tm)



来源:https://stackoverflow.com/questions/32193790/load-dll-exported-data-dynamically

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!