コード例 #1
0
ファイル: main_5_1.c プロジェクト: pengwang01/cs154_proj2
void doStage(int isFirst, int *stall, int * cycles, int * counter)
{
	if(pipelineInsts[4]->inst!=0){
		if(debug)printf("DEBUG: writing back\n");
		writeback(pipelineInsts[4]);
	}

	if(pipelineInsts[3]->inst!=0){
		if(debug)printf("DEBUG: memorying\n");
		memory(pipelineInsts[3]);
	}
	// if stall is being set, no need to call any of fowllowing functions
	if(!*stall){
		if(debug)printf("DEBUG: no stall...........\n");
		if(pipelineInsts[2]->inst!=0){
			if(debug)printf("DEBUG: executing\n");
			forwardData(pipelineInsts);	// forward data before execute

			if(debug)printf("DEBUG: instruction is about to get executed: %s\n", pipelineInsts[2]->string);
			execute(pipelineInsts[2]);
		}
		if(pipelineInsts[1]->inst!=0){
			if(debug)printf("DEBUG: decoding\n");

			
			decode(pipelineInsts[1]);
			
			setDependency(pipelineInsts, stall);	// set dependencies after decode

			// if cur inst is bge
			if(pipelineInsts[1]->signals.btype != 0){
				if(debug)printf("DEBUG: calling doBranching\n");
				doBranching(pipelineInsts, stall, cycles, counter);
			}
		}
	}
	if(pipelineInsts[0]->inst!=0 || isFirst){
		if(debug)printf("DEBUG: fetching\n");

		fetch(pipelineInsts[0]);
		if(*stall){		// when stall is being set, needs to defetch one instruction
			/*if(pipelineInsts[1]->signals.btype == 2){
				if(pipelineInsts[2]->aluout >= 0)
					pc = pc + pipelineInsts[1]->imm + 1;
			}*/
			defetch(pipelineInsts[0]);
		}
	}
}
コード例 #2
0
/* static */ DebuggerMemory *
DebuggerMemory::create(JSContext *cx, Debugger *dbg)
{

    Value memoryProto = dbg->object->getReservedSlot(Debugger::JSSLOT_DEBUG_MEMORY_PROTO);
    RootedObject memory(cx, NewObjectWithGivenProto(cx, &class_,
                                                    &memoryProto.toObject(), nullptr));
    if (!memory)
        return nullptr;

    dbg->object->setReservedSlot(Debugger::JSSLOT_DEBUG_MEMORY_INSTANCE, ObjectValue(*memory));
    memory->setReservedSlot(JSSLOT_DEBUGGER, ObjectValue(*dbg->object));

    return &memory->as<DebuggerMemory>();
}
コード例 #3
0
ファイル: main.cpp プロジェクト: caizezhi/SystemC_RAM
//#include"match.h"
int sc_main(int argc, char*argv[])
{
	Memory memory("memory", 2048);Test test("test");//match mt("mt");
	sc_signal<bool>  CE;sc_signal<bool> WE;
	sc_signal_rv<8> data;
	sc_signal<sc_bv<32>>address;
	memory.CE(CE);
	memory.WE(WE);
	memory.data(data);
	memory.address(address);
	test.CE(CE);
	test.WE(WE);
	test.address(address);
	sc_start();
	return 0;
};
コード例 #4
0
ファイル: Actor.cpp プロジェクト: OLR-xray/XRay-NEW
void CActor::reinit	()
{
	character_physics_support()->movement()->CreateCharacter		();
	character_physics_support()->movement()->SetPhysicsRefObject	(this);
	CEntityAlive::reinit						();
	CInventoryOwner::reinit						();

	character_physics_support()->in_Init		();
	material().reinit							();

	m_pUsableObject								= NULL;
	memory().reinit								();
	
	set_input_external_handler					(0);
	m_time_lock_accel							= 0;
}
コード例 #5
0
ファイル: WorldTests.cpp プロジェクト: MrJaqbq/Volkhvy
	TEST_F(WorldTest, CanRemoveEntity)
	{
		MemoryBlock memory(*allocator, "CanRemoveEntity");
		Logic::World world(memory);

		auto handle = world.createEntity(nullptr);
		world.removeEntity(handle);

		EXPECT_FALSE(world.isAlive(handle));
		EXPECT_TRUE(world.isAliveInCurrentFrame(handle));

		world.refresh();

		EXPECT_FALSE(world.isAlive(handle));
		EXPECT_FALSE(world.isAliveInCurrentFrame(handle));
	}
コード例 #6
0
ファイル: frontend.c プロジェクト: EtchedPixels/FUZIX
static void append_obj(struct objhead *h, char *p, uint8_t type)
{
	struct obj *o = malloc(sizeof(struct obj));
	if (o == NULL)
		memory();
	o->name = p;
	o->next = NULL;
	o->used = 0;
	o->type = type;
	if (h->tail)
		h->tail->next = o;
	else {
		h->tail = o;
		h->head = o;
	}
}
コード例 #7
0
void TeamHandler::send()
{
  if(!port || out.isEmpty())
    return;

  char buffer[sizeof(RoboCup::SPLStandardMessage)];

  SPLStandardMessage outMsg;
  const unsigned size = outMsg.fromMessageQueue(out);

  OutBinaryMemory memory(buffer);
  memory << outMsg;

  if(socket.write(buffer, size))
    out.clear();
}
コード例 #8
0
void MemoryHeapPmem::revoke()
{
    SortedVector< wp<MemoryPmem> > allocations;

    { // scope for lock
        Mutex::Autolock _l(mLock);
        allocations = mAllocations;
    }
    
    ssize_t count = allocations.size();
    for (ssize_t i=0 ; i<count ; i++) {
        sp<MemoryPmem> memory(allocations[i].promote());
        if (memory != 0)
            memory->revoke();
    }
}
コード例 #9
0
ファイル: vm.cpp プロジェクト: clockmaker002/rubinius
  VM::VM(uint32_t id, SharedState& shared, const char* name)
    : memory::ManagedThread(id, shared, memory::ManagedThread::eRuby, name)
    , call_frame_(NULL)
    , thread_nexus_(shared.thread_nexus())
    , saved_call_site_information_(NULL)
    , fiber_stacks_(this, shared)
    , park_(new Park)
    , stack_start_(0)
    , stack_size_(0)
    , current_stack_start_(0)
    , current_stack_size_(0)
    , interrupt_with_signal_(false)
    , interrupt_by_kill_(false)
    , check_local_interrupts_(false)
    , thread_step_(false)
    , interrupt_lock_()
    , method_missing_reason_(eNone)
    , constant_missing_reason_(vFound)
    , zombie_(false)
    , main_thread_(false)
    , thread_phase_(ThreadNexus::cUnmanaged)
    , profile_interval_(0)
    , profile_counter_(0)
    , shared(shared)
    , waiting_channel_(this, nil<Channel>())
    , interrupted_exception_(this, nil<Exception>())
    , thread(this, nil<Thread>())
    , current_fiber(this, nil<Fiber>())
    , root_fiber(this, nil<Fiber>())
    , waiting_object_(this, cNil)
    , profile_(this, nil<Tuple>())
    , profile_sample_count_(0)
    , max_profile_entries_(15)
    , min_profile_call_count_(0)
    , native_method_environment(NULL)
    , custom_wakeup_(NULL)
    , custom_wakeup_data_(NULL)
    , thread_state_(this)
  {
    if(memory()) {
      local_slab_.refill(0, 0);
    }

    set_profile_interval();

    allocation_tracking_ = shared.config.allocation_tracking;
  }
