MemoryProtectionScope 열거형

정의

Protect(Byte[], MemoryProtectionScope) 메서드에서 적용할 메모리 보호 범위를 지정합니다.

public enum class MemoryProtectionScope
public enum MemoryProtectionScope
type MemoryProtectionScope = 
Public Enum MemoryProtectionScope
상속
MemoryProtectionScope

필드

Name Description
SameProcess 0

메서드를 호출 Protect(Byte[], MemoryProtectionScope) 한 코드와 동일한 프로세스에서 실행되는 코드만 메모리 보호를 해제할 수 있습니다.

CrossProcess 1

모든 프로세스의 모든 코드는 메서드를 사용하여 보호된 메모리를 보호 해제할 Protect(Byte[], MemoryProtectionScope) 수 있습니다.

SameLogon 2

메서드를 호출 Protect(Byte[], MemoryProtectionScope) 한 코드와 동일한 사용자 컨텍스트에서 실행되는 코드만 메모리를 보호 해제할 수 있습니다.

예제

다음 코드 예제에서는 데이터 보호를 사용하는 방법을 보여줍니다.

#using <System.Security.dll>

using namespace System;
using namespace System::Security::Cryptography;

int main()
{
   
   // Create the original data to be encrypted (The data length should be a multiple of 16).
   array<Byte>^secret = {1,2,3,4,1,2,3,4,1,2,3,4,1,2,3,4};
   
   // Encrypt the data in memory. The result is stored in the same array as the original data.
   ProtectedMemory::Protect( secret, MemoryProtectionScope::SameLogon );
   
   // Decrypt the data in memory and store in the original array.
   ProtectedMemory::Unprotect( secret, MemoryProtectionScope::SameLogon );
}
using System;
using System.Security.Cryptography;

public class MemoryProtectionSample
{

    public static void Main()
    {
        // Create the original data to be encrypted (The data length should be a multiple of 16).
        byte [] secret = { 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4 };

        // Encrypt the data in memory. The result is stored in the same array as the original data.
        ProtectedMemory.Protect( secret, MemoryProtectionScope.SameLogon );

        // Decrypt the data in memory and store in the original array.
        ProtectedMemory.Unprotect( secret, MemoryProtectionScope.SameLogon );
    }
}
Imports System.Security.Cryptography

Public Class MemoryProtectionSample

    Public Shared Sub Main()
        ' Create the original data to be encrypted (The data length should be a multiple of 16).
        Dim secret As Byte() = {1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4}

        ' Encrypt the data in memory. The result is stored in the same array as the original data.
        ProtectedMemory.Protect(secret, MemoryProtectionScope.SameLogon)

        ' Decrypt the data in memory and store in the original array.
        ProtectedMemory.Unprotect(secret, MemoryProtectionScope.SameLogon)

    End Sub
End Class

설명

이 열거형은 메모리의 Protect 데이터를 보호하기 위해 메서드와 Unprotect 함께 사용됩니다.

적용 대상