I have a MFC form button with a PNG image and can be used normally, but I want to get this form into a DLL, into other process out of the question inside, crash and how this is? Have the source code under the ace to help me to solve, check the along while also didn't find out what reason
QQ 271072330
CodePudding user response:
Collapsed in the pop-up dialog box, press the corresponding button to enter debugging press Alt + 7 key to view the Call Stack, namely "the Call Stack" from the inside to the following out of from the inner to outer function Call history, double-click a row to the cursor to the Call of the source code or assembly instruction, don't understand when double click on the next line, until we can read ,Reference WinAPIOverride32 source code
CodePudding user response:
Then you add button program compiled into a DLL file call breakpoint and see where I went wrong specific to which line with miss zhao methodCodePudding user response:
Is likely to be unable to find picture resources lead to the failure load,You need to specify the resources for the image from the current module
CodePudding user response:
DLL injection, can't see the debug informationCodePudding user response:
Write the log is attached to the process that can debug,CodePudding user response:
To add the log information outputCodePudding user response:
DLL have the source code, can use the breaking process of debugging and DLL source codeCodePudding user response:
If resources use void AfxSetResourceHandle (HINSTANCE hInstResource);CodePudding user response:
By default, the MFC USES the resource handle of the main application to load the resource template. If you have an exported function in a DLL, to as one that launches a dialog box in the DLL, this template is later stored in the DLL module . You need to switch the module state for the correct handle to be 2. You can do this by adding the following code to the beginning of the function:AFX_MANAGE_STATE (AfxGetStaticModuleState ());
CodePudding user response:
In the DLL call dialogUse the SHARE DLL template
Create a dialog class
Then
Char * _stdcall MSG (char * words, CWnd * CWnd)
{
AFX_MANAGE_STATE (AfxGetStaticModuleState ());
MyDialog dialog.
Dialog. DoModal ();//modal dialog
//CDialog * dialog=new CDialog;//the modal dialog
//dialogCreate (IDD_DIALOG1);//note that Dll call, with only one parameter, specific I also don't know
//dialog. ShowWindow (SW_SHOW);
Return "buffer";
}
CodePudding user response:
Write the log information, this is the most simple and clear,,,