jeudi 31 août 2017

How to test a function which loads a DLL

I have a dll (MyDLL.dll), which I am loading in some class function and then calling a function "DLLProc" from it. Can I write this FuncLoad to be able to test it using a test framework like GTest / GMock...

HMODULE module;
SomeInterface service;
.
.
.
void MyClass::FuncLoad()
{
    auto libPath = std::wstring(L"MyDLL.dll");
    module = LoadLibrary(libPath.c_str());

    if (NULL != module)
    {
        ProcType fnObj = (ProcType)GetProcAddress(module, "DLLProc");
        if (NULL != fnObj)
        {
            service = fnObj();
        }
    }
}

Aucun commentaire:

Enregistrer un commentaire