当前位置: 首页 > news >正文

tftpd.exe源代码分析第一篇get 2.txt

tftpd.exe源代码分析
第一部分:TftpdIoCompletionCallback函数调用TftpdProcessReceivedBuffer函数
 

void
TftpdIoCompletionCallback(DWORD dwErrorCode,
                          DWORD dwBytes,
                          LPOVERLAPPED overlapped) {

    PTFTPD_BUFFER  buffer  = CONTAINING_RECORD(overlapped, TFTPD_BUFFER,
                                               internal.io.overlapped);
    PTFTPD_CONTEXT context = buffer->internal.context;
    PTFTPD_SOCKET  socket  = buffer->internal.socket;

    TFTPD_DEBUG((TFTPD_TRACE_IO,
                 "TftpdIoCompletionCallback(buffer = %p): bytes = %d.\n",
                 buffer, dwBytes));

    if (context == NULL)
        InterlockedDecrement((PLONG)&socket->postedBuffers);

    switch (dwErrorCode) {

        case STATUS_SUCCESS :

            if (context == NULL) {

                if (dwBytes < TFTPD_MIN_RECEIVED_DATA)
                    goto exit_completion_callback;

                buffer->internal.io.bytes = dwBytes;
                buffer = TftpdProcessReceivedBuffer(buffer);

            } // if (context == NULL)
            break;

        case STATUS_PORT_UNREACHABLE :


第二部分:TftpdProcessReceivedBuffer函数调用TftpdReadRequest函数

PTFTPD_BUFFER
TftpdProcessReceivedBuffer(PTFTPD_BUFFER buffer) {

    TFTPD_DEBUG((TFTPD_TRACE_PROCESS,
                 "TftpdProcessReceivedBuffer(buffer = %p).\n",
                 buffer));

    buffer->message.opcode = ntohs(buffer->message.opcode);

    switch (buffer->message.opcode) {

        //
        // Sending files to a client:
        //

        case TFTPD_RRQ :
            buffer = TftpdReadRequest(buffer);
            break;

        case TFTPD_ACK :
            buffer->message.ack.block = ntohs(buffer->message.ack.block);
            buffer = TftpdReadAck(buffer);
            break;

        //
        // Receiving files from a client:
        //

第三部分:TftpdReadRequest函数调用TftpdContextAquire函数和然后调用TftpdContextAllocate函数
PTFTPD_BUFFER
TftpdReadRequest(PTFTPD_BUFFER buffer) {

    PTFTPD_CONTEXT context = NULL;
    NTSTATUS status;

    // Ensure that a RRQ is from the master socket only.
    if (buffer->internal.socket != &globals.io.master) {
        TftpdIoSendErrorPacket(buffer, TFTPD_ERROR_ILLEGAL_OPERATION,
                               "Illegal TFTP operation");
        goto exit_read_request;
    }

    // Is this a duplicate request?  Do we ignore it or send an error?
    if ((context = TftpdContextAquire(&buffer->internal.io.peer)) != NULL) {
        if (context->block > 0)
            TftpdIoSendErrorPacket(buffer, TFTPD_ERROR_ILLEGAL_OPERATION,
                                   "Illegal TFTP operation");
        TftpdContextRelease(context);
        context = NULL;
        goto exit_read_request;
    }

    // Allocate a context for this request (this gives us a reference to it as well).
    if ((context = (PTFTPD_CONTEXT)TftpdContextAllocate()) == NULL)
        goto exit_read_request;

    TFTPD_DEBUG((TFTPD_TRACE_PROCESS,
                 "TftpdReadRequest(buffer = %p): context = %p.\n",
                 buffer, context));

    // Initialize the context.
    context->type = TFTPD_RRQ;
    CopyMemory(&context->peer, &buffer->internal.io.peer, sizeof(context->peer));
    context->state = TFTPD_STATE_BUSY;


http://www.mrgr.cn/news/55569.html

相关文章:

  • 如何计算表格中重复项有多少?
  • 智慧公厕厂家:智慧公厕建设推动城市公厕智能化变革
  • nginx解决非人类使用http打开的443,解决网安漏扫时误扫443端口带来的问题
  • 有同学问:拿到大厂JAVA OFFER,但是会不会不稳定,有失业风险?!
  • Vivado - Aurora 8B/10B IP
  • 一起搭WPF架构之livechart的MVVM使用介绍
  • 头歌——人工智能(启发式搜索算法)
  • Linux安装Python解释器
  • ThinkPHP3.1框架.zip
  • 特种作业操作烟花爆竹试题分享
  • 尚硅谷redis第144节 淘汰策略及使用建议 答疑
  • Nature 正刊丨相纯χ-Fe5C2高效转化合成气为线性α-烯烃
  • upload-labs靶场Pass-10
  • PH47代码框架软件二次开发极简教程
  • HarmonyOS开发 - ohpm环境变量配置
  • JAVA课设-图书指引系统(前后端分离)
  • 期权懂|股票下跌时可以使用期权止损吗?
  • 绝对差值的和
  • 【英特尔IA-32架构软件开发者开发手册第3卷:系统编程指南】2001年版翻译,2-1
  • 高级java每日一道面试题-2024年10月19日-消息队列[RabbitMQ]-RabbitMQ中积压了大量的消息,如何处理?
  • Saprk:数据插入的优化(forachPartition)
  • 电能表预付费系统-标准传输规范(STS)(15)
  • Hadoop---HDFS(2)
  • A Graph-Transformer for Whole SlideImage Classification文献笔记
  • arm_acle.h找不到
  • 基于递推式最小二乘法的PMSM参数辨识MATLAB仿真模型