コード例 #1
0
ファイル: RBTray.cpp プロジェクト: Robotguy27/rice
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR szCmdLine, int iCmdShow) {
	WNDCLASS wc;
	MSG msg;

	_hInstance = hInstance;
	_hwndHook = FindWindow(NAME, NAME);
	if (_hwndHook) {
		if (strstr(szCmdLine, "--exit")) {
			SendMessage(_hwndHook, WM_CLOSE, 0, 0);
		}
		else {
			MessageBox(NULL, L"RBTray is already running.", L"RBTray", MB_OK | MB_ICONINFORMATION);
		}
		return 0;
	}
	if (!(_hLib = LoadLibrary(L"RBHook.dll"))) {
		MessageBox(NULL, L"Error loading RBHook.dll.", L"RBTray", MB_OK | MB_ICONERROR);
		return 0;
	}
	if (!RegisterHook(_hLib)) {
		MessageBox(NULL, L"Error setting hook procedure.", L"RBTray", MB_OK | MB_ICONERROR);
		return 0;
	}
	wc.style         = 0;
	wc.lpfnWndProc   = HookWndProc;
	wc.cbClsExtra    = 0;
	wc.cbWndExtra    = 0;
	wc.hInstance     = hInstance;
	wc.hIcon         = NULL;
	wc.hCursor       = NULL;
	wc.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
	wc.lpszMenuName  = NULL;
	wc.lpszClassName = NAME;
	if (!RegisterClass(&wc)) {
		MessageBox(NULL, L"Error creating window class", L"RBTray", MB_OK | MB_ICONERROR);
		return 0;
	}
	if (!(_hwndHook = CreateWindow(NAME, NAME, WS_OVERLAPPED, 0, 0, 0, 0, (HWND)NULL, (HMENU)NULL, (HINSTANCE)hInstance, (LPVOID)NULL))) {
		MessageBox(NULL, L"Error creating window", L"RBTray", MB_OK | MB_ICONERROR);
		return 0;
	}
	for (int i = 0; i < MAXTRAYITEMS; i++) {
		_hwndItems[i] = NULL;
	}
	WM_TASKBAR_CREATED = RegisterWindowMessage(L"TaskbarCreated");

	while (IsWindow(_hwndHook) && GetMessage(&msg, _hwndHook, 0, 0)) {
		TranslateMessage(&msg);
		DispatchMessage(&msg);
	}

	return 0;
}
コード例 #2
0
ファイル: rbtray.c プロジェクト: shelt/RBXTray
int WINAPI
WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,LPSTR szCmdLine, int iCmdShow)
{
    WNDCLASS wc;
    MSG msg;
    int i;

    lastLButtonDown = 0;
    thisInstance = hInstance;
    hwndHook = FindWindow(NAME, NAME);
    if (strstr(szCmdLine,"--exit"))
    {
        if (hwndHook)SendMessage(hwndHook, WM_CLOSE, 0, 0);
        return 0;
    };
    showKeyb = ReadKbdCfg();

    if (!(hLib = LoadLibrary("RBHook.dll")))
    {
        MessageBox(NULL, "Error loading RBHook.dll", "RBTray", MB_OK
            | MB_ICONHAND);
        return FALSE;
    }
    if (!RegisterHook(hLib))
    {
        MessageBox(NULL, "Error setting hook procedure", "RBTray", MB_OK | MB_ICONHAND);
        return FALSE;
    }
    wc.hCursor        = NULL;
    wc.hIcon          = NULL;
    wc.lpszMenuName   = NULL;
    wc.lpszClassName  = NAME;
    wc.hbrBackground  = (HBRUSH)(COLOR_WINDOW + 1);
    wc.hInstance      = hInstance;
    wc.style          = 0;
    wc.lpfnWndProc    = HookWndProc;
    wc.cbWndExtra     = sizeof(HWND) + sizeof(HWND);
    wc.cbClsExtra     = 0;
    if (!RegisterClass(&wc))
    {
        MessageBox(NULL,"Error creating window class", "RBTray", MB_OK | MB_ICONHAND);
        return 2;
    }
    if (!(hwndHook = CreateWindow(NAME, NAME,
        WS_WINDOW_STYLE,
        0, 0, 0, 0,
        (HWND) NULL,
        (HMENU) NULL,
        (HINSTANCE)hInstance,
        (LPVOID) NULL)))
    {
        MessageBox(NULL, "Error creating window", "RBTray", MB_OK);
        return 3;
    }
    WM_TASKBAR_CREATED = RegisterWindowMessage("TaskbarCreated");
    for(i = 0 ; i < MAXCOUNT ;list[i++] = 0);
    keyState = -1;
    ShowKeyState();
    EnumWindows((WNDENUMPROC)UpdMenu,TRUE);
    while (IsWindow(hwndHook) && GetMessage(&msg, hwndHook, 0, 0))
    {
        TranslateMessage(&msg);
        DispatchMessage(&msg);
    }
    return 0;
}
コード例 #3
0
ファイル: LUAEngineMgr.cpp プロジェクト: Refuge89/Hearthstone
void LuaEngineMgr::Restart(ScriptMgr* sMgr)
{
	Log.Notice("LuaEngineMgr", "Restarting Engine.");
	CREATE_L_PTR;
	g_engine->getcoLock().Acquire();
	Unload();
	m_engine->LoadScripts();
	for(UnitBindingMap::iterator itr = m_unitBinding.begin(); itr != m_unitBinding.end(); ++itr)
	{
		typedef multimap<uint32, LuaCreature*> CMAP;
		CMAP & cMap = g_luaMgr.getLuCreatureMap();
		CMAP::iterator it = cMap.find(itr->first);
		CMAP::iterator itend = cMap.upper_bound(itr->first);
		if(it == cMap.end())
		{
			sMgr->register_creature_script(itr->first, CreateLuaCreature);
			cMap.insert(make_pair(itr->first, (LuaCreature*)NULL));
		}
		else
		{
			for(; it != itend; ++it)
			{
				if(it->second != NULL)
					it->second->m_binding = &itr->second;
			}
		}
	}

	for(GameObjectBindingMap::iterator itr = m_gameobjectBinding.begin(); itr != m_gameobjectBinding.end(); ++itr)
	{
		typedef multimap<uint32, LuaGameObject*> GMAP;
		GMAP & gMap = g_luaMgr.getLuGameObjectMap();
		GMAP::iterator it = gMap.find(itr->first);
		GMAP::iterator itend = gMap.upper_bound(itr->first);
		if(it == gMap.end())
		{
			sMgr->register_gameobject_script(itr->first, CreateLuaGameObject);
			gMap.insert(make_pair(itr->first, (LuaGameObject*)NULL));
		}
		else
		{
			for(; it != itend; ++it)
			{
				if(it->second != NULL)
					it->second->m_binding = &itr->second;
			}
		}
	}

	for(QuestBindingMap::iterator itr = m_questBinding.begin(); itr != m_questBinding.end(); ++itr)
	{
		typedef HM_NAMESPACE::hash_map<uint32, LuaQuest*> QMAP;
		QMAP & qMap = g_luaMgr.getLuQuestMap();
		QMAP::iterator it = qMap.find(itr->first);
		if(it == qMap.end())
		{
			sMgr->register_quest_script(itr->first, CreateLuaQuestScript(itr->first));
			qMap.insert(make_pair(itr->first, (LuaQuest*)NULL));
		}
		else
		{
			LuaQuest* q_interface = it->second;
			if(q_interface != NULL)
				q_interface->m_binding = &itr->second;
		}
	}

	for(InstanceBindingMap::iterator itr = m_instanceBinding.begin(); itr != m_instanceBinding.end(); ++itr)
	{
		typedef HM_NAMESPACE::hash_map<uint32, LuaInstance*> IMAP;
		IMAP & iMap = g_luaMgr.getLuInstanceMap();
		IMAP::iterator it = iMap.find(itr->first);
		if(it == iMap.end())
		{
			sMgr->register_mapmanager_script(itr->first, CreateLuaInstance);
			iMap.insert(make_pair(itr->first, (LuaInstance*)NULL));
		}
		else
		{
			if(it->second != NULL)
				it->second->m_binding = &itr->second;
		}
	}

	for(GossipUnitScriptsBindingMap::iterator itr = this->m_unit_gossipBinding.begin(); itr != m_unit_gossipBinding.end(); ++itr)
	{
		typedef HM_NAMESPACE::hash_map<uint32, LuaGossip*> GMAP;
		GMAP & gMap = g_luaMgr.getUnitGossipInterfaceMap();
		GMAP::iterator it = gMap.find(itr->first);
		if(it == gMap.end())
		{
			GossipScript* gs = CreateLuaUnitGossipScript(itr->first);
			if(gs != NULL)
			{
				sMgr->register_gossip_script(itr->first, gs);
				gMap.insert(make_pair(itr->first, (LuaGossip*)NULL));
			}
		}
		else
		{
			LuaGossip* u_gossip = it->second;
			if(u_gossip != NULL)
				u_gossip->m_unit_gossip_binding = &itr->second;
		}
	}

	for(GossipItemScriptsBindingMap::iterator itr = this->m_item_gossipBinding.begin(); itr != m_item_gossipBinding.end(); ++itr)
	{
		typedef HM_NAMESPACE::hash_map<uint32, LuaGossip*> GMAP;
		GMAP & gMap = g_luaMgr.getItemGossipInterfaceMap();
		GMAP::iterator it = gMap.find(itr->first);
		if(it == gMap.end())
		{
			GossipScript* gs = CreateLuaItemGossipScript(itr->first);
			if(gs != NULL)
			{
				sMgr->register_item_gossip_script(itr->first, gs);
				gMap.insert(make_pair(itr->first, (LuaGossip*)NULL));
			}
		}
		else
		{
			LuaGossip* i_gossip = it->second;
			if(i_gossip != NULL)
				i_gossip->m_item_gossip_binding = &itr->second;
		}
	}

	for(GossipGOScriptsBindingMap::iterator itr = this->m_go_gossipBinding.begin(); itr != m_go_gossipBinding.end(); ++itr)
	{
		typedef HM_NAMESPACE::hash_map<uint32, LuaGossip*> GMAP;
		GMAP & gMap = g_luaMgr.getGameObjectGossipInterfaceMap();
		GMAP::iterator it = gMap.find(itr->first);
		if(it == gMap.end())
		{
			GossipScript* gs = CreateLuaGOGossipScript(itr->first);
			if(gs != NULL)
			{
				sMgr->register_go_gossip_script(itr->first, gs);
				gMap.insert(make_pair(itr->first, (LuaGossip*)NULL));
			}
		}
		else
		{
			LuaGossip* g_gossip = it->second;
			if(g_gossip != NULL)
				g_gossip->m_go_gossip_binding = &itr->second;
		}
	}

	/* BIG SERV HOOK CHUNK EEK */
	RegisterHook(SERVER_HOOK_EVENT_ON_NEW_CHARACTER, Lua_HookOnNewCharacter);
	RegisterHook(SERVER_HOOK_EVENT_ON_KILL_PLAYER, Lua_HookOnKillPlayer);
	RegisterHook(SERVER_HOOK_EVENT_ON_FIRST_ENTER_WORLD, Lua_HookOnFirstEnterWorld);
	RegisterHook(SERVER_HOOK_EVENT_ON_ENTER_WORLD, Lua_HookOnEnterWorld);
	RegisterHook(SERVER_HOOK_EVENT_ON_GUILD_JOIN, Lua_HookOnGuildJoin);
	RegisterHook(SERVER_HOOK_EVENT_ON_DEATH, Lua_HookOnDeath);
	RegisterHook(SERVER_HOOK_EVENT_ON_REPOP, Lua_HookOnRepop);
	RegisterHook(SERVER_HOOK_EVENT_ON_EMOTE, Lua_HookOnEmote);
	RegisterHook(SERVER_HOOK_EVENT_ON_ENTER_COMBAT, Lua_HookOnEnterCombat);
	RegisterHook(SERVER_HOOK_EVENT_ON_CAST_SPELL, Lua_HookOnCastSpell);
	RegisterHook(SERVER_HOOK_EVENT_ON_TICK, Lua_HookOnTick);
	RegisterHook(SERVER_HOOK_EVENT_ON_LOGOUT_REQUEST, Lua_HookOnLogoutRequest);
	RegisterHook(SERVER_HOOK_EVENT_ON_LOGOUT, Lua_HookOnLogout);
	RegisterHook(SERVER_HOOK_EVENT_ON_QUEST_ACCEPT, Lua_HookOnQuestAccept);
	RegisterHook(SERVER_HOOK_EVENT_ON_ZONE, Lua_HookOnZone);
	RegisterHook(SERVER_HOOK_EVENT_ON_CHAT, Lua_HookOnChat);
	RegisterHook(SERVER_HOOK_EVENT_ON_LOOT, Lua_HookOnLoot);
	RegisterHook(SERVER_HOOK_EVENT_ON_GUILD_CREATE, Lua_HookOnGuildCreate);
	RegisterHook(SERVER_HOOK_EVENT_ON_FULL_LOGIN, Lua_HookOnEnterWorld2);
	RegisterHook(SERVER_HOOK_EVENT_ON_CHARACTER_CREATE, Lua_HookOnCharacterCreate);
	RegisterHook(SERVER_HOOK_EVENT_ON_QUEST_CANCELLED, Lua_HookOnQuestCancelled);
	RegisterHook(SERVER_HOOK_EVENT_ON_QUEST_FINISHED, Lua_HookOnQuestFinished);
	RegisterHook(SERVER_HOOK_EVENT_ON_HONORABLE_KILL, Lua_HookOnHonorableKill);
	RegisterHook(SERVER_HOOK_EVENT_ON_ARENA_FINISH, Lua_HookOnArenaFinish);
	RegisterHook(SERVER_HOOK_EVENT_ON_OBJECTLOOT, Lua_HookOnObjectLoot);
	RegisterHook(SERVER_HOOK_EVENT_ON_AREATRIGGER, Lua_HookOnAreaTrigger);
	RegisterHook(SERVER_HOOK_EVENT_ON_POST_LEVELUP, Lua_HookOnPostLevelUp);
	RegisterHook(SERVER_HOOK_EVENT_ON_PRE_DIE, Lua_HookOnPreUnitDie);
	RegisterHook(SERVER_HOOK_EVENT_ON_ADVANCE_SKILLLINE, Lua_HookOnAdvanceSkillLine);
	RegisterHook(SERVER_HOOK_EVENT_ON_DUEL_FINISHED, Lua_HookOnDuelFinished);
	RegisterHook(SERVER_HOOK_EVENT_ON_AURA_REMOVE, Lua_HookOnAuraRemove);
	RegisterHook(SERVER_HOOK_EVENT_ON_RESURRECT, Lua_HookOnResurrect);

	for(std::map<uint32, uint16>::iterator itr = m_luaDummySpells.begin(); itr != m_luaDummySpells.end(); ++itr)
	{
		if(find(g_luaMgr.HookInfo.dummyHooks.begin(), g_luaMgr.HookInfo.dummyHooks.end(), itr->first) == g_luaMgr.HookInfo.dummyHooks.end())
		{
			sMgr->register_dummy_spell(itr->first, &Lua_HookOnDummySpell);
			g_luaMgr.HookInfo.dummyHooks.push_back(itr->first);
		}
	}
	RELEASE_LOCK
	g_engine->getcoLock().Release();

	//hyper: do OnSpawns for spawned creatures.
	vector<uint32> temp = OnLoadInfo;
	OnLoadInfo.clear();
	for(vector<uint32>::iterator itr = temp.begin(); itr != temp.end(); itr += 3)
	{
		//*itr = mapid; *(itr+1) = iid; *(itr+2) = lowguid
		MapMgr* mgr = NULL;
		if(*(itr + 1) == 0) //no instance
			mgr = sInstanceMgr.GetMapMgr(*itr);
		else
		{
			Instance* inst = sInstanceMgr.GetInstanceByIds(*itr, *(itr + 1));
			if(inst != NULL)
				mgr = inst->m_mapMgr;
		}
		if(mgr != NULL)
		{
			Creature* unit = mgr->GetCreature(*(itr + 2));
			if(unit != NULL && unit->IsInWorld() && unit->GetScript() != NULL)
				unit->GetScript()->OnLoad();
		}
	}
	temp.clear();

	Log.Notice("LuaEngineMgr", "Done restarting engine.");
}