游戏开发论坛

 找回密码
 立即注册
搜索
查看: 1292|回复: 0

update 3ds max plugin without restarting 3ds max 2008

[复制链接]

414

主题

611

帖子

621

积分

高级会员

Rank: 4

积分
621
发表于 2009-2-18 11:03:00 | 显示全部楼层 |阅读模式
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:


  1. 0049CA49  push        0   
  2. 0049CA4B  call        ebp  
  3. 0049CA4D  push        eax  
  4. 0049CA4E  call        dword ptr ds:[7DFB68h]
  5. 0049CA54  mov         eax,dword ptr [edi]
  6. 0049CA56  mov         edx,dword ptr [eax] <===break here
  7. 0049CA58  mov         ebp,1
  8. 0049CA5D  push        ebp  
  9. 0049CA5E  mov         ecx,edi
  10. 0049CA60  call        edx
复制代码


The main plugin partial source code as below:



  1. int        maxProject1::DoExport(const TCHAR *name,ExpInterface *ei,Interface *i, BOOL suppressPrompts, DWORD options)
  2. {
  3.         typedef int (CALLBACK* D_MYEXPORT)(const TCHAR*,ExpInterface*,Interface*,BOOL,DWORD);

  4.         HMODULE l_mod;
  5.         D_MYEXPORT l_export=NULL;
  6.         int l_ret=0;

  7.         l_mod=LoadLibrary("plugins_akira\\2\\maxProject2.dll");

  8.         if (l_mod!=NULL)
  9.         {
  10.                 l_export=(D_MYEXPORT)GetProcAddress(l_mod,"fDoExport");
  11.                 l_ret=l_export(name,ei,i,suppressPrompts,options);

  12.                 FreeLibrary(l_mod);
  13.         }

  14.         return TRUE;//FALSE
  15. }
复制代码


The source code of another DLL for exporting data as below:



  1. #include "maxProject2.h"
  2. #include "resource.h"

  3. HINSTANCE g_hInstance;

  4. BOOL APIENTRY DllMain( HANDLE hModule,
  5.                                           DWORD  ul_reason_for_call,
  6.                                           LPVOID lpReserved
  7.                                           )
  8. {
  9.         // cache the DLL instance handle
  10.         g_hInstance = (HINSTANCE)hModule;

  11.         return TRUE;
  12. }

  13. ///////////////////////////////////////////////////////////////////////////////
  14. // Translate 3DS Data
  15. ///////////////////////////////////////////////////////////////////////////////


  16. static BOOL CALLBACK SettingDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
  17. {
  18.         //static maxProject2 *imp = NULL;

  19.         switch(msg) {
  20.                 case WM_INITDIALOG:
  21.                         //imp = (maxProject2 *)lParam;
  22.                         CenterWindow(hwnd,GetParent(hwnd));
  23.                         return TRUE;

  24.                 case WM_COMMAND:
  25.                         if (LOWORD(wParam)==IDCANCEL || LOWORD(wParam)==IDOK)
  26.                         {
  27.                                 EndDialog(hwnd, 0);
  28.                                 return TRUE;
  29.                         }
  30.                         break;

  31.                 case WM_CLOSE:
  32.                         EndDialog(hwnd, 0);
  33.                         return TRUE;

  34.                 default:
  35.                         return FALSE;
  36.         }
  37.        
  38.         return TRUE;
  39. }

  40. /**
  41. Receive Data from 3DS Plugin
  42. */
  43. extern "C" __declspec(dllexport) int fDoExport(const TCHAR *name,
  44.                                                                                            ExpInterface *ei,
  45.                                                                                            Interface *i,
  46.                                                                                            BOOL suppressPrompts,
  47.                                                                                            DWORD options)
  48. {
  49.         // Show Setting Dialog
  50.         //HWND mother=i->GetMAXHWnd();
  51.         if(DialogBoxParam(g_hInstance, MAKEINTRESOURCE(IDD_SETTING), GetActiveWindow(), SettingDlgProc, NULL) == TRUE) {
  52.                 //Do Data Export
  53.         }
  54.         else
  55.         {
  56.                 // No Data Export
  57.         }

  58.         return TRUE;
  59. }
复制代码


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"

sf_20092181133.zip

55.65 KB, 下载次数:

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

作品发布|文章投稿|广告合作|关于本站|游戏开发论坛 ( 闽ICP备17032699号-3 )

GMT+8, 2026-1-20 07:42

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表