Example #1
0
void project1() {
	// Create scene
	Scene scn;
	scn.SetSkyColor(Color(0.8f, 0.9f, 1.0f));

	// Create boxes
    LambertMaterial lambert1;
    lambert1.SetDiffuseColor(Color(0.3f,0.3f,0.3f));

	MeshObject box1;
	box1.MakeBox(5.0f,0.1f,5.0f, &lambert1);
	scn.AddObject(box1);
    
    
    LambertMaterial lambert2;
    lambert2.SetDiffuseColor(Color(0.7f,0.7f,0.7f));
	MeshObject box2;
	box2.MakeBox(1.0f,1.0f,1.0f, &lambert2);
    
	InstanceObject inst1(box2);
	Matrix34 mtx;
	mtx.MakeRotateX(0.5f);
	mtx.d.y=1.0f;
	inst1.SetMatrix(mtx);
	scn.AddObject(inst1);
    
	InstanceObject inst2(box2);
	mtx.MakeRotateY(1.0f);
	mtx.d.Set(-1.0f,0.0f,1.0f);
	inst2.SetMatrix(mtx);
	scn.AddObject(inst2);
    
	// Create lights
	DirectLight sunlgt;
	sunlgt.SetBaseColor(Color(1.0f, 1.0f, 0.9f));
	sunlgt.SetIntensity(0.5f);
	sunlgt.SetDirection(Vector3(-0.5f, -1.0f, -0.5f));
	scn.AddLight(sunlgt);
    
	PointLight redlgt;
	redlgt.SetBaseColor(Color(1.0f, 0.2f, 0.2f));
	redlgt.SetIntensity(2.0f);
	redlgt.SetPosition(Vector3(2.0f, 2.0f, 0.0f));
	scn.AddLight(redlgt);
    
	// Create camera
	Camera cam;
	cam.LookAt(Vector3(2.0f,2.0f,5.0f), Vector3(0.0f,0.0f,0.0f));
	cam.SetResolution(800,600);
	cam.SetFOV(40.0f);
	cam.SetAspect(1.33f);
    
	// Render image
	cam.Render(scn);
	cam.SaveBitmap("project1.bmp");
}
/**
  * Compares the Expr_instance with other.
  * Respects Symbol and attribute.
  */
bool Expr_instance::equals_without_index(const Expr_instance *other) const
{
    /* Save ins 1 */
    string inst1(i_symb->get_name());
    inst1.append(i_attr->get_name());

    /* Save ins 2 */
    string inst2(other->get_symb()->get_name());
    inst2.append(other->get_attr()->get_name());

    return inst1.compare(inst2) == 0;
}
Example #3
0
void TestCreateInstance5()
{
  if (verbose) cout << ProgName << "-TestCreateInstance5()" << endl;
    // -- Create an instance of each class:

    CIMInstance inst0(CIMName ("SuperClass"));
    inst0.addProperty(CIMProperty(CIMName ("key"), Uint32(11111)));
    r->createInstance(NS, inst0);

    CIMInstance inst1(CIMName ("SubClass"));
    inst1.addProperty(CIMProperty(CIMName ("key"), Uint32(22222)));
    r->createInstance(NS, inst1);
}
Example #4
0
static void _testInstances(void)
{
    // Simple test: instance with a few string properties
    {
        WsmInstance inst("testClass");
        WsmValue val_1("value_1");
        WsmValue val_2("value_2");
        inst.addProperty(WsmProperty("property_1", val_1));
        inst.addProperty(WsmProperty("property_2", val_2));

        _checkInstance(inst,
            "Instances with string properties do not compare");
    }

    // Test string array properties
    {
        WsmInstance inst("testClass");
        Array<String> stra;
        for (int i = 0; i < 5; i++)
        {
            char buf[20];
            sprintf(buf, "prop_1 value: %d", i);
            stra.append(buf);
        }
        WsmValue val1(stra);
        inst.addProperty(WsmProperty("property_1", val1));

        stra.clear();
        for (int i = 0; i < 10; i++)
        {
            char buf[20];
            sprintf(buf, "prop_2 value: %d", i);
            stra.append(buf);
        }
        WsmValue val2(stra);
        inst.addProperty(WsmProperty("property_2", val2));

        _checkInstance(inst,
            "Instances with string array properties do not compare");
    }

    // Test EPR properties
    {
        WsmInstance inst("testClass");
        WsmEndpointReference epr;
        epr.address = "http://www.acme.com:5988/wsman";
        epr.resourceUri = "TestURI";
        epr.selectorSet->selectors.
            append(WsmSelector("sel_1 name", "sel_1 value"));
        epr.selectorSet->selectors.
            append(WsmSelector("sel_2 name", "sel_2 value"));
        WsmValue val(epr);
        inst.addProperty(WsmProperty("property_1", val));

        _checkInstance(inst, "Instances with EPR properties do not compare");
    }

    // Test EPR array properties
    {
        WsmInstance inst("testClass");
        Array<WsmEndpointReference> epra;
        for (int i = 0; i < 5; i++)
        {
            char buf[50];
            WsmEndpointReference epr;
            sprintf(buf, "http://www.acme.com_%d:5988/wsman", i);
            epr.address = buf;
            sprintf(buf, "TestURI_%d", i);
            epr.resourceUri = buf;
            sprintf(buf, "selector value %d", i);
            epr.selectorSet->selectors.
                append(WsmSelector("sel_name", buf));
            epra.append(epr);

        }
        WsmValue val(epra);
        inst.addProperty(WsmProperty("property_1", val));

        _checkInstance(inst,
            "Instances with EPR array properties do not compare");
    }

    // Test recursive EPR properties
    {
        WsmInstance inst("testClass");

        WsmEndpointReference epr1;
        epr1.address = "http://www.acme.com_1:5988/wsman";
        epr1.resourceUri = "TestURI_1";
        epr1.selectorSet->selectors.
            append(WsmSelector("sel_0 name", "sel_1 value"));
        epr1.selectorSet->selectors.
            append(WsmSelector("sel_1 name", "sel_2 value"));

        WsmEndpointReference epr2;
        epr2.address = "http://www.acme.com_2:5988/wsman";
        epr2.resourceUri = "TestURI_2";
        epr2.selectorSet->selectors.append(WsmSelector("sel_2 name", epr1));

        WsmEndpointReference epr3;
        epr3.address = "http://www.acme.com_3:5988/wsman";
        epr3.resourceUri = "TestURI_3";
        epr3.selectorSet->selectors.append(WsmSelector("sel_3 name", epr2));

        WsmEndpointReference epr;
        epr.address = "http://www.acme.com:5988/wsman";
        epr.resourceUri = "TestURI";
        epr.selectorSet->selectors.append(WsmSelector("sel name", epr3));

        WsmValue val(epr);
        inst.addProperty(WsmProperty("property_1", val));

        _checkInstance(inst,
            "Instances with recursive EPR properties do not compare");
    }

    // Test embedded instance properties
    {
        WsmInstance inst1("testClass_1");
        WsmValue val_1("value_1");
        WsmValue val_2("value_2");
        inst1.addProperty(WsmProperty("property_1", val_1));
        inst1.addProperty(WsmProperty("property_2", val_2));

        WsmInstance inst("testClass");
        WsmValue val_3(inst1);
        inst.addProperty(WsmProperty("property_3", val_3));

        _checkInstance(inst,
            "Instances with instance properties do not compare");
    }

    // Test arrays of embedded instances
    {
        WsmInstance inst("testClass");
        Array<WsmInstance> insta;
        for (int i = 0; i < 5; i++)
        {
            char buf[20];
            sprintf(buf, "testClass_%d", i);
            WsmInstance inst1(buf);
            sprintf(buf, "value_%d", i);
            WsmValue val(buf);
            sprintf(buf, "property_%d", i);
            inst1.addProperty(WsmProperty(buf, val));

            insta.append(inst1);
        }
        WsmValue val(insta);
        inst.addProperty(WsmProperty("prop_array", val));

        _checkInstance(inst,
            "Instances with instance array properties do not compare");
    }

    // Test recursive embedded instances
    {
        WsmInstance inst1("testClass_1");
        WsmValue val_0("value_0");
        WsmValue val_1("value_1");
        inst1.addProperty(WsmProperty("property_0", val_0));
        inst1.addProperty(WsmProperty("property_1", val_1));

        WsmInstance inst2("testClass_2");
        WsmValue val_2(inst1);
        inst2.addProperty(WsmProperty("property_2", val_2));

        WsmInstance inst3("testClass_3");
        WsmValue val_3(inst2);
        inst3.addProperty(WsmProperty("property_3", val_3));

        WsmInstance inst("testClass");
        WsmValue val(inst3);
        inst.addProperty(WsmProperty("property", val));

        _checkInstance(inst,
            "Instances with recursive instance properties do not compare");
    }
}
Example #5
0
//------------------------------------------------------------------------------
// Name: do_find
// Desc:
//------------------------------------------------------------------------------
void DialogROPTool::do_find() {

	const QItemSelectionModel *const selModel = ui->tableView->selectionModel();
	const QModelIndexList sel = selModel->selectedRows();

	if(sel.size() == 0) {
		QMessageBox::critical(
			this,
			tr("No Region Selected"),
			tr("You must select a region which is to be scanned for gadgets."));
	} else {

		unique_results_.clear();

		if(IProcess *process = edb::v1::debugger_core->process()) {
			for(const QModelIndex &selected_item: sel) {

				const QModelIndex index = filter_model_->mapToSource(selected_item);
				if(auto region = *reinterpret_cast<const IRegion::pointer *>(index.internalPointer())) {

					edb::address_t start_address     = region->start();
					const edb::address_t end_address = region->end();
					const edb::address_t orig_start  = start_address;

					ByteShiftArray bsa(32);

					while(start_address < end_address) {

						// read in the next byte
						quint8 byte;
						if(process->read_bytes(start_address, &byte, 1)) {
							bsa << byte;

							const quint8       *p = bsa.data();
							const quint8 *const l = p + bsa.size();
							edb::address_t    rva = start_address - bsa.size() + 1;

							QList<edb::Instruction> instruction_list;

							// eat up any NOPs in front...
							Q_FOREVER {
								edb::Instruction inst(p, l, rva);
								if(!is_nop(inst)) {
									break;
								}

								instruction_list << inst;
								p += inst.size();
								rva += inst.size();
							}


							edb::Instruction inst1(p, l, rva);
							if(inst1) {
								instruction_list << inst1;

								if(inst1.operation() == edb::Instruction::Operation::X86_INS_INT && inst1.operands()[0].general_type() == edb::Operand::TYPE_IMMEDIATE && (inst1.operands()[0].immediate() & 0xff) == 0x80) {
									add_gadget(instruction_list);
								} else if(inst1.operation() == edb::Instruction::Operation::X86_INS_SYSENTER) {
									add_gadget(instruction_list);
								} else if(inst1.operation() == edb::Instruction::Operation::X86_INS_SYSCALL) {
									add_gadget(instruction_list);
								} else if(is_ret(inst1)) {
									ui->progressBar->setValue(util::percentage(start_address - orig_start, region->size()));
									++start_address;
									continue;
								} else {

									p += inst1.size();
									rva += inst1.size();

									// eat up any NOPs in between...
									Q_FOREVER {
										edb::Instruction inst(p, l, rva);
										if(!is_nop(inst)) {
											break;
										}

										instruction_list << inst;
										p += inst.size();
										rva += inst.size();
									}

									edb::Instruction inst2(p, l, rva);
									if(is_ret(inst2)) {
										instruction_list << inst2;
										add_gadget(instruction_list);
									} else if(inst2 && inst2.operation() == edb::Instruction::Operation::X86_INS_POP) {
										instruction_list << inst2;
										p += inst2.size();
										rva += inst2.size();

										edb::Instruction inst3(p, l, rva);
										if(inst3 && inst3.operation() == edb::Instruction::Operation::X86_INS_JMP) {

											instruction_list << inst3;

											if(inst2.operand_count() == 1 && inst2.operands()[0].general_type() == edb::Operand::TYPE_REGISTER) {
												if(inst3.operand_count() == 1 && inst3.operands()[0].general_type() == edb::Operand::TYPE_REGISTER) {
													if(inst2.operands()[0].reg() == inst3.operands()[0].reg()) {
														add_gadget(instruction_list);
													}
												}
											}
										}
									}
								}

								// TODO(eteran): catch things like "add rsp, 8; jmp [rsp - 8]" and similar, it's rare,
								// but could happen
							}
						}

						ui->progressBar->setValue(util::percentage(start_address - orig_start, region->size()));
						++start_address;
					}
				}
			}
		}
	}
Example #6
0
int main() {
  AudioBuffer::getInstance();
  IO::getInstance();
while( 1 ) {
//   typedef FM< Time, Const00, Const10, Const00, Const01, Const03, Const10 > Mod1;
/*   typedef ConstFM< Time, Const00, Const10, C_00, C_01, C_03, C_03 > Mod1;
   typedef ConstFM< Time, Mod1, Const10, C_00, C_05, C_05, C_10 > Mod2;
   typedef Scale< Const< EV_04 >, Mod2 > Mod3;
   typedef Mul< Scale< Const05, Piano< Time > >, ConstEnvelope< C_00, C_05, C_00, C_17 > > Mod5;
   typedef Scale< Const< EV_04 >, Mod5 > Mod6;
   typedef Scale< NoteFrequency, Add< Mod2, Mod3 > > Mod7;
   typedef Scale< NoteFrequency, Fuzz< Add< Const04, Mod5 > > > Mod8;
   typedef Mul< Triangle< Time >, ConstEnvelope< C_00, C_07, C_03, C_06 > > Mod9;
   typedef Scale< NoteFrequency, Mod9 > Mod10;*/
   typedef Scale< NoteFrequency,
     Mul<
       Rectangle< C_02, Time >,
       ConstEnvelope< C_01, C_05, C_03, C_10 >
     >
   > Rect;
   typedef Scale< NoteFrequency, Add<
     ConstFM< Time,
       ConstFM< Time,
         Const00,
         C_10,
         C_00, C_17, C_00, C_20
       >,
       C_03,
       C_01, C_15, C_00, C_20
     >,
     ConstFM< Time,
       ConstFM< Scale< Const< EV_06 >, Time >,
         Const00,
         C_10,
         C_00, C_05, C_00, C_20
       >,
       C_02,
       C_00, C_07, C_00, C_20
     >
   > > EleP;
   typedef Scale< NoteFrequency, Fuzz<
     Mul<
       Scale< Const05, Piano< Time > >,
       ConstEnvelope< C_00, C_05, C_00, C_17 >
     >
   > > EleG;
   typedef Scale< NoteFrequency,
     Mul<
       Add< Const08, Mul< Const02, Sin< Scale< Const01, Time > > > >,
       Mul<
         Scale< Const05, Piano< Time > >,
         ConstEnvelope< C_00, C_05, C_00, C_17 >
       >
     >
   > Piano;
   typedef Scale< NoteFrequency,
     ConstFM< Time,
       Scale<
         Const< EV_03 >,
         ConstFM< Time,
           Scale<
             Const< EV_02 >,
             ConstFM< Time,
               Scale<
                 Const< EV_01 >,
                 ConstFM< Time, Const00, C_00, C_00, C_10, C_10, C_20 >
               >,
               EV_07, C_00, C_10, C_10, C_20
             >
           >,
           EV_08, C_00, C_10, C_10, C_20
         >
       >,
       EV_08, C_01, C_02, C_07, C_20
     >
   > Strings;
   typedef Scale< NoteFrequency,
     Mul<
       Hammond< Time, HT >,
       ConstEnvelope< C_00, C_10, C_10, C_20 >
     >
   > Organ;
   SimpleReader< Polyphony< Rect, 16 > > inst( score0 );
   SimpleReader< Polyphony< EleP, 3 > > inst1( score0 );
   SimpleReader< Polyphony< EleG, 6 > > inst2( score0 );
   SimpleReader< Polyphony< Piano, 6 > > inst3( score0 );
   SimpleReader< Polyphony< Strings, 3 > > inst4( score0 );
   SimpleReader< Polyphony< Organ, 3 > > inst5( score0 );
    while( !inst.isEnd() ) {
      inst.read();
      for( int count = 0; AudioBuffer::getInstance().readyToSet() && count != 256; ++count ) {
        AudioBuffer::getInstance().set( inst() );
      }
    }
    while( !inst5.isEnd() ) {
      inst5.read();
      for( int count = 0; AudioBuffer::getInstance().readyToSet() && count != 256; ++count ) {
        AudioBuffer::getInstance().set( inst5() );
      }
    }
    while( !inst1.isEnd() ) {
      inst1.read();
      for( int count = 0; AudioBuffer::getInstance().readyToSet() && count != 256; ++count ) {
        AudioBuffer::getInstance().set( inst1() );
      }
    }
    while( !inst4.isEnd() ) {
      inst4.read();
      for( int count = 0; AudioBuffer::getInstance().readyToSet() && count != 256; ++count ) {
        AudioBuffer::getInstance().set( inst4() );
      }
    }
    while( !inst3.isEnd() ) {
      inst3.read();
      for( int count = 0; AudioBuffer::getInstance().readyToSet() && count != 256; ++count ) {
        AudioBuffer::getInstance().set( inst3() );
      }
    }
    while( !inst2.isEnd() ) {
      inst2.read();
      for( int count = 0; AudioBuffer::getInstance().readyToSet() && count != 256; ++count ) {
        AudioBuffer::getInstance().set( inst2() );
      }
    }
  }
}