コード例 #1
0
__fastcall TLoggerFile::TLoggerFile(const TPropertyMap &Init) : _outp(0), _max_file_count(Init["MaxFileCount"].ToInt()), _file_name(Init["Name"]) {
  if(_file_name.IsEmpty())
    _file_name = ExtractFilePath(GetModuleName(0))+"log\\"+Now().FormatString("yyyymmdd")+".log";
  _path = ExtractFilePath(_file_name);
  if(!DirectoryExists(_path)) CreateDirectory(_path.c_str(), 0);
  Reset();
  Info(String().sprintf("%s запуск", GetModuleName(0)));
}
コード例 #2
0
ファイル: r3hook.c プロジェクト: hackshields/antivirus
VOID CheckDllNameLoadSatellites(HMODULE hModule)
{
	WCHAR ModuleName[MAX_PATH];
	BOOL bResult;
	PWCHAR SatellPath;

	_ASSERT(hModule);

	if (!g_pLdrLoadDll_Context)
	{
		DbPrint("r3hook::CheckDllNameLoadSatellite - LdrLoadDll context is NULL\n");
		return;
	}

	bResult = GetModuleName(hModule, ModuleName, sizeof(ModuleName));
	if (!bResult)
	{
		DbPrint("r3hook::CheckDllNameLoadSatellites - failed to get module name for 0x%016Ix HMODULE\n", hModule);
		return;
	}

	EnterCriticalSection(&g_csR3ListLock);

	SatellPath = CheckDllName(ModuleName);
	if (SatellPath)
		LoadSatellites(SatellPath, hModule, "hme");

	LeaveCriticalSection(&g_csR3ListLock);
}
コード例 #3
0
ファイル: error.cpp プロジェクト: hackshields/antivirus
 KLSTD_NOTHROW const wchar_t* CError::GetLocModuleName() throw()
 {
     KLSTD::AutoCriticalSection acs(g_pErrorCS);
     return (    !m_pLocInfo )
                 ?   GetModuleName()
                 :   m_pLocInfo->m_wstrLocModule.c_str();
 };
