⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pcidp.asm

📁 一个amccs5933芯片的驱动程序开发源程序和部分文档
💻 ASM
📖 第 1 页 / 共 4 页
字号:
; 454  : 
; 455  : 	case IOCTL_PCIDP00_UNREGISTER_INTERRUPT:
; 456  : 		PCIDPUnregisterInterrupt(
; 457  : 			IN DeviceObject,
; 458  : 			IN OUT Irp,
; 459  : 			IN IoBuffer,
; 460  : 			IN InputBufferLength
; 461  : 		);

	push	ebx
	push	ecx
	push	esi
	push	DWORD PTR _DeviceObject$[ebp]
	call	_PCIDPUnregisterInterrupt@16

; 462  : 		break;

	jmp	SHORT $L8512
$L8522:

; 444  : 
; 445  : 	case IOCTL_PCIDP00_REGISTER_INTERRUPT:
; 446  : 		PCIDPRegisterInterrupt(
; 447  : 			IN DeviceObject,
; 448  : 			IN OUT Irp,
; 449  : 			IN IoBuffer,
; 450  : 			IN InputBufferLength,
; 451  : 			IN OutputBufferLength
; 452  : 		);

	push	DWORD PTR _OutputBufferLength$[ebp]
	push	ebx
	push	ecx
	push	esi
	push	DWORD PTR _DeviceObject$[ebp]
	call	_PCIDPRegisterInterrupt@20
$L8512:

; 478  : 	}
; 479  : 
; 480  : 	// Finish the I/O operation by simply completing the packet and returning
; 481  : 	// the same status as in the packet itself.  However, don't complete the I/O
; 482  : 	// if the status is pending (register interrupt only).
; 483  : 	NTStatus = Irp->IoStatus.Status;

	mov	edi, DWORD PTR [esi+24]

; 484  : 	if(NTStatus != STATUS_PENDING)

	cmp	edi, 259				; 00000103H
	je	SHORT $L8529

; 485  : 		IoCompleteRequest(Irp, IO_NO_INCREMENT);

	xor	dl, dl
	mov	ecx, esi
	call	DWORD PTR __imp_@IofCompleteRequest@8
$L8529:

; 486  : 
; 487  : 	// Debug exit point
; 488  : 	DbgPrint("[PCIDP]->Leaving DeviceControl, status=%ld...\n", NTStatus);	//debug

	push	edi
	push	OFFSET FLAT:$SG8530
	call	_DbgPrint
	pop	ecx
	pop	ecx

; 489  : 	DbgBreakPoint();	//debug

	call	_DbgBreakPoint@0

; 490  : 
; 491  : 	return NTStatus;

	mov	eax, edi
	pop	edi
	pop	esi
	pop	ebx

; 492  : }

	pop	ebp
	ret	8
_PCIDPDeviceControl@8 ENDP
_TEXT	ENDS
;	COMDAT _PCIDPCreateClose@8
; File c:\kernel2000\pcidp.c
_TEXT	SEGMENT
$SG8536	DB	'[PCIDP]->Entering CreateClose...', 0aH, 00H
_Irp$ = 12
_PCIDPCreateClose@8 PROC NEAR				; COMDAT

; 505  : 
; 506  : 	// Debug entry point
; 507  : 	DbgPrint("[PCIDP]->Entering CreateClose...\n");	//debug

	push	OFFSET FLAT:$SG8536
	call	_DbgPrint
	pop	ecx

; 508  : 	DbgBreakPoint();	//debug

	call	_DbgBreakPoint@0

; 509  : 
; 510  : 	Irp->IoStatus.Status = STATUS_SUCCESS;

	mov	ecx, DWORD PTR _Irp$[esp-4]

; 511  : 	Irp->IoStatus.Information = 0;
; 512  : 
; 513  : 	IoCompleteRequest( Irp, IO_NO_INCREMENT );

	xor	dl, dl
	and	DWORD PTR [ecx+24], 0
	and	DWORD PTR [ecx+28], 0
	call	DWORD PTR __imp_@IofCompleteRequest@8

; 514  : 
; 515  : 	return STATUS_SUCCESS;

	xor	eax, eax

; 516  : }

	ret	8
_PCIDPCreateClose@8 ENDP
_TEXT	ENDS
EXTRN	_GetNextEntry@16:NEAR
EXTRN	_PutBackEntry@8:NEAR
EXTRN	_FreeEntry@8:NEAR
EXTRN	__imp__IoAcquireCancelSpinLock@4:NEAR
EXTRN	__imp__IoReleaseCancelSpinLock@4:NEAR
;	COMDAT _PCIDPCleanup@8
; File c:\kernel2000\pcidp.c
_TEXT	SEGMENT
$SG8551	DB	'[PCIDP]->Entering Cleanup...', 0aH, 00H
_DeviceObject$ = 8
_Irp$ = 12
_Interrupt$ = -4
_CleanUpStack$ = 8
_CancelSpin$ = -16
_CurrentLink$ = -8
_FirstLink$ = -12
_PCIDPCleanup@8 PROC NEAR				; COMDAT

; 528  : ){

	push	ebp
	mov	ebp, esp
	sub	esp, 16					; 00000010H
	push	ebx
	push	esi
	push	edi

; 529  : 
; 530  : 	// Define variables.
; 531  : 	PPCIDP_EXTENSION ObjExt;
; 532  : 	PREGISTERED_INTERRUPT Interrupt;
; 533  : 	PIO_STACK_LOCATION CleanUpStack ;
; 534  : 	PIO_STACK_LOCATION IrpStack ;
; 535  : 	KIRQL CancelSpin;
; 536  : 	PLINKED_LIST CurrentLink;
; 537  : 	PLINKED_LIST FirstLink;
; 538  : 
; 539  : 	// Debug entry point
; 540  : 	DbgPrint("[PCIDP]->Entering Cleanup...\n");	//debug

	push	OFFSET FLAT:$SG8551
	call	_DbgPrint
	pop	ecx

; 541  : 	DbgBreakPoint();	//debug

	call	_DbgBreakPoint@0

; 542  : 
; 543  : 	// Initialize variables.
; 544  : 	ObjExt = (PPCIDP_EXTENSION)DeviceObject->DeviceExtension;

	mov	eax, DWORD PTR _DeviceObject$[ebp]

; 545  : 
; 546  : 	// Search the driver's events linked list for an entry containing the 
; 547  : 	// user provided Irp.
; 548  : 	CleanUpStack = IoGetCurrentIrpStackLocation(Irp);

	mov	esi, DWORD PTR _Irp$[ebp]

; 549  : 	CurrentLink = NULL;

	and	DWORD PTR _CurrentLink$[ebp], 0

; 550  : 	FirstLink = NULL;

	and	DWORD PTR _FirstLink$[ebp], 0
	mov	edi, DWORD PTR [eax+40]
	mov	eax, DWORD PTR [esi+96]
	mov	DWORD PTR _CleanUpStack$[ebp], eax

; 551  : 	while(GetNextEntry(ObjExt, &FirstLink, &CurrentLink, &Interrupt) == TRUE){

	lea	eax, DWORD PTR _Interrupt$[ebp]
	push	eax
	lea	eax, DWORD PTR _CurrentLink$[ebp]
	push	eax
	lea	eax, DWORD PTR _FirstLink$[ebp]
	push	eax
	push	edi
	call	_GetNextEntry@16
	mov	ebx, DWORD PTR __imp_@IofCompleteRequest@8
	cmp	al, 1
	jne	$L8557

; 552  : 		IrpStack = IoGetCurrentIrpStackLocation(Interrupt->Irp);
; 553  : 
; 554  : 		// Cancel the IRP, then delete its linked list entry.
; 555  : 		if (IrpStack->FileObject == CleanUpStack->FileObject) {

	mov	esi, DWORD PTR __imp__IoReleaseCancelSpinLock@4
$L8556:
	mov	eax, DWORD PTR _Interrupt$[ebp]
	mov	ecx, DWORD PTR _CleanUpStack$[ebp]
	mov	eax, DWORD PTR [eax+4]
	mov	eax, DWORD PTR [eax+96]
	mov	eax, DWORD PTR [eax+24]
	cmp	eax, DWORD PTR [ecx+24]
	jne	SHORT $L8558

; 556  : 			IoAcquireCancelSpinLock (&CancelSpin);

	lea	eax, DWORD PTR _CancelSpin$[ebp]
	push	eax
	call	DWORD PTR __imp__IoAcquireCancelSpinLock@4

; 557  : 			Interrupt->Irp->Cancel = TRUE;

	mov	eax, DWORD PTR _Interrupt$[ebp]
	mov	eax, DWORD PTR [eax+4]
	mov	BYTE PTR [eax+36], 1

; 558  : 			//Interrupt->Irp->CancelIrql = CancelSpin;
; 559  : 			Interrupt->Irp->CancelRoutine = NULL;

	mov	eax, DWORD PTR _Interrupt$[ebp]
	mov	eax, DWORD PTR [eax+4]
	and	DWORD PTR [eax+56], 0

; 560  : 			Interrupt->Irp->IoStatus.Status = STATUS_CANCELLED;

	mov	eax, DWORD PTR _Interrupt$[ebp]
	mov	eax, DWORD PTR [eax+4]
	mov	DWORD PTR [eax+24], -1073741536		; c0000120H

; 561  : 			Interrupt->Irp->IoStatus.Information = 0;

	mov	eax, DWORD PTR _Interrupt$[ebp]
	mov	eax, DWORD PTR [eax+4]
	and	DWORD PTR [eax+28], 0

; 562  : 			IoReleaseCancelSpinLock (CancelSpin);

	push	DWORD PTR _CancelSpin$[ebp]
	call	esi

; 563  : 			IoReleaseCancelSpinLock (Interrupt->Irp->CancelIrql);

	mov	eax, DWORD PTR _Interrupt$[ebp]
	mov	eax, DWORD PTR [eax+4]
	mov	al, BYTE PTR [eax+37]
	push	eax
	call	esi

; 564  : 
; 565  : 			IoCompleteRequest(Interrupt->Irp, IO_NO_INCREMENT);

	mov	eax, DWORD PTR _Interrupt$[ebp]
	xor	dl, dl
	mov	ecx, DWORD PTR [eax+4]
	call	ebx

; 566  : 			FreeEntry(ObjExt, CurrentLink);

	push	DWORD PTR _CurrentLink$[ebp]
	push	edi
	call	_FreeEntry@8

; 567  : 		}
; 568  : 		else

	jmp	SHORT $L8561
$L8558:

; 569  : 			PutBackEntry(ObjExt, CurrentLink);

	push	DWORD PTR _CurrentLink$[ebp]
	push	edi
	call	_PutBackEntry@8
$L8561:
	lea	eax, DWORD PTR _Interrupt$[ebp]
	push	eax
	lea	eax, DWORD PTR _CurrentLink$[ebp]
	push	eax
	lea	eax, DWORD PTR _FirstLink$[ebp]
	push	eax
	push	edi
	call	_GetNextEntry@16
	cmp	al, 1
	je	$L8556

; 551  : 	while(GetNextEntry(ObjExt, &FirstLink, &CurrentLink, &Interrupt) == TRUE){

	mov	esi, DWORD PTR _Irp$[ebp]
$L8557:

; 570  : 	}
; 571  : 
; 572  : 	Irp->IoStatus.Information = 0;

	and	DWORD PTR [esi+28], 0

; 573  : 	Irp->IoStatus.Status = STATUS_SUCCESS;

	and	DWORD PTR [esi+24], 0

; 574  : 	IoCompleteRequest (Irp, IO_NO_INCREMENT);

	xor	dl, dl
	mov	ecx, esi
	call	ebx
	pop	edi
	pop	esi

; 575  : 
; 576  : 	return STATUS_SUCCESS;

	xor	eax, eax
	pop	ebx

; 577  : }

	leave
	ret	8
_PCIDPCleanup@8 ENDP
_TEXT	ENDS
;	COMDAT _PCIDPUnload@4
; File c:\kernel2000\pcidp.c
_TEXT	SEGMENT
$SG8567	DB	'[PCIDP]->Entering Unload...', 0aH, 00H
_PCIDPUnload@4 PROC NEAR				; COMDAT

; 588  : 
; 589  : 	// Debug entry point
; 590  : 	DbgPrint("[PCIDP]->Entering Unload...\n");	//debug

	push	OFFSET FLAT:$SG8567
	call	_DbgPrint
	pop	ecx

; 591  : 	DbgBreakPoint();	//debug

	call	_DbgBreakPoint@0

; 592  : 
; 593  : 	return STATUS_SUCCESS;

	xor	eax, eax

; 594  : }

	ret	4
