コード例 #1
0
ファイル: memory.cpp プロジェクト: vitillo/vc
template<typename V, unsigned int Size> struct TestVectors2D { static void test()
{
    typedef typename V::EntryType T;
    const V startX(V::IndexType::IndexesFromZero() + Size);
    Memory<V, Size, Size> m;
    const Memory<V, Size, Size> &m2 = m;
    V x = startX;
    for (size_t i = 0; i < m.rowsCount(); ++i, x += V::Size) {
        Memory<V, Size> &mrow = m[i];
        for (size_t j = 0; j < mrow.vectorsCount(); ++j, x += V::Size) {
            mrow.vector(j) = x;
        }
    }
    x = startX;
    for (size_t i = 0; i < m.rowsCount(); ++i, x += V::Size) {
        Memory<V, Size> &mrow = m[i];
        const Memory<V, Size> &m2row = m2[i];
        size_t j;
        for (j = 0; j < mrow.vectorsCount() - 1; ++j) {
            COMPARE(V(mrow.vector(j)), x);
            COMPARE(V(m2row.vector(j)), x);
            for (int shift = 0; shift < V::Size; ++shift, ++x) {
                COMPARE(V(mrow.vector(j, shift)), x);
                COMPARE(V(m2row.vector(j, shift)), x);
            }
        }
        COMPARE(V(mrow.vector(j)), x) << i << " " << j;
        COMPARE(V(m2row.vector(j)), x);
        x += V::Size;
    }
}};
コード例 #2
0
ファイル: memdef.cpp プロジェクト: AltimorTASDK/TribesRebirth
void * _cdecl std::calloc(size_t num, size_t size)
{
	void* mem;
	if ((mem = Malloc.alloc(num * size, false)) != 0)
		memset(mem,0,Malloc.getPtrSize(mem));
	return mem;
}
コード例 #3
0
bool WorkItem::printVariable(string name) const
{
  // Find variable
  const llvm::Value *value = getVariable(name);
  if (!value)
  {
    return false;
  }

  // Get variable value
  TypedValue result = getOperand(value);
  const llvm::Type *type = value->getType();

  if (value->getValueID() == llvm::Value::GlobalVariableVal ||
      ((const llvm::Instruction*)value)->getOpcode()
         == llvm::Instruction::Alloca)
  {
    // If value is alloca or global variable, look-up data at address
    size_t address = result.getPointer();
    Memory *memory = getMemory(value->getType()->getPointerAddressSpace());
    unsigned char *data = (unsigned char*)memory->getPointer(address);
    printTypedData(value->getType()->getPointerElementType(), data);
  }
  else
  {
    printTypedData(type, result.data);
  }

  return true;
}
コード例 #4
0
ファイル: os.cpp プロジェクト: sean-broomfield/SOS
void manageDrum(int number) {
    //IF THE DRUM ISNT BUSY AND THERES A RUNNINGJOB PASSED
    if(!drum && number != -1) {
        queueAllJobs();
        
            
        //FIND WHERE THE JOB IS LOCATED IN THE MEMORY ARRAY
        int jobPlaceInMem = memory.locateJob(jobs, number);
            
        //CHECK MEMORY TO SEE IF THERE IS ENOUGH SPACE FOR THE JOB SIZE
        //RETURNS THE # OF THE SPACE THAT IS FREE
        int avail = memory.MemoryCheck(jobs[jobPlaceInMem].getSize());
        
        //IF AVAIL < 100 AND IF THE JOB ISNT IN MEMORY
        //PLACE THE LOCATION OF THE JOB IN THE AVAILABLE SPACE
        //SWAP THE JOB INTO MEMORY (DRMINT WILL OCCUR)
        //SET JOB GOING IN TO THE NUMBER OF THE JOB
        //SET THE GOING DIRECTION
        //SET THE JOB IN THE TABLE AND SET THE DRUM = TRUE
        //WHEN TRUE IT MEANS THE DRUM IS BUSY
        //tell the drmint that the drum is busy (use boolean or queue)
        //TEST: [TRY USING queue.empty() OR bool drum = true]
        if((avail < 100)){
            if(!jobs[jobPlaceInMem].isInMemory()) {
                drum = true;
                jobGoingIn = number;
                jobs[jobPlaceInMem].setLocation(avail);
                memory.setMemory(jobs, jobPlaceInMem, avail);
                siodrum(jobs[jobPlaceInMem].getNumber(), jobs[jobPlaceInMem].getSize(), jobs[jobPlaceInMem].getLocation(), 0);
            }
        }
    }
}
コード例 #5
0
ファイル: evltor.cpp プロジェクト: hoangt/cryptoleq
void Evaluator::overlap_check(bool throwOnErr)
{
    Memory m;

    Nodes & instructions = root->children;

    for (auto i : instructions)
    {
        Nodes & lis = i->children;

        for (auto l : lis )
        {
            Litem * pl = get<Litem>(LNFUN, l);

            try
            {
                m.put(pl->address, pl->value);
            }
            catch (string e)
            {
                Err err("Memory overlap: " + pl->address.str(), pl->tok());
                if (throwOnErr)
                    throw err;
                else
                    std::cout << err.str() << '\n';
            }
            catch (...)
            {
                throw Err(LNFUN);
            }

        } // next litem
    } // next instruction
}
コード例 #6
0
ファイル: xyssl.cpp プロジェクト: Redi0/jucpp
	//这个函数的特点是可以指定输入数据的长度,注意,input的有效数据长度必须是16的整数倍,input的大小必须大于等于len。
	//但是outbuf仅仅存储,有效的输出长度。
	int Aes::DecryptEcb(Memory<char>& outbuf,const void* input,int len){
		if(len<=0) return 0;
		if(outbuf.Length()<(uint)len){
			if(!outbuf.SetLength(len)) return 0;
		}
		return DecryptEcb(outbuf.Handle(),len,input,len);
	}
