This commit is contained in:
2024-08-07 09:12:07 -04:00
parent ca445435a0
commit fdfadd5c7e
1021 changed files with 73601 additions and 0 deletions

85
com/hold/inproc.cpp Normal file
View File

@@ -0,0 +1,85 @@
#include <com/factory.hpp>
#include <com/inproc.hpp>
#include <common/console.hpp>
DLLServer sDLLServer;
Console sWinConsole(Console::ConsoleType(Console::Write|Console::Read),true);
ClassFactory sClassFactory(sDLLServer,sWinConsole);
STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid,void **ppv)
{
sWinConsole.writeLine("<DllGetClassObject>");
*ppv=0;
return sClassFactory.QueryInterface(riid,ppv);
}
STDAPI DllCanUnloadNow(void)
{
sWinConsole.writeLine("<DllCanUnloadNow>");
return (0==sDLLServer.getRefCount()&&0==sDLLServer.getLockCount()?S_OK:S_FALSE);
}
#if 0
BOOL _stdcall DllMain(HINSTANCE /*hInstance*/,DWORD reasonCode,LPVOID /*lpvReserved*/)
{
switch(reasonCode)
{
case DLL_PROCESS_ATTACH :
sWinConsole.writeLine("<Process attach.>");
break;
case DLL_PROCESS_DETACH :
sWinConsole.writeLine("<Process detach.>");
sWinConsole.read();
break;
}
return TRUE;
}
#endif
InProcServer::InProcServer(IUnknown *pUnkOuter,REFIID riid,Console &winConsole)
: mUnkOuter(pUnkOuter), mRefCount(0), mWinConsole(winConsole)
{
getConsole().writeLine("<InProcServer::InProcServer>");
}
InProcServer::~InProcServer()
{
getConsole().writeLine("<InProcServer::~InProcServer>");
}
InProcServer &InProcServer::operator=(const InProcServer &/*someInProcServer*/)
{ // private implementation
return *this;
}
HRESULT __stdcall InProcServer::QueryInterface(REFIID riid,void **ppv)
{
getConsole().writeLine("<InProcServer::QueryInterface>");
*ppv=0;
if(IsEqualIID(riid,IID_IUnknown)||IsEqualIID(riid,getREFIID()))
{
*ppv=getInstance();
// *ppv=this;
AddRef();
return NOERROR;
}
return ComResult::NoInterface;
}
ULONG __stdcall InProcServer::AddRef(void)
{
getConsole().writeLine("<InProcServer::AddRef>");
return ++mRefCount;
}
ULONG __stdcall InProcServer::Release(void)
{
getConsole().writeLine("<InProcServer::Release>");
if(0==--mRefCount)::delete this;
return mRefCount;
}
Console &InProcServer::getConsole(void)
{
return mWinConsole;
}