Эх сурвалжийг харах

Z991239-6413 #comment 重定向操作迁移

80374374 1 сар өмнө
parent
commit
c051ebee88

+ 0 - 1
Framework/Common/SpSecureClient.h

@@ -75,7 +75,6 @@ private:
 
 	bool findConnectInfo(const char *pEntityName, ENTITY_CONNECT_INFO *connectInfo);
 	bool readConnectInfoFromCentralSetting(const char *pEntityName, ENTITY_CONNECT_INFO *connectInfo);
-	bool readConnectInfoFromConfig(const char *pEntityName, ENTITY_CONNECT_INFO *connectInfo);
 	bool setConnectInfo(const ENTITY_CONNECT_INFO *connectInfo);
 	void connectClose(const char *pEntityName);
 

+ 57 - 2
Framework/libtoolkit/osutil.c

@@ -4,8 +4,6 @@
 #include "strutil.h"
 #include "toolkit.h"
 
-//#define NEW_FEATURE
-
 #ifdef _WIN32
 
 #include <TlHelp32.h>
@@ -126,6 +124,44 @@ TOOLKIT_API int osutil_uname(tk_utsname_t* buffer)
 	return TOOLKIT_UNKNOWN;
 }
 
+
+TOOLKIT_API int osutil_is32r64_platform()
+{
+	int isWow64 = -1;
+	typedef BOOL(WINAPI* LPFN_ISWOW64PROCESS)(HANDLE, PBOOL);
+	BOOL bIsWow64 = FALSE;
+	LPFN_ISWOW64PROCESS fnIsWow64Process = (LPFN_ISWOW64PROCESS)GetProcAddress(GetModuleHandle("kernel32"), "IsWow64Process");
+	if (NULL != fnIsWow64Process) {
+		if (!fnIsWow64Process(GetCurrentProcess(), &bIsWow64)) {
+			return -1;
+		}
+		else {
+			isWow64 = bIsWow64 ? 1 : 0;
+		}
+	}
+	return isWow64;
+}
+
+
+TOOLKIT_API ostuile_void_ptr osutil_sure_redirect_32sys_in_wow64()
+{
+    ostuile_void_ptr value = NULL;
+    if (osutil_is32r64_platform() == 1) {
+        if (!Wow64DisableWow64FsRedirection(&value)) {
+            value = NULL;
+        }
+    }
+    return value;
+}
+
+TOOLKIT_API void osutil_reset_redirect_32sys_in_wow64(ostuile_void_ptr* value)
+{
+    if (value != NULL && (*value) != NULL) {
+        Wow64RevertWow64FsRedirection(*value);
+    }
+    return;
+}
+
 #else
 
 #include <unistd.h>
@@ -470,6 +506,23 @@ error:
 	return r;
 }
 
+TOOLKIT_API int osutil_is32r64_platform()
+{
+    return 0;
+}
+
+TOOLKIT_API ostuile_void_ptr osutil_sure_redirect_32sys_in_wow64()
+{
+    ostuile_void_ptr value = NULL;
+    return value;
+}
+
+
+TOOLKIT_API void osutil_reset_redirect_32sys_in_wow64(ostuile_void_ptr* value)
+{
+    return;
+}
+
 #endif
 
 TOOLKIT_API int osutil_shutdown_system()
@@ -481,3 +534,5 @@ TOOLKIT_API int osutil_shutdown_system()
 
 
 
+
+

+ 10 - 1
Framework/libtoolkit/osutil.h

@@ -13,6 +13,8 @@
 
 #include "config.h"
 