コード例 #7
0
ファイル: memory.cpp プロジェクト: vitillo/vc
template<typename V, unsigned int Size> struct TestEntries { static void test() {
    typedef typename V::EntryType T;
    const T x = Size;
    Memory<V, Size> m;
    const Memory<V, Size> &m2 = m;
    Memory<V> m3(Size);
    for (unsigned int i = 0; i < Size; ++i) {
        m[i] = x;
        m3[i] = x;
    }
    for (unsigned int i = 0; i < Size; ++i) {
        COMPARE(m[i], x);
        COMPARE(m2[i], x);
        COMPARE(m3[i], x);
    }
    for (unsigned int i = 0; i < Size; ++i) {
        COMPARE(m.entries()[i], x);
        COMPARE(m2.entries()[i], x);
        COMPARE(m3.entries()[i], x);
    }
    const T *ptr = m2;
    for (unsigned int i = 0; i < Size; ++i) {
        COMPARE(ptr[i], x);
    }
    ptr = m3;
    for (unsigned int i = 0; i < Size; ++i) {
        COMPARE(ptr[i], x);
    }
}};
コード例 #8
0
MemoryReader::MemoryReader( Memory &source )
:curPos( 0 )
{
  this->curData = source.GetData();
  this->curLength = source.GetLength();
  this->curPos = 0;
}//constructor
コード例 #9
0
ファイル: util.cpp プロジェクト: LXiong/OpenNVR
BooleanValue strToBoolean (ConstMemory const value_mem)
{
    if (value_mem.len() == 0)
	return Boolean_Default;

    // TODO malloc here is not necessary
    Ref<String> value_str = grab (new String (value_mem));
    Memory const mem = value_str->mem();
    for (Size i = 0; i < mem.len(); ++i)
	mem.mem() [i] = (Byte) tolower (mem.mem() [i]);

    if (equal (mem, "y")    ||
	equal (mem, "yes")  ||
	equal (mem, "on")   ||
	equal (mem, "true") ||
	equal (mem, "1"))
    {
	return Boolean_True;
    }

    if (equal (mem, "n")     ||
	equal (mem, "no")    ||
	equal (mem, "off")   ||
	equal (mem, "false") ||
	equal (mem, "0"))
    {
	return Boolean_False;
    }

    return Boolean_Invalid;
}
コード例 #10
0
ファイル: PELoader.cpp プロジェクト: dusek/army
    bool load(std::istream &in, Memory& mem, addr_t img_base) {
        if (virt_sz > 0) {
            addr_t sect_addr_va = img_base + virt_addr;
            int prot = get_prot(charac);
            mem.alloc_protect(sect_addr_va , virt_sz, prot | Memory::Write);
            //TODO check for file_sz > virt_sz (explained in spec)
            if (file_sz > 0) {
                std::istream::streampos pos_orig = in.tellg(); 
                if (pos_orig == std::istream::pos_type(std::istream::off_type(-1)))
                    return false;
                in.seekg(file_pos, std::ios_base::beg);
                // TODO is "bad()" the right thing to check?
                if (in.bad())
                    return false;
                char *sect_data = new char[file_sz];
                in.read(sect_data, file_sz);
                if (std::size_t(in.gcount()) < file_sz) {
                    delete[] sect_data;
                    return false;
                }
                // perhaps change "write" interface to accept const char * to
                // avoid this copying madness?
                mem.write(sect_addr_va, std::string(sect_data, file_sz));
                delete[] sect_data;
                if (!(prot & Memory::Write))
                    mem.alloc_protect(sect_addr_va, virt_sz, prot);
                in.seekg(pos_orig);
                if (in.bad())
                    return false;
            }
        }

        return true;
    }
