コード例 #1
0
ファイル: document.cpp プロジェクト: GrimDerp/medusa
bool Document::MakeString(Address const& rAddress, u8 StringType, u16 StringLength, bool Force)
{
  TOffset FileOff;
  if (!ConvertAddressToFileOffset(rAddress, FileOff))
    return false;
  u16 StrLen = GetBinaryStream().StringLength(FileOff);
  if (StrLen == 0)
    return false;
  if (StrLen > StringLength)
    return false;
  ++StrLen; // we want to include '\0'
  auto spNewStr = std::make_shared<String>(StringType, std::min(StrLen, StringLength));
  return SetCell(rAddress, spNewStr, Force);
}
コード例 #2
0
ファイル: document.cpp プロジェクト: GrimDerp/medusa
Cell::SPtr const Document::GetCell(Address const& rAddr) const
{
  boost::mutex::scoped_lock Lock(m_CellMutex);

  CellData CurCellData;
  if (!m_spDatabase->GetCellData(rAddr, CurCellData))
    return nullptr;
  auto spCellData = std::make_shared<CellData>(CurCellData); // TODO: we can avoid this

  switch (CurCellData.GetType())
  {
  case Cell::ValueType:     return std::make_shared<Value>(spCellData);
  case Cell::CharacterType: return std::make_shared<Character>(spCellData);
  case Cell::StringType:    return std::make_shared<String>(spCellData);
  case Cell::InstructionType:
    {
      auto spInsn = std::make_shared<Instruction>();
      spInsn->GetData()->ArchitectureTag() = CurCellData.GetArchitectureTag();
      spInsn->Mode() = CurCellData.GetMode();
      auto spArch = ModuleManager::Instance().GetArchitecture(CurCellData.GetArchitectureTag());
      if (spArch == nullptr)
      {
        Log::Write("core") << "unable to get architecture for " << rAddr << LogEnd;
        return nullptr;
      }
      TOffset Offset;
      ConvertAddressToFileOffset(rAddr, Offset);
      spArch->Disassemble(GetBinaryStream(), Offset, *spInsn, CurCellData.GetMode());
      return spInsn;
    }
  default:
    break;
  }

  return Cell::SPtr();
}
コード例 #3
0
int TEST::Application::Run () {
    
    auto service = std::make_shared<TEST::Service> ();
    TEST::Router router (service);
  
    auto httpFactory (std::make_shared<HTTP::ClientFactory> (router));
    TCP::Server httpServer (mCommandLine.GetOption ("ip"), mCommandLine.GetOption ("port"), httpFactory);
    httpServer.Start ();
    
    RFC6455::Server websockServer (mCommandLine.GetOption ("ip"), mCommandLine.GetOption ("websockport"));
    websockServer.Start ();
    service->GetStringStream ().Pipe (&websockServer, &RFC6455::Server::BroadCast);
    service->GetBinaryStream ().Pipe (&websockServer, &RFC6455::Server::BroadCast);
    
    SSE::Server sseServer (mCommandLine.GetOption ("ip"), mCommandLine.GetOption ("sseport"));
    sseServer.Start ();
    service->GetStringStream ().Pipe (&sseServer, &SSE::Server::BroadCast);
    
    // Block the main thread, wait for Ctrl-C
    APP::ThreadBlocker (SIGINT);
    LOGMESSAGE (OS::Log::kInfo, "Closing application...");

    return 0;
}