//.........这里部分代码省略.........
IO_COUNTERS pii;
if (ProcessInformationLength >= sizeof(IO_COUNTERS))
{
if (!ProcessInformation)
ret = STATUS_ACCESS_VIOLATION;
else if (!ProcessHandle)
ret = STATUS_INVALID_HANDLE;
else
{
/* FIXME : real data */
memset(&pii, 0 , sizeof(IO_COUNTERS));
memcpy(ProcessInformation, &pii, sizeof(IO_COUNTERS));
len = sizeof(IO_COUNTERS);
}
if (ProcessInformationLength > sizeof(IO_COUNTERS))
ret = STATUS_INFO_LENGTH_MISMATCH;
}
else
{
len = sizeof(IO_COUNTERS);
ret = STATUS_INFO_LENGTH_MISMATCH;
}
}
break;
case ProcessVmCounters:
{
VM_COUNTERS pvmi;
/* older Windows versions don't have the PrivatePageCount field */
if (ProcessInformationLength >= FIELD_OFFSET(VM_COUNTERS,PrivatePageCount))
{
if (!ProcessInformation)
ret = STATUS_ACCESS_VIOLATION;
else if (!ProcessHandle)
ret = STATUS_INVALID_HANDLE;
else
{
/* FIXME : real data */
memset(&pvmi, 0 , sizeof(VM_COUNTERS));
len = ProcessInformationLength;
if (len != FIELD_OFFSET(VM_COUNTERS,PrivatePageCount)) len = sizeof(VM_COUNTERS);
memcpy(ProcessInformation, &pvmi, min(ProcessInformationLength,sizeof(VM_COUNTERS)));
}
if (ProcessInformationLength != FIELD_OFFSET(VM_COUNTERS,PrivatePageCount) &&
ProcessInformationLength != sizeof(VM_COUNTERS))
ret = STATUS_INFO_LENGTH_MISMATCH;
}
else
{
len = sizeof(pvmi);
ret = STATUS_INFO_LENGTH_MISMATCH;
}
}
break;
case ProcessTimes:
{
KERNEL_USER_TIMES pti;
if (ProcessInformationLength >= sizeof(KERNEL_USER_TIMES))
NTSTATUS
FatQueryFsAttributeInfo (
IN PIRP_CONTEXT IrpContext,
IN PVCB Vcb,
IN PFILE_FS_ATTRIBUTE_INFORMATION Buffer,
IN OUT PULONG Length
)
/*++
Routine Description:
This routine implements the query volume attribute call
Arguments:
Vcb - Supplies the Vcb being queried
Buffer - Supplies a pointer to the output buffer where the information
is to be returned
Length - Supplies the length of the buffer in byte. This variable
upon return recieves the remaining bytes free in the buffer
Return Value:
Status - Returns the status for the query
--*/
{
ULONG BytesToCopy;
NTSTATUS Status;
DebugTrace(0, Dbg, "FatQueryFsAttributeInfo...\n", 0);
//
// Determine how much of the file system name will fit.
//
if ( (*Length - FIELD_OFFSET( FILE_FS_ATTRIBUTE_INFORMATION,
FileSystemName[0] )) >= 6 ) {
BytesToCopy = 6;
*Length -= FIELD_OFFSET( FILE_FS_ATTRIBUTE_INFORMATION,
FileSystemName[0] ) + 6;
Status = STATUS_SUCCESS;
} else {
BytesToCopy = *Length - FIELD_OFFSET( FILE_FS_ATTRIBUTE_INFORMATION,
FileSystemName[0]);
*Length = 0;
Status = STATUS_BUFFER_OVERFLOW;
}
//
// Set the output buffer
//
Buffer->FileSystemAttributes = FILE_CASE_PRESERVED_NAMES |
FILE_UNICODE_ON_DISK;
#ifdef WE_WON_ON_APPEAL
if (FlagOn(Vcb->VcbState, VCB_STATE_FLAG_COMPRESSED_VOLUME)) {
SetFlag( Buffer->FileSystemAttributes, FILE_VOLUME_IS_COMPRESSED );
}
#endif // WE_WON_ON_APPEAL
Buffer->MaximumComponentNameLength = FatData.ChicagoMode ? 255 : 12;
Buffer->FileSystemNameLength = BytesToCopy;
RtlCopyMemory( &Buffer->FileSystemName[0], L"FAT", BytesToCopy );
//
// And return success to our caller
//
UNREFERENCED_PARAMETER( IrpContext );
UNREFERENCED_PARAMETER( Vcb );
return Status;
}
VALUE_SEARCH_RETURN_TYPE
CmpQueryKeyValueData(
PCM_KEY_CONTROL_BLOCK KeyControlBlock,
PPCM_CACHED_VALUE ContainingList,
PCM_KEY_VALUE ValueKey,
BOOLEAN ValueCached,
KEY_VALUE_INFORMATION_CLASS KeyValueInformationClass,
PVOID KeyValueInformation,
ULONG Length,
PULONG ResultLength,
NTSTATUS *status
)
/*++
Routine Description:
Do the actual copy of data for a key value into caller's buffer.
If KeyValueInformation is not long enough to hold all requested data,
STATUS_BUFFER_OVERFLOW will be returned, and ResultLength will be
set to the number of bytes actually required.
Arguments:
Hive - supplies a pointer to the hive control structure for the hive
Cell - supplies index of node to whose sub keys are to be found
KeyValueInformationClass - Specifies the type of information returned in
KeyValueInformation. One of the following types:
KeyValueInformation -Supplies pointer to buffer to receive the data.
Length - Length of KeyInformation in bytes.
ResultLength - Number of bytes actually written into KeyInformation.
Return Value:
NTSTATUS
--*/
{
PKEY_VALUE_INFORMATION pbuffer;
PCELL_DATA pcell;
LONG leftlength;
ULONG requiredlength;
ULONG minimumlength;
ULONG offset;
ULONG base;
ULONG realsize;
PUCHAR datapointer;
BOOLEAN small;
USHORT NameLength;
BOOLEAN BufferAllocated = FALSE;
HCELL_INDEX CellToRelease = HCELL_NIL;
PHHIVE Hive;
VALUE_SEARCH_RETURN_TYPE SearchValue = SearchSuccess;
Hive = KeyControlBlock->KeyHive;
pbuffer = (PKEY_VALUE_INFORMATION)KeyValueInformation;
pcell = (PCELL_DATA) ValueKey;
NameLength = CmpValueNameLen(&pcell->u.KeyValue);
switch (KeyValueInformationClass) {
case KeyValueBasicInformation:
//
// TitleIndex, Type, NameLength, Name
//
requiredlength = FIELD_OFFSET(KEY_VALUE_BASIC_INFORMATION, Name) +
NameLength;
minimumlength = FIELD_OFFSET(KEY_VALUE_BASIC_INFORMATION, Name);
*ResultLength = requiredlength;
*status = STATUS_SUCCESS;
if (Length < minimumlength) {
*status = STATUS_BUFFER_TOO_SMALL;
} else {
pbuffer->KeyValueBasicInformation.TitleIndex = 0;
pbuffer->KeyValueBasicInformation.Type =
pcell->u.KeyValue.Type;
pbuffer->KeyValueBasicInformation.NameLength =
NameLength;
leftlength = Length - minimumlength;
requiredlength = NameLength;
if (leftlength < (LONG)requiredlength) {
requiredlength = leftlength;
//.........这里部分代码省略.........
DWORD
WINAPI
DECLSPEC_HOTPATCH
GetAdaptersAddresses(
_In_ ULONG Family,
_In_ ULONG Flags,
_In_ PVOID Reserved,
_Inout_ PIP_ADAPTER_ADDRESSES pAdapterAddresses,
_Inout_ PULONG pOutBufLen)
{
NTSTATUS Status;
HANDLE TcpFile;
TDIEntityID* InterfacesList;
ULONG InterfacesCount;
ULONG AdaptersCount = 0;
ULONG i;
ULONG TotalSize = 0, RemainingSize;
BYTE* Ptr = (BYTE*)pAdapterAddresses;
DWORD MIN_SIZE = 15 * 1024;
PIP_ADAPTER_ADDRESSES PreviousAA = NULL;
FIXME("GetAdaptersAddresses - Semi Stub: Family %u, Flags 0x%08x, Reserved %p, pAdapterAddress %p, pOutBufLen %p.\n",
Family, Flags, Reserved, pAdapterAddresses, pOutBufLen);
if (!pOutBufLen)
return ERROR_INVALID_PARAMETER;
// FIXME: the exact needed size should be computed first, BEFORE doing any write to the output buffer.
// As suggested by MSDN, require a 15 KB buffer, which allows to React properly to length checks.
if(!Ptr || *pOutBufLen < MIN_SIZE)
{
*pOutBufLen = MIN_SIZE;
return ERROR_BUFFER_OVERFLOW;
}
switch(Family)
{
case AF_INET:
break;
case AF_INET6:
/* One day maybe... */
FIXME("IPv6 is not supported in ReactOS!\n");
/* We got nothing to say in this case */
return ERROR_NO_DATA;
break;
case AF_UNSPEC:
WARN("IPv6 addresses ignored, IPv4 only\n");
Family = AF_INET;
break;
default:
ERR("Invalid family 0x%x\n", Family);
return ERROR_INVALID_PARAMETER;
break;
}
RemainingSize = *pOutBufLen;
if (Ptr)
ZeroMemory(Ptr, RemainingSize);
/* open the tcpip driver */
Status = openTcpFile(&TcpFile, FILE_READ_DATA);
if (!NT_SUCCESS(Status))
{
ERR("Could not open handle to tcpip.sys. Status %08x\n", Status);
return RtlNtStatusToDosError(Status);
}
/* Get the interfaces list */
Status = GetInterfacesList(TcpFile, &InterfacesList, &InterfacesCount);
if (!NT_SUCCESS(Status))
{
ERR("Could not get adapters list. Status %08x\n", Status);
NtClose(TcpFile);
return RtlNtStatusToDosError(Status);
}
/* Let's see if we got any adapter. */
for (i = 0; i < InterfacesCount; i++)
{
PIP_ADAPTER_ADDRESSES CurrentAA = (PIP_ADAPTER_ADDRESSES)Ptr;
ULONG CurrentAASize = 0;
if (InterfacesList[i].tei_entity == IF_ENTITY)
{
BYTE EntryBuffer[FIELD_OFFSET(IFEntry, if_descr) +
RTL_FIELD_SIZE(IFEntry, if_descr[0]) * (MAX_ADAPTER_DESCRIPTION_LENGTH + 1)];
IFEntry* Entry = (IFEntry*)EntryBuffer;
/* Remember we got one */
AdaptersCount++;
/* Set the pointer to this instance in the previous one*/
if(PreviousAA)
PreviousAA->Next = CurrentAA;
/* Of course we need some space for the base structure. */
CurrentAASize = sizeof(IP_ADAPTER_ADDRESSES);
/* Get the entry */
Status = GetInterfaceEntry(TcpFile, InterfacesList[i], Entry);
//.........这里部分代码省略.........
NTSTATUS
FatQueryFsVolumeInfo (
IN PIRP_CONTEXT IrpContext,
IN PVCB Vcb,
IN PFILE_FS_VOLUME_INFORMATION Buffer,
IN OUT PULONG Length
)
/*++
Routine Description:
This routine implements the query volume info call
Arguments:
Vcb - Supplies the Vcb being queried
Buffer - Supplies a pointer to the output buffer where the information
is to be returned
Length - Supplies the length of the buffer in byte. This variable
upon return recieves the remaining bytes free in the buffer
Return Value:
NTSTATUS - Returns the status for the query
--*/
{
ULONG BytesToCopy;
NTSTATUS Status;
DebugTrace(0, Dbg, "FatQueryFsVolumeInfo...\n", 0);
//
// Zero out the buffer, then extract and fill up the non zero fields.
//
RtlZeroMemory( Buffer, sizeof(FILE_FS_VOLUME_INFORMATION) );
Buffer->VolumeSerialNumber = Vcb->Vpb->SerialNumber;
Buffer->SupportsObjects = FALSE;
*Length -= FIELD_OFFSET(FILE_FS_VOLUME_INFORMATION, VolumeLabel[0]);
//
// Check if the buffer we're given is long enough
//
if ( *Length >= (ULONG)Vcb->Vpb->VolumeLabelLength ) {
BytesToCopy = Vcb->Vpb->VolumeLabelLength;
Status = STATUS_SUCCESS;
} else {
BytesToCopy = *Length;
Status = STATUS_BUFFER_OVERFLOW;
}
//
// Copy over what we can of the volume label, and adjust *Length
//
Buffer->VolumeLabelLength = Vcb->Vpb->VolumeLabelLength;
RtlCopyMemory( &Buffer->VolumeLabel[0],
&Vcb->Vpb->VolumeLabel[0],
BytesToCopy );
*Length -= BytesToCopy;
//
// Set our status and return to our caller
//
UNREFERENCED_PARAMETER( IrpContext );
return Status;
}
NTSTATUS
CmpQueryKeyData(
PHHIVE Hive,
PCM_KEY_NODE Node,
KEY_INFORMATION_CLASS KeyInformationClass,
PVOID KeyInformation,
ULONG Length,
PULONG ResultLength
)
/*++
Routine Description:
Do the actual copy of data for a key into caller's buffer.
If KeyInformation is not long enough to hold all requested data,
STATUS_BUFFER_OVERFLOW will be returned, and ResultLength will be
set to the number of bytes actually required.
Arguments:
Hive - supplies a pointer to the hive control structure for the hive
Node - Supplies pointer to node whose subkeys are to be found
KeyInformationClass - Specifies the type of information returned in
Buffer. One of the following types:
KeyBasicInformation - return last write time, title index, and name.
(see KEY_BASIC_INFORMATION structure)
KeyNodeInformation - return last write time, title index, name, class.
(see KEY_NODE_INFORMATION structure)
KeyInformation -Supplies pointer to buffer to receive the data.
Length - Length of KeyInformation in bytes.
ResultLength - Number of bytes actually written into KeyInformation.
Return Value:
NTSTATUS
--*/
{
NTSTATUS status;
PCELL_DATA pclass;
ULONG requiredlength;
LONG leftlength;
ULONG offset;
ULONG minimumlength;
PKEY_INFORMATION pbuffer;
USHORT NameLength;
pbuffer = (PKEY_INFORMATION)KeyInformation;
NameLength = CmpHKeyNameLen(Node);
switch (KeyInformationClass) {
case KeyBasicInformation:
//
// LastWriteTime, TitleIndex, NameLength, Name
//
requiredlength = FIELD_OFFSET(KEY_BASIC_INFORMATION, Name) +
NameLength;
minimumlength = FIELD_OFFSET(KEY_BASIC_INFORMATION, Name);
*ResultLength = requiredlength;
status = STATUS_SUCCESS;
if (Length < minimumlength) {
status = STATUS_BUFFER_TOO_SMALL;
} else {
pbuffer->KeyBasicInformation.LastWriteTime =
Node->LastWriteTime;
pbuffer->KeyBasicInformation.TitleIndex = 0;
pbuffer->KeyBasicInformation.NameLength =
NameLength;
leftlength = Length - minimumlength;
requiredlength = NameLength;
if (leftlength < (LONG)requiredlength) {
requiredlength = leftlength;
status = STATUS_BUFFER_OVERFLOW;
}
if (Node->Flags & KEY_COMP_NAME) {
CmpCopyCompressedName(pbuffer->KeyBasicInformation.Name,
//.........这里部分代码省略.........
请发表评论