- MGR/CLI: remove direct references to CreateEnvironmentBlock and

DestroyEnvironmentBlock since Win98 doesn't support them. This
        functionality is only required for the Windows sandbox implementation
        anyway.
    - LIB: Remove direct reference to OpenThread in win_util.C since it
        isn't supported on Win98.
    - MGR: Another fix for CC execution on a Linux machine.
        
    client/
        app_start.C
    clientgui/
        BOINCClientManager.cpp
    lib/
        proc_control.C
        win_util.C

svn path=/trunk/boinc/; revision=15117
This commit is contained in:
Rom Walton 2008-05-02 15:59:37 +00:00
parent d9645557a5
commit 3dc77154e5
7 changed files with 389 additions and 296 deletions

View File

@ -3511,3 +3511,20 @@ David May 1 2008
coproc.C
sched/
sched_send.C
Rom May 2 2008
- MGR/CLI: remove direct references to CreateEnvironmentBlock and
DestroyEnvironmentBlock since Win98 doesn't support them. This
functionality is only required for the Windows sandbox implementation
anyway.
- LIB: Remove direct reference to OpenThread in win_util.C since it
isn't supported on Win98.
- MGR: Another fix for CC execution on a Linux machine.
client/
app_start.C
clientgui/
BOINCClientManager.cpp
lib/
proc_control.C
win_util.C

View File

