This repository has been archived by the owner on Apr 27, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 269
/
crtfubar.h
55 lines (48 loc) · 2.38 KB
/
crtfubar.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#pragma once
// Fix up the CRT's FUBAR'ed _[w]sopen madness; we still have to link/run for/on
// down-level OS versions of the CRT DLL
// Produce prototypes matching the CRT but with different names (C linkage too!)
extern "C" {
int _ACRTIMP __cdecl _pdb_sopen(const char *, int, int, int);
int _ACRTIMP __cdecl _pdb_wsopen(const wchar_t *, int, int, int);
int _ACRTIMP __cdecl _pdb_open(const char *, int, int);
int _ACRTIMP __cdecl _pdb_wopen(const wchar_t *, int, int);
}
// Redirect the ones we use to the ones above
#define _sopen _pdb_sopen
#define _wsopen _pdb_wsopen
#define _open _pdb_open
#define _wopen _pdb_wopen
// Now, through a bit of linker magic, redirect the ones above to the real CRT ones
// that should have been accessible anyway.
#if defined(_M_IX86)
#if defined(_DLL)
#pragma comment(linker, "/alternatename:__imp___pdb_sopen=__imp___sopen")
#pragma comment(linker, "/alternatename:__imp___pdb_wsopen=__imp___wsopen")
#pragma comment(linker, "/alternatename:__imp___pdb_open=__imp___open")
#pragma comment(linker, "/alternatename:__imp___pdb_wopen=__imp___wopen")
#else
#pragma comment(linker, "/alternatename:__pdb_sopen=__sopen")
#pragma comment(linker, "/alternatename:__pdb_wsopen=__wsopen")
#pragma comment(linker, "/alternatename:__pdb_open=__open")
#pragma comment(linker, "/alternatename:__pdb_wopen=__wopen")
#endif
#else
#if defined(_DLL)
#pragma comment(linker, "/alternatename:__imp__pdb_sopen=__imp__sopen")
#pragma comment(linker, "/alternatename:__imp__pdb_wsopen=__imp__wsopen")
#pragma comment(linker, "/alternatename:__imp__pdb_open=__imp__open")
#pragma comment(linker, "/alternatename:__imp__pdb_wopen=__imp__wopen")
#else
#pragma comment(linker, "/alternatename:_pdb_sopen=_sopen")
#pragma comment(linker, "/alternatename:_pdb_wsopen=_wsopen")
#pragma comment(linker, "/alternatename:_pdb_open=_open")
#pragma comment(linker, "/alternatename:_pdb_wopen=_wopen")
#if defined(_M_IA64)
#pragma comment(linker, "/alternatename:._pdb_sopen=._sopen")
#pragma comment(linker, "/alternatename:._pdb_wsopen=._wsopen")
#pragma comment(linker, "/alternatename:._pdb_open=._open")
#pragma comment(linker, "/alternatename:._pdb_wopen=._wopen")
#endif
#endif
#endif