EldoS | Feel safer!

Software components for data protection, secure storage and transfer

SetIcon not working in CBFS v4

Also by EldoS: CallbackRegistry
A component to monitor and control Windows registry access and create virtual registry keys.
#24249
Posted: 03/22/2013 09:46:34
by Davide Baccaglini (Standard support level)
Joined: 11/19/2012
Posts: 48

Hello everyone, I've a problem with SetIcon method.

In my project the installation of icon works fine but, when I try to set the icon with SetIcon method this doen't have effects (there is an overlayIcon but is not recognize).

This is the code for install driver and icon :

Code
CallbackFileSystem.Install(currentDirectory + @"\Resources\Drivers\cbfs4.cab", ProjectResource.CBFS_INSTALL_GUID_V4, System.Environment.SystemDirectory, false, CallbackFileSystem.CBFS_MODULE_DRIVER | CallbackFileSystem.CBFS_MODULE_MOUNT_NOTIFIER_DLL | CallbackFileSystem.CBFS_MODULE_NET_REDIRECTOR_DLL, ref reboot4Driver);
CallbackFileSystem.Initialize(ProjectResource.CBFS_INSTALL_GUID_V4);
CallbackFileSystem.InstallIcon(currentDirectory + @"\Resources\Icons\EasyDriveIcon.ico", ProjectResource.CBFS_ICON_ID_V4, ref reboot4Icon);


and this for create storage and use icon :

Code
CallbackFileSystem.Initialize(ProjectResource.CBFS_INSTALL_GUID_V4);
CallbackFileSystem.SetRegistrationKey(ProjectResource.CBFS_LICENSE_KEY_V4);
callback.CreateStorage();
if(callback.IconInstalled(ProjectResource.CBFS_ICON_ID_V4))
callback.SetIcon(ProjectResource.CBFS_ICON_ID_V4);


IconInstalled returns always TRUE.

Is there any problem in my code?
With CBFS v3 it works fine and after upgrade dlls I only add CallbackFileSystem.Initialize method.

Thanks in advance,
Davide
#24250
Posted: 03/22/2013 09:50:19
by Davide Baccaglini (Standard support level)
Joined: 11/19/2012
Posts: 48

I forgot the a line in the first code block.

Quote
string currentDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);


It regards the path of drivers and icon: it's correct, the files exist.
#24251
Posted: 03/22/2013 10:03:45
by Eugene Mayevski (EldoS Corp.)

If you have a license, please link the license ticket to your user account before we continue. The ticket itself and the procedure of its use are specified in the registration e-mail that was sent to you upon license purchase. If you don't have the license ticket, please contact the person from which you have obtained the license key (the one in your source code) for a license ticket.

NOTE: please don't post license keys and license tickets to the forum. If you need to clarify something about your license, please use HelpDesk ( http://www.eldos.com/helpdesk/ ).


Sincerely yours
Eugene Mayevski
#28970
Posted: 03/26/2014 13:55:07
by Ivan P (Priority Standard support level)
Joined: 04/11/2011
Posts: 66

I have a similar problem:

When I install the icon from my provided path, it seems to be installed correctly, but clearing the TEMP folder makes icon unavailable.

After icon installation I can see there's a new registry hive with parameters:
Code
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\cbfs4\Parameters\DriveIconMappings\0

It contains 2 values (among others)
IconPath - this points to original filename provided to InstallIcon() method
TmpIconPath - this points to the icoXXXX.tmp file in the TEMP directory (that was obviously created by InstallIcon() call)

The problem is that when I launch Windows Exploer, the icon is obtained from TmpIconPath instead of IconPath.

If I delete the 'icoXXXX.tmp' file from my TEMP dir, the Windows Explorer (after restart) displays a 'broken icon' icon, and never tries to load the original one indicated by IconPath parameter (tested with Process Monitor)

CBFS: 4.0.136.25
Win7x64 ultimate.
#28977
Posted: 03/26/2014 16:19:02
by Vladimir Cherniga (EldoS Corp.)

