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

📄 entry.c

📁 一个类似与Windows环境下的softice的源代码
💻 C
📖 第 1 页 / 共 2 页
字号:
					{						DPRINT(PICE_DEBUG, DBT_ENTRY, DBL_INFO, "SKIP STEP: reinstalling INT3 @ %.4X:%.8X\n",OldFrame[GetProcessor()].cs,OldFrame[GetProcessor()].eip);						// puts the INT3 back in place						ReInstallSWBreakpointAtPreviousAddress(ulAddressCurrent);					}					ulSingleStepCondition &= ~SINGLE_STEP_CONDITION_BREAKPOINT_SKIP;				}				// need to reinstall breakpoint because a process page was paged-in				if(ulSingleStepCondition & SINGLE_STEP_CONDITION_BREAKPOINT_REINSTALL)				{					ulSingleStepCondition &= ~SINGLE_STEP_CONDITION_BREAKPOINT_REINSTALL;					DPRINT(PICE_DEBUG, DBT_ENTRY, DBL_INFO, "REINSTALL_STEP: coming from %.4X:%.8X\n",pFrame->cs,pFrame->eip);					// puts INT3 in the page back in place					ReInstallSWBreakpointsInPage(pFrame->eip);				}				// we came here while stepping through source code block				if(ulSingleStepCondition & SINGLE_STEP_CONDITION_BREAKPOINT_STEP_SOURCE)				{					ULONG ulLineNumber;					LPSTR pSrc,pFileName;					DPRINT(PICE_DEBUG, DBT_ENTRY, DBL_INFO, "stepping through source!\n");					ulSingleStepCondition &= ~SINGLE_STEP_CONDITION_BREAKPOINT_STEP_SOURCE;					// look up the corresponding source line					// if there isn't any or the source line number has changed					// we break back into the debugger					if(bShowSrc)						pSrc = FindSourceLineForAddress(ulAddressCurrent,&ulLineNumber,NULL,NULL,&pFileName);					else pSrc = NULL;					DPRINT(PICE_DEBUG, DBT_ENTRY, DBL_INFO, "line #%u pSrc=%x (old line #%u)\n",ulLineNumber,(ULONG)pSrc,g_ulLineNumberStart);					// if we have found a source line there					if(pSrc && ulLineNumber==g_ulLineNumberStart)					{						DPRINT(PICE_DEBUG, DBT_ENTRY, DBL_INFO, "stepping through line #%u in file = %s!\n",ulLineNumber,pFileName);						if(bStepInto)							StepInto(pFrame,NULL);						else							StepOver(pFrame,NULL);						goto common_return_point;					}					bNotifyToExit = FALSE; 					bDontEnterShell = FALSE;				}				// is it a real step				if(ulSingleStepCondition & SINGLE_STEP_CONDITION_SINGLE_STEP)				{					// we stepped in and there's a breakpoint at the current instruction					if(IsSwBpAtAddress(GetLinearAddress(pFrame->cs,pFrame->eip)))					{						// so, remove it						DeInstallSWBreakpoint(pFrame->eip);					}					ulSingleStepCondition &= ~SINGLE_STEP_CONDITION_SINGLE_STEP;					// enter shell					bDontEnterShell = FALSE;				}				if(ulSingleStepCondition & SINGLE_STEP_CONDITION_HOTKEY)				{					ulSingleStepCondition &= ~SINGLE_STEP_CONDITION_HOTKEY;					// enter shell					bDontEnterShell = FALSE;				}			}			break;        // HW breaks *************************************************************************        case REASON_HARDWARE_BP:			switch(HandleHardwareBreakPoint(pFrame))			{				case 1:					bDontEnterShell = FALSE;					break;			}	        break;        // embedded int 3s *******************************************************************        case REASON_INT3:			switch(HandleSoftwareBreakPoint(pFrame))			{				// it's a SW INT3, we'll single step over it and reinstall it next time				// OR its an permanent INT3, we don't break into the shell				case 0:					break;				// its an embedded INT3, we break into the shell				case 1:					bDontEnterShell = FALSE;					ulCallOldHandlerFlags = REASON_HOTKEY; // resume without calling old kernel handler									break;			}            break;        // HOTKEY ****************************************************************************        case REASON_HOTKEY:			HandleHotKey(pFrame);            break;        case REASON_DOUBLE_FAULT:            PICE_sprintf(tempEntry,"pICE: Breakpoint due to double fault at %.4X:%.8X\n",pFrame->cs,pFrame->eip); 		    Print(OUTPUT_WINDOW,tempEntry);             Print(OUTPUT_WINDOW,"pICE: !!! SYSTEM HALTED !!!\n");            bDontEnterShell = FALSE;			bDebuggerHaltState = TRUE;            break;        case REASON_GP_FAULT:			if(bHasFixup)			{				// skip the RDMSR instruction				pFrame->eip += 2;				pFrame->eax = 0xDEADBEEF;				pFrame->edx = 0xBAADF00D;				ulCallOldHandlerFlags = REASON_HOTKEY;				bHasFixup = FALSE;			}			else			{				HandleGeneralProtectionFault(pFrame);				bDontEnterShell = FALSE;			}            break;        case REASON_STACK_FAULT:            HandleStackFault(pFrame);            bDontEnterShell = FALSE;            break;        case REASON_DIVBYZERO_FAULT:            HandleDivideByZeroFault(pFrame);            bDontEnterShell = FALSE;            break;        case REASON_NMI:            HandleNmiFault(pFrame);            bDontEnterShell = FALSE;            break;        case REASON_NOT_PRESENT:            HandleNotPresentFault(pFrame);            bDontEnterShell = FALSE;            break;        case REASON_ALIGNMENT:			HandleAlignmentFault(pFrame);			break;        case REASON_BOOT_PARAMS:			ProcessBootParams(pFrame);			break;        case REASON_OTHER_CPU:			ProcessorsIdleLoop(pFrame);			break;        default:			InternalError(pFrame);            break;    }#ifdef ACTIVATE_DEBUGGER_SHELL             if(bDontEnterShell == FALSE)	{		// put all other processors into an endless loop		LoopProcessors();        DPRINT(PICE_DEBUG, DBT_ENTRY, DBL_INFO, "saving registers\n");        // save the extended regs	    __asm__ __volatile__	    (			"cli\n"            "pushl %eax\n"			"   movl %dr0,%eax \n"		    "   movl %eax,CurrentDR0\n"		    "   movl %dr1,%eax \n"		    "   movl %eax,CurrentDR1\n"		    "   movl %dr2,%eax \n"		    "   movl %eax,CurrentDR2\n"		    "   movl %dr3,%eax \n"		    "   movl %eax,CurrentDR3\n"		    "   movl %dr6,%eax \n"		    "   movl %eax,CurrentDR6\n"		    "   movl %dr7,%eax \n"		    "   movl %eax,CurrentDR7\n"		    "   movl %cr0,%eax \n"		    "   movl %eax,CurrentCR0\n"		    "   movl %cr2,%eax \n"		    "   movl %eax,CurrentCR2\n"		    "   movl %cr3,%eax \n"		    "   movl %eax,CurrentCR3\n"		    "   movl %cr4,%eax \n"		    "   movl %eax,CurrentCR4\n"            "popl %eax\n"	    );        DPRINT(PICE_DEBUG, DBT_ENTRY, DBL_INFO, "HandleEntry(): adding colon to output()\n");        Print(OUTPUT_WINDOW,":");        DPRINT(PICE_DEBUG, DBT_ENTRY, DBL_INFO, "HandleEntry(): calling DebuggerShell()\n");        DebuggerShell(pFrame);		// if there's a breakpoint at the current location,		// do a SKIP_STEP to reinstall it.		if(IsSwBpAtAddress(GetLinearAddress(pFrame->cs,pFrame->eip)))		{			pFrame->eflags |= TF_FLAG;			ulSingleStepCondition |= SINGLE_STEP_CONDITION_BREAKPOINT_SKIP;		}		// wake all other processors from endless loop		UnloopProcessors();	}#endif // #ifdef ACTIVATE_DEBUGGER_SHELL         common_return_point:    // reset the global flags     bNotifyToExit = FALSE; #if 0    // dump registers     DPRINT(PICE_DEBUG, DBT_ENTRY, DBL_INFO, "EFL     = %.8X\n",pFrame->eflags);    DPRINT(PICE_DEBUG, DBT_ENTRY, DBL_INFO, "CS:EIP  = %.4X:%.8X\n",pFrame->cs,pFrame->eip);    DPRINT(PICE_DEBUG, DBT_ENTRY, DBL_INFO, "ERR     = %.8X\n",pFrame->error_code);    DPRINT(PICE_DEBUG, DBT_ENTRY, DBL_INFO, "REA     = %.8X\n",pFrame->reason_code);    DPRINT(PICE_DEBUG, DBT_ENTRY, DBL_INFO, "EAX     = %.8X\n",pFrame->eax);    DPRINT(PICE_DEBUG, DBT_ENTRY, DBL_INFO, "EBX     = %.8X\n",pFrame->ebx);    DPRINT(PICE_DEBUG, DBT_ENTRY, DBL_INFO, "ECX     = %.8X\n",pFrame->ecx);    DPRINT(PICE_DEBUG, DBT_ENTRY, DBL_INFO, "EDX     = %.8X\n",pFrame->edx);    DPRINT(PICE_DEBUG, DBT_ENTRY, DBL_INFO, "EBP     = %.8X\n",pFrame->ebp);    DPRINT(PICE_DEBUG, DBT_ENTRY, DBL_INFO, "ESP     = %.8X\n",pFrame->esp);    DPRINT(PICE_DEBUG, DBT_ENTRY, DBL_INFO, "ESI     = %.8X\n",pFrame->esi);    DPRINT(PICE_DEBUG, DBT_ENTRY, DBL_INFO, "EDI     = %.8X\n",pFrame->edi);    DPRINT(PICE_DEBUG, DBT_ENTRY, DBL_INFO, "DS      = %.4X\n",pFrame->ds);    DPRINT(PICE_DEBUG, DBT_ENTRY, DBL_INFO, "ES      = %.4X\n",pFrame->es);    DPRINT(PICE_DEBUG, DBT_ENTRY, DBL_INFO, "FS      = %.4X\n",pFrame->fs);    DPRINT(PICE_DEBUG, DBT_ENTRY, DBL_INFO, "GS      = %.4X\n",pFrame->gs);#endif     DPRINT(PICE_DEBUG, DBT_ENTRY, DBL_INFO, "--------------------------------------------------returning %s --\n",szReasons[ulCallOldHandlerFlags]);    LEAVE_FUNC();    return ulCallOldHandlerFlags;}// EOF

⌨️ 快捷键说明

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