コード例 #4
0
ファイル: notifier.cpp プロジェクト: chyla/pat-lms
void Notifier::SendMailNotification() {
  BOOST_LOG_TRIVIAL(debug) << "notifier::Notifier::SendMailNotification: Function call";

  string mail_body = "Found new anomalies.";

  BOOST_LOG_TRIVIAL(debug) << "notifier::Notifier::SendMailNotification: Creating message body";
  while (IsMessageAvailable()) {
    auto message = GetMessage();

    mail_body += "\r\n\r\n"
        "Module: " + message->GetModuleName() + "\r\n"
        "================================================================================\r\n";
    mail_body += message->GetDetectionResults();
  }

  BOOST_LOG_TRIVIAL(debug) << "notifier::Notifier::SendMailNotification: Preparing message";
  mailer::MailPtr mail = mailer::Mail::Create();
  mail->AddTo(options_.GetMailTo());
  mail->SetFrom(options_.GetMailFrom());
  mail->SetSubject("Found new anomalies");
  mail->SetBody(mail_body);

  time_t t = system_->Time();
  tm *gmt = system_->GMTime(&t);

  mail->SetDate(::type::ToDay(gmt->tm_wday),
                ::type::Timestamp::Create(gmt->tm_hour, gmt->tm_min, gmt->tm_sec % 60,
                                          gmt->tm_mday, gmt->tm_mon + 1, gmt->tm_year + 1900),
                "+0000");

  BOOST_LOG_TRIVIAL(debug) << "notifier::Notifier::SendMailNotification: Sending message";
  mailer::MailerPtr sender = mailer::Mailer::Create(options_);
  sender->Send(mail);
}
コード例 #5
0
ファイル: agenda.c プロジェクト: DrItanium/AdventureEngine
globle void RefreshAgendaCommand(
    void *theEnv)
{
    int numArgs, error;
    struct defmodule *theModule;

    /*==============================================*/
    /* This function can have at most one argument. */
    /*==============================================*/

    if ((numArgs = EnvArgCountCheck(theEnv,(char*)"refresh-agenda",NO_MORE_THAN,1)) == -1) return;

    /*===============================================================*/
    /* If a module name is specified, then the agenda of that module */
    /* is refreshed. Otherwise, the agenda of the current module is  */
    /* refreshed.                                                    */
    /*===============================================================*/

    if (numArgs == 1)
    {
        theModule = GetModuleName(theEnv,(char*)"refresh-agenda",1,&error);
        if (error) return;
    }
    else
    {
        theModule = ((struct defmodule *) EnvGetCurrentModule(theEnv));
    }

    /*===============================================*/
    /* Refresh the agenda of the appropriate module. */
    /*===============================================*/

    EnvRefreshAgenda(theEnv,theModule);
}
コード例 #6
0
ファイル: sockinet.cpp プロジェクト: Eric-De/voiceglue
int sockinetbuf::connect (unsigned long addr,
			  const char* service_name,
			  const char* protocol_name)
{
  sockinetaddr sa (GetModuleName(), GetLog(), GetDiagBase(), addr,
		   service_name, protocol_name);
  return connect (sa);
}
コード例 #7
0
ファイル: sockinet.cpp プロジェクト: Eric-De/voiceglue
sockinetaddr sockinetbuf::peeraddr() const
{
  sockinetaddr sin (GetModuleName(), GetLog(), GetDiagBase());
  socklen_t len = sin.size();
  if (::getpeername(rep->sock, sin.addr (), &len) == -1)
    SOCK_ERROR("sockinetbuf", "getpeername");
  return sin;
}
コード例 #8
0
ファイル: sockinet.cpp プロジェクト: Eric-De/voiceglue
int sockinetbuf::connect (const char* host_name,
			  const char* service_name,
			  const char* protocol_name)
{
  sockinetaddr sa (GetModuleName(), GetLog(), GetDiagBase(), host_name,
		   service_name, protocol_name);
  return connect (sa);
}
コード例 #9
0
MainLoop::MainLoop(LuaInterpreter& lua)
    : mLua(lua)
    , mRenderer(Utils::make_unique<NullRenderer>(mLua))
{
    atexit(SDL_Quit);

    instances.Add(mLua.GetState(), *this);
    mLua.RegisterAPI(GetModuleName(), GetAPI().data());
}
コード例 #10
0
ファイル: FuzzerTracePC.cpp プロジェクト: CTSRD-SOAAP/llvm
void TracePC::PrintCoverage() {
  if (!EF->__sanitizer_symbolize_pc ||
      !EF->__sanitizer_get_module_and_offset_for_pc) {
    Printf("INFO: __sanitizer_symbolize_pc or "
           "__sanitizer_get_module_and_offset_for_pc is not available,"
           " not printing coverage\n");
    return;
  }
  Printf("COVERAGE:\n");
  std::string LastFunctionName = "";
  std::string LastFileStr = "";
  std::set<size_t> UncoveredLines;
  std::set<size_t> CoveredLines;

  auto FunctionEndCallback = [&](const std::string &CurrentFunc,
                                 const std::string &CurrentFile) {
    if (LastFunctionName != CurrentFunc) {
      if (CoveredLines.empty() && !UncoveredLines.empty()) {
        Printf("UNCOVERED_FUNC: %s\n", LastFunctionName.c_str());
      } else {
        for (auto Line : UncoveredLines) {
          if (!CoveredLines.count(Line))
            Printf("UNCOVERED_LINE: %s %s:%zd\n", LastFunctionName.c_str(),
                   LastFileStr.c_str(), Line);
        }
      }

      UncoveredLines.clear();
      CoveredLines.clear();
      LastFunctionName = CurrentFunc;
      LastFileStr = CurrentFile;
    }
  };

  for (size_t i = 0; i < NumPCTables; i++) {
    auto &M = ModulePCTable[i];
    assert(M.Start < M.Stop);
    auto ModuleName = GetModuleName(*M.Start);
    for (auto Ptr = M.Start; Ptr < M.Stop; Ptr++) {
      auto PC = *Ptr;
      auto VisualizePC = GetNextInstructionPc(PC);
      bool IsObserved = ObservedPCs.count(PC);
      std::string FileStr = DescribePC("%s", VisualizePC);
      if (!IsInterestingCoverageFile(FileStr)) continue;
      std::string FunctionStr = DescribePC("%F", VisualizePC);
      FunctionEndCallback(FunctionStr, FileStr);
      std::string LineStr = DescribePC("%l", VisualizePC);
      size_t Line = std::stoul(LineStr);
      if (IsObserved && CoveredLines.insert(Line).second)
        Printf("COVERED: %s %s:%zd\n", FunctionStr.c_str(), FileStr.c_str(),
               Line);
      else
        UncoveredLines.insert(Line);
    }
  }
  FunctionEndCallback("", "");
}
コード例 #11
0
//=============================================================================
void ControllerOptionsButtons::OnHybridButtonNavigatedTo( VPANEL defaultButton )
{
	Panel *panel = ipanel()->GetPanel( defaultButton, GetModuleName() );

	if ( panel )
	{
		OnCommand( panel->GetName() );
	}
}
コード例 #12
0
ファイル: Lusbbase.cpp プロジェクト: Igneel/MCTParamsExplorer
//==============================================================================
// вспомогательные функции для работы с модулем
//==============================================================================
BOOL WINAPI TLUSBBASE::OpenLDeviceByID(WORD VirtualSlot, DWORD DeviceID)
{
	char DeviceName[18];
	WORD i;
	DWORD WindowsVersion;

	// сбросим номер последней ошибки
	LAST_ERROR_NUMBER(0x0);

	// виртуальный слот доступен?
	if(hDevice != INVALID_HANDLE_VALUE) { CloseHandle(hDevice); hDevice = INVALID_HANDLE_VALUE; }

	// определимся с версией используемой Windows
	WindowsVersion = GetWindowsVersion();
	if((WindowsVersion == UNKNOWN_WINDOWS_VERSION) ||
		(WindowsVersion == WINDOWS_32S) || (WindowsVersion == WINDOWS_95) ||
		(WindowsVersion == WINDOWS_NT)) { LAST_ERROR_NUMBER(1); return FALSE; }

	// формируем название драйвера USB
	wsprintf(DeviceName, "\\\\.\\LDev%d", VirtualSlot);
	// попробуем открыть идентификатор для модуля
	hDevice = CreateFile(DeviceName, GENERIC_READ|GENERIC_WRITE, 0x0, NULL,
												OPEN_EXISTING, FILE_FLAG_OVERLAPPED, NULL);
	// проверим: получилось ли открыть устройство?
	if(hDevice == INVALID_HANDLE_VALUE) { LAST_ERROR_NUMBER(2); return FALSE; }
	// попробуем получить первичную информацию об открытом устройсве
	if(!GetDeviceInitialInfo()) { LAST_ERROR_NUMBER(11); CloseLDevice(); return FALSE; }
	// если требуется пройтись по всем ID, то выполним это
	else if(DeviceID == ENUM_ALL_USB_DEVICE_ID)
	{
		for(i = 0x0; i < SUPPORTED_USB_DEVICES_QUANTITY; i++)
			if(DeviceInitialInfo.DeviceID == DEVICES_ID_ARRAY[i]) break;
		if(i == SUPPORTED_USB_DEVICES_QUANTITY) { LAST_ERROR_NUMBER(12); return FALSE; }
	}
	// проверим полученное ID устройства с требуемым
	else if(DeviceInitialInfo.DeviceID != DeviceID)
	{
		if(DeviceID == E2010_ID)
		{
			if(DeviceInitialInfo.DeviceID != E2010B_ID) { LAST_ERROR_NUMBER(13); return FALSE; }
		}
		else { LAST_ERROR_NUMBER(13); return FALSE; }
	}

	// попробуем прочитать название модуля
	if(!GetModuleName(ModuleName)) { LAST_ERROR_NUMBER(3); CloseLDevice(); return FALSE; }
	// определим на какой скорости работает модуль
	else if(!GetUsbSpeed(&UsbSpeed)) { LAST_ERROR_NUMBER(4); CloseLDevice(); return FALSE; }
	// неправильно опредилась скорость работы модуля на шине USB
	else if(UsbSpeed >= INVALID_USB_SPEED_LUSBAPI) { LAST_ERROR_NUMBER(5); CloseLDevice(); return FALSE; }
	// все хорошо :)))))
	else return TRUE;
}
コード例 #13
0
ファイル: Player.cpp プロジェクト: vobject/gaming-experiments
Player::Player(LuaInterpreter& lua, const World& world)
    : mWorld(world)
    , mInput(Utils::make_unique<Input>(SDL_SCANCODE_W, SDL_SCANCODE_S,
                                       SDL_SCANCODE_A, SDL_SCANCODE_D,
                                       SDL_SCANCODE_E, SDL_SCANCODE_F))
{
    init_me_next = this;
    LuaHelper::InitInstance("player", "player.lua", l_init);
    init_me_next = nullptr;

    instances.Add(lua.GetState(), *this);
    lua.RegisterAPI(GetModuleName(), GetAPI().data());
}
コード例 #14
0
ファイル: TraceModule.c プロジェクト: ago/wimax-ns
EXPORT void TraceAgent_PrintTrace(const char *fmt, ...)
{
    va_list arglist;
    time_t currTime;
    struct tm timeinfo;

    const char *delimitedFileName = NULL;
    int tmpByteWritten;
    char userMessage[512] = {0}, fullMsg[512 + 128] = {0};

    // Make sure that the log file is initialized
    if (gLogFile == NULL)
        return;

    if ((gMessageProp.moduleID & gModuleID) && (gMessageProp.severity & gSeverity)) {

        delimitedFileName = strrchr(gMessageProp.file, '/');
        if (delimitedFileName == NULL) {
            delimitedFileName = gMessageProp.file;
        } else {
            delimitedFileName = delimitedFileName + 1;
        }

        currTime = time(NULL);
        timeinfo = *(localtime(&currTime));

        va_start(arglist, fmt);
        vsnprintf(userMessage, 512, fmt, arglist);
        va_end(arglist);

        OSAL_snprintf(fullMsg, 512 + 128, "%s [%s]", userMessage, gMessageProp.function);



        tmpByteWritten = fprintf(gLogFile, "%02d:%02d:%02d:%12u @%-8s@%-15s@%-150s@%-16s(%d)\t@%s\n",
                                 timeinfo.tm_hour,
                                 timeinfo.tm_min,
                                 timeinfo.tm_sec,
                                 OSAL_get_threadid(),
                                 GetSeverityName((Severities)gMessageProp.severity),
                                 GetModuleName((MODULE_IDS)gMessageProp.moduleID),
                                 fullMsg,
                                 delimitedFileName,
                                 gMessageProp.line,
                                 gcProcessName);

        fflush(gLogFile);
    }

    OSAL_exit_critical_section(&csWriteProt);
}
コード例 #15
0
ファイル: tree.cpp プロジェクト: rubenseam/dfptree
// Reads the input and builds ordered FPTrees
const bool Tree::_build() {

	_support *= _global_frequency;
	std::vector<unsigned int> data;

	Reader<DELIM> reader(_inpath, _support, _table);
	while (reader.read(data)) _fptree.insert(data);

	std::cout << ">>> " << GetModuleName() << '[' << GetRank()
		<< "] - # nodes: " << _fptree.nodecount() << std::endl;
	// MemInfo();
	return true;

}
コード例 #16
0
ファイル: kgc_mailmodule.cpp プロジェクト: github188/yol
BOOL KGC_MailModule::OnInit()
{
	BOOL bResult = FALSE;

	QCONFIRM_RET_FALSE(NULL != m_pIKGcQuery);

	g_GcModuleInitHelper_Log(GetModuleName());

	bResult = m_pIKGcQuery->QueryInterface(IID_IKG_GCScriptEnv, (void**)&g_pScriptEnv);
	QCONFIRM_RET_NULL(bResult);
	g_GcModuleInitHelper_Script(GetModuleName(), g_pScriptEnv);

	bResult = m_pIKGcQuery->QueryInterface(IID_IKG_GCServer, (void**)&m_pIKGcServer);
	QCONFIRM_RET_FALSE(bResult && NULL != m_pIKGcServer);

	bResult = m_pIKGcQuery->QueryInterface(IID_IKG_OnlinePlayerMgr, (void**)&m_pIKOnlinePlayerMgr);
	QCONFIRM_RET_FALSE(bResult && NULL != m_pIKOnlinePlayerMgr);

	bResult = m_pIKGcServer->RegisterGsProcessor((IKProcessServer*)this);
	QCONFIRM_RET_FALSE(bResult);

	return KMailCenter::Instance()->Init();
}
コード例 #17
0
void CObjectOStreamXml::x_WriteClassNamespace(TTypeInfo type)
{
    if (type->GetName().find(':') != string::npos) {
        return;
    }
    OpenTagEndBack();

    if (m_UseSchemaLoc) {
        m_Output.PutEol();
        m_Output.PutString("   ");
    }
    m_Output.PutString(" xmlns");
    if (!m_CurrNsPrefix.empty()) {
       m_Output.PutChar(':');
       m_Output.PutString(m_CurrNsPrefix);
    }
    m_Output.PutString("=\"");

    string ns_name( m_NsPrefixToName[m_CurrNsPrefix]);
    if (ns_name.empty()) {
        ns_name = GetDefaultSchemaNamespace();
    }
    m_Output.PutString(ns_name + "\"");

    if (m_UseSchemaLoc) {
        m_Output.PutEol();
        string xs_name("http://www.w3.org/2001/XMLSchema-instance");
        string xs_prefix("xs");
        if (m_NsNameToPrefix.find(xs_name) == m_NsNameToPrefix.end()) {
            for (char a='a';
                m_NsPrefixToName.find(xs_prefix) != m_NsPrefixToName.end(); ++a) {
                xs_prefix += a;
            }
            m_NsPrefixToName[xs_prefix] = xs_name;
            m_NsNameToPrefix[xs_name] = xs_prefix;
            m_Output.PutString("    xmlns:");
            m_Output.PutString(xs_prefix + "=\"");
            m_Output.PutString(xs_name + "\"");
            m_Output.PutEol();
            m_Output.PutString("    ");
            m_Output.PutString(xs_prefix);
            m_Output.PutString(":schemaLocation=\"");
            m_Output.PutString(ns_name + " ");
            m_Output.PutString(GetDTDFilePrefix() + GetModuleName(type));
            m_Output.PutString(".xsd\"");
            m_Output.PutEol();
        }
    }
    OpenTagEnd();
}
コード例 #18
0
HaarDetectorBody::HaarDetectorBody(const VertexElement& vertexElement)
    :   Body(vertexElement),
        imageMessageIn_(NULL),
        prevImageMessageIn_(NULL),
        rectangleMessageIn_(NULL),
        param_(NULL)
{
    param_ = new HaarDetectorParam(GetModulConfigurationFs());

    if(!cascade_.load(GlobalSettingsConstPtr->GetDirectories().moduleSettings + GetModuleName() + "/" + param_->cascadeName))
    {
        CV_Error(-1, "Could not load cascade classifier: " + param_->cascadeName + ".");
    }
}
コード例 #19
0
AnafesticaString TConfigRegistryHModSingleton::GetProductPath()
{
//    TFileVersionInfo const Info(
//        GetModuleName( reinterpret_cast<unsigned>( HInstance ) )
//    );
    shared_ptr<TFileVersionInfo> const Info(
        new TFileVersionInfo(
            GetModuleName( reinterpret_cast<unsigned>( HInstance ) )
        )
    );

    return Info->CompanyName + TEXT( "\\" )+
           Info->ProductName + TEXT( "\\" ) +
           Info->ProductVersion;
}
コード例 #20
0
void CObjectOStreamXml::WriteFileHeader(TTypeInfo type)
{
    if (m_UseXmlDecl) {
        m_Output.PutString("<?xml version=\"1.0");
        switch (m_Encoding) {
        default:
            break;
        case eEncoding_UTF8:
            m_Output.PutString("\" encoding=\"UTF-8");
            break;
        case eEncoding_ISO8859_1:
            m_Output.PutString("\" encoding=\"ISO-8859-1");   
            break;
        case eEncoding_Windows_1252:
            m_Output.PutString("\" encoding=\"Windows-1252");   
            break;
        }
        m_Output.PutString("\"?>");
    }

    if (!m_UseSchemaRef && m_UseDTDRef) {
        if (m_UseXmlDecl) {
            m_Output.PutEol();
        }
        m_Output.PutString("<!DOCTYPE ");
        m_Output.PutString(type->GetName());
    
        if (m_UsePublicId) {
            m_Output.PutString(" PUBLIC \"");
            if (m_PublicId.empty()) {
                m_Output.PutString("-//NCBI//");
                m_Output.PutString(GetPublicModuleName(type));
                m_Output.PutString("/EN");
            } else {
                m_Output.PutString(m_PublicId);
            }
            m_Output.PutString("\"");
        } else {
            m_Output.PutString(" SYSTEM");
        }
        m_Output.PutString(" \"");
        m_Output.PutString(GetDTDFilePrefix() + GetModuleName(type));
        m_Output.PutString(".dtd\">");
    } else if (!m_UseXmlDecl) {
        m_SkipIndent = true;
    }
    m_LastTagAction = eTagClose;
}
コード例 #21
0
ファイル: sockinet.cpp プロジェクト: Eric-De/voiceglue
int sockinetbuf::bind_until_success (int portno)
// a. bind to (INADDR_ANY, portno)
// b. if success return 0
// c. if failure and errno is EADDRINUSE, portno++ and go to step a.
// d. return errno.
{
  for (;;) {
    sockinetaddr sa (GetModuleName(), GetLog(), GetDiagBase(), 
		     (unsigned long) INADDR_ANY, portno++);
    int eno = bind (sa);
    if (eno == 0)
      return 0;
    if (errno != EADDRINUSE)
      return errno;
  }
}
コード例 #22
0
ファイル: CrashHandler.cpp プロジェクト: NGenesis/titanmods
void GetCallStack(_EXCEPTION_POINTERS* pException, List<LoadedModule*>* modules, StringList& headers){
	typedef struct STACK {
		STACK* Ebp;
		PBYTE Ret_Addr;
		DWORD Param[0];
	} STACK, *PSTACK;

	STACK Stack = {0, 0};
	PSTACK Ebp;
	Stack.Ebp = (PSTACK)pException->ContextRecord->Ebp;
	Stack.Ret_Addr = (PBYTE)pException->ExceptionRecord->ExceptionAddress;
	Ebp = &Stack;

	for(unsigned int i = 0; (i < MAX_CALL_STACK && !IsBadReadPtr(Ebp, sizeof(PSTACK)) && !IsBadCodePtr(FARPROC(Ebp->Ret_Addr))); ++i, Ebp = Ebp->Ebp){
		unsigned int addr = (unsigned int)Ebp->Ret_Addr;
		headers.push_back(String("Call-Stack-%1: %2 %3").arg(i).arg(GetModuleName(addr, modules)).arg(addr, 16, true, 8));
	}
}
コード例 #23
0
ファイル: engine.c プロジェクト: femto/rbclips
globle void ShowBreaksCommand(
  void *theEnv)
  {
   int numArgs, error;
   struct defmodule *theModule;

   if ((numArgs = EnvArgCountCheck(theEnv,"show-breaks",NO_MORE_THAN,1)) == -1) return;

   if (numArgs == 1)
     {
      theModule = GetModuleName(theEnv,"show-breaks",1,&error);
      if (error) return;
     }
   else
     { theModule = ((struct defmodule *) EnvGetCurrentModule(theEnv)); }

   EnvShowBreaks(theEnv,WDISPLAY,theModule);
  }
