DLLModuleTBL Class Reference

#include <WinDLLTool.h>

Collaboration diagram for DLLModuleTBL:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 DLLModuleTBL (LPCTSTR dirn)
 DLLModuleTBL ()
virtual ~DLLModuleTBL ()
void init (LPCTSTR dirn=NULL)
void free ()
BOOL load_module (LPCTSTR dirn=NULL)
void make_module_tbl (LPCTSTR fname, int n)

Public Attributes

int vnum
DLLModule ** dllmod
bool loaded

Protected Member Functions

tList * get_dir_module (LPCTSTR dirn)
virtual DLLModulenew_module (LPCTSTR fname, int n)
virtual void set_module_function ()

Protected Attributes

int tnum
tList * lp
CString dirname

Detailed Description

Definition at line 91 of file WinDLLTool.h.


Constructor & Destructor Documentation

DLLModuleTBL ( LPCTSTR  dirn  )  [inline]

Definition at line 105 of file WinDLLTool.h.

References DLLModuleTBL::init().

00105 { init(dirn);}

Here is the call graph for this function:

DLLModuleTBL (  )  [inline]

Definition at line 106 of file WinDLLTool.h.

References DLLModuleTBL::init().

00106 { init(NULL);}

Here is the call graph for this function:

virtual ~DLLModuleTBL (  )  [inline, virtual]

Definition at line 107 of file WinDLLTool.h.

References DLLModuleTBL::free().

00107 { free();}

Here is the call graph for this function:


Member Function Documentation

void free ( void   ) 

機能:クラス中のデータを解放する.

Definition at line 186 of file WinDLLTool.cpp.

References DLLModuleTBL::dllmod, DLLModule::free(), DLLModuleTBL::loaded, DLLModuleTBL::lp, DLLModuleTBL::tnum, and DLLModuleTBL::vnum.

Referenced by DLLModuleTBL::~DLLModuleTBL().

00187 {
00188     
00189     if (dllmod!=NULL) {
00190         for (int i=0; i<vnum; i++) {
00191             if (dllmod[i]!=NULL) {
00192                 dllmod[i]->free();
00193                 delete(dllmod[i]);
00194                 dllmod[i] = NULL;
00195             }
00196         }
00197     }
00198 
00199     tList* lt = lp;
00200     while (lt!=NULL) {
00201         if (lt->ldat.ptr!=NULL) {
00202             FreeLibrary((HMODULE)(lt->ldat.ptr));       // 関数へのハンドル
00203             lt->ldat.ptr = NULL;
00204             lt->ldat.sz  = 0;
00205         }
00206         lt = lt->next;
00207     }
00208     del_all_tList(&lp); 
00209 
00210     tnum = vnum = 0;
00211     if (dllmod!=NULL) ::free(dllmod);
00212     dllmod = NULL;
00213     loaded = false;
00214 }

Here is the call graph for this function:

Here is the caller graph for this function:

tList * get_dir_module ( LPCTSTR  dirn  )  [protected]

機能:ディレクトリ dirn にあるファイルを検索して,DLLファイルなら読み込みを行いリストに格納する. DLLのチェックは行わない.

引数:dirn -- 読み込むDLLがあるディレクトリ.通常はアプリケーションからの相対パス. NULL の場合は,読み込みを行わない.

戻り値:情報を格納したリストへのポインタ.エラーの場合は NULL. lp->ldat.key.buf : DLL名 lp->ldat.val.buf : DLLファイル名(ディレクトリを含む) lp->ldat.ptr : モジュールハンドラ

Definition at line 261 of file WinDLLTool.cpp.

References jbxwl::get_dir_files_t(), and jbxwl::mbs2ts().

Referenced by DLLModuleTBL::load_module().

00262 {
00263     tList* lm;
00264     tList* lt;
00265 
00266     if (dirn==NULL) return NULL;
00267     lm = lt = get_dir_files_t(dirn);
00268     if (lm==NULL) return NULL;
00269 
00270     while (lt!=NULL) {
00271         HMODULE hmod = LoadLibrary((LPCTSTR)mbs2ts((char*)(lt->ldat.val.buf)));
00272         lt->ldat.ptr = (void*)hmod;
00273         char* fn = get_file_name((char*)(lt->ldat.val.buf));
00274         lt->ldat.key = make_Buffer_bystr(fn);
00275         lt = lt->next;
00276     }
00277 
00278     // ハンドラが NULLの場合は削除
00279     lt = lm;
00280     while (lt!=NULL) {
00281         if (lt->ldat.ptr==NULL) {
00282             tList* ln = lt;
00283             if (lm==lt) lm = lt->next;
00284             lt = lt->next;
00285             del_tList_node(&ln);
00286         }
00287         else lt = lt->next;
00288     }
00289 
00290     return lm;
00291 }

Here is the call graph for this function:

Here is the caller graph for this function:

void init ( LPCTSTR  dirn = NULL  ) 

機能:クラスの初期化.ディレクトリdirnにある DLLを自動的に読み込む. dirn に NULLを指定した場合は DLLを読み込まないので,load_module() を改めて実行しなければならない.

