From 5111cf77d02c72a221355d7111a4c06a9ce63680 Mon Sep 17 00:00:00 2001 From: Andrew Schwartzmeyer Date: Wed, 16 Dec 2015 12:59:07 -0800 Subject: [PATCH] Bring back registry stub :( --- src/registry-stub/Makefile | 2 ++ src/registry-stub/README.md | 20 +++++++++++++++++++ .../api-ms-win-core-registry-l1-1-0.c | 6 ++++++ 3 files changed, 28 insertions(+) create mode 100644 src/registry-stub/Makefile create mode 100644 src/registry-stub/README.md create mode 100644 src/registry-stub/api-ms-win-core-registry-l1-1-0.c diff --git a/src/registry-stub/Makefile b/src/registry-stub/Makefile new file mode 100644 index 0000000000..50a1badf07 --- /dev/null +++ b/src/registry-stub/Makefile @@ -0,0 +1,2 @@ +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 new file mode 100644 index 0000000000..57126b7ce0 --- /dev/null +++ b/src/registry-stub/README.md @@ -0,0 +1,20 @@ +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 new file mode 100644 index 0000000000..878a0b01a1 --- /dev/null +++ b/src/registry-stub/api-ms-win-core-registry-l1-1-0.c @@ -0,0 +1,6 @@ +#include + +int32_t RegCloseKey(void* handle) +{ + return 0; +}