When you install icon, it is copied to the TmpIconPath. You must restart the system and on the next boot that icon will be cached by the system. From that moment the icon from TmpIconPath can be deleted safely, because icon is already in icon cache.
If you delete the icon from Temp path right before system restart, that will cause an error displaying overlay.
#28982
Posted: 03/27/2014 05:26:20
by Ivan P (Priority Standard support level)
Joined: 04/11/2011
Posts: 66

Hi Vladimir!

Here's what I did:

1. Installed the icon and then restarted the system
2. Run Windows Explorer and mounted the disk (until this moment icoXXXX.tmp is not loaded I suppose)
3. Verified that the icon appeared on a drive. And restarted system again.
4. After second restart I deleted the icoXXXX.tmp file and started Windows Explorer

By runnig ProcessMonitor vefore opening 'My Coputer' I can see that Explorer tried to load icoXXXX.tmp (with no success, because it's been deleted) and haven't tried the original icon path.

I also noticed that every time I restart computer, all icons on the desktop are 'redrawn' (it's possible that IconCache is cleared, but the DateCreated attribute of IconCache.db file is older than restart attempts)
BTW, even if the problem is caused by clearing icon cache on my machine (however, I'm not using any Windows tweaking tools, reg. cleaners, etc.), I cannot guarantee there'll be no such clearing on a customer's one . And the drive icon will become broken, which can make a feel that drive is working badly.

What are the reasons of doing this via some temp icon instead of using an original path? We put icon into installation folder, and this gives some kind guarantee that it won't be deleted as opposed to some file in the user's TEMP directory.

Sincerely,
IP
#28984
Posted: 03/27/2014 06:33:36
by Vladimir Cherniga (EldoS Corp.)

Quote
Ivan P wrote:
By runnig ProcessMonitor vefore opening 'My Coputer' I can see that Explorer tried to load icoXXXX.tmp (with no success, because it's been deleted) and haven't tried the original icon path.

Actually TmpIconPath is used as an icon ID when registered in system.
Quote
Ivan P wrote:
What are the reasons of doing this via some temp icon instead of using an original path? We put icon into installation folder, and this gives some kind guarantee that it won't be deleted as opposed to some file in the user's TEMP directory.

That could not guarantee that another installation will put an icon in some temporary folder created by own, then delete that folder on finish the installation and delete the original icon file.
#28986
Posted: 03/27/2014 07:05:45
by Ivan P (Priority Standard support level)
Joined: 04/11/2011
Posts: 66

Quote
That could not guarantee that another installation will put an icon in some temporary folder created by own, then delete that folder on finish the installation and delete the original icon file.

Well, yes, but if it was said in documentation that the icon should not be deleted, not many users would created installation packages with temporary icons. Other option might be an additional boolean parameter that specifies if provided icon path is persistent or not.
We had to disable the 'icon' feature due to such behavior.
As I understand we can change TmpIconPath value for our icon right after successful installation as a workaround?
#28987
Posted: 03/27/2014 07:39:09
by Vladimir Cherniga (EldoS Corp.)

Quote
Ivan P wrote:
As I understand we can change TmpIconPath value for our icon right after successful installation as a workaround?

Yes, this should work.
#29032
Posted: 03/30/2014 08:54:37
by Ivan P (Priority Standard support level)
Joined: 04/11/2011
Posts: 66

Thanks, that worked, but we also had to prevent file deletion before calling UninstallIcon (just a notice for those who'll use this approach). Does playing with StorageType value can help somehow?

Another reason to have custom location for icon is a multiuser environment. The icon is installed only once under some user and is stored in his TEMP folder.
When another user logs in, its Explorer cannot load the icon from another user's TEMP due to insufficient permissions, and the icon is broken.
Also by EldoS: CallbackProcess
A component to control process creation and termination in Windows and .NET applications.

Reply

Statistics

Topic viewed 3799 times

Number of guests: 1, registered members: 0, in total hidden: 0




|

Back to top

As of July 15, 2016 EldoS Corporation will operate as a division of /n software inc. For more information, please read the announcement.

Got it!