Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define echo(x) x
- #define random_var echo(__)echo(__LINE__)
- #define MAKE_VAR(x) static void echo(fakeFn)echo(__LINE__)() { if (&x)__debugbreak(); }
- #define ADD_INITIALIZER(section, function) \
- __pragma(const_seg(section)) \
- static INITIALIZER random_var = function; \
- MAKE_VAR(random_var)
- typedef void (__cdecl * const INITIALIZER)();
- #pragma const_seg("mydata$a")
- INITIALIZER firstInitializer = 0;
- #pragma const_seg("mydata$z")
- INITIALIZER lastInitializer = 0;
- void InitializeAllTheThings(INITIALIZER * pfbegin, INITIALIZER * pfend) {
- do {
- if (INITIALIZER initializer = *pfbegin++) initializer();
- } while(pfbegin < pfend);
- }
- void InitializeAllTheThings()
- {
- InitializeAllTheThings(&firstInitializer, &lastInitializer);
- }
- void __cdecl someFunc1();
- void __cdecl someFunc2();
- void __cdecl someFunc3();
- #pragma warning(disable : 4505) // unreferenced local function has been removed
- ADD_INITIALIZER("mydata$u", someFunc1)
- ADD_INITIALIZER("mydata$u", someFunc2)
- ADD_INITIALIZER("mydata$c", someFunc3)
- #pragma warning(default : 4505) // unreferenced local function has been removed
- ///////////////////////////////////////////////////////////////////////////////
- void __cdecl someFunc1() {
- DbgPrint("%s\n", __FUNCTION__);
- }
- void __cdecl someFunc2() {
- DbgPrint("%s\n", __FUNCTION__);
- }
- void __cdecl someFunc3() {
- DbgPrint("%s\n", __FUNCTION__);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement