diff options
Diffstat (limited to 'core')
-rw-r--r-- | core/Makefile | 20 | ||||
-rw-r--r-- | core/main.cpp | 185 | ||||
-rw-r--r-- | core/plugin.h | 33 | ||||
-rw-r--r-- | core/service.h | 15 | ||||
-rw-r--r-- | core/sqlite3.dll | bin | 541683 -> 0 bytes |
5 files changed, 0 insertions, 253 deletions
diff --git a/core/Makefile b/core/Makefile deleted file mode 100644 index 1613c29..0000000 --- a/core/Makefile +++ /dev/null @@ -1,20 +0,0 @@ -CFLAGS=-g -mwindows -mwin32 -D DEBUG -I../api/ -LDFLAGS=-static-libgcc -Wl,--subsystem=windows -CXXFLAGS=${CFLAGS} -CPPFLAGS = -CC=i686-pc-mingw32-gcc -CXX=i686-pc-mingw32-g++ -STRIP=i686-pc-mingw32-strip -LD=i686-pc-mingw32-ld -LNK_COMMON=-lkernel32 -MAINOBJS=main.o - -all: main -main: $(MAINOBJS) - $(CXX) $(MAINOBJS) $(LNK_COMMON) $(LDFLAGS) -o core.exe - #$(STRIP) core.exe - #upx -9 core.exe -clean: - rm *.o - rm core.exe - diff --git a/core/main.cpp b/core/main.cpp deleted file mode 100644 index 1068193..0000000 --- a/core/main.cpp +++ /dev/null @@ -1,185 +0,0 @@ -#include <windows.h> -#include <iostream> -//#include <tchar.h> - -#include <list> - -#include <pluginapi.h> -#include "plugin.h" -#include "service.h" - -using namespace std; - -list<plugin*> plugins; -list<service*> services; - -bool shutdown_called = false; - -int LoadModules(); -INT_PTR CallService(const char *name, WPARAM w, LPARAM l); -HANDLE CreateServiceFunction(const char *name, SERVICE pService); -DWORD WINAPI OnModulesLoadedThread( LPVOID lpParam ); -int ServiceExists(const char *name); -SERVICE Test(WPARAM, LPARAM); -SERVICE Shutdown(WPARAM, LPARAM); - -PLUGINLINK link = {&CreateServiceFunction, &CallService, &ServiceExists}; - -int main(int argc, char *argv[]) -{ - if(LoadModules()) - return 1; //something wrong - CreateServiceFunction("Core/Test", (SERVICE)Test); - CreateServiceFunction("Core/Shutdown", (SERVICE)Shutdown); - for(list<plugin*>::iterator p = plugins.begin(); p != plugins.end(); p++) //initializing plugins - { - (*p)->getFuncs().load(&link); - } - for(list<plugin*>::iterator p = plugins.begin(); p != plugins.end(); p++) - { - if((*p)->getFuncs().loaded) - { - CreateThread(NULL, 0, OnModulesLoadedThread, (LPVOID)(*p)->getFuncs().loaded, 0, 0); - } - } - for(;;) - { - if(shutdown_called) - { - plugin *db; - for(list<plugin*>::iterator p = plugins.begin(); p != plugins.end(); p++) - { - if((*p)->getPluginInfo()->flags == F_DB_PLUGIN) - db = (*p); - else - delete (*p); //is it right? , at least do not crasing... - } - delete db; - plugins.clear(); - break; - } - Sleep(1000); - } - return 0; -} - -int LoadModules() -{ - WIN32_FIND_DATAA findFileData; - HANDLE hFile = 0; - if(!(hFile = FindFirstFileA(".\\modules\\*", &findFileData))) - return 1; //failed to find any plugins in directory - HMODULE hPlugin = 0; - char tmp[MAX_PATH] = {0}; - plugin::exported_funcs_s funcs; - while(hFile != INVALID_HANDLE_VALUE && GetLastError() != ERROR_NO_MORE_FILES) - { - strcpy(tmp, ".\\modules\\"); - strcat(tmp, findFileData.cFileName); - hPlugin = LoadLibraryA(tmp); - funcs.info = (SetPluginInfo)GetProcAddress(hPlugin, "SetPluginInfo"); - funcs.load = (Load)GetProcAddress(hPlugin, "Load"); - funcs.loaded = (OnModulesLoaded)GetProcAddress(hPlugin, "OnModulesLoaded"); - funcs.unload = (Unload)GetProcAddress(hPlugin, "Unload"); - if(funcs.info && funcs.load) - { - PLUGININFO *pi = funcs.info(); - plugins.push_back(new plugin(hPlugin, funcs, pi)); - } - else - FreeLibrary(hPlugin); - FindNextFileA(hFile, &findFileData); - } - return 0; -} - -const HMODULE plugin::getHmodule() -{ - return hModule; -} - -int plugin::setHandle(const HMODULE &hMod) -{ - if(!hMod) - return 1; - hModule = hMod; - return 0; -} - -const plugin::exported_funcs_s plugin::getFuncs() -{ - return funcs; -} -PLUGININFO *plugin::getPluginInfo() -{ - return pluginInfo; -} -plugin::plugin(const HMODULE hMod, const exported_funcs_s fnct, PLUGININFO *info) -{ - hModule = hMod; - funcs = fnct; - pluginInfo = info; -} -plugin::~plugin() -{ - if(funcs.unload) - funcs.unload(); - FreeLibrary(hModule); -} -service::service(const char *name, SERVICE service) -{ - szName = new char [strlen(name)+1]; - strcpy(szName, name); - pService = service; -} -const char *service::getName() -{ - return szName; -} -const SERVICE service::getService() -{ - return pService; -} -INT_PTR CallService(const char *name, WPARAM w, LPARAM l) -{ - for(list<service*>::iterator p = services.begin(); p != services.end(); p++) - { - if(!strcmp((*p)->getName(), name)) - { - SERVICE s = *(*p)->getService(); - return s(w, l); - } - } - return 0; -} -HANDLE CreateServiceFunction(const char *name, SERVICE pService) -{ - if(!ServiceExists(name)) - services.push_back(new service(name, pService)); -} -int ServiceExists(const char *name) -{ - for(list<service*>::iterator p = services.begin(); p != services.end(); p++) - if(!strcmp((*p)->getName(), name)) - return 1; - return 0; -} - -SERVICE Test(WPARAM, LPARAM) -{ - MessageBoxA(0, "Test service working", "INFO", MB_OK); - return 0; -} - -SERVICE Shutdown(WPARAM, LPARAM) -{ - shutdown_called = true; -} - -DWORD WINAPI OnModulesLoadedThread( LPVOID lpParam ) -{ - OnModulesLoaded &l = (OnModulesLoaded&)lpParam; - l(); - return 0; -} - diff --git a/core/plugin.h b/core/plugin.h deleted file mode 100644 index c84ea0b..0000000 --- a/core/plugin.h +++ /dev/null @@ -1,33 +0,0 @@ -#ifndef PLUGIN_H -#define PLUGIN_H - -#include <list> - - -typedef PLUGININFO * (__cdecl * SetPluginInfo) (); -typedef int (__cdecl * Load) (PLUGINLINK *link); -typedef int (__cdecl * OnModulesLoaded) (); -typedef int (__cdecl * Unload) (); - -class plugin -{ -public: - struct exported_funcs_s - { - SetPluginInfo info; - Load load; - OnModulesLoaded loaded; - Unload unload; - }; - const HMODULE getHmodule(); - const exported_funcs_s getFuncs(); - PLUGININFO *getPluginInfo(); - int setHandle(const HMODULE &hMod); - plugin(const HMODULE hModule, const exported_funcs_s fnct, PLUGININFO *info); - ~plugin(); -private: - HMODULE hModule; - exported_funcs_s funcs; - PLUGININFO *pluginInfo; -}; -#endif diff --git a/core/service.h b/core/service.h deleted file mode 100644 index 8f624e8..0000000 --- a/core/service.h +++ /dev/null @@ -1,15 +0,0 @@ -#ifndef SERVICE_H -#define SERVICE_H -class service -{ -public: - const char *getName(); - const SERVICE getService(); - service(const char *name, SERVICE service); - ~service(); -private: - char *szName; - SERVICE pService; -}; -#endif - diff --git a/core/sqlite3.dll b/core/sqlite3.dll Binary files differdeleted file mode 100644 index 829c80e..0000000 --- a/core/sqlite3.dll +++ /dev/null |