Example #1
0
File: debug.c Project: fmccabe/cafe
static DebugWaitFor dbgDropFrame(char *line, processPo p, termPo loc, insWord ins, void *cl) {
  integer count = cmdCount(line, 0);

  // First we check that there are enough frames
  methodPo mtd = p->prog;
  framePo fp = p->fp;
  ptrPo sp = p->sp;

  integer frameNo = 0;

  while (frameNo < count && fp < (framePo) p->stackLimit) {
    mtd = fp->prog;
    sp = (ptrPo) (fp + 1);
    fp = fp->fp;
    frameNo++;
  }

  if (fp < (framePo) p->stackLimit) {
    p->prog = mtd;
    p->pc = entryPoint(mtd);

    integer lclCnt = lclCount(mtd);  /* How many locals do we have */
    p->sp = sp = ((ptrPo) fp) - lclCnt;
    p->fp = fp;

#ifdef TRACEEXEC
    for (integer ix = 0; ix < lclCnt; ix++)
      sp[ix] = voidEnum;
#endif
  } else
    outMsg(debugOutChnnl, "Could not drop %d stack frame\n%_", count);

  resetDeflt("n");
  return moreDebug;
}
bool        ParserBase::parseString(const std::string& str)
{
    initBuffer();
	if (this->st->loadString(str))
    {
        this->parser->peekChar(' ');
        if (entryPoint())
            return (true);
    }
    return (false);
}
bool        ParserBase::parseFile(const std::string& path)
{
    initBuffer();
	if (this->st->loadFile(path.c_str()))
    {
        this->parser->peekChar(' ');
        if (entryPoint())
            return (true);
    }
    return (false);
}
Example #4
0
File: debug.c Project: fmccabe/cafe
static DebugWaitFor dbgShowCode(char *line, processPo p, termPo loc, insWord ins, void *cl) {
  integer count = maximum(1, cmdCount(line, 1));
  methodPo mtd = p->prog;
  insPo pc = p->pc;

  insPo last = entryPoint(mtd) + insCount(mtd);

  for (integer ix = 0; ix < count && pc < last; ix++) {
    pc = disass(debugOutChnnl, p, mtd, pc, Null, Null);
    outStr(debugOutChnnl, "\n");
  }

  flushFile(debugOutChnnl);
  resetDeflt("n");

  return moreDebug;
}
Example #5
0
void SjCInterface::LoadModulesFastHack(SjModuleList& list, const wxArrayString& possibleDlls)
{
	size_t                  i, iCount = possibleDlls.GetCount();
	wxDynamicLibrary*       dynlib;
	dllMainEntryFuncType    entryPoint;
	SjInterface*            cinterf;
	for( i = 0; i < iCount; i++ )
	{
		// load a DLL
		{
			wxLogNull null;

			dynlib = new wxDynamicLibrary(possibleDlls[i]);
			if( dynlib == NULL )
				continue; // nothing to log - this is no SjDll

			if( !dynlib->IsLoaded() )
			{
				delete dynlib;
				continue; // nothing to log - this is no SjDll
			}

			entryPoint = (dllMainEntryFuncType)dynlib->GetSymbol(wxT("SjGetInterface"));
			if( entryPoint == NULL )
			{
				delete dynlib;
				continue; // nothing to log - this is no SjDll
			}
		}

		wxLogInfo(wxT("Loading %s"), possibleDlls.Item(i).c_str());

		cinterf = entryPoint();
		if( cinterf == NULL || cinterf->CallPlugin == NULL )
		{
			wxLogError(wxT("SjGetInterface returns 0 or CallPlugin set to 0."));
			wxLogError(_("Cannot open \"%s\"."), possibleDlls.Item(i).c_str());
			delete dynlib;
			continue; // error
		}

		// success so far - create the plugin and add it to the list
		list.Append(new SjCPlugin(this, possibleDlls[i], dynlib, cinterf));
	}
}
TemplateCore::GenerationResult FlashCardCore::generateMobileApplication(const QString &input_apk_file, QString &output_file) {
  emit generationProgress(5, tr("Preparing workspace..."));

  qApp->templateManager()->generator()->cleanWorkspace();

  emit generationProgress(10, tr("Extracting raw data from editor..."));

  // We need data which will be imported into apk/zip file.
  QString quiz_data = editor()->generateBundleData();

  if (quiz_data.isEmpty()) {
    // No date received, this is big problem.
    return BundleProblem;
  }

  QString temp_folder = qApp->templateManager()->tempDirectory();
  QDir temp_directory(temp_folder);
  QString base_folder = temp_folder + "/" + APP_LOW_NAME;
  QDir base_directory(base_folder);

  // Preparation of target bundle file
  emit generationProgress(20, tr("Creating base temporary folder..."));

  temp_directory.mkdir(APP_LOW_NAME);
  base_directory.mkdir("assets");

  QFile index_file(base_folder + "/assets/flash_content.xml");
  index_file.open(QIODevice::WriteOnly | QIODevice::Text);

  emit generationProgress(30, tr("Writting info data into file..."));

  QTextStream out(&index_file);
  out << quiz_data;

  out.flush();
  index_file.close();

  emit generationProgress(40, tr("Copying template apk file..."));

  // Copying of target apk file.
  QString new_apk_name = input_apk_file;

  if (!QFile::copy(APP_TEMPLATES_PATH + "/" + entryPoint()->baseFolder() + "/" + entryPoint()->mobileApplicationApkFile(),
                   base_folder + "/" + new_apk_name)) {
    qApp->templateManager()->generator()->cleanWorkspace();
    return CopyProblem;
  }

  emit generationProgress(60, tr("Inserting data into apk file..."));

  // Inserting bundle file into apk file.
  QProcess zip;

  zip.setWorkingDirectory(base_folder);
  zip.start(qApp->zipUtilityPath(), QStringList() << "-m" << "-r" << new_apk_name << "assets");
  zip.waitForFinished();

  if (zip.exitCode() != EXIT_STATUS_ZIP_NORMAL) {
    // Error during inserting quiz data via zip.
    qApp->templateManager()->generator()->cleanWorkspace();
    return ZipProblem;
  }

  emit generationProgress(70, tr("Signing apk file..."));

  // Signing and renaming target file.
  QString pem_certificate = QDir::toNativeSeparators(APP_CERT_PATH + "/" + CERTIFICATE_PATH);
  QString pk_certificate = QDir::toNativeSeparators(APP_CERT_PATH + "/" + KEY_PATH);
  QProcess signapk;

  signapk.setWorkingDirectory(base_folder);
  signapk.start(qApp->javaInterpreterPath(), QStringList() << "-jar" << qApp->signApkUtlityPath() <<
                pem_certificate << pk_certificate << new_apk_name <<
                QDir::toNativeSeparators(new_apk_name + ".new"));
  signapk.waitForFinished();

  if (signapk.exitCode() != EXIT_STATUS_SIGNAPK_WORKING) {
    qApp->templateManager()->generator()->cleanWorkspace();
    return SignApkProblem;
  }

  emit generationProgress(90, tr("Copying final apk file to output directory..."));

  // Now, our file is created. We need to move it to target directory.
  if (!IOFactory::copyFile(base_folder + "/" + new_apk_name + ".new",
                           qApp->templateManager()->outputDirectory() + "/" + new_apk_name)) {
    qApp->templateManager()->generator()->cleanWorkspace();
    return CopyProblem;
  }

  output_file = QDir(qApp->templateManager()->outputDirectory()).filePath(new_apk_name);

  // Removing temporary files and exit.
  qApp->templateManager()->generator()->cleanWorkspace();
  return Success;
}
QUrl ApplicationDescription::getEntryPoint() const
{
    return locateEntryPoint(QString::fromStdString(entryPoint()));
}
Example #8
0
	void CCodeAnalyser::AddEntryPoint(vector<CEntryPoint> &entryPoints, UINT32 addr, ELabelFlags autoFlag, const char *autoLabel)
	{
		CEntryPoint entryPoint(addr, autoFlag, autoLabel);
		if (find(entryPoints.begin(), entryPoints.end(), entryPoint) == entryPoints.end())
			entryPoints.push_back(entryPoint);
	}
Example #9
0
JobResult
PythonJob::exec()
{
    // We assume m_scriptFile to be relative to m_workingPath.
    QDir workingDir( m_workingPath );
    if ( !workingDir.exists() ||
         !workingDir.isReadable() )
    {
        return JobResult::error( tr( "Bad working directory path" ),
                                 tr( "Working directory %1 for python job %2 is not readable." )
                                    .arg( m_workingPath )
                                    .arg( prettyName() ) );
    }

    QFileInfo scriptFI( workingDir.absoluteFilePath( m_scriptFile ) );
    if ( !scriptFI.exists() ||
         !scriptFI.isFile() ||
         !scriptFI.isReadable() )
    {
        return JobResult::error( tr( "Bad main script file" ),
                                 tr( "Main script file %1 for python job %2 is not readable." )
                                    .arg( scriptFI.absoluteFilePath() )
                                    .arg( prettyName() ) );
    }

    try
    {
        bp::dict scriptNamespace = helper()->createCleanNamespace();

        bp::object calamaresModule = bp::import( "libcalamares" );
        bp::dict calamaresNamespace = bp::extract< bp::dict >( calamaresModule.attr( "__dict__" ) );

        calamaresNamespace[ "job" ] = CalamaresPython::PythonJobInterface( this );
        calamaresNamespace[ "globalstorage" ] = CalamaresPython::GlobalStoragePythonWrapper(
                                                JobQueue::instance()->globalStorage() );

        bp::object execResult = bp::exec_file( scriptFI.absoluteFilePath().toLocal8Bit().data(),
                                           scriptNamespace,
                                           scriptNamespace );

        bp::object entryPoint = scriptNamespace[ "run" ];
        bp::object prettyNameFunc = scriptNamespace.get("pretty_name", bp::object());

        cDebug() << "Job file" << scriptFI.absoluteFilePath();
        if ( !prettyNameFunc.is_none() )
        {
            bp::extract< std::string > prettyNameResult( prettyNameFunc() );
            if ( prettyNameResult.check() )
            {
                m_description = QString::fromStdString( prettyNameResult() ).trimmed();
            }
            if ( !m_description.isEmpty() )
            {
                cDebug() << "Job description from pretty_name" << prettyName() << "=" << m_description;
                emit progress( 0 );
            }
        }

        if ( m_description.isEmpty() )
        {
            bp::extract< std::string > entryPoint_doc_attr(entryPoint.attr( "__doc__" ) );

            if ( entryPoint_doc_attr.check() )
            {
                m_description = QString::fromStdString( entryPoint_doc_attr() ).trimmed();
                auto i_newline = m_description.indexOf('\n');
                if ( i_newline > 0 )
                    m_description.truncate( i_newline );
                cDebug() << "Job description from __doc__" << prettyName() << "=" << m_description;
                emit progress( 0 );
            }
        }

        bp::object runResult = entryPoint();

        if ( runResult.is_none() )
        {
            return JobResult::ok();
        }
        else // Something happened in the Python job
        {
            bp::tuple resultTuple = bp::extract< bp::tuple >( runResult );
            QString message = QString::fromStdString( bp::extract< std::string >( resultTuple[ 0 ] ) );
            QString description = QString::fromStdString( bp::extract< std::string >( resultTuple[ 1 ] ) );
            return JobResult::error( message, description );
        }
    }
    catch ( bp::error_already_set )
    {
        QString msg;
        if ( PyErr_Occurred() )
        {
            msg = helper()->handleLastError();
        }
        bp::handle_exception();
        PyErr_Clear();
        return JobResult::internalError(
                    tr( "Boost.Python error in job \"%1\"." ).arg( prettyName() ),
                    msg,
                    JobResult::PythonUncaughtException );
    }
}
Example #10
0
void
GameLoaderRun()
{
   auto appModule = gLoader.loadRPL(gGameRpx.c_str());
   if (!appModule) {
      gLog->error("Could not load {}", gGameRpx);
      return;
   }

   gSystem.setUserModule(appModule);

   gLog->debug("Succesfully loaded {}", gGameRpx);

   auto userPreinit = appModule->findFuncExport<void, be_ptr<CommonHeap>*, be_ptr<CommonHeap>*, be_ptr<CommonHeap>*>("__preinit_user");
   
   gDebugControl.preLaunch();

   if (userPreinit) {
      struct HeapHandles {
         be_ptr<CommonHeap> mem1Heap;
         be_ptr<CommonHeap> fgHeap;
         be_ptr<CommonHeap> mem2Heap;
      };
      HeapHandles *wiiHandles = OSAllocFromSystem<HeapHandles>();

      wiiHandles->mem1Heap = MEMGetBaseHeapHandle(BaseHeapType::MEM1);
      wiiHandles->fgHeap = MEMGetBaseHeapHandle(BaseHeapType::FG);
      wiiHandles->mem2Heap = MEMGetBaseHeapHandle(BaseHeapType::MEM2);
      userPreinit(&wiiHandles->mem1Heap, &wiiHandles->fgHeap, &wiiHandles->mem2Heap);
      MEMSetBaseHeapHandle(BaseHeapType::MEM1, wiiHandles->mem1Heap);
      MEMSetBaseHeapHandle(BaseHeapType::FG, wiiHandles->fgHeap);
      MEMSetBaseHeapHandle(BaseHeapType::MEM2, wiiHandles->mem2Heap);

      OSFreeToSystem(wiiHandles);
   }

   // Create default threads
   for (auto i = 0u; i < CoreCount; ++i) {
      auto thread = OSAllocFromSystem<OSThread>();
      auto stackSize = appModule->defaultStackSize();
      auto stack = reinterpret_cast<uint8_t*>(OSAllocFromSystem(stackSize, 8));
      auto name = OSSprintfFromSystem("Default Thread %d", i);

      OSCreateThread(thread,
         0, 0, nullptr,
         stack + stackSize, stackSize,
         16,
         static_cast<OSThreadAttributes::Flags>(1 << i));

      OSSetDefaultThread(i, thread);
      OSSetThreadName(thread, name);
   }

   // Create interrupt threads
   for (auto i = 0u; i < CoreCount; ++i) {
      auto thread = OSAllocFromSystem<OSThread>();
      auto stackSize = 16 * 1024;
      auto stack = reinterpret_cast<uint8_t*>(OSAllocFromSystem(stackSize, 8));
      auto name = OSSprintfFromSystem("Interrupt Thread %d", i);

      OSCreateThread(thread,
         InterruptThreadEntryPoint, i, nullptr,
         stack + stackSize, stackSize,
         16,
         static_cast<OSThreadAttributes::Flags>(1 << i));

      OSSetInterruptThread(i, thread);
      OSSetThreadName(thread, name);
      OSResumeThread(thread);
   }

   // Run thread 1
   OSRunThread(OSGetDefaultThread(1), appModule->entryPoint(), 0, nullptr);
}
Example #11
0
int main()
{
    Header binHeader;
    binHeader.dataPages = 0;
    binHeader.codePages = 1;
    binHeader.symbols   = 1;
    binHeader.strings   = 1;

    typedef unsigned int PageDataType[1 << 13];

    PageDataType page;
    std::memset(page, 0, sizeof(PageDataType));
    ir::InstructionContainer* vir = (ir::InstructionContainer*)page;

    {
        ir::Bitcast& bitcast = vir[0].asBitcast;

        bitcast.opcode = ir::Instruction::Bitcast;

        bitcast.d.asRegister.mode = ir::Operand::Register;
        bitcast.d.asRegister.type = ir::i64;
        bitcast.d.asRegister.reg  = 11;

        bitcast.a.asRegister.mode = ir::Operand::Register;
        bitcast.a.asRegister.type = ir::i64;
        bitcast.a.asRegister.reg  = 32;
    }

    {
        ir::Ld& load = vir[1].asLd;

        load.opcode = ir::Instruction::Ld;

        load.d.asRegister.mode = ir::Operand::Register;
        load.d.asRegister.type = ir::i64;
        load.d.asRegister.reg  = 0;

        load.a.asIndirect.mode   = ir::Operand::Indirect;
        load.a.asIndirect.type   = ir::i64;
        load.a.asIndirect.reg    = 11;
        load.a.asIndirect.offset = 0;
    }

    {
        ir::Ld& load = vir[2].asLd;

        load.opcode = ir::Instruction::Ld;

        load.d.asRegister.mode   = ir::Operand::Register;
        load.d.asRegister.type   = ir::i64;
        load.d.asRegister.reg    = 1;

        load.a.asIndirect.mode   = ir::Operand::Indirect;
        load.a.asIndirect.type   = ir::i64;
        load.a.asIndirect.reg    = 11;
        load.a.asIndirect.offset = 8;
    }

    {
        ir::Ld& load = vir[3].asLd;

        load.opcode = ir::Instruction::Ld;

        load.d.asRegister.mode   = ir::Operand::Register;
        load.d.asRegister.type   = ir::i32;
        load.d.asRegister.reg    = 2;

        load.a.asIndirect.mode   = ir::Operand::Indirect;
        load.a.asIndirect.type   = ir::i64;
        load.a.asIndirect.reg    = 11;
        load.a.asIndirect.offset = 16;
    }

    {
        ir::Bitcast& bitcast = vir[4].asBitcast;

        bitcast.opcode = ir::Instruction::Bitcast;

        bitcast.d.asRegister.mode = ir::Operand::Register;
        bitcast.d.asRegister.type = ir::i32;
        bitcast.d.asRegister.reg  = 3;

        bitcast.a.asRegister.mode = ir::Operand::Register;
        bitcast.a.asRegister.type = ir::i32;
        bitcast.a.asRegister.reg  = 33;
    }

    {
        ir::Zext& zext = vir[5].asZext;

        zext.opcode = ir::Instruction::Zext;

        zext.d.asRegister.mode = ir::Operand::Register;
        zext.d.asRegister.type = ir::i64;
        zext.d.asRegister.reg  = 12;

        zext.a.asRegister.mode = ir::Operand::Register;
        zext.a.asRegister.type = ir::i32;
        zext.a.asRegister.reg  = 3;
    }

    {
        ir::Mul& multiply = vir[6].asMul;

        multiply.opcode = ir::Instruction::Mul;

        multiply.d.asRegister.mode = ir::Operand::Register;
        multiply.d.asRegister.type = ir::i64;
        multiply.d.asRegister.reg  = 4;

        multiply.a.asRegister.mode = ir::Operand::Register;
        multiply.a.asRegister.type = ir::i64;
        multiply.a.asRegister.reg  = 12;

        multiply.b.asImmediate.mode = ir::Operand::Immediate;
        multiply.b.asImmediate.type = ir::i64;
        multiply.b.asImmediate.uint = 4;
    }

    {
        ir::Add& add = vir[7].asAdd;

        add.opcode = ir::Instruction::Add;

        add.d.asRegister.mode = ir::Operand::Register;
        add.d.asRegister.type = ir::i64;
        add.d.asRegister.reg  = 5;

        add.a.asRegister.mode = ir::Operand::Register;
        add.a.asRegister.type = ir::i64;
        add.a.asRegister.reg  = 4;

        add.b.asRegister.mode = ir::Operand::Register;
        add.b.asRegister.type = ir::i64;
        add.b.asRegister.reg  = 0;
    }

    {
        ir::Add& add = vir[8].asAdd;

        add.opcode = ir::Instruction::Add;

        add.d.asRegister.mode = ir::Operand::Register;
        add.d.asRegister.type = ir::i64;
        add.d.asRegister.reg  = 6;

        add.a.asRegister.mode = ir::Operand::Register;
        add.a.asRegister.type = ir::i64;
        add.a.asRegister.reg  = 4;

        add.b.asRegister.mode = ir::Operand::Register;
        add.b.asRegister.type = ir::i64;
        add.b.asRegister.reg  = 1;
    }

    {
        ir::Ld& load = vir[9].asLd;

        load.opcode = ir::Instruction::Ld;

        load.d.asRegister.mode   = ir::Operand::Register;
        load.d.asRegister.type   = ir::i32;
        load.d.asRegister.reg    = 7;

        load.a.asIndirect.mode   = ir::Operand::Indirect;
        load.a.asIndirect.type   = ir::i64;
        load.a.asIndirect.reg    = 5;

        load.a.asIndirect.offset = 0;
    }

    {
        ir::Ld& load = vir[10].asLd;

        load.opcode = ir::Instruction::Ld;

        load.d.asRegister.mode   = ir::Operand::Register;
        load.d.asRegister.type   = ir::i32;
        load.d.asRegister.reg    = 8;

        load.a.asIndirect.mode   = ir::Operand::Indirect;
        load.a.asIndirect.type   = ir::i64;
        load.a.asIndirect.reg    = 6;
        load.a.asIndirect.offset = 0;
    }

    {
        ir::Mul& multiply = vir[11].asMul;

        multiply.opcode = ir::Instruction::Mul;

        multiply.d.asRegister.mode = ir::Operand::Register;
        multiply.d.asRegister.type = ir::i32;
        multiply.d.asRegister.reg  = 9;

        multiply.a.asRegister.mode = ir::Operand::Register;
        multiply.a.asRegister.type = ir::i32;
        multiply.a.asRegister.reg  = 8;

        multiply.b.asRegister.mode = ir::Operand::Register;
        multiply.b.asRegister.type = ir::i32;
        multiply.b.asRegister.reg  = 2;
    }

    {
        ir::Add& add = vir[12].asAdd;

        add.opcode = ir::Instruction::Add;

        add.d.asRegister.mode = ir::Operand::Register;
        add.d.asRegister.type = ir::i32;
        add.d.asRegister.reg  = 10;

        add.a.asRegister.mode = ir::Operand::Register;
        add.a.asRegister.type = ir::i32;
        add.a.asRegister.reg  = 7;

        add.b.asRegister.mode = ir::Operand::Register;
        add.b.asRegister.type = ir::i32;
        add.b.asRegister.reg  = 9;

    }

    {
        ir::St& store = vir[13].asSt;

        store.opcode = ir::Instruction::St;

        store.d.asIndirect.mode   = ir::Operand::Indirect;
        store.d.asIndirect.type   = ir::i64;
        store.d.asIndirect.reg    = 5;
        store.d.asIndirect.offset = 0;

        store.a.asRegister.mode   = ir::Operand::Register;
        store.a.asRegister.type   = ir::i32;
        store.a.asRegister.reg    = 10;
    }

    {
        ir::Ret& ret = vir[14].asRet;

        ret.opcode = ir::Instruction::Ret;
    }
 
    std::ofstream ofs("BinarySaxpy.exe", std::ofstream::binary);
    
    SymbolTableEntry symbolInfo;
    symbolInfo.type              = 2; //FunctionSymbolType from the enum. Hardcoded for now.
    symbolInfo.stringTableOffset = 0;
    symbolInfo.pageId            = 0;
    symbolInfo.pageOffset        = 0;
    symbolInfo.attributes        = 0;
    
    std::string entryPoint("saxpy");
    if (!ofs.is_open())
    {
        std::cout << "Could not open the binary file\n";
        exit(1);
    }
    ofs.write((char*)&binHeader, sizeof(Header));
    ofs.write((char*)vir, sizeof(PageDataType));
    ofs.write((char*)&symbolInfo, sizeof(SymbolTableEntry));
    ofs.write(entryPoint.c_str(), entryPoint.size() + 1);
    ofs.close();
}
Example #12
0
int Plugin::init(VstIntPtr VSTCALLBACK (*HostCallback) (AEffect* effect, VstInt32 opcode, VstInt32 index, VstIntPtr value, void* ptr, float opt)) {

#if defined(_WIN32)

	entryPoint = (vstPluginFuncPtr) GetProcAddress((HMODULE)module, "VSTPluginMain");
	if (!entryPoint)
		entryPoint = (vstPluginFuncPtr) GetProcAddress((HMODULE)module, "main");

#elif defined(__linux__)

	/* bad stuff here: main() is a function pointer, dlsym(module, "main")
	 * returns a pointer to an object (void*) which should be casted to
	 * a pointer to function (main(), precisely). Unfortunately the standard
	 * forbids the conversion from void* to function pointer. So we do a raw
	 * mem copy from tmp to entryPoint. */

	void *tmp;
	tmp = dlsym(module, "VSTPluginMain");
	if (!tmp)
		tmp = dlsym(module, "main");
	memcpy(&entryPoint, &tmp, sizeof(tmp));

#elif defined(__APPLE__)

	/* same also for Unix/OSX. */

	void *tmp = NULL;
	tmp = CFBundleGetFunctionPointerForName(module, CFSTR("VSTPluginMain"));

	if (!tmp) {
		gLog("[plugin] entryPoint 'VSTPluginMain' not found\n");
		tmp = CFBundleGetFunctionPointerForName(module, CFSTR("main_macho"));  // VST SDK < 2.4
	}
	if (!tmp) {
		gLog("[plugin] entryPoint 'main_macho' not found\n");
		tmp = CFBundleGetFunctionPointerForName(module, CFSTR("main"));
	}
	if (tmp)
		memcpy(&entryPoint, &tmp, sizeof(tmp));
	else
		gLog("[plugin] entryPoint 'main' not found\n");

#endif

	/* if entry point is found, add to plugin a pointer to hostCallback. Or
	 * in other words bind the callback to the plugin. */

	if (entryPoint) {
		gLog("[plugin] entryPoint found\n");
		plugin = entryPoint(HostCallback);
		if (!plugin) {
			gLog("[plugin] failed to create effect instance!\n");
			return 0;
		}
	}
	else {
		gLog("[plugin] entryPoint not found, unable to proceed\n");
		return 0;
	}


	/* check the magicNumber */
	/** WARNING: on Windows one can load any DLL! Why!?! */

  if(plugin->magic == kEffectMagic) {
		gLog("[plugin] magic number OK\n");
		return 1;
	}
	else {
    gLog("[plugin] magic number is bad\n");
    return 0;
  }
}