-
Notifications
You must be signed in to change notification settings - Fork 24
feat(agent): RDM messages and pipe passthrough logic #1538
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -48,9 +48,17 @@ pub fn get_product_code(update_code: Uuid) -> Result<Option<Uuid>, RegistryError | |
| Ok(Some(reversed_hex_to_uuid(&product_code)?)) | ||
| } | ||
|
|
||
| pub enum ProductVersionEncoding { | ||
| Agent, | ||
| Rdm, | ||
| } | ||
|
|
||
| /// Get the installed version of a product using Windows registry. Returns `None` if the product | ||
| /// is not installed. | ||
| pub fn get_installed_product_version(update_code: Uuid) -> Result<Option<DateVersion>, RegistryError> { | ||
| pub fn get_installed_product_version( | ||
| update_code: Uuid, | ||
| version_encoding: ProductVersionEncoding, | ||
| ) -> Result<Option<DateVersion>, RegistryError> { | ||
| let product_code_uuid = match get_product_code(update_code)? { | ||
| Some(uuid) => uuid, | ||
| None => return Ok(None), | ||
|
|
@@ -79,7 +87,14 @@ pub fn get_installed_product_version(update_code: Uuid) -> Result<Option<DateVer | |
| })?; | ||
|
|
||
| // Convert encoded MSI version number to human-readable date. | ||
| let short_year = (product_version >> 24) + 2000; | ||
| // The high byte encodes the year as an offset: | ||
| // - Agent builds use a base year of 2000 (year = high_byte + 2000). | ||
| // - RDM MSI packages use 0x700 (1792) as base, found empirically. | ||
| // This offset must be preserved to correctly decode existing RDM installations. | ||
| let short_year = match version_encoding { | ||
| ProductVersionEncoding::Agent => (product_version >> 24) + 2000, | ||
| ProductVersionEncoding::Rdm => (product_version >> 24) + 0x700, | ||
|
Comment on lines
+94
to
+96
|
||
| }; | ||
| let month = (product_version >> 16) & 0xFF; | ||
| let day = product_version & 0xFFFF; | ||
|
|
||
|
|
@@ -91,3 +106,36 @@ pub fn get_installed_product_version(update_code: Uuid) -> Result<Option<DateVer | |
| revision: 0, | ||
| })) | ||
| } | ||
|
|
||
| /// Get the installation location of a product using Windows registry. Returns `None` if the product | ||
| /// is not installed or if the InstallLocation value is not present. | ||
| pub fn get_install_location(update_code: Uuid) -> Result<Option<String>, RegistryError> { | ||
| let product_code_uuid = match get_product_code(update_code)? { | ||
| Some(uuid) => uuid, | ||
| None => return Ok(None), | ||
| } | ||
| .braced(); | ||
|
|
||
| let key_path = format!("{REG_CURRENT_VERSION}\\Uninstall\\{product_code_uuid}"); | ||
|
|
||
| const INSTALL_LOCATION_VALUE_NAME: &str = "InstallLocation"; | ||
|
|
||
| // Now we know the product code of installed MSI, we could read its install location. | ||
| let product_tree = windows_registry::LOCAL_MACHINE | ||
| .open(&key_path) | ||
| .map_err(|source| RegistryError::OpenKey { | ||
| key: key_path.clone(), | ||
| source, | ||
| })?; | ||
|
|
||
| let install_location: String = product_tree | ||
| .get_value(INSTALL_LOCATION_VALUE_NAME) | ||
| .and_then(TryInto::try_into) | ||
| .map_err(|source| RegistryError::ReadValue { | ||
| value: INSTALL_LOCATION_VALUE_NAME.to_owned(), | ||
| key: key_path.clone(), | ||
| source, | ||
| })?; | ||
|
|
||
| Ok(Some(install_location)) | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -38,6 +38,7 @@ pub mod fs; | |
| pub mod io; | ||
| pub mod now_message_dissector; | ||
| pub mod process; | ||
| pub mod rdm; | ||
| pub mod task; | ||
|
|
||
| mod env; | ||
Uh oh!
There was an error while loading. Please reload this page.