- struct handle_data {
- unsigned long process_id;
- HWND window_handle;
- };
- BOOL is_main_window(HWND handle)
- {
- return ((GetWindow(handle, GW_OWNER) == (HWND)0) && (IsWindowVisible(handle)));
- }
- BOOL CALLBACK enum_windows_callback(HWND handle, LPARAM lParam)
- {
- handle_data& data = *(handle_data*)lParam;
- unsigned long process_id = 0;
- GetWindowThreadProcessId(handle, &process_id);
- if (data.process_id != process_id) return TRUE;
- if (!is_main_window(handle)) return TRUE;
- auto s = GetWindowLong(handle, GWL_STYLE);
- if (!(s & WS_VISIBLE)) return TRUE;
- data.window_handle = handle;
- return FALSE;
- }
- HWND find_main_window(unsigned long process_id)
- {
- handle_data data;
- data.process_id = process_id;
- data.window_handle = 0;
- EnumWindows(enum_windows_callback, (LPARAM)&data);
- if (data.window_handle != 0)
- {
- if (IsWindowVisible(data.window_handle))
- {
- return data.window_handle;
- }
- }
- return 0;
- }
- bool CPythonNetworkStream::SendCharacterStatePacket(const TPixelPosition& c_rkPPosDst, float fDstRot, UINT eFunc, UINT uArg)
- {
- NANOBEGIN
- if (!__CanActMainInstance())
- return true;
- if (GetActiveWindow() != find_main_window(GetCurrentProcessId()))
- return true;
Alles anzeigen
Thanks for the release, but this is a totally bad solution and useless code.
Already there's a function that checking if the application is active or not in Bitte melden Sie sich an, um diesen Link zu sehen.
The variable m_isActive is set when WM_ACTIVATEAPP it's called, basically when a window belonging to a different application than the active window is about to be activated.
If you read a little bit the documentation of Win32 Api, you can find those.
WA_ACTIVE
- Activated by some method other than a mouse click (for example, by a call to the SetActiveWindow function or by use of the keyboard interface to select the window)
WA_CLICKACTIVE
- Activated by a mouse click.
So, all what you've to use, it's just 2 lines:
- bool CPythonNetworkStream::SendAttackPacket(UINT uMotAttack, DWORD dwVIDVictim)
- {
- [...]
- if (!CPythonApplication::Instance().IsActive())
- return true;
- [...]
- }
This method doesn't make sense for the metin2 gameplay anyway.
Next time, do better research on metin2 source, nobody cares about those "HIGH" inventions of you that are totally ...great.
Also, this is something that made my day:
Eine richtige Lösung ist ein gutes Anticheat.
*hust hust* z.b. Hawkeye *hust hust*
Bitte melden Sie sich an, um dieses Bild zu sehen.