summaryrefslogtreecommitdiff
path: root/libraries/base/cbits
diff options
context:
space:
mode:
authorTamar Christina <tamar@zhox.com>2020-05-31 15:54:43 +0100
committerBen Gamari <ben@smart-cactus.org>2020-07-15 16:41:03 -0400
commit3ebd8ad9b1f7f77a928f2ff0d3e61ddfae068dd3 (patch)
tree4afd1a696e6fc82b2ad93a4e8603931e16549649 /libraries/base/cbits
parent256299b13e17044d6904a85043130d13bc592a62 (diff)
downloadhaskell-3ebd8ad9b1f7f77a928f2ff0d3e61ddfae068dd3.tar.gz
winio: Various fixes related to rebase and testdriver
Diffstat (limited to 'libraries/base/cbits')
-rw-r--r--libraries/base/cbits/Win32Utils.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/libraries/base/cbits/Win32Utils.c b/libraries/base/cbits/Win32Utils.c
index 4181e6105f..345e46811b 100644
--- a/libraries/base/cbits/Win32Utils.c
+++ b/libraries/base/cbits/Win32Utils.c
@@ -17,6 +17,8 @@
#include <windows.h>
#include <io.h>
#include <objbase.h>
+#include <ntstatus.h>
+#include <winternl.h>
#include "fs.h"
/* This is the error table that defines the mapping between OS error
@@ -210,6 +212,31 @@ fail:
return false;
}
+
+/* Seems to be part of the Windows SDK so provide an inline definition for
+ use and rename it so it doesn't conflict for people who do have the SDK. */
+
+typedef struct _MY_PUBLIC_OBJECT_BASIC_INFORMATION {
+ ULONG Attributes;
+ ACCESS_MASK GrantedAccess;
+ ULONG HandleCount;
+ ULONG PointerCount;
+ ULONG Reserved[10];
+ } MY_PUBLIC_OBJECT_BASIC_INFORMATION, *PMY_PUBLIC_OBJECT_BASIC_INFORMATION;
+
+ACCESS_MASK __get_handle_access_mask (HANDLE handle)
+{
+ MY_PUBLIC_OBJECT_BASIC_INFORMATION obi;
+ if (STATUS_SUCCESS != NtQueryObject(handle, ObjectBasicInformation, &obi,
+ sizeof(obi), NULL))
+ {
+ return obi.GrantedAccess;
+ }
+
+ maperrno();
+ return 0;
+}
+
bool getTempFileNameErrorNo (wchar_t* pathName, wchar_t* prefix,
wchar_t* suffix, uint32_t uUnique,
wchar_t* tempFileName)