Implementation of the Simple Debugger (iii) perfecting the debugger

Source: Internet
Author: User

DLL loading:

Case Load_dll_debug_event:
Read The debugging information included in the newly
Loaded DLL. Be sure to close the handle to the loaded DLL
With CloseHandle.

This event occurs when a DLL is loaded

Dwcontinuestatus = Onloaddlldebugevent (DebugEvent);
Break

DWORD onloaddlldebugevent (const lpdebug_event DebugEvent)
{
We can get a handle to the DLL through Debugevent->u.loaddll.hfile

However, without the API directly from the Handle->path, code conversions are required

The specific method is easy to find, here is not introduced.

Getfilenamefromhandle (Debugevent->u.loaddll.hfile);

return dbg_continue;
}

Read Memory:

Read the memory API we have already introduced readprocessmemory.

Part of the code:

Address Read by Addr

Size = sizeof (BYTE)

void *lpbuff;

Lpbuff = malloc (Size);

size_t Bytesread;

for (i = 0; i <; i++)
{
if ((i% 8) = = 0)//Output 4 rows 8 columns
printf ("\n%x", Addr);
if (FALSE = = ReadProcessMemory (g_process, Addr, Lpbuff, Size, &bytesread))
{
printf ("??"); Read failure on output "?? "
}
Else
{
printf ("%.2x", * (byte*) lpbuff);
}
ADDR = Addr + Size;
}

Free (lpbuff);

Effect:

This chapter is about so much ... A soft breakpoint is explained in detail in the next section.

Implementation of the Simple Debugger (iii) perfecting the debugger

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.