コード例 #24
0
ファイル: map.c プロジェクト: tmikov/a51
/* ************************************************************************
   Function: ComposeObjModuleName
   Description:
*/
void ComposeObjModuleName(int nObjModule)
{
  struct ObjFileData *pObj;

  pObj = AtItem(&ObjFilesCollection, nObjModule);

  if (pObj->nModuleName != -1)
  {
    ASSERT(pObj->szLibName[0] != '\0');
    sprintf(szModuleName, "%s (%s)", GetModuleName(pObj->nModuleName), pObj->szLibName);
  }
  else
  {
    ASSERT(pObj->szLibName[0] == '\0');
    ASSERT(pObj->nObjPos == 0);
    strcpy(szModuleName, pObj->szObjName);
  }
}
コード例 #25
0
ファイル: CArchonProcess.cpp プロジェクト: kronosaur/Hexarc
bool CArchonProcess::OnModuleStart (void)

//	OnModuleStart
//
//	Sends a message to central process telling it our status

	{
	//	If we're not the CentralModule then we need to send a message to
	//	this machine's Exarch telling it that we have started.

	if (!m_bCentralModule && !m_bConsoleMode)
		{
		//	Figure out the Mnemosynth sequence number for this endpoint at this
		//	point in time. We send it over to Exarch so that it waits until it
		//	synchronizes to that point before assuming that loading is complete.

		CString sEndpoint = CMnemosynthDb::GenerateEndpointName(GetMachineName(), GetModuleName());
		DWORD dwSeq = m_MnemosynthDb.GetSequence(sEndpoint);
		ASSERT(dwSeq != 0xffffffff);
		if (dwSeq == 0xffffffff)
			{
			Log(MSG_LOG_ERROR, ERR_UNABLE_TO_OPEN_MNEMOSYNTH);
			return false;
			}

		//	Compose the message

		CComplexArray *pArray = new CComplexArray;
		pArray->Insert(m_sName);
		pArray->Insert((int)dwSeq);

		if (!SendMessageCommand(ADDR_EXARCH_COMMAND, MSG_EXARCH_ON_MODULE_START, NULL_STR, 0, CDatum(pArray)))
			{
			Log(MSG_LOG_ERROR, ERR_UNABLE_TO_SEND_TO_EXARCH);
			return false;
			}
		}

	//	Done

	return true;
	}
コード例 #26
0
ファイル: typestr.cpp プロジェクト: swuecho/igblast
string CTypeStrings::GetModuleName(SInternalNames* names) const
{
    string module_name = GetModuleName();
    names->m_OwnerName.erase();
    names->m_MemberName.erase();
#if 1
    if ( module_name.empty() ) {
        // internal type
        const CDataType* this_type = DataType();
        if ( this_type ) {
            names->m_OwnerName = this_type->IdName();
            SIZE_TYPE dot = names->m_OwnerName.rfind('.');
            if ( dot != NPOS ) {
                names->m_MemberName = names->m_OwnerName.substr(dot+1);
                names->m_OwnerName.resize(dot);
            }
            module_name = this_type->GetModule()->GetName();
        }
    }
#endif
    return module_name;
}
コード例 #27
0
	std::wstring GetAppName()
	{
		std::wstring result;

		// Try environment variable first, executable name next.
		if ((result = GetEnvironmentVariable(L"BEARLIB_APPNAME")).empty())
			result = GetModuleName();

		// Cut off path part.
		size_t slash_pos = result.find_last_of(kPathSeparator);
		if (slash_pos != std::wstring::npos)
			result = result.substr(slash_pos+1);

		// Cut off possible extension.
		size_t period_pos = result.find_last_of(L".");
		if (period_pos != std::wstring::npos)
			result = result.substr(0, period_pos);

		if (result.empty())
			result = L"BearLibTerminal";

		return result;
	}