コード例 #10
0
void KisMemoryWindowTest::testTopReports()
{

    // default window size in 16 MiB
    KisMemoryWindow memory(QString(QDir::currentPath()), DEFAULT_WINDOW_SIZE);

    // write 1024 chunks 4 MiB each, hi-limit 4GiB

    const quint8 oddValue = 0xee;
    const qint64 chunkLength = 4 * MiB;

    QScopedArrayPointer<quint8> writeBuffer(new quint8[chunkLength]);
    memset(writeBuffer.data(), oddValue, chunkLength);

    QScopedArrayPointer<quint8> readBuffer(new quint8[chunkLength]);

    qint64 maxChunk = 0;

    for (int i = 0; i < 1024; i++) {
        {
            int chunkIndex = qrand() % 1024;

            qint64 chunkStart = chunkIndex * chunkLength;
            maxChunk = qMax(chunkStart, maxChunk);

            quint8 *ptr;
            ptr = memory.getWriteChunkPtr(KisChunkData(chunkStart, chunkLength));
            memcpy(ptr, writeBuffer.data(), chunkLength);

            dbgKrita << "Writing chunk at" << chunkStart / chunkLength << "MiB" << "max" << maxChunk / chunkLength;
            QTest::qWait(250);
        }

        {
            int chunkIndex = qrand() % 1024;

            qint64 chunkStart = chunkIndex * chunkLength;

            quint8 *ptr;
            ptr = memory.getReadChunkPtr(KisChunkData(chunkStart, chunkLength));
            memcpy(readBuffer.data(), ptr, chunkLength);

            dbgKrita << "Reading chunk at" << chunkStart / chunkLength << "MiB" << "max" << maxChunk / chunkLength;
            QTest::qWait(250);
        }
    }
}
コード例 #11
0
void CBenchMarker::RunL()
	{
	iTest.Printf(_L("Starting CntModel benchmarks...\n")); // This forces the console to get loaded under WINS - would otherwise scew profiles.

	for (TInt i=0;i<ENumTests;++i)
		{
		StartProfile();
		TInt timeMinorNumber=0;
		TRAPD(err,timeMinorNumber=DoTestL(TTest(i)));
		if (err)
			{
			iLog->LogLine(_L("Test %d left with %d"),i,err);
			break;
			}

		LogResult(i,timeMinorNumber,KTimeProfileFormat,EndProfile());

		User::CompressAllHeaps();
		TMemoryInfoV1Buf memoryBuf;
		UserHal::MemoryInfo(memoryBuf);
		TMemoryInfoV1 memory(memoryBuf());
		const TInt totalK=memory.iTotalRamInBytes>>10;
		const TInt freeK=memory.iFreeRamInBytes>>10;
		const TInt usedK=totalK-freeK;
		LogResult(i,timeMinorNumber+1,KSystemMemoryFormat,usedK);
		
		TInt allocSize;
		User::Heap().AllocSize(allocSize);;
		allocSize>>=10;
		LogResult(i,timeMinorNumber+2,KThreadMemoryFormat,allocSize);
		}

	iTest.Printf(_L("Dump log to comm port? (y/n) "));
	TKeyCode key=iTest.Getch();
	if (key=='y' || key=='Y')
		{
writelog:
		iLog->WriteLogToCommPortL();
		}
	iTest.Printf(_L("\nAgain? (y/n)"));
	key=iTest.Getch();
	if (key=='y' || key=='Y')
		{
		goto writelog;
		}
	}
コード例 #12
0
ファイル: WorldTests.cpp プロジェクト: MrJaqbq/Volkhvy
	TEST_F(WorldTest, AreRemovedEntititesRemovedFromSystem)
	{
		MockCallback onRemoveEntity;

		EXPECT_CALL(onRemoveEntity, Call());

		MemoryBlock memory(*allocator, "AreRemovedEntititesRemovedFromSystem");
		Logic::World world(memory);

		auto handle = world.createEntity(nullptr);
		world.createAndRegisterSystem<MockSystem>(memory, nullptr, nullptr, &onRemoveEntity);
		world.addComponent<MockComponent>(world.getEntity(handle));
		world.refresh();

		world.removeEntity(handle);
		world.refresh();
	}
