Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- UINT i = 0;
- PIRP Irp = NULL;
- ULONG Offset = 0;
- PIO_STACK_LOCATION IrpSp = NULL;
- LARGE_INTEGER StartingOffset;
- PKEVENT Event = NULL;
- CHAR packetBuffer[100];
- BOOLEAN BytesTransfered = FALSE;
- PDEVICE_OBJECT CurrentDeviceObject;
- ULONG IoControlCode = BIOCSENDPACKETSNOSYNC; // #define BIOCSENDPACKETSNOSYNC 9032
- ...
- DriverObject->MajorFunction[IRP_MJ_DEVICE_CONTROL] = NPF_IoControl;
- ...
- // CurrentDeviceObject gets set here
- ...
- StartingOffset.QuadPart = (LONGLONG) Offset;
- /* Supposing to be on ethernet, set mac destination to 1:1:1:1:1:1 */
- packetBuffer[0]=1;
- packetBuffer[1]=1;
- packetBuffer[2]=1;
- packetBuffer[3]=1;
- packetBuffer[4]=1;
- packetBuffer[5]=1;
- /* set mac source to 2:2:2:2:2:2 */
- packetBuffer[6]=2;
- packetBuffer[7]=2;
- packetBuffer[8]=2;
- packetBuffer[9]=2;
- packetBuffer[10]=2;
- packetBuffer[11]=2;
- packetBuffer[12] = 'H';
- packetBuffer[13] = 'E';
- packetBuffer[14] = 'L';
- packetBuffer[15] = 'L';
- packetBuffer[16] = 'O';
- /* Fill the rest of the packet */
- for(i=17;i<100;i++) {
- packetBuffer[i]= (u_char)i;
- }
- /*
- PIRP IoBuildDeviceIoControlRequest(
- __in ULONG IoControlCode,
- __in PDEVICE_OBJECT DeviceObject,
- __in_opt PVOID InputBuffer,
- __in ULONG InputBufferLength,
- __out_opt PVOID OutputBuffer,
- __in ULONG OutputBufferLength,
- __in BOOLEAN InternalDeviceIoControl,
- __in PKEVENT Event,
- __out PIO_STATUS_BLOCK IoStatusBlock
- );
- */
- Irp = IoBuildDeviceIoControlRequest (
- IoControlCode,
- CurrentDeviceObject,
- packetBuffer,
- 100,
- NULL,
- 0,
- BytesTransfered,
- Event,
- NULL
- );
- if (!Irp) {
- TRACE_MESSAGE(PACKET_DEBUG_INIT,"Failed to create IRP!");
- } else {
- IrpSp = IoGetCurrentIrpStackLocation(Irp);
- TRACE_MESSAGE3(PACKET_DEBUG_LOUD,
- "Function code is %08lx Input size=%08lx Output size %08lx",
- IrpSp->Parameters.DeviceIoControl.IoControlCode,
- IrpSp->Parameters.DeviceIoControl.InputBufferLength,
- IrpSp->Parameters.DeviceIoControl.OutputBufferLength);
- // Send the IRP and deviceobject to our IRP_MJ_DEVICE_CONTROL function
- // NPF_IoControl(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement