Kaynağa Gözat

合并到框架代码3.4版本

80374463 6 yıl önce
ebeveyn
işleme
f3e5e0fc17

+ 1 - 0
Common/SpBase.h

@@ -300,6 +300,7 @@ struct CSystemStaticInfo : public CInstallInfo
 	CVersion MachineVersion;
 	ScreenEnum eScreen;
 	CVersion LatterInstallVersion;				// 0 version for none
+	CSimpleStringA LatterInstallPack;
 	CAutoArray<CLightPackInfo> LightPackInfos;
 	WORD nTotalRunCount;
 	WORD nTodayRunCount;

+ 3 - 4
RVCComm/RVCComm.vcxproj

@@ -46,12 +46,11 @@
   <PropertyGroup Label="UserMacros" />
   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
     <LinkIncremental>false</LinkIncremental>
-    <OutDir>C:\Run\version\2.2.0.1\bin</OutDir>
   </PropertyGroup>
   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
     <LinkIncremental>true</LinkIncremental>
-    <LibraryPath>D:\工作\加密锁\1.9.3\LR04_ThirdParty_应用库\LR04_ThirdParty_Release\Release;$(LibraryPath)</LibraryPath>
-    <OutDir>C:\Run\version\2.2.0.1\bin</OutDir>
+    <LibraryPath>$(LibraryPath)</LibraryPath>
+    <OutDir>..\..\..\..\..\..\Run\version\3.1.0.0\bin</OutDir>
   </PropertyGroup>
   <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
     <ClCompile>
@@ -90,7 +89,7 @@
       <LinkDLL>true</LinkDLL>
       <SubSystem>Windows</SubSystem>
       <AdditionalDependencies>odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
-      <AdditionalLibraryDirectories>..\..\..\..\LR04_ThirdParty_应用库\LR04_ThirdParty_Release\Release;..\DeviceAdapter\ZH\DepLib</AdditionalLibraryDirectories>
+      <AdditionalLibraryDirectories>../../ThirdParty/openssl-1.0.1/lib/</AdditionalLibraryDirectories>
       <GenerateDebugInformation>false</GenerateDebugInformation>
     </Link>
   </ItemDefinitionGroup>

+ 1 - 1
libtoolkit/libtoolkit.vcxproj

@@ -76,7 +76,7 @@
   <PropertyGroup Label="UserMacros" />
   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
     <LinkIncremental>true</LinkIncremental>
-    <OutDir>C:\Run\version\2.2.0.1\bin</OutDir>
+    <OutDir>..\..\..\..\..\..\Run\version\3.1.0.0\bin</OutDir>
   </PropertyGroup>
   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
     <LinkIncremental>true</LinkIncremental>

+ 2 - 0
spbase/SpBase.cpp