コード例 #13
0
ファイル: frontend.c プロジェクト: EtchedPixels/FUZIX
void convert_c_to_s(char *path)
{
	char *tmp;
	build_arglist(CMD_CC);
	redirect_in(path);
	tmp = strdup(pathmod(path, ".%", ".@", 0));
	if (tmp == NULL)
		memory();
	redirect_out(tmp);
	run_command();
	build_arglist(CMD_COPT);
	add_argument(COPT_FILE);
	redirect_in(tmp);
	redirect_out(pathmod(path, ".%", ".s", 2));
	run_command();
	free(tmp);
}
コード例 #14
0
ファイル: rat_state_switch.cpp プロジェクト: 2asoft/xray
bool CAI_Rat::switch_to_free_recoil()
{
	if	(
		(m_tLastSound.dwTime >= m_dwLastUpdateTime) && 
		(
		!m_tLastSound.tpEntity || 
		(
		(!switch_to_eat() || (memory().item().selected()->ID() != m_tLastSound.tpEntity->ID())) && 
		(m_tLastSound.tpEntity->g_Team() != g_Team())
		)
		) && 
		!switch_if_enemy()
		)
	{
		return true;
	}
	return false;
}
コード例 #15
0
/* static */
Gdiplus::Bitmap* ResourceBundle::LoadBitmap(DataHandle data_handle, int resource_id)
{
    scoped_refptr<base::RefCountedMemory> memory(
        LoadResourceBytes(data_handle, resource_id));
    if(!memory)
    {
        return NULL;
    }

    Gdiplus::Bitmap* bitmap = BitmapFromMemory(memory->front(), memory->size());
    if(!bitmap)
    {
        NOTREACHED() << "Unable to decode theme image resource " << resource_id;
        return NULL;
    }

    return bitmap;
}
コード例 #16
0
ファイル: LinuxSystem.cpp プロジェクト: 0x90erator/binnavi
std::vector<char> LinuxSystem::readPointedMemory(CPUADDRESS address) {


  unsigned int currentSize = 128;

  while (currentSize != 0) {
    std::vector<char> memory(currentSize, 0);

    if (readMemoryData(&memory[0], address, memory.size())
        == NaviErrors::SUCCESS) {
      return memory;
    }

    currentSize /= 2;
  }

  return std::vector<char>();
}
コード例 #17
0
ファイル: ai_stalker_misc.cpp プロジェクト: denanden/xray-16
void CAI_Stalker::process_enemies		()
{
	if (memory().enemy().selected())
		return;

	typedef MemorySpace::squad_mask_type	squad_mask_type;
	typedef CVisualMemoryManager::VISIBLES	VISIBLES;

	squad_mask_type				mask = memory().visual().mask();
	VISIBLES::const_iterator	I = memory().visual().objects().begin();
	VISIBLES::const_iterator	E = memory().visual().objects().end();
	for ( ; I != E; ++I) {
		if (!(*I).visible(mask))
			continue;

		const CAI_Stalker		*member = smart_cast<const CAI_Stalker*>((*I).m_object);
		if (!member)
			continue;

		if (is_relation_enemy(member))
			continue;

		if (!member->g_Alive())
			continue;

		if (!member->memory().enemy().selected()) {
			if (!memory().danger().selected() && member->memory().danger().selected())
				memory().danger().add(*member->memory().danger().selected());
			continue;
		}

		//Alundaio: Only transfer enemy if I can see member at this very moment!
		if (!memory().visual().visible_now(member))
			continue;
		//Alundaio: END

		memory().make_object_visible_somewhen	(member->memory().enemy().selected());
		break;
	}
}
コード例 #18
0
ファイル: device.cpp プロジェクト: pdhahn/occa
  //  |---[ Memory ]--------------------
  memory device::malloc(const dim_t bytes,
                        const void *src,
                        const occa::properties &props) {
    if (bytes == 0) {
      return memory();
    }

    OCCA_ERROR("Trying to allocate "
               << "negative bytes (" << bytes << ")",
               bytes >= 0);

    occa::properties memProps = props + memoryProperties();

    memory mem(dHandle->malloc(bytes, src, memProps));
    mem.setDHandle(dHandle);

    dHandle->bytesAllocated += bytes;

    return mem;
  }
