use of com.oracle.svm.core.windows.headers.WinBase.HANDLE in project graal by oracle.
the class WindowsImageHeapProvider method createImageHeapFileMapping.
/**
* Returns a handle to the image heap file mapping or the null pointer in case of an error.
*/
@Uninterruptible(reason = "Called during isolate initialization.", mayBeInlined = true)
private static HANDLE createImageHeapFileMapping() {
/* Get the path of the file that contains the image heap. */
WCharPointer filePath = StackValue.get(WinBase.MAX_PATH, WCharPointer.class);
int length = LibLoaderAPI.GetModuleFileNameW((HMODULE) IMAGE_BASE.get(), filePath, WinBase.MAX_PATH);
if (length == 0 || length == WinBase.MAX_PATH) {
return WordFactory.nullPointer();
}
/* Open the file for mapping. */
HANDLE fileHandle = FileAPI.CreateFileW(filePath, FileAPI.GENERIC_READ(), FileAPI.FILE_SHARE_READ() | FileAPI.FILE_SHARE_DELETE(), WordFactory.nullPointer(), FileAPI.OPEN_EXISTING(), 0, WordFactory.nullPointer());
if (fileHandle.equal(WinBase.INVALID_HANDLE_VALUE())) {
return WordFactory.nullPointer();
}
/* Create the mapping and close the file. */
HANDLE fileMapping = MemoryAPI.CreateFileMappingW(fileHandle, WordFactory.nullPointer(), MemoryAPI.PAGE_READONLY(), 0, 0, WordFactory.nullPointer());
WinBase.CloseHandle(fileHandle);
return fileMapping;
}
use of com.oracle.svm.core.windows.headers.WinBase.HANDLE in project graal by oracle.
the class WindowsImageHeapProvider method getImageHeapFileMapping.
@Uninterruptible(reason = "Called during isolate initialization.", mayBeInlined = true)
private static HANDLE getImageHeapFileMapping() {
HANDLE value = IMAGE_HEAP_FILE_MAPPING.get().read();
if (value.equal(WindowsUtils.UNINITIALIZED_HANDLE)) {
HANDLE fileMapping = createImageHeapFileMapping();
HANDLE existingMapping = (HANDLE) ((Pointer) IMAGE_HEAP_FILE_MAPPING.get()).compareAndSwapWord(0, WindowsUtils.UNINITIALIZED_HANDLE, fileMapping, LocationIdentity.ANY_LOCATION);
if (existingMapping.equal(WindowsUtils.UNINITIALIZED_HANDLE)) {
value = fileMapping;
} else {
/* Another thread has already created the mapping, so use that. */
value = existingMapping;
WinBase.CloseHandle(fileMapping);
}
}
return value;
}
use of com.oracle.svm.core.windows.headers.WinBase.HANDLE in project graal by oracle.
the class WindowsProcessPropertiesSupport method destroyForcibly.
@Override
public boolean destroyForcibly(long processID) {
HANDLE handle = Process.NoTransitions.OpenProcess(Process.PROCESS_TERMINATE(), 0, (int) processID);
if (handle.isNull()) {
return false;
}
boolean result = Process.NoTransitions.TerminateProcess(handle, 1) != 0;
WinBase.CloseHandle(handle);
return result;
}
Aggregations