SwiftD
SwiftD

Reputation: 6079

windows registry storage best practice

Background

I've recently been shunted into the world of windows programming and I'm still trying to find my way around the best practices and ways of doing things. So I was just hoping for some pointers on use of the registry

Not particularly relevant but the background is that I am creating an installer in Golang, a couple of points to get out the way on that:

Current registry use

As part of the install process, I store several pieces of data in the registry:

run once commands:

Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce

I create a few entries here: to restart the process after a system reboot and to delete some temp files on reboot after uninstall

an uninstall entry:

Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Vendor Product

Content here is the same as an MSI would create, I was careful not to create any additional custom fields here (all static data until uninstall)

an application entry:

Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Vendor\Product

I store some additional data about the installation here, some of which is needed for uninstall such as state info from before installation (again all static content)

a temporary entry:

Computer\HKEY_CURRENT_USER\SOFTWARE\Vendor\Product

I store some temporary data here which can include some sensitive user entered data (usernames/passwords). I run some symmetric encryption to obscure the data though my understanding is this is area of the registry is encrypted so only the user could access anyway (would like confirmation on that) This data is used to resume after restart and then deleted

Questions

  1. I'm looking for confirmation / corrections on my current use of the registry?
  2. I now have need to pass some data between an application and a running service, this data would be updated every 1-2 minutes and would be a few bytes of JSON. Does the registry seem like a reasonable place to store variable data like this? If so is there a particular place that better for variable data - I was going to add it to: Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Vendor\Product

Upvotes: 0

Views: 691

Answers (1)

Christopher Painter
Christopher Painter

Reputation: 55601

HCKU isn't encrypted to my knowledge. It's stored in a file called NTUser.dat and could be loaded as a hive under HKEY_USERS and visible to other processes with sufficient rights to do so.

You would need to open up the rights to HKLM\SOFTWARE\Vendor\Product if you expect a user priv process to be able to write to it. If you want to pass data to a service you might want to use some sort of IPC pipe to do so. Not sure what's available in Golang for this.

Upvotes: 2

Related Questions