• R/O
  • HTTP
  • SSH
  • HTTPS

yamy: Commit

source code repository of yamy


Commit MetaInfo

Revision5fbbed253192e59fc5471b04474cb1e08b65eaa1 (tree)
Time2009-09-15 23:27:30
AuthorU-i7\gimy <gimy@user...>
CommiterU-i7\gimy

Log Message

enable command notify on x64

Change Summary

Incremental Difference

--- a/engine.cpp
+++ b/engine.cpp
@@ -1596,83 +1596,6 @@ void Engine::getHelpMessages(tstring *o_helpMessage, tstring *o_helpTitle) {
15961596 }
15971597
15981598
1599-// command notify
1600-void Engine::commandNotify(
1601- HWND i_hwnd, UINT i_message, WPARAM i_wParam, LPARAM i_lParam) {
1602- Acquire b(&m_log, 0);
1603- HWND hf = m_hwndFocus;
1604- if (!hf)
1605- return;
1606-
1607- if (GetWindowThreadProcessId(hf, NULL) ==
1608- GetWindowThreadProcessId(m_hwndAssocWindow, NULL))
1609- return; // inhibit the investigation of MADO TSUKAI NO YUUTSU
1610-
1611- const _TCHAR *target = NULL;
1612- int number_target = 0;
1613-
1614- if (i_hwnd == hf)
1615- target = _T("ToItself");
1616- else if (i_hwnd == GetParent(hf))
1617- target = _T("ToParentWindow");
1618- else {
1619- // Function::toMainWindow
1620- HWND h = hf;
1621- while (true) {
1622- HWND p = GetParent(h);
1623- if (!p)
1624- break;
1625- h = p;
1626- }
1627- if (i_hwnd == h)
1628- target = _T("ToMainWindow");
1629- else {
1630- // Function::toOverlappedWindow
1631- HWND h = hf;
1632- while (h) {
1633-#ifdef MAYU64
1634- LONG_PTR style = GetWindowLongPtr(h, GWL_STYLE);
1635-#else
1636- LONG style = GetWindowLong(h, GWL_STYLE);
1637-#endif
1638- if ((style & WS_CHILD) == 0)
1639- break;
1640- h = GetParent(h);
1641- }
1642- if (i_hwnd == h)
1643- target = _T("ToOverlappedWindow");
1644- else {
1645- // number
1646- HWND h = hf;
1647- for (number_target = 0; h; number_target ++, h = GetParent(h))
1648- if (i_hwnd == h)
1649- break;
1650- return;
1651- }
1652- }
1653- }
1654-
1655- m_log << _T("&PostMessage(");
1656- if (target)
1657- m_log << target;
1658- else
1659- m_log << number_target;
1660- m_log << _T(", ") << i_message
1661- << _T(", 0x") << std::hex << i_wParam
1662- << _T(", 0x") << i_lParam << _T(") # hwnd = ")
1663- << reinterpret_cast<int>(i_hwnd) << _T(", ")
1664- << _T("message = ") << std::dec;
1665- if (i_message == WM_COMMAND)
1666- m_log << _T("WM_COMMAND, ");
1667- else if (i_message == WM_SYSCOMMAND)
1668- m_log << _T("WM_SYSCOMMAND, ");
1669- else
1670- m_log << i_message << _T(", ");
1671- m_log << _T("wNotifyCode = ") << HIWORD(i_wParam) << _T(", ")
1672- << _T("wID = ") << LOWORD(i_wParam) << _T(", ")
1673- << _T("hwndCtrl = 0x") << std::hex << i_lParam << std::dec << std::endl;
1674-}
1675-
16761599 unsigned int WINAPI Engine::InputHandler::run(void *i_this)
16771600 {
16781601 reinterpret_cast<InputHandler*>(i_this)->run();
--- a/engine.h
+++ b/engine.h
@@ -604,8 +604,83 @@ public:
604604 void getHelpMessages(tstring *o_helpMessage, tstring *o_helpTitle);
605605
606606 /// command notify
607- void commandNotify(HWND i_hwnd, UINT i_message, WPARAM i_wParam,
608- LPARAM i_lParam);
607+ template <typename WPARAM_T, typename LPARAM_T>
608+ void commandNotify(HWND i_hwnd, UINT i_message, WPARAM_T i_wParam,
609+ LPARAM_T i_lParam)
610+ {
611+ Acquire b(&m_log, 0);
612+ HWND hf = m_hwndFocus;
613+ if (!hf)
614+ return;
615+
616+ if (GetWindowThreadProcessId(hf, NULL) ==
617+ GetWindowThreadProcessId(m_hwndAssocWindow, NULL))
618+ return; // inhibit the investigation of MADO TSUKAI NO YUUTSU
619+
620+ const _TCHAR *target = NULL;
621+ int number_target = 0;
622+
623+ if (i_hwnd == hf)
624+ target = _T("ToItself");
625+ else if (i_hwnd == GetParent(hf))
626+ target = _T("ToParentWindow");
627+ else {
628+ // Function::toMainWindow
629+ HWND h = hf;
630+ while (true) {
631+ HWND p = GetParent(h);
632+ if (!p)
633+ break;
634+ h = p;
635+ }
636+ if (i_hwnd == h)
637+ target = _T("ToMainWindow");
638+ else {
639+ // Function::toOverlappedWindow
640+ HWND h = hf;
641+ while (h) {
642+#ifdef MAYU64
643+ LONG_PTR style = GetWindowLongPtr(h, GWL_STYLE);
644+#else
645+ LONG style = GetWindowLong(h, GWL_STYLE);
646+#endif
647+ if ((style & WS_CHILD) == 0)
648+ break;
649+ h = GetParent(h);
650+ }
651+ if (i_hwnd == h)
652+ target = _T("ToOverlappedWindow");
653+ else {
654+ // number
655+ HWND h = hf;
656+ for (number_target = 0; h; number_target ++, h = GetParent(h))
657+ if (i_hwnd == h)
658+ break;
659+ return;
660+ }
661+ }
662+ }
663+
664+ m_log << _T("&PostMessage(");
665+ if (target)
666+ m_log << target;
667+ else
668+ m_log << number_target;
669+ m_log << _T(", ") << i_message
670+ << _T(", 0x") << std::hex << i_wParam
671+ << _T(", 0x") << i_lParam << _T(") # hwnd = ")
672+ << reinterpret_cast<int>(i_hwnd) << _T(", ")
673+ << _T("message = ") << std::dec;
674+ if (i_message == WM_COMMAND)
675+ m_log << _T("WM_COMMAND, ");
676+ else if (i_message == WM_SYSCOMMAND)
677+ m_log << _T("WM_SYSCOMMAND, ");
678+ else
679+ m_log << i_message << _T(", ");
680+ m_log << _T("wNotifyCode = ") << HIWORD(i_wParam) << _T(", ")
681+ << _T("wID = ") << LOWORD(i_wParam) << _T(", ")
682+ << _T("hwndCtrl = 0x") << std::hex << i_lParam << std::dec << std::endl;
683+ }
609684
610685 /// get current window class name
611686 const tstringi &getCurrentWindowClassName() const {
--- a/hook.cpp
+++ b/hook.cpp
@@ -427,17 +427,20 @@ static void notifyThreadDetach()
427427 static void notifyCommand(
428428 HWND i_hwnd, UINT i_message, WPARAM i_wParam, LPARAM i_lParam)
429429 {
430-#ifndef _WIN64
431430 if (g_hookData->m_doesNotifyCommand) {
432- NotifyCommand ntc;
433- ntc.m_type = Notify::Type_command;
431+#ifdef _WIN64
432+ NotifyCommand64 ntc;
433+ ntc.m_type = Notify::Type_command64;
434+#else // !_WIN64
435+ NotifyCommand32 ntc;
436+ ntc.m_type = Notify::Type_command32;
437+#endif // !_WIN64
434438 ntc.m_hwnd = i_hwnd;
435439 ntc.m_message = i_message;
436440 ntc.m_wParam = i_wParam;
437441 ntc.m_lParam = i_lParam;
438442 notify(&ntc, sizeof(ntc));
439443 }
440-#endif
441444 }
442445
443446
--- a/hook.h
+++ b/hook.h
@@ -36,7 +36,8 @@ struct Notify {
3636 Type_lockState, /// NotifyLockState
3737 Type_sync, /// Notify
3838 Type_threadDetach, /// NotifyThreadDetach
39- Type_command, /// NotifyThreadDetach
39+ Type_command64, /// NotifyCommand64
40+ Type_command32, /// NotifyCommand32
4041 Type_show, /// NotifyShow
4142 Type_log, /// NotifyLog
4243 };
@@ -72,11 +73,20 @@ struct NotifyThreadDetach : public Notify {
7273
7374
7475 ///
75-struct NotifyCommand : public Notify {
76+struct NotifyCommand32 : public Notify {
7677 HWND m_hwnd; ///
7778 UINT m_message; ///
78- WPARAM m_wParam; ///
79- LPARAM m_lParam; ///
79+ unsigned int m_wParam; ///
80+ long m_lParam; ///
81+};
82+
83+
84+///
85+struct NotifyCommand64 : public Notify {
86+ HWND m_hwnd; ///
87+ UINT m_message; ///
88+ unsigned __int64 m_wParam; ///
89+ __int64 m_lParam; ///
8090 };
8191
8292
--- a/mayu.cpp
+++ b/mayu.cpp
@@ -230,8 +230,15 @@ private:
230230 break;
231231 }
232232
233- case Notify::Type_command: {
234- NotifyCommand *n = (NotifyCommand *)cd->lpData;
233+ case Notify::Type_command64: {
234+ NotifyCommand64 *n = (NotifyCommand64 *)cd->lpData;
235+ m_engine.commandNotify(n->m_hwnd, n->m_message,
236+ n->m_wParam, n->m_lParam);
237+ break;
238+ }
239+
240+ case Notify::Type_command32: {
241+ NotifyCommand32 *n = (NotifyCommand32 *)cd->lpData;
235242 m_engine.commandNotify(n->m_hwnd, n->m_message,
236243 n->m_wParam, n->m_lParam);
237244 break;
Show on old repository browser