Ignore:
Timestamp:
Sep 29, 2010, 12:04:46 AM (15 years ago)
Author:
dmik
Message:

Fixed: CreateProcess could not start programs with national characters in names on systems where the OS/2 codepage is not equal to the Windows ANSI codepage (like the .ru locale). Continuation of r21461.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/kernel32/wprocess.cpp

    r21445 r21462  
    19181918//******************************************************************************
    19191919//******************************************************************************
     1920static BOOL WINAPI O32_CreateProcessA(LPCSTR lpApplicationName, LPCSTR lpCommandLine,
     1921                                      LPSECURITY_ATTRIBUTES lpProcessAttributes,
     1922                                      LPSECURITY_ATTRIBUTES lpThreadAttributes,
     1923                                      BOOL bInheritHandles, DWORD dwCreationFlags,
     1924                                      LPVOID lpEnvironment, LPCSTR lpCurrentDirectory,
     1925                                      LPSTARTUPINFOA lpStartupInfo,
     1926                                      LPPROCESS_INFORMATION lpProcessInfo)
     1927{
     1928    LPSTR lpstr;
     1929    DWORD cb;
     1930    BOOL rc;
     1931
     1932    #define ALLOC_OEM(v) \
     1933        if (v) { \
     1934            lpstr = (LPSTR)_smalloc(strlen(v) + 1); \
     1935            CharToOemA(v,  lpstr); \
     1936            v = lpstr; \
     1937        }
     1938    #define FREE_OEM(v) \
     1939        if (v) \
     1940            _sfree((void*)v); \
     1941
     1942
     1943    // this converts all string arguments from ANSI to OEM expected by
     1944    // O32_CreateProcess()
     1945
     1946    ALLOC_OEM(lpApplicationName)
     1947    ALLOC_OEM(lpCommandLine)
     1948    ALLOC_OEM(lpCurrentDirectory)
     1949
     1950    if (lpEnvironment) {
     1951        cb = 0;
     1952        lpstr = (LPSTR)lpEnvironment;
     1953        while (lpstr[cb]) {
     1954            cb += strlen(&lpstr[cb]) + 1;
     1955        }
     1956        ++cb;
     1957        lpstr = (LPSTR)_smalloc(cb);
     1958        CharToOemBuffA((LPSTR)lpEnvironment, lpstr, cb);
     1959        lpEnvironment = lpstr;
     1960    }
     1961
     1962    ALLOC_OEM(lpStartupInfo->lpReserved)
     1963    ALLOC_OEM(lpStartupInfo->lpDesktop)
     1964    ALLOC_OEM(lpStartupInfo->lpTitle)
     1965
     1966    rc = O32_CreateProcess(lpApplicationName, lpCommandLine,
     1967                           lpProcessAttributes, lpThreadAttributes,
     1968                           bInheritHandles, dwCreationFlags,
     1969                           lpEnvironment, lpCurrentDirectory,
     1970                           lpStartupInfo, lpProcessInfo);
     1971
     1972    FREE_OEM(lpStartupInfo->lpTitle)
     1973    FREE_OEM(lpStartupInfo->lpDesktop)
     1974    FREE_OEM(lpStartupInfo->lpReserved)
     1975
     1976    FREE_OEM(lpEnvironment)
     1977
     1978    FREE_OEM(lpCurrentDirectory)
     1979    FREE_OEM(lpCommandLine)
     1980    FREE_OEM(lpApplicationName)
     1981
     1982    return rc;
     1983}
     1984//******************************************************************************
     1985//******************************************************************************
    19201986BOOL WINAPI CreateProcessA( LPCSTR lpApplicationName, LPSTR lpCommandLine,
    19211987                            LPSECURITY_ATTRIBUTES lpProcessAttributes,
     
    19261992                            LPPROCESS_INFORMATION lpProcessInfo )
    19271993{
    1928  STARTUPINFOA startinfo;
    1929  TEB *pThreadDB = (TEB*)GetThreadTEB();
    1930  char *cmdline = NULL, *newenv = NULL, *oldlibpath = NULL;
    1931  BOOL  rc;
     1994    STARTUPINFOA startinfo;
     1995    TEB *pThreadDB = (TEB*)GetThreadTEB();
     1996    char *cmdline = NULL, *newenv = NULL, *oldlibpath = NULL;
     1997    BOOL  rc;
     1998    LPSTR lpstr;
    19321999
    19332000    dprintf(("KERNEL32: CreateProcessA %s cline:%s inherit:%d cFlags:%x Env:%x CurDir:%s StartupFlags:%x\n",
     
    20972164
    20982165    trylaunchagain:
    2099       if(O32_CreateProcess(szAppName, lpCommandLine, lpProcessAttributes,
    2100                          lpThreadAttributes, bInheritHandles, dwCreationFlags,
    2101                          lpEnvironment, lpCurrentDirectory, lpStartupInfo,
    2102                          lpProcessInfo) == TRUE)
     2166      if (O32_CreateProcessA(szAppName, lpCommandLine, lpProcessAttributes,
     2167                             lpThreadAttributes, bInheritHandles, dwCreationFlags,
     2168                             lpEnvironment, lpCurrentDirectory, lpStartupInfo,
     2169                             lpProcessInfo) == TRUE)
    21032170      {
    21042171        if (dwCreationFlags & DEBUG_PROCESS && pThreadDB != NULL)
     
    22242291                 cmdline));
    22252292
    2226         rc = O32_CreateProcess(lpszExecutable, (LPCSTR)cmdline,lpProcessAttributes,
    2227                                lpThreadAttributes, bInheritHandles, dwCreationFlags,
    2228                                lpEnvironment, lpCurrentDirectory, lpStartupInfo,
    2229                                lpProcessInfo);
     2293        rc = O32_CreateProcessA(lpszExecutable, (LPCSTR)cmdline,lpProcessAttributes,
     2294                                lpThreadAttributes, bInheritHandles, dwCreationFlags,
     2295                                lpEnvironment, lpCurrentDirectory, lpStartupInfo,
     2296                                lpProcessInfo);
    22302297    }
    22312298    else
     
    22442311                 szNELoader,
    22452312                 cmdline));
    2246         rc = O32_CreateProcess(szNELoader, (LPCSTR)cmdline, lpProcessAttributes,
    2247                                lpThreadAttributes, bInheritHandles, dwCreationFlags,
    2248                                lpEnvironment, lpCurrentDirectory, lpStartupInfo,
    2249                                lpProcessInfo);
     2313        rc = O32_CreateProcessA(szNELoader, (LPCSTR)cmdline, lpProcessAttributes,
     2314                                lpThreadAttributes, bInheritHandles, dwCreationFlags,
     2315                                lpEnvironment, lpCurrentDirectory, lpStartupInfo,
     2316                                lpProcessInfo);
    22502317    }
    22512318    else {//os/2 app??
    2252         rc = O32_CreateProcess(szAppName, (LPCSTR)lpCommandLine, lpProcessAttributes,
    2253                                lpThreadAttributes, bInheritHandles, dwCreationFlags,
    2254                                lpEnvironment, lpCurrentDirectory, lpStartupInfo,
    2255                                lpProcessInfo);
     2319        rc = O32_CreateProcessA(szAppName, (LPCSTR)lpCommandLine, lpProcessAttributes,
     2320                                lpThreadAttributes, bInheritHandles, dwCreationFlags,
     2321                                lpEnvironment, lpCurrentDirectory, lpStartupInfo,
     2322                                lpProcessInfo);
    22562323    }
    22572324    if(!lpEnvironment) {
Note: See TracChangeset for help on using the changeset viewer.