• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #define _get_output_format __dummy__get_output_format
2 #define _set_output_format __dummy__set_output_format
3 #include <windows.h>
4 #include <msvcrt.h>
5 
6 #undef _get_output_format
7 #undef _set_output_format
8 
9 static unsigned int last_value = 0;
10 typedef unsigned int (*f_get_output_format)(void);
11 typedef unsigned int (*f_set_output_format)(unsigned int);
12 
13 static unsigned int init_set_output_format(unsigned int);
14 f_set_output_format __MINGW_IMP_SYMBOL(_set_output_format) = init_set_output_format;
15 
16 unsigned int _set_output_format(unsigned int format);
_set_output_format(unsigned int format)17 unsigned int _set_output_format(unsigned int format)
18 {
19     return __MINGW_IMP_SYMBOL(_set_output_format)(format);
20 }
21 
fake_set_output_format(unsigned int value)22 static unsigned int fake_set_output_format(unsigned int value)
23 {
24     return InterlockedExchange((LONG*)&last_value, value);
25 }
26 
init_set_output_format(unsigned int format)27 static unsigned int init_set_output_format(unsigned int format)
28 {
29   f_set_output_format sof;
30 
31   sof = (f_set_output_format) GetProcAddress (__mingw_get_msvcrt_handle(), "_set_output_format");
32   if(!sof)
33       sof = fake_set_output_format;
34 
35   return (__MINGW_IMP_SYMBOL(_set_output_format) = sof)(format);
36 }
37 
38 
39 static unsigned int init_get_output_format(void);
40 f_get_output_format __MINGW_IMP_SYMBOL(_get_output_format) = init_get_output_format;
41 
42 unsigned int _get_output_format(void);
_get_output_format(void)43 unsigned int _get_output_format(void)
44 {
45     return __MINGW_IMP_SYMBOL(_get_output_format)();
46 }
47 
fake_get_output_format(void)48 static unsigned int fake_get_output_format(void)
49 {
50     return last_value;
51 }
52 
init_get_output_format(void)53 static unsigned int init_get_output_format(void)
54 {
55   f_get_output_format gof;
56 
57   gof = (f_get_output_format) GetProcAddress (__mingw_get_msvcrt_handle(), "_get_output_format");
58   if(!gof)
59       gof = fake_get_output_format;
60 
61   return (__MINGW_IMP_SYMBOL(_get_output_format) = gof)();
62 }
63