_PCIDPUnload@4 ENDP
_TEXT	ENDS
PUBLIC	_PCIDPCancelInterrupt@8
;	COMDAT _PCIDPCancelInterrupt@8
; File c:\kernel2000\pcidp.c
_TEXT	SEGMENT
$SG8578	DB	'[PCIDP]->Entering CancelInterrupt...', 0aH, 00H
_DeviceObject$ = 8
_Irp$ = 12
_Interrupt$ = -8
_CurrentLink$ = -4
_FirstLink$ = -12
_PCIDPCancelInterrupt@8 PROC NEAR			; COMDAT

; 605  : ){

	push	ebp
	mov	ebp, esp
	sub	esp, 12					; 0000000cH
	push	esi
	push	edi

; 606  : 	// Define variables.
; 607  : 	PPCIDP_EXTENSION ObjExt;
; 608  : 	PREGISTERED_INTERRUPT Interrupt;
; 609  : 	PLINKED_LIST CurrentLink;
; 610  : 	PLINKED_LIST FirstLink;
; 611  : 
; 612  : 	// Debug entry point
; 613  : 	DbgPrint("[PCIDP]->Entering CancelInterrupt...\n");	//debug

	push	OFFSET FLAT:$SG8578
	call	_DbgPrint
	pop	ecx

; 614  : 	DbgBreakPoint();	//debug

	call	_DbgBreakPoint@0

; 615  : 
; 616  : 	// Initialize variables.
; 617  : 	ObjExt = (PPCIDP_EXTENSION)DeviceObject->DeviceExtension;

	mov	eax, DWORD PTR _DeviceObject$[ebp]

; 618  : 
; 619  : 	// Search the driver's events linked list for an entry containing the 
; 620  : 	// user provided Irp.
; 621  : 	CurrentLink = NULL;

	and	DWORD PTR _CurrentLink$[ebp], 0

; 622  : 	FirstLink = NULL;

	and	DWORD PTR _FirstLink$[ebp], 0
	mov	esi, DWORD PTR [eax+40]

; 623  : 	while(GetNextEntry(ObjExt, &FirstLink, &CurrentLink, &Interrupt) == TRUE){

	lea	eax, DWORD PTR _Interrupt$[ebp]
	push	eax
	lea	eax, DWORD PTR _CurrentLink$[ebp]
	push	eax
	lea	eax, DWORD PTR _FirstLink$[ebp]
	push	eax
	push	esi
	call	_GetNextEntry@16
	mov	edi, DWORD PTR _Irp$[ebp]
	cmp	al, 1
	jne	SHORT $L8584
$L8583:

; 624  : 
; 625  : 		// Delete its linked list entry.
; 626  : 		if(Irp == Interrupt->Irp){

	mov	eax, DWORD PTR _Interrupt$[ebp]

; 628  : 			break;
; 629  : 		}
; 630  : 		else
; 631  : 			PutBackEntry(ObjExt, CurrentLink);

	push	DWORD PTR _CurrentLink$[ebp]
	cmp	edi, DWORD PTR [eax+4]
	push	esi
	je	SHORT $L8747
	call	_PutBackEntry@8
	lea	eax, DWORD PTR _Interrupt$[ebp]
	push	eax
	lea	eax, DWORD PTR _CurrentLink$[ebp]
	push	eax
	lea	eax, DWORD PTR _FirstLink$[ebp]
	push	eax
	push	esi
	call	_GetNextEntry@16
	cmp	al, 1
	je	SHORT $L8583

; 624  : 
; 625  : 		// Delete its linked list entry.
; 626  : 		if(Irp == Interrupt->Irp){

	jmp	SHORT $L8584
$L8747:

; 627  : 			FreeEntry(ObjExt, CurrentLink);

	call	_FreeEntry@8
$L8584:

; 632  : 	}
; 633  : 
; 634  : 	//IoReleaseCancelSpinLock (Irp->CancelIrql);
; 635  : 	Irp->IoStatus.Information = 0;

	and	DWORD PTR [edi+28], 0

; 636  : 	Irp->IoStatus.Status = STATUS_CANCELLED;
; 637  : 	IoCompleteRequest(Irp, IO_NO_INCREMENT) ;

	xor	dl, dl
	mov	ecx, edi
	mov	DWORD PTR [edi+24], -1073741536		; c0000120H
	call	DWORD PTR __imp_@IofCompleteRequest@8
	pop	edi
	pop	esi

; 638  : }

	leave
	ret	8
_PCIDPCancelInterrupt@8 ENDP
_TEXT	ENDS
PUBLIC	_PCIDPForDpcIsr@16
EXTRN	__imp_@InterlockedExchange@8:NEAR
;	COMDAT _PCIDPForDpcIsr@16
_TEXT	SEGMENT
_DeviceObject$ = 12
_RegisteredInt$ = 12
_CancelSpin$ = -12
_CurrentLink$ = -4
_FirstLink$ = -8
_PCIDPForDpcIsr@16 PROC NEAR				; COMDAT

; 650  : ){

	push	ebp
	mov	ebp, esp
	sub	esp, 12					; 0000000cH

; 651  : 	// Define variables.
; 652  : 	PPCIDP_EXTENSION ObjExt;
; 653  : 	PINTERRUPT_DATA IntData;
; 654  : 	PREGISTERED_INTERRUPT RegisteredInt;
; 655  : 	KIRQL CancelSpin;
; 656  : 	PLINKED_LIST CurrentLink;
; 657  : 	PLINKED_LIST FirstLink;
; 658  : 
; 659  : 	// Debug
; 660  : 	//PULONG MemoryBase;
; 661  : 
; 662  : 	// Initialize variables.
; 663  : 	ObjExt = (PPCIDP_EXTENSION)DeviceObject->DeviceExtension;

	mov	eax, DWORD PTR _DeviceObject$[ebp]
	push	esi
	mov	esi, DWORD PTR [eax+40]

; 664  : 	IntData = &ObjExt->InterruptData;
; 665  : 
; 666  : 
; 667  : 	// Debug
; 668  : 	//MemoryBase = ObjExt->MemoryBase;
; 669  : 	//MemoryBase[0x1C53]++;
; 670  : 
; 671  : 	//Service all of the recorded interrupts by checking to see if the interrupt 
; 672  : 	//type has been registered by the user.
; 673  : 	while(IntData->QueNew != IntData->QueNext){

	mov	al, BYTE PTR [esi+37]
	cmp	al, BYTE PTR [esi+36]
	je	$L8606
	push	ebx
	xor	ebx, ebx
$L8605:

; 674  : 
; 675  : 		// Debug
; 676  : 		//MemoryBase[0x1C54]++;
; 677  : 
; 678  : 		CurrentLink = NULL;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -