Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. Hardware & Devices
  4. DeviceIoControl input buffer question

DeviceIoControl input buffer question

Scheduled Pinned Locked Moved Hardware & Devices
questionhelp
7 Posts 2 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Mattzimmerer
    wrote on last edited by
    #1

    The following is a snippet from an exe that is communicating with my driver. I am trying to pass a buffer to my driver by using DeviceIoControl. The problem is I've never done this before, so I don't even know if I am on the right track. I guess I just need the starting address of my input struct. (struct input {int a;int b;int c;};) The problem seems to be that I cannot put the address of my bInput into a DWORD. Am I going about this right? When I check out the contents of pInput, it seems to b a DWORD with the actual struct attached after... Im just confused

    unsigned long Returned,*pReturned = &Returned;
    input bInput;
    bInput.a = 1;
    bInput.b = 2;
    bInput.c = 3;
    int test = sizeof(bInput);
    input *pInput = &bInput;

     DeviceIoControl(
          hFile,			// Device handle
          IOCTL\_MZ\_READMEMORY,          // Code
          NULL,				// Buffer TO driver
          0,			// Size of InBuffer
          NULL,				// Buffer FROM driver
          0,				// Size of OutBuffer
          pReturned,			// Bytes output
          (LPOVERLAPPED) NULL);		// Overlapped struc
    

    note: right now my DeviceIoControl call is not using any buffer. I plan on passing the starting address of bInput and the size of bInput.

    L 2 Replies Last reply
    0
    • M Mattzimmerer

      The following is a snippet from an exe that is communicating with my driver. I am trying to pass a buffer to my driver by using DeviceIoControl. The problem is I've never done this before, so I don't even know if I am on the right track. I guess I just need the starting address of my input struct. (struct input {int a;int b;int c;};) The problem seems to be that I cannot put the address of my bInput into a DWORD. Am I going about this right? When I check out the contents of pInput, it seems to b a DWORD with the actual struct attached after... Im just confused

      unsigned long Returned,*pReturned = &Returned;
      input bInput;
      bInput.a = 1;
      bInput.b = 2;
      bInput.c = 3;
      int test = sizeof(bInput);
      input *pInput = &bInput;

       DeviceIoControl(
            hFile,			// Device handle
            IOCTL\_MZ\_READMEMORY,          // Code
            NULL,				// Buffer TO driver
            0,			// Size of InBuffer
            NULL,				// Buffer FROM driver
            0,				// Size of OutBuffer
            pReturned,			// Bytes output
            (LPOVERLAPPED) NULL);		// Overlapped struc
      

      note: right now my DeviceIoControl call is not using any buffer. I plan on passing the starting address of bInput and the size of bInput.

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      The input and output buffers are defined here[^] as being LPVOID, which effectively means a pointer to something; what it really contains is between you and the driver. So to call this function passing your buffer address (suitably cast) all you need to code is something like:

       DeviceIoControl(
            hFile,			// Device handle
            IOCTL\_MZ\_READMEMORY,          // Code
            (LPVOID)&bInput,		// Buffer TO driver
            sizeof bInput,		// Size of InBuffer
            (LPVOID)&bOutput,		// Buffer FROM driver
            sizeof bOutput,		// Size of OutBuffer
            pReturned,			// Bytes output
            (LPOVERLAPPED) NULL);		// Overlapped struc
      

      And don't forget to check the return status.

      M 1 Reply Last reply
      0
      • L Lost User

        The input and output buffers are defined here[^] as being LPVOID, which effectively means a pointer to something; what it really contains is between you and the driver. So to call this function passing your buffer address (suitably cast) all you need to code is something like:

         DeviceIoControl(
              hFile,			// Device handle
              IOCTL\_MZ\_READMEMORY,          // Code
              (LPVOID)&bInput,		// Buffer TO driver
              sizeof bInput,		// Size of InBuffer
              (LPVOID)&bOutput,		// Buffer FROM driver
              sizeof bOutput,		// Size of OutBuffer
              pReturned,			// Bytes output
              (LPOVERLAPPED) NULL);		// Overlapped struc
        

        And don't forget to check the return status.

        M Offline
        M Offline
        Mattzimmerer
        wrote on last edited by
        #3

        Thanks!

        1 Reply Last reply
        0
        • M Mattzimmerer

          The following is a snippet from an exe that is communicating with my driver. I am trying to pass a buffer to my driver by using DeviceIoControl. The problem is I've never done this before, so I don't even know if I am on the right track. I guess I just need the starting address of my input struct. (struct input {int a;int b;int c;};) The problem seems to be that I cannot put the address of my bInput into a DWORD. Am I going about this right? When I check out the contents of pInput, it seems to b a DWORD with the actual struct attached after... Im just confused

          unsigned long Returned,*pReturned = &Returned;
          input bInput;
          bInput.a = 1;
          bInput.b = 2;
          bInput.c = 3;
          int test = sizeof(bInput);
          input *pInput = &bInput;

           DeviceIoControl(
                hFile,			// Device handle
                IOCTL\_MZ\_READMEMORY,          // Code
                NULL,				// Buffer TO driver
                0,			// Size of InBuffer
                NULL,				// Buffer FROM driver
                0,				// Size of OutBuffer
                pReturned,			// Bytes output
                (LPOVERLAPPED) NULL);		// Overlapped struc
          

          note: right now my DeviceIoControl call is not using any buffer. I plan on passing the starting address of bInput and the size of bInput.

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #4

          Mattzimmerer wrote:

          my driver

          You wrote a driver and you cant get devioctl to work! :omg:

          Morality is indistinguishable from social proscription

          M 1 Reply Last reply
          0
          • L Lost User

            Mattzimmerer wrote:

            my driver

            You wrote a driver and you cant get devioctl to work! :omg:

            Morality is indistinguishable from social proscription

            M Offline
            M Offline
            Mattzimmerer
            wrote on last edited by
            #5

            Thanks sir, your tons of help. No it works now... maybe you should try helpful comments instead of (in my perception) being boastful. Surely you have asked for help to understand certain things... Obviously in not doing this professionally, its a side project in developing a game hacking tool! :-D

            L 1 Reply Last reply
            0
            • M Mattzimmerer

              Thanks sir, your tons of help. No it works now... maybe you should try helpful comments instead of (in my perception) being boastful. Surely you have asked for help to understand certain things... Obviously in not doing this professionally, its a side project in developing a game hacking tool! :-D

              L Offline
              L Offline
              Lost User
              wrote on last edited by
              #6

              I saw though that someone else had solved your problem and felt like having a bit of a dig! :)

              Morality is indistinguishable from social proscription

              M 1 Reply Last reply
              0
              • L Lost User

                I saw though that someone else had solved your problem and felt like having a bit of a dig! :)

                Morality is indistinguishable from social proscription

                M Offline
                M Offline
                Mattzimmerer
                wrote on last edited by
                #7

                Yea, lol this stuff is pretty out there if you have only been exposed to userspace programming. Now onto assembly language!

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups