2010年10月22日 星期五

Backup & restore case study: XCamera

This post is a case study of backup and restore one application called XCamera which is a camera application with it’s own driver included.

After analysis, I found the components I think it should be backup for restoring.

Files in \Program Files\XCamera The application install folder. There are lot of exe, dll and ini files in this folder.
Two driver files in \Windows folder File camera.dll and backlight.dll. There are drivers run by device.exe.
A link file in \Windows\開始功能表\程式集 The shortcut LNK file.
Files in \Windows\AppMgr\[XCamera ….] Looks like some files created by AppMgr. I am not sure what they are, but they should be backup.
Registry XCamera does not user hive, we only need to backup system hive.

So, here is the procedure to backup system for XCamera.

  1. Backup registry using RegSaveKey()
  2. Backup all files listed in above table

I don’t get any problem on backup process (很棒). So, let’s clean boot the device and start our restore procedure.

  1. Find devices use camera.dll and backlight.dll, de-active them. (procedure in [Driver file replacement])
  2. Using CopyFile() API to replace camera.dll and backlight.dll (original files are INROM file, after this copy, they becomes NORMAL files)
  3. Create \windows\AppMgr\[XCamera …] folder and copy backup files into that folder
  4. Create \Program Files\XCamera folder and copy backup files into that folder
  5. Copy backup system hive file to “My Documents” folder and using RegReplaceKey() function to restore it.
  6. Reboot device

There are two things cause you need to reboot the device: First, the de-actived devices will be active again after reboot (Of course, you can active them by yourself). Second, the RegReplaceKey() API will un-mount system hive, you need to reboot the device and OS will use your hive to replace system hive.

After reboot, I can see XCamera in 程式集, and it can be run normally.

But, I found another problem on this procedure. After restore, I cannot find the application XCamera in application manager, that means I cannot uninstall and upgrade the application. 嚎啕大哭

Looks like application manager using other resource on disk. Maybe database??? I think I found my next topic…

沒有留言:

張貼留言