Closed Bug 237754 Opened 20 years ago Closed 20 years ago

reintroduce getRegistryEntry

Categories

(Firefox :: General, defect)

x86
Windows 2000
defect
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: bugzilla, Assigned: bugzilla)

References

()

Details

(Whiteboard: fixed0.9)

Attachments

(1 file, 5 obsolete files)

My extension Launchy:
http://gemal.dk/mozilla/launchy.html
which enables users to open webpages and mailto with external applications is
using the getRegistryEntry function.

This function used to be part of winhooks. It seems that winhooks has been
completely killed with Mozilla Firefox. This has also killed off Launchy on
Mozilla Firefox.

I desperatly need getRegistryEntry on Mozilla Firefox for Launchy to work.

Is there a chance that getRegistryEntry could be reintroduced?

all the code is already there since I dont need any new functionality. I just
need the function to be accessable from Mozilla Firefox. Perhaps from the
@mozilla.org/browser/shell-service;1 object?

For my extension this is a complete blocker....:(
Attached patch first cut (obsolete) — Splinter Review
one additional file is needed. nsWindowsShellServiceUtil.cpp
Attached file new file (obsolete) —
Assignee: bugs → bugzilla
Status: NEW → ASSIGNED
I've tested it in my own compiled build of Mozilla Firefox and it works. Need
feedback
Comment on attachment 145534 [details] [diff] [review]
first cut

Ben: could you look at the patch. There's also a new file called
nsWindowsShellServiceUtil.cpp attached to the bug. That's needed to compile.
Attachment #145534 - Flags: review?(bugs)
Attachment #145534 - Flags: review?(bugs) → review?(firefox)
Attachment #145534 - Flags: review?(firefox) → review?(bryner)
Hi Henrik, I'll look at this later tonight. I have some concerns about API that
I'd like to think about. 
I wonder why this was removed. Btw, is there a bug # for this removal?
(In reply to comment #6)
> I wonder why this was removed. Btw, is there a bug # for this removal?

winhooks got removed in bug 236744
I then filed bug 237617 about the missing getRegistryEntry
Comment on attachment 145534 [details] [diff] [review]
first cut

There's no need for a new file, nor a need to add back any of the old
excessively complex code. No structs, no classes, no byzantine object
structure, just some good ol' fashioned Windows C code. 

Simply add a method to nsIWindowsShellService called getRegistryEntry that
takes a string key name and a value name, so you can call:

var val = wss.getRegistryEntry("HKEY_CURRENT_USER\\blah\\blah\\blah\\", "val");
Attachment #145534 - Flags: review?(bryner) → review-
Hmm... I'm no C++ coder so I could really really need some help here.

Ben, do you have time to look at it?

Can anybody with interest in this bug, help me?
Attached patch Proposed patch (obsolete) — Splinter Review
I miss Launchy, so I figured I'd give this a shot. This patch is basically a
knockoff of the code Seth pointed out, simplified a little. It compiles and
seems to put Launchy back in working order (at least it does on my WinXP
system). It keeps the API the same as it used to be, rather than changing it to
resemble what Ben mentioned, since I don't see why extensions should have to
special-case Firefox in their code.
Comment on attachment 146203 [details] [diff] [review]
Proposed patch

How does this look, Ben?
Attachment #146203 - Flags: review?(bugs)
Comment on attachment 146203 [details] [diff] [review]
Proposed patch

You beat me to this, I was just about to give this a shot! You've taken the
same approach as I would as it seems the simplest way to implement things to
me.

>+
>+  LONG rv = ::RegOpenKey( baseKey, aSubKeyName, &key );

RegOpenKey is depreciated, according to MSDN it's for compatibility with 16 bit
apps only. Use RegOpenKeyEx instead:

LONG rv = ::RegOpenKeyEx( baseKey, aSubKeyName, 0, KEY_READ, &key );
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/sysinfo/base/r
egopenkeyex.asp
Attached patch Patch with RegOpenKeyEx (obsolete) — Splinter Review
As I nearly finished here's my patch anyway, basically similar to the earlier
one, but with RegOpenKeyEx rather than RegOpenKey (see my previous comment).

If this gets checked in credit should goto Jon Henry as he did post his patch
first which is almost identical bar the call to RegOpenKey.

The original winhooks code uses RegOpenKey too, perhaps I should file a bug for
seamonkey to replace it with RegOpenKeyEx there as well?

Dave
Attachment #145534 - Attachment is obsolete: true
Attachment #145535 - Attachment is obsolete: true
I would have a question. Does getRegistryEntry compromise security? I mean, can
this function be accessed via Javascript from a web page?
OK, forgot to declare one of the variables I was using! Here's the fixed
version.

On a bit of a tangent but vaguely related I've had a look and bug 216388 is the
bug that describes the issue of using RegOpenKey in Seamonkey
Attachment #146218 - Attachment is obsolete: true
(In reply to comment #15)
> I would have a question. Does getRegistryEntry compromise security? I mean, can
> this function be accessed via Javascript from a web page?

By default chrome apps (anything accessible via chrome:// url's - e.g.
extensions and the app itself) have a higher level of access than normal web
pages or locally saved HTML files. getRegistryEntry is not exposed to
non-prililedged code.

http://www.mozilla.org/projects/security/components/reviewguide.html
why not use the existing, scriptable, nsIWindowsRegistry interface?

I think you can get the winhooks service and QI to it.  (for launchy, you could
do that in js)

If the existing code in nsWindowsHooks::GetRegistryEntry() isn't right, we
should just fix it.
(In reply to comment #18)
> why not use the existing, scriptable, nsIWindowsRegistry interface?
The problem is that in Firefox winhooks has been replaced with the shell service
which is designed to be a cross platform equivalent of winhooks.

> I think you can get the winhooks service and QI to it.  (for launchy, you could
> do that in js)

That's what he used to do
> 
> If the existing code in nsWindowsHooks::GetRegistryEntry() isn't right, we
> should just fix it.
I guess a solution that'd fit the needs of both seamonkey and firefox would be a
good idea
Comment on attachment 146227 [details] [diff] [review]
Forgot to declare 'rv'! (supercedes my previous patch)

Fix the indentation:

>+NS_IMETHODIMP 
>+nsWindowsShellService::GetRegistryEntry( PRInt32 aHKEYConstant, const char *aSubKeyName, const char *aValueName, char **aResult ) {
>+  
>+  HKEY hKey, fullKey;
>+
>+  *aResult = 0;
>+  // Calculate HKEY_* base key
>+  switch (aHKEYConstant) {
>+  case HKCR:
>+    hKey = HKEY_CLASSES_ROOT;
>+    break;
>+  case HKCC:
>+    hKey = HKEY_CURRENT_CONFIG;
>+    break;
etc (line cases up with switch, only 2 spaces for each sub block)

and r=ben@mozilla.org
Attachment #146227 - Flags: review+
Attachment #146227 - Flags: superreview?(firefox)
Fixed the indentation as per Ben's comments
Attachment #146203 - Attachment is obsolete: true
Attachment #146227 - Attachment is obsolete: true
Comment on attachment 146338 [details] [diff] [review]
Patch addressing Ben's comments

Carrying over the r= from Ben
Attachment #146338 - Flags: review+
Attachment #146203 - Flags: review?(bugs)
Changes that affect Firefox only don't need super-review.
Ben: could you check the patch in?
Attachment #146227 - Flags: superreview?(firefox)
the changes in the bug are Firefox only. Could anybody check this in? I really
really like to get it into Firefox 1.0
David: where does the NS_INVALID_ARG come from. I seems to have problem with 
that? Did it compile with you?
it should be:
NS_ERROR_INVALID_ARG

could you make a new patch?
checked in (I did some formatting cleanup on it, and fixed the INVALID_ARG thing)
Status: ASSIGNED → RESOLVED
Closed: 20 years ago
Resolution: --- → FIXED
Bug thanx to David Hallowell!

Launchy will now be able to work with latest builds.

I've filed a new bug to improve the function:
http://bugzilla.mozilla.org/show_bug.cgi?id=241237
Status: RESOLVED → VERIFIED
reopening for the moment, will reclose once this lands on the 0.9 branch
(probably tomorrow)
Status: VERIFIED → REOPENED
Resolution: FIXED → ---
Whiteboard: checkin0.9
checked in on the 1.7 branch at 2004-04-25 12:43
Status: REOPENED → RESOLVED
Closed: 20 years ago20 years ago
Resolution: --- → FIXED
Whiteboard: checkin0.9 → fixed0.9
> checked in on the 1.7 branch

what do you mean? Mozilla 1.x already has getRegistryEntry!!!
I think they mean Firefox builds that are built off the 1.7 branch rather than
the Mozilla trunk. AFAIK 0.9 and 1.0 will be built off this stable branch.
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: