MoscaDotTo / Winapp2

A database of extended cleaning routines for popular Windows PC based maintenance software.
Creative Commons Attribution Share Alike 4.0 International
778 stars 87 forks source link

[Winapp2ool] VirtualStore Checker #356

Closed APMichael closed 5 years ago

APMichael commented 5 years ago

An idea for a new feature:

Could we possibly add a VirtualStore Checker? This feature would check if a FileKey or RegKey also exists in the VirtualStore location and if so, it would create a new entry for it. For example:

[32bit Web Browser *]
LangSecRef=3022
DetectFile=%ProgramFiles%\32BITWEB\32BW.exe
Default=False
FileKey1=%ProgramFiles%\32BITWEB\Data|LastURL.dat;LastURL.da0

Now VirtualStore Checker expands the variable %ProgramFiles% from FileKey1 to... %LocalAppData%\VirtualStore\Program Files %LocalAppData%\VirtualStore\Program Files (x86) ...and checks whether the directory exists on the system. I think the directory is enough, there is no need to check for the specified files.

If the directory exists, VirtualStore Checker creates a new entry. Either in a custom.ini or at the end of winapp2.ini.

[32bit Web Browser VS *]
LangSecRef=3022
DetectFile=%ProgramFiles%\32BITWEB\32BW.exe
Default=False
FileKey1=%LocalAppData%\VirtualStore\Program Files*\32BITWEB\Data|LastURL.dat;LastURL.da0

With this feature we could remove all VirtualStore Keys from winapp2.ini, because most of them are not necessary. And for legacy software users, the VirtualStore would still be cleaned.

Download > Trim > VirtualStore Checker and you have the perfect winapp2.ini. :smile:

VirtualStore locations:

%ProgramFiles%
> %LocalAppData%\VirtualStore\Program Files
> %LocalAppData%\VirtualStore\Program Files (x86)

%CommonAppData%
> %LocalAppData%\VirtualStore\ProgramData 

HKLM\SOFTWARE
> HKCU\Software\Classes\VirtualStore\MACHINE\SOFTWARE
MoscaDotTo commented 5 years ago

I've completed the FileKey portion of this work in https://github.com/MoscaDotTo/Winapp2/commit/148a46010ec25116dad285ba713b6f07f1ed20ea

Please test it out :)

https://github.com/MoscaDotTo/Winapp2/blob/148a46010ec25116dad285ba713b6f07f1ed20ea/winapp2ool/bin/Debug/winapp2ool.exe

MoscaDotTo commented 5 years ago

FWIW it is included as part of the normal trim process (for now?) with no way to enable/disable it, as it seems quite in line with the general concept of the trim anyway (removing entries that don't apply to your system)

I don't think I'd take it the logical next step (removing keys that point to places that don't exist) since many FileKeys may be "volatile" (to use Alan_B's nomenclature.)

MoscaDotTo commented 5 years ago

While there's no performance overhead (that I'm aware of) with any application regarding number of/unneeded filekeys, after trimming with the virtualstore trimming enabled on filekeys, my trimmed file is ~3.2% smaller than without trimming virtualstore (161.4KB vs 166.8)

APMichael commented 5 years ago

Wow, that was fast! Thank you very much. The improved Trim version works great and flawless and I didn't notice any speed loss. 👍

I noticed you reversed my logic: My original intention was that we could remove all FileKeys and RegKeys for the VirtualStore positions from the main Winapp2.in file on GitHub. Anyway, the result is almost the same.

MoscaDotTo commented 5 years ago

I noticed this too, I'm in the process of reimplementing it the way you originally asked (but still part of the trim).

MoscaDotTo commented 5 years ago

I pushed a new build that implements this new behavior (adding keys where there are none)

Feel free to test by removing all the FileKeys and RegKeys pointing to VirtualStore from your local file and see what (if anything) is recreated. I have not yet tested ExcludeKeys to make sure they work

MoscaDotTo commented 5 years ago

https://github.com/MoscaDotTo/Winapp2/commit/37e1a63fbe8852fce03b91d989528bbda42b90ee

ExcludeKeys appear to be working now that I've told the program to operate on them ;)

APMichael commented 5 years ago

Awesome! It works perfectly. 😃

Just two things I noticed:

MoscaDotTo commented 5 years ago

I'll check into the Reg ExcludeKeys

The header text is hardcoded and always has been more or less. Trimmed files have their # of entries updated and the header restored because winapp2ool's internals don't allow for saving the positions of the comments it reads so I have no way of restoring them. (This is a shortcoming of the design that I have plans to address at a later date).

I think it has some minor differences from the current one, but I had planned on opening a pull for that.

https://github.com/MoscaDotTo/Winapp2/blob/master/winapp2ool/components/winapp2handler.vb#L293

MoscaDotTo commented 5 years ago

Sorry that's the wrong branch

https://github.com/MoscaDotTo/Winapp2/blob/Branch1/winapp2ool/components/winapp2handler.vb#L293

APMichael commented 5 years ago

Thanks for the clarification.

Did you change something on the alphabetization check? In this new version WinappDebug reports alphabetization errors.

MoscaDotTo commented 5 years ago

If you removed the virtualstore keys there will be many alphabetization errors, winapp2ool can fix them :) See the main winapp2.ini on branch1

MoscaDotTo commented 5 years ago

ExcludeKeys pointing to VirtualStore locations in the registry should now be generated

APMichael commented 5 years ago

Yes, it's working now! 👍 Thanks again for your great work.

If you removed the virtualstore keys there will be many alphabetization errors, ...

The new version shows some errors that are not shown in the release version of winapp2ool. Just download winapp2.ini (don't use Trim) and run WinappDebug. When you compare the .ini files, you will notice that there is a changed order. For example:

Release version:
RegKey2=HKLM\Software\Microsoft\Microsoft Games\Age of Empires|Zone
RegKey3=HKLM\Software\Microsoft\Microsoft Games\Age of Empires Expansion\1.0|Zone
RegKey4=HKLM\Software\Microsoft\Microsoft Games\Age of Empires II: The Conquerors Expansion\1.0|Zone

New version:
RegKey2=HKLM\Software\Microsoft\Microsoft Games\Age of Empires Expansion\1.0|Zone
RegKey3=HKLM\Software\Microsoft\Microsoft Games\Age of Empires II: The Conquerors Expansion\1.0|Zone
RegKey4=HKLM\Software\Microsoft\Microsoft Games\Age of Empires|Zone
MoscaDotTo commented 5 years ago

It should be fixed. I removed a leading space from a parameter in a call to replaceAndSort thinking it to be a typo but I see now why I had it that way :)

APMichael commented 5 years ago

Confirmed! Thank you very much for the fast fix.

Great, after the release of the new winapp2ool version we can finally remove all VirtualStore Keys! 😃

APMichael commented 5 years ago

What I noticed when using WinappDebug: It seems that WinappDebug overlooks incorrectly numbered ExcludeKeys.

MoscaDotTo commented 5 years ago

ExcludeKeys were accidentally left out of the winappdebug process when I rewrote the way the keys are processed internally. should be fixed in the most recent build(s), I neglected to resync after I fixed this.

APMichael commented 5 years ago

Works with the latest build! 👍 Thank you very much for another quick fix. 😄

MoscaDotTo commented 5 years ago

Closing this since the work is done