TopMost Protection
TopMost protection is a critical defense mechanism that prevents players from opening external cheating tools, particularly injectors, during gameplay. By maintaining a fullscreen window that stays on top of all other applications, ACHCE Client creates a barrier that makes it significantly more difficult to launch unauthorized software.TopMost is a Windows Forms property that forces a window to remain visible above all other windows, even when it loses focus.
What is TopMost?
In Windows programming, theTopMost property is a boolean flag that, when set to true, ensures a window remains on top of all other windows in the z-order. This is commonly used for:
- Critical system notifications
- Always-visible toolbars
- Security overlays
- Splash screens and loading windows
Why TopMost Matters for Anti-Cheat
The Injector Problem
Injectors are tools that insert unauthorized code into a running game process. They typically:- Modify game memory to enable cheats
- Hook game functions to alter behavior
- Inject DLLs that provide unfair advantages
- Enable wallhacks, aimbots, and other exploits
How TopMost Prevents Injection
By maintaining a fullscreen overlay, ACHCE Client:- Blocks Visual Access: Users cannot see or interact with injector windows
- Prevents Focus Changes: External tools cannot steal focus from the protected window
- Creates User Friction: Makes the injection process significantly more complex
- Deters Casual Cheaters: Most users will not attempt advanced bypass techniques
Implementation Details
Form2: The TopMost Window
The TopMost protection is implemented inForm2.cs, which displays a fullscreen overlay window:
Window Activation Flow
The transition from the initial form to the TopMost window is handled by a timer inForm1.cs:
The TopMost window is only displayed after the player’s IP address has been successfully retrieved and registered in the database, ensuring the protection is active before game access.
Technical Breakdown
Screen Resolution Detection
ACHCE Client dynamically adapts to the player’s monitor configuration:Window Sizing and Positioning
Multi-Monitor Considerations
The current implementation usesScreen.PrimaryScreen.Bounds, which covers only the primary monitor. For multi-monitor setups:
Form Designer Configuration
While not shown in the code excerpts, the Form2 window must have itsTopMost property set in the designer or programmatically:
User Interface Elements
Exit Control
The TopMost window includes a clickable exit control (pictureBox2):This exit button allows users to close ACHCE Client when they want to stop playing. Its placement and design should make it visible but not accidentally clickable.
Security Analysis
Strengths
- Simple to Implement: Uses native Windows Forms functionality
- Low Performance Impact: No background scanning or memory monitoring required
- Immediate Effect: Active as soon as the form is displayed
- Platform Native: Leverages OS-level window management
Limitations
- Visual Only: Does not prevent background processes or command-line injectors
- Bypassable: Advanced users can disable TopMost via external tools
- Single Monitor: Current implementation only covers primary screen
- UI Dependent: Can be circumvented if form loses TopMost flag
Why It Still Works
Despite these limitations, TopMost protection is effective because:- Target Audience: Most cheaters use GUI-based tools that require visual interaction
- Layered Defense: Combined with other protections (temporary folders, hardware ID)
- Deterrent Effect: Raises the technical barrier for cheating attempts
- Ease of Detection: Attempts to bypass TopMost can be monitored
Best Practices
Enhancement Opportunities
Persistent TopMost Verification
Add a timer to continuously verify the TopMost state:Window State Monitoring
Detect attempts to minimize or hide the window:Focus Protection
Prevent other applications from stealing focus:Multi-Monitor Support
To protect multi-monitor setups:Performance Considerations
TopMost protection has minimal performance impact:- Memory: Single Form instance (~few KB)
- CPU: No continuous processing required
- GPU: Standard window rendering only
The main performance consideration is the window’s content. Keep the UI lightweight with optimized images and minimal animations to avoid impacting game performance.
Testing TopMost Protection
Manual Testing
- Launch ACHCE Client
- Verify fullscreen coverage appears
- Attempt to open Task Manager (Ctrl+Shift+Esc)
- Try Alt+Tab to switch applications
- Attempt to open injector tools
Automated Testing
Common Issues
Window not covering taskbar
Window not covering taskbar
Set
FormBorderStyle to None and WindowState to Maximized in addition to sizing manually.Other windows appearing on top
Other windows appearing on top
Verify that
TopMost is set to true in both the designer and code. Some applications (like Task Manager) can override TopMost.Performance issues with TopMost window
Performance issues with TopMost window
Optimize the form’s content. Use compressed images, disable unnecessary animations, and avoid complex UI elements that require continuous repainting.
Alt+Tab still shows other windows
Alt+Tab still shows other windows
Alt+Tab operates at the OS level and cannot be completely blocked. However, returning to the game will show the TopMost window again. Consider using keyboard hooks to intercept Alt+Tab (requires careful implementation to avoid system instability).
Relationship to Other Protection Layers
TopMost protection works in concert with other ACHCE Client features:- Temporary Folders: While TopMost prevents injector UI access, temporary folders prevent modified game files
- Hardware ID: If TopMost is bypassed and cheating occurs, hardware ID ensures bans persist
- Database Tracking: Active sessions are monitored regardless of TopMost bypass attempts
Summary
TopMost protection is a foundational security layer that:- Creates a visual and interactive barrier against injector tools
- Operates with minimal performance overhead
- Provides immediate protection upon activation
- Works best when combined with other anti-cheat mechanisms
Form2.cs demonstrates a straightforward approach to fullscreen window protection, with opportunities for enhancement through continuous monitoring and multi-monitor support.