3GL   4GL   5GL  

, " ", . , , , (stepping over) . , . , , (, Debug Break WDBG).

> . , , , ( ), , . Intel Pentium INT , , , . CPU, Intel Merced, , .

4-4 SetBreakpoint. , , DBG_* LOCALASSIST.DLL , WDBG . SetBreakpoint ( ), .

4-4. SetBreakepoint 1386CPUHELP.C

int CPUHELP_DLLINTERFACE _stdcall

SetBreakpoint ( PDEBUGPACKET dp ,

ULONG ulAddr ,

OPCODE * pOpCode ) 

{

DWORD dwReadWrite = 0;

BYTE bTempOp = BREAK_OPCODE;

BOOL bReadMem;

BOOL bWriteMem;

BOOL bFlush;

MEMORY_BASIC_INFORMATION mbi;

DWORD dwOldProtect;

ASSERT ( FALSE == IsBadReadPtr ( dp, sizeof ( DEBUGPACKET))) ;

 ASSERT ( FALSE == IsBadWritePtr ( pOpCode, sizeof ( OPCODE)));

 if ( ( TRUE == IsBadReadPtr ( dp, sizeof ( DEBUGPACKET))) ||

( TRUE == IsBadWritePtr ( pOpCode, sizeof ( OPCODE))) ) 

{

TRACE0 ( "SetBreakpoint : invalid parameters\n!");

return ( FALSE); 

}

// Windows 98

 // 2 , ,

 if ( ( FALSE = IsNT ()) && ( ulAddr >= 0x80000000))

 {

return ( FALSE); 

}

// .

 bReadMem = DBG_ReadProcessMemory ( dp->hProcess ,

(LPCVOID)ulAddr, SbTempOp , sizeof ( BYTE), SdwReadWrite ) ; 

ASSERT ( FALSE != bReadMem); 

ASSERT ( sizeof ( BYTE) = dwReadWrite);

 if ( ( FALSE = bReadMem ) ||

( sizeof ( BYTE) != dwReadWrite)) 

{

return ( FALSE); 

}

//  

// ?

 if ( BREAKJDPCODE = bTempOp)

{

return ( -1); 

}

// .

 DBG_VirtualQueryEx ( dp->hProcess  ,

(LPCVOID)ulAddr,

&mbi ,

 sizeof ( MEMORY_BASIC_INFORMATION) ); 

//  

// "- " ,

 if ( FALSE == DBG_VirtualProtectEx ( dp->hProcess ,

mbi.BaseAddress ,

 mbi.RegionSize , 

PAGE_EXECUTE_READWRITE, 

&mbi.Protect ) ) 

{

ASSERT ( ! "VirtualProtectEx .failed!!");

 return ( FALSE);

 }

// . 

*pOpCode = (void*)bTempOp; 

bm = BREAK_DPCODE; 

dwReadWrite = 0;

// ,

 // . 

bWriteMem = DBG_WriteProcessMemory ( dp->hProcess ,

(LPVOID)ulAddr , 

(LPVOID)SbTempOp,

 sizeof ( BYTE) , 

sdwReadWrite ); 

ASSERT ( FALSE != bWriteMem); 

ASSERT ( sizeof ( BYTE) == dwReadWrite);

if ( ( FALSE == bWriteMem ) ||

( sizeof ( BYTE) != dwReadWrite)) 

{

return ( FALSE); 

}

 // ,

//

// Change the protection back to what it was before

// I blasted thebreakpoint in.

VERIFY ( DBG_VirtualProtectEx ( dp->hProcess ,

mbi. BaseAddress, 

mbi.RegionSize ,

 mbi.Protect , 

SdwOldProtect ));

// , CPU

 bFlush = DBG_FlushInstructionCache ( dp->hProcess ,

(LPCVOID)ulAddr, 

sizeof ( BYTE) );

 ASSERT ( TRUE = bFlush);

 return ( TRUE);

 }

CPU , EXCEPTION_BREAKPOINT (0x80000003) - . , . . , , . , , , , , , , . , , . .

: , ? CPU , . CPU EXCEPTION_SINGLE_STEP (0x80000004). , CPU, 32- Windows, . Intel Pentium ( ) 8 . Intel Trap Rag (TF ). 4-5 Setsingiestep , TF. , , CPU .

4-5. SetSingleStep 1386CPUHELP.C

BOOL CPUHELP_DLLIMNTERFACE _stdcall 

SetSingleStep ( PDEBUGPACKET dp) 

{

BOOL bSetContext;

ASSERT ( FALSE == IsBadReadPtr ( dp, sizeof ( DEBUGPACKET)));

if ( TRUE = IsBadReadPtr ( dp, sizeof ( DEBUGPACKET)))

{

TRACED ( "SetSingleStep : invalid parameters\n!");

return ( FALSE);

}

// i386, TF-.

dp->context.EFlags |= TF_BIT;

bSetContext = DBG_SetThreadContext ( dp->hThread,

&dp->context);

ASSERT ( FALSE != bSetContext);

return ( bSetContext);

}

, ContinueDebugEvent, . , , . , "", . , . . , EXCEPTION_  SINGLE_STEP, TF, . , .

