-
Notifications
You must be signed in to change notification settings - Fork 23
[DRAFT][WIP] feat(session): RDM messages bootstrap #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,10 +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; | ||||||||||||||||||||||||||||||
| let month = (product_version >> 16) & 0xFF; | ||||||||||||||||||||||||||||||
| let day = product_version & 0xFFFF; | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| let short_year = match version_encoding { | ||||||||||||||||||||||||||||||
| ProductVersionEncoding::Agent => (product_version >> 24) + 2000, | ||||||||||||||||||||||||||||||
| ProductVersionEncoding::Rdm => (product_version >> 24) + 0x700, | ||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||
|
Comment on lines
90
to
+96
|
||||||||||||||||||||||||||||||
| let month = (product_version >> 16) & 0xFF; | |
| let day = product_version & 0xFFFF; | |
| let short_year = match version_encoding { | |
| ProductVersionEncoding::Agent => (product_version >> 24) + 2000, | |
| ProductVersionEncoding::Rdm => (product_version >> 24) + 0x700, | |
| }; | |
| let short_year = match version_encoding { | |
| ProductVersionEncoding::Agent => (product_version >> 24) + 2000, | |
| ProductVersionEncoding::Rdm => (product_version >> 24) + 0x700, | |
| }; | |
| let month = (product_version >> 16) & 0xFF; | |
| let day = product_version & 0xFFFF; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Magic number: The constant
0x700(1792 in decimal) for RDM version encoding is unexplained. This magic number makes the code difficult to understand and maintain. Consider adding a comment explaining what this value represents and why it's used for RDM version calculation, or define it as a named constant with documentation.