Architecture & Internals

chrlauncher is engineered for extreme performance, security, and independence. It is written entirely in native C/C++, ensuring a minimal memory footprint and zero reliance on external frameworks like the .NET Runtime, Python, or even external archiving utilities like 7-Zip or WinRAR.

This document provides an overview of the internal components for developers and advanced users.

Codebase Overview

The project is structured to compile into a single, standalone executable.

  • src/main.c: The core application entry point and logic handler. It manages:
    • Parsing of chrlauncher.ini via custom string routines.
    • Ingesting and parsing standard and custom command-line arguments.
    • Creating the Win32 dialog window and system tray interactions.
    • Managing the state machine for the update lifecycle (Checking -> Downloading -> Unpacking -> Launching).
  • WinHTTP API Integration: Network communication is a critical security vector. Instead of relying on bundled libraries like libcurl, chrlauncher natively uses Windows HTTP Services (WinHTTP).
    • Why WinHTTP? It guarantees that chrlauncher automatically respects system-level proxy configurations, corporate firewalls, and utilizes the OS's native, up-to-date TLS/SSL certificate store, removing the need to ship vulnerable certificate bundles.
  • Win32 GUI Model: The interface is an ultra-lightweight standard Win32 Dialog Box (IDD_MAIN) defined in src/resource.rc. It operates entirely via standard Windows messaging, allowing it to sit in the system tray (Shell_NotifyIcon) consuming virtually zero CPU cycles.

Embedded Unpackers

Chromium binaries are massive (often >150MB compressed). To remain completely self-contained while handling complex archives, chrlauncher statically links advanced extraction libraries directly into the executable:

  1. LZMA SDK (src/lzma/): A customized, heavily stripped-down version of the official 7-Zip LZMA SDK. This allows chrlauncher to natively decompress .7z packages (specifically LZMA/LZMA2 algorithms), which are the standard, highly-compressed distribution format for modern Chromium snapshots.
  2. Miniz (src/miniz.c): A brilliant, single-file, public-domain zlib-replacement library. It is used to rapidly parse and extract standard .zip archives. Miniz provides a drop-in replacement for standard deflation with a fraction of the compiled footprint.

Update Threading Model

Downloading and unpacking 300MB+ of binary data requires intensive disk I/O and network polling. If performed on the main execution thread, the Windows GUI would freeze, resulting in a "Not Responding" state.

To prevent this, chrlauncher implements a lightweight asynchronous threading model:

  1. Work Queue (R_WORKQUEUE): The core logic is dispatched to a background work queue managed by internal utility routines.
  2. The Worker Thread (_app_thread_check): This function executes entirely on the background worker thread. It handles the heavy lifting: acquiring the download lock (lock_download), executing the WinHTTP download streams, and parsing the archive streams through LZMA/Miniz.
  3. Cross-Thread Communication: As the worker thread processes bytes, it cannot update the UI directly (a Win32 violation). Instead, it periodically posts custom progress messages (PostMessage) back to the main UI thread's message queue. The UI thread catches these messages and securely updates the visual progress bar (IDC_PROGRESS) and system tray tooltips, ensuring a smooth, responsive user experience.

Security Considerations

  • Atomic Directory Replacement: During an update, chrlauncher performs directory rotation safely. It does not overwrite files in place, which could corrupt the browser if the system loses power. Instead, it unpacks to a temporary staging environment, and only upon complete success does it swap the old directory for the new one.
  • No Code Injection: chrlauncher acts purely as a wrapper and file-system manager. It does not inject hooks or modify the running memory of the browser process, ensuring compatibility with modern anti-cheat and anti-malware protections.