Bug #10820
closedWin32 Registry Delete uses ANSI instead of Wide APIs
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 10 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 10 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 10 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 10 years ago
- Description updated (diff)
- Status changed from Open to Assigned
- Assignee changed from usa (Usaku NAKAMURA) to 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
Updated by nobu (Nobuyoshi Nakada) almost 10 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 10 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 9 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 9 years ago
This issue is marked as ‘2.1: REQUIRED’.
Updated by usa (Usaku NAKAMURA) over 9 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.
Updated by headius (Charles Nutter) over 2 years ago
Late to the party, but why was RegQueryInfoKey
also update to use W
? I am working on https://github.com/jruby/jruby/issues/7106 and cannot figure out how CRuby manages to locate RegQueryInfoKey
when only the A
and W
versions should exist in the actual DLLs.
Updated by nobu (Nobuyoshi Nakada) over 2 years ago
headius (Charles Nutter) wrote in #note-10:
Late to the party, but why was
RegQueryInfoKey
also update to useW
?
It seems unneeded because not using any WCHAR
arguments.
I am working on https://github.com/jruby/jruby/issues/7106 and cannot figure out how CRuby manages to locate
RegQueryInfoKey
when only theA
andW
versions should exist in the actual DLLs.
It's done by fiddle.
https://github.com/ruby/fiddle/blob/master/ext/fiddle/handle.c#L342-L380