MouseClassServiceCallback函数分析DataIn+moveSize到达内存的尾部的情况需要二次拷贝

VOID

MouseClassServiceCallback(

IN PDEVICE_OBJECT DeviceObject,

IN PMOUSE_INPUT_DATA InputDataStart,

IN PMOUSE_INPUT_DATA InputDataEnd,

IN OUT PULONG InputDataConsumed

)

{

deviceExtension->DataIn = (PMOUSE_INPUT_DATA)

(((PCHAR) deviceExtension->DataIn) + moveSize);

if ((PCHAR) deviceExtension->DataIn >=

((PCHAR) deviceExtension->InputData +

deviceExtension->MouseAttributes.InputDataQueueLength)) {

deviceExtension->DataIn = deviceExtension->InputData;//满了则从头开始,设置为头

}

if ((bytesToMove - moveSize) > 0) {

//

// Special case. The data must wrap in the class input data buffer.

// Copy the rest of the port input data into the beginning of the

// class input data queue.

//

//

// moveSize <- Number of bytes to handle in the second move.

//

moveSize = bytesToMove - moveSize;

//

// Do the move from the port data queue to the class data queue.

//

MouPrint((

3,

"MOUCLASS-MouseClassServiceCallback: number of bytes in second move to class 0x%lx\n",

moveSize

));

MouPrint((

3,

"MOUCLASS-MouseClassServiceCallback: move bytes from 0x%lx to 0x%lx\n",

(PCHAR) InputDataStart,

(PCHAR) deviceExtension->DataIn

));

RtlMoveMemory(

(PCHAR) deviceExtension->DataIn,

(PCHAR) InputDataStart,

moveSize

);从头把剩下的应该拷贝的第二次拷贝完。

//

// Update the class input data queue insertion pointer.

//

deviceExtension->DataIn = (PMOUSE_INPUT_DATA)

(((PCHAR) deviceExtension->DataIn) + moveSize);

}