Update airfs.cpp

This commit is contained in:
John Oberschelp 2018-08-01 17:34:24 -07:00 committed by GitHub
parent f672ae817a
commit 773bb12146
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1616,14 +1616,16 @@ NTSTATUS ApiControl(FSP_FILE_SYSTEM *FileSystem,
PVOID InputBuffer, ULONG InputBufferLength, PVOID InputBuffer, ULONG InputBufferLength,
PVOID OutputBuffer, ULONG OutputBufferLength, PULONG PBytesTransferred) PVOID OutputBuffer, ULONG OutputBufferLength, PULONG PBytesTransferred)
{ {
// Trivial example: change upper to lower case and vice versa. // Trivial example: Perform a ROT13 translation on alphas.
if (CTL_CODE(0x8000 + 'A', 'C', METHOD_BUFFERED, FILE_ANY_ACCESS) == ControlCode) if (CTL_CODE(0x8000 + 'M', 'R', METHOD_BUFFERED, FILE_ANY_ACCESS) == ControlCode)
{ {
if (OutputBufferLength != InputBufferLength) return STATUS_INVALID_PARAMETER; if (OutputBufferLength != InputBufferLength) return STATUS_INVALID_PARAMETER;
for (ULONG i = 0; i < InputBufferLength; i++) for (ULONG i = 0; i < InputBufferLength; i++)
{ {
char c = ((char*)InputBuffer)[i]; char c = ((char*)InputBuffer)[i];
if ((c|0x20) >= 'a' && (c|0x20) <= 'z') c ^= 0x20; if (('A' <= c && c <= 'M') || ('a' <= c && c <= 'm')) c += 13;
else
if (('N' <= c && c <= 'Z') || ('n' <= c && c <= 'z')) c -= 13;
((char*)OutputBuffer)[i] = c; ((char*)OutputBuffer)[i] = c;
} }
*PBytesTransferred = InputBufferLength; *PBytesTransferred = InputBufferLength;