+typedef void* ostuile_void_ptr;
+
 #ifdef __cplusplus
 extern "C" {
 #endif
@@ -50,7 +52,14 @@ TOOLKIT_API void osutil_terminate_related_process(char** process_array, const in
 
 TOOLKIT_API int osutil_uname(tk_utsname_t* buffer);
 
-
+/*
+* -1:failed
+* 0:no
+* 1:yes
+*/
+TOOLKIT_API int osutil_is32r64_platform();
+TOOLKIT_API ostuile_void_ptr osutil_sure_redirect_32sys_in_wow64();
+TOOLKIT_API void osutil_reset_redirect_32sys_in_wow64(ostuile_void_ptr* value);
 #ifdef __cplusplus
 } // extern "C" {
 #endif

+ 0 - 61
Framework/libtoolkit/synch.c

@@ -1,61 +0,0 @@
-#include "synch.h"
-/*
-
-#include "memutil.h"
-
-TOOLKIT_API int toolkit_mutex_create(toolkit_mutex_t** p_mutex)
-{
-	toolkit_mutex_t* mutex;
-	mutex = MALLOC_T(toolkit_mutex_t);
-	*p_mutex = mutex;
-	return 0;
-}
-
-TOOLKIT_API int toolkit_mutex_init(toolkit_mutex_t* mutex)
-{
-#ifdef _WIN32
-	InitializeCriticalSection(mutex);
-#else
-#endif
-	FREE(mutex);
-	return 0;
-}
-
-TOOLKIT_API void toolkit_mutex_destroy(toolkit_mutex_t* mutex)
-{
-#ifdef _WIN32
-	DeleteCriticalSection(mutex);
-#else
-#endif
-}
-
-TOOLKIT_API void toolkit_mutex_lock(toolkit_mutex_t* mutex)
-{
-#ifdef _WIN32
-	EnterCriticalSection(mutex);
-#else
-#endif
-}
-
-TOOLKIT_API int toolkit_mutex_trylock(toolkit_mutex_t* mutex)
-{
-#ifdef _WIN32
-	if(TryEnterCriticalSection(mutex))
-	{
-		return 0;
-	}
-	return -1;
-#else
-#endif
-	return 0;
-}
-
-TOOLKIT_API void toolkit_mutex_unlock(toolkit_mutex_t* mutex)
-{
-#ifdef _WIN32
-	LeaveCriticalSection(mutex);
-#else
-#endif
-}
-
-*/

+ 0 - 25
Framework/libtoolkit/synch.h

@@ -1,25 +0,0 @@
-#ifndef TOOLKIT_SYNCH_H
-#define TOOLKIT_SYNCH_H
-
-#include "config.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-	
-	//TOOLKIT_API int toolkit_mutex_create(toolkit_mutex_t** p_mutex);
-	//TOOLKIT_API int toolkit_mutex_init(toolkit_mutex_t* mutex);
-	//TOOLKIT_API void toolkit_mutex_destroy(toolkit_mutex_t* mutex);
-
-	//TOOLKIT_API void toolkit_mutex_lock(toolkit_mutex_t* mutex);
-	//TOOLKIT_API int toolkit_mutex_trylock(toolkit_mutex_t* mutex);
-	//TOOLKIT_API void toolkit_mutex_unlock(toolkit_mutex_t* mutex);
-
-
-#ifdef __cplusplus
-}
-#endif
-
-
-#endif //TOOLKIT_SYNCH_H

+ 0 - 7
Framework/libtoolkit/test/test_synch.cpp

@@ -1,7 +0,0 @@
-#include "synch.h"
-#include <gtest/gtest.h>
-
-TEST(SynchronizeObjectTest, MutexTest) {
-	
-	
-}

+ 0 - 2
Framework/libtoolkit/toolkit.h

@@ -293,6 +293,4 @@ extern "C" {
 } // extern "C" {
 #endif
 
-#include "winfit.h"
-
 #endif //__TOOLKIT_GLOBAL_H__

+ 0 - 2
Framework/libtoolkit/win/bus.c

@@ -513,7 +513,6 @@ TOOLKIT_API int bus_endpt_create(const char* url, int epid, const bus_endpt_call
 		goto on_error;
 	rc = recv_pkt_raw(endpt, &ans_buf);
 	if (rc != 0) {
-		DWORD dwError = GetLastError();
 		goto on_error;
 	}
 	iobuffer_read(ans_buf, IOBUF_T_I4, &v, 0);
@@ -731,7 +730,6 @@ static int recv_until(bus_endpt_t* endpt, int type, iobuffer_t** p_ansbuf)
 		if (!endpt->rx_pending) {
 			rc = start_read_pkt(endpt, &ans_pkt);
 			if (rc < 0) {
-				DWORD dwError = WSAGetLastError();
 				break;
 			}
 		}

+ 0 - 3
Framework/libtoolkit/win/ioqueue.c

@@ -391,8 +391,6 @@ static void dispatch_acceptor(int err,
 							  ioqueue_acceptor_t *acceptor, 
 							  ioqueue_accept_overlapped_t *overlapped)
 {
-	ioqueue_t *ioq = acceptor->owner;
-
 	if (err == 0) {
 		/* only valid for winxp or later, ignore return value */
 		setsockopt(overlapped->client, SOL_SOCKET, SO_UPDATE_ACCEPT_CONTEXT, 
@@ -415,7 +413,6 @@ static void dispatch_pipe_acceptor(int err,
 								   ioqueue_pipe_acceptor_t *acceptor, 
 								   ioqueue_connectpipe_overlapped_t *overlapped)
 {
-	ioqueue_t *ioq = acceptor->owner;
 	int accepted;
 
 	CloseHandle(overlapped->hevt);

+ 0 - 13
Framework/libtoolkit/winfit.h

@@ -1,13 +0,0 @@
-#ifndef _TOOLKIT_WIN_FIT_H_
-#define _TOOLKIT_WIN_FIT_H_
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-
-#ifdef __cplusplus
-} // extern "C" {
-#endif
-
-#endif // !_TOOLKIT_WIN_FIT_H_

+ 1 - 2
Framework/spbase/SpBase.cpp

@@ -111,7 +111,7 @@ static LONG WINAPI SuppressError(struct _EXCEPTION_POINTERS* ExceptionInfo)
 
 		MINIDUMP_TYPE mdt       = MiniDumpWithIndirectlyReferencedMemory; 
 
-		BOOL rv = MiniDumpWriteDump( GetCurrentProcess(), GetCurrentProcessId(), 
+		MiniDumpWriteDump( GetCurrentProcess(), GetCurrentProcessId(), 
 			hDumpFile, mdt, (ExceptionInfo != 0) ? &mdei : 0, 0, 0 ); 
 		CloseHandle( hDumpFile );
 	}
@@ -559,7 +559,6 @@ extern "C" SPBASE_API int __stdcall SpRun(const char *mod_name, int epid, int ra
 #endif //RVC_OS_WIN
 
 	void* hint_addr = NULL;
-	HMODULE hModule = NULL;
 	sp_env_t* env = NULL;
 	sp_mod_t* mod = NULL;
 	sp_cfg_shell_module_t* cfg_mod = NULL;

+ 0 - 67
Framework/spbase/SpSecureClient.cpp

@@ -167,72 +167,6 @@ bool SpSecureClient::Connect(const char *pServerAddr, int nPort, int nOption) //
 	return result;
 }
 
-bool SpSecureClient::readConnectInfoFromConfig(const char *pEntityName, ENTITY_CONNECT_INFO *connectInfo)
-{
-	if (NULL == pEntityName || NULL == connectInfo)
-		return false;
-
-	connectControl *entityConnect = connectControl::getInstance();
-	bool readSuccess = entityConnect->getEntityInfo(pEntityName, connectInfo);
-
-	auto pFunc = m_pEntity->GetFunction();
-	CSmartPointer<IConfigInfo> spConfig;
-	if (Error_Succeed != pFunc->OpenConfig(Config_CenterSetting, spConfig))
-	{
-		//DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("open center setting config fail");
-		return false;
-	}
-
-	CSimpleStringA str;
-	int readEach = 0;
-	if (Error_Succeed == spConfig->ReadConfigValue("SpBase", "ReadEach", str) && !str.IsNullOrEmpty())
-		readEach = atoi(str);
-	if (0 == readEach && readSuccess)
-		return true;//不是每次都读取新的Entity的IP和Port,只在实体启动时读取一次
-
-	int dualActive = -1;
-	if (Error_Succeed == spConfig->ReadConfigValue("SpBase", "DualActive", str) && !str.IsNullOrEmpty())
-		dualActive = atoi(str);
-
-
-	if (Error_Succeed != pFunc->OpenConfig(Config_Software, spConfig))
-	{
-		//DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("open entity config fail");
-		return false;
-	}
-
-	if (Error_Succeed != spConfig->ReadConfigValue("Main", "Server", str) || str.IsNullOrEmpty())
-	{
-		//DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("read Main::Server config fail");
-		return false;
-	}
-
-	CSimpleStringA strServer1;
-	int nServer1Port;
-	if (Error_Succeed != ParseIPAddress(str, strServer1, nServer1Port))
-	{
-		//DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("parse ip addr fail: %s", (const char*)str);
-		return false;
-	}
-
-	CSimpleStringA strServer2;
-	int nServer2Port = 0;
-	if (Error_Succeed == spConfig->ReadConfigValue("Main", "Server_Backup", str) && !str.IsNullOrEmpty())
-		ParseIPAddress(str, strServer2, nServer2Port);
-
-
-	if (readSuccess)
-		connectInfo->setParam(pEntityName, strServer1.GetData(), nServer1Port, strServer2.GetData(), nServer2Port, dualActive, connectInfo->m_currentLink);
-	else
-	{
-		connectInfo->clear();
-		connectInfo->setParam(pEntityName, strServer1.GetData(), nServer1Port, strServer2.GetData(), nServer2Port, dualActive);
-	}
-	entityConnect->setEntityInfo(connectInfo);
-
-	return true;
-}
-
 void SpSecureClient::connectClose(const char *pEntityName)
 {
 	if (NULL == pEntityName)
@@ -739,7 +673,6 @@ bool SpSecureClient::OnAuthRequestSM(CConnAuthSMReq* pReq)
 	if(pReq != NULL)
 	{
 		// call token service to encrypt verify info
-		int nDestLen = sizeof(pReq->m_arrVerifyInfo);
 		TokenService_ClientBase* client = new TokenService_ClientBase(m_pEntity);
 
 		Error = client->Connect();

+ 0 - 1
Framework/spshell/app.cpp

@@ -249,7 +249,6 @@ int app_init(const sp_cfg_start_args_t* args, std::function<void(const char* msg
 	int rc;
 	int flag;
 	sp_rpc_server_callback callback;
-	int costTime = 0;
 
 	auto getClockDual = []() -> int {
 		static clock_t t_begin = clock();

+ 17 - 112
Module/mod_ResourceWatcher/ResourceWatcherFSM.cpp

@@ -5,6 +5,7 @@
 #include <assert.h>
 #include <algorithm>
 #include "fileutil.h"
+#include "osutil.h"
 #include <ctime>
 #include "SpUtility.h"
 #include "RestfulFunc.h"
@@ -14,6 +15,7 @@
 #include "ResourceWatcher_UserCode.h"
 
 #ifdef RVC_OS_LINUX
+
 #include <vector>
 #include <dirent.h>
 #include <sstream>  
@@ -24,7 +26,13 @@
 #include "iniutil.h"
 #include "osutil.h"
 #include <winpr/file.h>
+
+#define PROCESS_ITEM 14 //进程CPU信息读取位置参数
+const int MAX_MAINLINK_CHECK_TIME = 5000;
+const int TIMER_MAINLINK_CHECK = 4;
+#define SECNAME_SFINSTALL "SoftwareInstallDetect%d"
 #else
+
 #include <intrin.h>
 #include <ShlObj.h>
 #include <ShellAPI.h>
@@ -46,14 +54,7 @@
 #include <sysinfoapi.h>
 #include "Mmdeviceapi.h"
 #include "Propidl.h"
-#endif
 
-#ifdef RVC_OS_LINUX
-#define PROCESS_ITEM 14 //进程CPU信息读取位置参数
-const int MAX_MAINLINK_CHECK_TIME = 5000;
-const int TIMER_MAINLINK_CHECK = 4;
-#define SECNAME_SFINSTALL "SoftwareInstallDetect%d"
-#else
 const int MILLION = 1048576;
 #define SECNAME_SFINSTALL "SoftwareInstallDetectWIN%d"
 #define ENCODING (X509_ASN_ENCODING | PKCS_7_ASN_ENCODING)
@@ -1579,35 +1580,13 @@ void ResourceWatcherFSM::DetectAutoStartupCover()
 	}
 }
 
-//TODO: CrossPlaform  [Gifur@2025729]
-static int Is32R64Platform()
-{
-    static int isWow64 = -1;
-    typedef BOOL(WINAPI* LPFN_ISWOW64PROCESS)(HANDLE, PBOOL);
-    if (isWow64 == -1) {
-        BOOL bIsWow64 = FALSE;
-        LPFN_ISWOW64PROCESS fnIsWow64Process = (LPFN_ISWOW64PROCESS)GetProcAddress(GetModuleHandle("kernel32"), "IsWow64Process");
-        if (NULL != fnIsWow64Process) {
-            if (!fnIsWow64Process(GetCurrentProcess(), &bIsWow64)) {
-                DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("detect is running with 64bit or not failed: %u", GetLastError());
-                return -1;
-            }
-            else
-            {
-                isWow64 = bIsWow64 ? 1 : 0;
-            }
-        }
-    }
-    return isWow64;
-}
-
 int ResourceWatcherFSM::DetectAutoStartupType(CSimpleStringA& strValue)
 {
     LOG_FUNCTION();
 
     int vbsType = -1;
     DWORD dwFlag = KEY_READ | KEY_QUERY_VALUE | KEY_ENUMERATE_SUB_KEYS;
-    if (Is32R64Platform() != 0) {
+    if (osutil_is32r64_platform() == 1) {
         dwFlag |= KEY_WOW64_64KEY;
     }
     bool explorerSet = false;
@@ -1710,7 +1689,7 @@ ErrorCodeEnum ResourceWatcherFSM::ChangeAutoStartupWithExe(bool resetVBS, bool r
     }
 
     DWORD dwFlag = KEY_WRITE;
-    if (Is32R64Platform() != 0) {
+    if (osutil_is32r64_platform() == 1) {
         dwFlag |= KEY_WOW64_64KEY;
     }
     HKEY hKey;
@@ -2036,85 +2015,11 @@ void ResourceWatcherFSM::DetectVersionHasChangedAndWarn()
     }
 }
 
-bool ResourceWatcherFSM::SetDesktopSysIcon2Registry(const std::string& key, bool toDisplay)
-{
-    bool result(true);
-	DWORD dwFlag = KEY_READ | KEY_WRITE | KEY_QUERY_VALUE | KEY_ENUMERATE_SUB_KEYS;
-	if (Is32R64Platform() != 0) {
-		dwFlag |= KEY_WOW64_64KEY;
-	}
-	HKEY hKey4Panel;
-	HKEY hKey4StartMenu;
-    DWORD dwCurValue4Panel = (DWORD)-1;
-	DWORD dwCurValue4StartMenu = (DWORD)-1;
-
-	LONG lResult = RegOpenKeyEx(HKEY_CURRENT_USER,"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\HideDesktopIcons\\NewStartPanel", 0, dwFlag, &hKey4Panel);
-    if (lResult == ERROR_SUCCESS) {
-		DWORD dwType = REG_DWORD;
-		DWORD dwValue = 0;
-		DWORD dwSize = sizeof(DWORD);
-        lResult = RegQueryValueExA(hKey4Panel, key.c_str(), NULL, &dwType, (LPBYTE)&dwValue, &dwSize);
-		if (lResult == ERROR_SUCCESS) {
-            dwCurValue4Panel = dwValue;
-            DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("NewStartPanel Value of %s: %d", key.c_str(), dwCurValue4Panel);
-		}
-		else {
-            result = false;
-			DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("RegQueryValueEx for \"%s\" in NewStartPanel error, result=%ld.", key.c_str(), lResult);
-		}
-    }
-
-	lResult = RegOpenKeyEx(HKEY_CURRENT_USER, "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\HideDesktopIcons\\ClassicStartMenu", 0, dwFlag, &hKey4StartMenu);
-	if (lResult == ERROR_SUCCESS) {
-		DWORD dwType = REG_DWORD;
-		DWORD dwValue = 0;
-		DWORD dwSize = sizeof(DWORD);
-		lResult = RegQueryValueExA(hKey4StartMenu, key.c_str(), NULL, &dwType, (LPBYTE)&dwValue, &dwSize);
-		if (lResult == ERROR_SUCCESS) {
-            dwCurValue4StartMenu = dwValue;
-			DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("ClassicStartMenu Value of %s: %d", key.c_str(), dwCurValue4StartMenu);
-		}
-		else {
-            result = false;
-			DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("RegQueryValueEx for \"%s\" in ClassicStartMenu error, result=%ld.", key.c_str(), lResult);
-		}
-	}
-    const DWORD dwAimValue = toDisplay ? 0 : 1;
-    if (dwCurValue4Panel != (DWORD)(-1) && dwCurValue4Panel != dwAimValue) {
-		DWORD dwType = REG_DWORD;
-		DWORD dwValue = dwAimValue;
-		DWORD dwSize = sizeof(DWORD);
-        lResult = RegSetValueExA(hKey4Panel, key.c_str(), 0, dwType, (BYTE*)&dwValue, dwSize);
-		if (lResult == ERROR_SUCCESS) {
-            DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("Set Value with %d for %s in NewStartPanel succ.", dwValue, key.c_str());
-		}
-		else {
-            result = false;
-            DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("Set Value with %d for %s  in NewStartPanel error, result=%ld.", dwValue, key.c_str(), lResult);
-		}
-    }
-	if (dwCurValue4StartMenu != (DWORD)(-1) && dwCurValue4StartMenu != dwAimValue) {
-		DWORD dwType = REG_DWORD;
-		DWORD dwValue = dwAimValue;
-		DWORD dwSize = sizeof(DWORD);
-		lResult = RegSetValueExA(hKey4StartMenu, key.c_str(), 0, dwType, (BYTE*)&dwValue, dwSize);
-		if (lResult == ERROR_SUCCESS) {
-			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("Set Value with %d for %s in ClassicStartMenu succ.", dwValue, key.c_str());
-		}
-		else {
-            result = false;
-			DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("Set Value with %d for %s  in ClassicStartMenu error, result=%ld.", dwValue, key.c_str(), lResult);
-		}
-	}
-    RegCloseKey(hKey4Panel);
-	RegCloseKey(hKey4StartMenu);
-    return result;
-}
-
 void ResourceWatcherFSM::MakeSureWin8IntoDesktopPageAtLogon()
 {
+    const bool isWow64 = (osutil_is32r64_platform() == 1);
 	DWORD dwFlag = KEY_READ | KEY_QUERY_VALUE | KEY_ENUMERATE_SUB_KEYS;
-	if (Is32R64Platform() != 0) {
+	if (isWow64) {
 		dwFlag |= KEY_WOW64_64KEY;
 	}
     bool isWin8(false);
@@ -2146,7 +2051,7 @@ void ResourceWatcherFSM::MakeSureWin8IntoDesktopPageAtLogon()
     }
     if (toSetOpenAtLogon) {
 		dwFlag = KEY_WRITE;
-		if (Is32R64Platform() != 0) {
+		if (isWow64) {
 			dwFlag |= KEY_WOW64_64KEY;
 		}
         DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("to Set OpenAtLogon");
@@ -3485,8 +3390,9 @@ void ResourceWatcherFSM::DetectWallpaperAndWarn()
 		return;
     }
     bool wallpapaerSetCMD = true;
+    const bool isWow64 = (osutil_is32r64_platform() == 1);
 	DWORD dwFlag = KEY_READ | KEY_QUERY_VALUE | KEY_ENUMERATE_SUB_KEYS;
-	if (Is32R64Platform() != 0) {
+	if (isWow64) {
 		dwFlag |= KEY_WOW64_64KEY;
 	}
     bool wellDone = false;
@@ -3555,7 +3461,7 @@ void ResourceWatcherFSM::DetectWallpaperAndWarn()
 
 		if (ExistsFileA(aimWallPaper)) {
 			dwFlag = KEY_WRITE;
-			if (Is32R64Platform() != 0) {
+			if (isWow64) {
 				dwFlag |= KEY_WOW64_64KEY;
 			}
 			lResult = RegOpenKeyEx(HKEY_CURRENT_USER, "Control Panel\\Desktop", 0, dwFlag, &hKey);
@@ -3818,7 +3724,7 @@ const char* dmi_string(const dmi_header* dm, BYTE s)
 void FetchSoftewareInstall(vector<SetupSoftInfo>& stupInfo, DWORD& dwInitFlag)
 {
     DWORD dwFlag = KEY_READ | KEY_QUERY_VALUE | KEY_ENUMERATE_SUB_KEYS;
-    if (dwInitFlag == 0 && Is32R64Platform() != 0) {
+    if (dwInitFlag == 0 && osutil_is32r64_platform() == 1) {
         dwInitFlag = 1;
         DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("with KEY_WOW64_64KEY");
         dwFlag |= KEY_WOW64_64KEY;
@@ -3833,7 +3739,6 @@ void FetchSoftewareInstall(vector<SetupSoftInfo>& stupInfo, DWORD& dwInitFlag)
                 TCHAR szValue[MAX_PATH + 1] = { 0 };
                 memset(szValue, '\0', MAX_PATH + 1);
                 RegEnumKeyEx(hKey, i, szValue, &dwRegSize, NULL, NULL, NULL, NULL);
-                //DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("%d:%s",i,szValue);
                 DWORD dwType;
                 HKEY hSubKey;
                 if (RegOpenKeyEx(hKey, szValue, NULL, KEY_READ, &hSubKey) == ERROR_SUCCESS)

+ 0 - 1
Module/mod_ResourceWatcher/ResourceWatcherFSM.h

@@ -394,7 +394,6 @@ public:
 	//2:startmenu lnk from user customization
 	BOOL IsHasSetAutoStartupByFolder(CSimpleStringA& strPath, int& setType);
 	void DetectVersionHasChangedAndWarn();
-	bool SetDesktopSysIcon2Registry(const std::string& key, bool toDisplay);
 	void MakeSureWin8IntoDesktopPageAtLogon();
 
 	void DetectVersionHasChangedAndWarnCover()

+ 0 - 23
Module/mod_ResourceWatcher/mod_ResourceWatcher.cpp

@@ -223,29 +223,6 @@ static inline bool Is64BitPlatform()
         || si.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_IA64);
 }
 
-//TODO: CrossPlaform  [Gifur@2025729]
-static int Is32R64Platform()
-{
-    static int isWow64 = -1;
-    typedef BOOL(WINAPI* LPFN_ISWOW64PROCESS)(HANDLE, PBOOL);
-    if (isWow64 == -1) {
-        BOOL bIsWow64 = FALSE;
-        LPFN_ISWOW64PROCESS fnIsWow64Process =
-            (LPFN_ISWOW64PROCESS)GetProcAddress(GetModuleHandle("kernel32"), "IsWow64Process");
-
-        if (NULL != fnIsWow64Process) {
-            if (!fnIsWow64Process(GetCurrentProcess(), &bIsWow64)) {
-                DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("detect is running with 64bit or not failed: %u", GetLastError());
-                return -1;
-            }
-            else {
-                isWow64 = bIsWow64 ? 1 : 0;
-            }
-        }
-    }
-    return isWow64;
-}
-
 static bool GetRegistValue(HKEY hKey, LPCTSTR lpcszParam, DWORD* pDwValue, CHAR* pSzValue, const DWORD* pDwSizeOfSz)
 {
     if (pDwValue != NULL) {

+ 7 - 98
Module/mod_UpgradeMgr/UpgradeTaskFSM.cpp

@@ -2,7 +2,7 @@
 #include "fileutil.h"
 #include "iniutil.h"
 #include "memutil.h"
-
+#include "osutil.h"
 #include "RVCComm.h"
 #include <regex>
 #include "mod_UpgradeMgr.h"
@@ -2187,35 +2187,11 @@ int CUpgradeTaskFSM::ExecRunCmd(CSimpleStringA &strErrMsg,CInstallStep* ins)
 
 	if (ExistsFileA(destPath.GetData()))
 	{
-#ifdef RVC_OS_WIN
-		//TODO: CrossPlaform  [Gifur@2025729]
-		// window模式下 如果是Wow64模式,需屏蔽System32重定向
-		PVOID pRedirectOldValue(NULL);
-		bool bIsWow64 = IsWow64Process();
-		if (bIsWow64)
-		{
-			if (!Wow64DisableWow64FsRedirection(&pRedirectOldValue)){
-				DbgWithLink(LOG_LEVEL_INFO,LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("Wow64DisableWow64FsRedirection fail: %d", GetLastError());
-			}else{
-				DbgWithLink(LOG_LEVEL_DEBUG,LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("Wow64DisableWow64FsRedirection succ");
-			}
-		}
-#endif
-		//system(strSourcePath);
+		ostuile_void_ptr store = osutil_sure_redirect_32sys_in_wow64();
 		string sysPathStr = destPath.GetData();
 		CSimpleStringA err ="";
 		int ret = system_on(sysPathStr,true,err);
-#ifdef RVC_OS_WIN
-		// 如果是Wow64模式,恢复System32重定向
-		if (bIsWow64)
-		{
-			if (!Wow64RevertWow64FsRedirection(pRedirectOldValue)){
-				DbgWithLink(LOG_LEVEL_INFO,LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("Wow64RevertWow64FsRedirection fail: %d", GetLastError());
-			}else{
-				DbgWithLink(LOG_LEVEL_INFO,LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("Wow64RevertWow64FsRedirection succ");
-			}
-		}
-#endif
+		osutil_reset_redirect_32sys_in_wow64(&store);
 		if(ret!=0){
 			//TODO: CrossPlaform  [Gifur@2025730]
 			//程序执行异常,结果未知
@@ -2226,18 +2202,12 @@ int CUpgradeTaskFSM::ExecRunCmd(CSimpleStringA &strErrMsg,CInstallStep* ins)
 			DbgWithLink(LOG_LEVEL_INFO,LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("ExecRunCmd is fail, system_on exec unknown , ret=%d, err=%s",ret, strerror(errno));
 			strErrMsg = CSimpleStringA::Format("ExecRunCmd is fail, system_on exec unknown  ret=%d, err=%s", ret, strerror(errno));
 #endif			
-
 			return -1;//未知结果返回
 
 		}else{
 			//进一步看返回结果文件判断是否成功
 			CSimpleStringA strUnzipPath = GetFileDirectory(destPath.GetData());
-			//TODO: CrossPlaform  1111 [Gifur@2025730]
-#ifdef RVC_OS_WIN
-			CSimpleStringA strResultLog = strUnzipPath + "\\result.log";//结果文件
-#else
-			CSimpleStringA strResultLog = strUnzipPath + "/result.log";//结果文件
-#endif
+			CSimpleStringA strResultLog = strUnzipPath + SPLIT_SLASH_STR + "result.log";//结果文件
 			CSimpleStringA eErrorCode = "";
 			//获取结果文件
 			if (!GetSysUpgradeResult(strResultLog, eErrorCode, strErrMsg))
@@ -3297,33 +3267,6 @@ CSimpleStringA CUpgradeTaskFSM::GetFileDirectory(const char *pszFullPath)
 	return CSimpleStringA(pszFullPath, i);
 }
 
-//TODO: CrossPlaform  [Gifur@2025729]
-bool CUpgradeTaskFSM::IsWow64Process()
-{
-#ifdef RVC_OS_WIN
-	typedef BOOL(WINAPI *LPFN_ISWOW64PROCESS)(HANDLE, PBOOL);
-	LPFN_ISWOW64PROCESS fnIsWow64Process = (LPFN_ISWOW64PROCESS)GetProcAddress(GetModuleHandle("kernel32"), "IsWow64Process");
-
-	BOOL bIsWow64 = FALSE;
-	if (NULL != fnIsWow64Process)
-	{
-		if (!fnIsWow64Process(GetCurrentProcess(), &bIsWow64))
-		{
-			DbgWithLink(LOG_LEVEL_INFO,LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("call IsWow64Process error: %d", GetLastError());
-			return false;
-		}
-
-		return bIsWow64 == TRUE;
-	}
-	else
-	{
-		DbgWithLink(LOG_LEVEL_INFO,LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("get IsWow64Process error: %d", GetLastError());
-		return false;
-	}
-#endif
-	return true;
-}
-
 int CUpgradeTaskFSM::system_on(string cmdFilePath, bool isWait,CSimpleStringA &errMsg)
 {
 #ifdef RVC_OS_WIN
@@ -5094,38 +5037,11 @@ int CUpgradeTaskFSM::ExecDepRunCmd(CSimpleStringA& strErrMsg, CInstallStep* ins)
 
 	if (ExistsFileA(destPath.GetData()))
 	{
-#ifdef RVC_OS_WIN
-		//TODO: CrossPlaform  [Gifur@2025729]
-		// window模式下 如果是Wow64模式,需屏蔽System32重定向
-		PVOID pRedirectOldValue(NULL);
-		bool bIsWow64 = IsWow64Process();
-		if (bIsWow64)
-		{
-			if (!Wow64DisableWow64FsRedirection(&pRedirectOldValue)) {
-				DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("Wow64DisableWow64FsRedirection fail: %d", GetLastError());
-			}
-			else {
-				DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("Wow64DisableWow64FsRedirection succ");
-			}
-		}
-#endif
-		//system(strSourcePath);
+		ostuile_void_ptr store = osutil_sure_redirect_32sys_in_wow64();
 		string sysPathStr = destPath.GetData();
 		CSimpleStringA err = "";
 		int ret = system_on(sysPathStr, true, err);
-#ifdef RVC_OS_WIN
-		//TODO: CrossPlaform  [Gifur@2025729]
-		// 如果是Wow64模式,恢复System32重定向
-		if (bIsWow64)
-		{
-			if (!Wow64RevertWow64FsRedirection(pRedirectOldValue)) {
-				DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("Wow64RevertWow64FsRedirection fail: %d", GetLastError());
-			}
-			else {
-				DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("Wow64RevertWow64FsRedirection succ");
-			}
-		}
-#endif
+		osutil_reset_redirect_32sys_in_wow64(&store);
 		if (ret != 0) {
 			//程序执行异常,结果未知
 			//TODO: CrossPlaform  [Gifur@2025730]
@@ -5136,19 +5052,12 @@ int CUpgradeTaskFSM::ExecDepRunCmd(CSimpleStringA& strErrMsg, CInstallStep* ins)
 			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI(__FUNCTION__)("ExecRunCmd is fail, system_on exec unknown , ret=%d, err=%s", ret, strerror(errno));
 			strErrMsg = CSimpleStringA::Format("ExecRunCmd is fail, system_on exec unknown  ret=%d, err=%s", ret, strerror(errno));
 #endif			
-
 			return -1;//未知结果返回
-
 		}
 		else {
 			//进一步看返回结果文件判断是否成功
 			CSimpleStringA strUnzipPath = GetFileDirectory(destPath.GetData());
-			//TODO: CrossPlaform  [Gifur@2025730]
-#ifdef RVC_OS_WIN
-			CSimpleStringA strResultLog = strUnzipPath + "\\result.log";//结果文件
-#else
-			CSimpleStringA strResultLog = strUnzipPath + "/result.log";//结果文件
-#endif
+			CSimpleStringA strResultLog = strUnzipPath + SPLIT_SLASH_STR + "result.log";//结果文件
 			CSimpleStringA eErrorCode = "";
 			//获取结果文件
 			if (!GetSysUpgradeResult(strResultLog, eErrorCode, strErrMsg))

+ 0 - 1
Module/mod_UpgradeMgr/UpgradeTaskFSM.h

@@ -376,7 +376,6 @@ public:
 	bool IsFileMatch(const char *pszFilter, const char *pszFileName);
 	bool RecursiveCopyDir(const char *pszSourceDir, const char *pszDestDir,CSimpleStringA &strErrInfo);//可以合并
 	CSimpleStringA GetFileDirectory(const char *pszFullPath);//查找文件的父路径
-	bool IsWow64Process();//判断是否是64位windows程序
 	int system_on(string cmdFilePath, bool isWait,CSimpleStringA &errMsg);//cmd窗口程序
 	int waitSystem(string cmd, const char * par, bool nShow,CSimpleStringA &errMsg);//起进程执行cmd