summaryrefslogtreecommitdiff
path: root/lib/chef/win32
diff options
context:
space:
mode:
authorLamont Granquist <lamont@chef.io>2019-07-08 16:47:38 -0700
committerGitHub <noreply@github.com>2019-07-08 16:47:38 -0700
commitcfdd8523b66c92d988547269380319ac250b3ee9 (patch)
treed4983e2d9ca8b40f791e68152b7bfd99d4cd0fd7 /lib/chef/win32
parent643899fb580385968465c7e15e4f20908fc6c5ac (diff)
parentac56ffafe24e39fffb02cc1fbc0d3f27303390be (diff)
downloadchef-cfdd8523b66c92d988547269380319ac250b3ee9.tar.gz
Merge pull request #8711 from chef/lcg/new-chefstyle2
More Chefstyle updates
Diffstat (limited to 'lib/chef/win32')
-rw-r--r--lib/chef/win32/api/crypto.rb18
-rw-r--r--lib/chef/win32/api/error.rb8
-rw-r--r--lib/chef/win32/api/file.rb28
-rw-r--r--lib/chef/win32/api/installer.rb6
-rw-r--r--lib/chef/win32/api/memory.rb8
-rw-r--r--lib/chef/win32/api/net.rb74
-rw-r--r--lib/chef/win32/api/process.rb4
-rw-r--r--lib/chef/win32/api/psapi.rb2
-rw-r--r--lib/chef/win32/api/registry.rb6
-rw-r--r--lib/chef/win32/api/security.rb130
-rw-r--r--lib/chef/win32/api/synchronization.rb10
-rw-r--r--lib/chef/win32/api/system.rb14
-rw-r--r--lib/chef/win32/api/unicode.rb6
-rw-r--r--lib/chef/win32/eventlog.rb4
-rw-r--r--lib/chef/win32/file.rb5
-rw-r--r--lib/chef/win32/file/info.rb1
-rw-r--r--lib/chef/win32/file/version_info.rb29
-rw-r--r--lib/chef/win32/memory.rb2
-rw-r--r--lib/chef/win32/net.rb12
-rw-r--r--lib/chef/win32/registry.rb7
-rw-r--r--lib/chef/win32/security.rb5
-rw-r--r--lib/chef/win32/security/acl.rb3
-rw-r--r--lib/chef/win32/security/security_descriptor.rb6
-rw-r--r--lib/chef/win32/security/sid.rb21
-rw-r--r--lib/chef/win32/security/token.rb4
-rw-r--r--lib/chef/win32/version.rb6
26 files changed, 222 insertions, 197 deletions
diff --git a/lib/chef/win32/api/crypto.rb b/lib/chef/win32/api/crypto.rb
index 1b73ac65d1..13828dd62a 100644
--- a/lib/chef/win32/api/crypto.rb
+++ b/lib/chef/win32/api/crypto.rb
@@ -47,15 +47,15 @@ class Chef
end
- safe_attach_function :CryptProtectData, [
- :PDATA_BLOB,
- :LPCWSTR,
- :PDATA_BLOB,
- :pointer,
- :PCRYPTPROTECT_PROMPTSTRUCT,
- :DWORD,
- :PDATA_BLOB,
- ], :BOOL
+ safe_attach_function :CryptProtectData, %i{
+ PDATA_BLOB
+ LPCWSTR
+ PDATA_BLOB
+ pointer
+ PCRYPTPROTECT_PROMPTSTRUCT
+ DWORD
+ PDATA_BLOB
+ }, :BOOL
end
end
diff --git a/lib/chef/win32/api/error.rb b/lib/chef/win32/api/error.rb
index 618ce266f6..79b65c8509 100644
--- a/lib/chef/win32/api/error.rb
+++ b/lib/chef/win32/api/error.rb
@@ -905,8 +905,8 @@ DWORD WINAPI FormatMessage(
__in_opt va_list *Arguments
);
=end
- safe_attach_function :FormatMessageA, [:DWORD, :HANDLE, :DWORD, :DWORD, :LPTSTR, :DWORD, :varargs], :DWORD
- safe_attach_function :FormatMessageW, [:DWORD, :HANDLE, :DWORD, :DWORD, :LPWSTR, :DWORD, :varargs], :DWORD
+ safe_attach_function :FormatMessageA, %i{DWORD HANDLE DWORD DWORD LPTSTR DWORD varargs}, :DWORD
+ safe_attach_function :FormatMessageW, %i{DWORD HANDLE DWORD DWORD LPWSTR DWORD varargs}, :DWORD
=begin
DWORD WINAPI GetLastError(void);
@@ -918,7 +918,7 @@ void WINAPI SetLastError(
);
=end
safe_attach_function :SetLastError, [:DWORD], :void
- safe_attach_function :SetLastErrorEx, [:DWORD, :DWORD], :void
+ safe_attach_function :SetLastErrorEx, %i{DWORD DWORD}, :void
=begin
UINT WINAPI GetErrorMode(void);s
=end
@@ -938,7 +938,7 @@ HMODULE WINAPI LoadLibraryEx(
_In_ DWORD dwFlags
);
=end
- safe_attach_function :LoadLibraryExW, [:LPCTSTR, :HANDLE, :DWORD], :HANDLE
+ safe_attach_function :LoadLibraryExW, %i{LPCTSTR HANDLE DWORD}, :HANDLE
=begin
https://msdn.microsoft.com/en-us/library/windows/desktop/ms683152(v=vs.85).aspx
diff --git a/lib/chef/win32/api/file.rb b/lib/chef/win32/api/file.rb
index eea46ce87d..bdc2d6f6e5 100644
--- a/lib/chef/win32/api/file.rb
+++ b/lib/chef/win32/api/file.rb
@@ -369,7 +369,7 @@ HANDLE WINAPI CreateFile(
__in_opt HANDLE hTemplateFile
);
=end
- safe_attach_function :CreateFileW, [:LPCTSTR, :DWORD, :DWORD, :LPSECURITY_ATTRIBUTES, :DWORD, :DWORD, :pointer], :HANDLE
+ safe_attach_function :CreateFileW, %i{LPCTSTR DWORD DWORD LPSECURITY_ATTRIBUTES DWORD DWORD pointer}, :HANDLE
=begin
BOOL WINAPI FindClose(
@@ -393,7 +393,7 @@ DWORD WINAPI GetFinalPathNameByHandle(
__in DWORD dwFlags
);
=end
- safe_attach_function :GetFinalPathNameByHandleW, [:HANDLE, :LPTSTR, :DWORD, :DWORD], :DWORD
+ safe_attach_function :GetFinalPathNameByHandleW, %i{HANDLE LPTSTR DWORD DWORD}, :DWORD
=begin
BOOL WINAPI GetFileInformationByHandle(
@@ -401,7 +401,7 @@ BOOL WINAPI GetFileInformationByHandle(
__out LPBY_HANDLE_FILE_INFORMATION lpFileInformation
);
=end
- safe_attach_function :GetFileInformationByHandle, [:HANDLE, :LPBY_HANDLE_FILE_INFORMATION], :BOOL
+ safe_attach_function :GetFileInformationByHandle, %i{HANDLE LPBY_HANDLE_FILE_INFORMATION}, :BOOL
=begin
HANDLE WINAPI FindFirstFile(
@@ -409,7 +409,7 @@ HANDLE WINAPI FindFirstFile(
__out LPWIN32_FIND_DATA lpFindFileData
);
=end
- safe_attach_function :FindFirstFileW, [:LPCTSTR, :LPWIN32_FIND_DATA], :HANDLE
+ safe_attach_function :FindFirstFileW, %i{LPCTSTR LPWIN32_FIND_DATA}, :HANDLE
=begin
BOOL WINAPI CreateHardLink(
@@ -418,7 +418,7 @@ BOOL WINAPI CreateHardLink(
__reserved LPSECURITY_ATTRIBUTES lpSecurityAttributes
);
=end
- safe_attach_function :CreateHardLinkW, [:LPCTSTR, :LPCTSTR, :LPSECURITY_ATTRIBUTES], :BOOLEAN
+ safe_attach_function :CreateHardLinkW, %i{LPCTSTR LPCTSTR LPSECURITY_ATTRIBUTES}, :BOOLEAN
=begin
BOOLEAN WINAPI CreateSymbolicLink(
@@ -427,7 +427,7 @@ BOOLEAN WINAPI CreateSymbolicLink(
__in DWORD dwFlags
);
=end
- safe_attach_function :CreateSymbolicLinkW, [:LPTSTR, :LPTSTR, :DWORD], :BOOLEAN
+ safe_attach_function :CreateSymbolicLinkW, %i{LPTSTR LPTSTR DWORD}, :BOOLEAN
=begin
DWORD WINAPI GetLongPathName(
@@ -436,7 +436,7 @@ DWORD WINAPI GetLongPathName(
__in DWORD cchBuffer
);
=end
- safe_attach_function :GetLongPathNameW, [:LPCTSTR, :LPTSTR, :DWORD], :DWORD
+ safe_attach_function :GetLongPathNameW, %i{LPCTSTR LPTSTR DWORD}, :DWORD
=begin
DWORD WINAPI GetShortPathName(
@@ -445,7 +445,7 @@ DWORD WINAPI GetShortPathName(
__in DWORD cchBuffer
);
=end
- safe_attach_function :GetShortPathNameW, [:LPCTSTR, :LPTSTR, :DWORD], :DWORD
+ safe_attach_function :GetShortPathNameW, %i{LPCTSTR LPTSTR DWORD}, :DWORD
=begin
BOOL WINAPI DeviceIoControl(
@@ -459,7 +459,7 @@ BOOL WINAPI DeviceIoControl(
__inout_opt LPOVERLAPPED lpOverlapped
);
=end
- safe_attach_function :DeviceIoControl, [:HANDLE, :DWORD, :LPVOID, :DWORD, :LPVOID, :DWORD, :LPDWORD, :pointer], :BOOL
+ safe_attach_function :DeviceIoControl, %i{HANDLE DWORD LPVOID DWORD LPVOID DWORD LPDWORD pointer}, :BOOL
# BOOL WINAPI DeleteVolumeMountPoint(
# _In_ LPCTSTR lpszVolumeMountPoint
@@ -470,14 +470,14 @@ BOOL WINAPI DeviceIoControl(
# _In_ LPCTSTR lpszVolumeMountPoint,
# _In_ LPCTSTR lpszVolumeName
# );
- safe_attach_function :SetVolumeMountPointW, [:LPCTSTR, :LPCTSTR], :BOOL
+ safe_attach_function :SetVolumeMountPointW, %i{LPCTSTR LPCTSTR}, :BOOL
# BOOL WINAPI GetVolumeNameForVolumeMountPoint(
# _In_ LPCTSTR lpszVolumeMountPoint,
# _Out_ LPTSTR lpszVolumeName,
# _In_ DWORD cchBufferLength
# );
- safe_attach_function :GetVolumeNameForVolumeMountPointW, [:LPCTSTR, :LPTSTR, :DWORD], :BOOL
+ safe_attach_function :GetVolumeNameForVolumeMountPointW, %i{LPCTSTR LPTSTR DWORD}, :BOOL
=begin
BOOL WINAPI GetFileVersionInfo(
@@ -487,7 +487,7 @@ BOOL WINAPI GetFileVersionInfo(
_Out_ LPVOID lpData
);
=end
- safe_attach_function :GetFileVersionInfoW, [:LPCTSTR, :DWORD, :DWORD, :LPVOID], :BOOL
+ safe_attach_function :GetFileVersionInfoW, %i{LPCTSTR DWORD DWORD LPVOID}, :BOOL
=begin
DWORD WINAPI GetFileVersionInfoSize(
@@ -495,7 +495,7 @@ DWORD WINAPI GetFileVersionInfoSize(
_Out_opt_ LPDWORD lpdwHandle
);
=end
- safe_attach_function :GetFileVersionInfoSizeW, [:LPCTSTR, :LPDWORD], :DWORD
+ safe_attach_function :GetFileVersionInfoSizeW, %i{LPCTSTR LPDWORD}, :DWORD
=begin
BOOL WINAPI VerQueryValue(
@@ -505,7 +505,7 @@ BOOL WINAPI VerQueryValue(
_Out_ PUINT puLen
);
=end
- safe_attach_function :VerQueryValueW, [:LPCVOID, :LPCTSTR, :LPVOID, :PUINT], :BOOL
+ safe_attach_function :VerQueryValueW, %i{LPCVOID LPCTSTR LPVOID PUINT}, :BOOL
###############################################
# Helpers
diff --git a/lib/chef/win32/api/installer.rb b/lib/chef/win32/api/installer.rb
index 118afe8c8f..5af1be7eba 100644
--- a/lib/chef/win32/api/installer.rb
+++ b/lib/chef/win32/api/installer.rb
@@ -44,7 +44,7 @@ UINT MsiOpenPackage(
_Out_ MSIHANDLE *hProduct
);
=end
- safe_attach_function :msi_open_package, :MsiOpenPackageExA, [ :string, :int, :pointer ], :int
+ safe_attach_function :msi_open_package, :MsiOpenPackageExA, %i{string int pointer}, :int
=begin
UINT MsiGetProductProperty(
@@ -54,7 +54,7 @@ UINT MsiGetProductProperty(
_Inout_ DWORD *pcchValueBuf
);
=end
- safe_attach_function :msi_get_product_property, :MsiGetProductPropertyA, [ :pointer, :pointer, :pointer, :pointer ], :int
+ safe_attach_function :msi_get_product_property, :MsiGetProductPropertyA, %i{pointer pointer pointer pointer}, :int
=begin
UINT MsiGetProductInfo(
@@ -64,7 +64,7 @@ UINT MsiGetProductInfo(
_Inout_ DWORD *pcchValueBuf
);
=end
- safe_attach_function :msi_get_product_info, :MsiGetProductInfoA, [ :pointer, :pointer, :pointer, :pointer ], :int
+ safe_attach_function :msi_get_product_info, :MsiGetProductInfoA, %i{pointer pointer pointer pointer}, :int
=begin
UINT MsiCloseHandle(
diff --git a/lib/chef/win32/api/memory.rb b/lib/chef/win32/api/memory.rb
index 369ab5e650..cd7d9f0eb0 100644
--- a/lib/chef/win32/api/memory.rb
+++ b/lib/chef/win32/api/memory.rb
@@ -56,7 +56,7 @@ HLOCAL WINAPI LocalAlloc(
__in SIZE_T uBytes
);
=end
- safe_attach_function :LocalAlloc, [ :UINT, :SIZE_T ], :pointer
+ safe_attach_function :LocalAlloc, %i{UINT SIZE_T}, :pointer
=begin
UINT WINAPI LocalFlags(
@@ -79,7 +79,7 @@ HLOCAL WINAPI LocalReAlloc(
__in UINT uFlags
);
=end
- safe_attach_function :LocalReAlloc, [ :pointer, :SIZE_T, :UINT ], :pointer
+ safe_attach_function :LocalReAlloc, %i{pointer SIZE_T UINT}, :pointer
=begin
UINT WINAPI LocalSize(
@@ -95,9 +95,9 @@ UINT WINAPI LocalSize(
ffi_lib FFI::Library::LIBC
safe_attach_function :malloc, [:size_t], :pointer
safe_attach_function :calloc, [:size_t], :pointer
- safe_attach_function :realloc, [:pointer, :size_t], :pointer
+ safe_attach_function :realloc, %i{pointer size_t}, :pointer
safe_attach_function :free, [:pointer], :void
- safe_attach_function :memcpy, [:pointer, :pointer, :size_t], :pointer
+ safe_attach_function :memcpy, %i{pointer pointer size_t}, :pointer
end
end
diff --git a/lib/chef/win32/api/net.rb b/lib/chef/win32/api/net.rb
index 392a442962..182c31cf66 100644
--- a/lib/chef/win32/api/net.rb
+++ b/lib/chef/win32/api/net.rb
@@ -169,9 +169,9 @@ class Chef
# _In_ LPBYTE buf,
# _Out_ LPDWORD parm_err
# );
- safe_attach_function :NetLocalGroupAdd, [
- :LPCWSTR, :DWORD, :LPBYTE, :LPDWORD
- ], :DWORD
+ safe_attach_function :NetLocalGroupAdd, %i{
+ LPCWSTR DWORD LPBYTE LPDWORD
+ }, :DWORD
# NET_API_STATUS NetLocalGroupSetInfo(
# _In_ LPCWSTR servername,
@@ -180,15 +180,15 @@ class Chef
# _In_ LPBYTE buf,
# _Out_ LPDWORD parm_err
# );
- safe_attach_function :NetLocalGroupSetInfo, [
- :LPCWSTR, :LPCWSTR, :DWORD, :LPBYTE, :LPDWORD
- ], :DWORD
+ safe_attach_function :NetLocalGroupSetInfo, %i{
+ LPCWSTR LPCWSTR DWORD LPBYTE LPDWORD
+ }, :DWORD
# NET_API_STATUS NetLocalGroupDel(
# _In_ LPCWSTR servername,
# _In_ LPCWSTR groupname
# );
- safe_attach_function :NetLocalGroupDel, [:LPCWSTR, :LPCWSTR], :DWORD
+ safe_attach_function :NetLocalGroupDel, %i{LPCWSTR LPCWSTR}, :DWORD
# NET_API_STATUS NetLocalGroupGetMembers(
# _In_ LPCWSTR servername,
@@ -200,10 +200,10 @@ class Chef
# _Out_ LPDWORD totalentries,
# _Inout_ PDWORD_PTR resumehandle
# );
- safe_attach_function :NetLocalGroupGetMembers, [
- :LPCWSTR, :LPCWSTR, :DWORD, :LPBYTE, :DWORD,
- :LPDWORD, :LPDWORD, :PDWORD_PTR
- ], :DWORD
+ safe_attach_function :NetLocalGroupGetMembers, %i{
+ LPCWSTR LPCWSTR DWORD LPBYTE DWORD
+ LPDWORD LPDWORD PDWORD_PTR
+ }, :DWORD
# NET_API_STATUS NetUserEnum(
# _In_ LPCWSTR servername,
@@ -215,10 +215,10 @@ class Chef
# _Out_ LPDWORD totalentries,
# _Inout_ LPDWORD resume_handle
# );
- safe_attach_function :NetUserEnum, [
- :LPCWSTR, :DWORD, :DWORD, :LPBYTE,
- :DWORD, :LPDWORD, :LPDWORD, :LPDWORD
- ], :DWORD
+ safe_attach_function :NetUserEnum, %i{
+ LPCWSTR DWORD DWORD LPBYTE
+ DWORD LPDWORD LPDWORD LPDWORD
+ }, :DWORD
# NET_API_STATUS NetApiBufferFree(
# _In_ LPVOID Buffer
@@ -231,9 +231,9 @@ class Chef
# _In_ LPBYTE buf,
# _Out_ LPDWORD parm_err
# );
- safe_attach_function :NetUserAdd, [
- :LMSTR, :DWORD, :LPBYTE, :LPDWORD
- ], :DWORD
+ safe_attach_function :NetUserAdd, %i{
+ LMSTR DWORD LPBYTE LPDWORD
+ }, :DWORD
# NET_API_STATUS NetLocalGroupAddMembers(
# _In_ LPCWSTR servername,
@@ -242,9 +242,9 @@ class Chef
# _In_ LPBYTE buf,
# _In_ DWORD totalentries
# );
- safe_attach_function :NetLocalGroupAddMembers, [
- :LPCWSTR, :LPCWSTR, :DWORD, :LPBYTE, :DWORD
- ], :DWORD
+ safe_attach_function :NetLocalGroupAddMembers, %i{
+ LPCWSTR LPCWSTR DWORD LPBYTE DWORD
+ }, :DWORD
# NET_API_STATUS NetLocalGroupSetMembers(
# _In_ LPCWSTR servername,
@@ -253,9 +253,9 @@ class Chef
# _In_ LPBYTE buf,
# _In_ DWORD totalentries
# );
- safe_attach_function :NetLocalGroupSetMembers, [
- :LPCWSTR, :LPCWSTR, :DWORD, :LPBYTE, :DWORD
- ], :DWORD
+ safe_attach_function :NetLocalGroupSetMembers, %i{
+ LPCWSTR LPCWSTR DWORD LPBYTE DWORD
+ }, :DWORD
# NET_API_STATUS NetLocalGroupDelMembers(
# _In_ LPCWSTR servername,
@@ -264,9 +264,9 @@ class Chef
# _In_ LPBYTE buf,
# _In_ DWORD totalentries
# );
- safe_attach_function :NetLocalGroupDelMembers, [
- :LPCWSTR, :LPCWSTR, :DWORD, :LPBYTE, :DWORD
- ], :DWORD
+ safe_attach_function :NetLocalGroupDelMembers, %i{
+ LPCWSTR LPCWSTR DWORD LPBYTE DWORD
+ }, :DWORD
# NET_API_STATUS NetUserGetInfo(
# _In_ LPCWSTR servername,
@@ -274,9 +274,9 @@ class Chef
# _In_ DWORD level,
# _Out_ LPBYTE *bufptr
# );
- safe_attach_function :NetUserGetInfo, [
- :LPCWSTR, :LPCWSTR, :DWORD, :LPBYTE
- ], :DWORD
+ safe_attach_function :NetUserGetInfo, %i{
+ LPCWSTR LPCWSTR DWORD LPBYTE
+ }, :DWORD
# NET_API_STATUS NetApiBufferFree(
# _In_ LPVOID Buffer
@@ -290,22 +290,22 @@ class Chef
# _In_ LPBYTE buf,
# _Out_ LPDWORD parm_err
# );
- safe_attach_function :NetUserSetInfo, [
- :LPCWSTR, :LPCWSTR, :DWORD, :LPBYTE, :LPDWORD
- ], :DWORD
+ safe_attach_function :NetUserSetInfo, %i{
+ LPCWSTR LPCWSTR DWORD LPBYTE LPDWORD
+ }, :DWORD
# NET_API_STATUS NetUserDel(
# _In_ LPCWSTR servername,
# _In_ LPCWSTR username
# );
- safe_attach_function :NetUserDel, [:LPCWSTR, :LPCWSTR], :DWORD
+ safe_attach_function :NetUserDel, %i{LPCWSTR LPCWSTR}, :DWORD
# NET_API_STATUS NetUseDel(
# _In_ LMSTR UncServerName,
# _In_ LMSTR UseName,
# _In_ DWORD ForceCond
# );
- safe_attach_function :NetUseDel, [:LMSTR, :LMSTR, :DWORD], :DWORD
+ safe_attach_function :NetUseDel, %i{LMSTR LMSTR DWORD}, :DWORD
# NET_API_STATUS NetUseGetInfo(
# _In_ LMSTR UncServerName,
@@ -313,7 +313,7 @@ class Chef
# _In_ DWORD Level,
# _Out_ LPBYTE *BufPtr
# );
- safe_attach_function :NetUseGetInfo, [:LMSTR, :LMSTR, :DWORD, :pointer], :DWORD
+ safe_attach_function :NetUseGetInfo, %i{LMSTR LMSTR DWORD pointer}, :DWORD
# NET_API_STATUS NetUseAdd(
# _In_ LMSTR UncServerName,
@@ -321,7 +321,7 @@ class Chef
# _In_ LPBYTE Buf,
# _Out_ LPDWORD ParmError
# );
- safe_attach_function :NetUseAdd, [:LMSTR, :DWORD, :LPBYTE, :LPDWORD], :DWORD
+ safe_attach_function :NetUseAdd, %i{LMSTR DWORD LPBYTE LPDWORD}, :DWORD
end
end
end
diff --git a/lib/chef/win32/api/process.rb b/lib/chef/win32/api/process.rb
index 3ac6a5c222..81a411e099 100644
--- a/lib/chef/win32/api/process.rb
+++ b/lib/chef/win32/api/process.rb
@@ -31,10 +31,10 @@ class Chef
ffi_lib "kernel32"
safe_attach_function :GetCurrentProcess, [], :HANDLE
- safe_attach_function :GetProcessHandleCount, [ :HANDLE, :LPDWORD ], :BOOL
+ safe_attach_function :GetProcessHandleCount, %i{HANDLE LPDWORD}, :BOOL
safe_attach_function :GetProcessId, [ :HANDLE ], :DWORD
safe_attach_function :CloseHandle, [ :HANDLE ], :BOOL
- safe_attach_function :IsWow64Process, [ :HANDLE, :PBOOL ], :BOOL
+ safe_attach_function :IsWow64Process, %i{HANDLE PBOOL}, :BOOL
end
end
diff --git a/lib/chef/win32/api/psapi.rb b/lib/chef/win32/api/psapi.rb
index 852cb9710b..491fe22c50 100644
--- a/lib/chef/win32/api/psapi.rb
+++ b/lib/chef/win32/api/psapi.rb
@@ -43,7 +43,7 @@ class Chef
ffi_lib "psapi"
- safe_attach_function :GetProcessMemoryInfo, [ :HANDLE, :pointer, :DWORD ], :BOOL
+ safe_attach_function :GetProcessMemoryInfo, %i{HANDLE pointer DWORD}, :BOOL
end
end
diff --git a/lib/chef/win32/api/registry.rb b/lib/chef/win32/api/registry.rb
index c368add37a..49f0da0010 100644
--- a/lib/chef/win32/api/registry.rb
+++ b/lib/chef/win32/api/registry.rb
@@ -36,14 +36,14 @@ class Chef
# _In_ REGSAM samDesired,
# _Reserved_ DWORD Reserved
# );
- safe_attach_function :RegDeleteKeyExW, [ :HKEY, :LPCTSTR, :LONG, :DWORD ], :LONG
- safe_attach_function :RegDeleteKeyExA, [ :HKEY, :LPCTSTR, :LONG, :DWORD ], :LONG
+ safe_attach_function :RegDeleteKeyExW, %i{HKEY LPCTSTR LONG DWORD}, :LONG
+ safe_attach_function :RegDeleteKeyExA, %i{HKEY LPCTSTR LONG DWORD}, :LONG
# LONG WINAPI RegDeleteValue(
# _In_ HKEY hKey,
# _In_opt_ LPCTSTR lpValueName
# );
- safe_attach_function :RegDeleteValueW, [ :HKEY, :LPCTSTR ], :LONG
+ safe_attach_function :RegDeleteValueW, %i{HKEY LPCTSTR}, :LONG
end
end
diff --git a/lib/chef/win32/api/security.rb b/lib/chef/win32/api/security.rb
index a856fbd0a1..b651283758 100644
--- a/lib/chef/win32/api/security.rb
+++ b/lib/chef/win32/api/security.rb
@@ -216,21 +216,21 @@ class Chef
# Win32 API Bindings
###############################################
- SE_OBJECT_TYPE = enum :SE_OBJECT_TYPE, [
- :SE_UNKNOWN_OBJECT_TYPE,
- :SE_FILE_OBJECT,
- :SE_SERVICE,
- :SE_PRINTER,
- :SE_REGISTRY_KEY,
- :SE_LMSHARE,
- :SE_KERNEL_OBJECT,
- :SE_WINDOW_OBJECT,
- :SE_DS_OBJECT,
- :SE_DS_OBJECT_ALL,
- :SE_PROVIDER_DEFINED_OBJECT,
- :SE_WMIGUID_OBJECT,
- :SE_REGISTRY_WOW64_32KEY,
- ]
+ SE_OBJECT_TYPE = enum :SE_OBJECT_TYPE, %i{
+ SE_UNKNOWN_OBJECT_TYPE
+ SE_FILE_OBJECT
+ SE_SERVICE
+ SE_PRINTER
+ SE_REGISTRY_KEY
+ SE_LMSHARE
+ SE_KERNEL_OBJECT
+ SE_WINDOW_OBJECT
+ SE_DS_OBJECT
+ SE_DS_OBJECT_ALL
+ SE_PROVIDER_DEFINED_OBJECT
+ SE_WMIGUID_OBJECT
+ SE_REGISTRY_WOW64_32KEY
+ }
SID_NAME_USE = enum :SID_NAME_USE, [
:SidTypeUser, 1,
@@ -298,12 +298,12 @@ class Chef
end
# https://msdn.microsoft.com/en-us/library/windows/desktop/aa379572%28v=vs.85%29.aspx
- SECURITY_IMPERSONATION_LEVEL = enum :SECURITY_IMPERSONATION_LEVEL, [
- :SecurityAnonymous,
- :SecurityIdentification,
- :SecurityImpersonation,
- :SecurityDelegation,
- ]
+ SECURITY_IMPERSONATION_LEVEL = enum :SECURITY_IMPERSONATION_LEVEL, %i{
+ SecurityAnonymous
+ SecurityIdentification
+ SecurityImpersonation
+ SecurityDelegation
+ }
# https://msdn.microsoft.com/en-us/library/windows/desktop/bb530718%28v=vs.85%29.aspx?f=255&MSPPError=-2147217396
ELEVATION_TYPE = enum :ELEVATION_TYPE, [
@@ -415,58 +415,58 @@ class Chef
ffi_lib "advapi32"
- safe_attach_function :AccessCheck, [:pointer, :HANDLE, :DWORD, :pointer, :pointer, :pointer, :pointer, :pointer], :BOOL
- safe_attach_function :AddAce, [ :pointer, :DWORD, :DWORD, :LPVOID, :DWORD ], :BOOL
- safe_attach_function :AddAccessAllowedAce, [ :pointer, :DWORD, :DWORD, :pointer ], :BOOL
- safe_attach_function :AddAccessAllowedAceEx, [ :pointer, :DWORD, :DWORD, :DWORD, :pointer ], :BOOL
- safe_attach_function :AddAccessDeniedAce, [ :pointer, :DWORD, :DWORD, :pointer ], :BOOL
- safe_attach_function :AddAccessDeniedAceEx, [ :pointer, :DWORD, :DWORD, :DWORD, :pointer ], :BOOL
- safe_attach_function :AdjustTokenPrivileges, [ :HANDLE, :BOOL, :pointer, :DWORD, :pointer, :PDWORD ], :BOOL
- safe_attach_function :ConvertSidToStringSidA, [ :pointer, :pointer ], :BOOL
- safe_attach_function :ConvertStringSidToSidW, [ :pointer, :pointer ], :BOOL
- safe_attach_function :DeleteAce, [ :pointer, :DWORD ], :BOOL
- safe_attach_function :DuplicateToken, [:HANDLE, :SECURITY_IMPERSONATION_LEVEL, :PHANDLE], :BOOL
- safe_attach_function :EqualSid, [ :pointer, :pointer ], :BOOL
+ safe_attach_function :AccessCheck, %i{pointer HANDLE DWORD pointer pointer pointer pointer pointer}, :BOOL
+ safe_attach_function :AddAce, %i{pointer DWORD DWORD LPVOID DWORD}, :BOOL
+ safe_attach_function :AddAccessAllowedAce, %i{pointer DWORD DWORD pointer}, :BOOL
+ safe_attach_function :AddAccessAllowedAceEx, %i{pointer DWORD DWORD DWORD pointer}, :BOOL
+ safe_attach_function :AddAccessDeniedAce, %i{pointer DWORD DWORD pointer}, :BOOL
+ safe_attach_function :AddAccessDeniedAceEx, %i{pointer DWORD DWORD DWORD pointer}, :BOOL
+ safe_attach_function :AdjustTokenPrivileges, %i{HANDLE BOOL pointer DWORD pointer PDWORD}, :BOOL
+ safe_attach_function :ConvertSidToStringSidA, %i{pointer pointer}, :BOOL
+ safe_attach_function :ConvertStringSidToSidW, %i{pointer pointer}, :BOOL
+ safe_attach_function :DeleteAce, %i{pointer DWORD}, :BOOL
+ safe_attach_function :DuplicateToken, %i{HANDLE SECURITY_IMPERSONATION_LEVEL PHANDLE}, :BOOL
+ safe_attach_function :EqualSid, %i{pointer pointer}, :BOOL
safe_attach_function :FreeSid, [ :pointer ], :pointer
- safe_attach_function :GetAce, [ :pointer, :DWORD, :pointer ], :BOOL
- safe_attach_function :GetFileSecurityW, [:LPCWSTR, :DWORD, :pointer, :DWORD, :pointer], :BOOL
+ safe_attach_function :GetAce, %i{pointer DWORD pointer}, :BOOL
+ safe_attach_function :GetFileSecurityW, %i{LPCWSTR DWORD pointer DWORD pointer}, :BOOL
safe_attach_function :GetLengthSid, [ :pointer ], :DWORD
- safe_attach_function :GetNamedSecurityInfoW, [ :LPWSTR, :SE_OBJECT_TYPE, :DWORD, :pointer, :pointer, :pointer, :pointer, :pointer ], :DWORD
- safe_attach_function :GetSecurityDescriptorControl, [ :pointer, :PWORD, :LPDWORD], :BOOL
- safe_attach_function :GetSecurityDescriptorDacl, [ :pointer, :LPBOOL, :pointer, :LPBOOL ], :BOOL
- safe_attach_function :GetSecurityDescriptorGroup, [ :pointer, :pointer, :LPBOOL], :BOOL
- safe_attach_function :GetSecurityDescriptorOwner, [ :pointer, :pointer, :LPBOOL], :BOOL
- safe_attach_function :GetSecurityDescriptorSacl, [ :pointer, :LPBOOL, :pointer, :LPBOOL ], :BOOL
- safe_attach_function :InitializeAcl, [ :pointer, :DWORD, :DWORD ], :BOOL
- safe_attach_function :InitializeSecurityDescriptor, [ :pointer, :DWORD ], :BOOL
+ safe_attach_function :GetNamedSecurityInfoW, %i{LPWSTR SE_OBJECT_TYPE DWORD pointer pointer pointer pointer pointer}, :DWORD
+ safe_attach_function :GetSecurityDescriptorControl, %i{pointer PWORD LPDWORD}, :BOOL
+ safe_attach_function :GetSecurityDescriptorDacl, %i{pointer LPBOOL pointer LPBOOL}, :BOOL
+ safe_attach_function :GetSecurityDescriptorGroup, %i{pointer pointer LPBOOL}, :BOOL
+ safe_attach_function :GetSecurityDescriptorOwner, %i{pointer pointer LPBOOL}, :BOOL
+ safe_attach_function :GetSecurityDescriptorSacl, %i{pointer LPBOOL pointer LPBOOL}, :BOOL
+ safe_attach_function :InitializeAcl, %i{pointer DWORD DWORD}, :BOOL
+ safe_attach_function :InitializeSecurityDescriptor, %i{pointer DWORD}, :BOOL
safe_attach_function :IsValidAcl, [ :pointer ], :BOOL
safe_attach_function :IsValidSecurityDescriptor, [ :pointer ], :BOOL
safe_attach_function :IsValidSid, [ :pointer ], :BOOL
- safe_attach_function :LookupAccountNameW, [ :LPCWSTR, :LPCWSTR, :pointer, :LPDWORD, :LPWSTR, :LPDWORD, :pointer ], :BOOL
- safe_attach_function :LookupAccountSidW, [ :LPCWSTR, :pointer, :LPWSTR, :LPDWORD, :LPWSTR, :LPDWORD, :pointer ], :BOOL
- safe_attach_function :LookupPrivilegeNameW, [ :LPCWSTR, :PLUID, :LPWSTR, :LPDWORD ], :BOOL
- safe_attach_function :LookupPrivilegeDisplayNameW, [ :LPCWSTR, :LPCWSTR, :LPWSTR, :LPDWORD, :LPDWORD ], :BOOL
- safe_attach_function :LookupPrivilegeValueW, [ :LPCWSTR, :LPCWSTR, :PLUID ], :BOOL
- safe_attach_function :LsaAddAccountRights, [ :pointer, :pointer, :pointer, :ULONG ], :NTSTATUS
- safe_attach_function :LsaRemoveAccountRights, [ :pointer, :pointer, :BOOL, :pointer, :ULONG ], :NTSTATUS
+ safe_attach_function :LookupAccountNameW, %i{LPCWSTR LPCWSTR pointer LPDWORD LPWSTR LPDWORD pointer}, :BOOL
+ safe_attach_function :LookupAccountSidW, %i{LPCWSTR pointer LPWSTR LPDWORD LPWSTR LPDWORD pointer}, :BOOL
+ safe_attach_function :LookupPrivilegeNameW, %i{LPCWSTR PLUID LPWSTR LPDWORD}, :BOOL
+ safe_attach_function :LookupPrivilegeDisplayNameW, %i{LPCWSTR LPCWSTR LPWSTR LPDWORD LPDWORD}, :BOOL
+ safe_attach_function :LookupPrivilegeValueW, %i{LPCWSTR LPCWSTR PLUID}, :BOOL
+ safe_attach_function :LsaAddAccountRights, %i{pointer pointer pointer ULONG}, :NTSTATUS
+ safe_attach_function :LsaRemoveAccountRights, %i{pointer pointer BOOL pointer ULONG}, :NTSTATUS
safe_attach_function :LsaClose, [ :LSA_HANDLE ], :NTSTATUS
- safe_attach_function :LsaEnumerateAccountRights, [ :LSA_HANDLE, :PSID, :PLSA_UNICODE_STRING, :PULONG ], :NTSTATUS
+ safe_attach_function :LsaEnumerateAccountRights, %i{LSA_HANDLE PSID PLSA_UNICODE_STRING PULONG}, :NTSTATUS
safe_attach_function :LsaFreeMemory, [ :PVOID ], :NTSTATUS
safe_attach_function :LsaNtStatusToWinError, [ :NTSTATUS ], :ULONG
- safe_attach_function :LsaOpenPolicy, [ :PLSA_UNICODE_STRING, :PLSA_OBJECT_ATTRIBUTES, :DWORD, :PLSA_HANDLE ], :NTSTATUS
- safe_attach_function :MakeAbsoluteSD, [ :pointer, :pointer, :LPDWORD, :pointer, :LPDWORD, :pointer, :LPDWORD, :pointer, :LPDWORD, :pointer, :LPDWORD], :BOOL
- safe_attach_function :MapGenericMask, [ :PDWORD, :PGENERICMAPPING ], :void
- safe_attach_function :OpenProcessToken, [ :HANDLE, :DWORD, :PHANDLE ], :BOOL
- safe_attach_function :QuerySecurityAccessMask, [ :DWORD, :LPDWORD ], :void
- safe_attach_function :SetFileSecurityW, [ :LPWSTR, :DWORD, :pointer ], :BOOL
- safe_attach_function :SetNamedSecurityInfoW, [ :LPWSTR, :SE_OBJECT_TYPE, :DWORD, :pointer, :pointer, :pointer, :pointer ], :DWORD
- safe_attach_function :SetSecurityAccessMask, [ :DWORD, :LPDWORD ], :void
- safe_attach_function :SetSecurityDescriptorDacl, [ :pointer, :BOOL, :pointer, :BOOL ], :BOOL
- safe_attach_function :SetSecurityDescriptorGroup, [ :pointer, :pointer, :BOOL ], :BOOL
- safe_attach_function :SetSecurityDescriptorOwner, [ :pointer, :pointer, :BOOL ], :BOOL
- safe_attach_function :SetSecurityDescriptorSacl, [ :pointer, :BOOL, :pointer, :BOOL ], :BOOL
- safe_attach_function :GetTokenInformation, [ :HANDLE, :TOKEN_INFORMATION_CLASS, :pointer, :DWORD, :PDWORD ], :BOOL
- safe_attach_function :LogonUserW, [:LPTSTR, :LPTSTR, :LPTSTR, :DWORD, :DWORD, :PHANDLE], :BOOL
+ safe_attach_function :LsaOpenPolicy, %i{PLSA_UNICODE_STRING PLSA_OBJECT_ATTRIBUTES DWORD PLSA_HANDLE}, :NTSTATUS
+ safe_attach_function :MakeAbsoluteSD, %i{pointer pointer LPDWORD pointer LPDWORD pointer LPDWORD pointer LPDWORD pointer LPDWORD}, :BOOL
+ safe_attach_function :MapGenericMask, %i{PDWORD PGENERICMAPPING}, :void
+ safe_attach_function :OpenProcessToken, %i{HANDLE DWORD PHANDLE}, :BOOL
+ safe_attach_function :QuerySecurityAccessMask, %i{DWORD LPDWORD}, :void
+ safe_attach_function :SetFileSecurityW, %i{LPWSTR DWORD pointer}, :BOOL
+ safe_attach_function :SetNamedSecurityInfoW, %i{LPWSTR SE_OBJECT_TYPE DWORD pointer pointer pointer pointer}, :DWORD
+ safe_attach_function :SetSecurityAccessMask, %i{DWORD LPDWORD}, :void
+ safe_attach_function :SetSecurityDescriptorDacl, %i{pointer BOOL pointer BOOL}, :BOOL
+ safe_attach_function :SetSecurityDescriptorGroup, %i{pointer pointer BOOL}, :BOOL
+ safe_attach_function :SetSecurityDescriptorOwner, %i{pointer pointer BOOL}, :BOOL
+ safe_attach_function :SetSecurityDescriptorSacl, %i{pointer BOOL pointer BOOL}, :BOOL
+ safe_attach_function :GetTokenInformation, %i{HANDLE TOKEN_INFORMATION_CLASS pointer DWORD PDWORD}, :BOOL
+ safe_attach_function :LogonUserW, %i{LPTSTR LPTSTR LPTSTR DWORD DWORD PHANDLE}, :BOOL
safe_attach_function :ImpersonateLoggedOnUser, [:HANDLE], :BOOL
safe_attach_function :RevertToSelf, [], :BOOL
diff --git a/lib/chef/win32/api/synchronization.rb b/lib/chef/win32/api/synchronization.rb
index 19ca24bf00..aaedf2dd89 100644
--- a/lib/chef/win32/api/synchronization.rb
+++ b/lib/chef/win32/api/synchronization.rb
@@ -56,8 +56,8 @@ HANDLE WINAPI CreateMutex(
_In_opt_ LPCTSTR lpName
);
=end
- safe_attach_function :CreateMutexW, [ :LPSECURITY_ATTRIBUTES, :BOOL, :LPCTSTR ], :HANDLE
- safe_attach_function :CreateMutexA, [ :LPSECURITY_ATTRIBUTES, :BOOL, :LPCTSTR ], :HANDLE
+ safe_attach_function :CreateMutexW, %i{LPSECURITY_ATTRIBUTES BOOL LPCTSTR}, :HANDLE
+ safe_attach_function :CreateMutexA, %i{LPSECURITY_ATTRIBUTES BOOL LPCTSTR}, :HANDLE
=begin
DWORD WINAPI WaitForSingleObject(
@@ -65,7 +65,7 @@ DWORD WINAPI WaitForSingleObject(
_In_ DWORD dwMilliseconds
);
=end
- safe_attach_function :WaitForSingleObject, [ :HANDLE, :DWORD ], :DWORD
+ safe_attach_function :WaitForSingleObject, %i{HANDLE DWORD}, :DWORD
=begin
BOOL WINAPI ReleaseMutex(
@@ -81,8 +81,8 @@ HANDLE WINAPI OpenMutex(
_In_ LPCTSTR lpName
);
=end
- safe_attach_function :OpenMutexW, [ :DWORD, :BOOL, :LPCTSTR ], :HANDLE
- safe_attach_function :OpenMutexA, [ :DWORD, :BOOL, :LPCTSTR ], :HANDLE
+ safe_attach_function :OpenMutexW, %i{DWORD BOOL LPCTSTR}, :HANDLE
+ safe_attach_function :OpenMutexA, %i{DWORD BOOL LPCTSTR}, :HANDLE
end
end
end
diff --git a/lib/chef/win32/api/system.rb b/lib/chef/win32/api/system.rb
index ebe89f357f..48054c0b4f 100644
--- a/lib/chef/win32/api/system.rb
+++ b/lib/chef/win32/api/system.rb
@@ -177,7 +177,7 @@ BOOL WINAPI GetProductInfo(
__out PDWORD pdwReturnedProductType
);
=end
- safe_attach_function :GetProductInfo, [:DWORD, :DWORD, :DWORD, :DWORD, :PDWORD], :BOOL
+ safe_attach_function :GetProductInfo, %i{DWORD DWORD DWORD DWORD PDWORD}, :BOOL
=begin
int WINAPI GetSystemMetrics(
@@ -192,8 +192,8 @@ UINT WINAPI GetSystemWow64Directory(
_In_ UINT uSize
);
=end
- safe_attach_function :GetSystemWow64DirectoryW, [:LPTSTR, :UINT], :UINT
- safe_attach_function :GetSystemWow64DirectoryA, [:LPTSTR, :UINT], :UINT
+ safe_attach_function :GetSystemWow64DirectoryW, %i{LPTSTR UINT}, :UINT
+ safe_attach_function :GetSystemWow64DirectoryA, %i{LPTSTR UINT}, :UINT
=begin
BOOL WINAPI Wow64DisableWow64FsRedirection(
@@ -220,8 +220,8 @@ LRESULT WINAPI SendMessageTimeout(
_Out_opt_ PDWORD_PTR lpdwResult
);
=end
- safe_attach_function :SendMessageTimeoutW, [:HWND, :UINT, :WPARAM, :LPARAM, :UINT, :UINT, :PDWORD_PTR], :LRESULT
- safe_attach_function :SendMessageTimeoutA, [:HWND, :UINT, :WPARAM, :LPARAM, :UINT, :UINT, :PDWORD_PTR], :LRESULT
+ safe_attach_function :SendMessageTimeoutW, %i{HWND UINT WPARAM LPARAM UINT UINT PDWORD_PTR}, :LRESULT
+ safe_attach_function :SendMessageTimeoutA, %i{HWND UINT WPARAM LPARAM UINT UINT PDWORD_PTR}, :LRESULT
=begin
DWORD WINAPI ExpandEnvironmentStrings(
@@ -230,8 +230,8 @@ DWORD WINAPI ExpandEnvironmentStrings(
_In_ DWORD nSize
);
=end
- safe_attach_function :ExpandEnvironmentStringsW, [:pointer, :pointer, :DWORD], :DWORD
- safe_attach_function :ExpandEnvironmentStringsA, [:pointer, :pointer, :DWORD], :DWORD
+ safe_attach_function :ExpandEnvironmentStringsW, %i{pointer pointer DWORD}, :DWORD
+ safe_attach_function :ExpandEnvironmentStringsA, %i{pointer pointer DWORD}, :DWORD
end
end
end
diff --git a/lib/chef/win32/api/unicode.rb b/lib/chef/win32/api/unicode.rb
index 05c098fc62..70aee58df6 100644
--- a/lib/chef/win32/api/unicode.rb
+++ b/lib/chef/win32/api/unicode.rb
@@ -101,7 +101,7 @@ BOOL IsTextUnicode(
__inout LPINT lpiResult
);
=end
- safe_attach_function :IsTextUnicode, [:pointer, :int, :LPINT], :BOOL
+ safe_attach_function :IsTextUnicode, %i{pointer int LPINT}, :BOOL
=begin
int MultiByteToWideChar(
@@ -113,7 +113,7 @@ int MultiByteToWideChar(
__in int cchWideChar
);
=end
- safe_attach_function :MultiByteToWideChar, [:UINT, :DWORD, :LPCSTR, :int, :LPWSTR, :int], :int
+ safe_attach_function :MultiByteToWideChar, %i{UINT DWORD LPCSTR int LPWSTR int}, :int
=begin
int WideCharToMultiByte(
@@ -127,7 +127,7 @@ int WideCharToMultiByte(
__out LPBOOL lpUsedDefaultChar
);
=end
- safe_attach_function :WideCharToMultiByte, [:UINT, :DWORD, :LPCWSTR, :int, :LPSTR, :int, :LPCSTR, :LPBOOL], :int
+ safe_attach_function :WideCharToMultiByte, %i{UINT DWORD LPCWSTR int LPSTR int LPCSTR LPBOOL}, :int
end
end
diff --git a/lib/chef/win32/eventlog.rb b/lib/chef/win32/eventlog.rb
index e8c63bf13a..ca15acf3d8 100644
--- a/lib/chef/win32/eventlog.rb
+++ b/lib/chef/win32/eventlog.rb
@@ -17,9 +17,9 @@
#
if Chef::Platform.windows?
- if !defined? Chef::Win32EventLogLoaded
+ unless defined? Chef::Win32EventLogLoaded
if defined? Windows::Constants
- [:INFINITE, :WAIT_FAILED, :FORMAT_MESSAGE_IGNORE_INSERTS, :ERROR_INSUFFICIENT_BUFFER].each do |c|
+ %i{INFINITE WAIT_FAILED FORMAT_MESSAGE_IGNORE_INSERTS ERROR_INSUFFICIENT_BUFFER}.each do |c|
# These are redefined in 'win32/eventlog'
Windows::Constants.send(:remove_const, c) if Windows::Constants.const_defined? c
end
diff --git a/lib/chef/win32/file.rb b/lib/chef/win32/file.rb
index 274879a32d..4fac3fe797 100644
--- a/lib/chef/win32/file.rb
+++ b/lib/chef/win32/file.rb
@@ -41,6 +41,7 @@ class Chef
#
def self.link(old_name, new_name)
raise Errno::ENOENT, "(#{old_name}, #{new_name})" unless ::File.exist?(old_name) || ::File.symlink?(old_name)
+
# TODO do a check for CreateHardLinkW and
# raise NotImplemented exception on older Windows
old_name = encode_path(old_name)
@@ -104,6 +105,7 @@ class Chef
#
def self.readlink(link_name)
raise Errno::ENOENT, link_name unless ::File.exists?(link_name) || ::File.symlink?(link_name)
+
symlink_file_handle(link_name) do |handle|
# Go to DeviceIoControl to get the symlink information
# http://msdn.microsoft.com/en-us/library/windows/desktop/aa364571(v=vs.85).aspx
@@ -180,7 +182,8 @@ class Chef
Chef::ReservedNames::Win32::Security::STANDARD_RIGHTS_READ
token = Chef::ReservedNames::Win32::Security.open_process_token(
Chef::ReservedNames::Win32::Process.get_current_process,
- token_rights)
+ token_rights
+ )
duplicate_token = token.duplicate_token(:SecurityImpersonation)
mapping = Chef::ReservedNames::Win32::Security::GENERIC_MAPPING.new
diff --git a/lib/chef/win32/file/info.rb b/lib/chef/win32/file/info.rb
index 9d1b16fbea..234c04cdbb 100644
--- a/lib/chef/win32/file/info.rb
+++ b/lib/chef/win32/file/info.rb
@@ -34,6 +34,7 @@ class Chef
# http://msdn.microsoft.com/en-us/library/windows/desktop/aa363788(v=vs.85).aspx
def initialize(file_name)
raise Errno::ENOENT, file_name unless ::File.exist?(file_name)
+
@file_info = retrieve_file_info(file_name)
end
diff --git a/lib/chef/win32/file/version_info.rb b/lib/chef/win32/file/version_info.rb
index 609d72b96a..f74c98b86d 100644
--- a/lib/chef/win32/file/version_info.rb
+++ b/lib/chef/win32/file/version_info.rb
@@ -28,25 +28,26 @@ class Chef
def initialize(file_name)
raise Errno::ENOENT, file_name unless ::File.exist?(file_name)
+
@file_version_info = retrieve_file_version_info(file_name)
end
# defining method for each predefined version resource string
# see https://msdn.microsoft.com/en-us/library/windows/desktop/ms647464(v=vs.85).aspx
- [
- :Comments,
- :CompanyName,
- :FileDescription,
- :FileVersion,
- :InternalName,
- :LegalCopyright,
- :LegalTrademarks,
- :OriginalFilename,
- :ProductName,
- :ProductVersion,
- :PrivateBuild,
- :SpecialBuild,
- ].each do |method|
+ %i{
+ Comments
+ CompanyName
+ FileDescription
+ FileVersion
+ InternalName
+ LegalCopyright
+ LegalTrademarks
+ OriginalFilename
+ ProductName
+ ProductVersion
+ PrivateBuild
+ SpecialBuild
+ }.each do |method|
define_method method do
begin
get_version_info_string(method.to_s)
diff --git a/lib/chef/win32/memory.rb b/lib/chef/win32/memory.rb
index 853551f183..1ea6375e01 100644
--- a/lib/chef/win32/memory.rb
+++ b/lib/chef/win32/memory.rb
@@ -67,7 +67,7 @@ class Chef
# Free memory allocated using local_alloc
def self.local_free(pointer)
result = LocalFree(pointer)
- if !result.null?
+ unless result.null?
Chef::ReservedNames::Win32::Error.raise!
end
end
diff --git a/lib/chef/win32/net.rb b/lib/chef/win32/net.rb
index b92b723e27..1c08f2fbeb 100644
--- a/lib/chef/win32/net.rb
+++ b/lib/chef/win32/net.rb
@@ -224,7 +224,8 @@ class Chef
buf = FFI::MemoryPointer.new(LOCALGROUP_MEMBERS_INFO_3, members.size)
Array.new(members.size) do |i|
member_info = LOCALGROUP_MEMBERS_INFO_3.new(
- buf + i * LOCALGROUP_MEMBERS_INFO_3.size)
+ buf + i * LOCALGROUP_MEMBERS_INFO_3.size
+ )
member_info[:lgrmi3_domainandname] = FFI::MemoryPointer.from_string(wstring(members[i]))
member_info
end
@@ -236,7 +237,8 @@ class Chef
lgrmi3s = members_to_lgrmi3(members)
rc = NetLocalGroupAddMembers(
- server_name, group_name, 3, lgrmi3s[0], members.size)
+ server_name, group_name, 3, lgrmi3s[0], members.size
+ )
if rc != NERR_Success
Chef::ReservedNames::Win32::Error.raise!(nil, rc)
@@ -249,7 +251,8 @@ class Chef
lgrmi3s = members_to_lgrmi3(members)
rc = NetLocalGroupSetMembers(
- server_name, group_name, 3, lgrmi3s[0], members.size)
+ server_name, group_name, 3, lgrmi3s[0], members.size
+ )
if rc != NERR_Success
Chef::ReservedNames::Win32::Error.raise!(nil, rc)
@@ -262,7 +265,8 @@ class Chef
lgrmi3s = members_to_lgrmi3(members)
rc = NetLocalGroupDelMembers(
- server_name, group_name, 3, lgrmi3s[0], members.size)
+ server_name, group_name, 3, lgrmi3s[0], members.size
+ )
if rc != NERR_Success
Chef::ReservedNames::Win32::Error.raise!(nil, rc)
diff --git a/lib/chef/win32/registry.rb b/lib/chef/win32/registry.rb
index c0efa68464..90bc35143a 100644
--- a/lib/chef/win32/registry.rb
+++ b/lib/chef/win32/registry.rb
@@ -132,6 +132,7 @@ class Chef
if has_subkeys?(key_path) && !recursive
raise Chef::Exceptions::Win32RegNoRecursive, "Registry key #{key_path} has subkeys, and recursive not specified"
end
+
hive, key_including_parent = get_hive_and_key(key_path)
# key_including_parent: Software\\Root\\Branch\\Fruit
# key => Fruit
@@ -161,6 +162,7 @@ class Chef
unless key_exists?(key_path)
raise Chef::Exceptions::Win32RegKeyMissing, "Registry key #{key_path} does not exist"
end
+
true
end
@@ -226,6 +228,7 @@ class Chef
unless value_exists?(key_path, value)
raise Chef::Exceptions::Win32RegValueMissing, "Registry key #{key_path} has no value named #{value[:name]}"
end
+
true
end
@@ -233,6 +236,7 @@ class Chef
unless data_exists?(key_path, value)
raise Chef::Exceptions::Win32RegDataMissing, "Registry key #{key_path} has no value named #{value[:name]}, containing type #{value[:type]} and data #{value[:data]}"
end
+
true
end
@@ -279,6 +283,7 @@ class Chef
if val.is_a? String
return val.downcase
end
+
val
end
@@ -356,7 +361,7 @@ class Chef
hive, key = get_hive_and_key(key_path)
missing_key_arr.each do |intermediate_key|
existing_key_path = existing_key_path << "\\" << intermediate_key
- if !key_exists?(existing_key_path)
+ unless key_exists?(existing_key_path)
Chef::Log.trace("Recursively creating registry key #{existing_key_path}")
hive.create(get_key(existing_key_path), ::Win32::Registry::KEY_ALL_ACCESS | registry_system_architecture)
end
diff --git a/lib/chef/win32/security.rb b/lib/chef/win32/security.rb
index 9a97fd77d2..5b78b652eb 100644
--- a/lib/chef/win32/security.rb
+++ b/lib/chef/win32/security.rb
@@ -200,6 +200,7 @@ class Chef
result = LsaEnumerateAccountRights(policy_handle.read_pointer, sid, privilege_pointer, privilege_length)
win32_error = LsaNtStatusToWinError(result)
return [] if win32_error == 2 # FILE_NOT_FOUND - No rights assigned
+
test_and_raise_lsa_nt_status(result)
privilege_length.read_ulong.times do |i|
@@ -327,6 +328,7 @@ class Chef
elsif FFI::LastError.error != ERROR_INSUFFICIENT_BUFFER
Chef::ReservedNames::Win32::Error.raise!
end
+
owner_result_storage = FFI::MemoryPointer.new owner_result_size.read_ulong
unless GetTokenInformation(token.handle.handle, :TokenOwner, owner_result_storage, owner_result_size.read_ulong, owner_result_size)
Chef::ReservedNames::Win32::Error.raise!
@@ -342,6 +344,7 @@ class Chef
elsif FFI::LastError.error != ERROR_INSUFFICIENT_BUFFER
Chef::ReservedNames::Win32::Error.raise!
end
+
group_result_storage = FFI::MemoryPointer.new group_result_size.read_ulong
unless GetTokenInformation(token.handle.handle, :TokenPrimaryGroup, group_result_storage, group_result_size.read_ulong, group_result_size)
Chef::ReservedNames::Win32::Error.raise!
@@ -357,6 +360,7 @@ class Chef
elsif FFI::LastError.error != ERROR_INSUFFICIENT_BUFFER
Chef::ReservedNames::Win32::Error.raise!
end
+
info_ptr = FFI::MemoryPointer.new(:pointer)
token_info_pointer = TOKEN_ELEVATION_TYPE.new info_ptr
token_info_length = 4
@@ -653,6 +657,7 @@ class Chef
process_token = open_current_process_token(TOKEN_READ)
rescue Exception => run_error
return false if run_error.message =~ /Access is denied/
+
Chef::ReservedNames::Win32::Error.raise!
end
diff --git a/lib/chef/win32/security/acl.rb b/lib/chef/win32/security/acl.rb
index a2700b36ac..ec963fb522 100644
--- a/lib/chef/win32/security/acl.rb
+++ b/lib/chef/win32/security/acl.rb
@@ -45,6 +45,7 @@ class Chef
def ==(other)
return false if length != other.length
+
0.upto(length - 1) do |i|
return false if self[i] != other[i]
end
@@ -88,7 +89,7 @@ class Chef
end
def to_s
- "[#{collect { |ace| ace.to_s }.join(", ")}]"
+ "[#{collect(&:to_s).join(", ")}]"
end
def self.align_dword(size)
diff --git a/lib/chef/win32/security/security_descriptor.rb b/lib/chef/win32/security/security_descriptor.rb
index 83f5c466aa..3d109e60bb 100644
--- a/lib/chef/win32/security/security_descriptor.rb
+++ b/lib/chef/win32/security/security_descriptor.rb
@@ -41,7 +41,8 @@ class Chef
end
def dacl
- raise "DACL not present" if !dacl_present?
+ raise "DACL not present" unless dacl_present?
+
present, acl, defaulted = Chef::ReservedNames::Win32::Security.get_security_descriptor_dacl(self)
acl
end
@@ -65,7 +66,8 @@ class Chef
end
def sacl
- raise "SACL not present" if !sacl_present?
+ raise "SACL not present" unless sacl_present?
+
Security.with_privileges("SeSecurityPrivilege") do
present, acl, defaulted = Chef::ReservedNames::Win32::Security.get_security_descriptor_sacl(self)
acl
diff --git a/lib/chef/win32/security/sid.rb b/lib/chef/win32/security/sid.rb
index 4d34f8b8a7..9643a80c67 100644
--- a/lib/chef/win32/security/sid.rb
+++ b/lib/chef/win32/security/sid.rb
@@ -231,33 +231,33 @@ class Chef
end
def self.None
- SID.from_account("#{::ENV['COMPUTERNAME']}\\None")
+ SID.from_account("#{::ENV["COMPUTERNAME"]}\\None")
end
def self.Administrator
- SID.from_account("#{::ENV['COMPUTERNAME']}\\#{SID.admin_account_name}")
+ SID.from_account("#{::ENV["COMPUTERNAME"]}\\#{SID.admin_account_name}")
end
def self.Guest
- SID.from_account("#{::ENV['COMPUTERNAME']}\\Guest")
+ SID.from_account("#{::ENV["COMPUTERNAME"]}\\Guest")
end
def self.current_user
- SID.from_account("#{::ENV['USERDOMAIN']}\\#{::ENV['USERNAME']}")
+ SID.from_account("#{::ENV["USERDOMAIN"]}\\#{::ENV["USERNAME"]}")
end
SERVICE_ACCOUNT_USERS = [self.LocalSystem,
self.NtLocal,
self.NtNetwork].flat_map do |user_type|
- [user_type.account_simple_name.upcase,
- user_type.account_name.upcase]
- end.freeze
+ [user_type.account_simple_name.upcase,
+ user_type.account_name.upcase]
+ end.freeze
BUILT_IN_GROUPS = [self.BuiltinAdministrators,
self.BuiltinUsers, self.Guests].flat_map do |user_type|
- [user_type.account_simple_name.upcase,
- user_type.account_name.upcase]
- end.freeze
+ [user_type.account_simple_name.upcase,
+ user_type.account_name.upcase]
+ end.freeze
SYSTEM_USER = SERVICE_ACCOUNT_USERS + BUILT_IN_GROUPS
@@ -338,6 +338,7 @@ class Chef
end
raise "Can not determine the administrator account name." if admin_account_name.nil?
+
admin_account_name
end
end
diff --git a/lib/chef/win32/security/token.rb b/lib/chef/win32/security/token.rb
index dfd1e31241..78c79fbb44 100644
--- a/lib/chef/win32/security/token.rb
+++ b/lib/chef/win32/security/token.rb
@@ -35,7 +35,8 @@ class Chef
def enable_privileges(*privilege_names)
# Build the list of privileges we want to set
new_privileges = Chef::ReservedNames::Win32::API::Security::TOKEN_PRIVILEGES.new(
- FFI::MemoryPointer.new(Chef::ReservedNames::Win32::API::Security::TOKEN_PRIVILEGES.size_with_privileges(privilege_names.length)))
+ FFI::MemoryPointer.new(Chef::ReservedNames::Win32::API::Security::TOKEN_PRIVILEGES.size_with_privileges(privilege_names.length))
+ )
new_privileges[:PrivilegeCount] = 0
privilege_names.each do |privilege_name|
luid = Chef::ReservedNames::Win32::API::Security::LUID.new
@@ -64,6 +65,7 @@ class Chef
unless Chef::ReservedNames::Win32::API::Security.DuplicateToken(handle.handle, security_impersonation_level, duplicate_token_handle)
raise Chef::ReservedNames::Win32::Error.raise!
end
+
Token.new(Handle.new(duplicate_token_handle.read_ulong))
end
end
diff --git a/lib/chef/win32/version.rb b/lib/chef/win32/version.rb
index 93e09d3c83..d3ebf46871 100644
--- a/lib/chef/win32/version.rb
+++ b/lib/chef/win32/version.rb
@@ -43,7 +43,7 @@ class Chef
private_class_method :get_system_metrics
def self.method_name_from_marketing_name(marketing_name)
- "#{marketing_name.gsub(/\s/, '_').tr('.', '_').downcase}?"
+ "#{marketing_name.gsub(/\s/, "_").tr(".", "_").downcase}?"
end
private_class_method :method_name_from_marketing_name
@@ -80,7 +80,7 @@ class Chef
@sku = get_product_info(@major_version, @minor_version, @sp_major_version, @sp_minor_version)
end
- marketing_names = Array.new
+ marketing_names = []
# General Windows checks
WIN_VERSIONS.each do |k, v|
@@ -128,7 +128,7 @@ class Chef
# The operating system version is a string in the following form
# that can be split into components based on the '.' delimiter:
# MajorVersionNumber.MinorVersionNumber.BuildNumber
- os_version.split(".").collect { |version_string| version_string.to_i }
+ os_version.split(".").collect(&:to_i)
end
def get_version_ex