1 #if (defined(_WIN64) || defined(_WIN32_WCE)) && !defined(UNICODE)
4 #if defined(UNICODE) && !defined(_UNICODE)
7 #if defined(_UNICODE) && !defined(UNICODE)
15 void OPENSSL_showfatal(const char *, ...);
17 static TCHAR msg[128];
19 static void unimplemented(void)
21 OPENSSL_showfatal(sizeof(TCHAR) == sizeof(char) ? "%s\n" : "%S\n", msg);
25 void OPENSSL_Uplink(volatile void **table, int index)
27 static HMODULE volatile apphandle = NULL;
28 static void **volatile applinktable = NULL;
30 void (*func) (void) = unimplemented;
35 * Note that the below code is not MT-safe in respect to msg buffer, but
36 * what's the worst thing that can happen? Error message might be
37 * misleading or corrupted. As error condition is fatal and should never
38 * be risen, I accept the risk...
41 * One can argue that I should have used InterlockedExchangePointer or
42 * something to update static variables and table[]. Well, store
43 * instructions are as atomic as they can get and assigned values are
44 * effectively constant... So that volatile qualifier should be
45 * sufficient [it prohibits compiler to reorder memory access
49 len = _sntprintf(msg, sizeof(msg) / sizeof(TCHAR),
50 _T("OPENSSL_Uplink(%p,%02X): "), table, index);
51 _tcscpy(msg + len, _T("unimplemented function"));
53 if ((h = apphandle) == NULL) {
54 if ((h = GetModuleHandle(NULL)) == NULL) {
55 apphandle = (HMODULE) - 1;
56 _tcscpy(msg + len, _T("no host application"));
61 if ((h = apphandle) == (HMODULE) - 1) /* revalidate */
64 if (applinktable == NULL) {
67 applink = (void **(*)())GetProcAddress(h, "OPENSSL_Applink");
68 if (applink == NULL) {
69 apphandle = (HMODULE) - 1;
70 _tcscpy(msg + len, _T("no OPENSSL_Applink"));
75 apphandle = (HMODULE) - 1;
76 _tcscpy(msg + len, _T("no ApplinkTable"));
83 if (index > (int)p[0])
96 UP_fprintf(UP_stdout, "hello, world!\n");