openDecal/Native/DecalInput/WinMsgHook.cpp
erik d1442e3747 Initial commit: Complete open-source Decal rebuild
All 5 phases of the open-source Decal rebuild:

Phase 1: 14 decompiled .NET projects (Interop.*, Adapter, FileService, DecalUtil)
Phase 2: 10 native DLLs rewritten as C# COM servers with matching GUIDs
  - DecalDat, DHS, SpellFilter, DecalInput, DecalNet, DecalFilters
  - Decal.Core, DecalControls, DecalRender, D3DService
Phase 3: C++ shims for Inject.DLL (D3D9 hooking) and LauncherHook.DLL
Phase 4: DenAgent WinForms tray application
Phase 5: WiX installer and build script

25 C# projects building with 0 errors.
Native C++ projects require VS 2022 + Windows SDK (x86).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-08 18:27:56 +01:00

81 lines
1.7 KiB
C++

// WinMsgHook.cpp : Implementation of cWinMsgHook
#include "stdafx.h"
#include "DecalInput.h"
#include "WinMsgHook.h"
#include "InputService.h"
/////////////////////////////////////////////////////////////////////////////
// cWinMsgHook
STDMETHODIMP cWinMsgHook::get_Tag(VARIANT *pVal)
{
if( pVal == NULL )
{
_ASSERT( FALSE );
return E_POINTER;
}
return ::VariantCopy( pVal, &m_tag );
}
STDMETHODIMP cWinMsgHook::put_Tag(VARIANT newVal)
{
m_tag = newVal;
return S_OK;
}
STDMETHODIMP cWinMsgHook::get_Enabled(VARIANT_BOOL *pVal)
{
if( pVal == NULL )
{
_ASSERT( FALSE );
return E_POINTER;
}
*pVal = ( m_bEnabled ) ? VARIANT_TRUE : VARIANT_FALSE;
return S_OK;
}
STDMETHODIMP cWinMsgHook::put_Enabled(VARIANT_BOOL newVal)
{
if( !!newVal == m_bEnabled )
return S_FALSE;
if( cInputService::g_p == NULL )
{
// Input Service must be started to enable or disable a hotkey
_ASSERT( FALSE );
return E_FAIL;
}
m_bEnabled = !!newVal;
if( m_bEnabled )
{
#ifdef _DEBUG
for( cInputService::cWinMsgHookList::iterator i = cInputService::g_p->m_msghooks.begin(); i != cInputService::g_p->m_msghooks.end(); ++ i )
_ASSERTE( *i != this );
#endif
cInputService::g_p->m_msghooks.push_back( this );
}
else
{
for( cInputService::cWinMsgHookList::iterator i = cInputService::g_p->m_msghooks.begin(); i != cInputService::g_p->m_msghooks.end(); ++ i )
{
if( *i == this )
{
cInputService::g_p->m_msghooks.erase( i );
break;
}
}
_ASSERTE( i != cInputService::g_p->m_msghooks.end() );
}
return S_OK;
}