Debugging data breakpoint

xiaoxiao2021-03-06  51

In the morning, the brother has encountered a question, and he implemented a dialog with the dynamic link library. This dialog contains the VC's Grid control. When testing the test program, the dialog will not play! After removing the Grid control, it will run normal. ! Below is the function of exporting the dialog box in the DLL:

Void GEOADD_EXPORT DATAGRID (CWND * PWND)

{

AFX_MANAGE_STATE (AFXGETSTATICModuleState ()); // (1)

CDataGriddlg DLG;

Dlg.domodal (); (2)

}

(1) Already added, it is not the problem it has not been added. Follow (2). Found in Bool CWnd :: CreatedlGindirect (LPCDLGTEMPLATE LPDIALOGIRECT (LPCDLGTEMPLATE LPDIALOGTEMPLATE, CWND * PPARENTWND, HINSTANCE HINST) Function:

IF (hwnd! = null &&! (m_nflags & wf_continuemodal))

{

: DestroyWindow (HWND);

HWND = NULL;

}

The program will run this piece to destroy the dialog box! The dialog is killed here! If this condition statement is definitely not empty, there is a problem with m_nflags. It is equal to WF_OLECTLCONTAINER, which seems to be right! From the front side, found in hwnd = :: create, pParentWnd-> getSafehWnd (), AFXDLGPROC; M_nFlags. Where is it? m_nflags is a member variable, which will not change after initialization. This makes it convenient for us to set up data breakpoints. Enter: & m_nflags getting its memory address, click Edit-> BreakPoints-> Data, entered in the text box above: * (INT *) 0x111111), 0x111111 is the memory address you just got, when the program Trying to change m_nflags, it will be broken! Find the statement that appears! AFX_Static HRESULT AFXAPI _AFXCOCREATEINSTANCELIC (Refclsid CLSID, LPUNKNOWN PUNKOUTER, DWORD DWCLSCTX, REFIID, LPVOID * PPV, BSTR BSTR BSTR BSTR BSTRBEY):

IF (ac = cogetclassobject (CLSID, DWCLSCTX, NULL,

IID_ICLASSFAACTORY, (VOID **) & PCLASSFAACTORY))))))))

{

Assert (pclassfactory! = Null);

HR = PCLASSFAACTORY-> CREATEINSTANCE (Punkouter, IID, PPV);

PCLASSFAACTORY-> Release ();

}

COGETCLASSOBJECT failed, returned to HR equal to 0x800401F0. Take MSDN to check it, saying that is coinitialize (), no call. Plus, solve it! !

In addition, the output window output information is not very compliant, he said that the control is not registered! It seems that you can't fully believe in the output of MFC!

转载请注明原文地址:https://www.9cbs.com/read-117059.html

New Post(0)