Project

General

Profile

Bug #10820

Win32 Registry Delete uses ANSI instead of Wide APIs

Added by ferventcoder (Rob Reynolds) almost 6 years ago. Updated over 5 years ago.

Status:
Closed
Priority:
Normal
Assignee:
cruby-windows
Target version:
-
[ruby-core:67958]

Description

https://github.com/ruby/ruby/blob/trunk/ext/win32/lib/win32/registry.rb#L236-L237

Contains:

    module API
      include Constants
      extend Importer
      dlload "advapi32.dll"
      [
        "long RegOpenKeyExW(void *, void *, long, long, void *)",
        "long RegCreateKeyExW(void *, void *, long, long, long, long, void *, void *, void *)",
        "long RegEnumValueW(void *, long, void *, void *, void *, void *, void *, void *)",
        "long RegEnumKeyExW(void *, long, void *, void *, void *, void *, void *, void *)",
        "long RegQueryValueExW(void *, void *, void *, void *, void *, void *)",
        "long RegSetValueExW(void *, void *, long, long, void *, long)",
        "long RegDeleteValue(void *, void *)",
        "long RegDeleteKey(void *, void *)",
        "long RegFlushKey(void *)",
        "long RegCloseKey(void *)",
        "long RegQueryInfoKey(void *, void *, void *, void *, void *, void *, void *, void *, void *, void *, void *, void *)",
      ].each do |fn|
        cfunc = extern fn, :stdcall
        const_set cfunc.name.intern, cfunc
      end

Should use RegDeleteValueW and RegDeleteKeyW.

Updated by ferventcoder (Rob Reynolds) almost 6 years ago

Apparently markdown didn't work so well, but hopefully the gist of the issue is captured here.

Updated by ferventcoder (Rob Reynolds) almost 6 years ago

For the issue, without this fix, it is likely not to find registry keys/values that have unicode in them. This is what we were seeing.

Updated by ferventcoder (Rob Reynolds) almost 6 years ago

Looks like you may want to explore the same for RegQueryInfoKey as well. See https://msdn.microsoft.com/en-us/library/windows/desktop/ms724902.aspx

Updated by nobu (Nobuyoshi Nakada) almost 6 years ago

  • Description updated (diff)
  • Status changed from Open to Assigned
  • Assignee changed from usa (Usaku NAKAMURA) to cruby-windows
  • Backport changed from 2.0.0: UNKNOWN, 2.1: REQUIRED, 2.2: REQUIRED to 2.0.0: DONTNEED, 2.1: REQUIRED, 2.2: REQUIRED
#5

Updated by nobu (Nobuyoshi Nakada) almost 6 years ago

  • Status changed from Assigned to Closed
  • % Done changed from 0 to 100

Applied in changeset r49542.


registry.rb: wide versions

  • ext/win32/lib/win32/registry.rb (Win32::Registry::API): use wide versions of RegDeleteValue and RegDeleteKey. [ruby-core:67958] [Bug #10820]

Updated by naruse (Yui NARUSE) almost 6 years ago

  • Backport changed from 2.0.0: DONTNEED, 2.1: REQUIRED, 2.2: REQUIRED to 2.0.0: DONTNEED, 2.1: REQUIRED, 2.2: DONE

ruby_2_2 r49622 merged revision(s) 49542.

Updated by Iristyle (Ethan Brown) over 5 years ago

Yui NARUSE wrote:

ruby_2_2 r49622 merged revision(s) 49542.

I would like to see this backported to Ruby 2.1 as well. Without it, registry keys and values cannot be deleted at all. This is a fairly large issue on Windows.

Comment left on https://github.com/ruby/ruby/commit/eef3f0d94cd884a27ed2b9523240370f5e8026f1

Updated by nobu (Nobuyoshi Nakada) over 5 years ago

This issue is marked as ‘2.1: REQUIRED’.

#9

Updated by usa (Usaku NAKAMURA) over 5 years ago

  • Backport changed from 2.0.0: DONTNEED, 2.1: REQUIRED, 2.2: DONE to 2.0.0: DONTNEED, 2.1: DONE, 2.2: DONE

ruby_2_1 r51596 merged revision(s) 49542.

Also available in: Atom PDF