コード例 #28
0
ファイル: dcMap.cpp プロジェクト: JlblC/dcmap
static int CountRunnings()
{
	HANDLE h;
	PROCESSENTRY32W pe;

	h=CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS,NULL);
	pe.dwSize=sizeof(pe);
	Process32FirstW(h,&pe);

	String szModule = GetModuleName(0);

	int Count=0;
	while(true)
	{
		if(!_wcsicmp(L"dcmap.exe",pe.szExeFile))
		{
			  HANDLE h;
			  MODULEENTRY32 mdl;
			  h=CreateToolhelp32Snapshot(TH32CS_SNAPMODULE,pe.th32ProcessID);
			  mdl.dwSize=sizeof(MODULEENTRY32);
			  Module32First(h,&mdl);
			  while(1)
			  {
				if(szModule == mdl.szExePath)
				{
					Count++;
					break;
				}
				if (!Module32Next(h,&mdl)) break;
			  }
			  CloseHandle(h);
		}
		if (!Process32NextW(h,&pe)) break;
	  }
	  return Count;
}
コード例 #29
0
ファイル: receive.cpp プロジェクト: kxepal/miranda-ng
// This function handles the ACK received from that hooked.
int handleAckSMS(WPARAM wParam, LPARAM lParam)
{
	if (!lParam)
		return 0;
	if (((ACKDATA*)lParam)->type != ICQACKTYPE_SMS)
		return 0;

	char szPhone[MAX_PHONE_LEN] = { 0 };
	TCHAR tszPhone[MAX_PHONE_LEN] = { 0 };
	LPSTR lpszXML = (LPSTR)((ACKDATA*)lParam)->lParam, lpszData, lpszPhone;
	size_t dwXMLSize = 0, dwDataSize, dwPhoneSize;
	ACKDATA *ack = ((ACKDATA*)lParam);

	if (lpszXML)
		dwXMLSize = mir_strlen(lpszXML);

	if (GetXMLFieldEx(lpszXML, dwXMLSize, &lpszData, &dwDataSize, "sms_message", "text", NULL)) {
		if (GetXMLFieldEx(lpszXML, dwXMLSize, &lpszPhone, &dwPhoneSize, "sms_message", "sender", NULL)) {
			LPSTR lpszMessageUTF;
			size_t dwBuffLen, dwMessageXMLEncodedSize, dwMessageXMLDecodedSize;
			DBEVENTINFO dbei = { sizeof(dbei) };

			dwBuffLen = (dwDataSize + MAX_PATH);
			dbei.pBlob = (LPBYTE)MEMALLOC((dwBuffLen + dwPhoneSize));
			LPWSTR lpwszMessageXMLEncoded = (LPWSTR)MEMALLOC((dwBuffLen*sizeof(WCHAR)));
			LPWSTR lpwszMessageXMLDecoded = (LPWSTR)MEMALLOC((dwBuffLen*sizeof(WCHAR)));
			if (dbei.pBlob && lpwszMessageXMLEncoded && lpwszMessageXMLDecoded) {
				dwMessageXMLEncodedSize = MultiByteToWideChar(CP_UTF8, 0, lpszData, (int)dwDataSize, lpwszMessageXMLEncoded, (int)dwBuffLen);
				DecodeXML(lpwszMessageXMLEncoded, dwMessageXMLEncodedSize, lpwszMessageXMLDecoded, dwBuffLen, &dwMessageXMLDecodedSize);
				lpszMessageUTF = (LPSTR)lpwszMessageXMLEncoded;
				WideCharToMultiByte(CP_UTF8, 0, lpwszMessageXMLDecoded, (int)dwMessageXMLDecodedSize, lpszMessageUTF, (int)dwBuffLen, NULL, NULL);

				dwPhoneSize = CopyNumberA(szPhone, lpszPhone, dwPhoneSize);
				dwPhoneSize = MultiByteToWideChar(CP_UTF8, 0, szPhone, (int)dwPhoneSize, tszPhone, MAX_PHONE_LEN);
				MCONTACT hContact = HContactFromPhone(tszPhone, dwPhoneSize);

				dbei.szModule = GetModuleName(hContact);
				dbei.timestamp = time(NULL);
				dbei.flags = DBEF_UTF;
				dbei.eventType = ICQEVENTTYPE_SMS;
				dbei.cbBlob = (mir_snprintf((LPSTR)dbei.pBlob, ((dwBuffLen + dwPhoneSize)), "SMS From: +%s\r\n%s", szPhone, lpszMessageUTF) + sizeof(DWORD));
				//dbei.pBlob=(LPBYTE)lpszBuff;
				(*((DWORD*)(dbei.pBlob + (dbei.cbBlob - sizeof(DWORD))))) = 0;
				MEVENT hResult = db_event_add(hContact, &dbei);
				if (hContact == NULL) {
					if (RecvSMSWindowAdd(NULL, ICQEVENTTYPE_SMS, tszPhone, dwPhoneSize, (LPSTR)dbei.pBlob, dbei.cbBlob)) {
						db_event_markRead(hContact, hResult);
						SkinPlaySound("RecvSMSMsg");
					}
				}
			}
			MEMFREE(lpwszMessageXMLDecoded);
			MEMFREE(lpwszMessageXMLEncoded);
			MEMFREE(dbei.pBlob);
		}
	}
	else
		if (GetXMLFieldEx(lpszXML, dwXMLSize, &lpszData, &dwDataSize, "sms_delivery_receipt", "delivered", NULL)) {
			if (GetXMLFieldEx(lpszXML, dwXMLSize, &lpszPhone, &dwPhoneSize, "sms_delivery_receipt", "destination", NULL)) {
				dwPhoneSize = CopyNumberA(szPhone, lpszPhone, dwPhoneSize);
				dwPhoneSize = MultiByteToWideChar(CP_UTF8, 0, szPhone, (int)dwPhoneSize, tszPhone, MAX_PHONE_LEN);
				MCONTACT hContact = HContactFromPhone(tszPhone, dwPhoneSize);

				DBEVENTINFO dbei = { 0 };
				dbei.cbSize = sizeof(dbei);
				dbei.szModule = GetModuleName(hContact);
				dbei.timestamp = time(NULL);
				dbei.flags = DBEF_UTF;
				dbei.eventType = ICQEVENTTYPE_SMSCONFIRMATION;
				if (CompareStringA(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), NORM_IGNORECASE, lpszData, (int)dwDataSize, "yes", 3) == CSTR_EQUAL) {
					dbei.cbBlob = (MAX_PHONE_LEN + MAX_PATH);
					dbei.pBlob = (PBYTE)MEMALLOC(dbei.cbBlob);
					if (dbei.pBlob) dbei.cbBlob = (mir_snprintf((LPSTR)dbei.pBlob, dbei.cbBlob, "SMS Confirmation From: +%s\r\nSMS was sent succesfully", szPhone) + 4);
				}
				else {
					if (GetXMLFieldEx(lpszXML, dwXMLSize, &lpszData, &dwDataSize, "sms_delivery_receipt", "error", "params", "param", NULL) == FALSE) {
						lpszData = "";
						dwDataSize = 0;
					}
					dbei.cbBlob = (int)(MAX_PHONE_LEN + MAX_PATH + dwDataSize);
					dbei.pBlob = (PBYTE)MEMALLOC(dbei.cbBlob);
					if (dbei.pBlob) {
						dbei.cbBlob = mir_snprintf((LPSTR)dbei.pBlob, dbei.cbBlob, "SMS Confirmation From: +%s\r\nSMS was not sent succesfully: ", szPhone);
						memcpy((dbei.pBlob + dbei.cbBlob), lpszData, dwDataSize);
						dbei.cbBlob += (int)(dwDataSize + sizeof(DWORD));
						(*((DWORD*)(dbei.pBlob + (dbei.cbBlob - sizeof(DWORD))))) = 0;
					}
				}

				if (dbei.pBlob) {
					if (hContact)
						db_event_add(hContact, &dbei);
					else
						RecvSMSWindowAdd(NULL, ICQEVENTTYPE_SMSCONFIRMATION, tszPhone, dwPhoneSize, (LPSTR)dbei.pBlob, dbei.cbBlob);

					MEMFREE(dbei.pBlob);
				}
			}
		}
		else
			if ((ack->result == ACKRESULT_FAILED) || GetXMLFieldEx(lpszXML, dwXMLSize, &lpszData, &dwDataSize, "sms_response", "deliverable", NULL)) {
				HWND hWndDlg = SendSMSWindowHwndByHProcessGet(ack->hProcess);
				if (hWndDlg) {
					char szNetwork[MAX_PATH];

					KillTimer(hWndDlg, wParam);
					GetXMLFieldExBuff(lpszXML, dwXMLSize, szNetwork, sizeof(szNetwork), NULL, "sms_response", "network", NULL);

					if (ack->result == ACKRESULT_FAILED || CompareStringA(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), NORM_IGNORECASE, lpszData, (int)dwDataSize, "no", 2) == CSTR_EQUAL) {
						char szBuff[1024];
						TCHAR tszErrorMessage[1028];
						LPSTR lpszErrorDescription;

						if (SendSMSWindowMultipleGet(hWndDlg)) {
							TVITEM tvi;
							tvi.mask = TVIF_TEXT;
							tvi.hItem = SendSMSWindowHItemSendGet(hWndDlg);
							tvi.pszText = tszPhone;
							tvi.cchTextMax = _countof(tszPhone);
							TreeView_GetItem(GetDlgItem(hWndDlg, IDC_NUMBERSLIST), &tvi);
						}
						else GetDlgItemText(hWndDlg, IDC_ADDRESS, tszPhone, _countof(szPhone));

						if (ack->result == ACKRESULT_FAILED)
							lpszErrorDescription = lpszXML;
						else {
							lpszErrorDescription = szBuff;
							GetXMLFieldExBuff(lpszXML, dwXMLSize, szBuff, sizeof(szBuff), NULL, "sms_response", "error", "params", "param", NULL);
						}

						mir_sntprintf(tszErrorMessage, TranslateT("SMS message didn't send by %S to %s because: %S"), szNetwork, tszPhone, lpszErrorDescription);
						ShowWindow(hWndDlg, SW_SHOWNORMAL);
						EnableWindow(hWndDlg, FALSE);
						HWND hwndTimeOut = CreateDialog(ssSMSSettings.hInstance, MAKEINTRESOURCE(IDD_SENDSMSTIMEDOUT), hWndDlg, SMSTimedOutDlgProc);
						SetDlgItemText(hwndTimeOut, IDC_STATUS, tszErrorMessage);
					}
					else {
						SendSMSWindowDBAdd(hWndDlg);
						if (SendSMSWindowMultipleGet(hWndDlg)) {
							if (SendSMSWindowNextHItemGet(hWndDlg, SendSMSWindowHItemSendGet(hWndDlg))) {
								SendSMSWindowAsSentSet(hWndDlg);
								SendSMSWindowHItemSendSet(hWndDlg, SendSMSWindowNextHItemGet(hWndDlg, SendSMSWindowHItemSendGet(hWndDlg)));
								SendSMSWindowNext(hWndDlg);
							}
							else SendSMSWindowRemove(hWndDlg);
						}
						else {
							if (CompareStringA(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), NORM_IGNORECASE, lpszData, (int)dwDataSize, "yes", 3) == CSTR_EQUAL ||
								CompareStringA(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), NORM_IGNORECASE, lpszData, (int)dwDataSize, "smtp", 4) == CSTR_EQUAL) {
								char szSource[MAX_PATH], szMessageID[MAX_PATH];

								if (DB_SMS_GetByte(NULL, "ShowACK", SMS_DEFAULT_SHOWACK)) {
									HWND hwndAccepted = CreateDialog(ssSMSSettings.hInstance, MAKEINTRESOURCE(IDD_SENDSMSACCEPT), hWndDlg, SMSAcceptedDlgProc);
									if (CompareStringA(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), NORM_IGNORECASE, lpszData, (int)dwDataSize, "yes", 3) == CSTR_EQUAL) {
										GetXMLFieldExBuff(lpszXML, dwXMLSize, szSource, sizeof(szSource), NULL, "sms_response", "source", NULL);
										GetXMLFieldExBuff(lpszXML, dwXMLSize, szMessageID, sizeof(szMessageID), NULL, "sms_response", "message_id", NULL);
									}
									else {
										SetDlgItemText(hwndAccepted, IDC_ST_SOURCE, TranslateT("From:"));
										SetDlgItemText(hwndAccepted, IDC_ST_MESSAGEID, TranslateT("To:"));
										GetXMLFieldExBuff(lpszXML, dwXMLSize, szSource, sizeof(szSource), NULL, "sms_response", "from", NULL);
										GetXMLFieldExBuff(lpszXML, dwXMLSize, szMessageID, sizeof(szMessageID), NULL, "sms_response", "to", NULL);
									}
									SetDlgItemTextA(hwndAccepted, IDC_NETWORK, szNetwork);
									SetDlgItemTextA(hwndAccepted, IDC_SOURCE, szSource);
									SetDlgItemTextA(hwndAccepted, IDC_MESSAGEID, szMessageID);
								}
								else SendSMSWindowRemove(hWndDlg);
							}
							else SendSMSWindowRemove(hWndDlg);
						}
					}
				}
			}
	return 0;
}
コード例 #30
0
ファイル: serial.cpp プロジェクト: swuecho/igblast
void SetModuleName(CEnumeratedTypeValues* info, const char* moduleName)
{
    info->SetModuleName(GetModuleName(moduleName));
}