Reply To: Create TDI enpoint connection error, please help?

Home Forums Discussions General Create TDI enpoint connection error, please help? Reply To: Create TDI enpoint connection error, please help?

#5625
Anton
Participant

    1. You should set EaValue to ULONG “Connetion context”

    dwSize = FIELD_OFFSET( FILE_FULL_EA_INFORMATION, EaName[0] ) + TDI_CONNECTION_CONTEXT_LENGTH + 1 + sizeof(CONNECTION_CONTEXT);

    eaInfo = (PFILE_FULL_EA_INFORMATION)ExAllocatePool(PagedPool, dwSize);

    eaInfo->NextEntryOffset = 0;
    eaInfo->Flags = 0;
    eaInfo->EaNameLength = TDI_CONNECTION_CONTEXT_LENGTH;
    eaInfo->EaValueLength = sizeof(CONNECTION_CONTEXT);

    RtlCopyMemory(
    eaInfo->EaName,
    TdiConnectionContext,
    TDI_CONNECTION_CONTEXT_LENGTH+1
    );

    RtlCopyMemory(
    &eaInfo->EaName[TDI_CONNECTION_CONTEXT_LENGTH+1],
    pConnectionContext,
    sizeof(CONNECTION_CONTEXT)
    );

    2. It’s better to open “connection endpoint” with the following attributes:
    ZwCreateFile(
    Handle, // Handle
    GENERIC_READ | GENERIC_WRITE | SYNCHRONIZE, // Desired Access
    &ObjectAttributes, // Object Attributes
    &IoStatusBlock, // Final I/O status block
    0, // Allocation Size
    FILE_ATTRIBUTE_NORMAL, // Normal attributes
    FILE_SHARE_READ, // Sharing attributes
    FILE_OPEN_IF, // Create disposition
    0, // CreateOptions
    pConnectionContextEa, // EA Buffer
    TransportEaBufferLength // EA length
    );