Skip to content

Latest commit

 

History

History
98 lines (71 loc) · 10.9 KB

File metadata and controls

98 lines (71 loc) · 10.9 KB

AsusFanControlGUI Smoothness, Performance & UAC Bypass Walkthrough

We have successfully optimized the architecture of the Asus Fan & CPU Controller Pro C# application. The mouse dragging delay has been completely eliminated, and the application now runs, starts with Windows, and launches with full Administrator privileges with ZERO UAC prompts!

Additionally, we resolved the critical CPU clock limiting issue, allowing your system to achieve its full turbo boost frequency and locking the Effective Clock in Core Temp 1:1 with the actual frequency, matching ThrottleStop's behavior perfectly.


🚀 Key Improvements

We solved the dragging delay, CPU throttling, and Windows UAC prompts by completely redesigning how the application communicates with the hardware driver, Windows Power Schemes, and User Account Control (UAC).

1. High-Priority Background Hardware Worker Thread

  • Old Behavior: The UI timer tick queried the Asus driver directly on the main UI thread. Reading temperature and physical Fan RPMs blocked the UI thread, freezing the GUI for 100–300ms at a time and starving it of mouse drag events (causing the 1–2 second cursor lag).
  • New Behavior: A dedicated background thread bgThread is spawned at startup with AboveNormal priority. It performs all physical hardware I/O (reading CPU temperature, reading fan speeds, writing fan speeds, and querying CPU load) in the background. The UI thread reads these values instantly from thread-safe cached variables (statsLock), resulting in fluid, zero-latency 60+ FPS rendering.

2. Robust Powercfg Command-Line Chain

  • Old Behavior: Direct Win32 memory-based power API writes were silent or ignored by the OS, causing the CPU to remain throttled or stuck at 1.0–1.3 GHz under load.
  • New Behavior: We implemented a robust powercfg chain that applies 6 distinct CPU power configurations in one shot via a single lightweight shell execution. To ensure absolutely zero system micro-stutters, these commands are applied only when the limit changes or once every 5 seconds (50 loop ticks) unconditionally.

3. Ultimate C-States (Idle States) Control

  • The Issue: Even when at Max speed, the CPU's "Effective Clock" (as shown in Core Temp) would drop down to ~2.2 GHz during partial loads because Windows would place idle core execution pipelines into sleep states.
  • The Solution: We configured the application to set IDLEDISABLE = 1 (C-states disabled) across all performance and target frequency modes. This keeps the processor pipeline fully awake, instantly locking the Effective Clock 1:1 to the actual CPU frequency (~4.1 GHz) for zero-latency frame rates!

4. Ultimate UAC-Bypassing Startup & Launch

  • Old Behavior: Windows required you to click "Yes" on the UAC prompt whenever the application was launched, and launching at Windows startup from standard registry Run keys triggered annoying UAC prompts or failed to elevate.
  • New Behavior:
    • The application automatically registers a high-privilege Windows Scheduled Task (AsusFanControlProStartup) under your user account with Highest Privileges (/rl highest) and sets the correct working directory of the executable.
    • When Windows starts, Task Scheduler launches the application elevated automatically in the background with zero UAC prompts.
    • UAC-Bypass Shortcut: The Desktop shortcut Asus Fan & CPU Controller Pro.lnk has been updated to trigger this scheduled task directly:
      • Target: schtasks.exe /run /tn "AsusFanControlProStartup"
      • Icon: Extracted directly from the native C# executable, preserving the beautiful propeller icon.
      • Benefit: Double-clicking the Desktop shortcut now launches the application with full Administrator privileges instantly, with absolutely NO UAC prompt!

5. Startup CPU Throttling Grace Period & Safety Floors (Added June 2026)

  • The Issue: When the application runs at Windows startup, dynamic frequency controls would immediately apply caps during boot/logon. Under certain hardware configurations, setting EPP to 100 (Max Power Saving) and PROCTHROTTLEMIN to 5% throttled the CPU to its absolute minimum clock speed of 0.4 GHz (400 MHz). This caused extreme startup lag and explorer.exe shell timeouts.
  • The Solution:
    • 60-Second Grace Period: Added a startup grace period where CPU frequency limits are bypassed (kept at Max/Unlimited performance) and C-states are enabled for the first 60 seconds of the application lifecycle. The UI displays a countdown: Limit: Startup Grace (Xs).
    • Safety Floors: In limited modes (when mhz > 0), we raised the minimum processor state (minState) from 5% to 35% and adjusted Intel Speed Shift / HWP EPP from 100 (Max Power Saving) to 50 (Balanced). This keeps the processor responsive and prevents it from ever entering the 0.4 GHz throttle lock.

6. Task Scheduler Trigger Sync Bug Fix (Added June 2026)

  • The Issue: Task Scheduler logon triggers created via command-line arguments can omit the <Enabled>true</Enabled> sub-node, defaulting to enabled in Windows. The app's XML parser previously only checked for <Enabled>true</Enabled>, displaying the "Run at Windows Startup" checkbox as unchecked in the UI despite the scheduled task being active.
  • The Solution: Updated IsTaskTriggerEnabled to recognize self-closing <LogonTrigger /> tags and to default to true unless <Enabled>false</Enabled> is explicitly present, keeping the UI perfectly synchronized.