コード例 #19
0
ファイル: myprod.c プロジェクト: sudev/Os-Lab-Nitc
void producer()
{
	int n=0, j;
	share *mem=memory();
	while(1)
	{	
		sem_wait(&mem->empty);
		sem_wait(&mem->mutex);
		
		(mem->buffer)[n++]=mem->i;
		n%=BUFFER_SIZE;
		printf("Producer placed item %d\n", mem->i);
		(mem->i)++;
		
		sem_post(&mem->mutex);
		sem_post(&mem->full);
		for(j=0;j<pdelay;j++);
		
	}
}
コード例 #20
0
ファイル: bitgraphZ2.hpp プロジェクト: vbeffara/mtools
 /**
  * Print some informations concerning the object in a std::string and does a cleanup of the
  * memory.
  *
  * @return  A std::string.
 **/
 std::string stats()
 {
     std::string s;
     s += "*****************************************************\n";
     s += "BitGraphZ2 object statistics\n\n";
     s += "- memory used         : " + toString(memory()) + "Mb\n";
     s += "- lattice represented : [ " + toString(minV()) + " , " + toString(maxV()) + " ]^2\n";
     s += "- Main grid size      : [ " + toString(-LL) + " , " + toString(LL-1) + " ]^2 (" + toString((4*sizeof(int32)*LL*LL)/(1024*1024)) + "Mb)\n";
     s += "- Size of a subsquare : " + toString(N*8) + " x " + toString(N*8) + " (" + toString(sizeof(_MSQ)) + "b each)\n";
     s += "- Number of subsquare : " + toString(VV) + " (" + toString(((int64)VV)*sizeof(_MSQ) /(1024*1024)) + "Mb)\n\n";
     s += "Number of point set : " + toString(nbSet()) + "\n";
     s += "Surrounding square : ";
     if (minX() != LLONG_MAX) {
     s += "[ " + toString(minX()) + " , " + toString(maxX()) + " ] x [ " + toString(minY()) + " , " + toString(maxY()) + " ]\n";
     } else {s += "No point set yet !\n";}
     s += "Memory used before cleanup\t" + toString(v) + "/" + toString(VV) + " (" + toString((int)(100*(((double)v)/((double)VV))))+ "%)\n";
     cleanup();
     s += "Memory used after cleanup\t" + toString(v) + "/" + toString(VV) + " (" + toString((int)(100*(((double)v)/((double)VV))))+ "%)\n";
     s += "*****************************************************\n";
     return s;            
 }
コード例 #21
0
    QString makeFile(const QString &resource)
    {
        QFile memory(resource);
        if (!memory.open(QIODevice::ReadOnly)) {
            qDebug() << "error reading resource" << resource;
            return QString();
        }
        QTemporaryFile *file = new QTemporaryFile;
        file->open();
        file->write(memory.readAll());
        tempFiles.append(file);
        file->flush();
#ifdef Q_OS_WINCE
        // flush does not flush to disk on Windows CE. It flushes it into its application
        // cache. Thus we need to close the file to be able that other processes(lackey) can read it
        QString fileName = file->fileName();
        file->close();
        return fileName;
#endif
        return file->fileName();
    }
コード例 #22
0
ファイル: IndexBuffer.cpp プロジェクト: JJJohan/DX12Engine
	void IndexBuffer::Build()
	{
		size_t size;
		if (!CheckBufferSize(&size))
		{
			return;
		}

		bool sameSize = (size == _heapSize);

		// Perform memory copy.
		size_t offset = 0;
		size_t totalIndices = 0;
		std::unique_ptr<char> memory(new char[size]);
		for (auto it = _instances.begin(); it != _instances.end(); ++it)
		{
			IndexBufferInstance* instance = static_cast<IndexBufferInstance*>(*it);
			std::vector<int> indices = instance->GetIndices();
			size_t copySize = instance->GetSize();

			instance->SetOffset(totalIndices);
			totalIndices += instance->Count();
			memcpy(memory.get() + offset, &indices[0], copySize);
			offset += copySize;
		}

		_heapSize = size_t(offset);
		PrepareHeapResource(D3D12_RESOURCE_STATE_INDEX_BUFFER);

		HeapManager::Upload(this, memory.get());

		// Initialize the index buffer view.
		if (!sameSize)
		{
			_indexBufferView = {};
			_indexBufferView.BufferLocation = _pResource->GetGPUVirtualAddress();
			_indexBufferView.Format = DXGI_FORMAT_R32_UINT;
			_indexBufferView.SizeInBytes = UINT(_heapSize);
		}
	}
コード例 #23
0
ファイル: VertexBuffer.cpp プロジェクト: JJJohan/DX12Engine
	void VertexBuffer::Build()
	{
		size_t size;
		if (!CheckBufferSize(&size))
		{
			return;
		}

		bool sameSize = (size == _heapSize);

		// Perform memory copy.
		size_t offset = 0;
		size_t totalVertices = 0;
		std::unique_ptr<char> memory(new char[size]);
		for (auto it = _instances.begin(); it != _instances.end(); ++it)
		{
			VertexBufferInstance* instance = static_cast<VertexBufferInstance*>(*it);
			std::vector<Vertex> vertices = instance->GetVertices();
			size_t copySize = instance->GetSize();

			instance->SetOffset(totalVertices);
			totalVertices += instance->Count();
			memcpy(memory.get() + offset, &vertices[0], copySize);
			offset += copySize;
		}

		_heapSize = size_t(offset);
		PrepareHeapResource(D3D12_RESOURCE_STATE_VERTEX_AND_CONSTANT_BUFFER);
		HeapManager::Upload(this, memory.get());

		// Initialize the vertex buffer view.
		if (!sameSize)
		{
			_vertexBufferView = {};
			_vertexBufferView.BufferLocation = _pResource->GetGPUVirtualAddress();
			_vertexBufferView.StrideInBytes = sizeof(Vertex);
			_vertexBufferView.SizeInBytes = UINT(_heapSize);
		}
	}
コード例 #24
0
ファイル: TeamHandler.cpp プロジェクト: alon/bhuman2009fork
void TeamHandler::receive()
{
  if(!port)
    return; // not started yet

  char buffer[1400];
  int size;
  do
  {
    size = recv(udpSocket, buffer, sizeof(buffer), 0);
    if(size >= 4 && size == ((unsigned short*) buffer)[1] && 
       ((unsigned short*) buffer)[0] == calcCRC16(buffer + 2, size - 2))
    {
      in.out.bin << SystemCall::getCurrentSystemTime();
      in.out.finishMessage(idReceiveTimeStamp);
      InBinaryMemory memory(buffer + 4, size - 4);
      memory >> in;
      ASSERT(memory.eof());
    }
  }
  while(size > 0);
}
コード例 #25
0
std::string
CommandEventHandler::info(std::vector<std::string>& args)
{
  if (args.size() != 1)
    return agentWarnInvalidNumArgs(1);
  if (args[0].compare("id") == 0)
    return id();
  else if (args[0].compare("os") == 0)
    return os();
  else if (args[0].compare("systime") == 0)
    return systime();
  else if (args[0].compare("uptime") == 0)
    return uptime();
  else if (args[0].compare("uptimemillis") == 0)
    return uptimemillis();
  else if (args[0].compare("screen") == 0)
    return screen();
  else if (args[0].compare("memory") == 0)
    return memory();
  else if (args[0].compare("power") == 0)
    return power();
  return agentWarn("Invalid info subcommand.");
}
コード例 #26
0
    inline void performance_plot(std::string const& folder_name, TaskFactory factory, std::ostream& out_stream = fake_stream())
    {
        tape_empty_test_output outMemory(folder_name, {
            { "title", "Tape size dependence on number of variables" }
            , { "filename", "TapeSize" }
            , { "not_clear", "Not" }
            , { "ylabel", "Memory (B)" }
            , { "cleanlog", "false" }
        });

        compare_tape(factory, 10, out_stream);

#if defined CL_GRAPH_GEN
        for (size_t i = 1; i <= 50; i++)
        {
            auto array_task = factory.get_array_task(i);
            auto double_task = factory.get_double_task(i);
            test_statistic array_stat = adjoint_performance(array_task, out_stream);
            test_statistic double_stat = adjoint_performance(double_task, out_stream);
            plot_struct<mem_columns> memory(array_stat, double_stat);
            outMemory << memory;
        }
#endif
    }
