DLLModule Class Reference

#include <WinDLLTool.h>

List of all members.

Public Member Functions

 DLLModule (LPCTSTR fname, int n)
 DLLModule ()
virtual ~DLLModule ()
void init (LPCTSTR fname, int n)
void free ()
char * get_info (int n=0)
BOOL set_funcname (LPCTSTR fname, int n)
BOOL get_module_info (tList *lp)
void * get_funcptr (int n)

Public Attributes

int status
int fnum
char * title
CString dllname
CString filename
CString funcname
HMODULE hmod

Protected Attributes

FUNC_STRING pgetinfo
void ** pfunc

Friends

class DLLModuleTBL

Detailed Description

Definition at line 53 of file WinDLLTool.h.


Constructor & Destructor Documentation

DLLModule ( LPCTSTR  fname,
int  n 
) [inline]

Definition at line 71 of file WinDLLTool.h.

References DLLModule::init().

00071 { init(fname, n);}

Here is the call graph for this function:

DLLModule (  )  [inline]

Definition at line 72 of file WinDLLTool.h.

References DLLModule::init().

00072 { init(NULL, 0);}

Here is the call graph for this function:

virtual ~DLLModule (  )  [inline, virtual]

Definition at line 73 of file WinDLLTool.h.

References DLLModule::free().

00073 { free();}

Here is the call graph for this function:


Member Function Documentation

void free ( void   ) 

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

Definition at line 53 of file WinDLLTool.cpp.

References DLLModule::fnum, DLLModule::hmod, DLLModule::pfunc, DLLModule::pgetinfo, and DLLModule::status.

Referenced by DLLModuleTBL::free(), DLLModule::get_module_info(), DLLModule::set_funcname(), and DLLModule::~DLLModule().

00054 {
00055     status = 0;
00056 
00057     hmod = NULL;
00058     pgetinfo = NULL;
00059     if (fnum>0 && pfunc!=NULL) ::free(pfunc);
00060     fnum = 0;
00061     pfunc = NULL;
00062 }

Here is the caller graph for this function:

void * get_funcptr ( int  n  ) 

機能:DLL中の n番目の関数へのポインタを得る.関数の型は外部で決める

引数:求める関数の番号.0 〜 fnum-1

戻り値:関数へのポインタ.

Definition at line 148 of file WinDLLTool.cpp.

References DLLModule::fnum, DLLModule::pfunc, and DLLModule::status.

00149 {   
00150     if (status<=0) return NULL;
00151 
00152     if (n>=fnum) n = 0;
00153     return pfunc[n];
00154 }

char* get_info ( int  n = 0  )  [inline]

Definition at line 77 of file WinDLLTool.h.

References DLLModule::pgetinfo.

00077 { if (pgetinfo==NULL) return NULL; return (*pgetinfo)(n);}

BOOL get_module_info ( tList *  lp  ) 

機能:モジュールの一覧を格納したリストlp から,モジュール(一つだけ)の情報を獲得する. 関数名fname で示した関数 fname(0) からタイトル名を取得する. fname(1) 〜 fname(fnum-1) からは使用できる関数名を得る.使用できる関数の型は, 外部で決める.

引数:lp -- モジュールの情報が入ったリストへのポインタ. lp->ldat.key : DLL名 lp->ldat.val : DLLファイル名(ディレクトリを含む) lp->ldat.ptr : モジュールハンドラ

戻り値:TRUE -- 正常に情報を取得. FALSE -- 情報取得関数から,正しい情報を読み取れない.

Definition at line 108 of file WinDLLTool.cpp.

References DLLModule::dllname, DLLModule::filename, DLLModule::fnum, DLLModule::free(), DLLModule::funcname, DLLModule::hmod, jbxwl::mbs2ts(), DLLModule::pfunc, DLLModule::pgetinfo, DLLModule::status, DLLModule::title, and jbxwl::ts2mbs().

Referenced by DLLModuleTBL::make_module_tbl().