@ -77,6 +77,18 @@ using std::vector;
#include "app.h"
#ifdef _WIN32
// Dynamically link to these functions at runtime, otherwise BOINC
// cannot run on Win98
// CreateEnvironmentBlock
typedef BOOL (WINAPI *tCEB)(LPVOID *lpEnvironment, HANDLE hToken, BOOL bInherit);
// DestroyEnvironmentBlock
typedef BOOL (WINAPI *tDEB)(LPVOID lpEnvironment);
#endif
// Goes through an array of strings, and prints each string
//
#ifndef _WIN32
@ -514,8 +526,18 @@ int ACTIVE_TASK::start(bool first_time) {
for (i=0; i<5; i++) {
if (sandbox_account_service_token != NULL) {
// Find CreateEnvironmentBlock/DestroyEnvironmentBlock pointers
tCEB pCEB = NULL;
tDEB pDEB = NULL;
HMODULE hUserEnvLib = NULL;
if (!CreateEnvironmentBlock(&environment_block, sandbox_account_service_token, FALSE)) {
hUserEnvLib = LoadLibrary("userenv.dll");
if (hUserEnvLib) {
pCEB = (tCEB) GetProcAddress(hUserEnvLib, "CreateEnvironmentBlock");
pDEB = (tDEB) GetProcAddress(hUserEnvLib, "DestroyEnvironmentBlock");
}
if (!pCEB(&environment_block, sandbox_account_service_token, FALSE)) {
if (log_flags.task) {
windows_error_string(error_msg, sizeof(error_msg));
msg_printf(result->project, MSG_INFO,
@ -546,7 +568,7 @@ int ACTIVE_TASK::start(bool first_time) {
);
}
if (!DestroyEnvironmentBlock(environment_block)) {
if (!pDEB(environment_block)) {
if (log_flags.task) {
windows_error_string(error_msg, sizeof(error_msg));
msg_printf(result->project, MSG_INFO,
@ -555,6 +577,12 @@ int ACTIVE_TASK::start(bool first_time) {
}
}
if (hUserEnvLib) {
pCEB = NULL;
pDEB = NULL;
FreeLibrary(hUserEnvLib);
}
} else {
if (CreateProcess(
exec_path,

View File

@ -144,6 +144,8 @@ bool CBOINCClientManager::IsBOINCCoreRunning() {
bool CBOINCClientManager::StartupBOINCCore() {
wxLogTrace(wxT("Function Start/End"), wxT("CMainDocument::CachedStateUpdate - Function Begin"));
bool bReturnValue = false;
wxString strExecute = wxEmptyString;
@ -182,6 +184,9 @@ bool CBOINCClientManager::StartupBOINCCore() {
szDataDirectory = (LPTSTR)wxGetApp().GetDataDirectory().c_str();
}
fprintf(stderr, "CMainDocument::CachedStateUpdate - szExecute '%s'\n", szExecute);
fprintf(stderr, "CMainDocument::CachedStateUpdate - szDataDirectory '%s'\n", szDataDirectory);
bProcessStarted = CreateProcess(
NULL,
szExecute,
@ -257,7 +262,7 @@ bool CBOINCClientManager::StartupBOINCCore() {
#else // Unix based systems
// Append boinc.exe to the end of the strExecute string and get ready to rock
strExecute = wxT("boinc -redirectio -launched_by_manager");
strExecute = wxT("./boinc -redirectio -launched_by_manager");
if (!g_use_sandbox) {
strExecute += wxT(" -insecure");
}
@ -271,6 +276,7 @@ bool CBOINCClientManager::StartupBOINCCore() {
bReturnValue = true;
}
wxLogTrace(wxT("Function Start/End"), wxT("CMainDocument::CachedStateUpdate - Function End"));
return bReturnValue;
}

View File

@ -174,6 +174,13 @@ void get_sandbox_account_service_token() {
// chdir into the given directory, and run a program there.
// argv is set up Unix-style, i.e. argv[0] is the program name
//
// CreateEnvironmentBlock
typedef BOOL (WINAPI *tCEB)(LPVOID *lpEnvironment, HANDLE hToken, BOOL bInherit);
// DestroyEnvironmentBlock
typedef BOOL (WINAPI *tDEB)(LPVOID lpEnvironment);
int run_app_windows(
const char* dir, const char* file, int argc, char *const argv[], HANDLE& id
) {
@ -199,6 +206,18 @@ int run_app_windows(
get_sandbox_account_interactive_token();
if (sandbox_account_interactive_token != NULL) {
// Find CreateEnvironmentBlock/DestroyEnvironmentBlock pointers
tCEB pCEB = NULL;
tDEB pDEB = NULL;
HMODULE hUserEnvLib = NULL;
hUserEnvLib = LoadLibrary("userenv.dll");
if (hUserEnvLib) {
pCEB = (tCEB) GetProcAddress(hUserEnvLib, "CreateEnvironmentBlock");
pDEB = (tDEB) GetProcAddress(hUserEnvLib, "DestroyEnvironmentBlock");
}
// Retrieve the current window station and desktop names
char szWindowStation[256];
memset(szWindowStation, 0, sizeof(szWindowStation));
@ -238,7 +257,7 @@ int run_app_windows(
// Construct an environment block that contains environment variables that don't
// describe the current user.
if (!CreateEnvironmentBlock(&environment_block, sandbox_account_interactive_token, FALSE)) {
if (!pCEB(&environment_block, sandbox_account_interactive_token, FALSE)) {
windows_error_string(error_msg, sizeof(error_msg));
fprintf(stderr, "CreateEnvironmentBlock failed: %s\n", error_msg);
}
@ -257,10 +276,16 @@ int run_app_windows(
&process_info
);
if (!DestroyEnvironmentBlock(environment_block)) {
if (!pDEB(environment_block)) {
windows_error_string(error_msg, sizeof(error_msg));
fprintf(stderr, "DestroyEnvironmentBlock failed: %s\n", error_msg);
}
if (hUserEnvLib) {
pCEB = NULL;
pDEB = NULL;
FreeLibrary(hUserEnvLib);
}
} else {
retval = CreateProcess(
file,

View File

@ -745,9 +745,23 @@ GetAccountSid(
// all the threads in the entire system,
// and find those belonging to the process (ugh!!)
//
// OpenThread
typedef HANDLE (WINAPI *tOT)(DWORD dwDesiredAccess, BOOL bInheritHandle, DWORD dwThreadId);
int suspend_or_resume_threads(DWORD pid, bool resume) {
HANDLE threads, thread;
HMODULE hKernel32Lib = NULL;
THREADENTRY32 te = {0};
tOT pOT = NULL;
// Dynamically link to the proper function pointers.
hKernel32Lib = GetModuleHandle("kernel32.dll");
pOT = (tOT) GetProcAddress( hKernel32Lib, "OpenThread" );
if (!pOT) {
return -1;
}
threads = CreateToolhelp32Snapshot(TH32CS_SNAPTHREAD, 0);
if (threads == INVALID_HANDLE_VALUE) return -1;
@ -757,13 +771,16 @@ int suspend_or_resume_threads(DWORD pid, bool resume) {
CloseHandle(threads);
return -1;
}
do {
if (te.th32OwnerProcessID == pid) {
thread = OpenThread(THREAD_SUSPEND_RESUME, FALSE, te.th32ThreadID);
thread = pOT(THREAD_SUSPEND_RESUME, FALSE, te.th32ThreadID);
resume ? ResumeThread(thread) : SuspendThread(thread);
CloseHandle(thread);
}
} while (Thread32Next(threads, &te));
CloseHandle (threads);
return 0;
}

View File

@ -85,7 +85,7 @@
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="zlib1d.lib ssleay32.lib libeay32.lib libcurld_imp.lib MSVCRTD.LIB MSVCPRTD.LIB wsock32.lib wininet.lib winmm.lib libboincd.lib sensapi.lib userenv.lib"
AdditionalDependencies="zlib1d.lib ssleay32.lib libeay32.lib libcurld_imp.lib MSVCRTD.LIB MSVCPRTD.LIB wsock32.lib wininet.lib winmm.lib libboincd.lib sensapi.lib"
OutputFile=".\Build\$(PlatformName)\$(ConfigurationName)\boinc.exe"
LinkIncremental="2"
SuppressStartupBanner="true"
@ -302,7 +302,7 @@
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="zlib1.lib ssleay32.lib libeay32.lib libcurl_imp.lib MSVCRT.LIB MSVCPRT.LIB wsock32.lib wininet.lib winmm.lib libboinc.lib sensapi.lib userenv.lib"
AdditionalDependencies="zlib1.lib ssleay32.lib libeay32.lib libcurl_imp.lib MSVCRT.LIB MSVCPRT.LIB wsock32.lib wininet.lib winmm.lib libboinc.lib sensapi.lib"
ShowProgress="0"
OutputFile=".\Build\$(PlatformName)\$(ConfigurationName)\boinc.exe"
LinkIncremental="1"
@ -523,7 +523,7 @@
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="zlib1.lib ssleay32.lib libeay32.lib libcurl_imp.lib MSVCRT.LIB MSVCPRT.LIB wsock32.lib wininet.lib winmm.lib libboinc.lib sensapi.lib userenv.lib"
AdditionalDependencies="zlib1.lib ssleay32.lib libeay32.lib libcurl_imp.lib MSVCRT.LIB MSVCPRT.LIB wsock32.lib wininet.lib winmm.lib libboinc.lib sensapi.lib"
ShowProgress="0"
OutputFile=".\Build\$(PlatformName)\$(ConfigurationName)\boinc.exe"
LinkIncremental="1"

View File

@ -73,7 +73,7 @@
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="MSVCRT.LIB MSVCPRT.LIB kernel32.lib user32.lib gdi32.lib ole32.lib oleacc.lib shell32.lib comdlg32.lib advapi32.lib oldnames.lib uuid.lib rpcrt4.lib comctl32.lib wsock32.lib wininet.lib userenv.lib wxbase28.lib wxbase28_net.lib wxbase28_xml.lib wxmsw28_adv.lib wxmsw28_core.lib wxmsw28_html.lib wxregex.lib wxexpat.lib wxpng.lib wxzlib.lib boinc_dll.lib"
AdditionalDependencies="MSVCRT.LIB MSVCPRT.LIB kernel32.lib user32.lib gdi32.lib ole32.lib oleacc.lib shell32.lib comdlg32.lib advapi32.lib oldnames.lib uuid.lib rpcrt4.lib comctl32.lib wsock32.lib wininet.lib wxbase28.lib wxbase28_net.lib wxbase28_xml.lib wxmsw28_adv.lib wxmsw28_core.lib wxmsw28_html.lib wxregex.lib wxexpat.lib wxpng.lib wxzlib.lib boinc_dll.lib"
OutputFile=".\Build\$(PlatformName)\$(ConfigurationName)\$(ProjectName).exe"
LinkIncremental="1"
AdditionalLibraryDirectories="&quot;$(OutDir)&quot;;&quot;$(WXWIN)\lib\vc_lib&quot;;&quot;$(WXWIN)\contrib\lib&quot;"
@ -268,7 +268,7 @@
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="MSVCRTD.LIB MSVCPRTD.LIB kernel32.lib user32.lib gdi32.lib ole32.lib oleacc.lib shell32.lib comdlg32.lib advapi32.lib oldnames.lib uuid.lib rpcrt4.lib comctl32.lib wsock32.lib wininet.lib userenv.lib wxbase28d.lib wxbase28d_net.lib wxbase28d_xml.lib wxmsw28d_adv.lib wxmsw28d_core.lib wxmsw28d_html.lib wxregexd.lib wxexpatd.lib wxpngd.lib wxzlibd.lib boinc_dll.lib"
AdditionalDependencies="MSVCRTD.LIB MSVCPRTD.LIB kernel32.lib user32.lib gdi32.lib ole32.lib oleacc.lib shell32.lib comdlg32.lib advapi32.lib oldnames.lib uuid.lib rpcrt4.lib comctl32.lib wsock32.lib wininet.lib wxbase28d.lib wxbase28d_net.lib wxbase28d_xml.lib wxmsw28d_adv.lib wxmsw28d_core.lib wxmsw28d_html.lib wxregexd.lib wxexpatd.lib wxpngd.lib wxzlibd.lib boinc_dll.lib"
OutputFile=".\Build\$(PlatformName)\$(ConfigurationName)\$(ProjectName).exe"
LinkIncremental="0"
AdditionalLibraryDirectories="&quot;$(OutDir)&quot;;&quot;$(WXWIN)\lib\vc_lib&quot;;&quot;$(WXWIN)\contrib\lib&quot;"
@ -457,7 +457,7 @@
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="MSVCRT.LIB MSVCPRT.LIB kernel32.lib user32.lib gdi32.lib ole32.lib oleacc.lib shell32.lib comdlg32.lib advapi32.lib oldnames.lib uuid.lib rpcrt4.lib comctl32.lib wsock32.lib wininet.lib userenv.lib wxbase26.lib wxbase26_net.lib wxbase26_xml.lib wxmsw26_adv.lib wxmsw26_core.lib wxmsw26_html.lib wxregex.lib wxexpat.lib wxpng.lib wxzlib.lib boinc_dll.lib"
AdditionalDependencies="MSVCRT.LIB MSVCPRT.LIB kernel32.lib user32.lib gdi32.lib ole32.lib oleacc.lib shell32.lib comdlg32.lib advapi32.lib oldnames.lib uuid.lib rpcrt4.lib comctl32.lib wsock32.lib wininet.lib wxbase26.lib wxbase26_net.lib wxbase26_xml.lib wxmsw26_adv.lib wxmsw26_core.lib wxmsw26_html.lib wxregex.lib wxexpat.lib wxpng.lib wxzlib.lib boinc_dll.lib"
OutputFile=".\Build\$(PlatformName)\$(ConfigurationName)\$(ProjectName).exe"
LinkIncremental="1"
AdditionalLibraryDirectories="&quot;$(OutDir)&quot;;&quot;$(WXWINPROD)\lib\vc_lib&quot;;&quot;$(WXWINPROD)\contrib\lib&quot;"