diff options
author | Benny Prijono <bennylp@teluu.com> | 2009-12-14 14:24:26 +0000 |
---|---|---|
committer | Benny Prijono <bennylp@teluu.com> | 2009-12-14 14:24:26 +0000 |
commit | eaae76bc3e865c2d3303d42db9501c2daeb66419 (patch) | |
tree | 0f08cff0b9831f8d3458d480cd32fe8b6472a620 /pjlib/src/pj/ip_helper_win32.c | |
parent | 93d1127e3556d57f297f7c3ff405502633c31378 (diff) |
Ticket #1000: fixed different treatment with regard to Unicode argument to GetProcAddress between Windows and Windows Mobile
git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@3033 74dad513-b988-da41-8d7b-12977e46ad98
Diffstat (limited to 'pjlib/src/pj/ip_helper_win32.c')
-rw-r--r-- | pjlib/src/pj/ip_helper_win32.c | 49 |
1 files changed, 44 insertions, 5 deletions
diff --git a/pjlib/src/pj/ip_helper_win32.c b/pjlib/src/pj/ip_helper_win32.c index 56d292e4..8603a588 100644 --- a/pjlib/src/pj/ip_helper_win32.c +++ b/pjlib/src/pj/ip_helper_win32.c @@ -41,6 +41,45 @@ #include <pj/errno.h> #include <pj/string.h> +/* Dealing with Unicode quirks: + + There seems to be a difference with GetProcAddress() API signature between + Windows (i.e. Win32) and Windows CE (e.g. Windows Mobile). On Windows, the + API is declared as: + + FARPROC GetProcAddress( + HMODULE hModule, + LPCSTR lpProcName); + + while on Windows CE: + + FARPROC GetProcAddress( + HMODULE hModule, + LPCWSTR lpProcName); + + Notice the difference with lpProcName argument type. This means that on + Windows, even on Unicode Windows, the lpProcName always takes ANSI format, + while on Windows CE, the argument follows the UNICODE setting. + + Because of this, we use a different Unicode treatment here than the usual + PJ_NATIVE_STRING_IS_UNICODE PJLIB setting (<pj/unicode.h>): + - GPA_TEXT macro: convert literal string to platform's native literal + string + - gpa_char: the platform native character type + + Note that "GPA" and "gpa" are abbreviations for GetProcAddress. +*/ +#if defined(PJ_WIN32_WINCE) && PJ_WIN32_WINCE!=0 + /* on CE, follow the PJLIB Unicode setting */ +# define GPA_TEXT(x) PJ_T(x) +# define gpa_char pj_char_t +#else + /* on non-CE, always use ANSI format */ +# define GPA_TEXT(x) x +# define gpa_char char +#endif + + typedef DWORD (WINAPI *PFN_GetIpAddrTable)(PMIB_IPADDRTABLE pIpAddrTable, PULONG pdwSize, BOOL bOrder); @@ -71,7 +110,7 @@ static void unload_iphlp_module(void) s_pfnGetAdapterAddresses = NULL; } -static FARPROC GetIpHlpApiProc(char *lpProcName) +static FARPROC GetIpHlpApiProc(gpa_char *lpProcName) { if(NULL == s_hDLL) { s_hDLL = LoadLibrary(PJ_T("IpHlpApi")); @@ -92,7 +131,7 @@ static DWORD MyGetIpAddrTable(PMIB_IPADDRTABLE pIpAddrTable, { if(NULL == s_pfnGetIpAddrTable) { s_pfnGetIpAddrTable = (PFN_GetIpAddrTable) - GetIpHlpApiProc("GetIpAddrTable"); + GetIpHlpApiProc(GPA_TEXT("GetIpAddrTable")); } if(NULL != s_pfnGetIpAddrTable) { @@ -110,7 +149,7 @@ static DWORD MyGetAdapterAddresses(ULONG Family, { if(NULL == s_pfnGetAdapterAddresses) { s_pfnGetAdapterAddresses = (PFN_GetAdapterAddresses) - GetIpHlpApiProc("GetAdaptersAddresses"); + GetIpHlpApiProc(GPA_TEXT("GetAdaptersAddresses")); } if(NULL != s_pfnGetAdapterAddresses) { @@ -126,7 +165,7 @@ static DWORD MyGetIfEntry(MIB_IFROW *pIfRow) { if(NULL == s_pfnGetIfEntry) { s_pfnGetIfEntry = (PFN_GetIfEntry) - GetIpHlpApiProc("GetIfEntry"); + GetIpHlpApiProc(GPA_TEXT("GetIfEntry")); } if(NULL != s_pfnGetIfEntry) { @@ -144,7 +183,7 @@ static DWORD MyGetIpForwardTable(PMIB_IPFORWARDTABLE pIpForwardTable, { if(NULL == s_pfnGetIpForwardTable) { s_pfnGetIpForwardTable = (PFN_GetIpForwardTable) - GetIpHlpApiProc("GetIpForwardTable"); + GetIpHlpApiProc(GPA_TEXT("GetIpForwardTable")); } if(NULL != s_pfnGetIpForwardTable) { |