title: The stack around variable was corrupted calling a driver
body: <p>I am trying to get the pids of all the processes that are getting executed on the computer using a kernel mode driver. But when requesting the driver, I get a error.</p>
  
  <p>here is the function that fails, the problematic variable is "Id"</p>
  
  <pre><code>    DWORD GetTargetPid()
  {
      if (hDriver == INVALID_HANDLE_VALUE)
          return false;
  
      DWORD Id = 0;
      DWORD Bytes = 0;
  
      if (DeviceIoControl(hDriver, IO_GET_ID_REQUEST, &amp;Id, sizeof(Id),
          &amp;Id, sizeof(Id), &amp;Bytes, NULL))
          return Id;
      else
          return false;
  }
  </code></pre>
  
  <p>and here is the code handling the request in the driver :</p>
  
  <pre><code>else if (ControlCode == IO_GET_ID_REQUEST)
  {
      PULONG OutPut = (PULONG)Irp-&gt;AssociatedIrp.SystemBuffer;
      *OutPut = id;
  
      DbgPrintEx(0, 0, "id get %#010x", id);
      Status = STATUS_SUCCESS;
      BytesIO = sizeof(OutPut);
  }
  ...
  // Complete the request
  Irp-&gt;IoStatus.Status = Status;
  Irp-&gt;IoStatus.Information = BytesIO;
  IoCompleteRequest(Irp, IO_NO_INCREMENT);
  
  return Status;
  </code></pre>
  
  <p>I just don't understand why I have this problem, as I use DWORD in each part of the code.</p>