Skip to content

Commit

Permalink
(PUP-7627) Changes CreateSymbolicLinkW return from BOOL to BOOLEAN
Browse files Browse the repository at this point in the history
I was tracking down why CreateSymbolicLinkW was returning non-zero when
failing on one test VM and not a different one
(puppetlabs/puppetlabs_spec_helper#192).

Turns out CreateSymbolicLinkW returns a `BOOLEAN` (1 byte) rather than a
`BOOL` (4 bytes), so I was getting random garbage in the upper 3 bytes
and therefore a non-zero result.
  • Loading branch information
rodjek committed Jun 7, 2017
1 parent a490b36 commit e0bd386
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 3 additions & 0 deletions lib/puppet/util/windows/api_types.rb
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,9 @@ def read_com_memory_pointer(&block)
# https://blogs.msdn.com/b/oldnewthing/archive/2011/03/28/10146459.aspx
FFI.typedef :int32, :win32_bool

# The BOOLEAN data type (different to BOOL) is only 1 byte.
FFI.typedef :int8, :boolean

# Same as a LONG, a 32-bit signed integer
FFI.typedef :int32, :hresult

Expand Down
2 changes: 1 addition & 1 deletion lib/puppet/util/windows/file.rb
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ def self.resolve_symlink(handle)
begin
ffi_lib :kernel32
attach_function_private :CreateSymbolicLinkW,
[:lpwstr, :lpwstr, :dword], :win32_bool
[:lpwstr, :lpwstr, :dword], :boolean
rescue LoadError
end

Expand Down

0 comments on commit e0bd386

Please sign in to comment.