/* ares_library_init error codes */
#define ARES_ELOADIPHLPAPI 21
-#define ARES_ELOADADVAPI32 22
-#define ARES_EADDRGetNetworkParams 23
+#define ARES_EADDRGetNetworkParams 22
/* Flag values */
#define ARES_FLAG_USEVC (1 << 0)
return ARES_EADDRGetNetworkParams;
}
+ /*
+ * When advapi32.dll is unavailable or advapi32.dll has no SystemFunction036,
+ * also known as RtlGenRandom, which is the case for Windows versions prior
+ * to WinXP then c-ares uses portable rand() function. Then don't error here.
+ */
+
hnd_advapi32 = 0;
hnd_advapi32 = LoadLibrary("advapi32.dll");
- if (!hnd_advapi32)
+ if (hnd_advapi32)
{
- FreeLibrary(hnd_iphlpapi);
- return ARES_ELOADADVAPI32;
+ fpSystemFunction036 = (fpSystemFunction036_t)
+ GetProcAddress(hnd_advapi32, "SystemFunction036");
}
- fpSystemFunction036 = (fpSystemFunction036_t)
- GetProcAddress(hnd_advapi32, "SystemFunction036");
-
- /*
- * Intentionally avoid checking if the address of SystemFunction036, a.k.a.
- * RtlGenRandom, has been located or not. This function is only available on
- * WinXP and later. When unavailable c-ares uses portable rand() function.
- */
-
#endif
return ARES_SUCCESS;
}
"Given hostname is not numeric",
"Illegal hints flags specified",
"Error loading iphlpapi.dll",
- "Error loading advapi32.dll",
"Could not find GetNetworkParams function"
};