mirror of
https://codeberg.org/unspeaker/vestal.git
synced 2025-12-06 19:26:42 +01:00
good entrypoint for async rust
This commit is contained in:
parent
6660e28287
commit
0a1b74b2ae
6 changed files with 170 additions and 112 deletions
|
|
@ -434,3 +434,88 @@ impl Default for AEffect {
|
|||
}
|
||||
Ok(())
|
||||
}
|
||||
/// Relink a VST.
|
||||
//fn run (&mut self, path: impl AsRef<Path>) -> Usually<()> {
|
||||
//let path = path.as_ref().to_str().expect("path must be unicode");
|
||||
//let path = self.find(path)?.unwrap_or_else(||panic!("# not found: {path:?}"));
|
||||
//let main = self.load(&path)?;
|
||||
//Ok(())
|
||||
//}
|
||||
/// Load all dependencies recursively, starting from the given path.
|
||||
//fn load_all (&mut self, path: &impl AsRef<Path>) -> Usually<Arc<Module>> {
|
||||
//let name = to_dll_name(path);
|
||||
//let path: Arc<PathBuf> = Arc::from(PathBuf::from(path.as_ref()));
|
||||
//if self.modules.contains_key(&name) {
|
||||
//let module = self.modules.get(&name).unwrap().clone();
|
||||
//return Ok(module)
|
||||
//}
|
||||
//Log::load(self.verbose, &path);
|
||||
//let module = Arc::new(Module::new(&path, self.verbose)?.load(self.verbose)?);
|
||||
//self.modules.insert(module.name.clone(), module.clone());
|
||||
//Ok(module)
|
||||
//}
|
||||
//fn resolve (&self, dll: &Module, addr: u32, link: &Arc<CallSite>) -> Usually<()> {
|
||||
//let addr = (addr - dll.code_base) as usize;
|
||||
//dll.show_call_site(addr, link.length, 1);
|
||||
//link.show();
|
||||
//Ok(())
|
||||
//}
|
||||
//fn resolve_recursively (&self, dll: &Module, addr: u32, link: &Arc<CallSite>) -> Usually<()> {
|
||||
//self.resolve(dll, addr, link)?;
|
||||
//let module = &link.target.name;
|
||||
//let export = &link.method;
|
||||
//if let Some((module, export)) = match self.modules
|
||||
//.get(module)
|
||||
//.map(|module|module.exports.get(export))
|
||||
//{
|
||||
//Some(Some(ThunkData::Function(rva))) => Some((module.clone(), export.clone())),
|
||||
//Some(Some(ThunkData::ForwarderString(rva))) => dll.resolve_forward(&rva)?,
|
||||
//Some(Some(thunk)) => panic!("# unsupported {thunk:?}"),
|
||||
//Some(None) => panic!("# export not resolved: {export}"),
|
||||
//None => panic!("# module not resolved: {module}"),
|
||||
//} {
|
||||
//let module = self.modules.get(&module).unwrap_or_else(||panic!("# no module {module}"));
|
||||
//let method = module.exports.get(&export).unwrap_or_else(||panic!("# no method {export}"));
|
||||
//println!("{module:?} {export} {method:?}");
|
||||
//} else {
|
||||
//panic!("# unresolved link at {:?} [{addr}]", &dll.name)
|
||||
//}
|
||||
//Ok(())
|
||||
//}
|
||||
|
||||
/// Collect an imported dependency's descriptor thunks into a temporary [Vec].
|
||||
///
|
||||
/// Most of these are currently discarded, but may be needed in the future
|
||||
/// to resolve some of the trickier linkings.
|
||||
fn import_collect (pe: &VecPE, descriptor: &ImageImportDescriptor)
|
||||
-> Usually<(Arc<str>, Vec<(usize, Arc<str>)>)>
|
||||
{
|
||||
let mut buffer = vec![];
|
||||
let name = descriptor.get_name(pe)?.as_str()?.to_lowercase();
|
||||
for (index, import) in descriptor.get_imports(pe)?.iter().enumerate() {
|
||||
buffer.push((index, match import {
|
||||
ImportData::Ordinal(x) => format!("___VESTAL_ORDINAL_{x}"),
|
||||
ImportData::ImportByName(name) => format!("{name}"),
|
||||
}.into()));
|
||||
}
|
||||
Ok((name.into(), buffer))
|
||||
//let imp = descriptor.get_imports(pe)?;
|
||||
//let iat = descriptor.get_first_thunk(pe)?;
|
||||
//let ilt = descriptor.get_original_first_thunk(pe)?;
|
||||
//let lut = descriptor.get_lookup_thunks(pe)?;
|
||||
//for (index, (import, thunk, orig, lookup)) in izip!(
|
||||
//imp,
|
||||
//iat.iter().map(|thunk|format!("0x{:08x}", Self::thunk_unwrap(thunk, "IAT thunk"))),
|
||||
//ilt.iter().map(|thunk|format!("0x{:08x}", Self::thunk_unwrap(thunk, "ILT (orig) thunk"))),
|
||||
//lut.iter().map(|thunk|format!("0x{:08x}", Self::thunk_unwrap(thunk, "lookup thunk"))),
|
||||
//).enumerate() {
|
||||
//buffer.push((index, import));//, thunk, orig, lookup));
|
||||
//}
|
||||
}
|
||||
|
||||
//fn thunk_unwrap (thunk: &Thunk, name: impl AsRef<str>) -> u64 {
|
||||
//match thunk {
|
||||
//Thunk::Thunk32(t) => panic!("32 bit {}", name.as_ref()),
|
||||
//Thunk::Thunk64(t) => t.0
|
||||
//}
|
||||
//}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue