init
This commit is contained in:
@@ -0,0 +1,71 @@
|
||||
---
|
||||
source_files:
|
||||
- DataPRO/Modules/InstallerCustomActions/RegAddProductCode/AddProductCode.cs
|
||||
generated_at: "2026-04-17T16:46:50.881996+00:00"
|
||||
model: "zai-org/GLM-5-FP8"
|
||||
schema_version: 1
|
||||
sha256: "5cf0f99b67b34e4b"
|
||||
---
|
||||
|
||||
# Documentation: RegAddProductCode Module
|
||||
|
||||
## 1. Purpose
|
||||
|
||||
This module is a Windows Installer custom action that validates architecture compatibility between the installer and the operating system, then configures Windows Registry settings to add the DataPRO product code to the Secure Repair Whitelist. It exists to prevent mismatched architecture installations (e.g., 32-bit installer on 64-bit OS) and to ensure the Windows Installer service permits DataPRO installation by configuring the `SecureRepairPolicy` and whitelist entries under `HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\Installer`.
|
||||
|
||||
---
|
||||
|
||||
## 2. Public Interface
|
||||
|
||||
### `static int Main(string[] args)`
|
||||
|
||||
**Signature:** `static int Main(string[] args)`
|
||||
|
||||
**Behavior:** Entry point for the custom action. Accepts a single command-line argument specifying the architecture version (`"x86"` or `"x64"`). Validates that the installer architecture matches the operating system architecture—returns `1` (failure) if mismatched, otherwise proceeds to call `AddCodeToRegistry()` and returns `0` on success. Logs diagnostic information to the Windows Event Log under the source `"DataPROInstaller"`.
|
||||
|
||||
**Return Values:**
|
||||
- `0` — Success (architecture validated, registry updated)
|
||||
- `1` — Failure (architecture mismatch detected)
|
||||
|
||||
---
|
||||
|
||||
### `private static string AddCodeToRegistry()`
|
||||
|
||||
**Signature:** `private static string AddCodeToRegistry()`
|
||||
|
||||
**Behavior:** Configures registry settings required for DataPRO installation. Opens `HKEY_LOCAL_MACHINE` with a 64-bit registry view, sets `SecureRepairPolicy` to `2` (DWORD) under the Installer policies key, and adds the product code GUID to the `SecureRepairWhitelist`. Creates the whitelist key if it does not exist. Returns an empty string on success, or an error message string on exception.
|
||||
|
||||
**Note:** This method is private and not part of the public interface.
|
||||
|
||||
---
|
||||
|
||||
## 3. Invariants
|
||||
|
||||
1. **Architecture Argument Requirement:** The first command-line argument (`args[0]`) must be either `"x86"` or `"x64"`. Any other value bypasses architecture validation entirely (no error is thrown for unrecognized values).
|
||||
|
||||
2. **Architecture Matching:**
|
||||
- If `architectureVersion == "x86"` and `Environment.Is64BitOperatingSystem == true`, the process must terminate with return code `1`.
|
||||
- If `architectureVersion == "x64"` and `Environment.Is64BitOperatingSystem == false`, the process must terminate with return code `1`.
|
||||
|
||||
3. **Registry View:** The registry is always accessed using `RegistryView.Registry64`, regardless of process bitness.
|
||||
|
||||
4. **Event Log Source:** All log entries are written to the event log source `"DataPROInstaller"`, which must exist or be creatable.
|
||||
|
||||
5. **Registry Key Existence:** The key at `Settings.Default.InstallerKey` must exist; if it does not, the method returns early with an error message and does not attempt to create it. The `SecureRepairWhitelistKey` will be created if missing.
|
||||
|
||||
---
|
||||
|
||||
## 4. Dependencies
|
||||
|
||||
### External Dependencies (Imports)
|
||||
- `System` — Core framework types
|
||||
- `System.Diagnostics` — `EventLog` for Windows Event Log integration
|
||||
- `Microsoft.Win32` — `RegistryKey`, `RegistryHive`, `RegistryView`, `RegistryValueKind` for registry manipulation
|
||||
- `System.Windows.Forms` — `MessageBox` for user-facing error dialogs
|
||||
- `RegAddProductCode.Properties` — `Settings` class providing configuration values
|
||||
|
||||
### Configuration Dependencies (from `Settings.Default`)
|
||||
- `Settings.Default.InstallerKey` — Registry path to the Installer policies key
|
||||
- `Settings.Default.SecureRepairWhitelistKey` — Registry path to the SecureRepairWhitelist key
|
||||
- `Settings.Default.SecureRepairPolicy` — Name of the secure repair policy value
|
||||
- `Settings
|
||||
Reference in New Issue
Block a user