bool ModuleContainer::RemoveModule(uint32 itemID) { GenericModule * mod = GetModule(itemID); if( mod == NULL ) return false; // NO module pointer found at this slot flag, DO NOT attempt to dereference _removeModule(mod->flag(), mod); //delete the module delete mod; mod = NULL; return true; }
llvm::Value *CodeGen::CallMulWithOverflow(llvm::Value *left, llvm::Value *right, llvm::Value *&overflow_bit) { PELOTON_ASSERT(left->getType() == right->getType()); llvm::Function *mul_func = llvm::Intrinsic::getDeclaration( &GetModule(), llvm::Intrinsic::smul_with_overflow, left->getType()); // Perform the multiplication llvm::Value *mul_result = CallFunc(mul_func, {left, right}); // Pull out the overflow bit from the resulting aggregate/struct overflow_bit = GetBuilder().CreateExtractValue(mul_result, 1); // Pull out the actual result of the subtraction return GetBuilder().CreateExtractValue(mul_result, 0); }
bool CFlowGraphModuleManager::DeleteModuleXML( const char* moduleName ) { if(m_ModulesPathInfo.empty()) return false; TModulesPathInfo::iterator modulePathEntry = m_ModulesPathInfo.find(moduleName); if (m_ModulesPathInfo.end() != modulePathEntry) { if(remove(modulePathEntry->second) == 0) { m_ModulesPathInfo.erase(moduleName); // also remove module itself TModuleIdMap::iterator idIt = m_ModuleIds.find(moduleName); assert(idIt != m_ModuleIds.end()); TModuleId id = idIt->second; TModuleMap::iterator modIt = m_Modules.find(id); assert(modIt != m_Modules.end()); if(modIt != m_Modules.end() && idIt != m_ModuleIds.end()) { for(CListenerSet<IFlowGraphModuleListener*>::Notifier notifier(m_listeners); notifier.IsValid(); notifier.Next() ) { notifier->OnModuleDestroyed(GetModule(id)); } m_Modules[id]->Destroy(); delete m_Modules[id]; m_Modules[id] = NULL; m_ModuleIds.erase(idIt); m_Modules.erase(modIt); if (m_Modules.empty()) m_moduleIdMaker = 0; for(CListenerSet<IFlowGraphModuleListener*>::Notifier notifier(m_listeners); notifier.IsValid(); notifier.Next() ) { notifier->OnPostModuleDestroyed(); } } return true; } } return false; }
LibraryLoader* LoaderContainer::FindModule(const char* sName, const char* sCurrentDir, bool bLoadSymbols) { if (CURL::IsFullPath(sName)) { // Has a path, just try to load return LoadDll(sName, bLoadSymbols); } if (sCurrentDir) { // in the path of the parent dll? std::string strPath = sCurrentDir; strPath += sName; LibraryLoader* pLoader = LoadDll(strPath.c_str(), bLoadSymbols); if (pLoader) return pLoader; } // in environment variable? StringArray vecEnv; StringUtils::SplitString(ENV_PATH, ";", vecEnv); LibraryLoader* pDll = NULL; for (int i = 0; i < (int)vecEnv.size(); ++i) { std::string strPath = vecEnv[i]; strPath += '/'; #ifdef LOGALL LOGDEBUG("Searching for the dll %s in directory %s", sName, strPath.c_str()); #endif strPath += sName; // Have we already loaded this dll if ((pDll = GetModule(strPath.c_str())) != NULL) return pDll; if ((pDll = LoadDll(strPath.c_str(), bLoadSymbols)) != NULL) return pDll; } // can't find it in any of our paths - could be a system dll if ((pDll = LoadDll(sName, bLoadSymbols)) != NULL) return pDll; LOGDEBUG("Dll %s was not found in path", sName); return NULL; }
void CFlowGraphModuleManager::OnModuleFinished(TModuleId const& moduleId, TModuleInstanceId instanceId, bool bSuccess, TModuleParams const& params) { TModuleMap::iterator moduleEntry = m_Modules.find(moduleId); if (m_Modules.end() != moduleEntry) { CFlowGraphModule *pModule = moduleEntry->second; if (pModule) { for(CListenerSet<IFlowGraphModuleListener*>::Notifier notifier(m_listeners); notifier.IsValid(); notifier.Next() ) { notifier->OnModuleInstanceDestroyed(GetModule(pModule->GetId()), instanceId); } pModule->DestroyInstance(instanceId, bSuccess, params); } } }
JEventBody* JModuleThread::MakeEventBody(JEVT_TYPE eType, JCHAR* pModName) { JEventBody* pEventBody = JNULL; JModule* pModule = JNULL; JLogAutoPtr clsLogAutoPtr(JSingleton<JLog>::instance(), JLOG_MOD_THREAD, "JModuleThread::MakeEventBody"); pModule = GetModule(pModName); if (pModule) { pEventBody = pModule->MakeEventBody(static_cast<JUINT32>(eType)); } return pEventBody; }
void FunctionInstance::Read(ModuleReader &reader, const MemberHeader &header) { // Read the function id. uint32_t functionId; reader >> functionId; // Get the function. Module *module = GetModule(); function = module->GetFunction(functionId); // Read the generic instance instance.Read(reader); // Use the function generic prototype. instance.SetPrototype(function->GetGenericPrototype()); }
CExeModuleInstance* CRunningProcesses::GetProcessById(DWORD dwProcessId) { CExeModuleInstance* pResult = NULL; CExeModuleInstance* pProcess; for (DWORD i = 0; i < GetCount(); i++) { pProcess = static_cast<CExeModuleInstance*>( GetModule(i) ); if (pProcess->Get_ProcessId() == dwProcessId) { pResult = pProcess; break; } // if } // for return pResult; }
llvm::Value *CodeGen::CallSubWithOverflow(llvm::Value *left, llvm::Value *right, llvm::Value *&overflow_bit) { PELOTON_ASSERT(left->getType() == right->getType()); // Get the intrinsic that does the addition with overflow checking llvm::Function *sub_func = llvm::Intrinsic::getDeclaration( &GetModule(), llvm::Intrinsic::ssub_with_overflow, left->getType()); // Perform the subtraction llvm::Value *sub_result = CallFunc(sub_func, {left, right}); // Pull out the overflow bit from the resulting aggregate/struct overflow_bit = GetBuilder().CreateExtractValue(sub_result, 1); // Pull out the actual result of the subtraction return GetBuilder().CreateExtractValue(sub_result, 0); }
ErrorCode ComponentManager::LoadLibrary( const char *name ) { TRACE_BEGIN( LOG_LVL_INFO ); IModule *mod = NULL; ErrorCode result = kNoError; LOG_NOTICE( "Opening Library: %s", name ); ErrorCode (*LoadLibrary)( IComponentManager *mgr ); IModule *(*GetModule)(); void *handle = dlopen( name, RTLD_LAZY ); if ( handle == NULL ) { result = kLoadFailed; LOG_WARN( "Failed to open shared lib \"%s\": %s", name, dlerror() ); } else { LoadLibrary = (ErrorCode (*)(IComponentManager *mgr))dlsym( handle, "JHCOM_LibraryEntry" ); GetModule = (IModule *(*)())dlsym( handle, "JHCOM_GetModule" ); if ( GetModule == NULL || LoadLibrary == NULL ) { result = kLoadFailed; LOG_WARN( "Failed to get symbol" ); } else { LOG( "LoadLibrary is %p", LoadLibrary ); LOG( "RegisterServices is %p", GetModule ); result = LoadLibrary( this ); if ( result == kNoError ) { mod = GetModule(); mod->AddRef(); mod->loadComponents(); ModuleInfo *info = jh_new ModuleInfo( name, mod, handle ); mModules.push_back( info ); } } } return result; }
void GadWorkspace::newObject(int index, int x, int y) { qDebug("GadWorksapce::newObject(%d, (%d,%d))\n", index, x, y); if (!classNameMenu_) return; if (index < 0) return; qDebug(" className=%s\n name=%s\n", (const char *) classNameMenu_[index].className, (const char *) classNameMenu_[index].name); GadModule *module = GetModule(*classDict_, classNameMenu_[index].className, classNameMenu_[index].name); GadObject *obj = new GadObject(module, this); obj->move(x, y); obj->show(); resize(); }
void CException::ReportStd(ostream& out, TDiagPostFlags flags) const { string text(GetMsg()); string err_type(GetType()); err_type += "::"; err_type += GetErrCodeString(); SDiagMessage diagmsg( GetSeverity(), text.c_str(), text.size(), GetFile().c_str(), GetLine(), flags, NULL, 0, 0, err_type.c_str(), GetModule().c_str(), GetClass().c_str(), GetFunction().c_str()); diagmsg.Write(out, SDiagMessage::fNoEndl | SDiagMessage::fNoPrefix); }
void CFlowGraphModuleManager::LoadModuleGraph(const char* moduleName, const char* fileName) { // first check for existing module - must exist by this point CFlowGraphModule *pModule = static_cast<CFlowGraphModule*>(GetModule(moduleName)); assert(pModule); if(pModule) { if (pModule->LoadModuleGraph(moduleName, fileName)) { for(CListenerSet<IFlowGraphModuleListener*>::Notifier notifier(m_listeners); notifier.IsValid(); notifier.Next() ) { notifier->OnRootGraphChanged(pModule); } } } }
void CreateProjectDlg::UpdateVersionsCombo() { wxArrayString versions; if ( Lua::Get().call( "getModuleVersions", GetModule().ToStdString() ) ) { Helpers::PullTableOfStrings( versions ); } mVersionsCombo->Clear(); if (versions.size() > 0) { mVersionsCombo->Append( versions ); mVersionsCombo->SetSelection(0); } mVersionsCombo->Enable(versions.size() > 0); }
llvm::GlobalVariable *Property::GetMemberInfo() { if(!propertyInfo) { // Only create the property info variable when reflection is enabled. Module *module = GetModule(); if(!module->HasReflection()) return NULL; // Get the property info class. VirtualMachine *vm = module->GetVirtualMachine(); Class *propInfoClass = vm->GetPropertyInfoClass(); llvm::Module *targetModule = module->GetTargetModule(); propertyInfo = new llvm::GlobalVariable(*targetModule, propInfoClass->GetTargetType(), false, ComputeMetadataLinkage(), NULL, GetMangledName() + "_propinfo_"); } return propertyInfo; }
// Register the given function symbol and the LLVM function type it represents llvm::Function *CodeGen::RegisterBuiltin(const std::string &fn_name, llvm::FunctionType *fn_type, void *func_impl) { // Check if this is already registered as a built in, quit if to auto *builtin = LookupBuiltin(fn_name); if (builtin != nullptr) { return builtin; } // TODO: Function attributes here // Construct the function auto *function = llvm::Function::Create( fn_type, llvm::Function::ExternalLinkage, fn_name, &GetModule()); // Register the function in the context code_context_.RegisterBuiltin(function, func_impl); // That's it return function; }
CFlowGraphModule* CFlowGraphModuleManager::PreLoadModuleFile(const char* moduleName, const char* fileName, bool bGlobal) { // NB: the module name passed in might be a best guess based on the filename. The actual name // comes from within the module xml. // first check for existing module CFlowGraphModule *pModule = static_cast<CFlowGraphModule*>(GetModule(moduleName)); if(pModule) { for(CListenerSet<IFlowGraphModuleListener*>::Notifier notifier(m_listeners); notifier.IsValid(); notifier.Next() ) { notifier->OnModuleDestroyed(pModule); } // exists, reload pModule->Destroy(); pModule->PreLoadModule(fileName); for(CListenerSet<IFlowGraphModuleListener*>::Notifier notifier(m_listeners); notifier.IsValid(); notifier.Next() ) { notifier->OnPostModuleDestroyed(); } } else { // not found, create pModule = new CFlowGraphModule(m_moduleIdMaker++); pModule->SetType(bGlobal ? IFlowGraphModule::eT_Global : IFlowGraphModule::eT_Level); TModuleId id = pModule->GetId(); m_Modules[id] = pModule; pModule->PreLoadModule(fileName); AddModulePathInfo(pModule->GetName(), fileName); m_ModuleIds[pModule->GetName()] = id; } return pModule; }
// /// Loads a "hand" cursor from the winhlp32.exe module. // /// \note It appeared in Paul DiLascia's Jan 1998 MSJ articles. void TUrlLink::SetupCursor() { SetCursor(GetModule(), IDC_HANDCURSOR); if(HCursor == 0){ // if was problem try load cursor from winhlp32.exe // Get the windows directory TAPointer<tchar> Buffer(new tchar[MAX_PATH]); ::GetWindowsDirectory(Buffer, MAX_PATH); _tcscat(Buffer,_T("\\winhlp32.exe")); // This retrieves cursor #106 from winhlp32.exe, which is a hand pointer HMODULE hModule = ::LoadLibrary(Buffer); if (hModule) { HCURSOR hHandCursor = ::LoadCursor(hModule, TResId(106)); if (hHandCursor) HCursor = CopyCursor(hHandCursor); // it is a macro in Win32 ::FreeLibrary(hModule); } } }
/// Override TWindow virtual member function to fills out information about the /// Window class associated with a TUrlLink control. /// \note The class information is based on the system's "STATIC" class. // void TUrlLink::GetWindowClass(WNDCLASS& wndClass) { // Grab a the attributes of the native "STATIC" control if (::GetClassInfo(0, _T("STATIC"), &wndClass)){ wndClass.hInstance = *GetModule(); wndClass.style = CS_HREDRAW|CS_VREDRAW|CS_PARENTDC; wndClass.lpszClassName = GetClassName(); wndClass.lpfnWndProc = UrlLinkProc; wndClass.hCursor = HCursor; //wndClass.hbrBackground = HBRUSH(COLOR_BTNFACE+1); wndClass.hbrBackground = NULL; // Use the background of the parent } else { TStatic::GetWindowClass(wndClass); wndClass.style = CS_HREDRAW|CS_VREDRAW|CS_PARENTDC; //wndClass.hbrBackground = HBRUSH(COLOR_BTNFACE+1); wndClass.hbrBackground = NULL; // Use the background of the parent wndClass.hCursor = HCursor; } }
bool Cx_PluginLoader::RegisterPlugin(HMODULE instance) { if (FindModule(instance) >= 0) { return false; } Ix_Module* pModule = GetModule(instance); if (pModule != NULL) { MODULE moduleInfo; moduleInfo.hdll = instance; moduleInfo.module = pModule; moduleInfo.owned = false; moduleInfo.inited = false; GetModuleFileNameW(moduleInfo.hdll, moduleInfo.filename, MAX_PATH); int moduleIndex = GetPluginIndex(moduleInfo.filename); if (moduleIndex >= 0) { ASSERT(m_modules[moduleIndex] != NULL); *m_modules[moduleIndex] = moduleInfo; } else { moduleIndex = x3::GetSize(m_modules); MODULE* module = new MODULE; *module = moduleInfo; m_modules.push_back(module); } RegisterClassEntryTable(moduleIndex); return true; } return false; }
//---------------------------------------------------------------------------- // LoadModule HRESULT CMagpieApplication::LoadModule( CMagpieModule * pSrcModule, LPCOLESTR lpszModuleID, CMagpieModuleComObject *& pRet) { CString sModuleID; IF_FAILED_RET(ResolveModuleID( pSrcModule, lpszModuleID, sModuleID)); CComPtr<CMagpieModuleComObject> module; // is the module already loaded? HRESULT hr = E_FAIL; hr = GetModule(sModuleID, module.p); if (SUCCEEDED(hr)) { // yes, return module pRet = module.Detach(); return S_FALSE; // means: already loaded } // create a real path from the module ID... CString sModulePath, sModuleIDPath(sModuleID); sModuleIDPath.Replace(_T('/'), _T('\\')); // ...assuming that the file type is always 'js' // @TODO: Might change in future. sModulePath = m_RootPath + sModuleIDPath + _T(".js"); if (!PathFileExists(sModulePath)) { return HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND); } IF_FAILED_RET(CMagpieModule::CreateObject( *this, sModuleID, sModulePath, module.p)); m_Modules[sModuleID] = module; pRet = module.Detach(); return S_OK; }
// decref handled internally PyObject* LoadModule(std::string moduleName) { PyObject* module = GetModule(moduleName); if(module) return module; char* unConstName = const_cast<char*>(moduleName.c_str()); // lol // seriously, python's api implementers didn't get the const right? // or they are actually modifying stuff... module = PyImport_ImportModuleEx(unConstName, /*globals*/ NULL, /*locals*/ NULL, /*fromlist*/ NULL); if(!module || !PyModule_Check(module)) { printf("Error loading module:%s\n", moduleName.c_str()); PyErr_Print(); if(module) { Py_DECREF(module); } return NULL; } _modules.insert(std::make_pair(moduleName, module)); PyObject* dict = PyModule_GetDict(module); // borrowed reference _dictionaries.insert(std::make_pair(moduleName, dict)); return module; }
void Property::DefinitionPass() { // Only create once the member info. if(createdMemberInfo) return; createdMemberInfo = true; // Only create the reflection info in modules that support it. Module *module = GetModule(); if(!module->HasReflection()) return; // Get the property info class. VirtualMachine *vm = module->GetVirtualMachine(); Class *propInfoClass = vm->GetPropertyInfoClass(); // Create the property info value. ConstantStructurePtr propInfoValue(propInfoClass->CreateConstant(module)); // Store the MemberInfo attributes. SetMemberInfoData(propInfoValue); // Set the "getMethod" field. if(getAccessor) propInfoValue->SetField("getMethod", getAccessor->GetMemberInfo()); // Set the "setMethod" field. if(setAccessor) propInfoValue->SetField("setMethod", setAccessor->GetMemberInfo()); // Set the property type field. propInfoValue->SetField("propertyType", GetReflectedType(GetType())); // Set the field info. GetMemberInfo()->setInitializer(propInfoValue->Finish()); // Define the custom attributes. DefineAttributes(); }
VOID BuildNewImport(ULONG_PTR IATStart, ULONG_PTR IATEnd) { ULONG_PTR Current; PMODULE ActualModule = NULL; PEXPORTENTRY ActualExport = NULL; ImportEntryModule(IATStart); for (Current = IATStart; Current <= IATEnd; Current += SIZE_IMPORT_ENTRY) { if (!IsBadReadMemory((PVOID)Current, SIZE_IMPORT_ENTRY) && !IsBadReadMemory((PVOID)*(PULONG_PTR)Current, SIZE_IMPORT_ENTRY)) { if ((ActualModule = GetModule((ULONG_PTR)*(PVOID*)Current)) != NULL) { if ((ActualExport = GetExport(ActualModule, (ULONG_PTR)*(PVOID*)Current)) != NULL) { AddNewModuleApi(&pinfo.Importer, ActualModule, ActualExport, Current - (ULONG_PTR)GetModuleHandle(NULL)); } else { DbgMsg("[-] Meh can't find exports?!\n"); ExitProcess(42); } } } } PrintInfoImporter(&pinfo.Importer); ComputeAllITSize(&pinfo.Importer); }
CTypeInfo* CReferenceDataType::CreateTypeInfo(void) { CClassTypeInfo* info = CClassInfoHelper<AnyType>::CreateClassInfo(m_UserTypeName.c_str()); info->SetImplicit(); CMemberInfo* memInfo = info->AddMember("", 0, ResolveOrThrow()->GetTypeInfo()); const CDataMember *mem = GetDataMember(); if (!mem && GetParentType()) { mem = GetParentType()->GetDataMember(); } if (mem) { if (mem->Optional()) { memInfo->SetOptional(); } if (mem->NoPrefix()) { memInfo->SetNoPrefix(); } } if ( GetParentType() == 0 ) { // global info->SetModuleName(GetModule()->GetName()); } return info; }
HWND TUnixDialogBox :: DoCreate ( void ) { char far * globalp ; // Récupération du pointeur vers le template globalp = ( char far * ) GlobalLock ( MemoryHandle ) ; // Création de la boiboite DialogHandle = CreateDialogIndirectParam ( * GetModule ( ), globalp, ( ParentWindow != NULL ) ? ParentWindow -> HWindow : NULL, ( DLGPROC ) ( FARPROC ) DialogProcInstance, Attr. Param ) ; // Déverrouillage du template GlobalUnlock ( MemoryHandle ) ; // C'est bon return ( DialogHandle ) ; }
void ObjExtract (const char* Name) /* Extract a module from the library */ { FILE* Obj; /* Make a module name from the file name */ const char* Module = GetModule (Name); /* Try to find the module in the library */ const ObjData* O = FindObjData (Module); /* Bail out if the module does not exist */ if (O == 0) { Error ("Module `%s' not found in library `%s'", Module, LibName); } /* Open the output file */ Obj = fopen (Name, "w+b"); if (Obj == 0) { Error ("Cannot open target file `%s': %s", Name, strerror (errno)); } /* Copy the complete object file data from the library to the new object * file. */ LibCopyFrom (O->Start, O->Size, Obj); /* Close the file */ if (fclose (Obj) != 0) { Error ("Problem closing object file `%s': %s", Name, strerror (errno)); } /* Set access and modification time */ if (SetFileTimes (Name, O->MTime) != 0) { Error ("Cannot set mod time on `%s': %s", Name, strerror (errno)); } }
void TypeGroup::ReadStructure(ModuleReader &reader, const MemberHeader &header) { // Read the group members. Member *parent = GetParent(); Module *module = GetModule(); int count = header.memberSize/4; for(int i = 0; i < count; i++) { uint32_t id; reader >> id; // Get the member and check it.. Member *member = module->GetMember(id); if(!member->IsClass() && !member->IsStructure() && !member->IsInterface()) throw ModuleException("expected class/structure/interface member in type group."); // Store the member. buildings.push_back(static_cast<Structure*> (member)); // Update his parent. if(member && parent) member->UpdateParent(parent); } }
//----------------------------------------------------------------------------- // Get a ICorDebugValue for a static field on this class. // // Parameters: // fieldDef - metadata token for field on this class. Can not be from an // inherited class. // pFrame - frame used to resolve Thread-static, AppDomain-static, etc. // ppValue - OUT: gets value of the field. // // Returns: // S_OK on success. // CORDBG_E_STATIC_VAR_NOT_AVAILABLE //----------------------------------------------------------------------------- HRESULT CordbClass::GetStaticFieldValue(mdFieldDef fieldDef, ICorDebugFrame *pFrame, ICorDebugValue **ppValue) { PUBLIC_REENTRANT_API_ENTRY(this); FAIL_IF_NEUTERED(this); VALIDATE_POINTER_TO_OBJECT(ppValue, ICorDebugValue **); ATT_REQUIRE_STOPPED_MAY_FAIL(GetProcess()); HRESULT hr = S_OK; *ppValue = NULL; BOOL fEnCHangingField = FALSE; IMetaDataImport * pImport = NULL; EX_TRY { pImport = GetModule()->GetMetaDataImporter(); // throws // Validate the token. if (!pImport->IsValidToken(fieldDef) || (TypeFromToken(fieldDef) != mdtFieldDef)) { ThrowHR(E_INVALIDARG); } // Make sure we have enough info about the class. Init(); // Uninstantiated generics (eg, Foo<T>) don't have static data. Must use instantiated (eg Foo<int>) // But all CordbClass instances are uninstantiated. So this should fail for all generic types. // Normally, debuggers should be using ICorDebugType instead. // Though in the forward compat case, they'll hit this. if (HasTypeParams()) { ThrowHR(CORDBG_E_STATIC_VAR_NOT_AVAILABLE); } // Lookup the field given its metadata token. FieldData *pFieldData; hr = GetFieldInfo(fieldDef, &pFieldData); // This field was added by EnC, need to use EnC specific code path if (hr == CORDBG_E_ENC_HANGING_FIELD) { // Static fields added with EnC hang off the EnCFieldDesc hr = GetEnCHangingField(fieldDef, &pFieldData, NULL); if (SUCCEEDED(hr)) { fEnCHangingField = TRUE; } // Note: the FieldOffset in pFieldData has been cooked to produce // the correct address of the field in the syncBlock. // @todo: extend Debugger_IPCEFieldData so we don't have to cook the offset here } IfFailThrow(hr); { Instantiation emptyInst; hr = CordbClass::GetStaticFieldValue2(GetModule(), pFieldData, fEnCHangingField, &emptyInst, pFrame, ppValue); // Let hr fall through } } EX_CATCH_HRESULT(hr); // Translate Failure HRs. if (pImport != NULL) { hr = CordbClass::PostProcessUnavailableHRESULT(hr, pImport, fieldDef); } return hr; }
void CRouteTimeout::RunJob() { CRouteRepliesMod* pMod = (CRouteRepliesMod*)GetModule(); pMod->Timeout(); }