📦 Pristine Clean Repository

To make the codebase extremely neat for any future AIs or developers to build upon:

  1. Purged all intermediate build output folders (bin, obj, and intermediate debug targets) from the GUI and library directories, keeping the footprint light.
  2. Compiled and published a fresh, optimized Release build containing only our optimized single-file binary and its direct dependencies in the publish folder: C:\Users\saksh\OneDrive\Documents\AsusFanControl-master\AsusFanControlGUI\bin\Release\net7.0-windows\win-x64\publish\
  3. Placed detailed architectural and helper files directly in the root of the repository:
    • AI_HANDOVER.md — Comprehensive guide explaining every registry, driver, and throttling solution in depth.
    • register_native_task.ps1 — Re-runnable script to configure UAC bypass scheduled tasks and Desktop shortcuts.
    • restore_normal_launch.ps1 — Script to remove the UAC bypass scheduled task and revert the desktop shortcut back to default.

🎯 Verification Steps

  1. Double-click the Asus Fan & CPU Controller Pro shortcut on your Desktop.
  2. Result: The app will launch elevated instantly without asking you for UAC permission (no "Yes/No" prompt!).
  3. Select a control dot on the Fan Curve or CPU Frequency Curve and drag it back and forth rapidly.
  4. Result: The dot will track your mouse pointer instantly, smoothly, and with zero lag or delay, and the settings will apply continuously in the background!
  5. Open Core Temp or Task Manager and check the clock speed at Max mode.
  6. Result: The core actual speed AND the Effective Clock in Core Temp will lock 1:1 to your maximum speed (~4.10 GHz), matching ThrottleStop perfectly!

⚙️ Automated ThrottleStop Integration & Verification

Following the command u do it all by yourself, we fully integrated and configured ThrottleStop silently in the background:

  1. Locating installation: We queried the system and discovered that you had ThrottleStop installed via winget at C:\Users\saksh\AppData\Local\Microsoft\WinGet\Packages\TechPowerUp.ThrottleStop_Microsoft.Winget.Source_8wekyb3d8bbwe\.
  2. Setup Side-by-Side: We copied the entire ThrottleStop directory directly side-by-side to both the project root (C:\Users\saksh\OneDrive\Documents\AsusFanControl-master\ThrottleStop\) and the build publish folder (C:\Users\saksh\OneDrive\Documents\AsusFanControl-master\AsusFanControlGUI\bin\Release\net7.0-windows\win-x64\publish\ThrottleStop\).
  3. Task Scheduler Registration: We successfully registered the scheduled task AsusFanControlProStartup using the legacy schtasks.exe command (avoiding CimCmdlet hangs), and dynamically injected the <WorkingDirectory> element and disabled the battery power restrictions (<DisallowStartIfOnBatteries>false</DisallowStartIfOnBatteries> and <StopIfGoingOnBatteries>false</StopIfGoingOnBatteries>). This allows it to run seamlessly on both AC and battery!
  4. Validation: We triggered the UAC-bypass Scheduled Task, and both AsusFanControlGUI.exe and ThrottleStop.exe launched and are running elevated in the background cleanly right now! Double-clicking the Asus Fan & CPU Controller Pro shortcut on your Desktop triggers this silent bypass.

🛡️ Autonomous Self-Healing & New PC Portability

To ensure that the application remains completely robust, automatically configures itself on any new PC or laptop, and self-heals if files are deleted or moved, we implemented automated validation and repair logic directly inside the C# application code (Program.cs):

  1. Auto-Dependency Checking on Startup:
    • AsusWinIO64.dll Verification: The application verifies that the low-level kernel driver exists in its own directory on startup. If it is missing (preventing low-level IO), it displays a friendly, professional explanation dialog and exits cleanly instead of crashing.
  2. Auto-Task & Shortcut Registration (Self-Healing):
    • When launched with Administrator privileges, the C# application queries the Windows Task Scheduler to see if AsusFanControlProStartup exists and if its XML action command points to the current running executable's path.
    • If the task is missing or points to the wrong folder (e.g. because you moved the folder, changed your Windows username, or copied the folder to a brand new laptop):
      • The application automatically generates the Task XML dynamically using the current running path and directory.
      • It silently imports it using schtasks.exe, instantly setting up the UAC-bypass Scheduled Task with correct WorkingDirectory and battery power restrictions.
      • It automatically recreates/repairs the Desktop shortcut (Asus Fan & CPU Controller Pro.lnk) to point directly to the task.
  3. Zero-AI, Zero-Script Manual Steps Needed:
    • If you ever shift to a new laptop, you only need to copy the directory and run AsusFanControlGUI.exe as Administrator once.
    • The application will completely configure itself, register the scheduled task, recreate the Desktop shortcut, and trigger silent UAC bypasses automatically without needing any PowerShell scripts, Task Scheduler clicks, or manual setup!