Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
alexbevi
GitHub Repository: alexbevi/BizHawk
Path: blob/master/libsnes/bsnes/nall/public_cast.hpp
2 views
1
#ifndef NALL_PUBLIC_CAST_HPP
2
#define NALL_PUBLIC_CAST_HPP
3
4
//this is a proof-of-concept-*only* C++ access-privilege elevation exploit.
5
//this code is 100% legal C++, per C++98 section 14.7.2 paragraph 8:
6
//"access checking rules do not apply to names in explicit instantiations."
7
//usage example:
8
9
//struct N { typedef void (Class::*)(); };
10
//template class public_cast<N, &Class::Reference>;
11
//(class.*public_cast<N>::value);
12
13
//Class::Reference may be public, protected or private
14
//Class::Reference may be a function, object or variable
15
16
namespace nall {
17
template<typename T, typename T::type... P> struct public_cast;
18
19
template<typename T> struct public_cast<T> {
20
static typename T::type value;
21
};
22
23
template<typename T> typename T::type public_cast<T>::value;
24
25
template<typename T, typename T::type P> struct public_cast<T, P> {
26
static typename T::type value;
27
};
28
29
template<typename T, typename T::type P> typename T::type public_cast<T, P>::value = public_cast<T>::value = P;
30
}
31
32
#endif
33
34