コード例 #11
0
ファイル: Setter.cpp プロジェクト: exploder2013/Arma-II
void spawnWeapon( LPVOID args ){
	D3D9_item* item = (D3D9_item*) args;
	Memory* m = (Memory*) item->arguments;

	auto			WeaponTable		= WeaponTable::Singleton();
	auto			WeaponTableSize = WeaponTable->getTableSize();

	auto			world			= World::Singleton();
	auto			locPlayer		= world->getCameraOn()->getUnit();

	auto			InventoryTable			= locPlayer->getInventoryTable();
	auto			InventoryTableSize		= InventoryTable->getTableSize();
	auto			InventoryTableMaxSize	= InventoryTable->getTableMaxSize();
	auto			Inventory				= InventoryTable->getInventory( );

	if( item->value > (int)(WeaponTableSize - 1) ){
		item->value = 0;
		item->isEnabled = false;
		return;
	}

	auto  Weapon = WeaponTable->getEntryById( item->value );
	if( Weapon->getBase() ){
		if( InventoryTableSize < InventoryTableMaxSize ){
			DWORD distance = Inventory->calculateDistance( InventoryTableSize );

			m->write( distance, Weapon->getBase() );
			InventoryTable->setTableSize( InventoryTableSize + 1 );

			weapons.push_back( distance );
		}
	}

	item->isEnabled = false;
}
コード例 #12
0
ファイル: deque.cpp プロジェクト: JarrettBillingsley/Croc
	void Deque::resizeArray(Memory& mem, size_t newSize)
	{
		if(mDataLen == newSize)
			return;

		assert(newSize > mSize);

		GCObject** newData = cast(GCObject**)mem.allocRaw(newSize * sizeof(GCObject*) MEMBERTYPEID);

		if(mSize > 0)
		{
			if(mEnd > mStart)
				memcpy(newData, mDataPtr + mStart, (mEnd - mStart) * sizeof(GCObject*));
			else
			{
				size_t endLen = mDataLen - mStart;
				memcpy(newData, mDataPtr + mStart, endLen * sizeof(GCObject*));
				memcpy(newData + endLen, mDataPtr, mEnd * sizeof(GCObject*));
			}
		}

		void* p = mDataPtr;
		auto sz = mDataLen * sizeof(GCObject*);
		mem.freeRaw(p, sz MEMBERTYPEID);
		mDataPtr = newData;
		mDataLen = newSize;
		mStart = 0;
		mEnd = mSize;
	}
コード例 #13
0
int main()
{

   cout<<"Enter the algorithm number:"<<endl;
   cout<<"                           1) first_fit"<<endl;
   cout<<"                           2) best_fit"<<endl;
   cout<<"                           3) worst_fit"<<endl;
   cin>>algorithm_mode;

    HoleTable h1;
    ProcessesTable t1;
    Memory memory;
    list<Node> list_processes;
    holes_initialize(h1);   //User Enter the holes (number of holes and the size of each one) all are handeled inside the function

/*
    //Hard coded test case for holes input, make it easy in Debuging

    h1.allocate(0,1);
    h1.allocate(2,1);
    h1.allocate(3,1);
    h1.allocate(5,1);
    h1.allocate(8,1);
    h1.allocate(9,1);
*/
   initial_Processes_table_filling(h1, t1, 10);  //Automated function for entering initial processes, the name of these process is Px
   memory.update_memory(h1,t1);                  //update the memory array
   memory.print_memory_in_detail();             //Print the memory array in detail(name,base_address, size, final_addess)
   input_processes(list_processes);             //User enter the processes which he wants to allocate
   tables_handler(list_processes,h1,t1,memory); //Handling algorithms after the user enters the processe,(for more details open the function)
   cout<<endl<<"***************"<<" FINAL MEMORY "<<"*************"<<endl;
   memory.update_memory(h1,t1);                 //final update for the memory array
   memory.print_memory_in_detail();             //Print the memory array in detail
   return 0;
}
コード例 #14
0
Tribe::Memory* Tribe::FindRandomMemory(const char* name, const csVector3 &pos, const iSector* sector, float range, float* foundRange)
{
    csArray<Memory*> nearby;
    csArray<float> dist;

    float minRange = range*range;    // Working with Squared values
    if(range == -1) minRange = -1;   // -1*-1 = 1, will use -1 later

    csList<Memory*>::Iterator it(memories);
    while(it.HasNext())
    {
        Memory* memory = it.Next();

        if(memory->name == name && memory->npc == NULL)
        {
            float dist2 = npcclient->GetWorld()->Distance(pos,sector,memory->pos,memory->GetSector());

            if(minRange < 0 || dist2 < minRange)
            {
                nearby.Push(memory);
                dist.Push(dist2);
            }
        }
    }

    if(nearby.GetSize()>0)   // found one or more closer than range
    {
        size_t pick = psGetRandom((uint32)nearby.GetSize());

        if(foundRange) *foundRange = sqrt(dist[pick]);

        return nearby[pick];
    }
    return NULL;
}
コード例 #15
0
Tribe::Memory* Tribe::FindNearestMemory(const char* name, const csVector3 &pos, const iSector* sector, float range, float* foundRange)
{
    Memory* nearest = NULL;

    float minRange = range*range;    // Working with Squared values
    if(range == -1) minRange = -1;   // -1*-1 = 1, will use -1 later

    csList<Memory*>::Iterator it(memories);
    while(it.HasNext())
    {
        Memory* memory = it.Next();

        if(memory->name == name && memory->npc == NULL)
        {
            float dist2 = npcclient->GetWorld()->Distance(pos,sector,memory->pos,memory->GetSector());

            if(minRange < 0 || dist2 < minRange)
            {
                minRange = dist2;
                nearest = memory;
            }
        }
    }

    if(nearest && foundRange)   // found closest one
    {
        *foundRange = sqrt(minRange);
    }

    return nearest;
}
コード例 #16
0
ファイル: main.cpp プロジェクト: arashdn/shared-memory
int main(int argc, char *argv[])
{

    Memory mr;
    cout << "Enter a key number (write 0 to generate a random key): ";
    int key;
    cin>> key;
    if(key<=0)
    	mr = Memory();
    else
    	mr=Memory(key);

    cout << "\nKey is:" <<mr.getKey();
    char x;
    while(1)
    {
    	cout <<"\n\n-----------\nChoose one: \nr:Read\nd:Read with delay (to test concurrency)\nw:write\nx:exit\n-----------\n";
    	cin >> x;
    	if(x == 'r')
    	{
    		cout << "Data is: "<<mr.read();
    	}
        else if(x == 'd')
        {
            cout << "Data is: "<<mr.read(8);
        }
    	else if(x == 'w')
    	{
    		string s;
    		cout << "Enter data to input: ";
    		cin >> s;
    		mr.write(s);
    	}
    	else if(x == 'x')
コード例 #17
0
ファイル: Setter.cpp プロジェクト: exploder2013/Arma-II
void spawnAmmunation( LPVOID args ){
	D3D9_item* item = (D3D9_item*) args;
	Memory* m = (Memory*) item->arguments;

	auto			ConsumableTable = ConsumableTable::Singleton();
	auto			ConsumableTableSize = ConsumableTable->getTableSize();

	auto			world = World::Singleton();
	auto			locPlayer = world->getCameraOn()->getUnit();

	auto			InventoryTable = locPlayer->getInventoryTable();
	auto			InventoryTableSize = InventoryTable->getConsumableTableSize();
	auto			InventoryTableMaxSize = InventoryTable->getConsumableTableMaxSize( );
	auto			Inventory = InventoryTable->getConsumableInventory();

	if( item->value > (int)(ConsumableTableSize - 1) ){
		item->value = 0;
		item->isEnabled = false;
		return;
	}

	auto  Consumable = ConsumableTable->getEntryById( item->value );
	if( Consumable->getBase() ){
		if( InventoryTableSize < InventoryTableMaxSize ){
			DWORD memory = m->allocateMemory( 0x2C );
			if (!memory) {
				console->sendInput( "Failed to allocate memory!" );
				return;
			}
				

			DWORD item1 = m->read<DWORD>( m->read<DWORD>( Inventory->getBase( ) + 0x28 ) );
			DWORD item2 = m->read<DWORD>( m->read<DWORD>( Inventory->getBase( ) + 0x4 ) );

			m->write( memory, m->read<DWORD>( Inventory->getBase() ) );
			m->write( memory + 0x4, item2 );
			m->write( memory + 0x8, Consumable->getBase() );

			m->write( memory + 0x28, item1 );
			m->write( memory + 0x2C, itemRef );
			itemRef++;

			/* UNCHECKED */
			int ammoXOR = m->read<DWORD>( Consumable->getBase() + 0x2C ) ^ (int)( 0xBABAC8B6L );
			int ammoVal = ammoXOR << 1;

			m->write( memory + 0xC, int( ammoXOR - ammoVal ) );
			m->write( memory + 0x24, ammoVal );
			/* END UNCHECKED */

			DWORD distance = Inventory->calculateDistance( InventoryTableSize );

			m->write( distance, memory );
			InventoryTable->setConsumableTableSize( InventoryTableSize + 1 );
		}
	}

	item->isEnabled = false;
}
コード例 #18
0
ファイル: StreamedInstance.cpp プロジェクト: saggita/r5ge
bool StreamedInstance::Update()
{
	if (mState != State::Playing) return false;

	int queued;
	alGetSourcei(mSource, AL_BUFFERS_QUEUED, &queued);
	ASSERT(alGetError() == 0, "AL error occured");

	if (queued)
	{
		int processed;
		alGetSourcei(mSource, AL_BUFFERS_PROCESSED, &processed);
		ASSERT(alGetError() == 0, "AL error occured");

		while (processed--)
		{
			uint processedBuffer;
			alSourceUnqueueBuffers(mSource, 1, &processedBuffer);
			ASSERT(alGetError() == 0, "AL error occured");

			if (((StreamedSound*)mSound)->GetAudioData()->IsEOF() && mRepeat)
			{
				((StreamedSound*)mSound)->GetAudioData()->Reset();
			}

			if (!((StreamedSound*)mSound)->GetAudioData()->IsEOF())
			{
				Memory dataOut;
				ALenum format = (((StreamedSound*)mSound)->GetAudioData()->GetChannels() == 1) ? AL_FORMAT_MONO16 : AL_FORMAT_STEREO16;	

				((StreamedSound*)mSound)->GetAudioData()->Decode(dataOut);

				alBufferData(processedBuffer, format, dataOut.GetBuffer(), dataOut.GetSize(), ((StreamedSound*)mSound)->GetAudioData()->GetRate());
				ASSERT(alGetError() == 0, "AL error occured");

				alSourceQueueBuffers(mSource, 1, &processedBuffer);
				ASSERT(alGetError() == 0, "AL error occured");
			}
		}

		int streamState;
		alGetSourcei(mSource, AL_SOURCE_STATE, &streamState);

		if (streamState == AL_STOPPED)
		{
			alSourcePlay(mSource);
		}

		return true;
	}
	else
	{
		// Load the buffers with initial data in case the sound is to be played again.
		Init();
		mState = State::Stopped;
		mActiveInstancesEntry = NULL;
		return false;
	}
}
コード例 #19
0
ファイル: main.cpp プロジェクト: XToolsXYZ/MultiTool
/* Start code */
void main()
{
	/* Rename Console */
	SetConsoleTitle(" XTools Multi-Hack");
	SetWindow(29, 30, ConsolePos_x, ConsolePos_y);

	/* Console output */
	cout << "-----------------------------" << endl;
	cout << "|      XTools Multi Hack    |" << endl;
	cout << "|                           |" << endl;
	cout << "| Hotkeys:                  |" << endl;
	cout << "|        -> BunnyHop: F9    |" << endl;
	cout << "|        ->      RCS: F8    |" << endl;
	cout << "|        ->    Radar: F7    |" << endl;
	cout << "|        ->  SlowAIM: F6    |" << endl;
	cout << "|        ->  GlowESP: F5    |" << endl;
	cout << "|        ->     EXIT: F4    |" << endl;
	cout << "-----------------------------" << endl;

	/* Attach to the GAME process */
	if (!MManager.Attach("csgo.exe"))
	{
		cout << "-----------------------------" << endl;
		cout << "|         :WARNING:         |" << endl;
		cout << "|     CS:GO NOT FOUND!      |" << endl;
		cout << "|     CLOSING IN 3 SEC      |" << endl;
		cout << "-----------------------------" << endl;
		Sleep(1000 * 3);
		exit(0);
	}
	cout << "-----------------------------" << endl;
	cout << "|       :ACTIVATION:        |" << endl;
	cout << "|                           |" << endl;

	/* Get client.dll and engine.dll */
	Client = MManager.GetModule("client.dll");
	Engine = MManager.GetModule("engine.dll");

	/* Find all the offsets that the code need using pattern scan */
	PatternScan();

	/* Threads creation for multiple functions at the same time */
	thread ACTIVATION_thread = thread(ActivationByHotkeys);
	thread CONSOLEMOVE_thread = thread(MoveConsole);
	thread GLOW_thread = thread(GLOW);
	thread RADAR_thread = thread(RADAR);
	thread SLOWAIM_thread = thread(SLOWAIM);
	thread BHOP_thread = thread(BHOP);
	thread RCS_thread = thread(RCS);

	/* Start threads */
	ACTIVATION_thread.join();
	CONSOLEMOVE_thread.join();
	GLOW_thread.join();
	RADAR_thread.join();
	SLOWAIM_thread.join();
	BHOP_thread.join();
	RCS_thread.join();
}
コード例 #20
0
ファイル: Setter.cpp プロジェクト: exploder2013/Arma-II
void clearFile( LPVOID args ){
	D3D9_item*		item = (D3D9_item*) args;
	Memory*			m = (Memory*) item->arguments;

	m->clearFile();

	item->isEnabled = false;
}
コード例 #21
0
ファイル: xyssl.cpp プロジェクト: Redi0/jucpp
	int Base64::Encode(Memory<char>& output,const void* data,int len){
		int dlen = 0;
		base64_encode(0,&dlen,(uchar*)data,len);
		if(dlen==0) return 0;
		if(!output.SetLength(dlen)) return 0;
		base64_encode((byte*)output.Handle(),&dlen,(uchar*)data,len);
		return dlen;
	}
コード例 #22
0
TEST(memory, UnalignedAccess)
{
	Memory mem;

	// Must write at aligned locations, so this shouldn't work
	EXPECT_THROW(mem.set(1, 0), std::out_of_range);
	EXPECT_THROW(mem.get(1), std::out_of_range);
}
コード例 #23
0
ファイル: img.cpp プロジェクト: pgmsoul/GitLib
	uint Image::FrameCount(){
		if(!_image) return 0;
		UINT count = ((_Image*)_image)->GetFrameDimensionsCount();   
		Memory<GUID> ids;
		ids.SetLength(count);
		((_Image*)_image)->GetFrameDimensionsList(ids, count);   
		return ((_Image*)_image)->GetFrameCount(ids);   
	}
コード例 #24
0
ファイル: xyssl.cpp プロジェクト: Redi0/jucpp
	int Base64::Decode(Memory<char>& output,const char* data,int len){
		if(len==-1) len = strlen(data);
		int dlen = 0;
		base64_decode(0,&dlen,(uchar*)data,len);
		if(dlen==0) return 0;
		if(!output.SetLength(dlen)) return 0;
		base64_decode((byte*)output.Handle(),&dlen,(uchar*)data,len);
		return dlen;
	}
コード例 #25
0
ファイル: disassem.cpp プロジェクト: trieck/source
CString Disassembler::Get(USHORT &address)
{
    Memory *mem = Memory::instance();
    BYTE b = mem->Get(address);

    const Instruction *pInstr = instructions[b];

    return FormatInstruction(pInstr, b, address);
}
コード例 #26
0
ファイル: function_method.cpp プロジェクト: Arkshine/Okapi
long FunctionMethod::call_original(void** stack)
{
	float ret_data;

	AssemblyCreate assembly;

	assembly.add<Inst_Enter>();

	int start = this->get_stack_dislocation() / 4;

#ifdef __linux__
	int end = 0;
#else
	assembly.add<Inst_Mov_ECX_VAL>()->set_long((long)stack[0]);
	assembly.add<Inst_Push_ECX>();

	int end = 1;
#endif

	for (int i=start; i >= end; i--)
	{
		assembly.add<Inst_Push_VAL>()->set_long((long)stack[i]);
	}

	Inst_Call* inst_call  = assembly.add<Inst_Call>();		// call original

#ifdef __linux__
	assembly.add<Inst_Add_ESP_Val>()->set_inc(this->get_stack_dislocation());
#endif

	if (return_handler->uses_st_register())
	{
		assembly.add<Inst_Fstp>()->set_ptr((long)&ret_data);
	}

	assembly.add<Inst_Leave>();
	assembly.add<Inst_Ret>();

	int size = assembly.size();

	unsigned char* block = assembly.get_block();

	inst_call->set_address((long)this->address);

	Memory m;
	m.make_writable_executable((long)block, size);

	long ret = reinterpret_cast<long(*)()>(block)();

	if (!return_handler->uses_st_register())
	{
		return ret;
	}

	return ret_data;
}
コード例 #27
0
TEST(HDU, branch_previousRinstruct) {
	IFID ifid;
	IFID ifid2;
	IDEX idex, idex2;
	EXMEM exmem = {};
	MEMWB memwb = {};
	HDU hdu;
	FRWD_Out fwdout = {};
	Memory mem;
	IF if_block;
	ID id_block;
	IFControls ifcontrols;
	Controls controls = {};
	bool stall;

	if_block.set_pc(0x0004);
	
	ifid.instruction = inst::beq(reg::t0, reg::t1, 0x01);
	mem.set(0x0004, ifid.instruction);
	//Added to filter signals to ifid buffer
	if_block.signals_in(0x0004, ifcontrols.use_new_address = true, false);
	if_block.tick(mem);
	if_block.tock(mem);
	ifid = if_block.signals_out();
	//PC would now be 0x0006 for next fetch cycle
	idex.mem_controls.mem_read = 0;
	idex.write_reg = reg::t0;

	

	hdu.signals_in(ifid, idex, exmem, memwb);
	hdu.tick();
	hdu.tock();
	stall = hdu.signals_out();

	if_block.signals_in(0x0000, ifcontrols, stall);
	if_block.tick(mem);
	if_block.tock(mem);
	ifid2 = if_block.signals_out();

	id_block.signals_in(ifid2, controls, 0x00, 0x00, fwdout, 1);
	id_block.tick();
	id_block.tock();
	idex2 = id_block.signals_out();



	//check that stall was passed out of HDU
	EXPECT_EQ(1, stall);
	//check that PC was not changed
	EXPECT_EQ(0x0006, if_block.get_pc());
	EXPECT_EQ(ifid.instruction, ifid2.instruction);
	EXPECT_EQ(0, idex2.data1);

}
コード例 #28
0
ファイル: StackView.cpp プロジェクト: trieck/source
CString StackView::GetLine(USHORT i)
{
    static const TCHAR line[] = _T("$1%.2hX:  %.2hX");
    TCHAR buf[10];

    Memory* mem = Memory::instance();

    _stprintf(buf, line, 0xff - i, mem->Get(0x1ff - i));

    return buf;
}
コード例 #29
0
ファイル: amf_decoder.cpp プロジェクト: keyanmca/OpenNVR
Result
AmfDecoder::doDecodeStringData (Memory   const mem,
                                Size   * const ret_len,
                                Size   * const ret_full_len,
                                bool     const is_long_string)
{
    Uint32 string_len;
    if (is_long_string) {
        Byte str_len_buf [4];

        if (msg_len - cur_offset < 4) {
            logD_ (_func, "no long string length");
            return Result::Failure;
        }

        array->get (cur_offset, Memory::forObject (str_len_buf));
        cur_offset += 4;

        string_len = ((Uint32) str_len_buf [0] << 24) |
                     ((Uint32) str_len_buf [1] << 16) |
                     ((Uint32) str_len_buf [2] <<  8) |
                     ((Uint32) str_len_buf [3] <<  0);
    } else {
        Byte str_len_buf [2];

        if (msg_len - cur_offset < 2) {
            logD_ (_func, "no string length");
            return Result::Failure;
        }

        array->get (cur_offset, Memory::forObject (str_len_buf));
        cur_offset += 2;

        string_len = ((Uint32) str_len_buf [0] << 8) |
                     ((Uint32) str_len_buf [1] << 0);
    }

    if (msg_len - cur_offset < string_len) {
        logE_ (_func, "message is too short");
        return Result::Failure;
    }

    Size const tocopy = (mem.len() > string_len ? string_len : mem.len());
    array->get (cur_offset, mem.region (0, tocopy));
    cur_offset += string_len;

    if (ret_len)
        *ret_len = tocopy;

    if (ret_full_len)
        *ret_full_len = string_len;

    return Result::Success;
}
コード例 #30
0
ファイル: Setter.cpp プロジェクト: exploder2013/Arma-II
void cleanUP( LPVOID args ){
	D3D9_item*		item = (D3D9_item*) args;
	Memory*			m = (Memory*) item->arguments;

	m->clearMemory();
	for( DWORD dwAddress : weapons ){
		m->write( dwAddress, 0 );
	}

	item->isEnabled = false;
}