Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Access Violation on getValue? #64

Open
tomysshadow opened this issue Dec 17, 2018 · 3 comments
Open

Access Violation on getValue? #64

tomysshadow opened this issue Dec 17, 2018 · 3 comments

Comments

@tomysshadow
Copy link

tomysshadow commented Dec 17, 2018

This line of code in registry.js appears to be causing my NodeJS to abruptly terminate with an access violation.

        // QUERY FOR VALUE SIZE & TYPE
        var result = advApi.RegQueryValueExA(key.handle.deref(), valueName, null, pKeyType, null, pKeyDataLength);

This is my code...

			var WindowsRegistry = require("windows-registry");
			var internetSettingsKey = new WindowsRegistry.Key(WindowsRegistry.windef.HKEY.HKEY_CURRENT_USER, "Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings", WindowsRegistry.windef.KEY_ACCESS.KEY_QUERY_VALUE | WindowsRegistry.windef.KEY_ACCESS.KEY_SET_VALUE);
			local.internetSettings.proxyServer = internetSettingsKey.getValue("ProxyServer");
			local.internetSettings.proxyEnable = internetSettingsKey.getValue("ProxyEnable");

In debug output, I can see it attempting to invoke the function...

  ref allocating Buffer for type with "size" 4 +1ms
  ref setting value on allocated buffer <Buffer@0x00000206B0DC16A0 00 00 00 00 00 00 00 00> +0ms
  ref set(): (offset: 0) <Buffer@0x00000206B0DC16B0 00 00 00 00 00 00 00 00> <Buffer@0x00000206B0DC16A0 00 00 00 00 00 00 00 00> +1ms
  ref writing pointer to buffer <Buffer@0x00000206B0DC16B0 00 00 00 00 00 00 00 00> 0 <Buffer@0x00000206B0DC16A0 00 00 00 00 00 00 00 00> +0ms
  ref allocating Buffer for type with "size" 4 +0ms
  ref setting value on allocated buffer <Buffer@0x00000206B0DC15B0 00 00 00 00 00 00 00 00> +0ms
  ref set(): (offset: 0) <Buffer@0x00000206B0DC13D0 00 00 00 00 00 00 00 00> <Buffer@0x00000206B0DC15B0 00 00 00 00 00 00 00 00> +0ms
  ref writing pointer to buffer <Buffer@0x00000206B0DC13D0 00 00 00 00 00 00 00 00> 0 <Buffer@0x00000206B0DC15B0 00 00 00 00 00 00 00 00> +0ms
  ref dereferencing buffer <Buffer@0x00000206B0DC1710 10 04 00 00 00 00 00 00> +0ms
  ref get(): (offset: 0) <Buffer@0x00000206B0DC1710 10 04 00 00 00 00 00 00> +1ms
  ffi:_ForeignFunction invoking proxy function +8ms
  ref allocating Buffer for type with "size" 0 +0ms

Am I using this wrong?

@RupW
Copy link

RupW commented Dec 17, 2018

What version of Node are you using please, and what's in your registry there? In particular does that key exist, and are the values REG_SZ type of a reasonable length, or are they missing, or something else?

Do you get a stack trace with any information in it? You don't see an error code thrown by windows-registry-node? Thanks!

@tomysshadow
Copy link
Author

Hi RupW,

No, there is no error code thrown by windows-registry-node. Rather, the NodeJS process itself is getting terminated because of an Access Violation. The ProxyServer key does exist, it is a REG_SZ with a value of "127.0.0.1:8888". The expected behaviour is to receive this string.

To be sure, I updated to 10.14.2 LTS and I'm still having the problem.

@tomysshadow
Copy link
Author

Hi, adding on to this.

I've discovered that this issue only occurs with debugging on. If I start NodeJS with this command as I've been doing...

set DEBUG=* & node index.js

Then the crash occurs. If I instead use this command:

set DEBUG="" & node index.js

The issue no longer occurs and the value is found successfully.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants