MemoryProtectionScope 열거형

정의

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

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

필드

CrossProcess 1

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

SameLogon 2

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

SameProcess 0

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

설명

이 열거형을 사용 하 여 사용 합니다 ProtectUnprotect 메모리에 데이터를 보호 하는 방법입니다.

적용 대상