コード例 #27
0
ファイル: rat_state_switch.cpp プロジェクト: 2asoft/xray
void CAI_Rat::set_dir()
{
	if ((Device.dwTimeGlobal - m_previous_query_time > TIME_TO_GO) || !m_previous_query_time) {
		CMonsterSquad *squad	= monster_squad().get_squad(this);
		Fvector m_enemy_position = memory().enemy().selected()->Position();
		if (squad && squad->SquadActive())
		{
			float m_delta_Angle = angle_normalize((PI * 2) / squad->squad_alife_count());
			float m_heading, m_pitch;
			Fvector m_temp, m_dest_direction;
			m_temp = squad->GetLeader()->Position();
			m_dest_direction.x = (m_temp.x - m_enemy_position.x) / m_temp.distance_to(m_enemy_position);
			m_dest_direction.y = (m_temp.y - m_enemy_position.y) / m_temp.distance_to(m_enemy_position);
			m_dest_direction.z = (m_temp.z - m_enemy_position.z) / m_temp.distance_to(m_enemy_position);
			m_dest_direction.getHP(m_heading, m_pitch);
			m_heading = angle_normalize(m_heading + m_delta_Angle * squad->get_index(this));
			m_dest_direction.setHP(m_heading, m_pitch);
			m_dest_direction.mul(0.5f);
			m_enemy_position.add(m_enemy_position,m_dest_direction);
		}

		m_tGoalDir.set(m_enemy_position);
	}
}
コード例 #28
0
ファイル: pyfileselect.cpp プロジェクト: gauravssnl/pymgfetch
static PyObject* select_folder(PyObject* /*self*/, PyObject* args)
	{
	
	
	char *ttext = NULL;
	TInt ttextlen = 0;
	TInt32 useDefaultTitle;
	
	char *rtext = NULL;
	TInt rtextlen = 0;
	TInt32 useDefaultRight;
	
	char *ltext = NULL;
	TInt ltextlen = 0;
	TInt32 useDefaultLeft;
	
	char *mtext = NULL;
	TInt mtextlen = 0;
	
	TInt32 type;
	TCommonDialogType dialogType = ECFDDialogTypeSave;
	
	
	if (!PyArg_ParseTuple(args, "iu#u#iu#iu#i", &type, &mtext, &mtextlen, &ttext, &ttextlen,&useDefaultTitle, &rtext, &rtextlen,&useDefaultRight, &ltext, &ltextlen, &useDefaultLeft))
		{
		return Py_BuildValue("s", "Cannot parse arguments.");
		}
	switch (type)
		{
		case 0:
			{
			dialogType = ECFDDialogTypeSave;
			}
		break;
		case 1:
			{
			dialogType = ECFDDialogTypeMove;
			}
		break;
		case 2:
			{
			dialogType = ECFDDialogTypeCopy;
			}
		break;
		}
	Cpyfileselect* obj = Cpyfileselect::NewL();
	const char* res;
	TPtrC titleP((TUint16*) ttext, ttextlen);
	TPtrC memory((TUint16*) mtext, mtextlen);
	TPtrC leftP((TUint16*) ltext, ltextlen);
	TPtrC rightP((TUint16*) rtext, rtextlen);
	TBuf <20> title;
	title.Append(titleP);
	TBuf <20> right;
	right.Append(rightP);
	TBuf <20> left;
	left.Append(leftP);
	if(useDefaultTitle == 1)
		{
			title = KNullDesC;
		}
	if(useDefaultRight == 1)
		{
			right = KNullDesC;
		}
	if(useDefaultLeft == 1)
		{
			left = KNullDesC;
		}
	TRAPD( err, res = obj->FolderSelectionDlg(dialogType,memory, title, right, left) );

	PyObject* result;

	if (err != KErrNone)
		{
		result = SPyErr_SetFromSymbianOSErr(err);
		}
	else
		{
		result = Py_BuildValue("s", res);
		}
	delete obj;
	return result;
	}
