Skip to content

Instantly share code, notes, and snippets.

View ALSchwalm's full-sized avatar

Adam Schwalm ALSchwalm

View GitHub Profile
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
let cat = Cat {
meow_factor: 7
purr_factor: 8
};
let dog = Dog { ... };
let clone_mammal: &CloneMammal;
if get_random_bool() == true {
clone_mammal = &cat;
let cat = Cat {
meow_factor: 7
purr_factor: 8
};
// No problem, a CloneMammal is impl for Cat
let clone_mammal: &CloneMammal = cat;
// Error!
let clone: &Clone = &clone_mammal;
trait CloneMammal: Clone + Mammal{}
impl<T> CloneMammal for T where T: Clone + Mammal{}
struct CloningLab {
subjects: Vec<Box<Mammal + Clone>>,
}
impl CloningLab {
fn clone_subjects(&self) -> Vec<Box<Mammal + Clone>> {
self.subjects.clone()
}
}
struct CloningLab {
subjects: Vec<Box<Mammal>>,
}
trait Mammal {
fn walk(&self);
fn run(&self);
}
#[derive(Clone)]
""" A simple script to locate vtable groups in binaries with the Itanium ABI.
Note that this script does not account for virtual inheritance or (more notably),
cases were the vtable contains null pointers. This may happen in more recent
compilers with purely abstract types.
"""
import idaapi
import idautils
Bat* bat = new Bat();
Bird* b = bat;
Mammal* m = bat;
#include <iostream>
#include <cstdlib>
struct Mammal {
Mammal() { std::cout << "Mammal::Mammal\n"; }
virtual ~Mammal() {}
virtual void walk() { std::cout << "Mammal::walk\n"; }
};
struct Cat : Mammal {