@@ -112,6 +112,8 @@ SPBASE_API void LogError(const SeverityLevelEnum eLevel, ErrorCodeEnum dwSysErro
 	if (pModule) {
 		pModule->LogMessage(Log_Error, eLevel, dwSysErrorCode, dwUserErrorCode, pszMessage);
 	}
+	else
+		sp_dbg_info("LogError failed!can not find the module");
 
 	// write a copy in dbg log
 	sp_dbg_error("Error: {%s}(sc=0x%X, uc=0x%X)", pszMessage, dwSysErrorCode, dwUserErrorCode);

+ 2 - 3
spbase/SpBase.vcxproj

@@ -45,13 +45,12 @@
   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
     <LinkIncremental>true</LinkIncremental>
     <IntDir>$(SolutionDir)Temp\$(ProjectName)\</IntDir>
-    <LibraryPath>D:\工作\加密锁\1.9.3\LR04_ThirdParty_应用库\LR04_ThirdParty_Release\Release;D:\Run\version\1.9.4.0\bin;$(LibraryPath)</LibraryPath>
-    <OutDir>C:\Run\version\2.2.0.1\bin</OutDir>
+    <LibraryPath>$(LibraryPath)</LibraryPath>
+    <OutDir>..\..\..\..\..\..\Run\version\3.1.0.0\bin</OutDir>
   </PropertyGroup>
   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
     <IntDir>$(SolutionDir)Temp\$(ProjectName)\</IntDir>
     <LinkIncremental>false</LinkIncremental>
-    <OutDir>..\..\..\..\..\..\..\Run\version\1.9.4.0\bin</OutDir>
     <LibraryPath>D:\工作\加密锁\1.9.3\LR04_ThirdParty_应用库\LR04_ThirdParty_Release\Release;D:\Run\version\1.9.4.0\bin;$(LibraryPath)</LibraryPath>
   </PropertyGroup>
   <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">

+ 114 - 3
spbase/SpEntityPrivilege.cpp

@@ -1199,7 +1199,7 @@ ErrorCodeEnum SpEntityPrivilege::DeleteFileInNewVersion(const char *pszRelativeF
 ErrorCodeEnum SpEntityPrivilege::RollBackToPreviousVersion()
 {
 	auto env = sp_get_env();
-	auto cfg = env->cfg;	
+	auto cfg = env->cfg;
 
 	// 修改当前Install.ini配置
 	auto &v = cfg->install_ini->install_version;
@@ -1228,22 +1228,73 @@ ErrorCodeEnum SpEntityPrivilege::RollBackToPreviousVersion()
 	// 修改当前版本状态为倒回R
 	int nRet = inifile_write_str(cfg->install_ini_path, curVersion.ToString(), "InstallState", "R");
 
+	// 更新回退次数
+	auto nTotalRollbackCount = inifile_read_int(cfg->install_ini_path, curVersion.ToString(), "TotalRollbackCount", 0);
+	nTotalRollbackCount++;
+	nRet = inifile_write_int(cfg->install_ini_path, curVersion.ToString(), "TotalRollbackCount", nTotalRollbackCount);
+	if (-1 == nRet)
+	{
+		LogError(Severity_Low, Error_Unexpect, 0, "inifile_write_int TotalRollbackCount");
+	}
+	LOG_TRACE("inifile_write_int, nTotalRollbackCount[%d]", nTotalRollbackCount);
+
 	// 修改active.txt文件
 	CSimpleStringA strActiveFile = CSimpleStringA::Format("%s\\active.txt", env->dir->root_ver_path);
 	HANDLE hFile = ::CreateFileA(strActiveFile, GENERIC_WRITE, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
 	BOOL bSetSucc = FALSE;
-	if (hFile == INVALID_HANDLE_VALUE) 
+	if (hFile == INVALID_HANDLE_VALUE)
 	{
 		LogError(Severity_Low, Error_Unexpect, 0, "open active.txt fail");
 		return Error_Unexpect;
 	}
-	
+
 	DWORD dwWrittenLen(0);
 	bSetSucc = WriteFile(hFile, (const char*)strPrevVersion, strPrevVersion.GetLength(), &dwWrittenLen, NULL);
 	FlushFileBuffers(hFile);
 	SetEndOfFile(hFile);
 	CloseHandle(hFile);
 	LOG_TRACE("set rollback to previous version [%s] succeed", (const char*)strPrevVersion);
+
+	//出现active文件为空的问题,此处增加写文件件后再读一次,确认是否写成功,以此来确认是否是写文件导致
+	if (1)
+	{
+		hFile = ::CreateFileA(strActiveFile, GENERIC_ALL, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
+		if (hFile == INVALID_HANDLE_VALUE)
+		{
+			LogError(Severity_Low, Error_Unexpect, 0, "open active.txt fail");
+			return Error_Unexpect;
+		}
+
+		DWORD dwReadLen(0);
+		char cVer[16] = { 0 };
+
+		if (ReadFile(hFile, cVer, 16, &dwReadLen, NULL))
+		{
+			LOG_TRACE("read active.txt, version len[%d], version[%s]", dwReadLen, cVer);
+
+			//如果为空,则重写
+			if (strlen(cVer) == 0)
+			{
+				if (WriteFile(hFile, (const char*)strPrevVersion, strPrevVersion.GetLength(), &dwWrittenLen, NULL))
+				{
+					LOG_TRACE("rewrite active.txt success, strPrevVersion[%s]", strPrevVersion);
+				}
+				else
+				{
+					LogError(Severity_Low, Error_Unexpect, 0, "rewrite active.txt fail");
+				}
+			}
+		}
+		else
+		{
+			LogError(Severity_Low, Error_Unexpect, 0, "Read active.txt fail");
+		}
+
+		FlushFileBuffers(hFile);
+		SetEndOfFile(hFile);
+		CloseHandle(hFile);
+	}
+	
 	return bSetSucc ? Error_Succeed : Error_Unexpect;
 }
 
@@ -1283,6 +1334,16 @@ ErrorCodeEnum SpEntityPrivilege::RollBackToHistoryVersion(CVersion historyVersio
 	// 修改当前版本状态为倒回R
 	int nRet = inifile_write_str(cfg->install_ini_path, curVersion.ToString(), "InstallState", "R");
 
+	// 更新回退次数
+	auto nTotalRollbackCount = inifile_read_int(cfg->install_ini_path, curVersion.ToString(), "TotalRollbackCount", 0);
+	nTotalRollbackCount++;
+	nRet = inifile_write_int(cfg->install_ini_path, curVersion.ToString(), "TotalRollbackCount", nTotalRollbackCount);
+	if (-1 == nRet)
+	{
+		LogError(Severity_Low, Error_Unexpect, 0, "inifile_write_int TotalRollbackCount");
+	}
+	LOG_TRACE("inifile_write_int, nTotalRollbackCount[%d]", nTotalRollbackCount);
+
 	// 修改active.txt文件
 	CSimpleStringA strActiveFile = CSimpleStringA::Format("%s\\active.txt", env->dir->root_ver_path);
 	HANDLE hFile = ::CreateFileA(strActiveFile, GENERIC_WRITE, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
@@ -1298,6 +1359,31 @@ ErrorCodeEnum SpEntityPrivilege::RollBackToHistoryVersion(CVersion historyVersio
 	FlushFileBuffers(hFile);
 	SetEndOfFile(hFile);
 	CloseHandle(hFile);
+
+	//出现active文件为空的问题,此处增加写文件件后再读一次,确认是否写成功,以此来确认是否是写文件导致
+	if (1)
+	{
+		hFile = ::CreateFileA(strActiveFile, GENERIC_WRITE, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
+		if (hFile == INVALID_HANDLE_VALUE) 
+		{
+			LogError(Severity_Low, Error_Unexpect, 0, "open active.txt fail");
+			return Error_Unexpect;
+		}
+
+		DWORD dwReadLen(0);
+		char cVer[16] = {0};
+
+		if (ReadFile(hFile,cVer,16,&dwReadLen,NULL))
+		{
+			LOG_TRACE("read active.txt, version len[%d], version[%s]", dwReadLen, cVer);
+		}
+		else
+		{
+			LogError(Severity_Low, Error_Unexpect, 0, "Read active.txt fail");
+		}
+
+		CloseHandle(hFile);
+	}
 	LOG_TRACE("set rollback to history version [%s] succeed", (const char*)strHisVersion);
 	return bSetSucc ? Error_Succeed : Error_Unexpect;
 }
@@ -1344,6 +1430,7 @@ ErrorCodeEnum SpEntityPrivilege::UpgradeToNewVersion(bool bToSysInstall)
 		FlushFileBuffers(hFile);
 		SetEndOfFile(hFile);
 		CloseHandle(hFile);
+		LOG_TRACE("WriteFile [%s] to active.txt", (const char*)strNewVer);
 	}
 	else
 	{
@@ -1351,6 +1438,30 @@ ErrorCodeEnum SpEntityPrivilege::UpgradeToNewVersion(bool bToSysInstall)
 		LogError(Severity_Low, Error_Unexpect, 0, "open active.txt fail");
 	}
 
+	//出现active文件为空的问题,此处增加写文件件后再读一次,确认是否写成功,以此来确认是否是写文件导致
+	if (1)
+	{
+		hFile = ::CreateFileA(strActiveFile, GENERIC_WRITE, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
+		if (hFile == INVALID_HANDLE_VALUE) 
+		{
+			LogError(Severity_Low, Error_Unexpect, 0, "open active.txt fail");
+			return Error_Unexpect;
+		}
+
+		DWORD dwReadLen(0);
+		char cVer[16] = {0};
+
+		if (ReadFile(hFile,cVer,16,&dwReadLen,NULL))
+		{
+			LOG_TRACE("read active.txt, version len[%d], version[%s]", dwReadLen, cVer);
+		}
+		else
+		{
+			LogError(Severity_Low, Error_Unexpect, 0, "Read active.txt fail");
+		}
+		CloseHandle(hFile);
+	}
+
 	// 修改内存配置
 	if (bSetSucc)
 	{

+ 1 - 0
spbase/sp_cfg.h

@@ -77,6 +77,7 @@ typedef struct sp_cfg_install_ini_t {
 	y2k_time_t install_time;
 	y2k_time_t current_startup_time;
 	sp_version_t latter_install_version;
+	char *latter_install_pack;
 	array_header_t *arr_light_pack;
 	char *light_packs;
 	array_header_t *arr_version;		// array of sp_cfg_version_info_t

+ 8 - 1
spbase/sp_gui.cpp

@@ -30,6 +30,8 @@ using namespace std;
 #define FONT_SMALL_SIZE		20 // show message in a big font
 #define FONT_LARGE_SIZE		48 // show message in a big font
 
+int g_guiShowFirst = 1;
+
 struct sp_gui_t
 {
 	HINSTANCE hInst;
@@ -162,7 +164,7 @@ static int init(sp_gui_t *gui)
 
 	RegisterTouchWindow(gui->hWnd, 0);				// support WM_TOUCH
 
-	ShowWindow(gui->hWnd, SW_SHOW);
+	ShowWindow(gui->hWnd, g_guiShowFirst ? SW_SHOW : SW_HIDE);
 	UpdateWindow(gui->hWnd);
 
 	//BringWindowToTop(gui->hWnd);
@@ -771,6 +773,11 @@ static LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lPara
 	return 0;
 }
 
+void sp_gui_setShow(int isShowFirst)
+{
+	g_guiShowFirst = isShowFirst;
+}
+
 int sp_gui_create(sp_gui_t **p_gui)
 {
 	sp_gui_t *gui = ZALLOC_T(sp_gui_t);

+ 4 - 1
spbase/sp_gui.h

@@ -3,6 +3,7 @@
 
 #pragma once
 
+
 #ifdef __cplusplus
 extern "C" 
 {
@@ -10,7 +11,9 @@ extern "C"
 
 typedef struct sp_gui_t sp_gui_t;
 
-SPBASE_API int sp_gui_create(sp_gui_t **p_gui);			//spshell.exe????????¨¤?????
+
+SPBASE_API int sp_gui_create(sp_gui_t **p_gui);	
+SPBASE_API void sp_gui_setShow(int isShowFirst);
 SPBASE_API void sp_gui_destroy(sp_gui_t *gui);
 
 // type: 0 normal msg; 1 bluescreen; 2 fatal error

+ 5 - 0
spbase/sp_log.c

@@ -94,10 +94,15 @@ int sp_log_client_logv(sp_log_client_t *client, int type, int severity, int sys_
 
 	n = format ? _vscprintf(format, arg) : 0;
 	if (n < 0 || n > SP_LOG_MAX_LEN)
+	{
+		sp_dbg_info("client log len is not right, %d", n);
 		return Error_Param;
+	}
+		
 
 	ent = sp_mod_mgr_find_entity_by_idx(env->mod_mgr, client->local_svc_id);
 	if (!ent) {
+		sp_dbg_info("client log sp_mod_mgr_find_entity_by_idx failed");
 		return Error_Param;
 	}
 

+ 3 - 3
sphost/SpHost.vcxproj

@@ -45,8 +45,8 @@
   <PropertyGroup Label="UserMacros" />
   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
     <LinkIncremental>true</LinkIncremental>
-    <OutDir>C:\Run\version\2.2.0.1\bin</OutDir>
-    <LibraryPath>D:\Run\version\1.9.4.0\bin;$(LibraryPath)</LibraryPath>
+    <OutDir>..\..\..\..\..\..\Run\version\3.1.0.0\bin</OutDir>
+    <LibraryPath>$(LibraryPath)</LibraryPath>
   </PropertyGroup>
   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
     <LinkIncremental>false</LinkIncremental>
@@ -64,7 +64,7 @@
       <SubSystem>Windows</SubSystem>
       <GenerateDebugInformation>true</GenerateDebugInformation>
       <AdditionalDependencies>libtoolkit.lib;spbase.lib;%(AdditionalDependencies)</AdditionalDependencies>
-      <AdditionalLibraryDirectories>C:\Run\version\2.2.0.1\bin;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
+      <AdditionalLibraryDirectories>..\..\..\..\..\..\Run\version\3.1.0.0\bin;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
     </Link>
   </ItemDefinitionGroup>
   <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">

+ 16 - 9
sphost/sphost.c

@@ -71,18 +71,25 @@ static void SetEnvPath(const char *mod_name)
 DWORD sphostMonitor(LPVOID param)
 {
 	HANDLE spShellProcess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, GetProcessIdFromName(PROCESS_SPSHELL));
+	int waitTimes = 1;
 	if (NULL == spShellProcess)
 		ExitProcess(-1);	//can not find spShell
-	while (WAIT_TIMEOUT == WaitForSingleObject(spShellProcess, DEFAULT_MEMORY_CLEAN_TIME * 1000))	//spshell exit
+	
+	while (WAIT_TIMEOUT == WaitForSingleObject(spShellProcess, 1000))	//spshell exit
 	{
-		DWORD memoryInfo = 0, handleInfo = 0;
-		getCurrentMemoryInfo(&memoryInfo);
-		getHandleNum(&handleInfo);
-		Dbg("进程%d,当前内存占用为:\t%dK, 句柄数:\t%d", GetCurrentProcessId(), memoryInfo / 1000, handleInfo);
-		cleanMemory();
-		Sleep(10000);
-		getCurrentMemoryInfo(&memoryInfo);
-		Dbg("进程%d, 释放内存, 当前占用为:\t%dK", GetCurrentProcessId(), memoryInfo / 1000);
+		
+		if (waitTimes % DEFAULT_MEMORY_CLEAN_TIME == 0)
+		{
+			DWORD memoryInfo = 0, handleInfo = 0;
+			getCurrentMemoryInfo(&memoryInfo);
+			getHandleNum(&handleInfo);
+			Dbg("进程%d,当前内存占用为:\t%dK, 句柄数:\t%d", GetCurrentProcessId(), memoryInfo / 1000, handleInfo);
+			cleanMemory();
+			Sleep(10000);
+			getCurrentMemoryInfo(&memoryInfo);
+			Dbg("进程%d, 释放内存, 当前占用为:\t%dK", GetCurrentProcessId(), memoryInfo / 1000);
+		}
+		waitTimes++;
 	}
 	CloseHandle(spShellProcess);
 	ExitProcess(0);

+ 3 - 3
spshell/SpShell.vcxproj

@@ -45,8 +45,8 @@
   <PropertyGroup Label="UserMacros" />
   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
     <LinkIncremental>true</LinkIncremental>
-    <OutDir>C:\Run\version\2.2.0.1\bin</OutDir>
-    <LibraryPath>D:\Run\version\1.9.4.0\bin;D:\工作\加密锁\1.9.3\LR04_ThirdParty_应用库\LR04_ThirdParty_Release\Release;$(LibraryPath)</LibraryPath>
+    <OutDir>..\..\..\..\..\..\Run\version\3.1.0.0\bin</OutDir>
+    <LibraryPath>$(LibraryPath)</LibraryPath>
   </PropertyGroup>
   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
     <LinkIncremental>false</LinkIncremental>
@@ -64,7 +64,7 @@
       <SubSystem>Windows</SubSystem>
       <GenerateDebugInformation>true</GenerateDebugInformation>
       <AdditionalDependencies>ws2_32.lib;libtoolkit.lib;spbase.lib;%(AdditionalDependencies)</AdditionalDependencies>
-      <AdditionalLibraryDirectories>C:\Run\version\2.2.0.1\bin;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
+      <AdditionalLibraryDirectories>..\..\..\..\..\..\Run\version\3.1.0.0\bin;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
     </Link>
   </ItemDefinitionGroup>
   <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">

+ 1 - 0
spshell/SpShellConsole.cpp

@@ -265,6 +265,7 @@ void CSpShellConsole::OutputLog(int nLogEntityID, const char *pLogEntity, const
 
 		if ((((UINT64)0x1) << (nLogEntityID % 64)) &  nFlag)
 			AsyncSend(nConnectionID, (char*)(const char*)strMsg, strMsg.GetLength());
+			
 	}
 }
 

+ 23 - 8
spshell/app.cpp

@@ -179,15 +179,8 @@ int app_init()
 	sp_rpc_server_callback callback;
 		
 	memset(&g_app, 0, sizeof(g_app));
-	rc = sp_gui_create(&g_app.bsc_gui);			//创建窗口和消息循环机制
-	if (rc != 0) {
-		sp_dbg_error("app shell gui init failed!");
-		return rc;
-	}
 
-	sp_gui_display(g_app.bsc_gui);			//显示在任务栏
-	sp_dbg_set_output_gui(g_app.bsc_gui);
-	sp_dbg_info("app shell gui init ok!");
+
 
 
 	if (winsock_init() != 0)
@@ -210,6 +203,28 @@ int app_init()
 		return rc;
 	}
 	sp_dbg_info("create env ok!");
+
+	bool isEqual = !strcmp(env->cfg->root_ini->machine_type, "RVC.IL");
+	sp_gui_setShow(isEqual ? 0 : 1);
+	rc = sp_gui_create(&g_app.bsc_gui);			//创建窗口和消息循环机制
+	if (rc != 0) {
+		sp_dbg_error("app shell gui init failed!");
+		return rc;
+	}
+
+	if (isEqual)
+	{
+		sp_dbg_info("machine_type is RVC.IL, undisplay the logGui");
+		sp_gui_undisplay(g_app.bsc_gui);
+	}
+	else
+	{
+		sp_dbg_info("machine_type is %s, display the logGui", env->cfg->root_ini->machine_type);
+		sp_gui_display(g_app.bsc_gui);			//显示在任务栏
+	}
+		
+	sp_dbg_set_output_gui(g_app.bsc_gui);
+	sp_dbg_info("app shell gui init ok!");
 	env->gui = g_app.bsc_gui;
 
 	// log current version info

+ 10 - 0
spshell/spshell.cpp

@@ -284,6 +284,7 @@ bool  IsProcessRunAsAdmin()
 	PSID AdministratorsGroup = NULL;
 
 	BOOL bAdmin = FALSE;
+	sp_dbg_info("start AllocateAndInitializeSid");
 	if (AllocateAndInitializeSid(
 		&NtAuthority,
 		2,
@@ -292,7 +293,10 @@ bool  IsProcessRunAsAdmin()
 		0, 0, 0, 0, 0, 0,
 		&AdministratorsGroup))
 	{
+		sp_dbg_info("start CheckTokenMembership");
 		CheckTokenMembership(NULL, AdministratorsGroup, &bAdmin);
+
+		sp_dbg_info("start FreeSid");
 		FreeSid(AdministratorsGroup);
 	}
 
@@ -420,13 +424,17 @@ static bool SpTerminateProcess(HANDLE hProc, DWORD dwProcID)
 
 static bool DetectDuplicateInstance(char **pNames, int nNum)
 {
+	sp_dbg_info("start GetCurrentProcessId");
 	DWORD dwCurProcID = GetCurrentProcessId();
+
+	sp_dbg_info("start CreateToolhelp32Snapshot");
 	HANDLE hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
 
 	if (hSnapshot)
 	{
 		PROCESSENTRY32 pe = {};
 		pe.dwSize = sizeof(pe);
+		sp_dbg_info("start Process32First");
 		if (Process32First(hSnapshot, &pe))
 		{
 			do
@@ -435,6 +443,7 @@ static bool DetectDuplicateInstance(char **pNames, int nNum)
 				{
 					if (stricmp(&pe.szExeFile[0], pNames[i]) == 0 && pe.th32ProcessID != dwCurProcID)
 					{
+						sp_dbg_info("start OpenProcess");
 						HANDLE hProc = OpenProcess(PROCESS_ALL_ACCESS, FALSE, pe.th32ProcessID);
 						if (hProc == NULL)
 						{
@@ -635,6 +644,7 @@ static bool UnloadInterceptDllDriver(char* szSvrName)
 	SERVICE_STATUS SvrSta;
 
 	// ´ò¿ªSCM¹ÜÀíÆ÷
+	sp_dbg_info("start OpenSCManager");
 	hServiceMgr = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS); 
 	if( hServiceMgr == NULL ) 
 	{

+ 27 - 7
spshell/svc.cpp

@@ -102,6 +102,22 @@ static BOOL RestartWindows()
 	return TRUE;
 }
 
+DWORD getExePath(char *exePath)
+{
+	char pathbuf[MAX_PATH] = "";
+	int  pathlen = ::GetModuleFileName(NULL, pathbuf, MAX_PATH);
+
+	// 替换掉单杠
+	while (pathlen > 0)
+	{
+		if (pathbuf[pathlen--] == '\\')
+			break;
+	}
+	pathbuf[++pathlen] = '\0';
+	sprintf(exePath, "%s", pathbuf);
+	return strlen(exePath);
+}
+
 int KickoffSpRestart(bool bRestart)
 {
 	STARTUPINFO si;
@@ -115,15 +131,19 @@ int KickoffSpRestart(bool bRestart)
 	//CreateProcess(NULL, szCmdline, /*...*/);
 
 	// Start the child process.
+	char exepath[MAX_PATH] = "";
+	getExePath(exepath);
+
 	CSimpleStringA csRestart, csVerPath, csAll, csSep("\""), csBlank(" "), csScript("wscript.exe"), csReFlag("r");
-	csRestart = "sprestart.exe ";
+	csRestart = CSimpleStringA(exepath) + "\\sprestart.exe";
 
 	sp_env_t *env = sp_get_env();
 	csVerPath = env->dir->root_ver_path;
 	csVerPath += "\\spexplorerfast.vbs";
 	if (!bRestart)
 		csReFlag = "n";
-	csAll = csSep + csRestart + csSep + csBlank + csSep + csScript + csBlank + csVerPath + csSep
+	
+	csAll = csRestart + csBlank + csSep + csScript + csBlank + csVerPath + csSep
 		+ csBlank + csSep + csReFlag + csSep;
 	Dbg("allpath[%s]", (LPCTSTR)csAll);
 	LPTSTR szCmdline = _strdup(csAll);
@@ -133,9 +153,8 @@ int KickoffSpRestart(bool bRestart)
 		return -1;
 	}
 	
+	Dbg("CreateProcess Success PID:%d.\n", pi.dwProcessId);
 	DWORD dwErr = GetLastError();
-	// Wait until child process exits.
-	WaitForSingleObject(pi.hProcess, INFINITE);
 
 	// Close process and thread handles. 
 	CloseHandle(pi.hProcess);
@@ -159,9 +178,8 @@ void on_machine_reboot(sp_rpc_server_t *server, int epid, int svc_id, int call_t
 
 	RebootWayEnum eRebootWay = (RebootWayEnum)way;
 	
-	Dbg("spshell exit now");
-	app_t *app = get_app_instance();
-	sp_iom_post_quit(app->iom);
+
+
 
 	// 只处理框架重启及操作系统重启,电源重启由健康实体处理
 	if (eRebootWay == RebootWay_Framework)
@@ -174,6 +192,8 @@ void on_machine_reboot(sp_rpc_server_t *server, int epid, int svc_id, int call_t
 		Dbg("reboot windows now");
 		RestartWindows();
 	}
+	app_t *app = get_app_instance();
+	sp_iom_post_quit(app->iom);
 }
 
 void on_entity_quit(sp_rpc_server_t *server, int epid, int svc_id, int call_type, iobuffer_t **info_pkt)