From fcb2ce6d71de33eb9e18af5e208f559c349e40ef Mon Sep 17 00:00:00 2001 From: Andrew Schwartzmeyer Date: Tue, 9 Feb 2016 16:08:45 -0800 Subject: [PATCH] Remove registry stub With latest changes to PowerShell source code, and better behaviors of Get/Set-ExecutionPolicy, the Windows registry API stub can be removed. --- KNOWNISSUES.md | 8 -------- build.sh | 7 ------- src/registry-stub/.gitignore | 1 - src/registry-stub/Makefile | 2 -- src/registry-stub/README.md | 20 ------------------- .../api-ms-win-core-registry-l1-1-0.c | 11 ---------- 6 files changed, 49 deletions(-) delete mode 100644 src/registry-stub/.gitignore delete mode 100644 src/registry-stub/Makefile delete mode 100644 src/registry-stub/README.md delete mode 100644 src/registry-stub/api-ms-win-core-registry-l1-1-0.c diff --git a/KNOWNISSUES.md b/KNOWNISSUES.md index a4b232250f..896b254b54 100644 --- a/KNOWNISSUES.md +++ b/KNOWNISSUES.md @@ -59,14 +59,6 @@ Multiple sessions are not yet supported Server shut-down is not complete (must restart `omiserver` after a session is completed. -## Registry Use - -`SafeHandle` objects attempt to use the registry (even on Linux) so a stub is -in place to prevent error messages. This should be fixed in .NET Core. Use of -the registry is widespread throughout the PowerShell codebase, and so innocuous -things (such as loading particular modules) can cause strange behavior when -unguarded code is executed. - ## Unavailable cmdlets This project includes the CoreCLR versions of the `Commands.Management`, diff --git a/build.sh b/build.sh index 188db720ab..6654565e8e 100755 --- a/build.sh +++ b/build.sh @@ -27,13 +27,6 @@ mkdir -p $BIN/Modules cp src/libpsl-native.* $BIN ) -# Build registry stub (this should go away, again) -( - cd src/registry-stub - make - cp api-ms-win-core-registry-l1-1-0.dll $BIN -) - # Publish PowerShell ( cd src/Microsoft.PowerShell.Linux.Host diff --git a/src/registry-stub/.gitignore b/src/registry-stub/.gitignore deleted file mode 100644 index 580f8c19c1..0000000000 --- a/src/registry-stub/.gitignore +++ /dev/null @@ -1 +0,0 @@ -api-ms-win-core-registry-l1-1-0.dll diff --git a/src/registry-stub/Makefile b/src/registry-stub/Makefile deleted file mode 100644 index 50a1badf07..0000000000 --- a/src/registry-stub/Makefile +++ /dev/null @@ -1,2 +0,0 @@ -api-ms-win-core-registry-l1-1-0.dll: api-ms-win-core-registry-l1-1-0.c - gcc -o $@ -fPIC -shared -Wall $^ diff --git a/src/registry-stub/README.md b/src/registry-stub/README.md deleted file mode 100644 index 57126b7ce0..0000000000 --- a/src/registry-stub/README.md +++ /dev/null @@ -1,20 +0,0 @@ -This stubs the `RegCloseKey` function provided on Windows by -`api-ms-win-core-registry-l1-1-0.dll`. - -Without this DLL in the library path, the following exception is -thrown upon shutdown of PowerShell. While I do not like hiding this -error, it is neccesary for the rest of PowerShell to shutdown -properly, and release its file descriptors. Otherwise the shell will -mess up Bash, and it needs to be reset. - -This must be removed as soon as it can be addressed in a better way. - -``` -Unhandled Exception: System.DllNotFoundException: Unable to load DLL 'api-ms-win-core-registry-l1-1-0.dll': The specified module could not be found. - (Exception from HRESULT: 0x8007007E) - at Interop.mincore.RegCloseKey(IntPtr hKey) - at Microsoft.Win32.SafeHandles.SafeRegistryHandle.ReleaseHandle() - at System.Runtime.InteropServices.SafeHandle.InternalFinalize() - at System.Runtime.InteropServices.SafeHandle.Dispose(Boolean disposing) - at System.Runtime.InteropServices.SafeHandle.Finalize() -``` diff --git a/src/registry-stub/api-ms-win-core-registry-l1-1-0.c b/src/registry-stub/api-ms-win-core-registry-l1-1-0.c deleted file mode 100644 index b37b2c6a18..0000000000 --- a/src/registry-stub/api-ms-win-core-registry-l1-1-0.c +++ /dev/null @@ -1,11 +0,0 @@ -#include - -int32_t RegOpenKeyExW(void* hKey,uint16_t* lpSubKey,uint32_t ulOptions,uint32_t samDesired,void* phkResult) -{ - return 1; -} - -int32_t RegCloseKey(void* handle) -{ - return 0; -}