1 2 #ifdef _GCC_SSP_MSVCRT_ 3 4 #include <windef.h> 5 #include <winbase.h> 6 #include <stdio.h> 7 8 #define print_caller() do { \ 9 char buffer[64]; \ 10 _snprintf(buffer, sizeof(buffer), "STACK PROTECTOR FAULT AT %p\n", __builtin_extract_return_addr(__builtin_return_address (0))); \ 11 OutputDebugStringA(buffer); \ 12 } while(0) 13 14 #elif defined(_GCC_SSP_WIN32K_) 15 16 #include <windef.h> 17 #include <wingdi.h> 18 #include <winddi.h> 19 #include <stdarg.h> 20 21 static inline 22 void 23 print_caller_helper(char* fmt, ...) 24 { 25 va_list args; 26 27 va_start(args, fmt); 28 EngDebugPrint("", fmt, args); 29 va_end(args); 30 } 31 32 #define print_caller() print_caller_helper("STACK PROTECTOR FAULT AT %p\n", __builtin_extract_return_addr(__builtin_return_address(0))) 33 34 #elif defined(_GCC_SSP_SCSIPORT_) 35 36 #include <ntddk.h> 37 #include <srb.h> 38 39 #define print_caller() ScsiDebugPrint(0, "STACK PROTECTOR FAULT AT %p\n", __builtin_extract_return_addr(__builtin_return_address(0))) 40 41 #elif defined(_GCC_SSP_VIDEOPRT_) 42 43 #include <ntdef.h> 44 #include <miniport.h> 45 #include <video.h> 46 47 #define print_caller() VideoPortDebugPrint(0, "STACK PROTECTOR FAULT AT %p\n", __builtin_extract_return_addr(__builtin_return_address(0))) 48 49 #else 50 51 #include <ntdef.h> 52 #include <debug.h> 53 54 #define print_caller() DbgPrint("STACK PROTECTOR FAULT AT %p\n", __builtin_extract_return_addr(__builtin_return_address(0))) 55 56 #endif 57 58 /* Should be random :-/ */ 59 void * __stack_chk_guard = (void*)0xb00fbeefbaafb00f; 60 61 void __stack_chk_fail() 62 { 63 print_caller(); 64 __asm__("int $3"); 65 } 66