|
|
I read a chinese book called "全方位3D??蛟O? ??蛞?媾c??蜷_???例剖析"(http://tlsj.tenlong.com.tw/WebModule/BookSearch/bookSearchViewAction.do?isbn=9861256806&sid=28330). In this book's section 10-4-7, it support a skill about run the modified plugin (export) without restarting 3ds max 2008. Divide the origin 3ds max plugin into main plugin and the function for exporting(to e anothor DLL). When 3ds max start and load the main plugin, the main plugin will load the another DLL has only exporting function and DllMain. I test the moethod and the flow is correct. But I have a serious problem when the main plugin ends, the 3ds max 2008 will crack and show the exception likes the picture(http://cid-fbeb6373d9321a7f.skydrive.live.com/self.aspx/Questions/3ds%20max%20two%20plugin%20error.JPG). And break in assemble code as below:
- 0049CA49 push 0
- 0049CA4B call ebp
- 0049CA4D push eax
- 0049CA4E call dword ptr ds:[7DFB68h]
- 0049CA54 mov eax,dword ptr [edi]
- 0049CA56 mov edx,dword ptr [eax] <===break here
- 0049CA58 mov ebp,1
- 0049CA5D push ebp
- 0049CA5E mov ecx,edi
- 0049CA60 call edx
复制代码
The main plugin partial source code as below:
- int maxProject1::DoExport(const TCHAR *name,ExpInterface *ei,Interface *i, BOOL suppressPrompts, DWORD options)
- {
- typedef int (CALLBACK* D_MYEXPORT)(const TCHAR*,ExpInterface*,Interface*,BOOL,DWORD);
- HMODULE l_mod;
- D_MYEXPORT l_export=NULL;
- int l_ret=0;
- l_mod=LoadLibrary("plugins_akira\\2\\maxProject2.dll");
- if (l_mod!=NULL)
- {
- l_export=(D_MYEXPORT)GetProcAddress(l_mod,"fDoExport");
- l_ret=l_export(name,ei,i,suppressPrompts,options);
- FreeLibrary(l_mod);
- }
- return TRUE;//FALSE
- }
复制代码
The source code of another DLL for exporting data as below:
- #include "maxProject2.h"
- #include "resource.h"
- HINSTANCE g_hInstance;
- BOOL APIENTRY DllMain( HANDLE hModule,
- DWORD ul_reason_for_call,
- LPVOID lpReserved
- )
- {
- // cache the DLL instance handle
- g_hInstance = (HINSTANCE)hModule;
- return TRUE;
- }
- ///////////////////////////////////////////////////////////////////////////////
- // Translate 3DS Data
- ///////////////////////////////////////////////////////////////////////////////
- static BOOL CALLBACK SettingDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
- {
- //static maxProject2 *imp = NULL;
- switch(msg) {
- case WM_INITDIALOG:
- //imp = (maxProject2 *)lParam;
- CenterWindow(hwnd,GetParent(hwnd));
- return TRUE;
- case WM_COMMAND:
- if (LOWORD(wParam)==IDCANCEL || LOWORD(wParam)==IDOK)
- {
- EndDialog(hwnd, 0);
- return TRUE;
- }
- break;
- case WM_CLOSE:
- EndDialog(hwnd, 0);
- return TRUE;
- default:
- return FALSE;
- }
-
- return TRUE;
- }
- /**
- Receive Data from 3DS Plugin
- */
- extern "C" __declspec(dllexport) int fDoExport(const TCHAR *name,
- ExpInterface *ei,
- Interface *i,
- BOOL suppressPrompts,
- DWORD options)
- {
- // Show Setting Dialog
- //HWND mother=i->GetMAXHWnd();
- if(DialogBoxParam(g_hInstance, MAKEINTRESOURCE(IDD_SETTING), GetActiveWindow(), SettingDlgProc, NULL) == TRUE) {
- //Do Data Export
- }
- else
- {
- // No Data Export
- }
- return TRUE;
- }
复制代码
Colud somebody meet the same problem or has the solution? Or another better method?
PS:
I put my source code about the two plugin in the website of "http://cid-fbeb6373d9321a7f.skydrive.live.com/self.aspx/Questions/3ds%20max%20Plugin%20Two%20Project%20Q1.zip" |
|