Advertisement
Guest User

Untitled

a guest
Oct 15th, 2011
173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 2.19 KB | None | 0 0
  1. UINT i = 0;
  2. PIRP Irp = NULL;
  3. ULONG Offset = 0;
  4. PIO_STACK_LOCATION IrpSp = NULL;
  5. LARGE_INTEGER StartingOffset;
  6. PKEVENT Event = NULL;
  7. CHAR packetBuffer[100];
  8. BOOLEAN BytesTransfered = FALSE;
  9. PDEVICE_OBJECT     CurrentDeviceObject;
  10. ULONG IoControlCode = BIOCSENDPACKETSNOSYNC; // #define BIOCSENDPACKETSNOSYNC 9032
  11.  
  12. ...
  13.  
  14. DriverObject->MajorFunction[IRP_MJ_DEVICE_CONTROL]  = NPF_IoControl;
  15.  
  16. ...
  17.  
  18. // CurrentDeviceObject gets set here
  19.  
  20. ...
  21.  
  22. StartingOffset.QuadPart = (LONGLONG) Offset;
  23.  
  24. /* Supposing to be on ethernet, set mac destination to 1:1:1:1:1:1 */
  25. packetBuffer[0]=1;
  26. packetBuffer[1]=1;
  27. packetBuffer[2]=1;
  28. packetBuffer[3]=1;
  29. packetBuffer[4]=1;
  30. packetBuffer[5]=1;
  31.  
  32. /* set mac source to 2:2:2:2:2:2 */
  33. packetBuffer[6]=2;
  34. packetBuffer[7]=2;
  35. packetBuffer[8]=2;
  36. packetBuffer[9]=2;
  37. packetBuffer[10]=2;
  38. packetBuffer[11]=2;
  39.  
  40. packetBuffer[12] = 'H';
  41. packetBuffer[13] = 'E';
  42. packetBuffer[14] = 'L';
  43. packetBuffer[15] = 'L';
  44. packetBuffer[16] = 'O';
  45.  
  46. /* Fill the rest of the packet */
  47. for(i=17;i<100;i++) {
  48.    
  49.    packetBuffer[i]= (u_char)i;
  50. }
  51.  
  52. /*
  53.    PIRP IoBuildDeviceIoControlRequest(
  54.       __in       ULONG IoControlCode,
  55.       __in       PDEVICE_OBJECT DeviceObject,
  56.       __in_opt   PVOID InputBuffer,
  57.       __in       ULONG InputBufferLength,
  58.       __out_opt  PVOID OutputBuffer,
  59.       __in       ULONG OutputBufferLength,
  60.       __in       BOOLEAN InternalDeviceIoControl,
  61.       __in       PKEVENT Event,
  62.       __out      PIO_STATUS_BLOCK IoStatusBlock
  63.    );
  64. */
  65.  
  66. Irp = IoBuildDeviceIoControlRequest (
  67. IoControlCode,
  68. CurrentDeviceObject,
  69. packetBuffer,
  70. 100,
  71. NULL,
  72. 0,
  73. BytesTransfered,
  74. Event,
  75. NULL
  76. );
  77.  
  78.  
  79. if (!Irp) {
  80.  
  81.    TRACE_MESSAGE(PACKET_DEBUG_INIT,"Failed to create IRP!");
  82.    
  83. } else {
  84.    
  85.    IrpSp = IoGetCurrentIrpStackLocation(Irp);
  86.    
  87.    TRACE_MESSAGE3(PACKET_DEBUG_LOUD,
  88.    "Function code is %08lx Input size=%08lx Output size %08lx",
  89.    IrpSp->Parameters.DeviceIoControl.IoControlCode,
  90.    IrpSp->Parameters.DeviceIoControl.InputBufferLength,
  91.    IrpSp->Parameters.DeviceIoControl.OutputBufferLength);
  92.  
  93.    // Send the IRP and deviceobject to our IRP_MJ_DEVICE_CONTROL function
  94.    // NPF_IoControl(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp);
  95. }
  96.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement