typedef struct1* (*myfunc1)(int param1, char * param2);
typedef struct1* (*myfunc1)(int param1, char * param2); ...myfunc1 func1 = (myfunc1)QLibrary::resolve("my.dll","myfunc1");
myclass *cls = (myclass*)QLibrary::resolve("my.dll","myclass::myclass");
void (SomeClass::*my_constructorc_ptr)(int, char*) = QLibrary::resolve("my.dll","void SomeClass::SomeClass(int, char*)");
... unresolved "myfunc1@8" ...
myfunc1
myfunc1@8
myfunc1@8 = myfunc1
@TMapAccess@$bctr@qv
QLibrary lib("mapacces"); QStringList lst; lst << "@TMapAccess@$bctr$qv"; lst << "TMapAccess::bctr"; lst << "TMapAccess.bctr"; lst << "TMapAccess@$bctr"; lst << "@TMapAccess@ctr@qv"; lst << "@TMapAccess@$bctr@qv"; lst << "TMapAccess@$bctr@qv"; lst << "@TMapAccess@ctr"; lst << "@TMapAccess::ctr"; lst << "TMapAccess@ctr"; lst << "TMapAccess::ctr"; for (int i =0; i<lst.size(); i++){ TMapAccess_constructor map_constr = (TMapAccess_constructor)lib.resolve(lst[i].toAscii().constData()); if (map_constr){ QMessageBox::warning(0,"GOOD",QString("Here is function! %1").arg(i)); return; } } QMessageBox::warning(0,"BAD","There is no function!");
@TMapAccess@$bctr$qv
segmentation faultin mapacces!@TMapControl@ShowBlockRstDevice$qqrr4TRmf
SomeClass *x = (SomeClass*)malloc( sizeof(SomeClass) );//new некатит т к компилер не может самостоятельно вызвать конструктор(x->*my_constructor_ptr)(6, "Another arbitrary parameter");//память есть, явн овызываем конструктор.
//typedef TMapAccess* (TMapAccess::*TMapAccess_ptr)(TMapAccess*);//typedef void (TMapAccess::*TMapAccess_ptr)(TMapAccess*);typedef void (TMapAccess::*TMapAccess_ptr)();//typedef TMapAccess* (TMapAccess::*TMapAccess_ptr)();...TMapAccess* map = (TMapAccess*)malloc(sizeof(TMapAccess));map->*TMapAccess_ptr(); // указатель на функцию-то не установлен!
TMapAccess_ptr = (TMapAccess_ptr)lib.resolve("@TMapAccess@$bctr$qv");
1: typedef void (TMapAccess::*TMapAccess_ptr)();...2: TMapAccess* map = new TMapAccess();3: TMapAccess_ptr = &TMapAccess::TMapAccess;4: map->*TMapAccess_ptr();
error: expected primary-expression before '=' token error: expected primary-expression before ';' token
1: typedef void (TMapAccess::*TMapAccess_ptrTYPE)();...2: TMapAccess* map = (TMapAccess*)malloc(sizeof(TMapAccess));3: TMapAccess_ptrTYPE TMapAccess_ptr = (TMapAccess_ptrTYPE)lib.resolve("@TMapAccess@$bctr$qv"); 4: map->*TMapAccess_ptr();
3: error: cannot convert `(&lib)->QLibrary::resolve(((const char*)"@TMapAccess@$bctr$qv"))' from type `void*' to type `void (TMapAccess::*)()'4: error: must use .* or ->* to call pointer-to-member function in `TMapAccess_ptr (...)'
typedef void (*TMapAccess_constr_type)(void* map);typedef int (*TMapAccess_OpenMap_type)(void* map, const char * mapname, int mode);...class TMyMapAccess: public QObject{ Q_OBJECTpublic: TMyMapAccess(QObject * parent = 0);...private: QLibrary lib; void *map;// TMapAccess *map;}TMyMapAccess::TMyMapAccess(QObject * parent) : QObject(parent){ lib.setFileName("mapacces"); lib.load(); map = malloc(129040 /*sizeof(TMapAccess)*/ ); TMapAccess_constr_type map_constr = (TMapAccess_constr_type)lib.resolve(TMapAccess_constr_type_str); if (!map_constr) { QMessageBox::critical(0,"TMyMapAccess error!","Can't load TMapAccess constructor!"); return; } map_constr(map);}int TMyMapAccess::OpenMap(const char * mapname, int mode){ TMapAccess_OpenMap_type map_OpenMap = (TMapAccess_OpenMap_type)lib.resolve(TMapAccess_OpenMap_type_str); if (!map_OpenMap) { QMessageBox::critical(0,"TMyMapAccess error!","Can't load TMapAccess constructor!"); } return map_OpenMap(map,mapname,mode);}
typedef void (*method_ptr)(void*, int);method_ptr myPtr = resolve("MyClasssomeMethod");MyClass *instancePtr;myPtr(instancePtr,1);//Внимание, ключевое место
MyClass instance;instance.someMethod(1);//Внимание, ключевое место