⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mstscax.cpp

📁 ReactOS是一些高手根据Windows XP的内核编写出的类XP。内核实现机理和API函数调用几乎相同。甚至可以兼容XP的程序。喜欢研究系统内核的人可以看一看。
💻 CPP
📖 第 1 页 / 共 5 页
字号:
			return n;
		}

        virtual HRESULT STDMETHODCALLTYPE EnumConnectionPoints(IEnumConnectionPoints ** ppEnum)
		{
			dbgprintf(TEXT("CConnectionPointContainer::EnumConnectionPoints(%p)"), ppEnum);
			HRESULT hr = m_IConnectionPointContainer->EnumConnectionPoints(ppEnum);
			dbgprintf(TEXT("CConnectionPointContainer::EnumConnectionPoints -> %08X, pEnum = %p"), hr, *ppEnum);

			if(SUCCEEDED(hr))
				*ppEnum = HookIEnumConnectionPoints(*ppEnum);

			return hr;
		}
        
		virtual HRESULT STDMETHODCALLTYPE FindConnectionPoint(REFIID riid, IConnectionPoint ** ppCP)
		{
			dbgprintf(TEXT("CConnectionPointContainer::FindConnectionPoint(%ls, %p)"), UUIDToString(riid).c_str(), ppCP);
			HRESULT hr = m_IConnectionPointContainer->FindConnectionPoint(riid, ppCP);
			dbgprintf(TEXT("CConnectionPointContainer::FindConnectionPoint -> %08X, pCP = %p"), hr, *ppCP);

			if(SUCCEEDED(hr))
				*ppCP = HookIConnectionPoint(*ppCP);

			return hr;
		}
	};

	class CEnumConnectionPoints: public IEnumConnectionPoints
	{
	private:
		LONG m_refCount;
		IEnumConnectionPoints * m_IEnumConnectionPoints;

	public:
		CEnumConnectionPoints(IEnumConnectionPoints * pIEnumConnectionPoints):
			m_refCount(1),
			m_IEnumConnectionPoints(pIEnumConnectionPoints)
		{ }

		~CEnumConnectionPoints() { m_IEnumConnectionPoints->Release(); }

		virtual HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void ** ppvObject)
		{
			HRESULT hr = S_OK;

			dbgprintf(TEXT("CEnumConnectionPoints::QueryInterface(%ls, %p)"), UUIDToString(riid).c_str(), ppvObject);

			if(riid == IID_IUnknown || riid == IID_IEnumConnectionPoints)
				*ppvObject = this;
			else
			{
				*ppvObject = NULL;
				hr = E_NOINTERFACE;
			}
		
			dbgprintf(TEXT("CEnumConnectionPoints::QueryInterface -> %08X, ppvObject = %p"), hr, *ppvObject);
			return hr;
		}

		virtual ULONG STDMETHODCALLTYPE AddRef(void)
		{
			return InterlockedIncrement(&m_refCount);
		}

		virtual ULONG STDMETHODCALLTYPE Release(void)
		{
			LONG n = InterlockedDecrement(&m_refCount);

			if(n == 0)
				delete this;

			return n;
		}

        virtual HRESULT STDMETHODCALLTYPE Next(ULONG cConnections, LPCONNECTIONPOINT * ppCP, ULONG * pcFetched)
		{
			dbgprintf(TEXT("CEnumConnectionPoints::Next(%lu, %p, %p)"), cConnections, ppCP, pcFetched);
			HRESULT hr = m_IEnumConnectionPoints->Next(cConnections, ppCP, pcFetched);
			dbgprintf(TEXT("CEnumConnectionPoints:: -> %08X, pCP = %p, cFetched = %lu"), hr, *ppCP, *pcFetched);

			if(SUCCEEDED(hr))
				*ppCP = HookIConnectionPoint(*ppCP);

			return hr;
		}
        
        virtual HRESULT STDMETHODCALLTYPE Skip(ULONG cConnections)
		{
			dbgprintf(TEXT("CEnumConnectionPoints::Skip(%lu)"), cConnections);
			HRESULT hr = m_IEnumConnectionPoints->Skip(cConnections);
			dbgprintf(TEXT("CEnumConnectionPoints:: -> %08X"), hr);
			return hr;
		}
        
        virtual HRESULT STDMETHODCALLTYPE Reset(void)
		{
			dbgprintf(TEXT("CEnumConnectionPoints::Reset()"));
			HRESULT hr = m_IEnumConnectionPoints->Reset();
			dbgprintf(TEXT("CEnumConnectionPoints:: -> %08X"), hr);
			return hr;
		}
        
        virtual HRESULT STDMETHODCALLTYPE Clone(IEnumConnectionPoints ** ppEnum)
		{
			dbgprintf(TEXT("CEnumConnectionPoints::Clone(%p)"), ppEnum);
			HRESULT hr = m_IEnumConnectionPoints->Clone(ppEnum);
			dbgprintf(TEXT("CEnumConnectionPoints:: -> %08X, pEnum"), hr, *ppEnum);

			if(SUCCEEDED(hr))
				*ppEnum = HookIEnumConnectionPoints(*ppEnum);

			return hr;
		}
	};

	class CConnectionPoint: public IConnectionPoint
	{
	private:
		LONG m_refCount;
		IConnectionPoint * m_IConnectionPoint;

	public:
		CConnectionPoint(IConnectionPoint * pIConnectionPoint):
			m_refCount(1),
			m_IConnectionPoint(pIConnectionPoint)
		{ }

		~CConnectionPoint() { m_IConnectionPoint->Release(); }

		virtual HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void ** ppvObject)
		{
			HRESULT hr = S_OK;

			dbgprintf(TEXT("CConnectionPoint::QueryInterface(%ls, %p)"), UUIDToString(riid).c_str(), ppvObject);

			if(riid == IID_IUnknown || riid == IID_IConnectionPoint)
				*ppvObject = this;
			else
			{
				*ppvObject = NULL;
				hr = E_NOINTERFACE;
			}
		
			dbgprintf(TEXT("CConnectionPoint::QueryInterface -> %08X, ppvObject = %p"), hr, *ppvObject);
			return hr;
		}

		virtual ULONG STDMETHODCALLTYPE AddRef(void)
		{
			return InterlockedIncrement(&m_refCount);
		}

		virtual ULONG STDMETHODCALLTYPE Release(void)
		{
			LONG n = InterlockedDecrement(&m_refCount);

			if(n == 0)
				delete this;

			return n;
		}

		virtual HRESULT STDMETHODCALLTYPE GetConnectionInterface(IID * pIID)
		{
			dbgprintf(TEXT("CConnectionPoint::GetConnectionInterface(%p)"), pIID);
			HRESULT hr = m_IConnectionPoint->GetConnectionInterface(pIID);
			dbgprintf(TEXT("CConnectionPoint::GetConnectionInterface -> %08X, IID = %ls"), hr, UUIDToString(*pIID).c_str());
			return hr;
		}

		virtual HRESULT STDMETHODCALLTYPE GetConnectionPointContainer(IConnectionPointContainer ** ppCPC)
		{
			dbgprintf(TEXT("CConnectionPoint::GetConnectionPointContainer(%p)"), ppCPC);
			HRESULT hr = m_IConnectionPoint->GetConnectionPointContainer(ppCPC);
			dbgprintf(TEXT("CConnectionPoint::GetConnectionPointContainer -> %08X, pCPC = %p"), hr, *ppCPC);

			if(SUCCEEDED(hr))
				*ppCPC = HookIConnectionPointContainer(*ppCPC);

			return hr;
		}

		virtual HRESULT STDMETHODCALLTYPE Advise(IUnknown * pUnkSink, DWORD * pdwCookie)
		{
			dbgprintf(TEXT("CConnectionPoint::Advise(%p, %p)"), pUnkSink, pdwCookie);
			HRESULT hr = m_IConnectionPoint->Advise(pUnkSink, pdwCookie);
			dbgprintf(TEXT("CConnectionPoint::Advise -> %08X, dwCookie = %lu"), hr, *pdwCookie);
			// TODO: hook sink
			return hr;
		}

		virtual HRESULT STDMETHODCALLTYPE Unadvise(DWORD dwCookie)
		{
			dbgprintf(TEXT("CConnectionPoint::Unadvise(%lu)"), dwCookie);
			HRESULT hr = m_IConnectionPoint->Unadvise(dwCookie);
			dbgprintf(TEXT("CConnectionPoint::Unadvise -> %08X"), hr);
			return hr;
		}

		virtual HRESULT STDMETHODCALLTYPE EnumConnections(IEnumConnections ** ppEnum)
		{
			dbgprintf(TEXT("CConnectionPoint::EnumConnections(%p)"), ppEnum);
			HRESULT hr = m_IConnectionPoint->EnumConnections(ppEnum);
			dbgprintf(TEXT("CConnectionPoint::EnumConnections -> %08X, pEnum = %p"), hr, *ppEnum);
			
			if(SUCCEEDED(hr))
				*ppEnum = HookIEnumConnections(*ppEnum);

			return hr;
		}
	};

	class CEnumConnections: public IEnumConnections
	{
	private:
		LONG m_refCount;
		IEnumConnections * m_IEnumConnections;

	public:
		CEnumConnections(IEnumConnections * pIEnumConnections):
			m_refCount(1),
			m_IEnumConnections(pIEnumConnections)
		{ }

		~CEnumConnections() { m_IEnumConnections->Release(); }

		virtual HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void ** ppvObject)
		{
			HRESULT hr = S_OK;

			dbgprintf(TEXT("CEnumConnections::QueryInterface(%ls, %p)"), UUIDToString(riid).c_str(), ppvObject);

			if(riid == IID_IUnknown || riid == IID_IEnumConnections)
				*ppvObject = this;
			else
			{
				*ppvObject = NULL;
				hr = E_NOINTERFACE;
			}
		
			dbgprintf(TEXT("CEnumConnections::QueryInterface -> %08X, ppvObject = %p"), hr, *ppvObject);
			return hr;
		}

		virtual ULONG STDMETHODCALLTYPE AddRef(void)
		{
			return InterlockedIncrement(&m_refCount);
		}

		virtual ULONG STDMETHODCALLTYPE Release(void)
		{
			LONG n = InterlockedDecrement(&m_refCount);

			if(n == 0)
				delete this;

			return n;
		}

		virtual HRESULT STDMETHODCALLTYPE Next(ULONG cConnections, LPCONNECTDATA pCD, ULONG * pcFetched)
		{
			dbgprintf(TEXT("CEnumConnections::Next(%lu, %p, %p)"), cConnections, pCD, pcFetched);
			HRESULT hr = m_IEnumConnections->Next(cConnections, pCD, pcFetched);
			dbgprintf(TEXT("CEnumConnections:: -> %08X, CD = { pUnk = %p, dwCookie = %lu }, cFetched = %lu"), hr, pCD->pUnk, pCD->dwCookie, *pcFetched);
			return hr;
		}
        
        virtual HRESULT STDMETHODCALLTYPE Skip(ULONG cConnections)
		{
			dbgprintf(TEXT("CEnumConnections::Skip(%lu)"), cConnections);
			HRESULT hr = m_IEnumConnections->Skip(cConnections);
			dbgprintf(TEXT("CEnumConnections:: -> %08X"), hr);
			return hr;
		}
        
        virtual HRESULT STDMETHODCALLTYPE Reset(void)
		{
			dbgprintf(TEXT("CEnumConnections::Reset()"));
			HRESULT hr = m_IEnumConnections->Reset();
			dbgprintf(TEXT("CEnumConnections:: -> %08X"), hr);
			return hr;
		}
        
        virtual HRESULT STDMETHODCALLTYPE Clone(IEnumConnections ** ppEnum)
		{
			dbgprintf(TEXT("CEnumConnections::Clone(%p)"), ppEnum);
			HRESULT hr = m_IEnumConnections->Clone(ppEnum);
			dbgprintf(TEXT("CEnumConnections:: -> %08X, pEnum"), hr, *ppEnum);

			if(SUCCEEDED(hr))
				*ppEnum = HookIEnumConnections(*ppEnum);

			return hr;
		}
	};

	IConnectionPointContainer * HookIConnectionPointContainer(IConnectionPointContainer * p)
	{
		return new CConnectionPointContainer(p);
	}

	IEnumConnectionPoints * HookIEnumConnectionPoints(IEnumConnectionPoints * p)
	{
		return new CEnumConnectionPoints(p);
	}

	IConnectionPoint * HookIConnectionPoint(IConnectionPoint * p)
	{
		return new CConnectionPoint(p);
	}

	IEnumConnections * HookIEnumConnections(IEnumConnections * p)
	{
		return new CEnumConnections(p);
	}

	class CAdvancedSettings: public IMsRdpClientAdvancedSettings4
	{
	private:
		LONG m_refCount;
		IUnknown * m_IUnknown;
		IDispatch * m_IDispatch;
		IMsTscAdvancedSettings * m_IMsTscAdvancedSettings;
		IMsRdpClientAdvancedSettings * m_IMsRdpClientAdvancedSettings;
		IMsRdpClientAdvancedSettings2 * m_IMsRdpClientAdvancedSettings2;
		IMsRdpClientAdvancedSettings3 * m_IMsRdpClientAdvancedSettings3;
		IMsRdpClientAdvancedSettings4 * m_IMsRdpClientAdvancedSettings4;

		IDispatch * getIDispatch()
		{

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -