Exemplo n.º 1
0
// Get fully qualified path from module name. Assumes base directory is the
// directory of the currently executing binary.
std::tstring Injector::GetPath( const std::tstring& ModuleName )
{
	// Get handle to self
	HMODULE Self = GetModuleHandle(NULL);

	// Get path to loader
	std::vector<TCHAR> LoaderPath(MAX_PATH);
	if (!GetModuleFileName(Self,&LoaderPath[0],static_cast<DWORD>(LoaderPath.size())) || 
		GetLastError() == ERROR_INSUFFICIENT_BUFFER)
		throw std::runtime_error("Could not get path to loader.");

	// Convert path to loader to path to module
	std::tstring ModulePath(&LoaderPath[0]);
	ModulePath = ModulePath.substr(0, ModulePath.rfind( _T("\\") ) + 1);
	ModulePath.append(ModuleName);

	// Check path/file is valid
	if (GetFileAttributes(ModulePath.c_str()) == INVALID_FILE_ATTRIBUTES)
	{
		std::string NewModulePath(ModulePath.begin(),ModulePath.end());
		throw std::runtime_error("Could not find module. Path: '" + NewModulePath + "'.");
	}

	// Return module path
	return ModulePath;
}
Exemplo n.º 2
0
//-----------------------------------------------------------------------------
inline static dog::IEventTracing* CreateDOGFromLocalDirDLL(HINSTANCE* phDLL)
{
	const TCHAR* DOGDLL_FileName = _T("DOG.DLL");

	std::basic_string<TCHAR> ModulePath(MAX_PATH, NULL);
	::GetModuleFileName(reinterpret_cast<HMODULE>(&__ImageBase), &ModulePath[0], MAX_PATH);
	ModulePath.replace(ModulePath.begin() + ModulePath.find_last_of(_T('\\')) + 1, ModulePath.end(), DOGDLL_FileName);
	HINSTANCE hDLL = LoadLibrary(ModulePath.c_str());

	dog::IEventTracing* pDOG = NULL;

	if(hDLL)
	{
		typedef void* (*LPCreateComponentT)(void);
		LPCreateComponentT pCreateComponent = reinterpret_cast<LPCreateComponentT>(GetProcAddress(hDLL, "CreateComponent"));
		if(pCreateComponent)
		{
			pDOG = reinterpret_cast<dog::IEventTracing*>(pCreateComponent());
		}
		else
		{
			::FreeLibrary(hDLL);
			hDLL = NULL;
		}
	}

	if(phDLL)
	{
		*phDLL = hDLL;
	}

	return pDOG;
}
Exemplo n.º 3
0
HMODULE WINAPI HookLL::HookLoadLibraryExA(LPCSTR lpLibFileName, HANDLE hFile, DWORD dwFlags)
{
	if (!InputHookManager::Get().GetInputHook().GetState(InputHook::HOOK_LL)) return TrueLoadLibraryExA(lpLibFileName, hFile, dwFlags);

	if (SelfCheckA(lpLibFileName))
	{
		PrintLog("LoadLibraryExA");
		InputHookManager::Get().GetInputHook().StartTimeoutThread();

		std::string path;

		if (ModulePath(&path, InputHookManager::Get().GetInputHook().GetEmulator()))
			return TrueLoadLibraryExA(path.c_str(), hFile, dwFlags);
		else
			return TrueLoadLibraryExA(lpLibFileName, hFile, dwFlags);
	}

	return TrueLoadLibraryExA(lpLibFileName, hFile, dwFlags);
}
Exemplo n.º 4
0
HMODULE WINAPI HookLL::HookLoadLibraryW(LPCWSTR lpLibFileName)
{
	if (!InputHookManager::Get().GetInputHook().GetState(InputHook::HOOK_LL)) return TrueLoadLibraryW(lpLibFileName);

	if (SelfCheckW(lpLibFileName))
	{
		PrintLog("LoadLibraryW");
		InputHookManager::Get().GetInputHook().StartTimeoutThread();

		std::wstring path;

		if (ModulePath(&path, InputHookManager::Get().GetInputHook().GetEmulator()))
			return TrueLoadLibraryW(path.c_str());
		else
			return TrueLoadLibraryW(lpLibFileName);
	}

	return TrueLoadLibraryW(lpLibFileName);
}
Exemplo n.º 5
0
int main(int argc, char **argv)
{
    // OSG init
    osgInit(argc,argv);

    {
        TheLuaManager->init();

        // Set up Window
        WindowEventProducerRecPtr TutorialWindow = createNativeWindow();
        TutorialWindow->initWindow();

        // Create the SimpleSceneManager helper
        SimpleSceneManager sceneManager;
        TutorialWindow->setDisplayCallback(boost::bind(display, &sceneManager));
        TutorialWindow->setReshapeCallback(boost::bind(reshape, _1, &sceneManager));

        // Tell the Manager what to manage
        sceneManager.setWindow(TutorialWindow);

        //Setup the Lua Manager

        BoostPath ModulePath("./Data/");
        std::string PackagePath = std::string("?;")
            + (ModulePath / "?.lua" ).file_string() + ";"
            + (ModulePath / "?" /  "init.lua").file_string();
        TheLuaManager->setPackagePath(PackagePath);

        // Make Torus Node (creates Torus in background of scene)
        GeometryRefPtr TorusGeometry = makeTorusGeo(.5, 2, 16, 16);
        setName(TorusGeometry,"Torus Geometry");
        //calcVertexTangents(TorusGeometry,0,Geometry::TexCoords7FieldId, Geometry::TexCoords6FieldId);


        NodeRefPtr TorusGeometryNode = Node::create();
        setName(TorusGeometryNode,"Torus Geometry Node");
        TorusGeometryNode->setCore(TorusGeometry);

        //Torus Transformation Node
        TransformRefPtr TheTorusNodeTransform = Transform::create();

        NodeRefPtr TheTorusTransfromNode = Node::create();
        TheTorusTransfromNode->setCore(TheTorusNodeTransform);
        TheTorusTransfromNode->addChild(TorusGeometryNode);
        setName(TheTorusTransfromNode,"Torus Transform Node");

        // Make Main Scene Node and add the Torus
        NodeRefPtr scene = Node::create();
        scene->setCore(Group::create());
        scene->addChild(TheTorusTransfromNode);
        setName(scene,"Scene Node");

        //Light Beacon Node
        TransformRefPtr TheLightBeaconNodeTransform = Transform::create();

        NodeRefPtr TheLightBeaconNode = Node::create();
        TheLightBeaconNode->setCore(TheLightBeaconNodeTransform);
        setName(TheLightBeaconNode,"Light Beacon Node");


        //Light Node
        DirectionalLightRefPtr TheLightCore = DirectionalLight::create();
        TheLightCore->setDirection(Vec3f(1.0,0.0,0.0));
        TheLightCore->setAmbient(Color4f(1.0,1.0,1.0,1.0));
        TheLightCore->setDiffuse(Color4f(1.0,1.0,1.0,1.0));
        TheLightCore->setSpecular(Color4f(1.0,1.0,1.0,1.0));
        TheLightCore->setBeacon(TheLightBeaconNode);

        NodeRefPtr TheLightNode = Node::create();
        TheLightNode->setCore(TheLightCore);
        TheLightNode->addChild(scene);
        setName(TheLightNode,"Light Node");

        NodeRefPtr RootNode = Node::create();
        RootNode->setCore(Group::create());
        RootNode->addChild(TheLightNode);
        RootNode->addChild(TheLightBeaconNode);
        setName(RootNode,"Root Node");

        // Create the Graphics
        GraphicsRefPtr TutorialGraphics = Graphics2D::create();

        // Initialize the LookAndFeelManager to enable default settings
        LookAndFeelManager::the()->getLookAndFeel()->init();

        //Create the Main interface
        LuaDebuggerInterface TheLuaDebuggerInterface;

        // Create The Main InternalWindow
        // Create Background to be used with the Main InternalWindow
        ColorLayerRefPtr MainInternalWindowBackground = ColorLayer::create();
        MainInternalWindowBackground->setColor(Color4f(1.0,1.0,1.0,0.5));

        BorderLayoutRefPtr MainInternalWindowLayout = BorderLayout::create();

        //Split Panel
        BorderLayoutConstraintsRefPtr SplitPanelConstraints = BorderLayoutConstraints::create();
        SplitPanelConstraints->setRegion(BorderLayoutConstraints::BORDER_CENTER);
        TheLuaDebuggerInterface.getMainSplitPanel()->setConstraints(SplitPanelConstraints);

        BorderLayoutConstraintsRefPtr ButtonPanelConstraints = BorderLayoutConstraints::create();
        ButtonPanelConstraints->setRegion(BorderLayoutConstraints::BORDER_NORTH);
        TheLuaDebuggerInterface.getButtonPanel()->setConstraints(ButtonPanelConstraints);

        BorderLayoutConstraintsRefPtr CodeAreaInfoPanelConstraints = BorderLayoutConstraints::create();
        CodeAreaInfoPanelConstraints->setRegion(BorderLayoutConstraints::BORDER_SOUTH);
        TheLuaDebuggerInterface.getCodeAreaInfoPanel()->setConstraints(CodeAreaInfoPanelConstraints);

        InternalWindowRefPtr MainInternalWindow = InternalWindow::create();
        MainInternalWindow->pushToChildren(TheLuaDebuggerInterface.getButtonPanel());
        MainInternalWindow->pushToChildren(TheLuaDebuggerInterface.getMainSplitPanel());
        MainInternalWindow->pushToChildren(TheLuaDebuggerInterface.getCodeAreaInfoPanel());
        MainInternalWindow->setLayout(MainInternalWindowLayout);
        MainInternalWindow->setBackgrounds(MainInternalWindowBackground);
        MainInternalWindow->setTitle("Lua Debugger");
        setName(MainInternalWindow,"Internal Window");

        // Create the Drawing Surface
        UIDrawingSurfaceRefPtr TutorialDrawingSurface = UIDrawingSurface::create();
        TutorialDrawingSurface->setGraphics(TutorialGraphics);
        TutorialDrawingSurface->setEventProducer(TutorialWindow);

        TutorialDrawingSurface->openWindow(MainInternalWindow);

        // Create the UI Foreground Object
        UIForegroundRefPtr TutorialUIForeground = UIForeground::create();

        TutorialUIForeground->setDrawingSurface(TutorialDrawingSurface);

        //Scene Background
        GradientBackgroundRefPtr SceneBackground = GradientBackground::create();
        SceneBackground->addLine(Color3f(0.0,0.0,0.0),0.0);
        setName(SceneBackground,"Scene Background");

        // Tell the Manager what to manage
        sceneManager.setWindow(TutorialWindow);
        sceneManager.setRoot(RootNode);
        //sceneManager.setHeadlight(false);

        // Add the UI Foreground Object to the Scene
        ViewportRefPtr TutorialViewport = sceneManager.getWindow()->getPort(0);
        TutorialViewport->addForeground(TutorialUIForeground);
        TutorialViewport->setBackground(SceneBackground);

        TutorialWindow->connectKeyTyped(boost::bind(keyTyped,
                                                    _1,
                                                    &TheLuaDebuggerInterface));

        // Show the whole Scene
        sceneManager.showAll();


        //Open Window
        Vec2f WinSize(TutorialWindow->getDesktopSize() * 0.85f);
        Pnt2f WinPos((TutorialWindow->getDesktopSize() - WinSize) *0.5);
        TutorialWindow->openWindow(WinPos,
                                   WinSize,
                                   "03LuaDebugger");

        MainInternalWindow->setAlignmentInDrawingSurface(Vec2f(0.5f,0.5f));
        MainInternalWindow->setPreferredSize(WinSize * 0.85);

        //Enter main Loop
        TutorialWindow->mainLoop();

        TheLuaManager->uninit();
    }

    osgExit();

    return 0;
}
Exemplo n.º 6
0
 RetCode BOSS_CALL ServiceRegistry::Load(IIStream *stream)
 {
   if (!stream)
     return Status::InvalidArgument;
   std::lock_guard<std::recursive_mutex> Lock(Mtx);
   try
   {
     auto Registry = PropertyBagType::Create(RegistryTag);
     RetCode Code = Registry->Load(stream);
     if (Code != Status::Ok)
       return Code;
     RefObjPtr<IBase> ServiceEnumProp;
     if ((Code = Registry->GetProperty(ServicesTag, ServiceEnumProp.GetPPtr())) != Status::Ok)
       return Code;
     RefObjQIPtr<IEnum> ServiceEnum(ServiceEnumProp);
     if (!ServiceEnum.Get())
       return Status::Fail;
     ServicePool NewServices;
     for (RefObjPtr<IBase> i ; ServiceEnum->Next(i.GetPPtr()) == Status::Ok ; i.Release())
     {
       RefObjQIPtr<IPropertyBag> ServiceItem(i);
       if (!ServiceItem.Get())
         return Status::Fail;
       RefObjPtr<IBase> EntId;
       if ((Code = ServiceItem->GetProperty(ServiceIdTag, EntId.GetPPtr())) != Status::Ok)
         return Code;
       RefObjQIPtr<IEntityId> EntSrvId(EntId);
       if (!EntSrvId.Get())
         return Status::Fail;
       ServiceId SrvId = 0;
       if ((Code = EntSrvId->GetId(&SrvId)) != Status::Ok)
         return Code;
       RefObjPtr<IBase> ClassIdsEnumProp;
       if ((Code = ServiceItem->GetProperty(ClassIdsTag, ClassIdsEnumProp.GetPPtr())) != Status::Ok)
         return Code;
       RefObjQIPtr<IEnum> ClassIdsEnum(ClassIdsEnumProp);
       if (!ClassIdsEnum.Get())
         return Status::Fail;
       RefObjPtr<IBase> ModulePathProp;
       RefObjPtr<IServiceInfo> ServiceInfo;
       if (ServiceItem->GetProperty(ModulePathTag, ModulePathProp.GetPPtr()) == Status::Ok)
       {
         RefObjQIPtr<IString> ModulePath(ModulePathProp);
         if (!ModulePath.Get())
           return Status::Fail;
         auto LocalSrvInfo = Base<LocalServiceInfo>::Create();
         LocalSrvInfo->SetServiceId(SrvId);
         LocalSrvInfo->AddCoClassIds(ClassIdsEnum);
         LocalSrvInfo->SetModulePath(ModulePath);
         ServiceInfo = LocalSrvInfo;
       }
       else
       {
         RefObjPtr<IBase> RemotePropertiesProp;
         if (ServiceItem->GetProperty(RemotePropertiesTag, RemotePropertiesProp.GetPPtr()) == Status::Ok)
         {
           RefObjQIPtr<IPropertyBag> RemoteProperties(RemotePropertiesProp);
           if (!RemoteProperties.Get())
             return Status::Fail;
           auto RemoteSrvInfo = Base<RemoteServiceInfo>::Create();
           RemoteSrvInfo->SetServiceId(SrvId);
           RemoteSrvInfo->AddCoClassIds(ClassIdsEnum);
           RemoteSrvInfo->SetProps(RemoteProperties);
           ServiceInfo = RemoteSrvInfo;
         }
         else
           return Status::Fail;
       }
       if ((Code = ClassIdsEnum->Reset()) != Status::Ok)
         return Code;
       for (RefObjPtr<IBase> j ; ClassIdsEnum->Next(j.GetPPtr()) == Status::Ok ; j.Release())
       {
         RefObjQIPtr<IEntityId> ClsId(j);
         if (!ClsId.Get())
           return Status::Fail;
         ClassId Id = 0;
         if ((Code = ClsId->GetId(&Id)) != Status::Ok)
           return Code;
         NewServices[Id] = ServiceInfo;
       }
     }
     std::swap(Services, NewServices);
     return Status::Ok;
   }
   catch (...)
   {
     return Status::Fail;
   }
   return Status::Ok;
 }