daily pastebin goal
14%
SHARE
TWEET

Untitled

a guest Nov 9th, 2018 81 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. typedef void (__cdecl *INITIALIZER)();
  2.  
  3. #pragma const_seg("mydata$a")  
  4. const INITIALIZER firstInitializer = 0;
  5.  
  6. #pragma const_seg("mydata$z")  
  7. const INITIALIZER lastInitializer = 0;
  8.  
  9. void InitializeAllTheThings(const INITIALIZER * pfbegin, const INITIALIZER * pfend) {
  10.     // if (pfbegin < pfend)
  11.     do {
  12.         if (const INITIALIZER initializer = *pfbegin++) initializer();
  13.     } while(pfbegin < pfend);
  14. }
  15.  
  16. void InitializeAllTheThings()
  17. {
  18.     InitializeAllTheThings(&firstInitializer + 1, &lastInitializer);
  19. }
  20.  
  21. void __cdecl someFunc();
  22.  
  23. #pragma const_seg("mydata$u")  
  24. __declspec(allocate("mydata$u")) /*const*/ INITIALIZER __x_m = someFunc;
  25.  
  26. #pragma warning(disable : 4075) // initializers put in unrecognized initialization area
  27. #pragma init_seg("mydata$u")
  28.  
  29. struct XXX {
  30.     XXX() { someFunc(); }
  31. };
  32.  
  33. //static XXX g_x;
  34. __pragma(comment(linker, "/include:?__x_m@@3P6AXXZEA"))
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top