ProtectedMemory.Unprotect(Byte[], MemoryProtectionScope) メソッド

定義

Protect(Byte[], MemoryProtectionScope) メソッドを使用して保護されたメモリ内データの保護を解除します。

public:
 static void Unprotect(cli::array <System::Byte> ^ encryptedData, System::Security::Cryptography::MemoryProtectionScope scope);
public static void Unprotect (byte[] encryptedData, System.Security.Cryptography.MemoryProtectionScope scope);
static member Unprotect : byte[] * System.Security.Cryptography.MemoryProtectionScope -> unit
Public Shared Sub Unprotect (encryptedData As Byte(), scope As MemoryProtectionScope)

パラメーター

encryptedData
Byte[]

復号化するメモリ内のバイト配列。

scope
MemoryProtectionScope

メモリ保護のスコープを指定する列挙値の 1 つ。

例外

このメソッドがオペレーティング システムでサポートされていません。 このメソッドは、Windows 2000 以降のオペレーティング システムでのみ使用できます。

encryptedDatanullです。

encryptedData が空です。

- または -

この呼び出しは実装されていません。

- または -

NTSTATUS にエラーが含まれています。

次の例は、データ保護の使用方法を示しています。

#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 暗号化解除するために使用できます。

この方法のサポートは、Windows XP 以降のオペレーティング システムで利用できます。

適用対象