引数:dirn -- 読み込むDLLがあるディレクトリ.通常はアプリケーションからの相対パス.

Definition at line 170 of file WinDLLTool.cpp.

References DLLModuleTBL::dirname, DLLModuleTBL::dllmod, DLLModuleTBL::load_module(), DLLModuleTBL::loaded, DLLModuleTBL::lp, DLLModuleTBL::tnum, and DLLModuleTBL::vnum.

Referenced by DLLModuleTBL::DLLModuleTBL().

00171 {   
00172     tnum = vnum = 0;
00173     loaded  = false;
00174     lp      = NULL;
00175     dllmod  = NULL;
00176     dirname = _T("");
00177     
00178     if (dirn!=NULL) load_module(dirn);
00179 }

Here is the call graph for this function:

Here is the caller graph for this function:

BOOL load_module ( LPCTSTR  dirn = NULL  ) 

機能:ディレクトリdirnにある DLLを読み込む.DLLのチェック(使用できるものかどうか)は行わない. dirn に NULLを指定した場合は カレントディレクトリのDLLを読み込む.

引数:dirn -- 読み込むDLLがあるディレクトリ.通常はアプリケーションからの相対パス. NULL の場合は,カレント "."を指定したことになる.

戻り値:TRUE -- 読み込み完了.tnum に読み込んだDLLの数が入る. FLASE -- DLLは存在しない.または読み込み失敗.

Definition at line 228 of file WinDLLTool.cpp.

References DLLModuleTBL::dirname, DLLModuleTBL::get_dir_module(), DLLModuleTBL::loaded, DLLModuleTBL::lp, and DLLModuleTBL::tnum.

Referenced by DLLModuleTBL::init().

00229 {
00230     if (dirn!=NULL) dirname = dirn;
00231     else            dirname = _T(".");
00232 
00233     lp = get_dir_module((LPCTSTR)dirname);
00234     if (lp==NULL) return FALSE;
00235 
00236     tnum = 0;
00237     tList* lt = lp;
00238     while (lt!=NULL) {
00239         tnum++;
00240         lt = lt->next;
00241     }
00242     loaded = true;
00243 
00244     return TRUE;
00245 }

Here is the call graph for this function:

Here is the caller graph for this function:

void make_module_tbl ( LPCTSTR  fname,
int  m 
)

機能:モジュールの一覧を格納したリストlp から,モジュールテーブル(配列)を作成する. 関数名fname で示した関数 fname(0) からタイトル名が獲得できない場合は,テーブル から削除する.

引数:fname -- モジュールの情報を返す関数名.引数 (int)0 でタイトル(char*)を返えさなければならない. m -- 読み込むDLL中の使用できる関数の数

Definition at line 303 of file WinDLLTool.cpp.

References DLLModuleTBL::dllmod, DLLModule::get_module_info(), DLLModuleTBL::lp, DLLModuleTBL::new_module(), DLLModuleTBL::set_module_function(), DLLModuleTBL::tnum, and DLLModuleTBL::vnum.

00304 {
00305     tList* lm = lp;
00306 
00307     vnum = 0;
00308     if (fname==NULL) return;
00309 
00310     dllmod = (DLLModule**)malloc(sizeof(DLLModule*)*tnum);
00311     if (dllmod==NULL) return;
00312 
00313     int n = 0;
00314     if (m<=0) m = 1;
00315     while (lm!=NULL) {
00316         dllmod[n] = this->new_module(fname, m); 
00317         int ret = dllmod[n]->get_module_info(lm);
00318         if (ret) {
00319             n++;
00320             if (n>=tnum) break;
00321         }
00322         else {
00323             delete(dllmod[n]);
00324             dllmod[n] = NULL;
00325         }
00326         lm = lm->next;
00327     }
00328     vnum = n;
00329 
00330     this->set_module_function();
00331     return;
00332 }

Here is the call graph for this function:

virtual DLLModule* new_module ( LPCTSTR  fname,
int  n 
) [inline, protected, virtual]

Definition at line 118 of file WinDLLTool.h.

Referenced by DLLModuleTBL::make_module_tbl().

00118 { return new DLLModule(fname, n);} 

Here is the caller graph for this function:

virtual void set_module_function (  )  [inline, protected, virtual]

Definition at line 119 of file WinDLLTool.h.

Referenced by DLLModuleTBL::make_module_tbl().

00119 {}

Here is the caller graph for this function:


Member Data Documentation

CString dirname [protected]

Definition at line 102 of file WinDLLTool.h.

Referenced by DLLModuleTBL::init(), and DLLModuleTBL::load_module().

bool loaded

Definition at line 97 of file WinDLLTool.h.

Referenced by DLLModuleTBL::free(), DLLModuleTBL::init(), and DLLModuleTBL::load_module().

tList* lp [protected]
int tnum [protected]
int vnum

The documentation for this class was generated from the following files:

Generated on 15 Nov 2023 for JunkBox_Win_Lib by  doxygen 1.6.1