mirror of
https://github.com/HIllya51/LunaHook.git
synced 2024-11-30 17:15:38 +08:00
Update QtLoader_inline.cpp
Update QtLoader_inline.cpp Update QtLoader_inline.cpp
This commit is contained in:
parent
c93e98a567
commit
a2e182cd08
@ -40,13 +40,13 @@ FARPROC QString_fromStdWString,QCoreApplication_addLibraryPath,QString_dtor,QApp
|
|||||||
bool checkqterror(){
|
bool checkqterror(){
|
||||||
return QString_fromStdWString==0||QCoreApplication_addLibraryPath==0||QString_dtor==0||QApplication_ctor==0||QFont_ctor==0||QFont_dtor==0||QApplication_setFont==0||QApplication_exec==0||QApplication_dtor==0||QApplication_processEvents==0;
|
return QString_fromStdWString==0||QCoreApplication_addLibraryPath==0||QString_dtor==0||QApplication_ctor==0||QFont_ctor==0||QFont_dtor==0||QApplication_setFont==0||QApplication_exec==0||QApplication_dtor==0||QApplication_processEvents==0;
|
||||||
}
|
}
|
||||||
int loadqtdlls(){
|
void loadqtdlls(){
|
||||||
QString_fromStdWString=QCoreApplication_addLibraryPath=QString_dtor=QApplication_ctor=QFont_ctor=QFont_dtor=QApplication_setFont=QApplication_exec=QApplication_dtor=QApplication_processEvents=0;
|
QString_fromStdWString=QCoreApplication_addLibraryPath=QString_dtor=QApplication_ctor=QFont_ctor=QFont_dtor=QApplication_setFont=QApplication_exec=QApplication_dtor=QApplication_processEvents=0;
|
||||||
|
|
||||||
auto Qt5Widgets=LoadLibrary(L"Qt5Widgets.dll");
|
auto Qt5Widgets=LoadLibrary(L"Qt5Widgets.dll");
|
||||||
auto Qt5Gui=LoadLibrary(L"Qt5Gui.dll");
|
auto Qt5Gui=LoadLibrary(L"Qt5Gui.dll");
|
||||||
auto Qt5Core=LoadLibrary(L"Qt5Core.dll");
|
auto Qt5Core=LoadLibrary(L"Qt5Core.dll");
|
||||||
if(Qt5Core==0||Qt5Gui==0||Qt5Widgets==0)return 0;
|
if(Qt5Core==0||Qt5Gui==0||Qt5Widgets==0)return;
|
||||||
|
|
||||||
QString_fromStdWString=GetProcAddress(Qt5Core,fnQString_fromStdWString);
|
QString_fromStdWString=GetProcAddress(Qt5Core,fnQString_fromStdWString);
|
||||||
QCoreApplication_addLibraryPath=GetProcAddress(Qt5Core,fnQCoreApplication_addLibraryPath);
|
QCoreApplication_addLibraryPath=GetProcAddress(Qt5Core,fnQCoreApplication_addLibraryPath);
|
||||||
@ -58,7 +58,6 @@ int loadqtdlls(){
|
|||||||
QApplication_exec=GetProcAddress(Qt5Widgets,fnQApplication_exec);
|
QApplication_exec=GetProcAddress(Qt5Widgets,fnQApplication_exec);
|
||||||
QApplication_dtor=GetProcAddress(Qt5Widgets,fnQApplication_dtor);
|
QApplication_dtor=GetProcAddress(Qt5Widgets,fnQApplication_dtor);
|
||||||
QApplication_processEvents=GetProcAddress(Qt5Core,fnQApplication_processEvents);
|
QApplication_processEvents=GetProcAddress(Qt5Core,fnQApplication_processEvents);
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
struct info{
|
struct info{
|
||||||
int type;
|
int type;
|
||||||
@ -68,13 +67,13 @@ struct info{
|
|||||||
lockedqueue<info>waitingtask;
|
lockedqueue<info>waitingtask;
|
||||||
lockedqueue<HMODULE>waitingresult;
|
lockedqueue<HMODULE>waitingresult;
|
||||||
|
|
||||||
extern "C" __declspec(dllexport) int QtStartUp(std::vector<std::wstring>* dlls){
|
extern "C" __declspec(dllexport) void QtStartUp(std::vector<std::wstring>* dlls){
|
||||||
static bool once=false;
|
|
||||||
if(once)return 0;
|
|
||||||
once=true;
|
|
||||||
|
|
||||||
static auto once1=loadqtdlls();
|
static bool once=false;
|
||||||
if(checkqterror())return 0;
|
loadqtdlls();
|
||||||
|
once=checkqterror();
|
||||||
|
if(once)return;
|
||||||
|
once=checkqterror();
|
||||||
std::thread([=](){
|
std::thread([=](){
|
||||||
static void* qapp; //必须static
|
static void* qapp; //必须static
|
||||||
void* qstring;
|
void* qstring;
|
||||||
@ -112,6 +111,7 @@ extern "C" __declspec(dllexport) int QtStartUp(std::vector<std::wstring>* dlls){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
((void(_CDECL*)(DWORD))QApplication_processEvents)(0);
|
((void(_CDECL*)(DWORD))QApplication_processEvents)(0);
|
||||||
|
Sleep(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ((void(*)())QApplication_exec)();
|
// ((void(*)())QApplication_exec)();
|
||||||
@ -119,17 +119,23 @@ extern "C" __declspec(dllexport) int QtStartUp(std::vector<std::wstring>* dlls){
|
|||||||
// ((void(THISCALL*)(void*))QApplication_dtor)(&qapp);
|
// ((void(THISCALL*)(void*))QApplication_dtor)(&qapp);
|
||||||
|
|
||||||
}).detach();
|
}).detach();
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
std::mutex loadmutex;
|
std::mutex loadmutex;
|
||||||
|
|
||||||
extern "C" __declspec(dllexport) std::vector<HMODULE>* QtLoadLibraryBatch(std::vector<std::wstring>* dlls){
|
extern "C" __declspec(dllexport) std::vector<HMODULE>* QtLoadLibraryBatch(std::vector<std::wstring>* dlls){
|
||||||
std::lock_guard _(loadmutex);
|
std::lock_guard _(loadmutex);
|
||||||
static auto once=QtStartUp(dlls);
|
QtStartUp(dlls);
|
||||||
auto hdlls=new std::vector<HMODULE>;
|
auto hdlls=new std::vector<HMODULE>;
|
||||||
for(int i=0;i<dlls->size();i++){
|
for(int i=0;i<dlls->size();i++){
|
||||||
waitingtask.push({1,dlls->at(i)});
|
if(checkqterror()){
|
||||||
hdlls->push_back(waitingresult.pop());
|
hdlls->push_back(0);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
waitingtask.push({1,dlls->at(i)});
|
||||||
|
hdlls->push_back(waitingresult.pop());
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return hdlls;
|
return hdlls;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user