Old 2nd January 2018, 20:48   #1
eppf
Junior Member
 
Join Date: Jan 2018
Posts: 7
Question DeleteRegKey Blue Screen issue

Hi,
I am new to NSIS but have a legacy script that causes a blue screen on Windows 10. The issue is caused by a call to

DeleteRegKey HKLM "($NONEXISTINGVAR)".

The definition of $NONEXISTINGVAR was commented out, some time ago, so in effect the script is trying to delete a key that does not exist. I would expect that it would do nothing however it deletes the HKEY_LOCAL_MACHINE\BCD00000000\Description entry and thus the blue screen on reboot.

This issue did not occur with the same script in windows 8. Any ideas as to why this happens or if it is bug would be appreciated.

Thanks
eppf is offline   Reply With Quote
Old 2nd January 2018, 20:55   #2
eppf
Junior Member
 
Join Date: Jan 2018
Posts: 7
BTW. Warning Do not try DeleteRegKey HKLM "($NONEXISTINGVAR)".
unless you have a windows recovery disk available.
eppf is offline   Reply With Quote
Old 3rd January 2018, 07:00   #3
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 4,635
NSIS version?

I can see how it could happen if the path was "" but you have () there so it should never be a empty path, strange.

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 3rd January 2018, 07:24   #4
eppf
Junior Member
 
Join Date: Jan 2018
Posts: 7
It happens in the latest version as well as in version 2.3. I am away from my pc so I might have got the () incorrect. Is the empty string a bug then?
Thanks
eppf is offline   Reply With Quote
Old 3rd January 2018, 07:34   #5
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 4,635
2.3 or 3.2? There has been some changes to the registry handling after 3.0 but from my quick look at the code I don't think they matter even if it was related to registry delete handling. 2.3 is way too old, at least use 2.5x.

I don't know if a empty string is a bug, you are basically asking it to delete the entire tree. If we should allow you to do that is another question.

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 3rd January 2018, 12:23   #6
eppf
Junior Member
 
Join Date: Jan 2018
Posts: 7
Hi Anders,
Thanks for your replies. I am can now give you the actual revision details.
The issue is in both v2.44 and v3.02.

The entire tree does not get deleted just the Description Folder under Computer\HKEY_LOCAL_MACHINE\BCD00000000.

Would it not be better to block the deletion if the subkey is ""? As this is a very annoying and difficult to catch.

Any ideas why it would happen just in windows 10?

Thanks again
eppf is offline   Reply With Quote
Old 3rd January 2018, 19:18   #7
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 4,635
Can you please clarify if you are passing "' or "()" as the path?

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 4th January 2018, 09:09   #8
eppf
Junior Member
 
Join Date: Jan 2018
Posts: 7
The actual code used :

DeleteRegKey HKLM "$(MY_REGKEY)"

MY_REGKEY is not declared anywhere in the script.
eppf is offline   Reply With Quote
Old 4th January 2018, 12:42   #9
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 4,635
Yes, that turns into a empty string, but the compiler should be warning you with "LangString "MY_REGKEY" is not set in language table of language 1033"

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 5th January 2018, 08:10   #10
eppf
Junior Member
 
Join Date: Jan 2018
Posts: 7
Yes the warning was shown but unfortunately ignored. I am afraid this is common with warnings.

Now that you see the problem is there any chance that it could be upgraded to an error rather than a warning or some other measure to prevent the issue?

Thanks
eppf is offline   Reply With Quote
Old 5th January 2018, 12:25   #11
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 4,635
You can compile with /WX to turn warnings into errors.

It is not possible to fully detect this empty string in the compiler but we could perhaps avoid it at run-time.

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 5th January 2018, 12:29   #12
JasonFriday13
Major Dude
 
JasonFriday13's Avatar
 
Join Date: May 2005
Location: New Zealand
Posts: 858
You can add /WX to the makensis command line, this treats warnings as errors.

"Only a MouseHelmet will save you from a MouseTrap" -Jason Ross (Me)
NSIS 3 POSIX Ninja
Wiki Profile
JasonFriday13 is offline   Reply With Quote
Old 5th January 2018, 15:33   #13
eppf
Junior Member
 
Join Date: Jan 2018
Posts: 7
Ok, this is helpful but not useful as it only takes one user not to add the arguments to get into the situation. I think the problem can occur in other ways too.

DeleteRegKey HKLM ""
DeleteRegKey HKLM "$(MY_REGKEY)" where MY_REGKEY is defined as ""

In any case the big questions for me is in relation to :

1.Why only the HKEY_LOCAL_MACHINE\BCD00000000\Description entry is deleted and not the whole tree.

Quote:
I don't know if a empty string is a bug, you are basically asking it to delete the entire tree.
2. Who can answer the question :
Quote:
If we should allow you to do that is another question.
3. Why it only occurs on Windows 10?

Thanks again for your help
eppf is offline   Reply With Quote
Old 5th January 2018, 22:41   #14
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 4,635
We could detect "" and "${xyz}" in the compiler. Possibly "$(xyz)" but not "$xyz", that can only be detected at run-time. The soon to be released NSIS v3.03 will also allow you to turn warnings into errors in the .nsi with a !pragma.

1) To delete a registry key we have to delete all the children first. The order of keys returned by Windows is undefined. When we find a child key we cannot delete the whole operation is aborted but the already deleted keys are gone.


2) I will try to discuss it with kichik before the next release. I have already added some basic code to installers to try to stop this. We are however a little bit in undefined territory here. You are allowed to open a "" subkey but MSDN does not specify what happens when you try to delete one. We call RegDeleteKeyEx if it is available and RegDeleteKey if not and things might also vary depending on the Windows version and if it is 64-bit or not (the WOW64 layer might not be 100% compatible with the "real thing").


3) It looks like there is something wrong/changed with the ACL on the BCD00000000\Description key on Windows 10. On Windows 8 you would not be able to delete it so easily. The next key (Objects) however is more locked down so the delete operation would end there.

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Reply
Go Back   Winamp & SHOUTcast Forums > Developer Center > NSIS Discussion

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump