In my current project I need some functions exported from ntdll.dll and csrsrv.dll.
There is no problem with getting handle for ntdll and pointer to functions. But when I try get handle for csrsrv.dll function fails with error code "File not found". I've tried to specify full path to file, but it dose not change a thing.
Code for my load function from dll function:
PVOID GetFunctionFromDll(const std::string& _sModuleName,const std::string& _sFnName)
{
HMODULE hModule = NULL;
PVOID ptrFn = NULL;
if(!GetModuleHandleEx(0,_sModuleName.c_str(),&hModule))
{
return 0;
}
ptrFn = GetProcAddress(hModule, _sFnName.c_str());
FreeLibrary(hModule); // preventing handle leakage
return ptrFn;
}
Any ideas why does it fail with csrsrv.dll?