コード例 #29
0
ファイル: main.cpp プロジェクト: xairy/packet-sniffer
// Returns 'false' on failure, returns 'true' on success.
// Handle to the module is stored in '*output'.
bool InjectDLL(DWORD process_id, const std::string& dll_name, HMODULE* output) {
  CHECK(process_id != 0);

  ScopedHandle process(OpenProcess(CREATE_THREAD_ACCESS, FALSE, process_id));
  if(process.handle == NULL) {
    THROW_ERROR("Unable to open process!");
    return false;
  }

  HMODULE kernel32 = GetModuleHandle("kernel32.dll");
  if(kernel32 == NULL) {
    THROW_ERROR("Unable to get 'kernel32.dll' handle!");
    return false;
  }

  // Adding DLL search path.

  // XXX: hardcoded max buffer size.
  const SIZE_T buffer_size = 256;
  TCHAR buffer[buffer_size];
  DWORD path_size = GetCurrentDirectory(buffer_size, buffer);
  if(path_size == 0 || path_size >= buffer_size) {
    THROW_ERROR("Unable to get current directory!");
    return false;
  }

  LPVOID path_pointer = RemoteAllocateAndCopy(process.handle, buffer, path_size + 1);
  ScopedMemory path_memory(process.handle, path_pointer);
  if(path_memory.pointer == NULL) {
    THROW_ERROR("Unable to allocate memory in the remote process!");
    return false;
  }

  FARPROC setdlldir_address = GetProcAddress(kernel32, "SetDllDirectoryA");
  if(setdlldir_address == NULL) {
    THROW_ERROR("Unable to get 'SetDllDirectory()' address!");
    return false;
  }

  DWORD exit_code;
  BOOL rv = RemoteSynchronousCall(process.handle, setdlldir_address, path_memory.pointer, &exit_code);
  if(rv == FALSE) {
    THROW_ERROR("'RemoteSynchronousCall()' failed!");
    return false;
  }

  rv = static_cast<BOOL>(exit_code);
  if(rv == FALSE) {
    THROW_ERROR("'SetDllDirectory()' failed!");
    return false;
  }

  // Loading sniffer.dll.

  LPVOID pointer = RemoteAllocateAndCopy(process.handle, dll_name.c_str(), dll_name.size() + 1);
  ScopedMemory memory(process.handle, pointer);
  if(memory.pointer == NULL) {
    THROW_ERROR("Unable to allocate memory in the remote process!");
    return false;
  }

  FARPROC loadlib_address = GetProcAddress(kernel32, "LoadLibraryA");
  if(loadlib_address == NULL) {
    THROW_ERROR("Unable to get 'LoadLibraryA()' address!");
    return false;
  }

  rv = RemoteSynchronousCall(process.handle, loadlib_address, memory.pointer, &exit_code);
  if(rv == FALSE) {
    THROW_ERROR("'RemoteSynchronousCall()' failed!");
  }

  HMODULE module = reinterpret_cast<HMODULE>(exit_code);
  if(module == NULL) {
    THROW_ERROR("'LoadLibraryA()' failed!");
    return false;
  }

  // Cleaning up.

  if(!path_memory.Free()) {
    THROW_ERROR("Unable to free memory in the remote process!");
    return false;
  }

  if(!memory.Free()) {
    THROW_ERROR("Unable to free memory in the remote process!");
    return false;
  }

  if(!process.Close()) {
    THROW_ERROR("Unable to close remote process!");
    return false;
  }

  *output = module;
  return true;
}
コード例 #30
0
ファイル: vm.cpp プロジェクト: clockmaker002/rubinius
 TypeInfo* VM::find_type(int type) {
   return memory()->type_info[type];
 }