forked from dotnet/corefx
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
741 additions
and
573 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
src/System.IO.MemoryMappedFiles/src/Microsoft/Win32/SafeMemoryMappedFileHandle.Unix.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// Copyright (c) Microsoft. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
||
using System; | ||
using System.Runtime.InteropServices; | ||
using System.Security; | ||
|
||
namespace Microsoft.Win32.SafeHandles | ||
{ | ||
public sealed partial class SafeMemoryMappedFileHandle : SafeHandle | ||
{ | ||
private const int DefaultInvalidHandleValue = -1; // TODO: Implement this | ||
|
||
protected override bool ReleaseHandle() | ||
{ | ||
throw NotImplemented.ByDesign; // TODO: Implement this | ||
} | ||
|
||
public override bool IsInvalid | ||
{ | ||
[SecurityCritical] | ||
get { throw NotImplemented.ByDesign; } // TODO: Implement this | ||
} | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
src/System.IO.MemoryMappedFiles/src/Microsoft/Win32/SafeMemoryMappedFileHandle.Windows.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// Copyright (c) Microsoft. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
||
using System; | ||
using System.Runtime.InteropServices; | ||
using System.Security; | ||
|
||
namespace Microsoft.Win32.SafeHandles | ||
{ | ||
public sealed partial class SafeMemoryMappedFileHandle : SafeHandle | ||
{ | ||
private const int DefaultInvalidHandleValue = 0; | ||
|
||
protected override bool ReleaseHandle() | ||
{ | ||
return Interop.mincore.CloseHandle(handle); | ||
} | ||
|
||
public override bool IsInvalid | ||
{ | ||
[SecurityCritical] | ||
get | ||
{ | ||
return handle == IntPtr.Zero || handle == new IntPtr(-1); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
src/System.IO.MemoryMappedFiles/src/Microsoft/Win32/SafeMemoryMappedViewHandle.Unix.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// Copyright (c) Microsoft. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
||
using System; | ||
using System.Runtime.InteropServices; | ||
|
||
namespace Microsoft.Win32.SafeHandles | ||
{ | ||
public sealed partial class SafeMemoryMappedViewHandle | ||
{ | ||
protected override bool ReleaseHandle() | ||
{ | ||
throw NotImplemented.ByDesign; // TODO: Implement this | ||
} | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
src/System.IO.MemoryMappedFiles/src/Microsoft/Win32/SafeMemoryMappedViewHandle.Windows.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// Copyright (c) Microsoft. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
||
using System; | ||
using System.Runtime.InteropServices; | ||
|
||
namespace Microsoft.Win32.SafeHandles | ||
{ | ||
public sealed partial class SafeMemoryMappedViewHandle | ||
{ | ||
protected override bool ReleaseHandle() | ||
{ | ||
if (Interop.mincore.UnmapViewOfFile(handle) != 0) | ||
{ | ||
handle = IntPtr.Zero; | ||
return true; | ||
} | ||
return false; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
76 changes: 76 additions & 0 deletions
76
src/System.IO.MemoryMappedFiles/src/System/IO/MemoryMappedFiles/MemoryMappedFile.Unix.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
// Copyright (c) Microsoft. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
||
using Microsoft.Win32.SafeHandles; | ||
using System.Security; | ||
|
||
namespace System.IO.MemoryMappedFiles | ||
{ | ||
public partial class MemoryMappedFile | ||
{ | ||
/// <summary> | ||
/// Used by the 2 Create factory method groups. A -1 fileHandle specifies that the | ||
/// memory mapped file should not be associated with an exsiting file on disk (ie start | ||
/// out empty). | ||
/// </summary> | ||
[SecurityCritical] | ||
private static SafeMemoryMappedFileHandle CreateCore( | ||
SafeFileHandle fileHandle, String mapName, HandleInheritability inheritability, | ||
MemoryMappedFileAccess access, MemoryMappedFileOptions options, Int64 capacity) | ||
{ | ||
throw NotImplemented.ByDesign; // TODO: Implement this | ||
} | ||
|
||
/// <summary> | ||
/// Used by the OpenExisting factory method group and by CreateOrOpen if access is write. | ||
/// We'll throw an ArgumentException if the file mapping object didn't exist and the | ||
/// caller used CreateOrOpen since Create isn't valid with Write access | ||
/// </summary> | ||
[SecurityCritical] | ||
private static SafeMemoryMappedFileHandle OpenCore( | ||
String mapName, HandleInheritability inheritability, MemoryMappedFileAccess access, bool createOrOpen) | ||
{ | ||
throw NotImplemented.ByDesign; // TODO: Implement this | ||
} | ||
|
||
/// <summary> | ||
/// Used by the OpenExisting factory method group and by CreateOrOpen if access is write. | ||
/// We'll throw an ArgumentException if the file mapping object didn't exist and the | ||
/// caller used CreateOrOpen since Create isn't valid with Write access | ||
/// </summary> | ||
[SecurityCritical] | ||
private static SafeMemoryMappedFileHandle OpenCore( | ||
String mapName, HandleInheritability inheritability, MemoryMappedFileRights rights, bool createOrOpen) | ||
{ | ||
throw NotImplemented.ByDesign; // TODO: Implement this | ||
} | ||
|
||
/// <summary> | ||
/// Used by the CreateOrOpen factory method groups. A -1 fileHandle specifies that the | ||
/// memory mapped file should not be associated with an existing file on disk (ie start | ||
/// out empty). | ||
/// | ||
/// Try to open the file if it exists -- this requires a bit more work. Loop until we can | ||
/// either create or open a memory mapped file up to a timeout. CreateFileMapping may fail | ||
/// if the file exists and we have non-null security attributes, in which case we need to | ||
/// use OpenFileMapping. But, there exists a race condition because the memory mapped file | ||
/// may have closed inbetween the two calls -- hence the loop. | ||
/// | ||
/// This uses similar retry/timeout logic as in performance counter. It increases the wait | ||
/// time each pass through the loop and times out in approximately 1.4 minutes. If after | ||
/// retrying, a MMF handle still hasn't been opened, throw an InvalidOperationException. | ||
/// </summary> | ||
[SecurityCritical] | ||
private static SafeMemoryMappedFileHandle CreateOrOpenCore( | ||
SafeFileHandle fileHandle, String mapName, HandleInheritability inheritability, | ||
MemoryMappedFileAccess access, MemoryMappedFileOptions options, Int64 capacity) | ||
{ | ||
throw NotImplemented.ByDesign; // TODO: Implement this | ||
} | ||
|
||
// ----------------------------- | ||
// ---- PAL layer ends here ---- | ||
// ----------------------------- | ||
|
||
} | ||
} |
Oops, something went wrong.