page06ntfileinfo.cpp
来自「This ZIP archive includes the sources (a」· C++ 代码 · 共 1,751 行 · 第 1/5 页
CPP
1,751 行
_stprintf(szBuffer, _T("%p"), *phHandle);
break;
}
case TYPE_FDI_NAME:
{
PFILE_DIRECTORY_INFORMATION FileInfo;
// We have to take the whole structure and get the length
// (the name must not be zero terminated)
FileInfo = (PFILE_DIRECTORY_INFORMATION)
(pMember->pDataPtr - FIELD_OFFSET(FILE_DIRECTORY_INFORMATION, FileName));
// Process the file name as non-null-terminated
// string with variable length
szBuffer = VarStringToItemText(szBuffer,
FileInfo->FileName,
FileInfo->FileNameLength,
nMaxChars,
bFullItem);
break;
}
case TYPE_FFDI_NAME:
{
PFILE_FULL_DIR_INFORMATION FileInfo;
// We have to take the whole structure and get the length
// (the name must not be zero terminated)
FileInfo = (PFILE_FULL_DIR_INFORMATION)
(pMember->pDataPtr - FIELD_OFFSET(FILE_FULL_DIR_INFORMATION, FileName));
// Process the file name as non-null-terminated
// string with variable length
szBuffer = VarStringToItemText(szBuffer,
FileInfo->FileName,
FileInfo->FileNameLength,
nMaxChars,
bFullItem);
break;
}
case TYPE_FBDI_NAME1:
{
PFILE_BOTH_DIR_INFORMATION FileInfo;
// We have to take the whole structure and get the length
// (the name must not be zero terminated)
FileInfo = (PFILE_BOTH_DIR_INFORMATION)
(pMember->pDataPtr - FIELD_OFFSET(FILE_BOTH_DIR_INFORMATION, ShortName));
// Process the file name as non-null-terminated
// string with variable length
szBuffer = VarStringToItemText(szBuffer,
FileInfo->ShortName,
FileInfo->ShortNameLength,
nMaxChars,
bFullItem);
break;
}
case TYPE_FBDI_NAME2:
{
PFILE_BOTH_DIR_INFORMATION FileInfo;
// We have to take the whole structure and get the length
// (the name must not be zero terminated)
FileInfo = (PFILE_BOTH_DIR_INFORMATION)
(pMember->pDataPtr - FIELD_OFFSET(FILE_BOTH_DIR_INFORMATION, FileName));
// Process the file name as non-null-terminated
// string with variable length
szBuffer = VarStringToItemText(szBuffer,
FileInfo->FileName,
FileInfo->FileNameLength,
nMaxChars,
bFullItem);
break;
}
case TYPE_FNI_NAME:
{
PFILE_NAME_INFORMATION FileInfo;
// We have to take the whole structure and get the length
// (the name must not be zero terminated)
FileInfo = (PFILE_NAME_INFORMATION)
(pMember->pDataPtr - FIELD_OFFSET(FILE_NAME_INFORMATION, FileName));
// Process the file name as non-null-terminated string
// with variable length
szBuffer = VarStringToItemText(szBuffer,
FileInfo->FileName,
FileInfo->FileNameLength,
nMaxChars,
bFullItem);
break;
}
case TYPE_FNS_NAME:
{
PFILE_NAMES_INFORMATION FileInfo;
// We have to take the whole structure and get the length
// (the name must not be zero terminated)
FileInfo = (PFILE_NAMES_INFORMATION)
(pMember->pDataPtr - FIELD_OFFSET(FILE_NAMES_INFORMATION, FileName));
// Process the file name as non-null-terminated string
// with variable length
szBuffer = VarStringToItemText(szBuffer,
FileInfo->FileName,
FileInfo->FileNameLength,
nMaxChars,
bFullItem);
break;
}
case TYPE_FFEA_NAME:
{
PFILE_FULL_EA_INFORMATION FileInfo;
// We have to take the whole structure and get the length
// (the name must not be zero terminated)
FileInfo = (PFILE_FULL_EA_INFORMATION)
(pMember->pDataPtr - FIELD_OFFSET(FILE_FULL_EA_INFORMATION, EaName));
// Process the file name as non-null-terminated string
// with variable length
szBuffer = FullEaToItemText(szBuffer,
FileInfo,
nMaxChars,
bFullItem);
break;
}
case TYPE_FSI_NAME:
{
PFILE_STREAM_INFORMATION FileInfo;
// We have to take the whole structure and get the length
// (the name must not be zero terminated)
FileInfo = (PFILE_STREAM_INFORMATION)
(pMember->pDataPtr - FIELD_OFFSET(FILE_STREAM_INFORMATION, StreamName));
// Process the stream name as non-null-terminated string
// with variable length
szBuffer = VarStringToItemText(szBuffer,
FileInfo->StreamName,
FileInfo->StreamNameLength,
nMaxChars,
bFullItem);
break;
}
case TYPE_FIBD_NAME1: // ShortName in FILE_ID_BOTH_DIR_INFORMATION
{
PFILE_ID_BOTH_DIR_INFORMATION FileInfo;
// We have to take the whole structure and get the length
// (the name must not be zero terminated)
FileInfo = (PFILE_ID_BOTH_DIR_INFORMATION)
(pMember->pDataPtr - FIELD_OFFSET(FILE_ID_BOTH_DIR_INFORMATION, ShortName));
// Process the stream name as non-null-terminated string
// with variable length
szBuffer = VarStringToItemText(szBuffer,
FileInfo->ShortName,
FileInfo->ShortNameLength,
nMaxChars,
bFullItem);
break;
}
case TYPE_FIBD_NAME2: // FileName in FILE_ID_BOTH_DIR_INFORMATION
{
PFILE_ID_BOTH_DIR_INFORMATION FileInfo;
// We have to take the whole structure and get the length
// (the name must not be zero terminated)
FileInfo = (PFILE_ID_BOTH_DIR_INFORMATION)
(pMember->pDataPtr - FIELD_OFFSET(FILE_ID_BOTH_DIR_INFORMATION, FileName));
// Process the stream name as non-null-terminated string
// with variable length
szBuffer = VarStringToItemText(szBuffer,
FileInfo->FileName,
FileInfo->FileNameLength,
nMaxChars,
bFullItem);
break;
}
case TYPE_FIFD_NAME: // FileName in FILE_ID_FULL_DIR_INFORMATION
{
PFILE_ID_FULL_DIR_INFORMATION FileInfo;
// We have to take the whole structure and get the length
// (the name must not be zero terminated)
FileInfo = (PFILE_ID_FULL_DIR_INFORMATION)
(pMember->pDataPtr - FIELD_OFFSET(FILE_ID_FULL_DIR_INFORMATION, FileName));
// Process the stream name as non-null-terminated string
// with variable length
szBuffer = VarStringToItemText(szBuffer,
FileInfo->FileName,
FileInfo->FileNameLength,
nMaxChars,
bFullItem);
break;
}
case TYPE_FRI_NAME:
{
PFILE_RENAME_INFORMATION FileInfo;
// We have to take the whole structure and get the length
// (the name must not be zero terminated)
FileInfo = (PFILE_RENAME_INFORMATION)
(pMember->pDataPtr - FIELD_OFFSET(FILE_RENAME_INFORMATION, FileName));
// Process the stream name as non-null-terminated string
// with variable length
szBuffer = VarStringToItemText(szBuffer,
FileInfo->FileName,
FileInfo->FileNameLength,
nMaxChars,
bFullItem);
break;
}
case TYPE_LE_NAME: // FileName in FILE_LINK_ENTRY_INFORMATION
{
PFILE_LINK_ENTRY_INFORMATION FileInfo;
// We have to take the whole structure and get the length
// (the name must not be zero terminated)
FileInfo = (PFILE_LINK_ENTRY_INFORMATION)
(pMember->pDataPtr - FIELD_OFFSET(FILE_LINK_ENTRY_INFORMATION, FileName));
// Process the stream name as non-null-terminated string
// with variable length
szBuffer = VarStringToItemText(szBuffer,
FileInfo->FileName,
sizeof(WCHAR) * FileInfo->FileNameLength,
nMaxChars,
bFullItem);
break;
}
default:
_stprintf(szBuffer, _T("<unsupported>"));
// No break here !!
case TYPE_STRUCT:
break;
}
return ERROR_SUCCESS;
}
static int ItemTextToData(TStructMember * pMember, LPTSTR szItemText)
{
// Now insert the member value
switch(pMember->nDataType)
{
case TYPE_BOOLEAN:
{
PBOOLEAN pbValue = (PBOOLEAN)pMember->pDataPtr;
if(!_tcsicmp(szItemText, _T("TRUE")) || !_tcsicmp(szItemText, _T("1")))
{
*pbValue = TRUE;
return ERROR_SUCCESS;
}
if(!_tcsicmp(szItemText, _T("FALSE")) || !_tcsicmp(szItemText, _T("0")))
{
*pbValue = FALSE;
return ERROR_SUCCESS;
}
break;
}
case TYPE_UINT8:
{
PUCHAR pucValue = (PUCHAR)pMember->pDataPtr;
int nValue = 0;
int nRoot = 10;
// We allow either text or binary value
if(szItemText[0] == _T('0') && toupper(szItemText[1]) == _T('X'))
{
szItemText += 2;
nRoot = 16;
}
// Convert the text value to binary data
nValue = StrToInt(szItemText, &szItemText, nRoot);
if(*szItemText != 0 || nValue > 0xFF)
return ERROR_BAD_FORMAT;
*pucValue = (UCHAR)nValue;
return ERROR_SUCCESS;
}
case TYPE_UINT16:
{
PUSHORT pusValue = (PUSHORT)pMember->pDataPtr;
int nValue = 0;
int nRoot = 10;
// We allow either text or binary value
if(szItemText[0] == _T('0') && toupper(szItemText[1]) == _T('X'))
{
szItemText += 2;
nRoot = 16;
}
// Convert the text value to binary data
nValue = StrToInt(szItemText, &szItemText, nRoot);
if(*szItemText != 0 || nValue > 0xFFFF)
return ERROR_BAD_FORMAT;
*pusValue = (USHORT)nValue;
return ERROR_SUCCESS;
}
case TYPE_UINT32:
{
PULONG pulValue = (PULONG)pMember->pDataPtr;
int nRoot = 10;
// We allow either text or binary value
if(szItemText[0] == _T('0') && toupper(szItemText[1]) == _T('X'))
{
szItemText += 2;
nRoot = 16;
}
*pulValue = (ULONG)StrToInt(szItemText, &szItemText, nRoot);
return (*szItemText == 0) ? ERROR_SUCCESS : ERROR_BAD_FORMAT;
}
case TYPE_UINT64:
{
PLARGE_INTEGER pliValue = (PLARGE_INTEGER)pMember->pDataPtr;
ULONG ulValue;
// There must be two hexa values separated by '-'
ulValue = (ULONG)StrToInt(szItemText, &szItemText, 16);
if(*szItemText == _T('-'))
{
pliValue->HighPart = ulValue;
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?