Changeset 3033


Ignore:
Timestamp:
Dec 14, 2009 2:24:26 PM (9 years ago)
Author:
bennylp
Message:

Ticket #1000: fixed different treatment with regard to Unicode argument to GetProcAddress? between Windows and Windows Mobile

File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjlib/src/pj/ip_helper_win32.c

    r3030 r3033  
    4242#include <pj/string.h> 
    4343 
     44/* Dealing with Unicode quirks: 
     45 
     46 There seems to be a difference with GetProcAddress() API signature between 
     47 Windows (i.e. Win32) and Windows CE (e.g. Windows Mobile). On Windows, the 
     48 API is declared as: 
     49 
     50   FARPROC GetProcAddress( 
     51     HMODULE hModule, 
     52     LPCSTR lpProcName); 
     53  
     54 while on Windows CE: 
     55 
     56   FARPROC GetProcAddress( 
     57     HMODULE hModule, 
     58     LPCWSTR lpProcName); 
     59 
     60 Notice the difference with lpProcName argument type. This means that on  
     61 Windows, even on Unicode Windows, the lpProcName always takes ANSI format,  
     62 while on Windows CE, the argument follows the UNICODE setting. 
     63 
     64 Because of this, we use a different Unicode treatment here than the usual 
     65 PJ_NATIVE_STRING_IS_UNICODE PJLIB setting (<pj/unicode.h>): 
     66   - GPA_TEXT macro: convert literal string to platform's native literal  
     67         string 
     68   - gpa_char: the platform native character type 
     69 
     70 Note that "GPA" and "gpa" are abbreviations for GetProcAddress. 
     71*/ 
     72#if defined(PJ_WIN32_WINCE) && PJ_WIN32_WINCE!=0 
     73    /* on CE, follow the PJLIB Unicode setting */ 
     74#   define GPA_TEXT(x)  PJ_T(x) 
     75#   define gpa_char     pj_char_t 
     76#else 
     77    /* on non-CE, always use ANSI format */ 
     78#   define GPA_TEXT(x)  x 
     79#   define gpa_char     char 
     80#endif 
     81 
     82 
    4483typedef DWORD (WINAPI *PFN_GetIpAddrTable)(PMIB_IPADDRTABLE pIpAddrTable,  
    4584                                           PULONG pdwSize,  
     
    72111} 
    73112 
    74 static FARPROC GetIpHlpApiProc(char *lpProcName) 
     113static FARPROC GetIpHlpApiProc(gpa_char *lpProcName) 
    75114{ 
    76115    if(NULL == s_hDLL) { 
     
    93132    if(NULL == s_pfnGetIpAddrTable) { 
    94133        s_pfnGetIpAddrTable = (PFN_GetIpAddrTable)  
    95             GetIpHlpApiProc("GetIpAddrTable"); 
     134            GetIpHlpApiProc(GPA_TEXT("GetIpAddrTable")); 
    96135    } 
    97136     
     
    111150    if(NULL == s_pfnGetAdapterAddresses) { 
    112151        s_pfnGetAdapterAddresses = (PFN_GetAdapterAddresses)  
    113             GetIpHlpApiProc("GetAdaptersAddresses"); 
     152            GetIpHlpApiProc(GPA_TEXT("GetAdaptersAddresses")); 
    114153    } 
    115154     
     
    127166    if(NULL == s_pfnGetIfEntry) { 
    128167        s_pfnGetIfEntry = (PFN_GetIfEntry)  
    129             GetIpHlpApiProc("GetIfEntry"); 
     168            GetIpHlpApiProc(GPA_TEXT("GetIfEntry")); 
    130169    } 
    131170     
     
    145184    if(NULL == s_pfnGetIpForwardTable) { 
    146185        s_pfnGetIpForwardTable = (PFN_GetIpForwardTable)  
    147             GetIpHlpApiProc("GetIpForwardTable"); 
     186            GetIpHlpApiProc(GPA_TEXT("GetIpForwardTable")); 
    148187    } 
    149188     
Note: See TracChangeset for help on using the changeset viewer.