CWDBGProjDOC :: .-andieBreakpoint, WDBGPROJDOC.CPP -. BREAKPOINTS BREAKPOINT.CPP. , . WDBG Breakpoints , Visual C++. " " , . CBreakpointsDig::OnOk BREAKPOINTSDLG.CPP -.

, WDBG, Debug Break. , , .

, Debug Break, , WDBG. (one-shot) , , . . ,   CWDBGProj Doc: : OnDebugBreak WDBGPROJDOC.CPP, . 4-6 CWDBGProj Doc:: OnDebugBreak WDBGPROJDOC.CPP. " Step Into, Step Over u Step Out" .

4-5. Debug Breake WDBGPROJDOC.CPP

void CWDBGProjDoc :: OnDebugBreak ()

{

ASSERT ( m_vDbgThreads.size () > 0) ;

// ,

//

// . ,

// ,

// . ,

//

// , , "".

// , .

// ,

// :'

// 1. .

// 2. , ,

// Debug Break.

// 3. .

// 4. , .

// !

// 5. , "".

// 6.

//

// .

// 7. .

// 8. ,

//

// .

// ,

//

//

// .

HANDLE hThisThread = GetCurrentThread () ;

 int iOldPriority = GetThreadPriority ( hThisThread); 

SetThreadPriority ( hThisThread, THREAD_BASE_PRIORITY_LOWRT);

 HANDLE hProc = GetDebuggeeProcessHandle ();

 DBGTHREADVECT::iterator i; for ( i = m_vDbgThreads.begin ();

 i != m_vDbgThreads.end () ;

 i++ ) 

{

// .

// , , , .

//

// .

// .

DBG_SuspendThread ( i->m_hThread);

// , .

CONTEXT ctx;

ctx.ContextFlags = CONTEXT_FULL;

// , ASSERT,

// ,

// "" , if-

// .

if ( FALSE != DBG_GetThreadContext ( i->m_hThread, &ctx))

{

// ,

// . ,

// .

DWORD dwAddr = ReturnlnstructionPointer ( &ctx);

COneShotBP cBP;

// .

cBP.SetBreakpointLocation ( dwAddr);

// .

if ( TRUE == cBP.ArmBreakpoint ( hProc))

{

// Debug Break, 

//

 // .

 // ,

 // ,

 // . m_aDebugBreakBPs.Add ( cBP); 

}

 }

else 

{

TRACE ( "GetThreadContext failed! Last Error = Ox%08X\n",

 GetLastError ());

#ifdef _DEBUG

// GetThreadContext ,

 // , , .

 // , WDBG.

 // , WDBG  

// , DebugBreak

 //

 // , . DebugBreak ();

 #endif

}

 }

// .

 // .

 // .

 // ,  

// . ,

 // , .

// (ID) ,  

// WM_NULL. ,

 // , . 

// ,

 // , ,

 for ( i = m_vDbgThreads.begin () ;

 i!= m_vDbgThreads.end () ;

 i++ ) 

//

 //

. DBG_ResumeThread ( i->ro_hThread);

 PostThreadMessage ( i->m_dwTID, WM_NULL, 0, 0); 

}

// . 

SetThreadPriority ( hThisThread, iOldPriority); 

}

, "" CPU , . , API- suspendThread, . , API- GetThreadContext, . , . , API- ResumeThread, , .

, . , . , . , , , , , . , ,_MOUSEMOVE, .

, , . , , , API, , (HWND)? , . , , PostThreadMessage, . HWND- , PostThreadMessage , .

, ? , - , , , . , WM_CREATE, , . WM_NULL, , , . WM_NULL PostThreadMessage , , . , , .

. , , , ? , , , , , , , , , - . .

, . , . , , . , , . THREAD_BASE_PRIORITY_LOWRT, , , .

. , Debug Break , , . , , . , , , , . , ? , .

, , . ( Visual C+ 3 ), . Debug Break , , . , , . WDBG , GWDBGProjDoc::OnDebugBreak ( WDBGPROJDOC.CPP -). , , . , , WDBG.

        3GL   4GL   5GL  

, - . , , .




 10.11.2021 - 12:37: - Personalias -> WHO IS WHO - - _.
10.11.2021 - 12:36: - Conscience -> . ? - _.
10.11.2021 - 12:36: , , - Upbringing, Inlightening, Education -> ... - _.
10.11.2021 - 12:35: - Ecology -> - _.
10.11.2021 - 12:34: , - War, Politics and Science -> - _.
10.11.2021 - 12:34: , - War, Politics and Science -> . - _.
10.11.2021 - 12:34: , , - Upbringing, Inlightening, Education -> , - _.
10.11.2021 - 09:18: - New Technologies -> , 5G- - _.
10.11.2021 - 09:18: - Ecology -> - _.
10.11.2021 - 09:16: - Ecology -> - _.
10.11.2021 - 09:15: , , - Upbringing, Inlightening, Education -> - _.
10.11.2021 - 09:13: , , - Upbringing, Inlightening, Education -> - _.
Bourabai Research -  XXI Bourabai Research Institution