Jump to content

Welcome to MSFN Forum
Register now to gain access to all of our features. Once registered and logged in, you will be able to create topics, post replies to existing threads, give reputation to your fellow members, get your own private messenger, post status updates, manage your profile and so much more. This message will be removed once you have signed in.
Login to Account Create an Account


Photo

Registry Peculiarities and Solutions

- - - - -

  • Please log in to reply
13 replies to this topic

#1
CharlotteTheHarlot

CharlotteTheHarlot

    MSFN Master

  • Member
  • PipPipPipPipPipPipPipPip
  • 2,054 posts
  • Joined 24-September 07
  • OS:none specified
  • Country: Country Flag
Registry Peculiarities and Solutions

I am creating this thread to pool together the many interesting registry anomalies and their solutions into one place. This should be useful to help others check out their own registry to determine if any of the problems exist and whether they are something to worry about. It will probably take some time to dig through the vast array of discussions of the past and collect them here. I will edit this first post which will serve as an index into this and other threads with useful content. If anyone comes upon something that fits into this category make a comment below!

Index

References


+++ Originally Posted on 2013-03-14

Edited by CharlotteTheHarlot, 19 March 2013 - 01:19 PM.

... Let him who hath understanding reckon the Number Of The Beast ...



How to remove advertisement from MSFN

#2
CharlotteTheHarlot

CharlotteTheHarlot

    MSFN Master

  • Member
  • PipPipPipPipPipPipPipPip
  • 2,054 posts
  • Joined 24-September 07
  • OS:none specified
  • Country: Country Flag
Multiple Backslashes in File Paths.

This one was inspired by a problem seen here and IMHO is very much worth checking for in your own registry. I suggest a careful audit of your exported registry in a text editor to accomplish this. You need to pay attention to the convention that a text editor uses for searching particular characters. For example, PFE32 ( Programmer's File Editor ) itself uses the backslash character as a control code which makes searching for backslashes double the fun.


Escaping REGEDIT

Backslashes ( \ ) are historically used to demark directories in DOS are obviously also used in the registry to demark keys and in string values for file paths plus other things. The backslashes used in file paths are exported to registry text files doubled up ( \\ ). This is so that when they are re-imported into REGEDIT they get interpreted correctly. It can be very confusing since the same character serves two purposes, but is understandable if you just think of ( \\ ) as not really being two backslashes, but in actuality an "escape" character followed by a backslash, which means to REGEDIT ( or any other program using the same convention ) that when it sees an "escape" to enter the following character literally. This escape function is active for data being entered as strings which are signified by surrounding quotes. Both "quotes" and "backslashes" that are to be used within a string should be preceded with an "escape character". Therefore ( \" ) simply means escape quote and ( \\ ) means escape backslash. What happens literally is that when REGEDIT is importing or exporting the registry, and it encounters a quote ( " ) it slips into "string mode" and stays there until it sees the next non-escaped quote ( " ). All the quotes and backslashes that it encounters in between those two bookends get escaped when exporting, and require escapes when importing.

Posted Image


The main rule to remember is that when processing registry values through the REGEDIT interface via dialog boxes, you need to always enter them exactly as intended with single backslahes, but NO doubles. When editing an ASCII or Unicode registry text file you DO need to double them up and also pay careful attention to quotes since that is the single most powerful delimiter character and is treated in pairs ( open and close ). Everything in between the pair is a text string that requires careful escaping of its own quotes and backslashes. Note that within the open and close quotes that there is no requirement for an even number of quotes, but they must be escaped correctly.

Here is an actual example string taken from that referenced link above ...

@="\"C:\\Windows\\Printdir.bat\" \"%1\"" ... what gets fed into REGEDIT from a REG script
@="\"C:\\Windows\\Printdir.bat\" \"%1\"" ... escaped quote chars shown in red, backslashes in blue
"C:\Windows\Printdir.bat" "%1" ............. this is what is actually inserted in the registry



Be Careful with Text Editors

Quotes can cause havoc with text editors that provide colors and highlighting through syntax recognition, especially when browsing registry text files. The algorithm that identifies strings is rarely as smart as REGEDIT and merely counts the quotes up and highlights them according to pairing. So in the case of an open and close quote that contains an odd number of quotes within it, the editor syntax highlighting breaks down and it gets ugly ( at least until another case of odd number of quotes is encountered ). The point here is that any out-of-sync syntax highlighting you see does NOT necessarily indicate an error in the data strings. This will roughly approximate how they go out of sync, but keep in mind that there are no errors here at all ...

|----------------------------------------------|
" String Value with \" 1 ...interior ...quotes " Here is some following data.
" String Value with \" 2 \" interior ...quotes " Here is some following data.
" String Value with \" 3 \" interior \" quotes " Here is some following data.



Bogus REGEDIT Backslashes

If everything is done properly within REGEDIT you will never see a case of a file path within a string utilizing double ( or more ) backslashes. But things can go awry via several avenues.

The most common way to mess this up is in the situation of entering string data directly into a REGEDIT dialog box using the escaped formatting designed a REG text file. As mentioned above, this is incorrect! When entering string data into a dialog box it is NOT escaped, it requires the single backslash for paths. This error happens when someone finds a registry patch ( meant for a REG text file ) on the Internet and they jump into REGEDIT and paste it in. Here is the problem: now you will have doubled backslashes and backslashed quotes that are sitting in the registry and when a program reads that registry value, the registry API supplies the contents literally as doubled backslashes and backslashed quotes and the program most likely will throw up an error ( if you're lucky ) or do nothing at all. The error that you encounter might be of absolutely no value to debugging either. It could say File Not Found or Path Not Found or almost anything else, and none of these will likely send you into REGEDIT to delete a single extra character.

Posted Image


Another error method occurs because of setup programs that have mistakes in their programming or perhaps in an associated INF file. This is something I find all the time as I'll show a few actual examples below.


Finding Errors

So it makes pretty good sense to periodically search for four consecutive backslashes \\\\ in a registry export, or two \\ if you are using the FIND function in REGEDIT. I'm doing the former here.

However there is a very important caveat ... remember that many times it is perfectly normal for multiple backslashes to appear in the registry in data values. For example in UNC path URLs like "uNCName"="\\\\ComputerName\\etc ( this is literally \\ComputerName\etc ). These are commonly used in the PnP section for USB and other devices, for example "SymbolicLink"="\\\\?\\. These must be skipped over when you search for anomalies ( except if for some strange reason it had 6 or 8 backslashes for example ). Anyway, the trick is to zero in on actual paths into the file system because these can have immediate consequences to a program that reads that data.

After completing an audit on a WinXP machine here are actual errors I found. I suspect others will also see these or similar entries. Note that I case-corrected everything here for better legibility but it has no consequence to registry operation as these are case insensitive ...

;;; Java ( Web Start Launcher )
[HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Uninstall\{26a24ae4-039d-4ca4-87b4-2f83216030ff}]
"DisplayIcon"="C:\\Program Files\\Java\\Jre6\\\\Bin\\Javaws.exe"

;;; Real Player
[HKEY_LOCAL_MACHINE\Software\Classes\Software\RealNetworks\RealMediaSDK\6.0\Preferences\ExternalResourcesDirectory]
@="C:\\Program Files\\Common Files\\Real\\Plugins\\\\ExtResources"
[HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Uninstall\RealPlayer 6.0]
"UninstallString"="C:\\Program Files\\Common Files\\Real\\Update\\\\Rnuninst.exe RealNetworks|RealPlayer|6.0"

;;; Shockwave Flash
[HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Uninstall\Shockwave]
"QuietUninstallString"="RunDll32 Advpack.dll,LaunchInfSection C:\\Windows\\\\Inf\\\\Swdir.inf,DefaultUninstall,5"

;;; seen on WinXP from unknown installer, WbemSnmp.log currently is blank!
[HKEY_LOCAL_MACHINE\Software\Microsoft\Wbem\Providers\Logging\WbemSnmp]
"File"="C:\\Windows\\System32\\Wbem\\Logs\\\\WbemSnmp.log"

;;; VBA ( Visual Basic for Applications ) installs with certain suites like Corel
[HKEY_LOCAL_MACHINE\Software\Classes\AWfile\DefaultIcon]
@="C:\\Windows\\Installer\\\\{db81779e-7cc5-4630-bcfc-754004956444}\\Misc.exe,6"
[HKEY_LOCAL_MACHINE\Software\Classes\ELMfile\DefaultIcon]
@="C:\\Windows\\Installer\\\\{db81779e-7cc5-4630-bcfc-754004956444}\\Misc.exe,6"
[HKEY_LOCAL_MACHINE\Software\Classes\FFAfile\DefaultIcon]
@="C:\\Windows\\Installer\\\\{db81779e-7cc5-4630-bcfc-754004956444}\\Misc.exe,6"
[HKEY_LOCAL_MACHINE\Software\Classes\FFLfile\DefaultIcon]
@="C:\\Windows\\Installer\\\\{db81779e-7cc5-4630-bcfc-754004956444}\\Misc.exe,6"
[HKEY_LOCAL_MACHINE\Software\Classes\FFTfile\DefaultIcon]
@="C:\\Windows\\Installer\\\\{db81779e-7cc5-4630-bcfc-754004956444}\\Misc.exe,6"
[HKEY_LOCAL_MACHINE\Software\Classes\FFXfile\DefaultIcon]
@="C:\\Windows\\Installer\\\\{db81779e-7cc5-4630-bcfc-754004956444}\\Misc.exe,6"
[HKEY_LOCAL_MACHINE\Software\Classes\OPCfile\DefaultIcon]
@="C:\\Windows\\Installer\\\\{db81779e-7cc5-4630-bcfc-754004956444}\\Misc.exe,6"
[HKEY_LOCAL_MACHINE\Software\Classes\STFfile\DefaultIcon]
@="C:\\Windows\\Installer\\\\{db81779e-7cc5-4630-bcfc-754004956444}\\Misc.exe,6"


NOTES: Many of these look like they will effectively disable those commands from ever executing, so they are errors of consequence. Both the Real Player and Flash Player screwups look like their UNINSTALLER cannot ever execute. That empty WBEM log file is almost certainly a consequence of that messed up registry entry. That set of keys from VBA means no icon will ever show for those filetypes ( thanks to its overly complicated MSI installer procedure ). All of these are manufacturer mistakes, their programmers messed it up in the installer most likely.

Fortunately it is easily fixed. Here is the simple "correcter" I ran to clean these up ...

;;; correcter
[HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Uninstall\{26a24ae4-039d-4ca4-87b4-2f83216030ff}]
"DisplayIcon"="C:\\Program Files\\Java\\Jre6\\Bin\\Javaws.exe"
[HKEY_LOCAL_MACHINE\Software\Classes\Software\RealNetworks\REalMediaSDK\6.0\Preferences\ExternalResourcesDirectory]
@="C:\\Program Files\\Common Files\\Real\\Plugins\\ExtResources"
[HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Uninstall\RealPlayer 6.0]
"UninstallString"="C:\\Program Files\\Common Files\\Real\\Update\\Rnuninst.exe RealNetworks|RealPlayer|6.0"
[HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Uninstall\Shockwave]
"QuietUninstallString"="RunDll32 Advpack.dll,LaunchInfSection C:\\Windows\\Inf\\Swdir.inf,DefaultUninstall,5"
[HKEY_LOCAL_MACHINE\Software\Microsoft\Wbem\Providers\Logging\WbemSnmp]
"File"="C:\\Windows\\System32\\Wbem\\Logs\\WbemSnmp.log"
[HKEY_LOCAL_MACHINE\Software\Classes\AWfile\DefaultIcon]
@="C:\\Windows\\Installer\\{db81779e-7cc5-4630-bcfc-754004956444}\\Misc.exe,6"
[HKEY_LOCAL_MACHINE\Software\Classes\ELMfile\DefaultIcon]
@="C:\\Windows\\Installer\\{db81779e-7cc5-4630-bcfc-754004956444}\\Misc.exe,6"
[HKEY_LOCAL_MACHINE\Software\Classes\FFAfile\DefaultIcon]
@="C:\\Windows\\Installer\\{db81779e-7cc5-4630-bcfc-754004956444}\\Misc.exe,6"
[HKEY_LOCAL_MACHINE\Software\Classes\FFLfile\DefaultIcon]
@="C:\\Windows\\Installer\\{db81779e-7cc5-4630-bcfc-754004956444}\\Misc.exe,6"
[HKEY_LOCAL_MACHINE\Software\Classes\FFTfile\DefaultIcon]
@="C:\\Windows\\Installer\\{db81779e-7cc5-4630-bcfc-754004956444}\\Misc.exe,6"
[HKEY_LOCAL_MACHINE\Software\Classes\FFXfile\DefaultIcon]
@="C:\\Windows\\Installer\\{db81779e-7cc5-4630-bcfc-754004956444}\\Misc.exe,6"
[HKEY_LOCAL_MACHINE\Software\Classes\OPCfile\DefaultIcon]
@="C:\\Windows\\Installer\\{db81779e-7cc5-4630-bcfc-754004956444}\\Misc.exe,6"
[HKEY_LOCAL_MACHINE\Software\Classes\STFfile\DefaultIcon]
@="C:\\Windows\\Installer\\{db81779e-7cc5-4630-bcfc-754004956444}\\Misc.exe,6"


+++ Originally Posted on 2013-03-14

Edited by CharlotteTheHarlot, 14 March 2013 - 08:00 PM.

... Let him who hath understanding reckon the Number Of The Beast ...


#3
CharlotteTheHarlot

CharlotteTheHarlot

    MSFN Master

  • Member
  • PipPipPipPipPipPipPipPip
  • 2,054 posts
  • Joined 24-September 07
  • OS:none specified
  • Country: Country Flag
Very Long Data Values

While auditing for extra backslashes I stumbled across that infamous FUBAR key from Real Player, which apparently gets automagically re-inserted whenever the thing is run ...

[HKEY_CURRENT_USER\Software\RealNetworks\RealMediaSDK\6.0\Preferences\PluginHandlerData\PluginInfo0]
@="xxx"
... where "xxx" is an astonishing 8,441 ASCII characters of nonsense. It of course is too long to display on a single line in most text editors so it will span several. This thing really must cause problems in Win9x and perhaps other versions and I wouldn't be surprised if it stops registry defragging from working successfully. Real Player has truly always been the epitome of suckiness. I decided not to display the actual data not for brevity, but because Real Player had a history of transmitting user data so I cannot be sure what the data actually decrypts to. Anyway, here is a really quick fix ...

[HKEY_CURRENT_USER\Software\RealNetworks\RealMediaSDK\6.0\Preferences\PluginHandlerData\PluginInfo0]
@=""
... which just sets the default to empty. I added that solution to my personal REG fixer that gets imported automatically from time to time to reset many common registry changes. Will it affect Real Player? I have no idea. I have not installed it on purpose in years, it apparently comes as a value-added payload with AOL and other 3rd party software. If it breaks, I just couldn't care less.


Registry Limits

Using that MSDN reference in the first post I snipped this table of alleged registry limits ...

Posted Image


... I say alleged because that page does not even mention what Windows versions they are talking about. I suspect we are seeing a table for Windows NT operating systems in general. I have much doubt that these apply to Win9x, especially Win95 prior to OSR when they corrected various mistakes in REGEDIT. If there is a problem at all, it will probably be one of those registry corruption issues. In other words, perhaps the registry API can successfully read or write 1 MB of characters contained in a registry value field. I suspect that in Win9x simply entering such data via a script or deleting such a value is very dangerous to the hive structure. And it certainly might cause problems with registry defragging. If anyone turns up more specific information please mention it and I will add them as references to the top post.

To see an actual example on WinXP have a look at this key ...

[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\TrayNotify]

... which has three values: "BalloonTip", "IconStreams" and "PastIconsStream". The first one is of no consequence but the latter two contain lots of data in the value field.

"IconStreams" ....... exports to 0,114,534 ASCI characters and contains 0,035,792 hex bytes
"PastIconsStream" ... exports to 3,346,344 ASCI characters and contains 1,081,522 hex bytes


Note that the difference in the ASCII size is that it contains commas and escapes and spaces as well as utilizing two characters to display a single byte.


Historical Examples

I haven't got anything except for older notes about these, but I can say they were noted by me over the years and may still exist to this day on various Win9x or WinXP+ computer systems.

;;; xxx = 5,966 ASCI characters ( Microsoft .NET Framework 2.0 Service Pack 1 )
[HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Installer\UserData\S-1-5-18\Products\1F3B805BA42A0C233B0158879691FE82\Features]
"URTM_STD_ENU_X86_IXP"="xxx"

;;; xxx = 5,981 ASCI characters ( Seagate DiscWizard )
[HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Installer\UserData\S-1-5-18\Products\31A06A18D42273642830E3CA301B124A\Features]
"TrueImageClient"="xxx"

;;; xxx = 5,012 ASCI characters ( Microsoft SQL Server Desktop Engine ) ... WinXP verified 5,000 actual ASCII characters
[HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Installer\UserData\S-1-5-18\Products\5B84B90E141EA724BAC03D06157222A4\Features]
"SqlRun"="xxx"

;;; xxx = 4,380 ASCI characters ( Microsoft .NET Framework 1.1 ) ... WinXP verified 4,360 actual ASCII characters
[HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Installer\UserData\S-1-5-18\Products\DDE7F2BCF1D91C3409CFF425AE1E271A\Features]
"Redist_Package"="xxx"

;;; xxx = 2,504 ASCI characters ( needs research )
[HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Installer\UserData\S-1-5-18\Products\68AB67CA7DA73301B7448A0000000020\Features]
"ReaderProgramFiles"="xxx"


 

Very Long Registry Key Names

If you look at that table of limitations again, clearly the easiest one to bump into is registry key name which is "255 characters. The key name includes the absolute path of the key in the registry, always starting at a base key, for example, HKEY_LOCAL_MACHINE". This is a very easy limit to hit. For example, just looking at one of those historical keys just above ...

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UserData\S-1-5-18\Products\1F3B805BA42A0C233B0158879691FE82\Features]

... that adds up to 141 characters as it is. If we hang that off a full user SID it would clock in at 179 characters. Add a subkey or two and we're right up against the limit. Sometime in the future I will get back to this subject and scan some registries for long keys and see what turns up.

Here is a guide for Total Key Name Length ( I had to shrink the font size to not run off the screen ) ...

1........10........20........30........40........50........60........70........80........90.......100.......110.......120.......130.......140.......150.......160.......170.......180.......190.......200.......210.......220.......230.......240.......250..255
|--------|---------|---------|---------|---------|---------|---------|---------|---------|---------|---------|---------|---------|---------|---------|---------|---------|---------|---------|---------|---------|---------|---------|---------|---------|----|
HKEY_LOCAL_MACHINE\aaaaaaaaaaaaaaaaaaaaaaaa\bbbbbbbbbbbbbbbbbbbbbbbb\ccccccccccccccccccccccccc\dddddddddddddddddddddddddd\eeeeeeeeeeeeeeeeeeeeeeeee\ffffffffffffffffffffffff\Total.Length.of.this.Registry.Key.Name.is.perfectly.fine.at.exactly.255.characters
HKEY_LOCAL_MACHINE\aaaaaaaaaaaaaaaaaaaaaaaa\bbbbbbbbbbbbbbbbbbbbbbbb\ccccccccccccccccccccccccc\dddddddddddddddddddddddddd\eeeeeeeeeeeeeeeeeeeeeeeee\ffffffffffffffffffffffff\This.Registry.Key.Name.is.NOT.GOOD.because.the.Length.Totals.exactly.256.characters

|--------|---------|---------|---------|---------|---------|---------|---------|---------|---------|---------|---------|---------|---------|---------|---------|---------|---------|---------|---------|---------|---------|---------|---------|---------|-----|
1........10........20........30........40........50........60........70........80........90.......100.......110.......120.......130.......140.......150.......160.......170.......180.......190.......200.......210.......220.......230.......240.......250...256


BTW, in certain editors like UltraEdit, you can set vertical line column markers. I find it helpful to set one at column 257 which accounts for the leading open square bracket in [HKEY_LOCAL_MACHINE, consequently the vertical line points to the 256th character position where no registry key names should touch.


Historical Examples

This is quite amazing. Here is my list of 192 illegal SoundBlaster Live Software keys which exceeded the limit. The shortest one here is 257 characters. These caused quite a mess ...

Spoiler



+++ Originally Posted on 2013-03-14

Edited by CharlotteTheHarlot, 15 March 2013 - 01:14 AM.

... Let him who hath understanding reckon the Number Of The Beast ...


#4
CharlotteTheHarlot

CharlotteTheHarlot

    MSFN Master

  • Member
  • PipPipPipPipPipPipPipPip
  • 2,054 posts
  • Joined 24-September 07
  • OS:none specified
  • Country: Country Flag
Length of Win9x Uninstall Key Name and String Value

This is an old one. The problem was that sometimes programs went missing in the Add/Remove Programs list even though it had a valid entry in the HKLM\...\Uninstall section. Microsoft still has the MSKB article up here. It lists Win98 and Win98se and NT4 as the affected operating systems. The problem was determined to be the overall length of a particular key name and/or string value.

Note that although it looks similar, this problem is different than the previous case of overall Key Name Length. This is effectively a further limitation of the previous case which I believe involves a function utilized by Add/Remove rather than a limitation of the Registry API itself. I would guess that it lies in a procedure that parses the key name and data and throws them into an array to populate that always extremely slow displaying list of installed programs. The absolute limitation here means that the key can never exceed 134 characters in total length, well short of the aforementioned absolute 255 character limit.

Here are the two things to check for ...

[HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Uninstall\xxx]
"DisplayName"="yyy"


Where both xxx and yyy are 63 characters or less.


Here is how to check the registry Key Name Length ...

.......................................................................1........10........20........30........40........50........60.63
|----------------------------------------------------------------------|--------|---------|---------|---------|---------|---------|--|
HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Uninstall\This Registry Key Name is perfectly fine at 63 characters Total
HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Uninstall\This Registry Key Name is a bit long because it is 64 characters

|----------------------------------------------------------------------|--------|---------|---------|---------|---------|---------|---|
.......................................................................1........10........20........30........40........50........60..64



Here is how to check the length of the String Value Length ...

[HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Uninstall\Acme Software Program]
...............1........10........20........30........40........50........60.63
|--------------|--------|---------|---------|---------|---------|---------|--|
"DisplayName"="This Value String Length is perfectly OK at 63 characters Total
"DisplayName"="This Value String Length is too long because it is 64 characters

|--------------|--------|---------|---------|---------|---------|---------|---|
...............1........10........20........30........40........50........60..64



+++ Originally Posted on 2013-03-14

Edited by CharlotteTheHarlot, 15 March 2013 - 01:06 AM.

... Let him who hath understanding reckon the Number Of The Beast ...


#5
CharlotteTheHarlot

CharlotteTheHarlot

    MSFN Master

  • Member
  • PipPipPipPipPipPipPipPip
  • 2,054 posts
  • Joined 24-September 07
  • OS:none specified
  • Country: Country Flag
( reserved )

... Let him who hath understanding reckon the Number Of The Beast ...


#6
GrofLuigi

GrofLuigi

    GroupPolicy Tattoo Artist

  • Member
  • PipPipPipPipPipPip
  • 1,360 posts
  • Joined 21-April 05
  • OS:none specified
  • Country: Country Flag
VisualC 2005 and 2008 Redistributables created* multiple entries with double backslashes (while in the same string, same line, single backslashes were also present). I am sure that is a bug.

Yes, I also search regularly for \\ in the registry. :angel

* I haven't checked the very latest, but all versions until SP1 MFC update did that, and I haven't installed later version.

GL

Edited by GrofLuigi, 14 March 2013 - 05:18 PM.


#7
CharlotteTheHarlot

CharlotteTheHarlot

    MSFN Master

  • Member
  • PipPipPipPipPipPipPipPip
  • 2,054 posts
  • Joined 24-September 07
  • OS:none specified
  • Country: Country Flag

VisualC 2005 and 2008 Redistributables created* multiple entries with double backslashes (while in the same string, same line, single backslashes were also present). I am sure that is a bug.

Yes, I also search regularly for \\ in the registry. :angel

* I haven't checked the very latest, but all versions until SP1 MFC update did that, and I haven't installed later version.

Thanks GL. Please feel free to throw these keys into a comment here so other people can check for the same errors in their own registries. :thumbup

... Let him who hath understanding reckon the Number Of The Beast ...


#8
GrofLuigi

GrofLuigi

    GroupPolicy Tattoo Artist

  • Member
  • PipPipPipPipPipPip
  • 1,360 posts
  • Joined 21-April 05
  • OS:none specified
  • Country: Country Flag

VisualC 2005 and 2008 Redistributables created* multiple entries with double backslashes (while in the same string, same line, single backslashes were also present). I am sure that is a bug.

Yes, I also search regularly for \\ in the registry. :angel

* I haven't checked the very latest, but all versions until SP1 MFC update did that, and I haven't installed later version.

Thanks GL. Please feel free to throw these keys into a comment here so other people can check for the same errors in their own registries. :thumbup


I can't because I've corrected them now. :) When I get to install them another time, I will.

It happened on XP and Server2003 (many, many times, every time I installed them, it was not a single case), while not on Win 7. They were inside multistring values, listing the paths to dlls and/or other files that got installed into WinSXS. As I said, in one line (the path) there could be several good (signle) backslashes and one double. Or in the multistring, few good lines and one bad.

And there were too many of them to list, but regedit search could find them.

GL

#9
Tripredacus

Tripredacus

    K-Mart-ian Legend

  • Super Moderator
  • 9,814 posts
  • Joined 28-April 06
  • OS:Server 2012
  • Country: Country Flag

Donator

When it comes to the double backslashes ( \\ ) I seem to recall something from my early days of learning programming. That sometimes you needed to use the backslash as an escape character. I suspect many programs were written with this in mind, and as such would store registry keys this way. So that when that program reads the registry, they can read the keys properly. It was only until later that I learned it is better (but not as nice looking) to handle those extra slashes, quotes, double quotes, etc that can potentially get in the way of parsing a string by using ASCII characters instead.

So it could be either an error on the programmer's side that allows these paths to be saved into the registry this way (write the data exactly without stripping out the extra backslash) or potential laziness on the programmer for storing the path this way (so that they do not need to re-convert the path for usage later). Of course all the while not realising that Windows itself may have trouble with these values, especially if (say) some new update or other program attempts to use the data and is not written by the same programmer.

The thought doesn't seem too difficult to fix the paths before inserting them into the registry, or reversing the process when reading them:
var p = new RegExp(s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&"))
https://github.com/viatropos/tower/issues/235

But it could be worse... maybe you can find some paths that use forward slashes instead!
myDirname = os.path.normpath("c:/aDirname/")
http://pythonconquerstheuniverse.wordpress.com/2008/06/04/gotcha-%E2%80%94-backslashes-in-windows-filenames/

Now I would think the idea of using a backslash as an escape character is a bad idea specifically because it is used in paths. Perhaps this was borrowed from some pre-DOS language? It seems only DOS and Windows based OSes will use a backslash in a path, while Unix and Linux will use the forward slash.

The internet is great for programming nowadays, with tons of help on tech and programmer sites, online documentation, etc. However, software isn't always that "new" in a lot of cases, but more like adaptations of older versions. Even drivers suffer this problem where there can still be found some old Windows 95 code in there. This can lead to these kinds of mistakes as well, since not all programmers at that time had access to online documentation, but instead would have to manage their offline manuals. Maybe if you were lucky you remembered to install those TechNet CDs with Visual Studio, or you had those 30lbs of books that came with Visual C. Even then, that's only documentation, you had no real feedback on whether what you were doing was a good idea, and no world-wide resource for finding new ways to do the same thing, or do that thing better. If it worked, that's all that mattered.
MSFN RULES | GimageX HTA for PE 3-5 | lol probloms
msfn2_zpsc37c7153.jpg

#10
CharlotteTheHarlot

CharlotteTheHarlot

    MSFN Master

  • Member
  • PipPipPipPipPipPipPipPip
  • 2,054 posts
  • Joined 24-September 07
  • OS:none specified
  • Country: Country Flag

When it comes to the double backslashes ( \\ ) I seem to recall something from my early days of learning programming. That sometimes you needed to use the backslash as an escape character. I suspect many programs were written with this in mind, and as such would store registry keys this way. So that when that program reads the registry, they can read the keys properly. It was only until later that I learned it is better (but not as nice looking) to handle those extra slashes, quotes, double quotes, etc that can potentially get in the way of parsing a string by using ASCII characters instead.

[...]

Now I would think the idea of using a backslash as an escape character is a bad idea specifically because it is used in paths. Perhaps this was borrowed from some pre-DOS language? It seems only DOS and Windows based OSes will use a backslash in a path, while Unix and Linux will use the forward slash.

It is especially fun when the text editor uses them also like PFE. So when you are searching for file path errors with 4 backslashes \\\\ in an export, the find string is literally 8 of them \\\\\\\\. It is a pain in the eyes! UltraEdit uses a caret ^ for the control character so searching for \\\\ is just that, \\\\ ( amazingly, searching for carets, is also simple ).

Anyone old enough to remember ANSI codes in DOS might recall how difficult it was to handle escape codes in most text editors. Perhaps they decided to avoid that and stick with a character that appears on every keyboard since the IBM PC era.

Still, they could have picked something else specifically for REGEDIT importing and exporting, because as I mentioned there are times that 2 backslashes \\ are legitimate.But there is so little chance that they were going to nail all the details correctly since they botched a couple of gigantic things along the way. For example, they should have completely isolated a separate machine hardware hive only containing information unique to that system with no other entries allowed. Allowing everything to co-mingle is at the root of most problems.

A better scenario would have been a 1st party Windows utility that can easily rebuild a theoretical independent hardware hive without messing up anything else. This could have been handled in the registry API by blocking write access to this protected hive except by this hardware tool and CfgMgr and other official tools. Repairing a machine would be simple and the saved costs would be in the many billions of dollars to Microsoft and all of us.

So compared to the major screwups that were made almost 20 years ago, the escape character seems to pale in comparison.

... Let him who hath understanding reckon the Number Of The Beast ...


#11
Tripredacus

Tripredacus

    K-Mart-ian Legend

  • Super Moderator
  • 9,814 posts
  • Joined 28-April 06
  • OS:Server 2012
  • Country: Country Flag

Donator

How about some more backslashes for you? :whistle:

Playing around with the WMI Object Browser recently, I found that when you look at Win32_DiskDrive, it will list your disks for you to choose one, for example:

\\.\PHYSICALDRIVE0
\\.\PHYSICALDRIVE1
etc

So let's say I want to pick the first option and see what info is in WMI... well the WMI path turns into this:

Win32_DiskDrive.DeviceID="\\\\.\\PHYSICALDRIVE0"

:wacko:
MSFN RULES | GimageX HTA for PE 3-5 | lol probloms
msfn2_zpsc37c7153.jpg

#12
CharlotteTheHarlot

CharlotteTheHarlot

    MSFN Master

  • Member
  • PipPipPipPipPipPipPipPip
  • 2,054 posts
  • Joined 24-September 07
  • OS:none specified
  • Country: Country Flag

Win32_DiskDrive.DeviceID="\\\\.\\PHYSICALDRIVE0"

Yeah, it is tricky. That one is an attempt to use the "proper" syntax as opposed to strictly legacy DOS/Windows. There is a good reference on URI at wiki ... here.

Things to consider

Windows

On Microsoft Windows systems, the normal colon ":" after a device letter has sometimes been replaced by a vertical bar (|) in file URLs. This reflected the original URL syntax, which made the colon a reserved character in a path part.

Since Internet Explorer 4, file URIs have been standardized on Windows, and should follow the following scheme. This applies to all applications which use URLMON or SHLWAPI for parsing, fetching or binding to URIs. To convert a path to a URL, use UrlCreateFromPath, and to convert a URL to a path, use PathCreateFromUrl.

To access a file "the file.txt", the following might be used.

For a network location:
file://hostname/path/to/the%20file.txt

Or for a local file, the hostname is omitted, but the slash is not (note the third slash):
file:///c:/path/to/the%20file.txt

This is not the same as providing the string "localhost" or the dot "." in place of the hostname. The string "localhost" will attempt to access the file as \\localhost\c:\path\to\the file.txt, which will not work since the colon is not allowed in a share name. The dot "." results in the string being passed as \\.\c:\path\to\the file.txt, which will work for local files, but not shares on the local system. For example file://./sharename/path/to/the%20file.txt will not work, because it will result in sharename being interpreted as part of the DOSDEVICES namespace, not as a network share.

The following outline roughly describes the requirements.

  • The colon should be used, and should not be replaced with a vertical bar.
  • Forward slashes should be used to delimit paths. note that while DOS requires backslashes, the Win32 API will accept either a forward or back slash.
  • Characters such as the hash (#) or question mark (?) which are part of the filename should be percent-encoded.
  • Characters which are not allowed in URIs, but which are allowed in filenames, must also be percent-encoded. For example, any of "{}`^ " and all control characters. In the example above, the space in the filename is encoded as %20.
  • Characters which are allowed in both URIs and filenames must NOT be percent-encoded.
  • Must not use legacy ACP encodings. (ACP code pages are specified by DOS CHCP or Windows Control Panel language setting.)
  • Unicode characters outside of the ASCII range must be UTF-8 encoded, and those UTF-8 encodings must be percent-encoded.
Use the provided functions if you can. If you must create a URL programmatically and you cannot access SHLWAPI.dll (for example from script, or another programming environment where the equivalent functions are not available) the above outline will help.

Legacy URLs

To aid the installed base of legacy applications, the PathCreateFromUrl recognizes certain URLs which do not meet these criteria, and treats them uniformly. These are called "legacy" file URLs as opposed to "healthy" file URLs.

In the past, a variety of other applications have used other systems. Some added an additional two slashes. For example, \\remotehost\share\dir\file.txt, would become file:////remotehost/share/dir/file.txt instead of the "healthy" file://remotehost/share/dir/file.txt.

Web pages

File URLs are rarely used in Web pages on the Internet, since they make the assumption that such a file exists on the client's computer. The host specifier can be used to retrieve a file from an external source, although no specific file-retrieval protocol is specified; and using it should result in a message that informs the user that no mechanism to access that machine is available.


... Let him who hath understanding reckon the Number Of The Beast ...


#13
bphlpt

bphlpt

    MSFN Addict

  • Member
  • PipPipPipPipPipPipPip
  • 1,798 posts
  • Joined 12-May 07
  • OS:none specified
  • Country: Country Flag
I'm afraid I know just enough about RegEx expressions to be very dangerous and get myself in a whole heap of trouble. Would someone mind please breaking this expression down and interpreting it for me, and/or pointing me to a well organized RegEx tutorial where I can find the answer for myself?

var p = new RegExp(s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&"))


Thanks in advance.

Cheers and Regards

Edited by bphlpt, 11 April 2013 - 09:28 PM.

Posted Image


#14
Tripredacus

Tripredacus

    K-Mart-ian Legend

  • Super Moderator
  • 9,814 posts
  • Joined 28-April 06
  • OS:Server 2012
  • Country: Country Flag

Donator

The example you quoted has an equivalent in AutoIT known as StringRegExpReplace which has this description: Replace text in a string based on regular expressions
http://www.autoitscr...gExpReplace.htm

Now even though I did read that link I had originally posted, I am not certain as to what language it is in exactly. Here are the basic concepts of RegExp:
http://en.wikipedia....#Basic_concepts

Here is W3school's Javascript page:
http://www.w3schools..._obj_regexp.asp
MSFN RULES | GimageX HTA for PE 3-5 | lol probloms
msfn2_zpsc37c7153.jpg




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users



How to remove advertisement from MSFN