This topic has not yet been rated - Rate this topic

RtlDecryptMemory function

[The RtlDecryptMemory function is available for use in the operating systems specified in the Requirements section. It may be altered or unavailable in subsequent versions. Instead, use the CryptUnprotectMemory function.]

Applies to: desktop apps only

The RtlDecryptMemory function decrypts memory contents previously encrypted by the RtlEncryptMemory function.

Note  This function has no associated import library. This function is available as a resource named SystemFunction041 in Advapi32.dll. You must use the LoadLibrary and GetProcAddress functions to dynamically link to Advapi32.dll.

Syntax

NTSTATUS RtlDecryptMemory(
  __inout  PVOID Memory,
  __in     ULONG MemoryLength,
  __in     ULONG OptionFlags
);

Parameters

Memory [in, out]

A pointer to the memory to encrypt. The size of the memory must be a multiple of the RTL_ENCRYPT_MEMORY_SIZE constant.

MemoryLength [in]

Number of bytes to which Memory points. The number of bytes must be a multiple of the RTL_ENCRYPT_MEMORY_SIZE constant.

OptionFlags [in]

Value that specifies how the encryption works over process boundaries and impersonation. This parameter can be one of the following values. The values are mutually exclusive. You must specify the same flag when encrypting and decrypting the memory.

ValueMeaning
0

Encrypt and decrypt memory in the same process. An application running in a different process will not be able to decrypt the data.

RTL_ENCRYPT_OPTION_CROSS_PROCESS

Encrypt and decrypt memory in different processes. An application running in a different process will be able to decrypt the data.

RTL_ENCRYPT_OPTION_SAME_LOGON

Use the same logon credentials to encrypt and decrypt memory in different processes. An application running in a different process will be able to decrypt the data. However, the process must run as the same user that encrypted the data and in the same logon session.

 

Return value

If the function is successful, the return value is STATUS_SUCCESS.

If the function fails, the return value is an NTSTATUS code that indicates the error.

Requirements

Minimum supported client

Windows XP, Windows 2000 Professional with SP3

Minimum supported server

Windows Server 2003, Windows 2000 Server with SP3

Header

Ntsecapi.h

DLL

Advapi32.dll

 

 

Send comments about this topic to Microsoft

Build date: 3/6/2012

Did you find this helpful?
(1500 characters remaining)
Community Content Add
Annotations FAQ
C# syntax
[DllImport("advapi32.dll", CharSet=CharSet.Unicode, SetLastError=true)]
internal static extern int SystemFunction041([In, Out] byte[] pDataIn, [In] uint cbDataIn, [In] uint dwFlags);
vb.net syntax
<DllImport("advapi32.dll", CharSet:=CharSet.Unicode, SetLastError:=True)> _
Public Shared Function SystemFunction041(<[In], Out> ByVal pDataIn As Byte(), <[In]> ByVal cbDataIn As UInt32, <[In]> ByVal dwFlags As UInt32) As Integer
End Function