00109 {
00110     if (lp==NULL) return FALSE;
00111     if (funcname==_T("")) return FALSE;
00112 
00113     status   = 0;
00114     hmod = (HMODULE)(lp->ldat.ptr);
00115     char* mbstr = ts2mbs(funcname);
00116     pgetinfo = (FUNC_STRING)GetProcAddress(hmod, mbstr);
00117     ::free(mbstr);
00118     if (pgetinfo==NULL) return FALSE;
00119     
00120     dllname  = mbs2ts((char*)(lp->ldat.key.buf));
00121     filename = mbs2ts((char*)(lp->ldat.val.buf));
00122     title    = (*pgetinfo)(0);
00123 
00124     pfunc[0] = (void*)pgetinfo;
00125     for (int i=1; i<fnum; i++) {
00126         char* nfn = (*pgetinfo)(i);
00127         void* pfn = (void*)GetProcAddress(hmod, nfn);
00128         pfunc[i] = pfn;
00129         //if (pfn==NULL) {
00130         //  status = -1;
00131         //  return FALSE;
00132         //}
00133     }
00134 
00135     status = 1;
00136     return TRUE;
00137 }

Here is the call graph for this function:

Here is the caller graph for this function:

void init ( LPCTSTR  fname,
int  n 
)

機能:クラスの初期化.fnameに NULL または nに 0以下を指定した場合は set_funcname() で改めて指定しなければならない.

引数:fname -- 読み込むDLL中の情報取得関数の名前 n -- 読み込むDLL中の使用できる関数の数

Definition at line 30 of file WinDLLTool.cpp.

References DLLModule::dllname, DLLModule::filename, DLLModule::fnum, DLLModule::funcname, DLLModule::hmod, DLLModule::pfunc, DLLModule::pgetinfo, DLLModule::status, and DLLModule::title.

Referenced by DLLModule::DLLModule().

00031 {
00032     status = 0;
00033     fnum   = n;
00034     
00035     title    = NULL;
00036     dllname  = _T("");
00037     filename = _T("");
00038 
00039     if (fname!=NULL) funcname = fname;
00040     else             funcname = _T("");
00041     
00042     hmod     = NULL;
00043     pgetinfo = NULL;
00044     pfunc    = NULL;
00045     if (fnum>0) pfunc = (void**)malloc(sizeof(void*)*fnum);
00046 }

Here is the caller graph for this function:

BOOL set_funcname ( LPCTSTR  fname,
int  n 
)

機能:DLL中の情報取得関数の名前と,使用できる関数の数を指定する. fnameに NULL または nに 0以下を指定した場合,改めて指定しなければならない.

引数:fname -- 読み込むDLL中の情報取得関数の名前 n -- 読み込むDLL中の使用できる関数の数

戻り値:TRUE -- 指定は完了した. FALSE -- 指定は完了していない.続行は保障されない.

Definition at line 76 of file WinDLLTool.cpp.

References DLLModule::fnum, DLLModule::free(), DLLModule::funcname, and DLLModule::pfunc.

00077 {
00078     if (fname!=NULL) funcname = fname;
00079     else             funcname = _T("");
00080     
00081     if (fnum>0 && pfunc!=NULL) ::free(pfunc);
00082     pfunc = NULL;
00083 
00084     fnum = n;
00085     if (fnum>0) pfunc = (void**)malloc(sizeof(void*)*fnum);
00086 
00087     if (fname==NULL || n<=0) return FALSE;
00088     return TRUE;
00089 }

Here is the call graph for this function:


Friends And Related Function Documentation

friend class DLLModuleTBL [friend]

Definition at line 83 of file WinDLLTool.h.


Member Data Documentation

CString dllname

Definition at line 60 of file WinDLLTool.h.

Referenced by DLLModule::get_module_info(), and DLLModule::init().

CString filename

Definition at line 61 of file WinDLLTool.h.

Referenced by DLLModule::get_module_info(), and DLLModule::init().

int fnum
CString funcname
HMODULE hmod

Definition at line 64 of file WinDLLTool.h.

Referenced by DLLModule::free(), DLLModule::get_module_info(), and DLLModule::init().

void** pfunc [protected]
FUNC_STRING pgetinfo [protected]
int status
char* title

Definition at line 59 of file WinDLLTool.h.

Referenced by DLLModule::get_module_info(), and DLLModule::init().


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