|
From: Jeffrey D. <ha...@us...> - 2003-09-05 04:59:57
|
Log Message:
-----------
Mopy's tool text stuffs
Modified Files:
--------------
/cvsroot/decaldev/source/Decal:
ACHooks.cpp
ACHooks.h
DecalCP.h
Revision Data
-------------
Index: ACHooks.cpp
===================================================================
RCS file: /cvsroot/decaldev/source/Decal/ACHooks.cpp,v
retrieving revision 1.61
retrieving revision 1.62
diff -u -d -r1.61 -r1.62
--- ACHooks.cpp 27 Aug 2003 19:07:16 -0000 1.61
+++ ACHooks.cpp 5 Sep 2003 04:59:45 -0000 1.62
@@ -27,6 +27,8 @@
long g_lObjectDestroyedProc = 0;
long g_lSelectItemHijackProc = 0;
long g_lIdentifyHijackProc = 0;
+long g_lToolTextProc = 0;
+long g_lToolText2Proc = 0;
void (__fastcall *pfnOldChatMessage)(int _ecx, int _edx, char *, DWORD ) = NULL;
void (*pfnOldChatText)() = NULL;
@@ -46,6 +48,8 @@
char g_charBufferPreviousCall;
extern void __fastcall OnChatMessage( int _ecx, int _edx, char* pText, long dwColor );
+extern void CatchToolText();
+extern void CatchToolTextAppend();
extern void OnChatText();
extern void IdentifyShortcircuit();
@@ -98,6 +102,8 @@
m_bSelectItemHook = false;
m_bUstAddItem_Useable = false;
m_bRequestShortcircuit = false;
+ m_bToolTextHook = false;
+ m_bToolText2Hook = false;
m_Hooks = 0;
memset(m_HooksEx, 0, sizeof(m_HooksEx));
@@ -692,6 +698,26 @@
}
}
+ if (QueryMemLoc(BSTRT( "ToolTextHJ" ), &Val) == S_OK)
+ {
+ m_lToolTextHJ = Val;
+
+ g_lToolTextProc = HookCall( m_lToolTextHJ, (DWORD)CatchToolText );
+
+ SetHookEx( eToolText );
+ m_bToolTextHook = true;
+ }
+
+ if (QueryMemLoc(BSTRT( "ToolText2HJ" ), &Val) == S_OK)
+ {
+ m_lToolText2HJ = Val;
+
+ g_lToolText2Proc = HookCall( m_lToolText2HJ, (DWORD)CatchToolTextAppend );
+
+ SetHookEx( eToolText2 );
+ m_bToolText2Hook = true;
+ }
+
DWORD dwOldProtect;
if( QueryMemLoc( BSTRT( "OnChatText" ), &Val ) == S_OK )
{
@@ -807,6 +833,16 @@
HookCall( m_lRequestShortcircuit3, g_lIdentifyHijackProc );
}
+ if( m_bToolTextHook )
+ {
+ HookCall( m_lToolTextHJ, g_lToolTextProc );
+ }
+
+ if( m_bToolText2Hook )
+ {
+ HookCall( m_lToolText2HJ, g_lToolText2Proc );
+ }
+
s_pACHooks = NULL;
g_lObjectDestroyedProc = 0;
@@ -1716,6 +1752,76 @@
return S_FALSE;
}
+STDMETHODIMP cACHooks::ToolText(BSTR Text, VARIANT_BOOL bError)
+{
+ /*
+ Moputu - 09012003: Added to allow plugins to display text
+ in the upper left hand corner as either white text w/o sound or
+ as yellow text with the busy/error sound.
+
+ Either CombatState or ObjectBase can be used as the starting
+ memloc as both always seems to have the same value and the
+ function is called using one or the other in the client.exe.
+ You can only find the function address after the player is logged in.
+ */
+
+ if( !m_bCombatState ) //the combat state memloc is necessary
+ return S_FALSE;
+
+ USES_CONVERSION;
+ char *szText = OLE2A( Text ); //pointer to the text being passed
+ DWORD cstate = *((long *)m_lCombatState);
+
+ long lErr;
+ if (bError)
+ lErr = 1; // display text as yellow w/sound
+ else
+ lErr = 0; // display text as white w/o sound
+
+ __asm
+ {
+ mov ecx, cstate
+
+ push lErr
+ push szText
+
+ mov edx, dword ptr [ecx]
+ call dword ptr [edx+114h]
+ add esp, 8
+ }
+
+ return S_OK;
+}
+
+STDMETHODIMP cACHooks::ToolTextAppend(BSTR Text, VARIANT_BOOL bError)
+{
+ if( !m_bCombatState ) //the combat state memloc is necessary
+ return S_FALSE;
+
+ USES_CONVERSION;
+ char *szText = OLE2A( Text ); //pointer to the text being passed
+ DWORD cstate = *((long *)m_lCombatState);
+
+ long lErr;
+ if (bError)
+ lErr = 1; // display text as yellow w/sound
+ else
+ lErr = 0; // display text as white w/o sound
+
+ __asm
+ {
+ mov ecx, cstate
+
+ push lErr
+ push szText
+
+ mov edx, dword ptr [ecx]
+ call dword ptr [edx+118h]
+ }
+
+ return S_OK;
+}
+
STDMETHODIMP cACHooks::SecureTrade_Add(long ItemID, VARIANT_BOOL *pVal)
{
void ( __fastcall *Internal_SecureTrade_Add )( struct qPointerList *, int, long );
@@ -2198,6 +2304,68 @@
mov esp, ebp
pop ebp
ret
+ }
+}
+
+void cACHooks::InternalToolText( char *szText, VARIANT_BOOL bError )
+{
+ USES_CONVERSION;
+ Fire_OnToolText( T2BSTR( szText ), bError );
+}
+
+void OnToolText( char *szText, long lError )
+{
+ VARIANT_BOOL bError = lError;
+
+ if( cACHooks::s_pACHooks )
+ cACHooks::s_pACHooks->InternalToolText( szText, bError );
+}
+
+void __declspec(naked) CatchToolText()
+{
+ __asm
+ {
+ push ecx
+ push edx
+ push edi
+ push eax
+ call OnToolText
+ pop eax
+ pop edi
+ pop edx
+ pop ecx
+ jmp g_lToolTextProc
+ }
+}
+
+void cACHooks::InternalToolTextAppend( char *szText, VARIANT_BOOL bError )
+{
+ USES_CONVERSION;
+ Fire_OnToolTextAppend( T2BSTR( szText ), bError );
+}
+
+void OnToolTextAppend( char *szText, long lError )
+{
+ VARIANT_BOOL bError = lError;
+
+ if( cACHooks::s_pACHooks )
+ cACHooks::s_pACHooks->InternalToolTextAppend( szText, bError );
+}
+
+void __declspec(naked) CatchToolTextAppend()
+{
+ __asm
+ {
+ push ecx
+ push edx
+ push edi
+ push eax
+ call OnToolTextAppend
+ pop eax
+ pop edi
+ pop edx
+ pop ecx
+ jmp g_lToolText2Proc
}
}
Index: ACHooks.h
===================================================================
RCS file: /cvsroot/decaldev/source/Decal/ACHooks.h,v
retrieving revision 1.44
retrieving revision 1.45
diff -u -d -r1.44 -r1.45
--- ACHooks.h 21 Aug 2003 22:22:46 -0000 1.44
+++ ACHooks.h 5 Sep 2003 04:59:45 -0000 1.45
@@ -240,10 +240,17 @@
long m_lRequestShortcircuit2;
long m_lRequestShortcircuit3;
+ //Moputu - 09012003
+ bool m_bToolTextHook;
+ long m_lToolTextHJ;
+ bool m_bToolText2Hook;
+ long m_lToolText2HJ;
+ //end add
+
unsigned int m_HooksEx[1];
unsigned int m_HookCount;
- CComPtr< IDecal > m_pDecal;
+ CComPtr< IDecal > m_pDecal;
public:
static cACHooks* s_pACHooks;
@@ -252,6 +259,9 @@
void InternalShortcircuit( DWORD dwID );
bool InternalChatText( char *szText );
bool InternalChatMessage( char *szText, long lColor );
+ void InternalToolText( char *szText, VARIANT_BOOL bError );
+ void InternalToolTextAppend( char *szText, VARIANT_BOOL bError );
+
void SetHookEx(enum eAvailableHooksEx HookID);
CComPtr< IKitchenSink > m_pIdQueue;
@@ -300,6 +310,9 @@
STDMETHOD(LocalChatEmote)(BSTR EmoteText);
STDMETHOD(get_HooksAvailEx)(enum eAvailableHooksEx HookID, VARIANT_BOOL* pVal);
STDMETHOD(Logout)();
+ STDMETHOD(ToolText)(BSTR Text, VARIANT_BOOL bError);
+ STDMETHOD(ToolTextAppend)(BSTR Text, VARIANT_BOOL bError);
+
STDMETHOD(SetDecal)(IUnknown *pDecal);
STDMETHOD(SecureTrade_Add)(long ItemID, VARIANT_BOOL *pVal);
Index: DecalCP.h
===================================================================
RCS file: /cvsroot/decaldev/source/Decal/DecalCP.h,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- DecalCP.h 22 Mar 2003 01:37:06 -0000 1.7
+++ DecalCP.h 5 Sep 2003 04:59:45 -0000 1.8
@@ -114,6 +114,7 @@
HRESULT Fire_OnSelectItem(LONG guid)
{
+
CComVariant varResult;
T* pT = static_cast<T*>(this);
int nConnectionIndex;
@@ -138,5 +139,64 @@
return varResult.scode;
}
+ void Fire_OnToolText(BSTR bstrText, VARIANT_BOOL bError)
+ {
+ T* pT = static_cast<T*>(this);
+ int nConnectionIndex;
+ CComVariant* pvars = new CComVariant[2];
+ int nConnections = m_vec.GetSize();
+
+ for (nConnectionIndex = 0; nConnectionIndex < nConnections; nConnectionIndex++)
+ {
+ pT->Lock();
+ CComPtr<IUnknown> sp = m_vec.GetAt(nConnectionIndex);
+ pT->Unlock();
+ IDispatch* pDispatch = reinterpret_cast<IDispatch*>(sp.p);
+ if (pDispatch != NULL)
+ {
+ // operator= doesn't accept VARIANT_BOOL *
+ VARIANT vt;
+ ::VariantInit(&vt);
+ vt.vt = VT_BYREF | VT_BOOL;
+ vt.pboolVal = &bError;
+
+ pvars[1] = bstrText;
+ pvars[0] = vt;
+ DISPPARAMS disp = { pvars, NULL, 2, 0 };
+ pDispatch->Invoke(5, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, &disp, NULL, NULL, NULL);
+ }
+ }
+ delete[] pvars;
+ }
+
+ void Fire_OnToolTextAppend(BSTR bstrText, VARIANT_BOOL bError)
+ {
+ T* pT = static_cast<T*>(this);
+ int nConnectionIndex;
+ CComVariant* pvars = new CComVariant[2];
+ int nConnections = m_vec.GetSize();
+
+ for (nConnectionIndex = 0; nConnectionIndex < nConnections; nConnectionIndex++)
+ {
+ pT->Lock();
+ CComPtr<IUnknown> sp = m_vec.GetAt(nConnectionIndex);
+ pT->Unlock();
+ IDispatch* pDispatch = reinterpret_cast<IDispatch*>(sp.p);
+ if (pDispatch != NULL)
+ {
+ // operator= doesn't accept VARIANT_BOOL *
+ VARIANT vt;
+ ::VariantInit(&vt);
+ vt.vt = VT_BYREF | VT_BOOL;
+ vt.pboolVal = &bError;
+
+ pvars[1] = bstrText;
+ pvars[0] = vt;
+ DISPPARAMS disp = { pvars, NULL, 2, 0 };
+ pDispatch->Invoke(6, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, &disp, NULL, NULL, NULL);
+ }
+ }
+ delete[] pvars;
+ }
};
#endif
|