none
Is this code correct? RRS feed

  • Question

  • In SoraSDK1.5 Mdl.c, the definition of function "PushHeaderInPlace" as follows:

    PUCHAR PushHeaderInPlace(PMDL pFirstBuffer, ULONG HeaderSize, PUCHAR OlderHeader)
    {
        PUCHAR  pBuffer = NULL;
        ULONG   Length  = 0;
        PUCHAR  NewHeader = NULL;

        MP_QUERY_MDL_SAFE(pFirstBuffer, &pBuffer, &Length, NormalPagePriority);
        do
        {
            if (!pBuffer) break;

            if (pBuffer - OlderHeader > (LONG) HeaderSize) //big enough
            {
                pFirstBuffer->ByteCount      = pFirstBuffer->ByteCount  + HeaderSize;
                pFirstBuffer->ByteOffset     = pFirstBuffer->ByteOffset - HeaderSize;
                pFirstBuffer->MappedSystemVa = (PUCHAR)(pFirstBuffer->MappedSystemVa) + pFirstBuffer->ByteOffset;
                MmBuildMdlForNonPagedPool(pFirstBuffer);
                NewHeader = pFirstBuffer->MappedSystemVa;
            }

        } while(FALSE);
        return NewHeader;
    }

    I guess there must be something wrong with the the underline code. My question is that whether  it should be :

    pFirstBuffer->MappedSystemVa = (PUCHAR)(pFirstBuffer->StartVa) + pFirstBuffer->ByteOffset;   ????

    am i right?

    Wednesday, October 31, 2012 7:03 AM

Answers