本文整理汇总了C++中LibraryView::GetCrazy方法的典型用法代码示例。如果您正苦于以下问题:C++ LibraryView::GetCrazy方法的具体用法?C++ LibraryView::GetCrazy怎么用?C++ LibraryView::GetCrazy使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LibraryView
的用法示例。
在下文中一共展示了LibraryView::GetCrazy方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: FindSymbolFrom
void* LibraryList::FindSymbolFrom(const char* symbol_name, LibraryView* from) {
SymbolLookupState lookup_state;
if (!from)
return NULL;
// Use a work-queue and a set to ensure to perform a breadth-first
// search.
Vector<LibraryView*> work_queue;
Set<LibraryView*> visited_set;
work_queue.PushBack(from);
while (!work_queue.IsEmpty()) {
LibraryView* lib = work_queue.PopFirst();
if (lib->IsCrazy()) {
if (lookup_state.CheckSymbol(symbol_name, lib->GetCrazy()))
return lookup_state.found_addr;
} else if (lib->IsSystem()) {
// TODO(digit): Support weak symbols in system libraries.
// With the current code, all symbols in system libraries
// are assumed to be non-weak.
void* addr = lib->LookupSymbol(symbol_name);
if (addr)
return addr;
}
// If this is a crazy library, add non-visited dependencies
// to the work queue.
if (lib->IsCrazy()) {
SharedLibrary::DependencyIterator iter(lib->GetCrazy());
while (iter.GetNext()) {
LibraryView* dependency = FindKnownLibrary(iter.GetName());
if (dependency && !visited_set.Has(dependency)) {
work_queue.PushBack(dependency);
visited_set.Add(dependency);
}
}
}
}
if (lookup_state.weak_count >= 1) {
// There was at least a single weak symbol definition, so use
// the first one found in breadth-first search order.
return lookup_state.weak_addr;
}
// There was no symbol definition.
return NULL;
}
示例2: crazy_library_open_in_zip_file
crazy_status_t crazy_library_open_in_zip_file(crazy_library_t** library,
const char* zipfile_name,
const char* lib_name,
crazy_context_t* context) {
ScopedDelayedCallbackPoster poster(context);
ScopedGlobalLock lock;
LibraryView* wrap =
crazy::Globals::GetLibraries()->LoadLibraryInZipFile(
zipfile_name,
lib_name,
RTLD_NOW,
context->load_address,
&context->search_paths,
false,
&context->error);
if (!wrap)
return CRAZY_STATUS_FAILURE;
if (context->java_vm != NULL && wrap->IsCrazy()) {
crazy::SharedLibrary* lib = wrap->GetCrazy();
if (!lib->SetJavaVM(
context->java_vm, context->minimum_jni_version, &context->error)) {
crazy::Globals::GetLibraries()->UnloadLibrary(wrap);
return CRAZY_STATUS_FAILURE;
}
}
*library = reinterpret_cast<crazy_library_t*>(wrap);
return CRAZY_STATUS_SUCCESS;
}
示例3: FindLibraryForAddress
LibraryView* LibraryList::FindLibraryForAddress(void* address) {
// Linearly scan all libraries, looking for one that contains
// a given address. NOTE: This doesn't check that this falls
// inside one of the mapped library segments.
for (size_t n = 0; n < known_libraries_.GetCount(); ++n) {
LibraryView* wrap = known_libraries_[n];
// TODO(digit): Search addresses inside system libraries.
if (wrap->IsCrazy()) {
SharedLibrary* lib = wrap->GetCrazy();
if (lib->ContainsAddress(address))
return wrap;
}
}
return NULL;
}
示例4: crazy_library_use_shared_relro
crazy_status_t crazy_library_use_shared_relro(crazy_library_t* library,
crazy_context_t* context,
size_t relro_start,
size_t relro_size,
int relro_fd) {
LibraryView* wrap = reinterpret_cast<LibraryView*>(library);
if (!library || !wrap->IsCrazy()) {
context->error = "Invalid library file handle";
return CRAZY_STATUS_FAILURE;
}
crazy::SharedLibrary* lib = wrap->GetCrazy();
if (!lib->UseSharedRelro(relro_start, relro_size, relro_fd, &context->error))
return CRAZY_STATUS_FAILURE;
return CRAZY_STATUS_SUCCESS;
}
示例5: LoadLibrary
LibraryView* LibraryList::LoadLibrary(const char* lib_name,
int dlopen_mode,
uintptr_t load_address,
off_t file_offset,
SearchPathList* search_path_list,
Error* error) {
const char* base_name = GetBaseNamePtr(lib_name);
LOG("%s: lib_name='%s'\n", __FUNCTION__, lib_name);
// First check whether a library with the same base name was
// already loaded.
LibraryView* wrap = FindKnownLibrary(lib_name);
if (wrap) {
if (load_address) {
// Check that this is a crazy library and that is was loaded at
// the correct address.
if (!wrap->IsCrazy()) {
error->Format("System library can't be loaded at fixed address %08x",
load_address);
return NULL;
}
uintptr_t actual_address = wrap->GetCrazy()->load_address();
if (actual_address != load_address) {
error->Format("Library already loaded at @%08x, can't load it at @%08x",
actual_address,
load_address);
return NULL;
}
}
wrap->AddRef();
return wrap;
}
if (IsSystemLibrary(lib_name)) {
// This is a system library, probably because we're loading the
// library as a dependency.
LOG("%s: Loading system library '%s'\n", __FUNCTION__, lib_name);
::dlerror();
void* system_lib = dlopen(lib_name, dlopen_mode);
if (!system_lib) {
error->Format("Can't load system library %s: %s", lib_name, ::dlerror());
return NULL;
}
LibraryView* wrap = new LibraryView();
wrap->SetSystem(system_lib, lib_name);
known_libraries_.PushBack(wrap);
LOG("%s: System library %s loaded at %p\n", __FUNCTION__, lib_name, wrap);
LOG(" name=%s\n", wrap->GetName());
return wrap;
}
ScopedPtr<SharedLibrary> lib(new SharedLibrary());
// Find the full library path.
String full_path;
if (!strchr(lib_name, '/')) {
LOG("%s: Looking through the search path list\n", __FUNCTION__);
const char* path = search_path_list->FindFile(lib_name);
if (!path) {
error->Format("Can't find library file %s", lib_name);
return NULL;
}
full_path = path;
} else {
if (lib_name[0] != '/') {
// Need to transform this into a full path.
full_path = GetCurrentDirectory();
if (full_path.size() && full_path[full_path.size() - 1] != '/')
full_path += '/';
full_path += lib_name;
} else {
// Absolute path. Easy.
full_path = lib_name;
}
LOG("%s: Full library path: %s\n", __FUNCTION__, full_path.c_str());
if (!PathIsFile(full_path.c_str())) {
error->Format("Library file doesn't exist: %s", full_path.c_str());
return NULL;
}
}
// Load the library
if (!lib->Load(full_path.c_str(), load_address, file_offset, error))
return NULL;
// Load all dependendent libraries.
LOG("%s: Loading dependencies of %s\n", __FUNCTION__, base_name);
SharedLibrary::DependencyIterator iter(lib.Get());
Vector<LibraryView*> dependencies;
while (iter.GetNext()) {
Error dep_error;
LibraryView* dependency = LoadLibrary(iter.GetName(),
dlopen_mode,
0U /* load address */,
0U /* file offset */,
//.........这里部分代码省略.........