Esempio n. 1
0
CFileIndex CIndexTreeBlockFile::LoadRootFileIndex(char* szRootFileName)
{
	CFileBasic	cFileBasic;
	CDiskFile	cDiskFile;
	CFileUtil	cFileUtil;
	CFileIndex	cIndex;
	filePos		iSize;

	iSize = cFileUtil.Size(szRootFileName);
	if (iSize != -1)
	{
		if (iSize == sizeof(CFileIndex))
		{
			cDiskFile.Init(szRootFileName);
			cFileBasic.Init(&cDiskFile);

			cFileBasic.Open(EFM_Read);
			cFileBasic.Read(&cIndex, 0, sizeof(CFileIndex));
			cFileBasic.Close();

			cFileBasic.Kill();
			cDiskFile.Kill();

			return cIndex;
		}
		else
		{
			gcLogger.Error2(__METHOD__, "Index Root file size [", LongLongToString(iSize), "] is incorrect.  Should be SizeOf(CFileIndex).", NULL);
			cIndex.Init();
			return cIndex;
		}
	}
	else
	{
		cIndex.Init();
		return cIndex;
	}
}
Esempio n. 2
0
VOID
DumpAfdConnection(
    PAFD_CONNECTION Connection,
    DWORD ActualAddress
)

/*++

Routine Description:

    Dumps the specified AFD_CONNECTION structures.

Arguments:

    Connection - Points to the AFD_CONNECTION structure to dump.

    ActualAddress - The actual address where the structure resides on the
        debugee.

Return Value:

    None.

--*/

