1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-08 11:38:21 +02:00

Fixed environment issue

This commit is contained in:
Brian Fiete 2021-01-03 07:04:33 -08:00
parent 5fd037bc58
commit f928b93644

View file

@ -1645,24 +1645,31 @@ public:
} }
UTF16String envW; UTF16String envW;
WCHAR* envPtrW = NULL; void* envVoidPtr = NULL;
if ((env != NULL) && (env[0] != 0)) if ((env != NULL) && (env[0] != 0))
{ {
const char* envPtr = env; bool useUnicodeEnv = false;
while (true) if (useUnicodeEnv)
{ {
if ((envPtr[0] == 0) && (envPtr[1] == 0)) const char* envPtr = env;
break; while (true)
envPtr++; {
if ((envPtr[0] == 0) && (envPtr[1] == 0))
break;
envPtr++;
}
int envSize = (int)(envPtr - env) + 2;
String str8(env, envSize);
envW = UTF8Decode(str8);
envVoidPtr = (void*)envW.c_str();
startupInfo.dwFlags |= CREATE_UNICODE_ENVIRONMENT;
}
else
{
envVoidPtr = (void*)env;
} }
int envSize = (int)(envPtr - env) + 2;
String str8(env, envSize);
envW = UTF8Decode(str8);
envPtrW = (WCHAR*)envW.c_str();
startupInfo.dwFlags |= CREATE_UNICODE_ENVIRONMENT;
} }
retVal = ::CreateProcessW( retVal = ::CreateProcessW(
@ -1672,7 +1679,7 @@ public:
NULL, // pointer to thread security attributes NULL, // pointer to thread security attributes
true, // handle inheritance flag true, // handle inheritance flag
creationFlags, // creation flags creationFlags, // creation flags
envPtrW, // pointer to new environment block envVoidPtr, // pointer to new environment block
dirStrPtr, // pointer to current directory name dirStrPtr, // pointer to current directory name
&startupInfo, // pointer to STARTUPINFO &startupInfo, // pointer to STARTUPINFO
&processInfo // pointer to PROCESS_INFORMATION &processInfo // pointer to PROCESS_INFORMATION
@ -2757,6 +2764,7 @@ BFP_EXPORT BfpFile* BFP_CALLTYPE BfpFile_Create(const char* path, BfpFileCreateK
if (outResult != NULL) if (outResult != NULL)
{ {
int lastError = GetLastError(); int lastError = GetLastError();
switch (lastError) switch (lastError)
{ {
case ERROR_SHARING_VIOLATION: case ERROR_SHARING_VIOLATION: