Giter Site home page Giter Site logo

codeword's Introduction

codeword's People

Stargazers

dev avatar

Forkers

uvbs

codeword's Issues

use a switch in the buffer allocation part of CwDispatchHandlerIoControl

The if...else if... else stuff in the main.c file was pissing me off. Ioctl
is a ULONG and so you should be able to use a switch on it. I didn't
compile to see if it worked but it should. Here is what I changed main.c to:

btw I despise gotos... they are the bane of my existence.

// from CwDispatchHandlerIoControl(): 

    //--------------------
    // PRELIM VALIDATION
    //--------------------
    //determine required sizes for in/out bufs

    // use a switch wtf... it's a ulong, switch is valid on numeric types.

    switch(Ioctl)
    {
        case IOCTL_SSDT_DETECT_HOOKS:
            RequiredOutputBufferSize = sizeof(HOOKED_SSDT_TABLE);
            RequiredInputBufferSize  = 0; //no input buf needed
            break;

        case IOCTL_SSDT_DETECT_DETOURS:
            RequiredOutputBufferSize = sizeof(DETOURED_SSDT_TABLE);
            RequiredInputBufferSize  = 0; //no input buf needed
            break;

        case IOCTL_WIN32API_DETOUR_DETECTION:
            RequiredOutputBufferSize = sizeof(WIN32API_DETOUR_TABLE);
            RequiredInputBufferSize  = 0; //input buf needed but not checked
            break;

        case IOCTL_IRP_HOOK_DETECTION:
            RequiredOutputBufferSize = sizeof(HOOKED_DISPATCH_FUNCTIONS_TABLE);
            RequiredInputBufferSize  = sizeof(DRIVER_CHECK_INFO);
            break;

        case IOCTL_IRP_DETOUR_DETECTION:
            RequiredOutputBufferSize = sizeof(DETOURED_DISPATCH_FUNCTIONS_TABLE);
            RequiredInputBufferSize  = sizeof(DRIVER_CHECK_INFO);
            break;

        case IOCTL_GET_PROCESS_LISTING_ZWQ:
            RequiredOutputBufferSize = sizeof(PROCESS_LISTING_ZWQ);
            RequiredInputBufferSize  = 0; //no inbuf needed
            break;

        case IOCTL_GET_PROCESS_LISTING_PSP:
            RequiredOutputBufferSize = sizeof(UINT)*256;
            RequiredInputBufferSize  = 0; //no inbuf needed
            break;

        default: //unrecognized IOCTL.  bail now.
            Irp->IoStatus.Status = STATUS_INVALID_DEVICE_REQUEST;
            Irp->IoStatus.Information = 0;
            DbgPrint("CwDispatchHandlerIoControl():  Received unrecognized IOCTL
code 0x%08x",Ioctl);

          goto End; // WHO THE FUCK STILL USES GOTO? THIS IS C GOD DAMNIT, NOT
ASSEMBLY!
                         // Goto should be avoided it gets in the way of debugging and is bad 
                         // style because it creates spaghetti code. the code structure should
                         // be in a way such that you don't need goto.

            break;
    }

Original issue reported on code.google.com by [email protected] on 3 Nov 2009 at 4:49

Attachments:

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.