{

    UCHAR address[MAX_TRANSPORT_ADDR];
    ULONG result;

    dprintf(
        "AFD_CONNECTION @ %08lx:\n",
        ActualAddress
    );

    dprintf(
        "    Type                         = %04X (%s)\n",
        Connection->Type,
        StructureTypeToString( Connection->Type )
    );

    dprintf(
        "    ReferenceCount               = %d\n",
        Connection->ReferenceCount
    );

    dprintf(
        "    State                        = %08X (%s)\n",
        Connection->State,
        ConnectionStateToString( Connection->State )
    );

    dprintf(
        "    Handle                       = %08lx\n",
        Connection->Handle
    );

    dprintf(
        "    FileObject                   = %08lx\n",
        Connection->FileObject
    );

    dprintf(
        "    ConnectTime                  = %s\n",
        SystemTimeToString( Connection->ConnectTime )
    );

    if( Connection->TdiBufferring )
    {
        dprintf(
            "    ReceiveBytesIndicated        = %s\n",
            LongLongToString( Connection->Common.Bufferring.ReceiveBytesIndicated.QuadPart )
        );

        dprintf(
            "    ReceiveBytesTaken            = %s\n",
            LongLongToString( Connection->Common.Bufferring.ReceiveBytesTaken.QuadPart )
        );

        dprintf(
            "    ReceiveBytesOutstanding      = %s\n",
            LongLongToString( Connection->Common.Bufferring.ReceiveBytesOutstanding.QuadPart )
        );

        dprintf(
            "    ReceiveExpeditedBytesIndicated   = %s\n",
            LongLongToString( Connection->Common.Bufferring.ReceiveExpeditedBytesIndicated.QuadPart )
        );

        dprintf(
            "    ReceiveExpeditedBytesTaken       = %s\n",
            LongLongToString( Connection->Common.Bufferring.ReceiveExpeditedBytesTaken.QuadPart )
        );

        dprintf(
            "    ReceiveExpeditedBytesOutstanding = %s\n",
            LongLongToString( Connection->Common.Bufferring.ReceiveExpeditedBytesOutstanding.QuadPart )
        );

        dprintf(
            "    NonBlockingSendPossible      = %s\n",
            BooleanToString( Connection->Common.Bufferring.NonBlockingSendPossible )
        );

        dprintf(
            "    ZeroByteReceiveIndicated     = %s\n",
            BooleanToString( Connection->Common.Bufferring.ZeroByteReceiveIndicated )
        );
    }
    else
    {
        if( IS_LIST_EMPTY(
                    ActualAddress,
                    Connection,
                    Common.NonBufferring.ReceiveIrpListHead ) ) {

            dprintf(
                "    ReceiveIrpListHead           = EMPTY\n"
            );

        } else {

            dprintf(
                "    ReceiveIrpListHead           @ %08lx\n",
                ACTUAL_ADDRESS(
                    ActualAddress,
                    Connection,
                    Common.NonBufferring.ReceiveIrpListHead
                )
            );

        }

        if( IS_LIST_EMPTY(
                    ActualAddress,
                    Connection,
                    Common.NonBufferring.ReceiveBufferListHead ) ) {

            dprintf(
                "    ReceiveBufferListHead        = EMPTY\n"
            );

        } else {

            dprintf(
                "    ReceiveBufferListHead        @ %08lx\n",
                ACTUAL_ADDRESS(
                    ActualAddress,
                    Connection,
                    Common.NonBufferring.ReceiveBufferListHead
                )
            );

        }

        if( IS_LIST_EMPTY(
                    ActualAddress,
                    Connection,
                    Common.NonBufferring.SendIrpListHead ) ) {

            dprintf(
                "    SendIrpListHead              = EMPTY\n"
            );

        } else {

            dprintf(
                "    SendIrpListHead              @ %08lx\n",
                ACTUAL_ADDRESS(
                    ActualAddress,
                    Connection,
                    Common.NonBufferring.SendIrpListHead
                )
            );

        }

        dprintf(
            "    BufferredReceiveBytes        = %lu\n",
            Connection->Common.NonBufferring.BufferredReceiveBytes
        );

        dprintf(
            "    BufferredExpeditedBytes      = %lu\n",
            Connection->Common.NonBufferring.BufferredExpeditedBytes
        );

        dprintf(
            "    BufferredReceiveCount        = %u\n",
            Connection->Common.NonBufferring.BufferredReceiveCount
        );

        dprintf(
            "    BufferredExpeditedCount      = %u\n",
            Connection->Common.NonBufferring.BufferredExpeditedCount
        );

        dprintf(
            "    ReceiveBytesInTransport      = %lu\n",
            Connection->Common.NonBufferring.ReceiveBytesInTransport
        );

        dprintf(
            "    BufferredSendBytes           = %lu\n",
            Connection->Common.NonBufferring.BufferredSendBytes
        );

        dprintf(
            "    ReceiveCountInTransport      = %u\n",
            Connection->Common.NonBufferring.ReceiveCountInTransport
        );

        dprintf(
            "    BufferredSendCount           = %u\n",
            Connection->Common.NonBufferring.BufferredSendCount
        );

        dprintf(
            "    DisconnectIrp                = %08lx\n",
            Connection->Common.NonBufferring.DisconnectIrp
        );
    }

    dprintf(
        "    Endpoint                     = %08lx\n",
        Connection->Endpoint
    );

    dprintf(
        "    MaxBufferredReceiveBytes     = %lu\n",
        Connection->MaxBufferredReceiveBytes
    );

    dprintf(
        "    MaxBufferredSendBytes        = %lu\n",
        Connection->MaxBufferredSendBytes
    );

    dprintf(
        "    MaxBufferredReceiveCount     = %u\n",
        Connection->MaxBufferredReceiveCount
    );

    dprintf(
        "    MaxBufferredSendCount        = %u\n",
        Connection->MaxBufferredSendCount
    );

    dprintf(
        "    ConnectDataBuffers           = %08lx\n",
        Connection->ConnectDataBuffers
    );

    dprintf(
        "    OwningProcess                = %08lx\n",
        Connection->OwningProcess
    );

    dprintf(
        "    DeviceObject                 = %08lx\n",
        Connection->DeviceObject
    );

    dprintf(
        "    RemoteAddress                = %08lx\n",
        Connection->RemoteAddress
    );

    dprintf(
        "    RemoteAddressLength          = %lu\n",
        Connection->RemoteAddressLength
    );

    if( Connection->RemoteAddressLength <= sizeof(address) &&
            Connection->RemoteAddress != NULL ) {

        if( ReadMemory(
                    (DWORD)Connection->RemoteAddress,
                    address,
                    sizeof(address),
                    &result
                ) ) {

            DumpTransportAddress(
                "    ",
                (PTRANSPORT_ADDRESS)address,
                (DWORD)Connection->RemoteAddress
            );

        }

    }

    dprintf(
        "    DisconnectIndicated          = %s\n",
        BooleanToString( Connection->DisconnectIndicated )
    );

    dprintf(
        "    AbortIndicated               = %s\n",
        BooleanToString( Connection->AbortIndicated )
    );

    dprintf(
        "    TdiBufferring                = %s\n",
        BooleanToString( Connection->TdiBufferring )
    );

    dprintf(
        "    ConnectedReferenceAdded      = %s\n",
        BooleanToString( Connection->ConnectedReferenceAdded )
    );

    dprintf(
        "    SpecialCondition             = %s\n",
        BooleanToString( Connection->SpecialCondition )
    );

    dprintf(
        "    CleanupBegun                 = %s\n",
        BooleanToString( Connection->CleanupBegun )
    );

    dprintf(
        "    ClosePendedTransmit          = %s\n",
        BooleanToString( Connection->ClosePendedTransmit )
    );

    if( IsCheckedAfd ) {

        dprintf(
            "    CurrentReferenceSlot         = %lu\n",
            Connection->CurrentReferenceSlot % MAX_REFERENCE
        );

        dprintf(
            "    ReferenceDebug               = %08lx\n",
            ACTUAL_ADDRESS(
                ActualAddress,
                Connection,
                ReferenceDebug
            )
        );

    }

    dprintf( "\n" );

}   // DumpAfdConnection
Esempio n. 3
0
VOID
DumpAfdTransmitInfo(
    PAFD_TRANSMIT_FILE_INFO_INTERNAL TransmitInfo,
    DWORD ActualAddress
)
{

    dprintf(
        "AFD_TRANSMIT_FILE_INFO_INTERNAL @ %08lx\n",
        ActualAddress
    );

    dprintf(
        "    Offset                 = %s\n",
        LongLongToString( TransmitInfo->Offset )
    );

    dprintf(
        "    FileWriteLength        = %s\n",
        LongLongToString( TransmitInfo->FileWriteLength )
    );

    dprintf(
        "    SendPacketLength       = %08lx\n",
        TransmitInfo->SendPacketLength
    );

    dprintf(
        "    FileHandle             = %08lx\n",
        TransmitInfo->FileHandle
    );

    dprintf(
        "    Head                   = %08lx\n",
        TransmitInfo->Head
    );

    dprintf(
        "    HeadLength             = %08lx\n",
        TransmitInfo->HeadLength
    );

    dprintf(
        "    Tail                   = %08lx\n",
        TransmitInfo->Tail
    );

    dprintf(
        "    TailLength             = %08lx\n",
        TransmitInfo->TailLength
    );

    dprintf(
        "    Flags                  = %08lx\n",
        TransmitInfo->Flags
    );

    dprintf(
        "    _Dummy                 = %08lx\n",
        TransmitInfo->_Dummy
    );

    dprintf(
        "    TotalBytesToSend       = %s\n",
        LongLongToString( TransmitInfo->TotalBytesToSend )
    );

    dprintf(
        "    BytesRead              = %s\n",
        LongLongToString( TransmitInfo->BytesRead )
    );

    dprintf(
        "    BytesSent              = %s\n",
        LongLongToString( TransmitInfo->BytesSent )
    );

    dprintf(
        "    FileObject             = %08lx\n",
        TransmitInfo->FileObject
    );

    dprintf(
        "    DeviceObject           = %08lx\n",
        TransmitInfo->DeviceObject
    );

    dprintf(
        "    TdiFileObject          = %08lx\n",
        TransmitInfo->TdiFileObject
    );

    dprintf(
        "    TdiDeviceObject        = %08lx\n",
        TransmitInfo->TdiDeviceObject
    );

    dprintf(
        "    TransmitIrp            = %08lx\n",
        TransmitInfo->TransmitIrp
    );

    dprintf(
        "    Endpoint               = %08lx\n",
        TransmitInfo->Endpoint
    );

    dprintf(
        "    FileMdl                = %08lx\n",
        TransmitInfo->FileMdl
    );

    dprintf(
        "    HeadMdl                = %08lx\n",
        TransmitInfo->HeadMdl
    );

    dprintf(
        "    TailMdl                = %08lx\n",
        TransmitInfo->TailMdl
    );

    dprintf(
        "    FirstFileMdlAfterHead  = %08lx\n",
        TransmitInfo->FirstFileMdlAfterHead
    );

    dprintf(
        "    LastFileMdlBeforeTail  = %08lx\n",
        TransmitInfo->LastFileMdlBeforeTail
    );

    dprintf(
        "    IrpUsedTOSendTail      = %08lx\n",
        TransmitInfo->IrpUsedToSendTail
    );

    dprintf(
        "    FileMdlLength          = %08lx\n",
        TransmitInfo->FileMdlLength
    );

    dprintf(
        "    ReadPending            = %s\n",
        BooleanToString( TransmitInfo->ReadPending )
    );

    dprintf(
        "    CompletionPending      = %s\n",
        BooleanToString( TransmitInfo->CompletionPending )
    );

    dprintf(
        "    NeedToSendHead         = %s\n",
        BooleanToString( TransmitInfo->NeedToSendHead )
    );

    dprintf(
        "    Queued                 = %s\n",
        BooleanToString( TransmitInfo->Queued )
    );

    dprintf(
        "    Read.Irp               = %08lx%s\n",
        TransmitInfo->Read.Irp,
        IsTransmitIrpBusy( TransmitInfo->Read.Irp )
        ? " (BUSY)"
        : ""
    );

    dprintf(
        "    Read.AfdBuffer         = %08lx\n",
        TransmitInfo->Read.AfdBuffer
    );

    dprintf(
        "    Read.Length            = %08lx\n",
        TransmitInfo->Read.Length
    );

    dprintf(
        "    Send1.Irp              = %08lx%s\n",
        TransmitInfo->Send1.Irp,
        IsTransmitIrpBusy( TransmitInfo->Send1.Irp )
        ? " (BUSY)"
        : ""
    );

    dprintf(
        "    Send1.AfdBuffer        = %08lx\n",
        TransmitInfo->Send1.AfdBuffer
    );

    dprintf(
        "    Send1.Length           = %08lx\n",
        TransmitInfo->Send1.Length
    );

    dprintf(
        "    Send2.Irp              = %08lx%s\n",
        TransmitInfo->Send2.Irp,
        IsTransmitIrpBusy( TransmitInfo->Send2.Irp )
        ? " (BUSY)"
        : ""
    );

    dprintf(
        "    Send2.AfdBuffer        = %08lx\n",
        TransmitInfo->Send2.AfdBuffer
    );

    dprintf(
        "    Send2.Length           = %08lx\n",
        TransmitInfo->Send2.Length
    );

    dprintf( "\n" );

}   // DumpAfdTransmitInfo
Esempio n. 4
0
PSTR
SystemTimeToString(
    LONGLONG Value
)

/*++

Routine Description:

    Maps a LONGLONG representing system time to a displayable string.

Arguments:

    Value - The LONGLONG time to map.

Return Value:

    PSTR - Points to the displayable form of the system time.

Notes:

    This routine is NOT multithread safe!

--*/

{

    static char buffer[64];
    NTSTATUS status;
    LARGE_INTEGER systemTime;
    LARGE_INTEGER localTime;
    TIME_FIELDS timeFields;

    systemTime.QuadPart = Value;

    status = RtlSystemTimeToLocalTime( &systemTime, &localTime );

    if( !NT_SUCCESS(status) ) {

        return LongLongToString( Value );

    }

    RtlTimeToTimeFields( &localTime, &timeFields );

    sprintf(
        buffer,
        "%s %s %2d %4d %02d:%02d:%02d.%03d",
        WeekdayNames[timeFields.Weekday],
        MonthNames[timeFields.Month],
        timeFields.Day,
        timeFields.Year,
        timeFields.Hour,
        timeFields.Minute,
        timeFields.Second,
        timeFields.Milliseconds
    );

    return buffer;

}   // SystemTimeToString
char* IndexToString(OIndex oi)
{
	return LongLongToString(oi);
}