From 5cab279a8cb5cbe744f75b86bc31d3150c6ea20b Mon Sep 17 00:00:00 2001 From: Davide Beatrici Date: Sat, 3 Apr 2021 02:25:19 +0200 Subject: [PATCH] Cedar, Mayaqua: Set minimum Windows version to Vista --- src/Cedar/BridgeWin32.c | 49 +- src/Cedar/CM.c | 233 +--- src/Cedar/Cedar.h | 1 - src/Cedar/Client.c | 220 +-- src/Cedar/Client.h | 8 - src/Cedar/Command.c | 19 +- src/Cedar/EM.c | 35 +- src/Cedar/NM.c | 4 +- src/Cedar/Proto_Win7.c | 5 - src/Cedar/SM.c | 70 +- src/Cedar/SW.c | 339 ++--- src/Cedar/SWInner.h | 2 - src/Cedar/Server.c | 2 +- src/Cedar/Session.c | 6 - src/Cedar/UT.c | 4 +- src/Cedar/VLanWin32.c | 208 +-- src/Cedar/VLanWin32.h | 2 - src/Cedar/Virtual.c | 5 +- src/Cedar/Win32Com.cpp | 51 +- src/Cedar/WinJumpList.cpp | 4 +- src/Cedar/WinUi.c | 868 +----------- src/Cedar/WinUi.h | 22 - src/Mayaqua/CMakeLists.txt | 13 +- src/Mayaqua/Kernel.c | 22 +- src/Mayaqua/MayaType.h | 8 +- src/Mayaqua/Microsoft.c | 2568 ++++++------------------------------ src/Mayaqua/Microsoft.h | 182 +-- src/Mayaqua/Network.c | 317 +---- src/Mayaqua/Network.h | 4 +- src/Mayaqua/Table.c | 16 - src/Mayaqua/Win32.c | 21 +- 31 files changed, 773 insertions(+), 4535 deletions(-) diff --git a/src/Cedar/BridgeWin32.c b/src/Cedar/BridgeWin32.c index eca7952a..2c02516a 100644 --- a/src/Cedar/BridgeWin32.c +++ b/src/Cedar/BridgeWin32.c @@ -466,11 +466,6 @@ bool EnumEthVLanWin32(RPC_ENUM_ETH_VLAN *t) Zero(t, sizeof(RPC_ENUM_ETH_VLAN)); - if (MsIsWin2000OrGreater() == false) - { - return false; - } - if (IsEthSupported() == false) { return false; @@ -1488,7 +1483,7 @@ LIST *GetEthAdapterListInternal() i = 0; - if (OS_IS_WINDOWS_NT(GetOsInfo()->OsType)) + if (true) { // Windows NT if (size >= 2 && buf[0] != 0 && buf[1] != 0) @@ -1526,7 +1521,6 @@ LIST *GetEthAdapterListInternal() } else { - // Windows 9x ANSI_STR: while (true) { @@ -1564,18 +1558,6 @@ ANSI_STR: StrCpy(a->Title, sizeof(a->Title), &buf[i]); i += StrSize(a->Title); - // If device description is "Unknown" in Win9x, skip 1 byte - if (OS_IS_WINDOWS_9X(GetOsInfo()->OsType)) - { - if (StrCmp(a->Title, "Unknown") == 0) - { - if (buf[i] == 0) - { - i+=sizeof(char); - } - } - } - TrimCrlf(a->Title); Trim(a->Title); TrimCrlf(a->Title); @@ -1790,31 +1772,7 @@ bool IsEthSupportedInner() // Is the PCD driver supported in current OS bool IsPcdSupported() { - UINT type; - OS_INFO *info = GetOsInfo(); - - if (MsIsWindows10()) - { - // Windows 10 or later never supports PCD driver. - return false; - } - - type = info->OsType; - - if (OS_IS_WINDOWS_NT(type) == false) - { - // Only on Windows NT series - return false; - } - - if (GET_KETA(type, 100) >= 2) - { - // Good for Windows 2000 or later - return true; - } - - // Not good for Windows NT 4.0 or Longhorn - return false; + return !MsIsWindows10(); } // Save build number of PCD driver @@ -2085,8 +2043,7 @@ void GetEthNetworkConnectionName(wchar_t *dst, UINT size, char *device_name) UniStrCpy(dst, size, L""); // Validate arguments - if (device_name == NULL || IsEthSupported() == false || - IsNt() == false || MsIsWin2000OrGreater() == false) + if (device_name == NULL || IsEthSupported() == false) { return; } diff --git a/src/Cedar/CM.c b/src/Cedar/CM.c index 84ac5544..a7525d8d 100644 --- a/src/Cedar/CM.c +++ b/src/Cedar/CM.c @@ -13,8 +13,8 @@ #define SM_C #define MICROSOFT_C -#define _WIN32_WINNT 0x0502 -#define WINVER 0x0502 +#define _WIN32_WINNT 0x0600 +#define WINVER 0x0600 #define SECURITY_WIN32 #include #include @@ -232,14 +232,7 @@ UINT CmGetSecureBitmapId(char *dest_hostname) // Activate the window of UAC void CmSetUacWindowActive() { - HWND hWnd; - - if (MsIsVista() == false) - { - return; - } - - hWnd = FindWindowA("$$$Secure UAP Dummy Window Class For Interim Dialog", NULL); + HWND hWnd = FindWindowA("$$$Secure UAP Dummy Window Class For Interim Dialog", NULL); if (hWnd == NULL) { return; @@ -1485,22 +1478,8 @@ void CmTrafficRunDlgAddStr(HWND hWnd, wchar_t *str) UniReplaceStrEx(tmp, tmp_size, tmp, L"\r\n", L"\n", false); UniReplaceStrEx(tmp, tmp_size, tmp, L"\n", L"\r\n", false); - if (MsIsNt()) - { - SendMsg(hWnd, E_EDIT, EM_SETSEL, 0x7fffffff, 0x7fffffff); - SendMsg(hWnd, E_EDIT, EM_REPLACESEL, false, (LPARAM)tmp); - } - else - { - char *s = CopyUniToStr(tmp); - UINT len; - - len = GetWindowTextLength(DlgItem(hWnd, E_EDIT)); - SendMsg(hWnd, E_EDIT, EM_SETSEL, 0x7fffffff, 0x7fffffff); - SendMsg(hWnd, E_EDIT, EM_SETSEL, len, len); - SendMsg(hWnd, E_EDIT, EM_REPLACESEL, false, (LPARAM)s); - Free(s); - } + SendMsg(hWnd, E_EDIT, EM_SETSEL, 0x7fffffff, 0x7fffffff); + SendMsg(hWnd, E_EDIT, EM_REPLACESEL, false, (LPARAM)tmp); Free(tmp); } @@ -3568,11 +3547,6 @@ bool CmStopInstallVLan(HWND hWnd) // There is no need to be prohibited if the client is an UNIX return true; } - if (cm->Client->Win9x) - { - // There is no need to prohibit if the client is a Win9x - return true; - } return true; @@ -5474,27 +5448,12 @@ void CmMainWindowOnCommandEx(HWND hWnd, WPARAM wParam, LPARAM lParam, bool easy) name = CmNewVLanDlg(hWnd); if (name != NULL) { - wchar_t tmp[MAX_SIZE]; void *helper = NULL; RPC_CLIENT_CREATE_VLAN c; Zero(&c, sizeof(c)); StrCpy(c.DeviceName, sizeof(c.DeviceName), name); - if (MsIsNt() == false) - { - // Change the title of the window - GetTxt(hWnd, 0, tmp, sizeof(tmp)); - SetText(hWnd, 0, _UU("CM_VLAN_INSTALLING")); - } - // Minimize - if (MsIsVista() == false) - { - ShowWindow(hWnd, SW_SHOWMINIMIZED); - } - if (MsIsVista()) - { - helper = CmStartUacHelper(); - } + helper = CmStartUacHelper(); if (CALL(hWnd, CcCreateVLan(cm->Client, &c))) { @@ -5503,16 +5462,6 @@ void CmMainWindowOnCommandEx(HWND hWnd, WPARAM wParam, LPARAM lParam, bool easy) CmStopUacHelper(helper); - if (MsIsNt() == false) - { - // Restore the title of the window - SetText(hWnd, 0, tmp); - } - // Restore - if (MsIsVista() == false) - { - ShowWindow(hWnd, SW_SHOWNORMAL); - } Free(name); CmRefresh(hWnd); @@ -5523,38 +5472,26 @@ void CmMainWindowOnCommandEx(HWND hWnd, WPARAM wParam, LPARAM lParam, bool easy) index = LvGetSelected(hWnd, L_VLAN); if (index != INFINITE) { - if (cm->Client->Win9x == false) + // Windows 2000 or later + wchar_t *s = LvGetStr(hWnd, L_VLAN, index, 0); + if (s != NULL) { - // Windows 2000 or later - wchar_t *s = LvGetStr(hWnd, L_VLAN, index, 0); - if (s != NULL) + RPC_CLIENT_CREATE_VLAN c; + char str[MAX_SIZE]; + CmVoice("delete_vlan_1"); + if (MsgBoxEx(hWnd, MB_ICONQUESTION | MB_YESNO | MB_DEFBUTTON2, _UU("CM_DELETE_VLAN"), s) == IDYES) { - RPC_CLIENT_CREATE_VLAN c; - char str[MAX_SIZE]; - CmVoice("delete_vlan_1"); - if (MsgBoxEx(hWnd, MB_ICONQUESTION | MB_YESNO | MB_DEFBUTTON2, _UU("CM_DELETE_VLAN"), s) == IDYES) + Zero(&c, sizeof(c)); + UniToStr(str, sizeof(str), s); + if (CmPrintNameToVLanName(c.DeviceName, sizeof(c.DeviceName), str)) { - Zero(&c, sizeof(c)); - UniToStr(str, sizeof(str), s); - if (CmPrintNameToVLanName(c.DeviceName, sizeof(c.DeviceName), str)) + if (CALL(hWnd, CcDeleteVLan(cm->Client, &c))) { - if (CALL(hWnd, CcDeleteVLan(cm->Client, &c))) - { - CmVoice("delete_vlan_2"); - } + CmVoice("delete_vlan_2"); } } - Free(s); - } - } - else - { - // Windows 9x - if (MsgBox(hWnd, MB_ICONQUESTION | MB_YESNO, _UU("CM_9X_VLAN_UNINSTALL")) == IDYES) - { - Run("rundll32.exe", "shell32.dll,Control_RunDLL NETCPL.CPL", - false, false); } + Free(s); } CmRefresh(hWnd); @@ -5629,26 +5566,11 @@ void CmMainWindowOnCommandEx(HWND hWnd, WPARAM wParam, LPARAM lParam, bool easy) UniToStr(str, sizeof(str), s); if (CmPrintNameToVLanName(c.DeviceName, sizeof(c.DeviceName), str)) { - void *helper = NULL; - - if (MsIsVista() == false) - { - ShowWindow(hWnd, SW_SHOWMINIMIZED); - } - - if (MsIsVista()) - { - helper = CmStartUacHelper(); - } + void *helper = CmStartUacHelper(); CALL(hWnd, CcUpgradeVLan(cm->Client, &c)); CmStopUacHelper(helper); - - if (MsIsVista() == false) - { - ShowWindow(hWnd, SW_SHOWNORMAL); - } } Free(s); @@ -5720,11 +5642,7 @@ void CmMainWindowOnCommandEx(HWND hWnd, WPARAM wParam, LPARAM lParam, bool easy) break; case CMD_MMCSS: // Optimization utility for Windows Vista - if (MsIsVista() == false) - { - MsgBox(hWnd, MB_ICONINFORMATION, _UU("VISTA_MMCSS_MSG_4")); - } - else + if (true) { if (MsIsAdmin() == false) { @@ -5792,7 +5710,6 @@ void CmConfigDlgInit(HWND hWnd) { bool use_alpha; UINT alpha_value; - UINT os; CLIENT_CONFIG c; // Validate arguments if (hWnd == NULL) @@ -5827,15 +5744,7 @@ void CmConfigDlgInit(HWND hWnd) SetInt(hWnd, E_ALPHA_VALUE, alpha_value == 0 ? 50 : alpha_value); Check(hWnd, R_ALPHA, use_alpha); - os = GetOsInfo()->OsType; - if (OS_IS_WINDOWS_NT(os) && GET_KETA(os, 100) >= 2) - { - Enable(hWnd, R_ALPHA); - } - else - { - Disable(hWnd, R_ALPHA); - } + Enable(hWnd, R_ALPHA); CmConfigDlgRefresh(hWnd); } @@ -6437,8 +6346,8 @@ UINT CmNewVLanDlgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam, void *p switch (msg) { case WM_INITDIALOG: - LimitText(hWnd, E_NAME, cm->Client->Win9x ? MAX_DEVICE_NAME_LEN_9X : MAX_DEVICE_NAME_LEN); - FormatText(hWnd, S_INFO, cm->Client->Win9x ? MAX_DEVICE_NAME_LEN_9X : MAX_DEVICE_NAME_LEN); + LimitText(hWnd, E_NAME, MAX_DEVICE_NAME_LEN); + FormatText(hWnd, S_INFO, MAX_DEVICE_NAME_LEN); Zero(&ver, sizeof(ver)); @@ -6463,15 +6372,7 @@ UINT CmNewVLanDlgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam, void *p switch (wParam) { case IDOK: - if (cm->Client->Win9x) - { - // For Windows 9x, show a confirmation message - if (MsgBox(hWnd, MB_ICONQUESTION | MB_OKCANCEL, _UU("CM_9X_VLAN_INSTALL")) == IDCANCEL) - { - break; - } - } - GetTxtA(hWnd, E_NAME, tmp, (cm->Client->Win9x ? MAX_DEVICE_NAME_LEN_9X : MAX_DEVICE_NAME_LEN) + 1); + GetTxtA(hWnd, E_NAME, tmp, MAX_DEVICE_NAME_LEN + 1); Trim(tmp); if (CcGetClientVersion(cm->Client, &ver) == ERR_NO_ERROR) @@ -9933,30 +9834,6 @@ void CmConnect(HWND hWnd, wchar_t *account_name) return; } - if (hWnd == cm->hMainWnd) - { - if (LvNum(hWnd, L_VLAN) == 0 && cm->Client->Win9x) - { - if (MsgBox(hWnd, MB_ICONINFORMATION | MB_YESNO, _UU("CM_NO_VLAN_2")) == IDNO) - { - return; - } - else - { - if (cm->server_name == NULL || cm->Client->Unix) - { - Command(hWnd, CMD_NEW_VLAN); - return; - } - else - { - MsgBox(hWnd, MB_ICONINFORMATION, _UU("CM_VLAN_REMOTE_ERROR")); - } - return; - } - } - } - // (If necessary) display a warning if (CmWarningDesktop(hWnd, account_name) == false) { @@ -10095,7 +9972,7 @@ bool CmIsEnabled(HWND hWnd, UINT id) switch (id) { case CMD_LANGUAGE: - return MsIsNt(); + return true; case CMD_SHOWPORT: case CMD_GRID: if (cm->IconView) @@ -10104,7 +9981,7 @@ bool CmIsEnabled(HWND hWnd, UINT id) } return true; case CMD_MMCSS: - if (MsIsVista() == false || IsEmptyStr(cm->server_name) == false) + if (IsEmptyStr(cm->server_name) == false) { return false; } @@ -10115,12 +9992,7 @@ bool CmIsEnabled(HWND hWnd, UINT id) return true; case CMD_TRAYICON: case CMD_TRAFFIC: - return (cm->server_name == NULL); case CMD_NETIF: - if (MsIsNt() == false) - { - return false; - } return (cm->server_name == NULL); case CMD_CM_SETTING: return cm->CmSettingSupported; @@ -10257,21 +10129,11 @@ bool CmIsEnabled(HWND hWnd, UINT id) } break; case CMD_NEW_VLAN: - if (cm->Client->Unix == false && cm->Client->Win9x == false) + if (cm->Client->Unix == false && cm->server_name != NULL) { - if (cm->server_name != NULL) - { - return false; - } - } - if (cm->Client->Win9x) - { - if (LvNum(hWnd, L_VLAN) >= 1) - { - // You can not install two or more virtual LAN cards in Win9x - return false; - } + return false; } + break; case CMD_PROPERTY: name = LvGetSelectedStr(hWnd, L_ACCOUNT, 0); @@ -10296,10 +10158,6 @@ bool CmIsEnabled(HWND hWnd, UINT id) } return LvIsSelected(hWnd, L_VLAN); case CMD_ENABLE_VLAN: - if (cm->Client->Win9x) - { - return false; - } if (LvIsMultiMasked(hWnd, L_VLAN)) { return false; @@ -10325,10 +10183,6 @@ bool CmIsEnabled(HWND hWnd, UINT id) } break; case CMD_DISABLE_VLAN: - if (cm->Client->Win9x) - { - return false; - } if (LvIsMultiMasked(hWnd, L_VLAN)) { return false; @@ -10358,7 +10212,7 @@ bool CmIsEnabled(HWND hWnd, UINT id) { return false; } - if (cm->Client->Win9x || cm->Client->Unix) + if (cm->Client->Unix) { // Upgrading the virtual LAN card on a UNIX system or Win9x is unavailable return false; @@ -10369,24 +10223,7 @@ bool CmIsEnabled(HWND hWnd, UINT id) } return LvIsSelected(hWnd, L_VLAN); case CMD_WINNET: - { - UINT os_type = GetOsInfo()->OsType; - - if (OS_IS_WINDOWS_NT(os_type) && GET_KETA(os_type, 100) >= 2) - { - if (cm->server_name != NULL) - { - return false; - } - - return true; - } - else - { - return false; - } - } - break; + return (cm->server_name == NULL); case CMD_EXIT: return cm->TrayInited; } @@ -11274,7 +11111,7 @@ void CmMainWindowOnInit(HWND hWnd) } else { - cm->VistaStyle = MsIsVista(); + cm->VistaStyle = true; } if (MsRegIsValue(REG_CURRENT_USER, CM_REG_KEY, "ShowPort")) @@ -12078,10 +11915,6 @@ RETRY: { cm->CmSettingSupported = true; cm->CmEasyModeSupported = true; - if (OS_IS_WINDOWS_9X(a.OsType)) - { - cm->CmEasyModeSupported = false; - } } return true; diff --git a/src/Cedar/Cedar.h b/src/Cedar/Cedar.h index b3c09d76..a84e67db 100644 --- a/src/Cedar/Cedar.h +++ b/src/Cedar/Cedar.h @@ -118,7 +118,6 @@ #define MAX_SESSION_NAME_LEN 255 // Session name maximum length #define MAX_CONNECTION_NAME_LEN 255 // Maximum length of connection name #define MAX_DEVICE_NAME_LEN 31 // Device name maximum length -#define MAX_DEVICE_NAME_LEN_9X 4 // Maximum length of Virtual LAN card name in Win9x #define MAX_ACCESSLIST_NOTE_LEN 255 // Maximum length of the note of access list entry #define MAX_SECURE_DEVICE_FILE_LEN 255 // Secure device file name maximum length #define MAX_ADMIN_OPTION_NAME_LEN 63 // Management option name diff --git a/src/Cedar/Client.c b/src/Cedar/Client.c index 3acf9423..0e7b7dfe 100644 --- a/src/Cedar/Client.c +++ b/src/Cedar/Client.c @@ -1108,11 +1108,7 @@ void Win32CnNicInfoThreadProc(THREAD *thread, void *param) return; } - if (MsIsNt()) - { - // Do not show a dialog on Windows 9x system - NicInfo(info); - } + NicInfo(info); Disconnect(info->Sock); } @@ -1370,10 +1366,7 @@ void Win32CnExecDriverInstaller(SOCK *s, PACK *p) return; } - if (MsIsVista()) - { - helper = CmStartUacHelper(); - } + helper = CmStartUacHelper(); ret = MsExecDriverInstaller(arg); @@ -5725,7 +5718,6 @@ L_TRY: CcGetClientVersion(ret, &t); ret->OsType = t.OsType; ret->Unix = OS_IS_UNIX(ret->OsType); - ret->Win9x = OS_IS_WINDOWS_9X(ret->OsType); ret->IsVgcSupported = t.IsVgcSupported; ret->ShowVgcLink = t.ShowVgcLink; StrCpy(ret->ClientId, sizeof(ret->ClientId), t.ClientId); @@ -6282,17 +6274,12 @@ bool CtConnect(CLIENT *c, RPC_CLIENT_CONNECT *connect) { if (t.NumItem == 0) { - // There are no virtual LAN cards in the system - if (OS_IS_WINDOWS_NT(GetOsInfo()->OsType) || OS_IS_UNIX(GetOsInfo()->OsType)) - { - // Only in Linux system or Windows NT system, - // create a new virtual LAN card which named as "VPN" automatically + // Create a new virtual LAN card named "VPN" automatically RPC_CLIENT_CREATE_VLAN t; Zero(&t, sizeof(t)); StrCpy(t.DeviceName, sizeof(t.DeviceName), "VPN"); CtCreateVLan(c, &t); - } } CiFreeClientEnumVLan(&t); @@ -7641,13 +7628,6 @@ bool CtDeleteVLan(CLIENT *c, RPC_CLIENT_CREATE_VLAN *d) #else // OS_WIN32 - if (MsIsNt() == false) - { - // Not available in Win9x - CiSetError(c, ERR_NOT_SUPPORTED); - return false; - } - // Check whether the virtual LAN card are present if (MsIsVLanExists(VLAN_ADAPTER_NAME_TAG, d->DeviceName) == false && MsIsVLanExists(VLAN_ADAPTER_NAME_TAG_OLD, d->DeviceName) == false) @@ -8021,8 +8001,7 @@ bool CtUpgradeVLan(CLIENT *c, RPC_CLIENT_CREATE_VLAN *create) { bool use_old_name = false; -#ifdef OS_WIN32 - KAKUSHI *k = NULL; +#ifdef OS_WIN32 MS_DRIVER_VER ver; #endif // OS_WIN32 @@ -8042,13 +8021,6 @@ bool CtUpgradeVLan(CLIENT *c, RPC_CLIENT_CREATE_VLAN *create) CiInitDriverVerStruct(&ver); - if (MsIsNt() == false) - { - // Not available in Win9x - CiSetError(c, ERR_NOT_SUPPORTED); - return false; - } - // Check whether the LAN card with the specified name already exists if (MsIsVLanExists(VLAN_ADAPTER_NAME_TAG, create->DeviceName) == false && MsIsVLanExists(VLAN_ADAPTER_NAME_TAG_OLD, create->DeviceName) == false) @@ -8065,47 +8037,19 @@ bool CtUpgradeVLan(CLIENT *c, RPC_CLIENT_CREATE_VLAN *create) use_old_name = true; } - if (MsIsVista() == false) + // Perform the installation + char tmp[MAX_SIZE]; + Format(tmp, sizeof(tmp), "upgradevlan %s", create->DeviceName); + + if (CncExecDriverInstaller(tmp) == false) { - k = InitKakushi(); + // Installation Failed + CiSetError(c, ERR_VLAN_INSTALL_ERROR); + CiNotify(c); + CiSendGlobalPulse(c); + return false; } - - if (MsIsVista() == false) - { - // Perform the installation (other than Windows Vista) - if (MsUpgradeVLan(use_old_name ? VLAN_ADAPTER_NAME_TAG_OLD : VLAN_ADAPTER_NAME_TAG, - use_old_name ? VLAN_CONNECTION_NAME_OLD : VLAN_CONNECTION_NAME, - create->DeviceName, &ver) == false) - { - // Installation Failed - FreeKakushi(k); - CiSetError(c, ERR_VLAN_INSTALL_ERROR); - CiNotify(c); - CiSendGlobalPulse(c); - return false; - } - } - else - { - // Perform the installation (Windows Vista) - char tmp[MAX_SIZE]; - - Format(tmp, sizeof(tmp), "upgradevlan %s", create->DeviceName); - - if (CncExecDriverInstaller(tmp) == false) - { - // Installation Failed - FreeKakushi(k); - CiSetError(c, ERR_VLAN_INSTALL_ERROR); - CiNotify(c); - CiSendGlobalPulse(c); - return false; - } - } - - FreeKakushi(k); - CLog(c, "LC_UPDATE_VLAN", create->DeviceName); CiNotify(c); @@ -8122,10 +8066,6 @@ bool CtCreateVLan(CLIENT *c, RPC_CLIENT_CREATE_VLAN *create) TOKEN_LIST *t; UINT max_len; -#ifdef OS_WIN32 - KAKUSHI *k = NULL; -#endif // OS_WIN32 - // Validate arguments if (c == NULL || create == NULL) { @@ -8206,25 +8146,6 @@ bool CtCreateVLan(CLIENT *c, RPC_CLIENT_CREATE_VLAN *create) return true; #else // OS_WIN32 - - if (OS_IS_WINDOWS_9X(GetOsInfo()->OsType)) - { - // Only one LAN card is available in the Win9x - TOKEN_LIST *t; - - t = MsEnumNetworkAdapters(VLAN_ADAPTER_NAME, VLAN_ADAPTER_NAME_OLD); - if (t != NULL) - { - if (t->NumTokens >= 1) - { - FreeToken(t); - CiSetError(c, ERR_NOT_SUPPORTED); - return false; - } - FreeToken(t); - } - } - // Check whether the specified name is valid or not if (IsSafeStr(create->DeviceName) == false) { @@ -8233,7 +8154,7 @@ bool CtCreateVLan(CLIENT *c, RPC_CLIENT_CREATE_VLAN *create) return false; } - max_len = MsIsNt() ? MAX_DEVICE_NAME_LEN : MAX_DEVICE_NAME_LEN_9X; + max_len = MAX_DEVICE_NAME_LEN; if (StrLen(create->DeviceName) > max_len) { // Name is too long @@ -8261,51 +8182,18 @@ bool CtCreateVLan(CLIENT *c, RPC_CLIENT_CREATE_VLAN *create) return false; } - if (MsIsNt()) + // Perform the installation (Windows Vista) + char tmp[MAX_SIZE]; + Format(tmp, sizeof(tmp), "instvlan %s", create->DeviceName); + + if (CncExecDriverInstaller(tmp) == false) { - if (MsIsVista() == false) - { - k = InitKakushi(); - } + CiSetError(c, ERR_VLAN_INSTALL_ERROR); + CiNotify(c); + CiSendGlobalPulse(c); + return false; } - if (MsIsVista() == false) - { - MS_DRIVER_VER ver; - - CiInitDriverVerStruct(&ver); - - // Perform the installation (other than Windows Vista) - if (MsInstallVLan(VLAN_ADAPTER_NAME_TAG, VLAN_CONNECTION_NAME, create->DeviceName, &ver) == false) - { - // Installation Failed - FreeKakushi(k); - CiSetError(c, ERR_VLAN_INSTALL_ERROR); - CiNotify(c); - CiSendGlobalPulse(c); - return false; - } - } - else - { - // Perform the installation (Windows Vista) - char tmp[MAX_SIZE]; - - Format(tmp, sizeof(tmp), "instvlan %s", create->DeviceName); - - if (CncExecDriverInstaller(tmp) == false) - { - // Installation Failed - FreeKakushi(k); - CiSetError(c, ERR_VLAN_INSTALL_ERROR); - CiNotify(c); - CiSendGlobalPulse(c); - return false; - } - } - - FreeKakushi(k); - t = MsEnumNetworkAdapters(VLAN_ADAPTER_NAME, VLAN_ADAPTER_NAME_OLD); if (t->NumTokens == 1) { @@ -8340,17 +8228,6 @@ bool CtCreateVLan(CLIENT *c, RPC_CLIENT_CREATE_VLAN *create) CiSaveConfigurationFile(c); - if (MsIsNt() == false) - { - if (GetOsInfo()->OsType == OSTYPE_WINDOWS_ME) - { - // Show the warning in the case of Windows Me - MsgBox(NULL, 0x00000040L, _UU("CM_9X_VLAN_ME_MESSAGE")); - } - - ReleaseThread(NewThread(Win9xRebootThread, NULL)); - } - return true; #endif // OS_WIN32 @@ -9741,12 +9618,7 @@ bool CiReadSettingFromCfg(CLIENT *c, FOLDER *root) UINT ostype = GetOsInfo()->OsType; // CM_SETTING CM_SETTING *s = c->CmSetting; - - if (OS_IS_UNIX(ostype) || OS_IS_WINDOWS_NT(ostype)) - { - s->EasyMode = CfgGetBool(cmsetting, "EasyMode"); - } - + s->EasyMode = CfgGetBool(cmsetting, "EasyMode"); s->LockMode = CfgGetBool(cmsetting, "LockMode"); CfgGetByte(cmsetting, "HashedPassword", s->HashedPassword, sizeof(s->HashedPassword)); } @@ -10432,16 +10304,6 @@ CLIENT *CiNewClient() // Raise the priority OSSetHighPriority(); - - -#ifdef OS_WIN32 - // For Win9x, release the DHCP address of all the virtual LAN card - if (MsIsNt() == false) - { - Win32ReleaseAllDhcp9x(true); - } -#endif // OS_WIN32 - CiChangeAllVLanMacAddressIfMachineChanged(c); CiChangeAllVLanMacAddressIfCleared(c); @@ -10564,14 +10426,6 @@ void CiCleanupClient(CLIENT *c) Free(c); -#ifdef OS_WIN32 - // For Win9x, release the DHCP address of all the virtual LAN card - if (MsIsNt() == false) - { - Win32ReleaseAllDhcp9x(true); - } -#endif // OS_WIN32 - StopCedarLog(); if (ci_active_sessions_lock != NULL) @@ -10632,9 +10486,6 @@ void CtStartClient() return; } - // OS check - CiCheckOs(); - #ifdef OS_WIN32 RegistWindowsFirewallAll(); #endif @@ -10754,27 +10605,6 @@ void CtStopClient() client = NULL; } -// OS check -void CiCheckOs() -{ - // Get the OS type - OS_INFO *info = GetOsInfo(); - - if (OS_IS_WINDOWS(info->OsType)) - { - bool ok = IS_CLIENT_SUPPORTED_OS(info->OsType); - - if (ok == false) - { - Alert( - CEDAR_PRODUCT_STR " VPN Client doesn't support this Windows Operating System.\n" - CEDAR_PRODUCT_STR " VPN Client requires Windows 98, Windows Me, Windows 2000, Windows XP, Windows Server 2003 or Greater.\n\n" - "Please contact your system administrator.", CEDAR_PRODUCT_STR " VPN Client"); - exit(0); - } - } -} - // Client status indicator void CiClientStatusPrinter(SESSION *s, wchar_t *status) { diff --git a/src/Cedar/Client.h b/src/Cedar/Client.h index 96b5fe07..439a5e9f 100644 --- a/src/Cedar/Client.h +++ b/src/Cedar/Client.h @@ -12,12 +12,6 @@ #define CLIENT_NOTIFY_PORT GC_CLIENT_NOTIFY_PORT // Client notification port number #define CLIENT_WAIT_CN_READY_TIMEOUT (10 * 1000) // Standby time to start the client notification service - -// Check whether the client can run on the specified OS_TYPE -#define IS_CLIENT_SUPPORTED_OS(t) \ - ((OS_IS_WINDOWS_NT(t) && GET_KETA(t, 100) >= 2) || (OS_IS_WINDOWS_9X(t))) - - // Constants #define CLIENT_CONFIG_FILE_NAME "$vpn_client.config" #define CLIENT_DEFAULT_KEEPALIVE_HOST "keepalive.softether.org" @@ -420,7 +414,6 @@ struct REMOTE_CLIENT RPC *Rpc; UINT OsType; bool Unix; - bool Win9x; UINT ProcessId; UINT ClientBuildInt; bool IsVgcSupported; @@ -643,7 +636,6 @@ void CiFreeGetCa(RPC_GET_CA *a); void CiFreeGetIssuer(RPC_GET_ISSUER *a); void CiFreeClientEnumAccount(RPC_CLIENT_ENUM_ACCOUNT *a); void CiSetError(CLIENT *c, UINT err); -void CiCheckOs(); CLIENT *CiNewClient(); void CiCleanupClient(CLIENT *c); bool CiLoadConfigurationFile(CLIENT *c); diff --git a/src/Cedar/Command.c b/src/Cedar/Command.c index 82120a07..52582fb1 100644 --- a/src/Cedar/Command.c +++ b/src/Cedar/Command.c @@ -916,14 +916,7 @@ void VpnCmdInitBootPath() { bool b = false; // Copy the vpncmdsys.exe to system32 - if (MsIsNt()) - { - Format(tmp, sizeof(tmp), "%s\\vpncmd.exe", MsGetSystem32Dir()); - } - else - { - Format(tmp, sizeof(tmp), "%s\\vpncmd.exe", MsGetWindowsDir()); - } + Format(tmp, sizeof(tmp), "%s\\vpncmd.exe", MsGetSystem32Dir()); if (MsIs64BitWindows() == false || Is64()) { @@ -24700,19 +24693,13 @@ void Win32CmdDebug(bool is_uac) UniPrint(_UU("CMD_DEBUG_PRINT")); - if (MsIsWin2000OrGreater() == false) - { - MsgBox(NULL, 0x00000040L, _UU("CMD_DEBUG_NOT_2000")); - goto LABEL_CLEANUP; - } - - if ((MsIsVista() == false || is_uac) && MsIsAdmin() == false) + if (is_uac && MsIsAdmin() == false) { MsgBox(NULL, 0x00000040L, _UU("CMD_DEBUG_NOT_ADMIN")); goto LABEL_CLEANUP; } - if (MsIsVista() && MsIsAdmin() == false) + if (MsIsAdmin() == false) { void *process_handle = NULL; diff --git a/src/Cedar/EM.c b/src/Cedar/EM.c index ee529211..cfc0bbcf 100644 --- a/src/Cedar/EM.c +++ b/src/Cedar/EM.c @@ -14,8 +14,8 @@ #define NM_C #define EM_C -#define _WIN32_WINNT 0x0502 -#define WINVER 0x0502 +#define _WIN32_WINNT 0x0600 +#define WINVER 0x0600 #include #include #include @@ -1120,32 +1120,23 @@ RES_ERROR: return; } - // Message after the end - if (OS_IS_WINDOWS_NT(GetOsInfo()->OsType) == false) + // Need to restart the service + if (MsgBox(hWnd, MB_ICONQUESTION | MB_YESNO, _UU("EM_WPCAP_REBOOT2")) == IDNO) { - // Need to restart the computer - MsgBox(hWnd, MB_ICONINFORMATION, _UU("EM_WPCAP_REBOOT1")); + // Not restart } else { - // Need to restart the service - if (MsgBox(hWnd, MB_ICONQUESTION | MB_YESNO, _UU("EM_WPCAP_REBOOT2")) == IDNO) - { - // Not restart - } - else - { - // Restart - RPC_TEST t; - RPC_BRIDGE_SUPPORT t2; - Zero(&t, sizeof(t)); - EcRebootServer(r, &t); + // Restart + RPC_TEST t; + RPC_BRIDGE_SUPPORT t2; + Zero(&t, sizeof(t)); + EcRebootServer(r, &t); - SleepThread(500); + SleepThread(500); - Zero(&t2, sizeof(t2)); - CALL(hWnd, EcGetBridgeSupport(r, &t2)); - } + Zero(&t2, sizeof(t2)); + CALL(hWnd, EcGetBridgeSupport(r, &t2)); } } diff --git a/src/Cedar/NM.c b/src/Cedar/NM.c index 61c98f0e..3e63738e 100644 --- a/src/Cedar/NM.c +++ b/src/Cedar/NM.c @@ -13,8 +13,8 @@ #define CM_C #define NM_C -#define _WIN32_WINNT 0x0502 -#define WINVER 0x0502 +#define _WIN32_WINNT 0x0600 +#define WINVER 0x0600 #include #include #include diff --git a/src/Cedar/Proto_Win7.c b/src/Cedar/Proto_Win7.c index 48b23aee..82e4e217 100644 --- a/src/Cedar/Proto_Win7.c +++ b/src/Cedar/Proto_Win7.c @@ -49,11 +49,6 @@ IPSEC_WIN7 *IPsecWin7Init() Debug("IPsecWin7Init()\n"); - if (MsIsVista() == false) - { - return NULL; - } - if (MsIsAdmin() == false) { return NULL; diff --git a/src/Cedar/SM.c b/src/Cedar/SM.c index c5716b4c..a2726969 100644 --- a/src/Cedar/SM.c +++ b/src/Cedar/SM.c @@ -13,8 +13,8 @@ #define CM_C #define NM_C -#define _WIN32_WINNT 0x0502 -#define WINVER 0x0502 +#define _WIN32_WINNT 0x0600 +#define WINVER 0x0600 #include #include #include @@ -834,10 +834,10 @@ void SmDDnsDlgInit(HWND hWnd, SM_DDNS *d) SetFont(hWnd, S_SUFFIX, GetFont("Verdana", 10, false, false, false, false)); SetFont(hWnd, E_NEWHOST, GetFont("Verdana", 10, false, false, false, false)); - SetFont(hWnd, E_HOST, GetFont((MsIsWinXPOrGreater() ? "Verdana" : NULL), 10, false, false, false, false)); - SetFont(hWnd, E_IPV4, GetFont((MsIsWinXPOrGreater() ? "Verdana" : NULL), 10, false, false, false, false)); - SetFont(hWnd, E_IPV6, GetFont((MsIsWinXPOrGreater() ? "Verdana" : NULL), 10, false, false, false, false)); - SetFont(hWnd, E_KEY, GetFont((MsIsWinXPOrGreater() ? "Verdana" : NULL), 8, false, false, false, false)); + SetFont(hWnd, E_HOST, GetFont("Verdana", 10, false, false, false, false)); + SetFont(hWnd, E_IPV4, GetFont("Verdana", 10, false, false, false, false)); + SetFont(hWnd, E_IPV6, GetFont("Verdana", 10, false, false, false, false)); + SetFont(hWnd, E_KEY, GetFont("Verdana", 8, false, false, false, false)); DlgFont(hWnd, IDOK, 0, true); @@ -1056,7 +1056,6 @@ void SmOpenVpn(HWND hWnd, SM_SERVER *s) UINT SmOpenVpnDlg(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam, void *param) { SM_SERVER *s = (SM_SERVER *)param; - char tmp[MAX_SIZE]; // Validate arguments if (hWnd == NULL) { @@ -1993,14 +1992,7 @@ void SmHubMsgDlgInit(HWND hWnd, SM_EDIT_HUB *s) return; } - if (MsIsVista()) - { - SetFont(hWnd, E_TEXT, GetMeiryoFont()); - } - else - { - DlgFont(hWnd, E_TEXT, 11, false); - } + SetFont(hWnd, E_TEXT, GetMeiryoFont()); FormatText(hWnd, S_MSG_2, s->HubName); @@ -8195,7 +8187,7 @@ void SmInstallWinPcap(HWND hWnd, SM_SERVER *s) UniFormat(temp_name, sizeof(temp_name), L"%s\\winpcap_installer.exe", MsGetTempDirW()); // Read from hamcore - buf = ReadDump(MsIsNt() ? "|winpcap_installer.exe" : "|winpcap_installer_win9x.exe"); + buf = ReadDump("|winpcap_installer.exe"); if (buf == NULL) { RES_ERROR: @@ -8231,31 +8223,22 @@ RES_ERROR: return; } - // Message after completed - if (OS_IS_WINDOWS_NT(GetOsInfo()->OsType) == false) + // Need to restart the service + if (MsgBox(hWnd, MB_ICONQUESTION | MB_YESNO, _UU("SM_BRIDGE_WPCAP_REBOOT2")) == IDNO) { - // Need to restart the computer - MsgBox(hWnd, MB_ICONINFORMATION, _UU("SM_BRIDGE_WPCAP_REBOOT1")); + // Not restart } else { - // Need to restart the service - if (MsgBox(hWnd, MB_ICONQUESTION | MB_YESNO, _UU("SM_BRIDGE_WPCAP_REBOOT2")) == IDNO) - { - // Not restart - } - else - { - // Restart - RPC_TEST t; - Zero(&t, sizeof(t)); - ScRebootServer(s->Rpc, &t); + // Restart + RPC_TEST t; + Zero(&t, sizeof(t)); + ScRebootServer(s->Rpc, &t); - SleepThread(500); + SleepThread(500); - Zero(&t, sizeof(t)); - CALL(hWnd, ScTest(s->Rpc, &t)); - } + Zero(&t, sizeof(t)); + CALL(hWnd, ScTest(s->Rpc, &t)); } } @@ -8517,14 +8500,14 @@ void SmCreateCertDlgInit(HWND hWnd, SM_CERT *s) } // Font - SetFont(hWnd, E_CN, GetFont((MsIsWinXPOrGreater() ? "Verdana" : NULL), 0, false, false, false, false)); - SetFont(hWnd, E_O, GetFont((MsIsWinXPOrGreater() ? "Verdana" : NULL), 0, false, false, false, false)); - SetFont(hWnd, E_OU, GetFont((MsIsWinXPOrGreater() ? "Verdana" : NULL), 0, false, false, false, false)); - SetFont(hWnd, E_C, GetFont((MsIsWinXPOrGreater() ? "Verdana" : NULL), 0, false, false, false, false)); - SetFont(hWnd, E_ST, GetFont((MsIsWinXPOrGreater() ? "Verdana" : NULL), 0, false, false, false, false)); - SetFont(hWnd, E_L, GetFont((MsIsWinXPOrGreater() ? "Verdana" : NULL), 0, false, false, false, false)); - SetFont(hWnd, E_SERIAL, GetFont((MsIsWinXPOrGreater() ? "Verdana" : NULL), 0, false, false, false, false)); - SetFont(hWnd, E_EXPIRE, GetFont((MsIsWinXPOrGreater() ? "Verdana" : NULL), 0, false, false, false, false)); + SetFont(hWnd, E_CN, GetFont("Verdana", 0, false, false, false, false)); + SetFont(hWnd, E_O, GetFont("Verdana", 0, false, false, false, false)); + SetFont(hWnd, E_OU, GetFont("Verdana", 0, false, false, false, false)); + SetFont(hWnd, E_C, GetFont("Verdana", 0, false, false, false, false)); + SetFont(hWnd, E_ST, GetFont("Verdana", 0, false, false, false, false)); + SetFont(hWnd, E_L, GetFont("Verdana", 0, false, false, false, false)); + SetFont(hWnd, E_SERIAL, GetFont("Verdana", 0, false, false, false, false)); + SetFont(hWnd, E_EXPIRE, GetFont("Verdana", 0, false, false, false, false)); SetFont(hWnd, C_BITS, GetFont("Verdana", 0, false, false, false, false)); FocusEx(hWnd, E_CN); @@ -18681,7 +18664,6 @@ UINT SmServerDlgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam, void *pa case B_APPLY: { // Apply UDP ports - bool ret; LIST* ports; RPC_PORTS t; char tmp[MAX_SIZE]; diff --git a/src/Cedar/SW.c b/src/Cedar/SW.c index ae3ebae7..ae089d1b 100644 --- a/src/Cedar/SW.c +++ b/src/Cedar/SW.c @@ -14,8 +14,8 @@ #define NM_C #define SW_C -#define _WIN32_WINNT 0x0502 -#define WINVER 0x0502 +#define _WIN32_WINNT 0x0600 +#define WINVER 0x0600 #include #include #include @@ -1188,15 +1188,7 @@ void SwLang1Init(HWND hWnd, SW *sw) UniFormat(tmp, sizeof(tmp), L"%s (%s)", t.TitleEnglish, t.TitleLocal); SetText(hWnd, E_CURRENT, tmp); - - if (MsIsVista()) - { - SetFont(hWnd, E_CURRENT, GetMeiryoFontEx(11)); - } - else - { - DlgFont(hWnd, E_CURRENT, 11, false); - } + SetFont(hWnd, E_CURRENT, GetMeiryoFontEx(11)); } } @@ -1239,14 +1231,7 @@ UINT SwLang1(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam, WIZARD *wizard, case WM_INITDIALOG: LvInitEx2(hWnd, L_LIST, false, true); - if (MsIsVista()) - { - SetFont(hWnd, L_LIST, GetMeiryoFontEx(12)); - } - else - { - DlgFont(hWnd, L_LIST, 12, false); - } + SetFont(hWnd, L_LIST, GetMeiryoFontEx(12)); LvInsertColumn(hWnd, L_LIST, 0, L"English Name", 250); LvInsertColumn(hWnd, L_LIST, 1, L"Local Name", 250); @@ -1276,14 +1261,6 @@ UINT SwLang1(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam, WIZARD *wizard, break; } - if (MsIsNt() == false) - { - // Win9x - MsgBox(hWnd, MB_ICONSTOP, - L"Windows 9x / Me doesn't support multi-language switcing.\r\n\r\nIf you want to switch to another language, please use Windows NT 4.0, 2000 or greater."); - break; - } - // Get the current selection id = (UINT)LvGetSelectedParam(hWnd, L_LIST); if (id != 0) @@ -1375,35 +1352,27 @@ LABEL_RUN_CHILD_PROCESS: // In the case of system mode if (MsIsAdmin() == false) { - if (MsIsVista()) + if (sw->IsReExecForUac == false) { - if (sw->IsReExecForUac == false) - { - // If there is no Admin privileges in Vista or later, attempt to acquire Admin rights by UAC first during the first run - UniStrCat(add_param, sizeof(add_param), L" /SETLANGANDREBOOT:true"); + // If there is no Admin privileges in Vista or later, attempt to acquire Admin rights by UAC first during the first run + UniStrCat(add_param, sizeof(add_param), L" /SETLANGANDREBOOT:true"); - if (SwReExecMyself(sw, add_param, true)) - { - // Terminate itself if it succeeds to start the child process - CloseWizard(wizard_page); - break; - } - else - { - // Do nothing if it fails to start in the UAC - sw->DoubleClickBlocker = false; - break; - } + if (SwReExecMyself(sw, add_param, true)) + { + // Terminate itself if it succeeds to start the child process + CloseWizard(wizard_page); + break; } else { - // If no Admin privileges after being started by the UAC, jump to the guidance screen indicating it is not Admin - return D_SW_NOT_ADMIN; + // Do nothing if it fails to start in the UAC + sw->DoubleClickBlocker = false; + break; } } else { - // Jump to guide screen indicating that it is not the Admin in the case of XP or earlier + // If no Admin privileges after being started by the UAC, jump to the guidance screen indicating it is not Admin return D_SW_NOT_ADMIN; } } @@ -1507,32 +1476,24 @@ UINT SwUninst1(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam, WIZARD *wizard // In the case of system mode if (MsIsAdmin() == false) { - if (MsIsVista()) + if (sw->IsReExecForUac == false) { - if (sw->IsReExecForUac == false) + // If there is no Admin privileges in Vista or later, attempt to acquire Admin rights by UAC first during the first run + if (SwReExecMyself(sw, NULL, true)) { - // If there is no Admin privileges in Vista or later, attempt to acquire Admin rights by UAC first during the first run - if (SwReExecMyself(sw, NULL, true)) - { - // Terminate itself if it succeeds to start the child process - CloseWizard(wizard_page); - break; - } - else - { - // If fail to run in UAC, jump to guide screen indicating that it is not Admin - return D_SW_NOT_ADMIN; - } + // Terminate itself if it succeeds to start the child process + CloseWizard(wizard_page); + break; } else { - // If no Admin privileges after being started by the UAC, jump to the guidance screen indicating it is not Admin + // If fail to run in UAC, jump to guide screen indicating that it is not Admin return D_SW_NOT_ADMIN; } } else { - // Jump to guide screen indicating that it is not the Admin in the case of XP or earlier + // If no Admin privileges after being started by the UAC, jump to the guidance screen indicating it is not Admin return D_SW_NOT_ADMIN; } } @@ -1987,7 +1948,7 @@ bool SwUninstallMain(SW *sw, WIZARD_PAGE *wp, SW_COMPONENT *c) if (UniIsEmptyStr(svc_title) == false) { - if (sw->IsSystemMode && MsIsNt()) + if (sw->IsSystemMode) { // WinNT and system mode if (MsIsServiceRunning(c->SvcName)) @@ -2157,17 +2118,7 @@ LABEL_RETRY_1: if (UniIsEmptyStr(svc_title) == false) { - if (sw->IsSystemMode == false || MsIsNt() == false) - { - // Win9x or user mode - if (MsIsNt() == false) - { - // Remove the Run key from the registry for Win9x - MsRegDeleteValue(REG_LOCAL_MACHINE, WIN9X_SVC_REGKEY_1, c->SvcName); - MsRegDeleteValue(REG_LOCAL_MACHINE, WIN9X_SVC_REGKEY_2, c->SvcName); - } - } - else + if (sw->IsSystemMode) { // System mode UniFormat(tmp, sizeof(tmp), _UU("SW_PERFORM_MSG_UNINSTALL_SVC"), svc_title); @@ -2437,19 +2388,17 @@ void SwDefineTasks(SW *sw, SW_TASK *t, SW_COMPONENT *c) _UU("SW_LINK_NAME_TCP"), _UU("SW_LINK_NAME_TCP_COMMENT"), false)); - if (MsIsWin2000OrGreater()) - { - Add(t->LinkTasks, SwNewLinkTask(MsGetSystem32DirW(), L"services.msc", NULL, L"filemgmt.dll", 0, dir_config_program, - _UU("SW_LINK_NAME_SERVICES"), - _UU("SW_LINK_NAME_SERVICES_COMMENT"), false)); - if (sw->IsSystemMode) - { - // Debugging information collecting tool - Add(t->LinkTasks, SwNewLinkTask(sw->InstallDir, vpncmd->DstFileName, L"/debug", L"vpnsetup.exe", 4, dir_admin_tools, - _UU("SW_LINK_NAME_DEBUG"), - _UU("SW_LINK_NAME_DEBUG_COMMENT"), false)); - } + Add(t->LinkTasks, SwNewLinkTask(MsGetSystem32DirW(), L"services.msc", NULL, L"filemgmt.dll", 0, dir_config_program, + _UU("SW_LINK_NAME_SERVICES"), + _UU("SW_LINK_NAME_SERVICES_COMMENT"), false)); + + if (sw->IsSystemMode) + { + // Debugging information collecting tool + Add(t->LinkTasks, SwNewLinkTask(sw->InstallDir, vpncmd->DstFileName, L"/debug", L"vpnsetup.exe", 4, dir_admin_tools, + _UU("SW_LINK_NAME_DEBUG"), + _UU("SW_LINK_NAME_DEBUG_COMMENT"), false)); } if (sw->IsSystemMode == false) @@ -2508,19 +2457,16 @@ void SwDefineTasks(SW *sw, SW_TASK *t, SW_COMPONENT *c) _UU("SW_LINK_NAME_TCP"), _UU("SW_LINK_NAME_TCP_COMMENT"), false)); - if (MsIsWin2000OrGreater()) - { - Add(t->LinkTasks, SwNewLinkTask(MsGetSystem32DirW(), L"services.msc", NULL, L"filemgmt.dll", 0, dir_config_program, - _UU("SW_LINK_NAME_SERVICES"), - _UU("SW_LINK_NAME_SERVICES_COMMENT"), false)); + Add(t->LinkTasks, SwNewLinkTask(MsGetSystem32DirW(), L"services.msc", NULL, L"filemgmt.dll", 0, dir_config_program, + _UU("SW_LINK_NAME_SERVICES"), + _UU("SW_LINK_NAME_SERVICES_COMMENT"), false)); - if (sw->IsSystemMode) - { - // Debugging information collecting tool - Add(t->LinkTasks, SwNewLinkTask(sw->InstallDir, vpncmd->DstFileName, L"/debug", L"vpnsetup.exe", 4, dir_admin_tools, - _UU("SW_LINK_NAME_DEBUG"), - _UU("SW_LINK_NAME_DEBUG_COMMENT"), false)); - } + if (sw->IsSystemMode) + { + // Debugging information collecting tool + Add(t->LinkTasks, SwNewLinkTask(sw->InstallDir, vpncmd->DstFileName, L"/debug", L"vpnsetup.exe", 4, dir_admin_tools, + _UU("SW_LINK_NAME_DEBUG"), + _UU("SW_LINK_NAME_DEBUG_COMMENT"), false)); } if (sw->IsSystemMode == false) @@ -2621,32 +2567,26 @@ void SwDefineTasks(SW *sw, SW_TASK *t, SW_COMPONENT *c) _UU("SW_LINK_NAME_TCP"), _UU("SW_LINK_NAME_TCP_COMMENT"), false)); - if (MsIsWin2000OrGreater()) - { - Add(t->LinkTasks, SwNewLinkTask(MsGetSystem32DirW(), L"services.msc", NULL, L"filemgmt.dll", 0, dir_config_program, - _UU("SW_LINK_NAME_SERVICES"), - _UU("SW_LINK_NAME_SERVICES_COMMENT"), false)); + Add(t->LinkTasks, SwNewLinkTask(MsGetSystem32DirW(), L"services.msc", NULL, L"filemgmt.dll", 0, dir_config_program, + _UU("SW_LINK_NAME_SERVICES"), + _UU("SW_LINK_NAME_SERVICES_COMMENT"), false)); - if (sw->IsSystemMode) - { - // Debugging information collecting tool - Add(t->LinkTasks, SwNewLinkTask(sw->InstallDir, vpncmd->DstFileName, L"/debug", L"vpnsetup.exe", 4, dir_admin_tools, - _UU("SW_LINK_NAME_DEBUG"), - _UU("SW_LINK_NAME_DEBUG_COMMENT"), false)); - } + if (sw->IsSystemMode) + { + // Debugging information collecting tool + Add(t->LinkTasks, SwNewLinkTask(sw->InstallDir, vpncmd->DstFileName, L"/debug", L"vpnsetup.exe", 4, dir_admin_tools, + _UU("SW_LINK_NAME_DEBUG"), + _UU("SW_LINK_NAME_DEBUG_COMMENT"), false)); } // Programs\PacketiX VPN Client\System administrators tool - if (MsIsNt()) - { - Add(t->LinkTasks, SwNewLinkTask(sw->InstallDir, L"vpnsetup.exe", L"/easy:true", L"vpnsetup.exe", 12, dir_admin_tools, - _UU("SW_LINK_NAME_EASYINSTALLER"), - _UU("SW_LINK_NAME_EASYINSTALLER_COMMENT"), false)); + Add(t->LinkTasks, SwNewLinkTask(sw->InstallDir, L"vpnsetup.exe", L"/easy:true", L"vpnsetup.exe", 12, dir_admin_tools, + _UU("SW_LINK_NAME_EASYINSTALLER"), + _UU("SW_LINK_NAME_EASYINSTALLER_COMMENT"), false)); - Add(t->LinkTasks, SwNewLinkTask(sw->InstallDir, L"vpnsetup.exe", L"/web:true", L"vpnsetup.exe", 1, dir_admin_tools, - _UU("SW_LINK_NAME_WEBINSTALLER"), - _UU("SW_LINK_NAME_WEBINSTALLER_COMMENT"), false)); - } + Add(t->LinkTasks, SwNewLinkTask(sw->InstallDir, L"vpnsetup.exe", L"/web:true", L"vpnsetup.exe", 1, dir_admin_tools, + _UU("SW_LINK_NAME_WEBINSTALLER"), + _UU("SW_LINK_NAME_WEBINSTALLER_COMMENT"), false)); // Startup Add(t->LinkTasks, SwNewLinkTask(sw->InstallDir, vpncmgr->DstFileName, L"/startup", NULL, 0, dir_startup, @@ -2717,16 +2657,13 @@ void SwDefineTasks(SW *sw, SW_TASK *t, SW_COMPONENT *c) tmp1, tmp2, false)); - // Language settings (except for Win9x) - if (MsIsNt()) - { - UniFormat(tmp1, sizeof(tmp1), _UU("SW_LINK_NAME_LANGUAGE"), c->Title); - UniFormat(tmp2, sizeof(tmp2), _UU("SW_LINK_NAME_LANGUAGE_COMMENT"), c->Title); - Add(t->LinkTasks, SwNewLinkTask(setup_exe->DstDir, setup_exe->DstFileName, L"/language:yes", - L"vpnsetup.exe", 10, dir_config_language, - tmp1, - tmp2, false)); - } + // Language settings + UniFormat(tmp1, sizeof(tmp1), _UU("SW_LINK_NAME_LANGUAGE"), c->Title); + UniFormat(tmp2, sizeof(tmp2), _UU("SW_LINK_NAME_LANGUAGE_COMMENT"), c->Title); + Add(t->LinkTasks, SwNewLinkTask(setup_exe->DstDir, setup_exe->DstFileName, L"/language:yes", + L"vpnsetup.exe", 10, dir_config_language, + tmp1, + tmp2, false)); // Hamcore! Add(t->CopyTasks, SwNewCopyTask(L"hamcore.se2", NULL, sw->InstallSrc, sw->InstallDir, true, true)); @@ -3082,7 +3019,7 @@ bool SwInstallMain(SW *sw, WIZARD_PAGE *wp, SW_COMPONENT *c) if (UniIsEmptyStr(svc_title) == false) { - if (sw->IsSystemMode && MsIsNt()) + if (sw->IsSystemMode) { // WinNT and system mode if (MsIsServiceRunning(c->SvcName)) @@ -3337,7 +3274,7 @@ LABEL_RETRY_2: } - if (sw->IsSystemMode && MsIsNt()) + if (sw->IsSystemMode) { // ACL settings only in the system mode for (i = 0;i < LIST_NUM(t->SetSecurityPaths);i++) @@ -3398,7 +3335,7 @@ LABEL_RETRY_2: if (UniIsEmptyStr(svc_title) == false) { - if (sw->IsSystemMode == false || MsIsNt() == false) + if (sw->IsSystemMode == false) { // Just simply start in user mode or Win9x mode wchar_t fullpath[MAX_SIZE]; @@ -3407,7 +3344,7 @@ LABEL_RETRY_USERMODE_EXEC: CombinePathW(fullpath, sizeof(fullpath), sw->InstallDir, c->SvcFileName); - if (MsExecuteW(fullpath, (MsIsNt() ? L"/usermode" : L"/win9x_service")) == false) + if (MsExecuteW(fullpath, L"/usermode") == false) { UniFormat(tmp, sizeof(tmp), _UU("SW_PERFORM_MSG_SVC_USERMODE_EXEC_FAILED"), fullpath); @@ -3422,19 +3359,6 @@ LABEL_RETRY_USERMODE_EXEC: goto LABEL_RETRY_USERMODE_EXEC; } } - else - { - if (MsIsNt() == false) - { - // Register into the registry as a background service in the case of Win9x - wchar_t fullpath2[MAX_SIZE]; - - UniFormat(fullpath2, sizeof(fullpath2), L"\"%s\" /win9x_service", fullpath); - - MsRegWriteStrW(REG_LOCAL_MACHINE, WIN9X_SVC_REGKEY_1, c->SvcName, fullpath2); - MsRegWriteStrW(REG_LOCAL_MACHINE, WIN9X_SVC_REGKEY_2, c->SvcName, fullpath2); - } - } } else { @@ -3565,7 +3489,7 @@ LABEL_CREATE_SHORTCUT: if (UniIsEmptyStr(svc_description) == false) { - if (sw->IsSystemMode && MsIsNt()) + if (sw->IsSystemMode) { MsSetServiceDescription(c->SvcName, svc_description); } @@ -4306,17 +4230,9 @@ void SwPerformInit(HWND hWnd, SW *sw, WIZARD_PAGE *wp) SetTextA(hWnd, S_STATUS, ""); - if (MsIsWinXPOrWinVista()) - { - // Display the progress bar for Windows XP or later - SendMsg(hWnd, IDC_PROGRESS1, PBM_SETMARQUEE, TRUE, 100); - SetStyle(hWnd, IDC_PROGRESS1, PBS_MARQUEE); - } - else - { - // Hide the progress bar in the case of Windows 2000 or earlier - Hide(hWnd, IDC_PROGRESS1); - } + // Display the progress bar + SendMsg(hWnd, IDC_PROGRESS1, PBM_SETMARQUEE, TRUE, 100); + SetStyle(hWnd, IDC_PROGRESS1, PBS_MARQUEE); } // Do the set-up process @@ -4572,22 +4488,11 @@ void SwInitDefaultInstallDir(SW *sw) UniStrCpy(sw->DefaultInstallDir_User, sizeof(sw->DefaultInstallDir_User), reg_dir_user); } - if (MsIsNt() == false) - { - // Set to system mode for Win9x - sw->IsSystemMode = true; - } - if (MsIsAdmin() == false) { sw->IsAvailableSystemMode = false; sw->IsAvailableUserMode = true; } - else if (MsIsNt() == false) - { - sw->IsAvailableSystemMode = true; - sw->IsAvailableUserMode = false; - } else { sw->IsAvailableSystemMode = true; @@ -5272,16 +5177,8 @@ UINT SwComponents(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam, WIZARD *wiz case WM_INITDIALOG: LvInitEx2(hWnd, L_LIST, false, true); - if (MsIsVista()) - { - SetFont(hWnd, L_LIST, GetMeiryoFontEx(12)); - SetFont(hWnd, S_TITLE, GetMeiryoFontEx(11)); - } - else - { - DlgFont(hWnd, L_LIST, 12, false); - DlgFont(hWnd, S_TITLE, 11, false); - } + SetFont(hWnd, L_LIST, GetMeiryoFontEx(12)); + SetFont(hWnd, S_TITLE, GetMeiryoFontEx(11)); LvInsertColumn(hWnd, L_LIST, 0, L"Component", 515); break; @@ -5306,13 +5203,6 @@ UINT SwComponents(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam, WIZARD *wiz if (c != NULL) { - if (SwCheckOs(sw, c) == false) - { - // OS Check Failed - MsgBoxEx(hWnd, MB_ICONEXCLAMATION, _UU("SW_OS_FAILED"), c->Title); - break; - } - sw->CurrentComponent = c; if (sw->CurrentComponent->SystemModeOnly == false || MsIsAdmin()) @@ -5480,7 +5370,7 @@ UINT SwModeDlg(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam, WIZARD *wizard if (sw->IsSystemMode) { - if (MsIsVista() && MsIsAdmin() == false && sw->IsReExecForUac == false) + if (MsIsAdmin() == false && sw->IsReExecForUac == false) { // If UAC is available and this isn't invoked via UAC, // give the user a chance to get administrator privileges on UAC start again @@ -5579,33 +5469,25 @@ UINT SwWelcomeDlg(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam, WIZARD *wiz if (MsIsAdmin() == false) { - if (MsIsVista()) + if (sw->IsReExecForUac == false) { - if (sw->IsReExecForUac == false) + // If there is no Admin privileges in Vista or later, attempt to acquire Admin rights by UAC first during the first run + if (SwReExecMyself(sw, NULL, true)) { - // If there is no Admin privileges in Vista or later, attempt to acquire Admin rights by UAC first during the first run - if (SwReExecMyself(sw, NULL, true)) - { - // Terminate itself if it succeeds to start the child process - CloseWizard(wizard_page); - break; - } - else - { - // Jump to mode selection screen if it fails to start the - // child process (including user presses the cancel of UAC) - return D_SW_MODE; - } + // Terminate itself if it succeeds to start the child process + CloseWizard(wizard_page); + break; } else { - // Jump to mode selection screen when the user don't have Admin rights after being activated by UAC + // Jump to mode selection screen if it fails to start the + // child process (including user presses the cancel of UAC) return D_SW_MODE; } } else { - // Jump to the mode selection screen in the case of older than Vista + // Jump to mode selection screen when the user don't have Admin rights after being activated by UAC return D_SW_MODE; } } @@ -5710,10 +5592,7 @@ void SwUiMain(SW *sw) AddWizardPage(w, NewWizardPage(D_SW_WEB1, SwWeb1, _UU("SW_WEB1_TITLE"))); AddWizardPage(w, NewWizardPage(D_SW_WEB2, SwWeb2, _UU("SW_WEB2_TITLE"))); - if (MsIsVista()) - { - w->IsAreoStyle = true; - } + w->IsAreoStyle = true; if (sw->UninstallMode) { @@ -5984,48 +5863,6 @@ SW_COMPONENT *SwNewComponent(char *name, char *svc_name, UINT id, UINT icon, UIN return c; } -// Examine the OS requirements -bool SwCheckOs(SW *sw, SW_COMPONENT *c) -{ - // Validate arguments - if (sw == NULL || c == NULL) - { - return false; - } - - if (c->Id == SW_CMP_VPN_CLIENT) - { - OS_INFO *info = GetOsInfo(); - - if (OS_IS_WINDOWS_NT(info->OsType)) - { - if (MsIsWin2000OrGreater() == false) - { - // It doesn't work with WinNT 4.0 - return false; - } - } - else - { - if (GET_KETA(info->OsType, 100) <= 1) - { - // It doesn't work with Win95 - return false; - } - else if (info->OsType == OSTYPE_WINDOWS_98) - { - if (EndWith(info->OsVersion, "A") == false) - { - // It doesn't work in Win98 First Edition - return false; - } - } - } - } - - return true; -} - // Define the component void SwDefineComponents(SW *sw) { diff --git a/src/Cedar/SWInner.h b/src/Cedar/SWInner.h index a1617ddf..cf22ac2c 100644 --- a/src/Cedar/SWInner.h +++ b/src/Cedar/SWInner.h @@ -287,8 +287,6 @@ void SwFreeLogFile(SW_LOGFILE *logfile); void SwInstallShortcuts(SW *sw, WIZARD_PAGE *wp, SW_COMPONENT *c, SW_TASK *t); void SwDeleteShortcuts(SW_LOGFILE *logfile); -bool SwCheckOs(SW *sw, SW_COMPONENT *c); - bool SwEnterSingle(SW *sw); void SwLeaveSingle(SW *sw); diff --git a/src/Cedar/Server.c b/src/Cedar/Server.c index 75a648ca..42b987e3 100644 --- a/src/Cedar/Server.c +++ b/src/Cedar/Server.c @@ -1578,7 +1578,7 @@ void GetServerCapsMain(SERVER *s, CAPSLIST *t) AddCapsBool(t, "b_support_ipv6_ac", true); // Support for VLAN tagged packet transmission configuration tool - AddCapsBool(t, "b_support_eth_vlan", (OS_IS_WINDOWS_NT(GetOsType()) && GET_KETA(GetOsType(), 100) >= 2)); + AddCapsBool(t, "b_support_eth_vlan", true); // Support for the message display function when the VPN connect to the Virtual HUB AddCapsBool(t, "b_support_msg", true); diff --git a/src/Cedar/Session.c b/src/Cedar/Session.c index 21b6aefe..3f80511d 100644 --- a/src/Cedar/Session.c +++ b/src/Cedar/Session.c @@ -1913,12 +1913,6 @@ SESSION *NewClientSessionEx(CEDAR *cedar, CLIENT_OPTION *option, CLIENT_AUTH *au s->VirtualHost = true; } - if (OS_IS_WINDOWS_9X(GetOsInfo()->OsType)) - { - // Prohibit the half-duplex mode in the case of Win9x - s->ClientOption->HalfConnection = false; - } - // Copy the client authentication data s->ClientAuth = Malloc(sizeof(CLIENT_AUTH)); Copy(s->ClientAuth, auth, sizeof(CLIENT_AUTH)); diff --git a/src/Cedar/UT.c b/src/Cedar/UT.c index 27873169..2149e08e 100644 --- a/src/Cedar/UT.c +++ b/src/Cedar/UT.c @@ -11,8 +11,8 @@ #define UT_C -#define _WIN32_WINNT 0x0502 -#define WINVER 0x0502 +#define _WIN32_WINNT 0x0600 +#define WINVER 0x0600 #include #include #include diff --git a/src/Cedar/VLanWin32.c b/src/Cedar/VLanWin32.c index 5932af27..fc094fc4 100644 --- a/src/Cedar/VLanWin32.c +++ b/src/Cedar/VLanWin32.c @@ -37,26 +37,8 @@ void Win32GetWinVer(RPC_WINVER *v) v->IsWindows = true; - if (OS_IS_WINDOWS_NT(GetOsType()) == false) + if (true) { - // Windows 9x - OSVERSIONINFO os; - Zero(&os, sizeof(os)); - os.dwOSVersionInfoSize = sizeof(os); - GetVersionEx(&os); - - v->Build = LOWORD(os.dwBuildNumber); - v->VerMajor = os.dwMajorVersion; - v->VerMinor = os.dwMinorVersion; - - Format(v->Title, sizeof(v->Title), "%s %s", - GetOsInfo()->OsProductName, - GetOsInfo()->OsVersion); - Trim(v->Title); - } - else - { - // Windows NT 4.0 SP6 or later OSVERSIONINFOEX os; Zero(&os, sizeof(os)); os.dwOSVersionInfoSize = sizeof(os); @@ -93,31 +75,6 @@ void Win32GetWinVer(RPC_WINVER *v) } } -// Release the DHCP addresses of all virtual LAN cards -void Win32ReleaseAllDhcp9x(bool wait) -{ - TOKEN_LIST *t; - UINT i; - - t = MsEnumNetworkAdapters(VLAN_ADAPTER_NAME, VLAN_ADAPTER_NAME_OLD); - if (t == NULL) - { - return; - } - - for (i = 0;i < t->NumTokens;i++) - { - char *name = t->Token[i]; - UINT id = GetInstanceId(name); - if (id != 0) - { - Win32ReleaseDhcp9x(id, wait); - } - } - - FreeToken(t); -} - // Routing table tracking main void RouteTrackingMain(SESSION *s) { @@ -311,7 +268,7 @@ void RouteTrackingMain(SESSION *s) if (other_if_default_gateway_metric_min > e->Metric) { // Ignore the metric value of all PPP connection in the case of Windows Vista - if (MsIsVista() == false || e->PPPConnection == false) + if (e->PPPConnection == false) { other_if_default_gateway_metric_min = e->Metric; } @@ -513,12 +470,9 @@ void RouteTrackingStart(SESSION *s) if_id = GetInstanceId(v->InstanceName); Debug("[InstanceId of %s] = 0x%x\n", v->InstanceName, if_id); - if (MsIsVista()) - { - // The routing table by the virtual LAN card body should be - // excluded explicitly in Windows Vista - exclude_if_id = if_id; - } + // The routing table by the virtual LAN card body should be + // excluded explicitly in Windows Vista + exclude_if_id = if_id; // Get the route to the server e = GetBestRouteEntryEx(&s->ServerIP, exclude_if_id); @@ -532,10 +486,8 @@ void RouteTrackingStart(SESSION *s) Debug("GetBestRouteEntry() Succeed. [Gateway: %s]\n", tmp); // Add a route - if (MsIsVista()) - { - e->Metric = e->OldIfMetric; - } + e->Metric = e->OldIfMetric; + if (AddRouteEntryEx(e, &already_exists) == false) { FreeRouteEntry(e); @@ -597,15 +549,12 @@ void RouteTrackingStart(SESSION *s) else { // Add a route - if (MsIsVista()) - { - dns->Metric = dns->OldIfMetric; + dns->Metric = dns->OldIfMetric; - if (AddRouteEntry(dns) == false) - { - FreeRouteEntry(dns); - dns = NULL; - } + if (AddRouteEntry(dns) == false) + { + FreeRouteEntry(dns); + dns = NULL; } } } @@ -620,10 +569,7 @@ void RouteTrackingStart(SESSION *s) if (route_to_real_server_global != NULL) { - if (MsIsVista()) - { - route_to_real_server_global->Metric = route_to_real_server_global->OldIfMetric; - } + route_to_real_server_global->Metric = route_to_real_server_global->OldIfMetric; if (AddRouteEntry(route_to_real_server_global) == false) { @@ -717,21 +663,6 @@ void RouteTrackingStop(SESSION *s, ROUTE_TRACKING *t) Zero(&dns_ip, sizeof(dns_ip)); - // Remove the default gateway added by the virtual LAN card - if (MsIsVista() == false) - { - if (t->DefaultGatewayByVLan != NULL) - { - Debug("Default Gateway by VLAN was deleted.\n"); - DeleteRouteEntry(t->DefaultGatewayByVLan); - } - - if (t->VistaOldDefaultGatewayByVLan != NULL) - { - FreeRouteEntry(t->VistaOldDefaultGatewayByVLan); - } - } - if (t->DefaultGatewayByVLan != NULL) { FreeRouteEntry(t->DefaultGatewayByVLan); @@ -748,12 +679,6 @@ void RouteTrackingStop(SESSION *s, ROUTE_TRACKING *t) FreeRouteEntry(t->VistaDefaultGateway2); } - if (MsIsNt() == false) - { - // Only in the case of Windows 9x, release the DHCP address of the virtual LAN card - Win32ReleaseDhcp9x(t->VLanInterfaceId, false); - } - // Clear the DNS cache Win32FlushDnsCache(); @@ -1130,11 +1055,8 @@ bool VLanPaInit(SESSION *s) // Normalize the setting of interface metric of the default gateway if (s->ClientModeAndUseVLan) { - if (MsIsVista()) - { - MsNormalizeInterfaceDefaultGatewaySettings(VLAN_ADAPTER_NAME_TAG, s->ClientOption->DeviceName); - MsNormalizeInterfaceDefaultGatewaySettings(VLAN_ADAPTER_NAME_TAG_OLD, s->ClientOption->DeviceName); - } + MsNormalizeInterfaceDefaultGatewaySettings(VLAN_ADAPTER_NAME_TAG, s->ClientOption->DeviceName); + MsNormalizeInterfaceDefaultGatewaySettings(VLAN_ADAPTER_NAME_TAG_OLD, s->ClientOption->DeviceName); } // Connect to the driver @@ -1288,33 +1210,19 @@ bool VLanPutPacketsToDriver(VLAN *v) return false; } - if (v->Win9xMode == false) + PROBE_STR("VLanPutPacketsToDriver: WriteFile"); + if (WriteFile(v->Handle, v->PutBuffer, NEO_EXCHANGE_BUFFER_SIZE, &write_size, + NULL) == false) { - // Windows NT - PROBE_STR("VLanPutPacketsToDriver: WriteFile"); - if (WriteFile(v->Handle, v->PutBuffer, NEO_EXCHANGE_BUFFER_SIZE, &write_size, - NULL) == false) - { - v->Halt = true; - return false; - } - PROBE_STR("VLanPutPacketsToDriver: WriteFile Completed."); - - if (write_size != NEO_EXCHANGE_BUFFER_SIZE) - { - v->Halt = true; - return false; - } + v->Halt = true; + return false; } - else + PROBE_STR("VLanPutPacketsToDriver: WriteFile Completed."); + + if (write_size != NEO_EXCHANGE_BUFFER_SIZE) { - // Windows 9x - if (DeviceIoControl(v->Handle, NEO_IOCTL_PUT_PACKET, v->PutBuffer, - NEO_EXCHANGE_BUFFER_SIZE, NULL, 0, &write_size, NULL) == false) - { - v->Halt = true; - return false; - } + v->Halt = true; + return false; } return true; @@ -1334,26 +1242,12 @@ bool VLanGetPacketsFromDriver(VLAN *v) return false; } - if (v->Win9xMode == false) + PROBE_STR("VLanGetPacketsFromDriver: ReadFile"); + if (ReadFile(v->Handle, v->GetBuffer, NEO_EXCHANGE_BUFFER_SIZE, + &read_size, NULL) == false) { - // Windows NT - PROBE_STR("VLanGetPacketsFromDriver: ReadFile"); - if (ReadFile(v->Handle, v->GetBuffer, NEO_EXCHANGE_BUFFER_SIZE, - &read_size, NULL) == false) - { - v->Halt = true; - return false; - } - } - else - { - // Windows 9x - if (DeviceIoControl(v->Handle, NEO_IOCTL_GET_PACKET, NULL, 0, - v->GetBuffer, NEO_EXCHANGE_BUFFER_SIZE, &read_size, NULL) == false) - { - v->Halt = true; - return false; - } + v->Halt = true; + return false; } if (read_size != NEO_EXCHANGE_BUFFER_SIZE) @@ -1423,23 +1317,14 @@ VLAN *NewVLan(char *instance_name, VLAN_PARAM *param) v = ZeroMalloc(sizeof(VLAN)); - if (OS_IS_WINDOWS_9X(GetOsInfo()->OsType)) - { - v->Win9xMode = true; - } - // Initialize the name Format(name_upper, sizeof(name_upper), "%s", instance_name); StrUpper(name_upper); v->InstanceName = CopyStr(name_upper); Format(tmp, sizeof(tmp), NDIS_NEO_DEVICE_FILE_NAME, v->InstanceName); v->DeviceNameWin32 = CopyStr(tmp); - - if (v->Win9xMode == false) - { - Format(tmp, sizeof(tmp), NDIS_NEO_EVENT_NAME_WIN32, v->InstanceName); - v->EventNameWin32 = CopyStr(tmp); - } + Format(tmp, sizeof(tmp), NDIS_NEO_EVENT_NAME_WIN32, v->InstanceName); + v->EventNameWin32 = CopyStr(tmp); // Connect to the device h = CreateFile(v->DeviceNameWin32, @@ -1455,31 +1340,12 @@ VLAN *NewVLan(char *instance_name, VLAN_PARAM *param) goto CLEANUP; } - if (v->Win9xMode == false) + // Connect to the event + e = OpenEvent(SYNCHRONIZE, FALSE, v->EventNameWin32); + if (e == INVALID_HANDLE_VALUE) { - // Connect to the event - e = OpenEvent(SYNCHRONIZE, FALSE, v->EventNameWin32); - if (e == INVALID_HANDLE_VALUE) - { - // Connection failure - goto CLEANUP; - } - } - else - { - OPENVXDHANDLE OpenVxDHandle; - DWORD vxd_handle; - UINT bytes_returned; - - OpenVxDHandle = (OPENVXDHANDLE)GetProcAddress(GetModuleHandle("KERNEL32"), - "OpenVxDHandle"); - - // Deliver to the driver by creating an event - e = CreateEvent(NULL, FALSE, FALSE, NULL); - vxd_handle = (DWORD)OpenVxDHandle(e); - - DeviceIoControl(h, NEO_IOCTL_SET_EVENT, &vxd_handle, sizeof(DWORD), - NULL, 0, &bytes_returned, NULL); + // Connection failure + goto CLEANUP; } v->Event = e; diff --git a/src/Cedar/VLanWin32.h b/src/Cedar/VLanWin32.h index 2e8c092c..3bdee0b0 100644 --- a/src/Cedar/VLanWin32.h +++ b/src/Cedar/VLanWin32.h @@ -44,7 +44,6 @@ struct ROUTE_TRACKING struct VLAN { volatile bool Halt; // Halting flag - bool Win9xMode; // Windows 9x char *InstanceName; // Instance name char *DeviceNameWin32; // Win32 device name char *EventNameWin32; // Win32 event name @@ -87,7 +86,6 @@ UINT GetInstanceId(char *name); void RouteTrackingStart(SESSION *s); void RouteTrackingStop(SESSION *s, ROUTE_TRACKING *t); void RouteTrackingMain(SESSION *s); -void Win32ReleaseAllDhcp9x(bool wait); void Win32GetWinVer(RPC_WINVER *v); diff --git a/src/Cedar/Virtual.c b/src/Cedar/Virtual.c index ddae4dea..dab42cab 100644 --- a/src/Cedar/Virtual.c +++ b/src/Cedar/Virtual.c @@ -10310,10 +10310,7 @@ VH *NewVirtualHostEx(CEDAR *cedar, CLIENT_OPTION *option, CLIENT_AUTH *auth, VH_ if (v->IcmpRawSocketOk == false) { - if (IsIcmpApiSupported()) - { - v->IcmpApiOk = true; - } + v->IcmpApiOk = true; } // Set the options diff --git a/src/Cedar/Win32Com.cpp b/src/Cedar/Win32Com.cpp index 9d0cdcb8..ad44ae22 100644 --- a/src/Cedar/Win32Com.cpp +++ b/src/Cedar/Win32Com.cpp @@ -11,8 +11,8 @@ #define _WIN32_DCOM -//#define _WIN32_WINNT 0x0502 -//#define WINVER 0x0502 +#define _WIN32_WINNT 0x0600 +#define WINVER 0x0600 #include #include #include @@ -856,32 +856,9 @@ bool CreateLinkInner(wchar_t *filename, wchar_t *target, wchar_t *workdir, wchar wchar_t *comment, wchar_t *icon, UINT icon_index) { HRESULT r; - bool ret; IShellLinkW* pShellLink; IPersistFile* pPersistFile; - if (OS_IS_WINDOWS_9X(GetOsInfo()->OsType)) - { - char *a1, *a2, *a3, *a4, *a5, *a6; - a1 = CopyUniToStr(filename); - a2 = CopyUniToStr(target); - a3 = CopyUniToStr(workdir); - a4 = CopyUniToStr(args); - a5 = CopyUniToStr(icon); - a6 = CopyUniToStr(comment); - - ret = CreateLinkInnerA(a1, a2, a3, a4, a6, a5, icon_index); - - Free(a1); - Free(a2); - Free(a3); - Free(a4); - Free(a5); - Free(a6); - - return ret; - } - r = CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, IID_IShellLinkW, (void **)&pShellLink); if (FAILED(r)) { @@ -966,31 +943,11 @@ extern "C" // Show the folder selection dialog wchar_t *FolderDlgW(HWND hWnd, wchar_t *title, wchar_t *default_dir) { - wchar_t *ret; - - if (MsIsNt() == false) - { - char *default_dir_a = CopyUniToStr(default_dir); - char *ret_a = FolderDlgA(hWnd, title, default_dir_a); - - ret = CopyStrToUni(ret_a); - Free(ret_a); - Free(default_dir_a); - - return ret; - } - - ret = FolderDlgInnerW(hWnd, title, default_dir); - - return ret; + return FolderDlgInnerW(hWnd, title, default_dir); } char *FolderDlgA(HWND hWnd, wchar_t *title, char *default_dir) { - char *ret; - - ret = FolderDlgInnerA(hWnd, title, default_dir); - - return ret; + return FolderDlgInnerA(hWnd, title, default_dir); } // Create a shortcut diff --git a/src/Cedar/WinJumpList.cpp b/src/Cedar/WinJumpList.cpp index d3feedbc..66b6d45e 100644 --- a/src/Cedar/WinJumpList.cpp +++ b/src/Cedar/WinJumpList.cpp @@ -35,8 +35,8 @@ #undef StrCmp #endif -//#define _WIN32_WINNT 0x0502 -//#define WINVER 0x0502 +#define _WIN32_WINNT 0x0600 +#define WINVER 0x0600 #include #include #include diff --git a/src/Cedar/WinUi.c b/src/Cedar/WinUi.c index 481b664c..8b6acbd1 100644 --- a/src/Cedar/WinUi.c +++ b/src/Cedar/WinUi.c @@ -11,8 +11,8 @@ #define WINUI_C -#define _WIN32_WINNT 0x0502 -#define WINVER 0x0502 +#define _WIN32_WINNT 0x0600 +#define WINVER 0x0600 #include #include #include @@ -467,11 +467,6 @@ void SetUacIcon(HWND hWnd, UINT id) return; } - if (MsIsVista() == false) - { - goto LABEL_FAILED; - } - if (hShell32 == NULL) { hShell32 = LoadLibraryA("shell32.dll"); @@ -500,14 +495,10 @@ void SetUacIcon(HWND hWnd, UINT id) } } - if (ok) + if (!ok) { - return; + Hide(hWnd, id); } - -LABEL_FAILED: - - Hide(hWnd, id); } // Procedure of the wizard page @@ -768,14 +759,7 @@ LRESULT CALLBACK WizardCustomizedWindowProc(HWND hWnd, UINT msg, WPARAM wParam, break; } - if (MsIsNt()) - { - return CallWindowProcW(wizard->OriginalWindowProc, hWnd, msg, wParam, lParam); - } - else - { - return CallWindowProcA(wizard->OriginalWindowProc, hWnd, msg, wParam, lParam); - } + return CallWindowProcW(wizard->OriginalWindowProc, hWnd, msg, wParam, lParam); } else { @@ -801,25 +785,10 @@ UINT CALLBACK WizardDlgProc(HWND hWnd, UINT msg, LPARAM lParam) { wizard->ReplaceWindowProcFlag = true; - if (MsIsNt()) - { - wizard->OriginalWindowProc = (void *)GetWindowLongPtrW(hWnd, GWLP_WNDPROC); - } - else - { - wizard->OriginalWindowProc = (void *)GetWindowLongPtrA(hWnd, GWLP_WNDPROC); - } - + wizard->OriginalWindowProc = (void *)GetWindowLongPtrW(hWnd, GWLP_WNDPROC); if (wizard->OriginalWindowProc != NULL) { - if (MsIsNt()) - { - SetWindowLongPtrW(hWnd, GWLP_WNDPROC, (LONG_PTR)WizardCustomizedWindowProc); - } - else - { - SetWindowLongPtrA(hWnd, GWLP_WNDPROC, (LONG_PTR)WizardCustomizedWindowProc); - } + SetWindowLongPtrW(hWnd, GWLP_WNDPROC, (LONG_PTR)WizardCustomizedWindowProc); } } } @@ -893,12 +862,6 @@ void ShowWizard(HWND hWndParent, WIZARD *w, UINT start_id) h.dwSize = sizeof(PROPSHEETHEADERW_V2); h.dwFlags = PSH_WIZARD97 | PSH_HEADER | PSH_USEICONID | PSH_USECALLBACK; - if (MsIsVista() == false) - { - // Aero Wizard is unavailable in pre-Vista - w->IsAreoStyle = false; - } - if (MsIsAeroColor() == false) { // Aero Wizard can not be used If the color of Aero is disabled @@ -1198,7 +1161,7 @@ void NicInfoShowStatus(HWND hWnd, UI_NICINFO *info, wchar_t *msg1, wchar_t *msg2 SetText(hWnd, S_STATUS1, msg1); SetText(hWnd, S_STATUS2, msg2); - SetShow(hWnd, P_BAR, animate && MsIsWinXPOrWinVista()); + SetShow(hWnd, P_BAR, animate); } void NicInfoRefresh(HWND hWnd, UI_NICINFO *info) { @@ -1277,12 +1240,9 @@ void NicInfoInit(HWND hWnd, UI_NICINFO *info) return; } - if (MsIsWinXPOrWinVista()) - { - // Show a progress bar for Windows XP or later - SendMsg(hWnd, P_BAR, PBM_SETMARQUEE, TRUE, 150); - SetStyle(hWnd, P_BAR, PBS_MARQUEE); - } + // Show a progress bar + SendMsg(hWnd, P_BAR, PBM_SETMARQUEE, TRUE, 150); + SetStyle(hWnd, P_BAR, PBS_MARQUEE); DlgFont(hWnd, S_STATUS1, 9, false); DlgFont(hWnd, S_STATUS2, 11, false); @@ -1382,17 +1342,9 @@ UINT WinConnectDlgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam, void * SetIcon(hWnd, S_ICON, d->icon_id); d->hWnd = hWnd; - if (MsIsWinXPOrWinVista()) - { - // Show a progress bar for Windows XP or later - SendMsg(hWnd, IDC_PROGRESS1, PBM_SETMARQUEE, TRUE, 100); - SetStyle(hWnd, IDC_PROGRESS1, PBS_MARQUEE); - } - else - { - // Hide the progress bar in the case of pre-Windows 2000 - Hide(hWnd, IDC_PROGRESS1); - } + // Show a progress bar + SendMsg(hWnd, IDC_PROGRESS1, PBM_SETMARQUEE, TRUE, 100); + SetStyle(hWnd, IDC_PROGRESS1, PBS_MARQUEE); // Create a thread d->thread = NewThread(WinConnectDlgThread, d); @@ -1514,14 +1466,7 @@ char *GetMeiryoFontName() } else { - if (MsIsVista()) - { - return "Meiryo"; - } - else - { - return "MS UI Gothic"; - } + return "Meiryo"; } } @@ -1663,14 +1608,7 @@ UINT OnceMsgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam, void *param) SetIcon(hWnd, 0, d->Icon); } - if (MsIsVista()) - { - SetFont(hWnd, E_TEXT, GetMeiryoFont()); - } - else - { - DlgFont(hWnd, E_TEXT, 11, false); - } + SetFont(hWnd, E_TEXT, GetMeiryoFont()); SetTimer(hWnd, 1, 50, NULL); break; @@ -1801,11 +1739,6 @@ void InitVistaWindowTheme(HWND hWnd) static HINSTANCE hInstDll = NULL; HRESULT (WINAPI *_SetWindowTheme)(HWND, LPCWSTR, LPCWSTR) = NULL; - if (MsIsVista() == false) - { - return; - } - if (hInstDll == NULL) { hInstDll = LoadLibraryA("uxtheme.dll"); @@ -1885,149 +1818,6 @@ void ShowEasterEgg(HWND hWnd) { } -void KakushiThread(THREAD *thread, void *param) -{ - KAKUSHI *k; - // Validate arguments - if (thread == NULL || param == NULL) - { - return; - } - - k = (KAKUSHI *)param; - - k->Thread = thread; - AddRef(k->Thread->ref); - NoticeThreadInit(thread); - - Dialog(NULL, D_CM_KAKUSHI, KakushiDlgProc, k); - k->hWnd = NULL; -} - -KAKUSHI *InitKakushi() -{ - THREAD *t; - KAKUSHI *k = ZeroMalloc(sizeof(KAKUSHI)); - - t = NewThread(KakushiThread, k); - - WaitThreadInit(t); - ReleaseThread(t); - - return k; -} - -UINT KakushiDlgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam, void *param) -{ - KAKUSHI *k = (KAKUSHI *)param; - UINT64 now; - bool b; - if (hWnd == NULL) - { - return 0; - } - - switch (msg) - { - case WM_INITDIALOG: - SetText(hWnd, S_INFO, _UU("CM_VLAN_CREATING")); - - b = false; - - if (MsIsVista()) - { - if (_GETLANG() == 0) - { - SetFont(hWnd, S_INFO, GetFont(GetMeiryoFontName(), 11, false, false, false, false)); - b = true; - } - else if (_GETLANG() == 2) - { - SetFont(hWnd, S_INFO, GetFont("Microsoft YaHei", 11, false, false, false, false)); - b = true; - } - else if (_GETLANG() == 3) - { - SetFont(hWnd, S_INFO, GetFont("Microsoft JhengHei", 11, false, false, false, false)); - b = true; - } - } - - if (b == false) - { - DlgFont(hWnd, S_INFO, 11, false); - } - - SetTimer(hWnd, 1, 50, NULL); - k->hWnd = hWnd; - - k->Span = 20 * 1000; - k->StartTick = Tick64(); - - SetRange(hWnd, P_PROGRESS, 0, (UINT)k->Span); - - case WM_APP + 9821: - now = Tick64(); - - if (((k->StartTick + k->Span) <= now) || k->Halt) - { - EndDialog(hWnd, 0); - break; - } - - SetPos(hWnd, P_PROGRESS, (UINT)(now - k->StartTick)); - break; - - case WM_TIMER: - switch (wParam) - { - case 1: - AllowSetForegroundWindow(ASFW_ANY); - SetForegroundWindow(hWnd); - SetActiveWindow(hWnd); - - now = Tick64(); - - if (((k->StartTick + k->Span) <= now) || k->Halt) - { - EndDialog(hWnd, 0); - break; - } - - SetPos(hWnd, P_PROGRESS, (UINT)(now - k->StartTick)); - break; - } - break; - - case WM_CLOSE: - return 1; - } - - return 0; -} - -// Release the Kakushi screen -void FreeKakushi(KAKUSHI *k) -{ - // Validate arguments - if (k == NULL) - { - return; - } - - k->Halt = true; - - if (k->hWnd != NULL) - { - PostMessage(k->hWnd, WM_APP + 9821, 0, 0); - } - - WaitThread(k->Thread, INFINITE); - ReleaseThread(k->Thread); - - Free(k); -} - // TCP/IP optimization selection dialog procedure UINT TcpMsgDlgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam, void *param) { @@ -2309,7 +2099,7 @@ void ShowTcpIpConfigUtil(HWND hWnd, bool util_mode) } // Disable the task off-loading by netsh - if (MsIsVista()) + if (true) { DIRLIST *dl; UINT i; @@ -2358,14 +2148,11 @@ void ShowTcpIpConfigUtil(HWND hWnd, bool util_mode) if (MsIsAdmin()) { - if (MsIsVista()) + // If installing on Windows Vista, + // dispel the network limitation of MMCSS + if (MsIsMMCSSNetworkThrottlingEnabled()) { - // If installing on Windows Vista, - // dispel the network limitation of MMCSS - if (MsIsMMCSSNetworkThrottlingEnabled()) - { - MsSetMMCSSNetworkThrottlingEnable(false); - } + MsSetMMCSSNetworkThrottlingEnable(false); } } } @@ -2474,63 +2261,13 @@ void InitMenuInternationalUni(HMENU hMenu, char *prefix) // Internationalization of menu void InitMenuInternational(HMENU hMenu, char *prefix) { - UINT i, num; // Validate arguments if (hMenu == NULL || prefix == NULL) { return; } - if (MsIsNt()) - { - InitMenuInternationalUni(hMenu, prefix); - return; - } - - // Get the number of items in the menu - num = GetMenuItemCount(hMenu); - - // Enumerate the menu items - for (i = 0;i < num;i++) - { - HMENU hSubMenu = GetSubMenu(hMenu, i); - MENUITEMINFO info; - char tmp[MAX_SIZE]; - - if (hSubMenu != NULL) - { - // If there is a sub-menu, call it recursively - InitMenuInternational(hSubMenu, prefix); - } - - // Get the menu item - Zero(&info, sizeof(info)); - info.cbSize = sizeof(info); - info.cch = sizeof(tmp); - info.dwTypeData = tmp; - info.fMask = MIIM_STRING; - Zero(tmp, sizeof(tmp)); - - if (GetMenuItemInfo(hMenu, i, true, &info)) - { - if (tmp[0] == '@') - { - char name[256]; - char *ret; - - Format(name, sizeof(name), "%s@%s", prefix, &tmp[1]); - - ret = _SS(name); - if (IsEmptyStr(ret) == false) - { - StrCpy(tmp, sizeof(tmp), ret); - info.cch = StrLen(tmp); - - SetMenuItemInfo(hMenu, i, true, &info); - } - } - } - } + InitMenuInternationalUni(hMenu, prefix); } // Get the default font for the dialog box @@ -2597,9 +2334,6 @@ void AdjustWindowAndControlSize(HWND hWnd, bool *need_resize, double *factor_x, { HFONT hDlgFont; UINT dlgfont_x, dlgfont_y; - RECT rect, rect2; - LIST *o; - UINT i; // Validate arguments if (hWnd == NULL || need_resize == NULL || factor_x == NULL || factor_y == NULL) { @@ -2629,120 +2363,6 @@ void AdjustWindowAndControlSize(HWND hWnd, bool *need_resize, double *factor_x, *factor_x = (double)dlgfont_x / (double)WINUI_DEFAULT_DIALOG_UNIT_X; *factor_y = (double)dlgfont_y / (double)WINUI_DEFAULT_DIALOG_UNIT_Y; //Debug("Factors: %f %f\n", *factor_x, *factor_y); - - if (MsIsVista()) - { - // In Windows Vista or later, trust the size expansion by the OS to follow this (not adjusted) - return; - } - - // Adjust the size of the window - if (GetWindowRect(hWnd, &rect)) - { - if (GetClientRect(hWnd, &rect2)) - { - UINT width = rect2.right - rect2.left; - UINT height = rect2.bottom - rect2.top; - - AdjustDialogXY(&width, &height, dlgfont_x, dlgfont_y); - - width += (rect.right - rect.left) - (rect2.right - rect2.left); - height += (rect.bottom - rect.top) - (rect2.bottom - rect2.top); - - if (true) - { - HWND hParent = GetParent(hWnd); - - if (hParent != NULL) - { - RECT r; - - Zero(&r, sizeof(r)); - - if (GetWindowRect(hParent, &r)) - { - RECT r2; - - rect.top = r.top + GetSystemMetrics(SM_CYCAPTION); - - Zero(&r2, sizeof(r2)); - if (SystemParametersInfo(SPI_GETWORKAREA, 0, &r2, 0)) - { - if (r2.bottom < (rect.top + (int)height)) - { - rect.top -= (rect.top + (int)height) - r2.bottom; - - if (rect.top < 0) - { - rect.top = 0; - } - } - } - } - } - } - - MoveWindow(hWnd, rect.left, rect.top, width, height, false); - } - } - - // Enumerate the child windows - o = EnumAllChildWindowEx(hWnd, false, true, true); - - for (i = 0;i < LIST_NUM(o);i++) - { - // Adjust the size of the child window - HWND h = *((HWND *)LIST_DATA(o, i)); - HWND hWndParent = GetParent(h); - RECT current_rect; - char class_name[MAX_PATH]; - bool is_image = false; - - // Get the class name - Zero(class_name, sizeof(class_name)); - GetClassNameA(h, class_name, sizeof(class_name)); - - if (StrCmpi(class_name, "static") == 0) - { - if (SendMsg(h, 0, STM_GETIMAGE, IMAGE_BITMAP, 0) != 0 || - SendMsg(h, 0, STM_GETIMAGE, IMAGE_ICON, 0) != 0 || - SendMsg(h, 0, STM_GETICON, 0, 0) != 0) - { - is_image = true; - } - } - - // Get the position - if (GetWindowRect(h, ¤t_rect)) - { - // Convert to client coordinates - POINT p1, p2; - - p1.x = current_rect.left; - p1.y = current_rect.top; - - p2.x = current_rect.right; - p2.y = current_rect.bottom; - - ScreenToClient(hWndParent, &p1); - ScreenToClient(hWndParent, &p2); - - // Adjust the position - AdjustDialogXY(&p1.x, &p1.y, dlgfont_x, dlgfont_y); - AdjustDialogXY(&p2.x, &p2.y, dlgfont_x, dlgfont_y); - - if (is_image) - { - p2.x = p1.x + (current_rect.right - current_rect.left); - p2.y = p1.y + (current_rect.bottom - current_rect.top); - } - - // Move - MoveWindow(h, p1.x, p1.y, p2.x - p1.x, p2.y - p1.y, false); - } - } - - FreeWindowList(o); } // Adjust the values of x and y according to the font @@ -2850,15 +2470,12 @@ void InitDialogInternational(HWND hWnd, void *pparam) SetFont(hControl, 0, hFont); } - if (MsIsVista()) - { - char classname[MAX_PATH]; - GetClassNameA(hControl, classname, sizeof(classname)); + char classname[MAX_PATH]; + GetClassNameA(hControl, classname, sizeof(classname)); - if (StrCmpi(classname, "syslistview32") == 0) - { - InitVistaWindowTheme(hControl); - } + if (StrCmpi(classname, "syslistview32") == 0) + { + InitVistaWindowTheme(hControl); } if (is_managed_dialog) @@ -2897,7 +2514,7 @@ void InitDialogInternational(HWND hWnd, void *pparam) FreeWindowList(o); - if (MsIsVista() && need_resize) + if (need_resize) { // Since the window size is changed automatically by the OS by the dpi setting // in Windows Vista or later, a static (bitmap) control needs to be expanded @@ -3285,81 +2902,6 @@ char *StringDlgA(HWND hWnd, wchar_t *title, wchar_t *info, char *def, UINT icon, return ret; } -// Restarting dialog -UINT Win9xRebootDlgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam, void *param) -{ - WIN9X_REBOOT_DLG *d = (WIN9X_REBOOT_DLG *)param; - UINT64 now; - wchar_t tmp[MAX_PATH]; - // Validate arguments - if (hWnd == NULL) - { - return 0; - } - - switch (msg) - { - case WM_INITDIALOG: - d->StartTime = Tick64(); - SetRange(hWnd, P_PROGRESS, 0, d->TotalTime); - SetTimer(hWnd, 1, 100, NULL); - goto UPDATE; - - case WM_TIMER: - switch (wParam) - { - case 1: -UPDATE: - now = Tick64(); - if ((d->StartTime + (UINT64)d->TotalTime) <= now) - { - KillTimer(hWnd, 1); - UniStrCpy(tmp, sizeof(tmp), _UU("DLG_REBOOT_INFO_2")); - SetText(hWnd, S_INFO, tmp); - if (MsShutdown(true, false) == false) - { - MsgBox(hWnd, MB_ICONSTOP, _UU("DLG_REBOOT_ERROR")); - } - EndDialog(hWnd, 0); - } - else - { - SetPos(hWnd, P_PROGRESS, (UINT)(now - d->StartTime)); - UniFormat(tmp, sizeof(tmp), _UU("DLG_REBOOT_INFO"), - (UINT)((UINT64)d->TotalTime - (now - d->StartTime)) / 1000 + 1); - SetText(hWnd, S_INFO, tmp); - } - - break; - } - break; - } - return 0; -} - -// Restarting thread -void Win9xRebootThread(THREAD *t, void *p) -{ - // Validate arguments - if (t == NULL) - { - return; - } - - Win9xReboot(NULL); -} - -// Restart automatically -void Win9xReboot(HWND hWnd) -{ - WIN9X_REBOOT_DLG d; - - Zero(&d, sizeof(d)); - d.TotalTime = 10 * 1000; - - Dialog(hWnd, D_WIN9X_REBOOT, Win9xRebootDlgProc, &d); -} - // Show a text file void ShowTextFile(HWND hWnd, char *filename, wchar_t *caption, UINT icon) { @@ -3936,11 +3478,7 @@ void AllowFGWindow(UINT process_id) return; } - if (OS_IS_WINDOWS_NT(GetOsInfo()->OsType) && - GET_KETA(GetOsInfo()->OsType, 100) >= 2) - { - AllowSetForegroundWindow(process_id); - } + AllowSetForegroundWindow(process_id); } // Rename the item @@ -3958,17 +3496,7 @@ void LvRename(HWND hWnd, UINT id, UINT pos) // Enhanced function LRESULT CALLBACK LvEnhancedProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) { - WNDPROC func = NULL; - - if (MsIsNt()) - { - func = (WNDPROC)GetPropW(hWnd, L"ORIGINAL_FUNC"); - } - else - { - func = (WNDPROC)GetPropA(hWnd, "ORIGINAL_FUNC"); - } - + WNDPROC func = (WNDPROC)GetPropW(hWnd, L"ORIGINAL_FUNC"); if (func == NULL) { Debug("LvEnhancedProc(): GetProp() returned NULL!\n"); @@ -3999,14 +3527,7 @@ LRESULT CALLBACK LvEnhancedProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lPara LvSetEnhanced(hWnd, 0, false); } - if (MsIsNt()) - { - return CallWindowProcW(func, hWnd, msg, wParam, lParam); - } - else - { - return CallWindowProcA(func, hWnd, msg, wParam, lParam); - } + return CallWindowProcW(func, hWnd, msg, wParam, lParam); } // Toggle enhanced function @@ -4020,46 +3541,20 @@ void LvSetEnhanced(HWND hWnd, UINT id, bool enable) if (enable) { - if (MsIsNt()) - { - const HANDLE fn = (HANDLE)SetWindowLongPtrW(DlgItem(hWnd, id), GWLP_WNDPROC, (LONG_PTR)LvEnhancedProc); - SetPropW(DlgItem(hWnd, id), L"ORIGINAL_FUNC", fn); - } - else - { - const HANDLE fn = (HANDLE)SetWindowLongPtrA(DlgItem(hWnd, id), GWLP_WNDPROC, (LONG_PTR)LvEnhancedProc); - SetPropA(DlgItem(hWnd, id), "ORIGINAL_FUNC", fn); - } + const HANDLE fn = (HANDLE)SetWindowLongPtrW(DlgItem(hWnd, id), GWLP_WNDPROC, (LONG_PTR)LvEnhancedProc); + SetPropW(DlgItem(hWnd, id), L"ORIGINAL_FUNC", fn); } else { - if (MsIsNt()) - { - SetWindowLongPtrW(DlgItem(hWnd, id), GWLP_WNDPROC, (LONG_PTR)GetPropW(DlgItem(hWnd, id), L"ORIGINAL_FUNC")); - RemovePropW(DlgItem(hWnd, id), L"ORIGINAL_FUNC"); - } - else - { - SetWindowLongPtrA(DlgItem(hWnd, id), GWLP_WNDPROC, (LONG_PTR)GetPropA(DlgItem(hWnd, id), "ORIGINAL_FUNC")); - RemovePropA(DlgItem(hWnd, id), "ORIGINAL_FUNC"); - } + SetWindowLongPtrW(DlgItem(hWnd, id), GWLP_WNDPROC, (LONG_PTR)GetPropW(DlgItem(hWnd, id), L"ORIGINAL_FUNC")); + RemovePropW(DlgItem(hWnd, id), L"ORIGINAL_FUNC"); } } // Enhanced function LRESULT CALLBACK EditBoxEnhancedProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) { - WNDPROC func = NULL; - - if (MsIsNt()) - { - func = (WNDPROC)GetPropW(hWnd, L"ORIGINAL_FUNC"); - } - else - { - func = (WNDPROC)GetPropA(hWnd, "ORIGINAL_FUNC"); - } - + WNDPROC func = (WNDPROC)GetPropW(hWnd, L"ORIGINAL_FUNC"); if (func == NULL) { Debug("EditBoxEnhancedProc(): GetProp() returned NULL!\n"); @@ -4088,14 +3583,7 @@ LRESULT CALLBACK EditBoxEnhancedProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM EditBoxSetEnhanced(hWnd, 0, false); } - if (MsIsNt()) - { - return CallWindowProcW(func, hWnd, msg, wParam, lParam); - } - else - { - return CallWindowProcA(func, hWnd, msg, wParam, lParam); - } + return CallWindowProcW(func, hWnd, msg, wParam, lParam); } // Toggle enhanced function @@ -4109,29 +3597,13 @@ void EditBoxSetEnhanced(HWND hWnd, UINT id, bool enable) if (enable) { - if (MsIsNt()) - { - const HANDLE fn = (HANDLE)SetWindowLongPtrW(DlgItem(hWnd, id), GWLP_WNDPROC, (LONG_PTR)EditBoxEnhancedProc); - SetPropW(DlgItem(hWnd, id), L"ORIGINAL_FUNC", fn); - } - else - { - const HANDLE fn = (HANDLE)SetWindowLongPtrA(DlgItem(hWnd, id), GWLP_WNDPROC, (LONG_PTR)EditBoxEnhancedProc); - SetPropA(DlgItem(hWnd, id), "ORIGINAL_FUNC", fn); - } + const HANDLE fn = (HANDLE)SetWindowLongPtrW(DlgItem(hWnd, id), GWLP_WNDPROC, (LONG_PTR)EditBoxEnhancedProc); + SetPropW(DlgItem(hWnd, id), L"ORIGINAL_FUNC", fn); } else { - if (MsIsNt()) - { - SetWindowLongPtrW(DlgItem(hWnd, id), GWLP_WNDPROC, (LONG_PTR)GetPropW(DlgItem(hWnd, id), L"ORIGINAL_FUNC")); - RemovePropW(DlgItem(hWnd, id), L"ORIGINAL_FUNC"); - } - else - { - SetWindowLongPtrA(DlgItem(hWnd, id), GWLP_WNDPROC, (LONG_PTR)GetPropA(DlgItem(hWnd, id), "ORIGINAL_FUNC")); - RemovePropA(DlgItem(hWnd, id), "ORIGINAL_FUNC"); - } + SetWindowLongPtrW(DlgItem(hWnd, id), GWLP_WNDPROC, (LONG_PTR)GetPropW(DlgItem(hWnd, id), L"ORIGINAL_FUNC")); + RemovePropW(DlgItem(hWnd, id), L"ORIGINAL_FUNC"); } } @@ -4212,14 +3684,6 @@ void SetMenuStr(HMENU hMenu, UINT pos, wchar_t *str) return; } - if (MsIsNt() == false) - { - char *s = CopyUniToStr(str); - SetMenuStrA(hMenu, pos, s); - Free(s); - return; - } - Zero(&info, sizeof(info)); info.cbSize = sizeof(info); info.fMask = MIIM_STRING; @@ -4251,20 +3715,6 @@ wchar_t *GetMenuStr(HMENU hMenu, UINT pos) { return NULL; } - if (MsIsNt() == false) - { - char *s = GetMenuStrA(hMenu, pos); - if (s == NULL) - { - return NULL; - } - else - { - wchar_t *ret = CopyStrToUni(s); - Free(s); - return ret; - } - } if (GetMenuStringW(hMenu, pos, tmp, sizeof(tmp), MF_BYPOSITION) == 0) { @@ -4887,10 +4337,7 @@ void LvInitEx2(HWND hWnd, UINT id, bool no_image, bool large_icon) ListView_SetExtendedListViewStyle(DlgItem(hWnd, id), LVS_EX_FULLROWSELECT); - if (MsIsVista()) - { - LvSetStyle(hWnd, id, LVS_EX_DOUBLEBUFFER); - } + LvSetStyle(hWnd, id, LVS_EX_DOUBLEBUFFER); } void LvInit(HWND hWnd, UINT id) { @@ -5415,14 +4862,6 @@ UINT LvInsertItemByImageListId(HWND hWnd, UINT id, UINT image, void *param, wcha { return INFINITE; } - if (MsIsNt() == false) - { - char *s = CopyUniToStr(str); - UINT ret; - ret = LvInsertItemByImageListIdA(hWnd, id, image, param, s); - Free(s); - return ret; - } Zero(&t, sizeof(t)); t.mask = LVIF_IMAGE | LVIF_PARAM | LVIF_TEXT; @@ -5503,13 +4942,6 @@ void LvSetItem(HWND hWnd, UINT id, UINT index, UINT pos, wchar_t *str) { return; } - if (MsIsNt() == false) - { - char *s = CopyUniToStr(str); - LvSetItemA(hWnd, id, index, pos, s); - Free(s); - return; - } Zero(&t, sizeof(t)); t.mask = LVIF_TEXT; @@ -5880,21 +5312,6 @@ wchar_t *LvGetStr(HWND hWnd, UINT id, UINT index, UINT pos) { return NULL; } - if (MsIsNt() == false) - { - char *s = LvGetStrA(hWnd, id, index, pos); - if (s == NULL) - { - return NULL; - } - else - { - wchar_t *ret = CopyStrToUni(s); - Free(s); - - return ret; - } - } size = 65536; tmp = Malloc(size); @@ -6554,13 +5971,6 @@ wchar_t *CbGetStr(HWND hWnd, UINT id) UINT CbFindStr(HWND hWnd, UINT id, wchar_t *str) { UINT ret; - if (MsIsNt() == false) - { - char *tmp = CopyUniToStr(str); - ret = CbFindStr9xA(hWnd, id, tmp); - Free(tmp); - return ret; - } // Validate arguments if (hWnd == NULL || str == NULL) { @@ -6615,13 +6025,6 @@ UINT CbAddStrA(HWND hWnd, UINT id, char *str, UINT data) UINT CbAddStr(HWND hWnd, UINT id, wchar_t *str, UINT data) { UINT ret; - if (MsIsNt() == false) - { - char *s = CopyUniToStr(str); - ret = CbAddStr9xA(hWnd, id, s, data); - Free(s); - return ret; - } // Validate arguments if (hWnd == NULL || str == NULL) { @@ -7241,24 +6644,6 @@ wchar_t *SaveDlg(HWND hWnd, wchar_t *filter, wchar_t *title, wchar_t *default_na wchar_t tmp[MAX_SIZE]; OPENFILENAMEW o; - if (MsIsNt() == false) - { - char *ret, *s1, *s2, *s3, *s4; - wchar_t *wr; - s1 = CopyUniToStr(filter); - s2 = CopyUniToStr(title); - s3 = CopyUniToStr(default_name); - s4 = CopyUniToStr(default_ext); - ret = SaveDlgA(hWnd, s1, s2, s3, s4); - Free(s1); - Free(s2); - Free(s3); - Free(s4); - wr = CopyStrToUni(ret); - Free(ret); - return wr; - } - // Validate arguments if (filter == NULL) { @@ -7276,12 +6661,6 @@ wchar_t *SaveDlg(HWND hWnd, wchar_t *filter, wchar_t *title, wchar_t *default_na } o.lStructSize = sizeof(o); - - if (OS_IS_WINDOWS_9X(GetOsInfo()->OsType) || (OS_IS_WINDOWS_NT(GetOsInfo()->OsType) && GET_KETA(GetOsInfo()->OsType, 100) <= 1)) - { - o.lStructSize = OPENFILENAME_SIZE_VERSION_400W; - } - o.hwndOwner = hWnd; o.hInstance = GetModuleHandle(NULL); o.lpstrFile = tmp; @@ -7323,12 +6702,6 @@ char *SaveDlgA(HWND hWnd, char *filter, char *title, char *default_name, char *d } o.lStructSize = sizeof(o); - - if (OS_IS_WINDOWS_9X(GetOsInfo()->OsType) || (OS_IS_WINDOWS_NT(GetOsInfo()->OsType) && GET_KETA(GetOsInfo()->OsType, 100) <= 1)) - { - o.lStructSize = OPENFILENAME_SIZE_VERSION_400A; - } - o.hwndOwner = hWnd; o.hInstance = GetModuleHandle(NULL); o.lpstrFile = tmp; @@ -7356,22 +6729,6 @@ wchar_t *OpenDlg(HWND hWnd, wchar_t *filter, wchar_t *title) wchar_t tmp[MAX_SIZE]; OPENFILENAMEW o; - if (MsIsNt() == false) - { - char *ret; - char *filter_a; - char *title_a; - wchar_t *w; - filter_a = CopyUniToStr(filter); - title_a = CopyUniToStr(title); - ret = OpenDlgA(hWnd, filter_a, title_a); - Free(filter_a); - Free(title_a); - w = CopyStrToUni(ret); - Free(ret); - return w; - } - // Validate arguments if (filter == NULL) { @@ -7384,14 +6741,6 @@ wchar_t *OpenDlg(HWND hWnd, wchar_t *filter, wchar_t *title) Zero(tmp, sizeof(tmp)); o.lStructSize = sizeof(o); - - - if (OS_IS_WINDOWS_9X(GetOsInfo()->OsType) || (OS_IS_WINDOWS_NT(GetOsInfo()->OsType) && GET_KETA(GetOsInfo()->OsType, 100) <= 1)) - { - o.lStructSize = OPENFILENAME_SIZE_VERSION_400W; - } - - o.hwndOwner = hWnd; o.hInstance = GetModuleHandle(NULL); o.lpstrFilter = filter_str; @@ -7427,12 +6776,6 @@ char *OpenDlgA(HWND hWnd, char *filter, char *title) Zero(tmp, sizeof(tmp)); o.lStructSize = sizeof(o); - - if (OS_IS_WINDOWS_9X(GetOsInfo()->OsType) || (OS_IS_WINDOWS_NT(GetOsInfo()->OsType) && GET_KETA(GetOsInfo()->OsType, 100) <= 1)) - { - o.lStructSize = OPENFILENAME_SIZE_VERSION_400A; - } - o.hwndOwner = hWnd; o.hInstance = GetModuleHandle(NULL); o.lpstrFilter = filter_str; @@ -8155,10 +7498,7 @@ UINT DialogEx2(HWND hWnd, UINT id, WINUI_DIALOG_PROC *proc, void *param, bool wh p.BitmapList = NewBitmapList(); - if (MsIsVista()) - { - p.meiryo = meiryo; - } + p.meiryo = meiryo; ret = DialogInternal(hWnd, id, InternalDialogProc, &p); @@ -8460,12 +7800,6 @@ double GetTextScalingFactor() static int cached_dpi = 0; double ret = 1.0; - if (MsIsVista() == false) - { - // It's always 1.0 in Windows XP or earlier - return 1.0; - } - if (cached_dpi == 0) { HDC hDC = CreateCompatibleDC(NULL); @@ -8575,21 +7909,9 @@ HFONT GetFont(char *name, UINT size, bool bold, bool italic, bool underline, boo // Create a new font hDC = CreateCompatibleDC(NULL); - // Specify the ClearType in Windows XP or later - if (OS_IS_WINDOWS_NT(os->OsType) && GET_KETA(os->OsType, 100) >= 3) - { - font_quality = CLEARTYPE_NATURAL_QUALITY; - rotate = 3600; - } - - if (MsIsVista()) - { - dpi = GetDeviceCaps(hDC, LOGPIXELSY); - } - else - { - dpi = 96; - } + font_quality = CLEARTYPE_NATURAL_QUALITY; + rotate = 3600; + dpi = GetDeviceCaps(hDC, LOGPIXELSY); // Create a font hFont = CreateFontA(-MulDiv(size, dpi, 72), @@ -8939,16 +8261,7 @@ UINT DialogInternal(HWND hWnd, UINT id, DIALOG_PROC *proc, void *param) return 0; } - if (MsIsNt() == false) - { - // Win9x - return (UINT)DialogBoxParam(hDll, MAKEINTRESOURCE(id), hWnd, (DLGPROC)proc, (LPARAM)param); - } - else - { - // WinNT - return (UINT)DialogBoxParamW(hDll, MAKEINTRESOURCEW(id), hWnd, (DLGPROC)proc, (LPARAM)param); - } + return (UINT)DialogBoxParamW(hDll, MAKEINTRESOURCEW(id), hWnd, (DLGPROC)proc, (LPARAM)param); } // Dialog box procedure managed by WinUi @@ -8987,23 +8300,19 @@ UINT DlgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam, bool white_color if (UseAlpha) { - UINT os_type = GetOsInfo()->OsType; - if (OS_IS_WINDOWS_NT(os_type) && GET_KETA(os_type, 100) >= 2) + bool (WINAPI *_SetLayeredWindowAttributes)(HWND, COLORREF, BYTE, DWORD); + HINSTANCE hInst; + + hInst = LoadLibrary("user32.dll"); + _SetLayeredWindowAttributes = + (bool (__stdcall *)(HWND,COLORREF,BYTE,DWORD)) + GetProcAddress(hInst, "SetLayeredWindowAttributes"); + + if (_SetLayeredWindowAttributes != NULL) { - bool (WINAPI *_SetLayeredWindowAttributes)(HWND, COLORREF, BYTE, DWORD); - HINSTANCE hInst; - - hInst = LoadLibrary("user32.dll"); - _SetLayeredWindowAttributes = - (bool (__stdcall *)(HWND,COLORREF,BYTE,DWORD)) - GetProcAddress(hInst, "SetLayeredWindowAttributes"); - - if (_SetLayeredWindowAttributes != NULL) - { - // Only available on Windows 2000 or later - SetExStyle(hWnd, 0, WS_EX_LAYERED); - _SetLayeredWindowAttributes(hWnd, 0, AlphaValue * 255 / 100, LWA_ALPHA); - } + // Only available on Windows 2000 or later + SetExStyle(hWnd, 0, WS_EX_LAYERED); + _SetLayeredWindowAttributes(hWnd, 0, AlphaValue * 255 / 100, LWA_ALPHA); } } @@ -9308,16 +8617,6 @@ wchar_t *GetClass(HWND hWnd, UINT id) { wchar_t tmp[MAX_SIZE]; - if (MsIsNt() == false) - { - wchar_t *ret; - char *s; - s = GetClassA(hWnd, id); - ret = CopyStrToUni(s); - Free(s); - return ret; - } - // Validate arguments if (hWnd == NULL) { @@ -9351,14 +8650,7 @@ UINT SendMsg(HWND hWnd, UINT id, UINT msg, WPARAM wParam, LPARAM lParam) return 0; } - if (MsIsNt()) - { - return (UINT)SendMessageW(DlgItem(hWnd, id), msg, wParam, lParam); - } - else - { - return (UINT)SendMessageA(DlgItem(hWnd, id), msg, wParam, lParam); - } + return (UINT)SendMessageW(DlgItem(hWnd, id), msg, wParam, lParam); } // Move the cursor to the right edge of the text in the EDIT @@ -9849,18 +9141,7 @@ bool IsFontFitInRect(struct FONT *f, UINT width, UINT height, wchar_t *text, UIN r.right = width; r.bottom = height; - if (MsIsNt()) - { - i = DrawTextW(hCommonDC, text, -1, &r, format); - } - else - { - char *a = CopyUniToStr(text); - - i = DrawTextA(hCommonDC, a, -1, &r, format); - - Free(a); - } + i = DrawTextW(hCommonDC, text, -1, &r, format); SelectObject(hCommonDC, hOldFont); } @@ -9913,23 +9194,7 @@ void SetTextInner(HWND hWnd, UINT id, wchar_t *str) Free(old); - if (MsIsNt()) - { - SetWindowTextW(DlgItem(hWnd, id), str); - } - else - { - char *tmp = CopyUniToStr(str); - - if (MsIsNt() == false && StrLen(tmp) >= 32000) - { - // Truncate to less than 32k - tmp[32000] = 0; - } - - SetWindowTextA(DlgItem(hWnd, id), tmp); - Free(tmp); - } + SetWindowTextW(DlgItem(hWnd, id), str); AdjustFontSize(hWnd, id); @@ -10013,15 +9278,6 @@ wchar_t *GetText(HWND hWnd, UINT id) return NULL; } - if (MsIsNt() == false) - { - char *s = GetTextA(hWnd, id); - ret = CopyStrToUni(s); - Free(s); - - return ret; - } - len = GetWindowTextLengthW(DlgItem(hWnd, id)); if (len == 0) { diff --git a/src/Cedar/WinUi.h b/src/Cedar/WinUi.h index 801eb6b0..d3db3c14 100644 --- a/src/Cedar/WinUi.h +++ b/src/Cedar/WinUi.h @@ -287,12 +287,6 @@ typedef struct WINUI_ABOUT UINT AboutDlgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam, void *param); void AboutDlgInit(HWND hWnd, WINUI_ABOUT *a); -typedef struct WIN9X_REBOOT_DLG -{ - UINT64 StartTime; - UINT TotalTime; -} WIN9X_REBOOT_DLG; - #define LED_WIDTH 96 #define LED_HEIGHT 16 #define LED_FORCE_UPDATE 60000 @@ -354,15 +348,6 @@ HBITMAP ResizeBitmap(HBITMAP hSrc, UINT src_x, UINT src_y, UINT dst_x, UINT dst_ #endif // WINUI_C -// Kakushi -typedef struct KAKUSHI -{ - HWND hWnd; - THREAD *Thread; - volatile bool Halt; - UINT64 StartTick, Span; -} KAKUSHI; - // The information screen about the free version typedef struct FREEINFO { @@ -695,9 +680,6 @@ bool IpIsFilled(HWND hWnd, UINT id); UINT IpGetFilledNum(HWND hWnd, UINT id); void About(HWND hWnd, CEDAR *cedar, wchar_t *product_name); void AboutEx(HWND hWnd, CEDAR *cedar, wchar_t *product_name, WINUI_UPDATE *u); -void Win9xReboot(HWND hWnd); -void Win9xRebootThread(THREAD *t, void *p); -UINT Win9xRebootDlgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam, void *param); wchar_t *StringDlg(HWND hWnd, wchar_t *title, wchar_t *info, wchar_t *def, UINT icon, bool allow_empty, bool allow_unsafe); char *StringDlgA(HWND hWnd, wchar_t *title, wchar_t *info, char *def, UINT icon, bool allow_empty, bool allow_unsafe); UINT StringDlgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam, void *param); @@ -715,10 +697,6 @@ UINT TcpIpDlgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam, void *param void TcpIpDlgInit(HWND hWnd); void TcpIpDlgUpdate(HWND hWnd); UINT TcpMsgDlgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam, void *param); -UINT KakushiDlgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam, void *param); -void KakushiThread(THREAD *thread, void *param); -KAKUSHI *InitKakushi(); -void FreeKakushi(KAKUSHI *k); void ShowEasterEgg(HWND hWnd); bool Win32CnCheckAlreadyExists(bool lock); void RegistWindowsFirewallAll(); diff --git a/src/Mayaqua/CMakeLists.txt b/src/Mayaqua/CMakeLists.txt index 4a54b491..17305322 100644 --- a/src/Mayaqua/CMakeLists.txt +++ b/src/Mayaqua/CMakeLists.txt @@ -28,7 +28,18 @@ if(WIN32) COMPILE_PDB_OUTPUT_DIRECTORY "${BUILD_DIRECTORY}" ) - target_link_libraries(mayaqua PRIVATE setupapi.lib winmm.lib) + target_link_libraries(mayaqua + PRIVATE + "DbgHelp.Lib" + "dwmapi.lib" + "iphlpapi.lib" + "newdev.lib" + "Psapi.Lib" + "Secur32.Lib" + "setupapi.lib" + "winmm.lib" + "WtsApi32.Lib" + ) endif() if(UNIX) diff --git a/src/Mayaqua/Kernel.c b/src/Mayaqua/Kernel.c index 78d69a49..b641072d 100644 --- a/src/Mayaqua/Kernel.c +++ b/src/Mayaqua/Kernel.c @@ -612,15 +612,8 @@ void HashInstanceName(char *name, UINT size, char *instance_name) Format(name, size, "VPN-%s", key); - if (OS_IS_WINDOWS_NT(GetOsInfo()->OsType)) - { - if (GET_KETA(GetOsInfo()->OsType, 100) >= 2 || - GetOsInfo()->OsType == OSTYPE_WINDOWS_NT_4_TERMINAL_SERVER) - { - StrCpy(tmp, sizeof(tmp), name); - Format(name, size, "Global\\%s", tmp); - } - } + StrCpy(tmp, sizeof(tmp), name); + Format(name, size, "Global\\%s", tmp); } void HashInstanceNameLocal(char *name, UINT size, char *instance_name) { @@ -643,15 +636,8 @@ void HashInstanceNameLocal(char *name, UINT size, char *instance_name) Format(name, size, "VPN-%s", key); - if (OS_IS_WINDOWS_NT(GetOsInfo()->OsType)) - { - if (GET_KETA(GetOsInfo()->OsType, 100) >= 2 || - GetOsInfo()->OsType == OSTYPE_WINDOWS_NT_4_TERMINAL_SERVER) - { - StrCpy(tmp, sizeof(tmp), name); - Format(name, size, "Local\\%s", tmp); - } - } + StrCpy(tmp, sizeof(tmp), name); + Format(name, size, "Local\\%s", tmp); } // Run the process diff --git a/src/Mayaqua/MayaType.h b/src/Mayaqua/MayaType.h index 433b7483..37b76574 100644 --- a/src/Mayaqua/MayaType.h +++ b/src/Mayaqua/MayaType.h @@ -252,11 +252,9 @@ typedef unsigned int SOCKET; // OS discrimination macro #define GET_KETA(t, i) (((t) % (i * 10)) / i) -#define OS_IS_WINDOWS_9X(t) (GET_KETA(t, 1000) == 1) -#define OS_IS_WINDOWS_NT(t) (GET_KETA(t, 1000) == 2) -#define OS_IS_WINDOWS(t) (OS_IS_WINDOWS_9X(t) || OS_IS_WINDOWS_NT(t)) -#define OS_IS_SERVER(t) (OS_IS_WINDOWS_NT(t) && GET_KETA(t, 10)) -#define OS_IS_WORKSTATION(t) ((OS_IS_WINDOWS_NT(t) && (!(GET_KETA(t, 10)))) || OS_IS_WINDOWS_9X(t)) +#define OS_IS_WINDOWS(t) ((GET_KETA(t, 1000) == 1) || (GET_KETA(t, 1000) == 2)) +#define OS_IS_SERVER(t) (OS_IS_WINDOWS(t) && GET_KETA(t, 10)) +#define OS_IS_WORKSTATION(t) (OS_IS_WINDOWS(t) && !(GET_KETA(t, 10)) #define OS_IS_UNIX(t) (GET_KETA(t, 1000) == 3) diff --git a/src/Mayaqua/Microsoft.c b/src/Mayaqua/Microsoft.c index 802dcb09..af313043 100644 --- a/src/Mayaqua/Microsoft.c +++ b/src/Mayaqua/Microsoft.c @@ -29,16 +29,15 @@ typedef enum _PNP_VETO_TYPE { } PNP_VETO_TYPE, *PPNP_VETO_TYPE; #define _WIN32_IE 0x0600 -#define _WIN32_WINNT 0x0502 -#define WINVER 0x0502 +#define _WIN32_WINNT 0x0600 +#define WINVER 0x0600 #define SECURITY_WIN32 #include #include #include #include -#include #include -#include +#include #include #include #include @@ -65,6 +64,8 @@ typedef enum _PNP_VETO_TYPE { #include #include #include +#include +#include static MS *ms = NULL; @@ -99,9 +100,7 @@ static bool exiting = false; static bool wnd_end; static bool is_usermode = false; static HICON tray_icon; -static NOTIFYICONDATA nid; static NOTIFYICONDATAW nid_nt; -static bool service_for_9x_mode = false; static bool tray_inited = false; static HWND hWndUsermode = NULL; static HANDLE hLsa = NULL; @@ -333,7 +332,7 @@ bool MsSaveSystemInfo(wchar_t *dst_filename) { return false; } - if (MsIsAdmin() == false || MsIsWin2000OrGreater() == false) + if (MsIsAdmin() == false) { return false; } @@ -466,16 +465,6 @@ bool MsIsInVmMain() void *process; bool ret = false; - if (MsIsNt() == false) - { - return false; - } - - if (MsIsWin2000OrGreater() == false) - { - return false; - } - CombinePathW(bat_filename, sizeof(bat_filename), MsGetMyTempDirW(), L"detectvm.vbs"); if (DumpDataW(bat_data, StrLen(bat_data), bat_filename) == false) @@ -614,14 +603,6 @@ bool MsSetFileSecureAcl(wchar_t *path) { return false; } - if (ms->nt == NULL) - { - return false; - } - if (ms->nt->SetNamedSecurityInfoW == NULL || ms->nt->AddAccessAllowedAceEx == NULL) - { - return false; - } sid_system = MsGetSidFromAccountName("SYSTEM"); sid_admin = MsGetSidFromAccountName("Administrators"); @@ -635,10 +616,10 @@ bool MsSetFileSecureAcl(wchar_t *path) if (InitializeAcl(acl, acl_size, 2)) { - if (ms->nt->AddAccessAllowedAceEx(acl, 2, CONTAINER_INHERIT_ACE | OBJECT_INHERIT_ACE, GENERIC_ALL, sid_system) && - ms->nt->AddAccessAllowedAceEx(acl, 2, CONTAINER_INHERIT_ACE | OBJECT_INHERIT_ACE, GENERIC_ALL, sid_admin)) + if (AddAccessAllowedAceEx(acl, 2, CONTAINER_INHERIT_ACE | OBJECT_INHERIT_ACE, GENERIC_ALL, sid_system) && + AddAccessAllowedAceEx(acl, 2, CONTAINER_INHERIT_ACE | OBJECT_INHERIT_ACE, GENERIC_ALL, sid_admin)) { - if (ms->nt->SetNamedSecurityInfoW(path, SE_FILE_OBJECT, DACL_SECURITY_INFORMATION | PROTECTED_DACL_SECURITY_INFORMATION, NULL, NULL, acl, NULL) == ERROR_SUCCESS) + if (SetNamedSecurityInfoW(path, SE_FILE_OBJECT, DACL_SECURITY_INFORMATION | PROTECTED_DACL_SECURITY_INFORMATION, NULL, NULL, acl, NULL) == ERROR_SUCCESS) { ret = true; } @@ -659,45 +640,49 @@ void MsDisableWcmNetworkMinimize() { MS_WCM_POLICY_VALUE v; bool b; - if (ms->nt == NULL) - { - return; - } - if (ms->nt->WcmQueryProperty == NULL || ms->nt->WcmSetProperty == NULL || ms->nt->WcmFreeMemory == NULL || ms->nt->WcmGetProfileList == NULL) - { - return; - } if (MsIsWindows8() == false) { return; } - Zero(&v, sizeof(v)); - v.fIsGroupPolicy = true; - v.fValue = false; - b = false; - ms->nt->WcmSetProperty(NULL, NULL, ms_wcm_global_property_minimize_policy, NULL, sizeof(v), (const BYTE *)&v); - ms->nt->WcmSetProperty(NULL, NULL, ms_wcm_global_property_minimize_policy, NULL, sizeof(b), (const BYTE *)&b); + HMODULE hWcmapi = LoadLibrary("wcmapi.dll"); + if (!hWcmapi) + { + return; + } + + typedef DWORD (WINAPI* PWCMSETPROPERTY)(const GUID *, LPCWSTR, MS_WCM_PROPERTY, PVOID, DWORD, const BYTE *); + + PWCMSETPROPERTY WcmSetProperty = (PWCMSETPROPERTY)GetProcAddress(hWcmapi, "WcmSetProperty"); Zero(&v, sizeof(v)); v.fIsGroupPolicy = true; v.fValue = false; b = false; - ms->nt->WcmSetProperty(NULL, NULL, ms_wcm_global_property_domain_policy, NULL, sizeof(v), (const BYTE *)&v); - ms->nt->WcmSetProperty(NULL, NULL, ms_wcm_global_property_domain_policy, NULL, sizeof(b), (const BYTE *)&b); + WcmSetProperty(NULL, NULL, ms_wcm_global_property_minimize_policy, NULL, sizeof(v), (const BYTE *)&v); + WcmSetProperty(NULL, NULL, ms_wcm_global_property_minimize_policy, NULL, sizeof(b), (const BYTE *)&b); + + Zero(&v, sizeof(v)); + v.fIsGroupPolicy = true; + v.fValue = false; + b = false; + WcmSetProperty(NULL, NULL, ms_wcm_global_property_domain_policy, NULL, sizeof(v), (const BYTE *)&v); + WcmSetProperty(NULL, NULL, ms_wcm_global_property_domain_policy, NULL, sizeof(b), (const BYTE *)&b); Zero(&v, sizeof(v)); v.fIsGroupPolicy = false; v.fValue = false; - ms->nt->WcmSetProperty(NULL, NULL, ms_wcm_global_property_minimize_policy, NULL, sizeof(v), (const BYTE *)&v); - ms->nt->WcmSetProperty(NULL, NULL, ms_wcm_global_property_minimize_policy, NULL, sizeof(b), (const BYTE *)&b); + WcmSetProperty(NULL, NULL, ms_wcm_global_property_minimize_policy, NULL, sizeof(v), (const BYTE *)&v); + WcmSetProperty(NULL, NULL, ms_wcm_global_property_minimize_policy, NULL, sizeof(b), (const BYTE *)&b); Zero(&v, sizeof(v)); v.fIsGroupPolicy = false; v.fValue = false; - ms->nt->WcmSetProperty(NULL, NULL, ms_wcm_global_property_domain_policy, NULL, sizeof(v), (const BYTE *)&v); - ms->nt->WcmSetProperty(NULL, NULL, ms_wcm_global_property_domain_policy, NULL, sizeof(b), (const BYTE *)&b); + WcmSetProperty(NULL, NULL, ms_wcm_global_property_domain_policy, NULL, sizeof(v), (const BYTE *)&v); + WcmSetProperty(NULL, NULL, ms_wcm_global_property_domain_policy, NULL, sizeof(b), (const BYTE *)&b); + + FreeLibrary(hWcmapi); } // Request the MS-CHAPv2 authentication to the LSA @@ -783,7 +768,7 @@ bool MsPerformMsChapV2AuthByLsa(char *username, UCHAR *challenge8, UCHAR *client Zero(&logon_id, sizeof(logon_id)); Zero(&q, sizeof(q)); - i = ms->nt->LsaLogonUser(hLsa, &origin, Network, lsa_package_id, m, m_size, NULL, &lsa_token_source, + i = LsaLogonUser(hLsa, &origin, Network, lsa_package_id, m, m_size, NULL, &lsa_token_source, &profile_buffer, &profile_buffer_size, &logon_id, &hLogon, &q, &sub_status); if (i == 0) @@ -796,7 +781,7 @@ bool MsPerformMsChapV2AuthByLsa(char *username, UCHAR *challenge8, UCHAR *client ret = true; - ms->nt->LsaFreeReturnBuffer(profile_buffer); + LsaFreeReturnBuffer(profile_buffer); } CloseHandle(hLogon); } @@ -883,17 +868,7 @@ void *MsOpenOrCreateGlobalPulse(char *name) Sha1(hash, name, StrLen(name)); BinToStr(tmp, sizeof(tmp), hash, sizeof(hash)); - - Format(tmp2, sizeof(tmp2), "GlobalPulse_%s", tmp); - - if (OS_IS_WINDOWS_NT(GetOsInfo()->OsType)) - { - if (GET_KETA(GetOsInfo()->OsType, 100) >= 2 || - GetOsInfo()->OsType == OSTYPE_WINDOWS_NT_4_TERMINAL_SERVER) - { - Format(tmp2, sizeof(tmp2), "Global\\GlobalPulse_%s", tmp); - } - } + Format(tmp2, sizeof(tmp2), "Global\\GlobalPulse_%s", tmp); h = CreateEvent(NULL, true, false, tmp2); @@ -930,14 +905,7 @@ bool MsStartIPsecService() // Get the IPsec service name char *MsGetIPsecServiceName() { - char *svc_name = "PolicyAgent"; - - if (MsIsVista()) - { - svc_name = "ikeext"; - } - - return svc_name; + return "ikeext"; } // Initialize the global lock @@ -1024,55 +992,13 @@ bool MsGetFileInformation(void *h, void *info) return false; } - if (MsIsNt() == false) - { - return false; - } - - if (ms->nt->GetFileInformationByHandle == NULL) - { - return false; - } - - return ms->nt->GetFileInformationByHandle(h, info); + return GetFileInformationByHandle(h, info); } // Set the shutdown parameters of the process void MsSetShutdownParameters(UINT level, UINT flag) { - if (MsIsNt() == false) - { - return; - } - - if (ms->nt == false || ms->nt->SetProcessShutdownParameters == NULL) - { - return; - } - - ms->nt->SetProcessShutdownParameters(level, flag); -} - -// Get whether the version of the OS is Windows XP or Windows Vista or later -bool MsIsWinXPOrWinVista() -{ - OS_INFO *info = GetOsInfo(); - if (info == NULL) - { - return false; - } - - if (OS_IS_WINDOWS_NT(info->OsType) == false) - { - return false; - } - - if (GET_KETA(info->OsType, 100) >= 3) - { - return true; - } - - return false; + SetProcessShutdownParameters(level, flag); } // Restart of MMCSS @@ -1090,10 +1016,6 @@ void MsRestartMMCSS() void MsSetMMCSSNetworkThrottlingEnable(bool enable) { UINT value; - if (MsIsVista() == false) - { - return; - } if (enable) { @@ -1115,10 +1037,6 @@ void MsSetMMCSSNetworkThrottlingEnable(bool enable) bool MsIsMMCSSNetworkThrottlingEnabled() { UINT value; - if (MsIsVista() == false) - { - return false; - } if (MsRegIsKeyEx2(REG_LOCAL_MACHINE, MMCSS_PROFILE_KEYNAME, false, true) == false) { @@ -1435,14 +1353,6 @@ bool MsUniMakeDir(wchar_t *name) return false; } - if (MsIsNt() == false) - { - char *s = CopyUniToStr(name); - bool ret = MsMakeDir(s); - Free(s); - return ret; - } - return CreateDirectoryW(name, NULL); } bool MsMakeDir(char *name) @@ -1478,8 +1388,7 @@ void MsGetComputerNameFullEx(wchar_t *name, UINT size, bool with_cache) } } - if (MsIsNt() == false || ms->nt->GetComputerNameExW == NULL || - ms->nt->GetComputerNameExW(ComputerNameDnsFullyQualified, name, &size2) == false) + if (GetComputerNameExW(ComputerNameDnsFullyQualified, name, &size2) == false) { char tmp[MAX_SIZE]; @@ -1549,12 +1458,6 @@ void *MsRunAsUserExInnerW(wchar_t *filename, wchar_t *arg, bool hide) return NULL; } - if (MsIsVista() == false) - { - // Can not be used in non-Windows Vista - return NULL; - } - UniStrCpy(name, sizeof(name), filename); UniTrim(name); @@ -1596,7 +1499,7 @@ void *MsRunAsUserExInnerW(wchar_t *filename, wchar_t *arg, bool hide) return NULL; } - if (ms->nt->CreateProcessAsUserW(hToken, NULL, cmdline, NULL, NULL, FALSE, + if (CreateProcessAsUserW(hToken, NULL, cmdline, NULL, NULL, FALSE, (hide == false ? CREATE_NEW_CONSOLE : CREATE_NO_WINDOW | CREATE_NEW_CONSOLE) | NORMAL_PRIORITY_CLASS, NULL, NULL, &info, &ret) == FALSE) { @@ -1623,15 +1526,10 @@ SID *MsGetSidFromAccountName(char *name) return NULL; } - if (MsIsNt() == false) - { - return NULL; - } - sid = ZeroMalloc(sid_size); domain_name = ZeroMalloc(domain_name_size); - if (ms->nt->LookupAccountNameA(NULL, name, sid, &sid_size, domain_name, &domain_name_size, &use) == false) + if (LookupAccountNameA(NULL, name, sid, &sid_size, domain_name, &domain_name_size, &use) == false) { Free(sid); Free(domain_name); @@ -1662,22 +1560,10 @@ HANDLE MsCreateUserToken() PSID sid = NULL; TOKEN_MANDATORY_LABEL til; HANDLE hCurrentToken, hNewToken; - if (MsIsNt() == false) - { - return NULL; - } - if (ms->nt->ConvertStringSidToSidA == NULL || - ms->nt->OpenProcessToken == NULL || - ms->nt->DuplicateTokenEx == NULL || - ms->nt->GetTokenInformation == NULL || - ms->nt->SetTokenInformation == NULL) - { - return NULL; - } Zero(&til, sizeof(til)); - if (ms->nt->ConvertStringSidToSidA(medium_sid, &sid) == false) + if (ConvertStringSidToSidA(medium_sid, &sid) == false) { return NULL; } @@ -1685,13 +1571,13 @@ HANDLE MsCreateUserToken() til.Label.Attributes = SE_GROUP_INTEGRITY; til.Label.Sid = sid; - if (ms->nt->OpenProcessToken(GetCurrentProcess(), MAXIMUM_ALLOWED, &hCurrentToken) == false) + if (OpenProcessToken(GetCurrentProcess(), MAXIMUM_ALLOWED, &hCurrentToken) == false) { LocalFree(sid); return NULL; } - if (ms->nt->DuplicateTokenEx(hCurrentToken, MAXIMUM_ALLOWED, NULL, + if (DuplicateTokenEx(hCurrentToken, MAXIMUM_ALLOWED, NULL, SecurityImpersonation, TokenPrimary, &hNewToken) == false) { CloseHandle(hCurrentToken); @@ -1699,7 +1585,7 @@ HANDLE MsCreateUserToken() return NULL; } - if (ms->nt->SetTokenInformation(hNewToken, VistaTokenIntegrityLevel, &til, + if (SetTokenInformation(hNewToken, VistaTokenIntegrityLevel, &til, sizeof(TOKEN_MANDATORY_LABEL) + GetLengthSid(sid)) == false) { CloseHandle(hNewToken); @@ -1751,16 +1637,13 @@ bool MsIsKB3033929RequiredAndMissing() return false; } - if (OS_IS_WINDOWS_NT(info->OsType)) + if (GET_KETA(info->OsType, 100) == 6) { - if (GET_KETA(info->OsType, 100) == 6) + if (MsIsX64()) { - if (MsIsX64()) + if (MsIsSha2KernelModeSignatureSupported() == false) { - if (MsIsSha2KernelModeSignatureSupported() == false) - { - return true; - } + return true; } } } @@ -1854,13 +1737,7 @@ void *MsDisableWow64FileSystemRedirection() return NULL; } - if (ms->nt->Wow64DisableWow64FsRedirection == NULL || - ms->nt->Wow64RevertWow64FsRedirection == NULL) - { - return NULL; - } - - if (ms->nt->Wow64DisableWow64FsRedirection(&p) == false) + if (Wow64DisableWow64FsRedirection(&p) == false) { return NULL; } @@ -1890,13 +1767,7 @@ void MsRestoreWow64FileSystemRedirection(void *p) return; } - if (ms->nt->Wow64DisableWow64FsRedirection == NULL || - ms->nt->Wow64RevertWow64FsRedirection == NULL) - { - return; - } - - ms->nt->Wow64RevertWow64FsRedirection(p); + Wow64RevertWow64FsRedirection(p); } // Get whether the x64 version of Windows is currently running @@ -1908,13 +1779,9 @@ bool MsIsX64() { return false; } - if (ms->nt->GetNativeSystemInfo == NULL) - { - return false; - } Zero(&info, sizeof(info)); - ms->nt->GetNativeSystemInfo(&info); + GetNativeSystemInfo(&info); if (info.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64) { @@ -1947,34 +1814,14 @@ bool MsIs64BitWindows() { return true; } - else - { - if (MsIsNt() == false) - { - return false; - } - else - { - if (ms == NULL || ms->nt == NULL) - { - return false; - } - if (ms->nt->IsWow64Process == NULL) - { - return false; - } - else - { - BOOL b = false; - if (ms->nt->IsWow64Process(GetCurrentProcess(), &b) == false) - { - return false; - } - return b; - } - } + BOOL b = false; + if (IsWow64Process(GetCurrentProcess(), &b) == false) + { + return false; } + + return b; } // Windows Firewall registration @@ -2017,7 +1864,6 @@ void MsRegistWindowsFirewallEx(char *title, char *exe) char filename[MAX_PATH]; char cscript[MAX_PATH]; char arg[MAX_PATH]; - UINT ostype; IO *o; char hash[MAX_PATH]; UCHAR hashbin[SHA1_SIZE]; @@ -2029,27 +1875,18 @@ void MsRegistWindowsFirewallEx(char *title, char *exe) return; } - // OS check (This Is not performed except Windows XP, Windows Server 2003, Windows Vista or later) - ostype = GetOsInfo()->OsType; - if (OS_IS_WINDOWS_NT(ostype) == false) - { - return; - } if (MsIsAdmin() == false) { return; } - if (MsIsVista()) - { - data = "Option Explicit\r\n\r\nConst PROFILES_ALL = 7\r\nConst NET_FW_ACTION_ALLOWNET_FW_ACTION_ALLOW = 1\r\n" - "\r\nDim policy2\r\nDim rules\r\nDim new_rule\r\n\r\nOn Error Resume Next\r\n\r\n" - "Set policy2 = CreateObject(\"HNetCfg.FwPolicy2\")\r\nSet rules = policy2.Rules\r\n" - "Set new_rule = CreateObject(\"HNetCfg.FWRule\")\r\nnew_rule.Name = \"$TITLE$\"\r\n" - "new_rule.Description = \"$TITLE$\"\r\nnew_rule.ApplicationName = \"$PATH$\"\r\n" - "new_rule.Enabled = TRUE\r\nnew_rule.Profiles = PROFILES_ALL\r\nnew_rule.Action = " - "NET_FW_ACTION_ALLOWNET_FW_ACTION_ALLOW\r\nrules.Add new_rule\r\n\r\n"; - } + data = "Option Explicit\r\n\r\nConst PROFILES_ALL = 7\r\nConst NET_FW_ACTION_ALLOWNET_FW_ACTION_ALLOW = 1\r\n" + "\r\nDim policy2\r\nDim rules\r\nDim new_rule\r\n\r\nOn Error Resume Next\r\n\r\n" + "Set policy2 = CreateObject(\"HNetCfg.FwPolicy2\")\r\nSet rules = policy2.Rules\r\n" + "Set new_rule = CreateObject(\"HNetCfg.FWRule\")\r\nnew_rule.Name = \"$TITLE$\"\r\n" + "new_rule.Description = \"$TITLE$\"\r\nnew_rule.ApplicationName = \"$PATH$\"\r\n" + "new_rule.Enabled = TRUE\r\nnew_rule.Profiles = PROFILES_ALL\r\nnew_rule.Action = " + "NET_FW_ACTION_ALLOWNET_FW_ACTION_ALLOW\r\nrules.Add new_rule\r\n\r\n"; tmp_size = StrLen(data) * 4; tmp = ZeroMalloc(tmp_size); @@ -2063,7 +1900,7 @@ void MsRegistWindowsFirewallEx(char *title, char *exe) Sha1(file_hash_bin, tmp, StrLen(tmp)); BinToStr(file_hash_str, sizeof(file_hash_str), file_hash_bin, sizeof(file_hash_bin)); - if (MsIsVista() == false || MsRegReadIntEx2(REG_LOCAL_MACHINE, SOFTETHER_FW_SCRIPT_HASH, file_hash_str, false, true) == 0) + if (MsRegReadIntEx2(REG_LOCAL_MACHINE, SOFTETHER_FW_SCRIPT_HASH, file_hash_str, false, true) == 0) { Format(filename, sizeof(filename), "%s\\winfire_%s.vbs", MsGetMyTempDir(), hash); o = FileCreate(filename); @@ -2483,22 +2320,17 @@ void MsGetAdapterTcpIpInformation(MS_ADAPTER *a) return; } - if (w32net->GetAdaptersInfo == NULL) - { - return; - } - info_top = ZeroMalloc(sizeof(IP_ADAPTER_INFO)); info_size = sizeof(IP_ADAPTER_INFO); - ret = w32net->GetAdaptersInfo(info_top, &info_size); + ret = GetAdaptersInfo(info_top, &info_size); if (ret == ERROR_INSUFFICIENT_BUFFER || ret == ERROR_BUFFER_OVERFLOW) { Free(info_top); info_size *= 2; info_top = ZeroMalloc(info_size); - if (w32net->GetAdaptersInfo(info_top, &info_size) != NO_ERROR) + if (GetAdaptersInfo(info_top, &info_size) != NO_ERROR) { Free(info_top); return; @@ -2714,131 +2546,7 @@ MS_ADAPTER_LIST *MsCreateAdapterListInner() } MS_ADAPTER_LIST *MsCreateAdapterListInnerEx(bool no_info) { - LIST *o; - UINT i; - UINT retcode; - MIB_IFTABLE *table; - ULONG table_size = sizeof(MIB_IFTABLE); - MS_ADAPTER_LIST *ret; - - if (w32net->GetIfTable2 != NULL && w32net->FreeMibTable != NULL) - { - return MsCreateAdapterListInnerExVista(no_info); - } - - if (w32net->GetIfTable == NULL) - { - return ZeroMalloc(sizeof(MS_ADAPTER_LIST)); - } - - table = ZeroMalloc(table_size); - - retcode = w32net->GetIfTable(table, &table_size, TRUE); - if (retcode == ERROR_INSUFFICIENT_BUFFER || retcode == ERROR_BUFFER_OVERFLOW) - { - Free(table); - table_size *= 2; - table = ZeroMalloc(table_size); - if (w32net->GetIfTable(table, &table_size, TRUE) != NO_ERROR) - { - Free(table); - return ZeroMalloc(sizeof(MS_ADAPTER_LIST)); - } - } - else if (retcode != NO_ERROR) - { - Free(table); - return ZeroMalloc(sizeof(MS_ADAPTER_LIST)); - } - - o = NewListFast(NULL); - - for (i = 0;i < table->dwNumEntries;i++) - { - MIB_IFROW *r = &table->table[i]; - char title[MAX_PATH]; - MS_ADAPTER *a; - UINT j; - - //if (r->dwOperStatus == MIB_IF_OPER_STATUS_CONNECTED || r->dwOperStatus == MIB_IF_OPER_STATUS_OPERATIONAL) - { - //if (r->dwType & IF_TYPE_ETHERNET_CSMACD) - { - for (j = 1;;j++) - { - UINT k; - bool exists; - if (j == 1) - { - StrCpy(title, sizeof(title), (char *)r->bDescr); - } - else - { - Format(title, sizeof(title), "%s (%u)", (char *)r->bDescr, j); - } - - exists = false; - - for (k = 0;k < LIST_NUM(o);k++) - { - MS_ADAPTER *a = LIST_DATA(o, k); - - if (StrCmpi(a->Title, title) == 0) - { - exists = true; - break; - } - } - - if (exists == false) - { - break; - } - } - - a = ZeroMalloc(sizeof(MS_ADAPTER)); - - // Create an adapter information - StrCpy(a->Title, sizeof(a->Title), title); - StrToUni(a->TitleW, sizeof(a->TitleW), title); - a->Index = r->dwIndex; - a->Type = r->dwType; - a->Status = r->dwOperStatus; - a->Mtu = r->dwMtu; - a->Speed = r->dwSpeed; - a->AddressSize = MIN(sizeof(a->Address), r->dwPhysAddrLen); - Copy(a->Address, r->bPhysAddr, a->AddressSize); - a->RecvBytes = r->dwInOctets; - a->RecvPacketsBroadcast = r->dwInNUcastPkts; - a->RecvPacketsUnicast = r->dwInUcastPkts; - a->SendBytes = r->dwOutOctets; - a->SendPacketsBroadcast = r->dwOutNUcastPkts; - a->SendPacketsUnicast = r->dwOutUcastPkts; - - if (a->Type != IF_TYPE_ETHERNET_CSMACD) - { - a->IsNotEthernetLan = true; - } - - // TCP/IP information acquisition - if (no_info == false) - { - MsGetAdapterTcpIpInformation(a); - } - - Add(o, a); - } - } - } - - ret = ZeroMalloc(sizeof(MS_ADAPTER_LIST)); - ret->Num = LIST_NUM(o); - ret->Adapters = ToArray(o); - - ReleaseList(o); - Free(table); - - return ret; + return MsCreateAdapterListInnerExVista(no_info); } // Creating an adapters list (Windows Vista version) @@ -2850,12 +2558,7 @@ MS_ADAPTER_LIST *MsCreateAdapterListInnerExVista(bool no_info) PMIB_IF_TABLE2 table; MS_ADAPTER_LIST *ret; - if (w32net->GetIfTable2 == NULL || w32net->FreeMibTable == NULL) - { - return ZeroMalloc(sizeof(MS_ADAPTER_LIST)); - } - - retcode = w32net->GetIfTable2((void **)&table); + retcode = GetIfTable2(&table); if (retcode != NO_ERROR || table == NULL) { return ZeroMalloc(sizeof(MS_ADAPTER_LIST)); @@ -2956,7 +2659,7 @@ MS_ADAPTER_LIST *MsCreateAdapterListInnerExVista(bool no_info) ret->Adapters = ToArray(o); ReleaseList(o); - w32net->FreeMibTable(table); + FreeMibTable(table); return ret; } @@ -3350,14 +3053,9 @@ LIST *MsGetProcessListNt() o = NewListFast(MsCompareProcessList); - if (ms->nt->EnumProcesses == NULL) - { - return o; - } - processes = ZeroMalloc(sizeof(DWORD) * max); - if (ms->nt->EnumProcesses(processes, sizeof(DWORD) * max, &needed) == FALSE) + if (EnumProcesses(processes, sizeof(DWORD) * max, &needed) == FALSE) { Free(processes); return NULL; @@ -3383,20 +3081,18 @@ LIST *MsGetProcessListNt() sz1 = sizeof(exe) - 1; sz2 = sizeof(exe_w) / sizeof(wchar_t) - 1; - if (ms->nt->EnumProcessModules(h, &hInst, sizeof(hInst), &needed) == false) + if (EnumProcessModules(h, &hInst, sizeof(hInst), &needed) == false) { hInst = NULL; } - if (ms->nt->GetModuleFileNameExA(h, hInst, exe, sizeof(exe) - 1) && - ms->nt->GetModuleFileNameExW(h, hInst, exe_w, sizeof(exe_w) / sizeof(wchar_t) - 1)) + if (GetModuleFileNameExA(h, hInst, exe, sizeof(exe) - 1) && + GetModuleFileNameExW(h, hInst, exe_w, sizeof(exe_w) / sizeof(wchar_t) - 1)) { ok = true; } - else if (ms->nt->QueryFullProcessImageNameA != NULL && - ms->nt->QueryFullProcessImageNameW != NULL && - ms->nt->QueryFullProcessImageNameA(h, 0, exe, &sz1) && - ms->nt->QueryFullProcessImageNameW(h, 0, exe_w, &sz2)) + else if (QueryFullProcessImageNameA(h, 0, exe, &sz1) && + QueryFullProcessImageNameW(h, 0, exe_w, &sz2)) { ok = true; } @@ -3423,73 +3119,10 @@ LIST *MsGetProcessListNt() return o; } -// Get the Process List (for Win9x) -LIST *MsGetProcessList9x() -{ - HANDLE h; - LIST *o; - HANDLE (WINAPI *CreateToolhelp32Snapshot)(DWORD, DWORD); - BOOL (WINAPI *Process32First)(HANDLE, LPPROCESSENTRY32); - BOOL (WINAPI *Process32Next)(HANDLE, LPPROCESSENTRY32); - - CreateToolhelp32Snapshot = - (HANDLE (__stdcall *)(DWORD,DWORD)) - GetProcAddress(ms->hKernel32, "CreateToolhelp32Snapshot"); - Process32First = - (BOOL (__stdcall *)(HANDLE,LPPROCESSENTRY32)) - GetProcAddress(ms->hKernel32, "Process32First"); - Process32Next = - (BOOL (__stdcall *)(HANDLE,LPPROCESSENTRY32)) - GetProcAddress(ms->hKernel32, "Process32Next"); - - o = NewListFast(MsCompareProcessList); - - if (CreateToolhelp32Snapshot != NULL && Process32First != NULL && Process32Next != NULL) - { - h = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0); - if (h != INVALID_HANDLE_VALUE) - { - PROCESSENTRY32 e; - Zero(&e, sizeof(e)); - e.dwSize = sizeof(e); - - if (Process32First(h, &e)) - { - while (true) - { - MS_PROCESS *p = ZeroMalloc(sizeof(MS_PROCESS)); - StrCpy(p->ExeFilename, sizeof(p->ExeFilename), e.szExeFile); - StrToUni(p->ExeFilenameW, sizeof(p->ExeFilenameW), p->ExeFilename); - p->ProcessId = e.th32ProcessID; - Add(o, p); - if (Process32Next(h, &e) == false) - { - break; - } - } - } - CloseHandle(h); - } - } - - Sort(o); - - return o; -} - // Get the Process List LIST *MsGetProcessList() { - if (MsIsNt() == false) - { - // Windows 9x - return MsGetProcessList9x(); - } - else - { - // Windows NT, 2000, XP - return MsGetProcessListNt(); - } + return MsGetProcessListNt(); } // Force to run the current thread on a single CPU @@ -3538,31 +3171,16 @@ bool MsShowIconOnTray(HWND hWnd, HICON icon, wchar_t *tooltip, UINT msg) return true; } - if (MsIsNt() == false) - { - Zero(&nid, sizeof(nid)); - nid.cbSize = sizeof(nid); - nid.hWnd = hWnd; - nid.uID = 1; - nid.uFlags = NIF_ICON | NIF_MESSAGE | NIF_TIP | NIF_INFO; - nid.uCallbackMessage = msg; - nid.hIcon = icon; - UniToStr(nid.szTip, sizeof(nid.szTip), tooltip); - ret = Shell_NotifyIcon(NIM_ADD, &nid); - } - else - { - Zero(&nid_nt, sizeof(nid_nt)); - nid_nt.cbSize = sizeof(nid_nt); - nid_nt.hWnd = hWnd; - nid_nt.uID = 1; - nid_nt.uFlags = NIF_ICON | NIF_MESSAGE | NIF_TIP | NIF_INFO; - nid_nt.uCallbackMessage = msg; - nid_nt.hIcon = icon; - UniStrCpy(nid_nt.szTip, sizeof(nid_nt.szTip), tooltip); + Zero(&nid_nt, sizeof(nid_nt)); + nid_nt.cbSize = sizeof(nid_nt); + nid_nt.hWnd = hWnd; + nid_nt.uID = 1; + nid_nt.uFlags = NIF_ICON | NIF_MESSAGE | NIF_TIP | NIF_INFO; + nid_nt.uCallbackMessage = msg; + nid_nt.hIcon = icon; + UniStrCpy(nid_nt.szTip, sizeof(nid_nt.szTip), tooltip); - ret = Shell_NotifyIconW(NIM_ADD, &nid_nt); - } + ret = Shell_NotifyIconW(NIM_ADD, &nid_nt); tray_inited = true; @@ -3577,14 +3195,7 @@ void MsRestoreIconOnTray() return; } - if (MsIsNt() == false) - { - Shell_NotifyIcon(NIM_ADD, &nid); - } - else - { - Shell_NotifyIconW(NIM_ADD, &nid_nt); - } + Shell_NotifyIconW(NIM_ADD, &nid_nt); } // Change the icon in the task tray @@ -3604,103 +3215,48 @@ bool MsChangeIconOnTrayEx(HICON icon, wchar_t *tooltip, wchar_t *info_title, wch if (icon != NULL) { - if (MsIsNt() == false) + if (nid_nt.hIcon != icon) { - if (nid.hIcon != icon) - { - changed = true; - nid.hIcon = icon; - } - } - else - { - if (nid_nt.hIcon != icon) - { - changed = true; - nid_nt.hIcon = icon; - } + changed = true; + nid_nt.hIcon = icon; } } if (tooltip != NULL) { - if (MsIsNt() == false) + wchar_t tmp[MAX_SIZE]; + UniStrCpy(tmp, sizeof(tmp), tooltip); + + if (UniStrCmp(nid_nt.szTip, tmp) != 0) { - char tmp[MAX_SIZE]; - - UniToStr(tmp, sizeof(tmp), tooltip); - - if (StrCmp(nid.szTip, tmp) != 0) - { - StrCpy(nid.szTip, sizeof(nid.szTip), tmp); - changed = true; - } - } - else - { - wchar_t tmp[MAX_SIZE]; - - UniStrCpy(tmp, sizeof(tmp), tooltip); - - if (UniStrCmp(nid_nt.szTip, tmp) != 0) - { - UniStrCpy(nid_nt.szTip, sizeof(nid_nt.szTip), tmp); - changed = true; - } + UniStrCpy(nid_nt.szTip, sizeof(nid_nt.szTip), tmp); + changed = true; } } if (info_title != NULL && info != NULL) { - if (MsIsNt() == false) + wchar_t tmp1[MAX_SIZE]; + wchar_t tmp2[MAX_PATH]; + + UniStrCpy(tmp1, sizeof(tmp1), info_title); + UniStrCpy(tmp2, sizeof(tmp2), info); + + if (UniStrCmp(nid_nt.szInfo, tmp1) != 0 || + UniStrCmp(nid_nt.szInfoTitle, tmp2) != 0) { - char tmp1[MAX_SIZE]; - char tmp2[MAX_PATH]; + UniStrCpy(nid_nt.szInfo, sizeof(nid_nt.szInfo), tmp1); + UniStrCpy(nid_nt.szInfoTitle, sizeof(nid_nt.szInfoTitle), tmp2); + nid_nt.dwInfoFlags = info_flags; - UniToStr(tmp1, sizeof(tmp1), info_title); - UniToStr(tmp2, sizeof(tmp2), info); - - if (StrCmp(nid.szInfo, tmp1) != 0 || - StrCmp(nid.szInfoTitle, tmp2) != 0) - { - StrCpy(nid.szInfo, sizeof(nid.szInfo), tmp1); - StrCpy(nid.szInfoTitle, sizeof(nid.szInfoTitle), tmp2); - nid.dwInfoFlags = info_flags; - - changed = true; - } - } - else - { - wchar_t tmp1[MAX_SIZE]; - wchar_t tmp2[MAX_PATH]; - - UniStrCpy(tmp1, sizeof(tmp1), info_title); - UniStrCpy(tmp2, sizeof(tmp2), info); - - if (UniStrCmp(nid_nt.szInfo, tmp1) != 0 || - UniStrCmp(nid_nt.szInfoTitle, tmp2) != 0) - { - UniStrCpy(nid_nt.szInfo, sizeof(nid_nt.szInfo), tmp1); - UniStrCpy(nid_nt.szInfoTitle, sizeof(nid_nt.szInfoTitle), tmp2); - nid_nt.dwInfoFlags = info_flags; - - changed = true; - } + changed = true; } } if (changed || add) { UINT op = (add ? NIM_ADD : NIM_MODIFY); - if (MsIsNt() == false) - { - ret = Shell_NotifyIcon(op, &nid); - } - else - { - ret = Shell_NotifyIconW(op, &nid_nt); - } + ret = Shell_NotifyIconW(op, &nid_nt); } return ret; @@ -3709,54 +3265,20 @@ bool MsChangeIconOnTrayEx(HICON icon, wchar_t *tooltip, wchar_t *info_title, wch // Remove the icon in the task tray void MsHideIconOnTray() { - if (MsIsNt() == false) - { - Shell_NotifyIcon(NIM_DELETE, &nid); - } - else - { - Shell_NotifyIconW(NIM_DELETE, &nid_nt); - } - + Shell_NotifyIconW(NIM_DELETE, &nid_nt); tray_inited = false; } // Insert a menu item bool MsInsertMenu(HMENU hMenu, UINT pos, UINT flags, UINT_PTR id_new_item, wchar_t *lp_new_item) { - bool ret; - - if (MsIsNt()) - { - ret = InsertMenuW(hMenu, pos, flags, id_new_item, lp_new_item); - } - else - { - char *s = CopyUniToStr(lp_new_item); - ret = InsertMenuA(hMenu, pos, flags, id_new_item, s); - Free(s); - } - - return ret; + return InsertMenuW(hMenu, pos, flags, id_new_item, lp_new_item); } // Adding a menu item bool MsAppendMenu(HMENU hMenu, UINT flags, UINT_PTR id, wchar_t *str) { - bool ret; - - if (MsIsNt()) - { - ret = AppendMenuW(hMenu, flags, id, str); - } - else - { - char *s = CopyUniToStr(str); - ret = AppendMenuA(hMenu, flags, id, s); - Free(s); - } - - return ret; + return AppendMenuW(hMenu, flags, id, str); } // Display the menu @@ -3777,16 +3299,7 @@ void MsUserModeTrayMenu(HWND hWnd) MsAppendMenu(h, MF_ENABLED | MF_STRING, 10001, _UU("SVC_USERMODE_MENU_1")); MsAppendMenu(h, MF_SEPARATOR, 10002, NULL); - if (MsIsNt()) - { - GetWindowTextW(hWnd, caption, sizeof(caption)); - } - else - { - char tmp[MAX_SIZE]; - GetWindowTextA(hWnd, tmp, sizeof(tmp)); - StrToUni(caption, sizeof(caption), tmp); - } + GetWindowTextW(hWnd, caption, sizeof(caption) / sizeof(caption[0])); UniFormat(tmp, sizeof(tmp), _UU("SVC_USERMODE_MENU_2"), caption); MsAppendMenu(h, MF_ENABLED | MF_STRING, 10003, tmp); @@ -3818,8 +3331,7 @@ LRESULT CALLBACK MsUserModeWindowProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM if (msg == taskbar_msg && taskbar_msg != 0) { // The taskbar was regenerated - if (MsRegReadInt(REG_CURRENT_USER, SVC_USERMODE_SETTING_KEY, value_name) == 0 && - service_for_9x_mode == false) + if (MsRegReadInt(REG_CURRENT_USER, SVC_USERMODE_SETTING_KEY, value_name) == 0) { MsRestoreIconOnTray(); } @@ -3847,8 +3359,7 @@ LRESULT CALLBACK MsUserModeWindowProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM } Format(value_name, sizeof(value_name), SVC_HIDETRAY_REG_VALUE, title_w); - if (MsRegReadInt(REG_CURRENT_USER, SVC_USERMODE_SETTING_KEY, value_name) == 0 && - service_for_9x_mode == false) + if (MsRegReadInt(REG_CURRENT_USER, SVC_USERMODE_SETTING_KEY, value_name) == 0) { MsShowIconOnTray(hWnd, tray_icon, tmp, WM_APP + 33); } @@ -4089,19 +3600,15 @@ LRESULT CALLBACK MsSuspendHandlerWindowProc(HWND hWnd, UINT msg, WPARAM wParam, break; case WM_POWERBROADCAST: - if (MsIsVista()) + switch (wParam) { - switch (wParam) - { - case PBT_APMSUSPEND: - MsProcEnterSuspend(); - return 1; - - case PBT_APMRESUMEAUTOMATIC: - case PBT_APMRESUMESUSPEND: - MsProcLeaveSuspend(); - return 1; - } + case PBT_APMSUSPEND: + MsProcEnterSuspend(); + return 1; + case PBT_APMRESUMEAUTOMATIC: + case PBT_APMRESUMESUSPEND: + MsProcLeaveSuspend(); + return 1; } break; @@ -4258,11 +3765,7 @@ void MsUserModeW(wchar_t *title, SERVICE_FUNCTION *start, SERVICE_FUNCTION *stop inst = NewSingleInstance(NULL); if (inst == NULL) { - if (service_for_9x_mode == false) - { - // Do not display an error if Win9x service mode - MsgBoxEx(NULL, MB_ICONINFORMATION, _UU("SVC_USERMODE_MUTEX"), ms->ExeFileNameW); - } + MsgBoxEx(NULL, MB_ICONINFORMATION, _UU("SVC_USERMODE_MUTEX"), ms->ExeFileNameW); return; } @@ -4277,7 +3780,7 @@ void MsUserModeW(wchar_t *title, SERVICE_FUNCTION *start, SERVICE_FUNCTION *stop // Read icon tray_icon = LoadImage(hDll, MAKEINTRESOURCE(icon), IMAGE_ICON, 16, 16, - (MsIsNt() ? LR_SHARED : 0) | LR_VGACOLOR); + LR_SHARED | LR_VGACOLOR); // Creating the main window Zero(&wc, sizeof(wc)); @@ -4751,18 +4254,6 @@ UINT MsService(char *name, SERVICE_FUNCTION *start, SERVICE_FUNCTION *stop, UINT { mode = SVC_MODE_SETUP_UNINSTALL; } - if (StrCmpi(arg, SVC_ARG_WIN9X_SERVICE) == 0) - { - mode = SVC_MODE_WIN9X_SERVICE; - } - if (StrCmpi(arg, SVC_ARG_WIN9X_INSTALL) == 0) - { - mode = SVC_MODE_WIN9X_INSTALL; - } - if (StrCmpi(arg, SVC_ARG_WIN9X_UNINSTALL) == 0) - { - mode = SVC_MODE_WIN9X_UNINSTALL; - } if (StrCmpi(arg, SVC_ARG_TCP) == 0) { mode = SVC_MODE_TCP; @@ -5127,60 +4618,10 @@ UINT MsService(char *name, SERVICE_FUNCTION *start, SERVICE_FUNCTION *stop, UINT // Test mode MsTestModeW(service_title, start, stop); break; - - case SVC_MODE_WIN9X_SERVICE: - // Win9x service mode (hide icon in the task tray unconditionally) - if (MsIsNt()) - { - // Don't do this on Windows 2000 or later - break; - } - service_for_9x_mode = true; - // Not a oblivion to break case SVC_MODE_USERMODE: // User mode MsUserModeW(service_title, start, stop, icon); break; - - case SVC_MODE_WIN9X_INSTALL: - // Win9x installation mode - MsWriteCallingServiceManagerProcessId(service_name, MsGetCurrentProcessId()); - restoreReg = true; - - if (MsIsNt() == false) - { - // Adding a registry key - char cmdline[MAX_PATH]; - Format(cmdline, sizeof(cmdline), "\"%s\" %s", - MsGetExeFileName(), SVC_ARG_WIN9X_SERVICE); - MsRegWriteStr(REG_LOCAL_MACHINE, WIN9X_SVC_REGKEY_1, - name, cmdline); - MsRegWriteStr(REG_LOCAL_MACHINE, WIN9X_SVC_REGKEY_2, - name, cmdline); - - // Start - //Run(MsGetExeFileName(), SVC_ARG_WIN9X_SERVICE, false, false); - } - break; - - case SVC_MODE_WIN9X_UNINSTALL: - // Win9x uninstall mode - MsWriteCallingServiceManagerProcessId(service_name, MsGetCurrentProcessId()); - restoreReg = true; - - if (MsIsNt() == false) - { - // Delete the registry key - MsRegDeleteValue(REG_LOCAL_MACHINE, WIN9X_SVC_REGKEY_1, - name); - MsRegDeleteValue(REG_LOCAL_MACHINE, WIN9X_SVC_REGKEY_2, - name); - - // Terminate all the processes of PacketiX VPN Client other than itself - MsKillOtherInstance(); - } - break; - case SVC_MODE_SERVICE: // Run as a service // Obsoleted (2012.12.31) (Do this in the above code) @@ -5193,7 +4634,7 @@ UINT MsService(char *name, SERVICE_FUNCTION *start, SERVICE_FUNCTION *stop, UINT InitCedar(); InitWinUi(service_title_uni, NULL, 0); - if (MsIsVista() && MsIsAdmin() == false && mode != SVC_MODE_TCP_UAC) + if (MsIsAdmin() == false && mode != SVC_MODE_TCP_UAC) { void *handle = NULL; if (MsExecuteEx2W(ms->ExeFileNameW, SVC_ARG_TCP_UAC_W, &handle, true) == false) @@ -5219,7 +4660,7 @@ UINT MsService(char *name, SERVICE_FUNCTION *start, SERVICE_FUNCTION *stop, UINT InitCedar(); InitWinUi(service_title_uni, NULL, 0); - if (MsIsVista() && MsIsAdmin() == false) + if (MsIsAdmin() == false) { void *handle = NULL; if (MsExecuteEx2W(ms->ExeFileNameW, arg_w, &handle, true) == false) @@ -5278,8 +4719,8 @@ wchar_t *MsGetSessionUserName(UINT session_id) wchar_t *ret; wchar_t *name; DWORD size = 0; - if (ms->nt->WTSQuerySessionInformation(WTS_CURRENT_SERVER_HANDLE, session_id, - WTSUserName, (wchar_t *)&name, &size) == false) + if (WTSQuerySessionInformationW(WTS_CURRENT_SERVER_HANDLE, session_id, + WTSUserName, (LPWSTR *)&name, &size) == false) { return NULL; } @@ -5293,7 +4734,7 @@ wchar_t *MsGetSessionUserName(UINT session_id) ret = UniCopyStr(name); } - ms->nt->WTSFreeMemory(name); + WTSFreeMemory(name); return ret; } @@ -5315,8 +4756,8 @@ bool MsIsTerminalSessionActive(UINT session_id) DWORD size = sizeof(status); bool active = true; - if (ms->nt->WTSQuerySessionInformation(WTS_CURRENT_SERVER_HANDLE, session_id, - WTSConnectState, (wchar_t *)&status, &size) == false) + if (WTSQuerySessionInformationW(WTS_CURRENT_SERVER_HANDLE, session_id, + WTSConnectState, (LPWSTR *)&status, &size) == false) { return true; } @@ -5332,7 +4773,7 @@ bool MsIsTerminalSessionActive(UINT session_id) break; } - ms->nt->WTSFreeMemory(status); + WTSFreeMemory(status); return active; } @@ -5348,15 +4789,15 @@ UINT MsGetCurrentTerminalSessionId() UINT ret; UINT *session_id = NULL; DWORD size = sizeof(session_id); - if (ms->nt->WTSQuerySessionInformation(WTS_CURRENT_SERVER_HANDLE, WTS_CURRENT_SESSION, - WTSSessionId, (wchar_t *)&session_id, &size) == false) + if (WTSQuerySessionInformationW(WTS_CURRENT_SERVER_HANDLE, WTS_CURRENT_SESSION, + WTSSessionId, (LPWSTR *)&session_id, &size) == false) { return 0; } ret = *session_id; - ms->nt->WTSFreeMemory(session_id); + WTSFreeMemory(session_id); return ret; } @@ -5367,26 +4808,7 @@ UINT MsGetCurrentTerminalSessionId() // Examine whether the user switching is installed bool MsIsUserSwitchingInstalled() { - OS_INFO *info = GetOsInfo(); OSVERSIONINFOEX i; - - if (OS_IS_WINDOWS_NT(info->OsType) == false) - { - return false; - } - - if (ms->nt->WTSDisconnectSession == NULL || - ms->nt->WTSFreeMemory == NULL || - ms->nt->WTSQuerySessionInformation == NULL) - { - return false; - } - - if (GET_KETA(info->OsType, 100) < 2) - { - return false; - } - Zero(&i, sizeof(i)); i.dwOSVersionInfoSize = sizeof(i); if (GetVersionEx((OSVERSIONINFO *)&i) == false) @@ -5402,65 +4824,10 @@ bool MsIsUserSwitchingInstalled() return false; } -// Examine whether Windows 2000 or later -bool MsIsWin2000OrGreater() -{ - OS_INFO *info = GetOsInfo(); - - if (OS_IS_WINDOWS_NT(info->OsType) == false) - { - return false; - } - - if (GET_KETA(info->OsType, 100) >= 2) - { - return true; - } - - return false; -} - -// Examine whether Windows XP or later -bool MsIsWinXPOrGreater() -{ - OS_INFO *info = GetOsInfo(); - - if (OS_IS_WINDOWS_NT(info->OsType) == false) - { - return false; - } - - if (GET_KETA(info->OsType, 100) >= 3) - { - return true; - } - - return false; -} - // Examine whether the Terminal Services is installed bool MsIsTerminalServiceInstalled() { - OS_INFO *info = GetOsInfo(); OSVERSIONINFOEX i; - - if (OS_IS_WINDOWS_NT(info->OsType) == false) - { - return false; - } - - if (ms->nt->WTSDisconnectSession == NULL || - ms->nt->WTSFreeMemory == NULL || - ms->nt->WTSQuerySessionInformation == NULL) - { - return false; - } - - if (GET_KETA(info->OsType, 100) < 2) - { - return false; - } - Zero(&i, sizeof(i)); i.dwOSVersionInfoSize = sizeof(i); if (GetVersionEx((OSVERSIONINFO *)&i) == false) @@ -5486,24 +4853,20 @@ bool MsStopService(char *name) { return false; } - if (ms->IsNt == false) - { - return false; - } - sc = ms->nt->OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS); + sc = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS); if (sc == NULL) { return false; } - service = ms->nt->OpenService(sc, name, SERVICE_ALL_ACCESS); + service = OpenService(sc, name, SERVICE_ALL_ACCESS); if (service != NULL) { SERVICE_STATUS st; - ret = ms->nt->ControlService(service, SERVICE_CONTROL_STOP, &st); + ret = ControlService(service, SERVICE_CONTROL_STOP, &st); - ms->nt->CloseServiceHandle(service); + CloseServiceHandle(service); } if (ret) @@ -5520,7 +4883,7 @@ bool MsStopService(char *name) } } - ms->nt->CloseServiceHandle(sc); + CloseServiceHandle(sc); return ret; } @@ -5539,10 +4902,7 @@ bool MsStartServiceEx(char *name, UINT *error_code) { return false; } - if (ms->IsNt == false) - { - return false; - } + if (error_code == NULL) { error_code = &dummy; @@ -5550,19 +4910,19 @@ bool MsStartServiceEx(char *name, UINT *error_code) *error_code = 0; - sc = ms->nt->OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS); + sc = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS); if (sc == NULL) { *error_code = GetLastError(); return false; } - service = ms->nt->OpenService(sc, name, SERVICE_ALL_ACCESS); + service = OpenService(sc, name, SERVICE_ALL_ACCESS); if (service != NULL) { - ret = ms->nt->StartService(service, 0, NULL); + ret = StartService(service, 0, NULL); - ms->nt->CloseServiceHandle(service); + CloseServiceHandle(service); } else { @@ -5583,7 +4943,7 @@ bool MsStartServiceEx(char *name, UINT *error_code) } } - ms->nt->CloseServiceHandle(sc); + CloseServiceHandle(sc); return ret; } @@ -5597,23 +4957,19 @@ bool MsIsServiceRunning(char *name) { return false; } - if (ms->IsNt == false) - { - return false; - } - sc = ms->nt->OpenSCManager(NULL, NULL, GENERIC_READ); + sc = OpenSCManager(NULL, NULL, GENERIC_READ); if (sc == NULL) { return false; } - service = ms->nt->OpenService(sc, name, GENERIC_READ); + service = OpenService(sc, name, GENERIC_READ); if (service != NULL) { SERVICE_STATUS st; Zero(&st, sizeof(st)); - if (ms->nt->QueryServiceStatus(service, &st)) + if (QueryServiceStatus(service, &st)) { switch (st.dwCurrentState) { @@ -5628,10 +4984,10 @@ bool MsIsServiceRunning(char *name) } } - ms->nt->CloseServiceHandle(service); + CloseServiceHandle(service); } - ms->nt->CloseServiceHandle(sc); + CloseServiceHandle(sc); return ret; } @@ -5645,30 +5001,26 @@ bool MsUninstallService(char *name) { return false; } - if (ms->IsNt == false) - { - return false; - } MsStopService(name); - sc = ms->nt->OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS); + sc = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS); if (sc == NULL) { return false; } - service = ms->nt->OpenService(sc, name, SERVICE_ALL_ACCESS); + service = OpenService(sc, name, SERVICE_ALL_ACCESS); if (service != NULL) { - if (ms->nt->DeleteService(service)) + if (DeleteService(service)) { ret = true; } - ms->nt->CloseServiceHandle(service); + CloseServiceHandle(service); } - ms->nt->CloseServiceHandle(sc); + CloseServiceHandle(sc); if (ret) { @@ -5688,13 +5040,13 @@ bool MsSetServiceDescription(char *name, wchar_t *description) return false; } - sc = ms->nt->OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS); + sc = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS); if (sc == NULL) { return false; } - service = ms->nt->OpenService(sc, name, SERVICE_ALL_ACCESS); + service = OpenService(sc, name, SERVICE_ALL_ACCESS); if (service != NULL) { if (GET_KETA(GetOsInfo()->OsType, 100) >= 2) @@ -5705,14 +5057,14 @@ bool MsSetServiceDescription(char *name, wchar_t *description) { Zero(&d, sizeof(d)); d.lpDescription = description; - ms->nt->ChangeServiceConfig2(service, SERVICE_CONFIG_DESCRIPTION, &d); + ChangeServiceConfig2(service, SERVICE_CONFIG_DESCRIPTION, &d); } } - ms->nt->CloseServiceHandle(service); + CloseServiceHandle(service); } - ms->nt->CloseServiceHandle(sc); + CloseServiceHandle(sc); return true; } @@ -5736,13 +5088,13 @@ bool MsUpdateServiceConfig(char *name) } } - sc = ms->nt->OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS); + sc = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS); if (sc == NULL) { return false; } - service = ms->nt->OpenService(sc, name, SERVICE_ALL_ACCESS); + service = OpenService(sc, name, SERVICE_ALL_ACCESS); if (service != NULL) { if (GET_KETA(GetOsInfo()->OsType, 100) >= 2) @@ -5757,7 +5109,7 @@ bool MsUpdateServiceConfig(char *name) action.cActions = 3; action.lpsaActions = e; action.dwResetPeriod = 1 * 60 * 60 * 24; - ms->nt->ChangeServiceConfig2(service, SERVICE_CONFIG_FAILURE_ACTIONS, &action); + ChangeServiceConfig2(service, SERVICE_CONFIG_FAILURE_ACTIONS, &action); MsRegWriteInt(REG_LOCAL_MACHINE, "Software\\" GC_REG_COMPANY_NAME "\\Update Service Config", name, 1); } @@ -5777,14 +5129,14 @@ bool MsUpdateServiceConfig(char *name) { Zero(&d, sizeof(d)); d.lpDescription = description; - ms->nt->ChangeServiceConfig2(service, SERVICE_CONFIG_DESCRIPTION, &d); + ChangeServiceConfig2(service, SERVICE_CONFIG_DESCRIPTION, &d); } } - ms->nt->CloseServiceHandle(service); + CloseServiceHandle(service); } - ms->nt->CloseServiceHandle(sc); + CloseServiceHandle(sc); return true; } @@ -5801,10 +5153,7 @@ bool MsInstallDeviceDriverW(char *name, wchar_t *title, wchar_t *path, UINT *err { return false; } - if (ms->IsNt == false) - { - return false; - } + if (error_code == NULL) { error_code = &temp_int; @@ -5814,14 +5163,14 @@ bool MsInstallDeviceDriverW(char *name, wchar_t *title, wchar_t *path, UINT *err StrToUni(name_w, sizeof(name_w), name); - sc = ms->nt->OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS); + sc = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS); if (sc == NULL) { *error_code = GetLastError(); return false; } - service = ms->nt->CreateServiceW(sc, name_w, title, SERVICE_ALL_ACCESS, + service = CreateServiceW(sc, name_w, title, SERVICE_ALL_ACCESS, SERVICE_KERNEL_DRIVER, SERVICE_DEMAND_START, SERVICE_ERROR_NORMAL, path, NULL, NULL, NULL, NULL, NULL); @@ -5829,14 +5178,14 @@ bool MsInstallDeviceDriverW(char *name, wchar_t *title, wchar_t *path, UINT *err { ret = true; - ms->nt->CloseServiceHandle(service); + CloseServiceHandle(service); } else { *error_code = GetLastError(); } - ms->nt->CloseServiceHandle(sc); + CloseServiceHandle(sc); if (ret) { @@ -5862,10 +5211,7 @@ bool MsInstallServiceExW(char *name, wchar_t *title, wchar_t *description, wchar { return false; } - if (ms->IsNt == false) - { - return false; - } + if (error_code == NULL) { error_code = &temp_int; @@ -5875,15 +5221,15 @@ bool MsInstallServiceExW(char *name, wchar_t *title, wchar_t *description, wchar StrToUni(name_w, sizeof(name_w), name); - sc = ms->nt->OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS); + sc = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS); if (sc == NULL) { *error_code = GetLastError(); return false; } - service = ms->nt->CreateServiceW(sc, name_w, title, SERVICE_ALL_ACCESS, - SERVICE_WIN32_OWN_PROCESS | (MsIsVista() ? 0 : SERVICE_INTERACTIVE_PROCESS), SERVICE_AUTO_START, + service = CreateServiceW(sc, name_w, title, SERVICE_ALL_ACCESS, + SERVICE_WIN32_OWN_PROCESS, SERVICE_AUTO_START, SERVICE_ERROR_NORMAL, path, NULL, NULL, NULL, NULL, NULL); if (service != NULL) @@ -5897,7 +5243,7 @@ bool MsInstallServiceExW(char *name, wchar_t *title, wchar_t *description, wchar SC_ACTION *e; Zero(&d, sizeof(d)); d.lpDescription = description; - ms->nt->ChangeServiceConfig2(service, SERVICE_CONFIG_DESCRIPTION, &d); + ChangeServiceConfig2(service, SERVICE_CONFIG_DESCRIPTION, &d); Zero(&action, sizeof(action)); e = ZeroMalloc(sizeof(SC_ACTION) * 3); e[0].Delay = 10000; e[0].Type = SC_ACTION_RESTART; @@ -5906,19 +5252,19 @@ bool MsInstallServiceExW(char *name, wchar_t *title, wchar_t *description, wchar action.cActions = 3; action.lpsaActions = e; action.dwResetPeriod = 1 * 60 * 60 * 24; - ms->nt->ChangeServiceConfig2(service, SERVICE_CONFIG_FAILURE_ACTIONS, &action); + ChangeServiceConfig2(service, SERVICE_CONFIG_FAILURE_ACTIONS, &action); Free(e); } - ms->nt->CloseServiceHandle(service); + CloseServiceHandle(service); } else { *error_code = GetLastError(); } - ms->nt->CloseServiceHandle(sc); + CloseServiceHandle(sc); if (ret) { @@ -5939,25 +5285,21 @@ bool MsIsServiceInstalled(char *name) { return false; } - if (ms->IsNt == false) - { - return false; - } - sc = ms->nt->OpenSCManager(NULL, NULL, GENERIC_READ); + sc = OpenSCManager(NULL, NULL, GENERIC_READ); if (sc == NULL) { return false; } - service = ms->nt->OpenService(sc, name, GENERIC_READ); + service = OpenService(sc, name, GENERIC_READ); if (service != NULL) { ret = true; } - ms->nt->CloseServiceHandle(service); - ms->nt->CloseServiceHandle(sc); + CloseServiceHandle(service); + CloseServiceHandle(sc); return ret; } @@ -6041,17 +5383,7 @@ void MsApplyTcpConfig() // Check whether the dynamic configuration of TCP is supported in current state bool MsIsTcpConfigSupported() { - if (MsIsNt() && MsIsAdmin()) - { - UINT type = GetOsInfo()->OsType; - - if (GET_KETA(type, 100) >= 2) - { - return true; - } - } - - return false; + return MsIsAdmin(); } // Read the TCP settings from the registry setting @@ -6063,31 +5395,24 @@ bool MsLoadTcpConfigReg(MS_TCP *tcp) return false; } - if (MsIsNt()) - { - Zero(tcp, sizeof(MS_TCP)); + Zero(tcp, sizeof(MS_TCP)); - if (MsRegIsValueEx(REG_LOCAL_MACHINE, MS_REG_TCP_SETTING_KEY, "RecvWindowSize", true) == false || - MsRegIsValueEx(REG_LOCAL_MACHINE, MS_REG_TCP_SETTING_KEY, "SendWindowSize", true) == false) - { - return false; - } - - tcp->RecvWindowSize = MsRegReadIntEx(REG_LOCAL_MACHINE, MS_REG_TCP_SETTING_KEY, "RecvWindowSize", true); - tcp->SendWindowSize = MsRegReadIntEx(REG_LOCAL_MACHINE, MS_REG_TCP_SETTING_KEY, "SendWindowSize", true); - - return true; - } - else + if (MsRegIsValueEx(REG_LOCAL_MACHINE, MS_REG_TCP_SETTING_KEY, "RecvWindowSize", true) == false || + MsRegIsValueEx(REG_LOCAL_MACHINE, MS_REG_TCP_SETTING_KEY, "SendWindowSize", true) == false) { return false; } + + tcp->RecvWindowSize = MsRegReadIntEx(REG_LOCAL_MACHINE, MS_REG_TCP_SETTING_KEY, "RecvWindowSize", true); + tcp->SendWindowSize = MsRegReadIntEx(REG_LOCAL_MACHINE, MS_REG_TCP_SETTING_KEY, "SendWindowSize", true); + + return true; } // Remove the TCP settings from the registry void MsDeleteTcpConfigReg() { - if (MsIsNt() && MsIsAdmin()) + if (MsIsAdmin()) { MsRegDeleteKeyEx(REG_LOCAL_MACHINE, MS_REG_TCP_SETTING_KEY, true); } @@ -6102,7 +5427,7 @@ void MsSaveTcpConfigReg(MS_TCP *tcp) return; } - if (MsIsNt() && MsIsAdmin()) + if (MsIsAdmin()) { MsRegWriteIntEx(REG_LOCAL_MACHINE, MS_REG_TCP_SETTING_KEY, "RecvWindowSize", tcp->RecvWindowSize, true); MsRegWriteIntEx(REG_LOCAL_MACHINE, MS_REG_TCP_SETTING_KEY, "SendWindowSize", tcp->SendWindowSize, true); @@ -6120,25 +5445,22 @@ void MsGetTcpConfig(MS_TCP *tcp) Zero(tcp, sizeof(MS_TCP)); - if (MsIsNt()) - { - UINT v; - // Initialize the network setting - MsInitGlobalNetworkConfig(); + UINT v; + // Initialize the network setting + MsInitGlobalNetworkConfig(); - // Read the value of TcpWindowSize or GlobalMaxTcpWindowSize if there is - v = MsRegReadInt(REG_LOCAL_MACHINE, "SYSTEM\\CurrentControlSet\\Services\\Tcpip\\Parameters", "TcpWindowSize"); - tcp->RecvWindowSize = MAX(tcp->RecvWindowSize, v); + // Read the value of TcpWindowSize or GlobalMaxTcpWindowSize if there is + v = MsRegReadInt(REG_LOCAL_MACHINE, "SYSTEM\\CurrentControlSet\\Services\\Tcpip\\Parameters", "TcpWindowSize"); + tcp->RecvWindowSize = MAX(tcp->RecvWindowSize, v); - v = MsRegReadInt(REG_LOCAL_MACHINE, "SYSTEM\\CurrentControlSet\\Services\\Tcpip\\Parameters", "GlobalMaxTcpWindowSize"); - tcp->RecvWindowSize = MAX(tcp->RecvWindowSize, v); + v = MsRegReadInt(REG_LOCAL_MACHINE, "SYSTEM\\CurrentControlSet\\Services\\Tcpip\\Parameters", "GlobalMaxTcpWindowSize"); + tcp->RecvWindowSize = MAX(tcp->RecvWindowSize, v); - v = MsRegReadInt(REG_LOCAL_MACHINE, "SYSTEM\\CurrentControlSet\\Services\\AFD\\Parameters", "DefaultReceiveWindow"); - tcp->RecvWindowSize = MAX(tcp->RecvWindowSize, v); + v = MsRegReadInt(REG_LOCAL_MACHINE, "SYSTEM\\CurrentControlSet\\Services\\AFD\\Parameters", "DefaultReceiveWindow"); + tcp->RecvWindowSize = MAX(tcp->RecvWindowSize, v); - // Read the value of DefaultSendWindow if there is - tcp->SendWindowSize = MsRegReadInt(REG_LOCAL_MACHINE, "SYSTEM\\CurrentControlSet\\Services\\AFD\\Parameters", "DefaultSendWindow"); - } + // Read the value of DefaultSendWindow if there is + tcp->SendWindowSize = MsRegReadInt(REG_LOCAL_MACHINE, "SYSTEM\\CurrentControlSet\\Services\\AFD\\Parameters", "DefaultSendWindow"); } // Write the TCP settings @@ -6150,7 +5472,7 @@ void MsSetTcpConfig(MS_TCP *tcp) return; } - if (MsIsNt() && MsIsAdmin()) + if (MsIsAdmin()) { bool window_scaling = false; UINT tcp1323opts; @@ -6223,41 +5545,26 @@ void MsSetTcpConfig(MS_TCP *tcp) // Initialize the global network settings void MsInitGlobalNetworkConfig() { - if (MsIsNt()) - { - UINT current_window_size; - current_window_size = MsRegReadInt(REG_LOCAL_MACHINE, "SYSTEM\\CurrentControlSet\\Services\\Tcpip\\Parameters", "TcpWindowSize"); + UINT current_window_size = MsRegReadInt(REG_LOCAL_MACHINE, "SYSTEM\\CurrentControlSet\\Services\\Tcpip\\Parameters", "TcpWindowSize"); - if (current_window_size == 65535 || current_window_size == 5980160 || - current_window_size == 16777216 || current_window_size == 16777214) - { - // Remove the strange value which is written by older version of PacketiX VPN - MsRegDeleteValue(REG_LOCAL_MACHINE, "SYSTEM\\CurrentControlSet\\Services\\AFD\\Parameters", - "DefaultReceiveWindow"); - MsRegDeleteValue(REG_LOCAL_MACHINE, "SYSTEM\\CurrentControlSet\\Services\\AFD\\Parameters", - "DefaultSendWindow"); - MsRegDeleteValue(REG_LOCAL_MACHINE, "SYSTEM\\CurrentControlSet\\Services\\Tcpip\\Parameters", - "Tcp1323Opts"); - MsRegDeleteValue(REG_LOCAL_MACHINE, "SYSTEM\\CurrentControlSet\\Services\\Tcpip\\Parameters", - "TcpWindowSize"); - MsRegDeleteValue(REG_LOCAL_MACHINE, "SYSTEM\\CurrentControlSet\\Services\\Tcpip\\Parameters", - "GlobalMaxTcpWindowSize"); - - // Set vpn_no_change = true - MsRegWriteInt(REG_LOCAL_MACHINE, "SYSTEM\\CurrentControlSet\\Services\\Tcpip\\Parameters", "vpn_no_change", 1); - MsRegWriteInt(REG_LOCAL_MACHINE, "SYSTEM\\CurrentControlSet\\Services\\AFD\\Parameters", "vpn_no_change", 1); - } - } - else + if (current_window_size == 65535 || current_window_size == 5980160 || + current_window_size == 16777216 || current_window_size == 16777214) { - if (MsRegReadInt(REG_LOCAL_MACHINE, - "System\\CurrentControlSet\\Services\\VxD\\MSTCP", - "packetix_no_optimize") == 0) - { - // Disable the DeadGWDetect - MsRegWriteStr(REG_LOCAL_MACHINE, "System\\CurrentControlSet\\Services\\VxD\\MSTCP", - "DeadGWDetect", "0"); - } + // Remove the strange value which is written by older version of PacketiX VPN + MsRegDeleteValue(REG_LOCAL_MACHINE, "SYSTEM\\CurrentControlSet\\Services\\AFD\\Parameters", + "DefaultReceiveWindow"); + MsRegDeleteValue(REG_LOCAL_MACHINE, "SYSTEM\\CurrentControlSet\\Services\\AFD\\Parameters", + "DefaultSendWindow"); + MsRegDeleteValue(REG_LOCAL_MACHINE, "SYSTEM\\CurrentControlSet\\Services\\Tcpip\\Parameters", + "Tcp1323Opts"); + MsRegDeleteValue(REG_LOCAL_MACHINE, "SYSTEM\\CurrentControlSet\\Services\\Tcpip\\Parameters", + "TcpWindowSize"); + MsRegDeleteValue(REG_LOCAL_MACHINE, "SYSTEM\\CurrentControlSet\\Services\\Tcpip\\Parameters", + "GlobalMaxTcpWindowSize"); + + // Set vpn_no_change = true + MsRegWriteInt(REG_LOCAL_MACHINE, "SYSTEM\\CurrentControlSet\\Services\\Tcpip\\Parameters", "vpn_no_change", 1); + MsRegWriteInt(REG_LOCAL_MACHINE, "SYSTEM\\CurrentControlSet\\Services\\AFD\\Parameters", "vpn_no_change", 1); } MsApplyTcpConfig(); @@ -6268,10 +5575,6 @@ void MsDisableNetworkOffloadingEtc() { wchar_t netsh[MAX_SIZE]; UINT exec_timeout = 10000; - if (MsIsNt() == false) - { - return; - } // Get the path of netsh.exe CombinePathW(netsh, sizeof(netsh), MsGetSystem32DirW(), L"netsh.exe"); @@ -6280,26 +5583,12 @@ void MsDisableNetworkOffloadingEtc() MsRegWriteIntEx2(REG_LOCAL_MACHINE, "SYSTEM\\CurrentControlSet\\Services\\Tcpip\\Parameters", "DisableTaskOffload", 1, false, true); MsRegWriteIntEx2(REG_LOCAL_MACHINE, "SYSTEM\\CurrentControlSet\\Services\\Tcpip\\Parameters", "TcpNumConnections", TCP_MAX_NUM_CONNECTIONS, false, true); - if (MsIsVista() == false) - { - // Windows Server 2003 or earlier - MsRegWriteIntEx2(REG_LOCAL_MACHINE, "SYSTEM\\CurrentControlSet\\Services\\Tcpip\\Parameters", "EnableRSS", 1, false, true); - MsRegWriteIntEx2(REG_LOCAL_MACHINE, "SYSTEM\\CurrentControlSet\\Services\\Tcpip\\Parameters", "EnableTCPChimney", 1, false, true); - MsRegWriteIntEx2(REG_LOCAL_MACHINE, "SYSTEM\\CurrentControlSet\\Services\\Tcpip\\Parameters", "EnableTCPA", 1, false, true); - - Win32RunAndWaitProcess(netsh, L"netsh int ip set chimney disabled", true, true, exec_timeout); - SleepThread(250); - } - else - { - // Windows Vista or later - Win32RunAndWaitProcess(netsh, L"int ipv4 set global taskoffload=disabled", true, true, exec_timeout); - SleepThread(250); - Win32RunAndWaitProcess(netsh, L"int ipv6 set global taskoffload=disabled", true, true, exec_timeout); - SleepThread(250); - Win32RunAndWaitProcess(netsh, L"int tcp set global chimney=disabled", true, true, exec_timeout); - SleepThread(250); - } + Win32RunAndWaitProcess(netsh, L"int ipv4 set global taskoffload=disabled", true, true, exec_timeout); + SleepThread(250); + Win32RunAndWaitProcess(netsh, L"int ipv6 set global taskoffload=disabled", true, true, exec_timeout); + SleepThread(250); + Win32RunAndWaitProcess(netsh, L"int tcp set global chimney=disabled", true, true, exec_timeout); + SleepThread(250); } // Upgrade the virtual LAN card @@ -6328,12 +5617,6 @@ bool MsUpgradeVLanWithoutLock(char *tag_name, char *connection_tag_name, char *i return false; } - if (MsIsNt() == false) - { - // Can not be upgraded in Windows 9x - return false; - } - if (MsIsInfCatalogRequired()) { if (MsIsValidVLanInstanceNameForInfCatalog(instance_name) == false) @@ -6386,127 +5669,6 @@ bool MsUpgradeVLanWithoutLock(char *tag_name, char *connection_tag_name, char *i return ret; } -// Test for Windows 9x -void MsWin9xTest() -{ -} - -// Update the CompatibleIDs of virtual LAN card -void MsUpdateCompatibleIDs(char *instance_name) -{ - TOKEN_LIST *t; - char id[MAX_SIZE]; - char device_title[MAX_SIZE]; - char device_title_old[MAX_SIZE]; - // Validate arguments - if (instance_name == NULL) - { - return; - } - - Format(id, sizeof(id), DRIVER_DEVICE_ID_TAG, instance_name); - Format(device_title, sizeof(device_title), VLAN_ADAPTER_NAME_TAG, instance_name); - Format(device_title_old, sizeof(device_title_old), VLAN_ADAPTER_NAME_TAG_OLD, instance_name); - - t = MsRegEnumKey(REG_LOCAL_MACHINE, "Enum\\Root\\Net"); - if (t != NULL) - { - UINT i; - for (i = 0;i < t->NumTokens;i++) - { - char keyname[MAX_PATH]; - char *str; - char *title; - - Format(keyname, sizeof(keyname), "Enum\\Root\\Net\\%s", t->Token[i]); - - title = MsRegReadStr(REG_LOCAL_MACHINE, keyname, "DeviceDesc"); - - if (title != NULL) - { - if (StrCmpi(title, device_title) == 0 || StrCmpi(title, device_title_old) == 0) - { - Format(keyname, sizeof(keyname), "Enum\\Root\\Net\\%s",t->Token[i]); - str = MsRegReadStr(REG_LOCAL_MACHINE, keyname, "CompatibleIDs"); - if (str != NULL) - { - Free(str); - } - else - { - MsRegWriteStr(REG_LOCAL_MACHINE, keyname, "CompatibleIDs", id); - } - } - Free(title); - } - } - - FreeToken(t); - } - - MsRegWriteStr(REG_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Setup", "SourcePath", - ms->System32Dir); -} - -// Installing the virtual LAN card (for Win9x) -bool MsInstallVLan9x(char *instance_name, MS_DRIVER_VER *ver) -{ - char sysdir[MAX_PATH]; - char infdir[MAX_PATH]; - char otherdir[MAX_PATH]; - char syspath[MAX_PATH]; - char syspath2[MAX_PATH]; - char infpath[MAX_PATH]; - char vpn16[MAX_PATH]; - char infpath_src[MAX_PATH]; - char syspath_src[MAX_PATH]; - char neo_sys[MAX_PATH]; - // Validate arguments - if (instance_name == NULL || ver == NULL) - { - return false; - } - - StrCpy(sysdir, sizeof(sysdir), MsGetSystem32Dir()); - Format(infdir, sizeof(infdir), "%s\\inf", MsGetWindowsDir()); - Format(otherdir, sizeof(otherdir), "%s\\other", infdir); - Format(syspath, sizeof(syspath), "%s\\Neo_%s.sys", sysdir, instance_name); - Format(syspath2, sizeof(syspath2), "%s\\Neo_%s.sys", infdir, instance_name); - Format(infpath, sizeof(infpath), "%s\\Neo_%s.inf", infdir, instance_name); - Format(vpn16, sizeof(vpn16), "%s\\vpn16.exe", MsGetMyTempDir()); - - MakeDir(otherdir); - - Format(neo_sys, sizeof(neo_sys), "Neo_%s.sys", instance_name); - - // Copy of vpn16.exe - FileCopy("|vpn16.exe", vpn16); - - // Starting the installation - if (MsStartDriverInstall(instance_name, NULL, neo_sys, NULL, ver) == false) - { - return false; - } - MsGetDriverPathA(instance_name, NULL, NULL, infpath_src, syspath_src, NULL, NULL, neo_sys); - - // Copy of the inf file - FileCopy(infpath_src, infpath); - - // Copy of the sys file - FileCopy(syspath_src, syspath); - - // Install the device driver - if (Run(vpn16, instance_name, false, true) == false) - { - return false; - } - - // Update the CompatibleIDs - MsUpdateCompatibleIDs(instance_name); - - return true; -} - // Child window enumeration procedure BOOL CALLBACK MsEnumChildWindowProc(HWND hWnd, LPARAM lParam) { @@ -6757,27 +5919,6 @@ LIST *NewWindowList() return NewListFast(CmpWindowList); } -// Determine whether it's Windows Vista or later -bool MsIsVista() -{ - OS_INFO *info = GetOsInfo(); - - if (info == NULL) - { - return false; - } - - if (OS_IS_WINDOWS_NT(info->OsType)) - { - if (GET_KETA(info->OsType, 100) >= 5) - { - return true; - } - } - - return false; -} - // Determine whether it's Windows 7 or later bool MsIsWindows7() { @@ -6788,12 +5929,9 @@ bool MsIsWindows7() return false; } - if (OS_IS_WINDOWS_NT(info->OsType)) + if (GET_KETA(info->OsType, 100) >= 6) { - if (GET_KETA(info->OsType, 100) >= 6) - { - return true; - } + return true; } return false; @@ -6809,22 +5947,19 @@ bool MsIsWindows10() return false; } - if (OS_IS_WINDOWS_NT(info->OsType)) + if (GET_KETA(info->OsType, 100) == 7) { - if (GET_KETA(info->OsType, 100) == 7) - { - if (GET_KETA(info->OsType, 1) >= 2) - { - return true; - } - } - - if (GET_KETA(info->OsType, 100) >= 8) + if (GET_KETA(info->OsType, 1) >= 2) { return true; } } + if (GET_KETA(info->OsType, 100) >= 8) + { + return true; + } + return false; } @@ -6838,22 +5973,19 @@ bool MsIsWindows81() return false; } - if (OS_IS_WINDOWS_NT(info->OsType)) + if (GET_KETA(info->OsType, 100) == 7) { - if (GET_KETA(info->OsType, 100) == 7) - { - if (GET_KETA(info->OsType, 1) >= 1) - { - return true; - } - } - - if (GET_KETA(info->OsType, 100) >= 8) + if (GET_KETA(info->OsType, 1) >= 1) { return true; } } + if (GET_KETA(info->OsType, 100) >= 8) + { + return true; + } + return false; } @@ -6867,12 +5999,9 @@ bool MsIsWindows8() return false; } - if (OS_IS_WINDOWS_NT(info->OsType)) + if (GET_KETA(info->OsType, 100) >= 7) { - if (GET_KETA(info->OsType, 100) >= 7) - { - return true; - } + return true; } return false; @@ -6942,7 +6071,7 @@ bool MsCloseWarningWindow(NO_WARNING *nw, UINT thread_id) bool ret = false; bool press = false; - if (MsIsVista() == false || nw->StartTimer == 0) + if (nw->StartTimer == 0) { press = true; } @@ -6952,15 +6081,7 @@ bool MsCloseWarningWindow(NO_WARNING *nw, UINT thread_id) press = true; } - if (MsIsVista() == false) - { - o = NewListFast(NULL); - EnumThreadWindows(thread_id, MsEnumThreadWindowProc, (LPARAM)o); - } - else - { - o = EnumAllTopWindow(); - } + o = EnumAllTopWindow(); for (i = 0;i < LIST_NUM(o);i++) { @@ -6971,73 +6092,14 @@ bool MsCloseWarningWindow(NO_WARNING *nw, UINT thread_id) break; } - if (MsIsVista() == false) - { - hWnd = LIST_DATA(o, i); - } - else - { - hWnd = *((HWND *)LIST_DATA(o, i)); - } + hWnd = *((HWND *)LIST_DATA(o, i)); if (hWnd != NULL) { - if (MsIsNt()) + if (true) { // Get whether this window is a warning screen of driver - if (MsIsVista() == false) - { - // Other than Windows Vista - HWND hStatic, hOk, hCancel, hDetail; - - hStatic = GetDlgItem(hWnd, 0x14C1); - hOk = GetDlgItem(hWnd, 0x14B7); - hCancel = GetDlgItem(hWnd, 0x14BA); - hDetail = GetDlgItem(hWnd, 0x14B9); - - if ((hStatic != NULL || hDetail != NULL) && hOk != NULL && hCancel != NULL) - { - char tmp[MAX_SIZE]; - bool b = false; - - if (GetClassName(hStatic, tmp, sizeof(tmp)) != 0) - { - if (StrCmpi(tmp, "static") == 0) - { - b = true; - } - } - - if (GetClassName(hDetail, tmp, sizeof(tmp)) != 0) - { - if (StrCmpi(tmp, "button") == 0) - { - b = true; - } - } - - if (b) - { - if (GetClassName(hOk, tmp, sizeof(tmp)) != 0) - { - if (StrCmpi(tmp, "button") == 0) - { - if (GetClassName(hCancel, tmp, sizeof(tmp)) != 0) - { - if (StrCmpi(tmp, "button") == 0) - { - // Press the OK button since it was found - PostMessage(hWnd, WM_COMMAND, 0x14B7, 0); - - ret = true; - } - } - } - } - } - } - } - else + if (true) { // Windows Vista char exe[MAX_PATH]; @@ -7160,14 +6222,7 @@ bool MsCloseWarningWindow(NO_WARNING *nw, UINT thread_id) } } - if (MsIsVista() == false) - { - ReleaseList(o); - } - else - { - FreeWindowList(o); - } + FreeWindowList(o); if (press == false) { @@ -7205,12 +6260,7 @@ void MsNoWarningThreadProc(THREAD *thread, void *param) NoticeThreadInit(thread); - interval = 50; - - if (MsIsVista()) - { - interval = 1000; - } + interval = 1000; i = 0; @@ -7285,26 +6335,6 @@ NO_WARNING *MsInitNoWarningEx(UINT start_timer) NO_WARNING *nw = ZeroMalloc(sizeof(NO_WARNING)); nw->StartTimer = (UINT64)start_timer; - - // Get the current sound file name - if (MsIsVista() == false) - { - wchar_t *tmp; - - // Turn off the unnecessary warning tone in Windows XP or earlier - tmp = MsRegReadStrW(REG_CURRENT_USER, "AppEvents\\Schemes\\Apps\\.Default\\SystemAsterisk\\.Current", ""); - if (UniIsEmptyStr(tmp) == false) - { - nw->SoundFileName = CopyUniStr(tmp); - - MsRegWriteStrW(REG_CURRENT_USER, - "AppEvents\\Schemes\\Apps\\.Default\\SystemAsterisk\\.Current", - "", L""); - } - - Free(tmp); - } - nw->ThreadId = GetCurrentThreadId(); nw->HaltEvent = NewEvent(); @@ -7329,22 +6359,9 @@ void MsFreeNoWarning(NO_WARNING *nw) Set(nw->HaltEvent); WaitThread(nw->NoWarningThread, INFINITE); + ReleaseThread(nw->NoWarningThread); - ReleaseEvent(nw->HaltEvent); - - if (MsIsVista() == false) - { - if (nw->SoundFileName != NULL) - { - MsRegWriteStrExpandW(REG_CURRENT_USER, - "AppEvents\\Schemes\\Apps\\.Default\\SystemAsterisk\\.Current", - "", nw->SoundFileName); - - Free(nw->SoundFileName); - } - } - Free(nw); } @@ -7486,12 +6503,6 @@ bool MsInstallVLanWithoutLock(char *tag_name, char *connection_tag_name, char *i return false; } - if (MsIsNt() == false) - { - // For Windows 9x - return MsInstallVLan9x(instance_name, ver); - } - if (MsIsInfCatalogRequired()) { if (MsIsValidVLanInstanceNameForInfCatalog(instance_name) == false) @@ -7543,10 +6554,7 @@ bool MsInstallVLanWithoutLock(char *tag_name, char *connection_tag_name, char *i MsGetDriverPath(instance_name, NULL, NULL, infpath, NULL, NULL, NULL, neo_sys); // Delete the device information that is left on fail of installation - if (MsIsNt()) - { - MsDeleteTroubleVLAN(tag_name, instance_name); - } + MsDeleteTroubleVLAN(tag_name, instance_name); // Call the Win32 API ret = MsInstallVLanInternal(infpath, hwid_w, hwid); @@ -7565,13 +6573,13 @@ bool MsInstallVLanWithoutLock(char *tag_name, char *connection_tag_name, char *i MsSetMacAddress(VLAN_ADAPTER_NAME_TAG, instance_name, mac_address_str); } - SleepThread(MsIsVista() ? 1000 : 300); + SleepThread(1000); } if (ret) { MsDisableVLan(instance_name); - SleepThread(MsIsVista() ? 1000 : 300); + SleepThread(1000); MsEnableVLan(instance_name); } @@ -7627,19 +6635,14 @@ bool MsInstallVLanInternal(wchar_t *infpath, wchar_t *hwid_w, char *hwid) if (SetupDiSetDeviceRegistryProperty(device_info, &device_info_data, SPDRP_HARDWAREID, (BYTE *)hwid_copy, sizeof(hwid_copy))) { - NO_WARNING *nw = NULL; - - //if (MsIsVista() == false) - { - nw = MsInitNoWarning(); - } + NO_WARNING *nw = MsInitNoWarning(); // Start the class installer if (SetupDiCallClassInstaller(DIF_REGISTERDEVICE, device_info, &device_info_data)) { // Do the installation - if (ms->nt->UpdateDriverForPlugAndPlayDevicesW( + if (UpdateDriverForPlugAndPlayDevicesW( NULL, hwid_w, infpath, 1, &need_reboot)) { ret = true; @@ -7781,7 +6784,7 @@ bool MsIsDeviceRunning(HDEVINFO info, SP_DEVINFO_DATA *dev_info_data) detail.cbSize = sizeof(detail); if (SetupDiGetDeviceInfoListDetail(info, &detail) == false || - ms->nt->CM_Get_DevNode_Status_Ex(&status, &problem, dev_info_data->DevInst, + CM_Get_DevNode_Status_Ex(&status, &problem, dev_info_data->DevInst, 0, detail.RemoteMachineHandle) != CR_SUCCESS) { return false; @@ -7879,7 +6882,7 @@ bool MsDeleteDevice(HDEVINFO info, SP_DEVINFO_DATA *dev_info_data) return false; } - ret = ms->nt->CM_Get_Device_ID_Ex(dev_info_data->DevInst, device_id, sizeof(device_id), + ret = CM_Get_Device_ID_Ex(dev_info_data->DevInst, device_id, sizeof(device_id), 0, detail.RemoteMachineHandle); if (ret != CR_SUCCESS) { @@ -7932,11 +6935,6 @@ bool MsEnableVLanWithoutLock(char *instance_name) return false; } - if (MsIsNt() == false) - { - return false; - } - Format(tmp, sizeof(tmp), DRIVER_DEVICE_ID_TAG, instance_name); h = MsGetDevInfoFromDeviceId(&data, tmp); @@ -7977,11 +6975,6 @@ bool MsDisableVLanWithoutLock(char *instance_name) return false; } - if (MsIsNt() == false) - { - return false; - } - Format(tmp, sizeof(tmp), DRIVER_DEVICE_ID_TAG, instance_name); h = MsGetDevInfoFromDeviceId(&data, tmp); @@ -8014,11 +7007,6 @@ void MsRestartVLanWithoutLock(char *instance_name) return; } - if (MsIsNt() == false) - { - return; - } - if (MsIsVLanEnabled(instance_name) == false) { return; @@ -8053,11 +7041,6 @@ bool MsIsVLanEnabledWithoutLock(char *instance_name) return false; } - if (MsIsNt() == false) - { - return true; - } - Format(tmp, sizeof(tmp), DRIVER_DEVICE_ID_TAG, instance_name); h = MsGetDevInfoFromDeviceId(&data, tmp); @@ -8211,11 +7194,6 @@ bool MsStartDriverInstall(char *instance_name, UCHAR *mac_address, char *neo_sys ReplaceStrEx(tmp, size * 2, tmp, "$VER_MINOR$", str_minor, false); ReplaceStrEx(tmp, size * 2, tmp, "$VER_BUILD$", str_build, false); - if (MsIsVista()) - { - //ReplaceStrEx(tmp, size * 2, tmp, "\"100\"", "\"2000\"", false); - } - io = FileCreateW(dest_inf); if (io == NULL) { @@ -8314,32 +7292,26 @@ void MsFinishDriverInstall(char *instance_name, char *neo_sys) } // Get the path to the driver file -void MsGetDriverPath(char *instance_name, wchar_t *src_inf, wchar_t *src_sys, wchar_t *dest_inf, wchar_t *dest_sys, wchar_t *src_cat, wchar_t *dest_cat, char *neo_sys) +void MsGetDriverPath(char* instance_name, wchar_t* src_inf, wchar_t* src_sys, wchar_t* dest_inf, wchar_t* dest_sys, wchar_t* src_cat, wchar_t* dest_cat, char* neo_sys) { - wchar_t *src_filename; - wchar_t *src_sys_filename; + wchar_t* src_filename; + wchar_t* src_sys_filename; // Validate arguments if (instance_name == NULL) { return; } - // WinNT x86 - src_filename = L"|DriverPackages\\Neo\\x86\\Neo_x86.inf"; - src_sys_filename = L"|DriverPackages\\Neo\\x86\\Neo_x86.sys"; - - if (MsIsNt() == false) + if (MsIsX64()) { - // Win9x - src_filename = L"|DriverPackages\\Neo9x\\x86\\Neo9x_x86.inf"; - src_sys_filename = L"|DriverPackages\\Neo9x\\x86\\Neo9x_x86.sys"; - } - else if (MsIsX64()) - { - // WinNT x64 src_filename = L"|DriverPackages\\Neo\\x64\\Neo_x64.inf"; src_sys_filename = L"|DriverPackages\\Neo\\x64\\Neo_x64.sys"; } + else + { + src_filename = L"|DriverPackages\\Neo\\x86\\Neo_x86.inf"; + src_sys_filename = L"|DriverPackages\\Neo\\x86\\Neo_x86.sys"; + } if (MsIsWindows7()) { @@ -8834,12 +7806,6 @@ void MsNormalizeInterfaceDefaultGatewaySettings(char *tag_name, char *instance_n Debug("MsNormalizeInterfaceDefaultGatewaySettings()\n"); - if (MsIsVista() == false) - { - Debug("MsIsVista() == false\n"); - return; - } - Format(tmp2, sizeof(tmp2), tag_name, instance_name); if_index = Win32GetVLanInterfaceID(tmp2); Debug("if_index=%u\n", if_index); @@ -8930,11 +7896,6 @@ void MsInitNetworkConfig(char *tag_name, char *instance_name, char *connection_t return; } - if (MsIsNt() == false) - { - return; - } - // Settings such as string Format(tmp, sizeof(tmp), connection_tag_name, instance_name); MsSetNetworkConfig(tag_name, instance_name, tmp, true); @@ -8983,7 +7944,7 @@ void MsSetNetworkConfig(char *tag_name, char *instance_name, char *friendly_name old_name = MsRegReadStr(REG_LOCAL_MACHINE, key, "Name"); if (old_name != NULL) { - if (MsIsVista()) + if (true) { char arg[MAX_PATH]; char netsh[MAX_PATH]; @@ -9080,16 +8041,9 @@ void MsSetMacAddress(char *tag_name, char *instance_name, char *mac_address) Format(dest_name, sizeof(dest_name), tag_name, instance_name); // Enumerate the key - if (MsIsNt()) - { - key_list = MsRegEnumKey(REG_LOCAL_MACHINE, - "SYSTEM\\CurrentControlSet\\Control\\Class\\{4D36E972-E325-11CE-BFC1-08002bE10318}"); - } - else - { - key_list = MsRegEnumKey(REG_LOCAL_MACHINE, - "System\\CurrentControlSet\\Services\\Class\\Net"); - } + key_list = MsRegEnumKey(REG_LOCAL_MACHINE, + "SYSTEM\\CurrentControlSet\\Control\\Class\\{4D36E972-E325-11CE-BFC1-08002bE10318}"); + if (key_list == NULL) { return; @@ -9101,18 +8055,9 @@ void MsSetMacAddress(char *tag_name, char *instance_name, char *mac_address) char full_key_name[MAX_SIZE]; char *driver_desc; - if (MsIsNt()) - { - Format(full_key_name, sizeof(full_key_name), - "SYSTEM\\CurrentControlSet\\Control\\Class\\{4D36E972-E325-11CE-BFC1-08002bE10318}\\%s", - key_name); - } - else - { - Format(full_key_name, sizeof(full_key_name), - "System\\CurrentControlSet\\Services\\Class\\Net\\%s", - key_name); - } + Format(full_key_name, sizeof(full_key_name), + "SYSTEM\\CurrentControlSet\\Control\\Class\\{4D36E972-E325-11CE-BFC1-08002bE10318}\\%s", + key_name); // Read the DriverDesc driver_desc = MsRegReadStr(REG_LOCAL_MACHINE, full_key_name, "DriverDesc"); @@ -9154,16 +8099,9 @@ char *MsGetDriverFileName(char *tag_name, char *instance_name) Format(dest_name, sizeof(dest_name), tag_name, instance_name); // Enumerate the key - if (MsIsNt()) - { - key_list = MsRegEnumKey(REG_LOCAL_MACHINE, - "SYSTEM\\CurrentControlSet\\Control\\Class\\{4D36E972-E325-11CE-BFC1-08002bE10318}"); - } - else - { - key_list = MsRegEnumKey(REG_LOCAL_MACHINE, - "System\\CurrentControlSet\\Services\\Class\\Net"); - } + key_list = MsRegEnumKey(REG_LOCAL_MACHINE, + "SYSTEM\\CurrentControlSet\\Control\\Class\\{4D36E972-E325-11CE-BFC1-08002bE10318}"); + if (key_list == NULL) { return NULL; @@ -9175,18 +8113,9 @@ char *MsGetDriverFileName(char *tag_name, char *instance_name) char full_key_name[MAX_SIZE]; char *driver_desc; - if (MsIsNt()) - { - Format(full_key_name, sizeof(full_key_name), - "SYSTEM\\CurrentControlSet\\Control\\Class\\{4D36E972-E325-11CE-BFC1-08002bE10318}\\%s", - key_name); - } - else - { - Format(full_key_name, sizeof(full_key_name), - "System\\CurrentControlSet\\Services\\Class\\Net\\%s", - key_name); - } + Format(full_key_name, sizeof(full_key_name), + "SYSTEM\\CurrentControlSet\\Control\\Class\\{4D36E972-E325-11CE-BFC1-08002bE10318}\\%s", + key_name); // Read the DriverDesc driver_desc = MsRegReadStr(REG_LOCAL_MACHINE, full_key_name, "DriverDesc"); @@ -9226,16 +8155,9 @@ char *MsGetDriverVersion(char *tag_name, char *instance_name) Format(dest_name, sizeof(dest_name), tag_name, instance_name); // Enumerate the key - if (MsIsNt()) - { - key_list = MsRegEnumKey(REG_LOCAL_MACHINE, - "SYSTEM\\CurrentControlSet\\Control\\Class\\{4D36E972-E325-11CE-BFC1-08002bE10318}"); - } - else - { - key_list = MsRegEnumKey(REG_LOCAL_MACHINE, - "System\\CurrentControlSet\\Services\\Class\\Net"); - } + key_list = MsRegEnumKey(REG_LOCAL_MACHINE, + "SYSTEM\\CurrentControlSet\\Control\\Class\\{4D36E972-E325-11CE-BFC1-08002bE10318}"); + if (key_list == NULL) { return NULL; @@ -9247,18 +8169,9 @@ char *MsGetDriverVersion(char *tag_name, char *instance_name) char full_key_name[MAX_SIZE]; char *driver_desc; - if (MsIsNt()) - { - Format(full_key_name, sizeof(full_key_name), - "SYSTEM\\CurrentControlSet\\Control\\Class\\{4D36E972-E325-11CE-BFC1-08002bE10318}\\%s", - key_name); - } - else - { - Format(full_key_name, sizeof(full_key_name), - "System\\CurrentControlSet\\Services\\Class\\Net\\%s", - key_name); - } + Format(full_key_name, sizeof(full_key_name), + "SYSTEM\\CurrentControlSet\\Control\\Class\\{4D36E972-E325-11CE-BFC1-08002bE10318}\\%s", + key_name); // Read the DriverDesc driver_desc = MsRegReadStr(REG_LOCAL_MACHINE, full_key_name, "DriverDesc"); @@ -9314,16 +8227,8 @@ char *MsGetMacAddress(char *tag_name, char *instance_name) Format(dest_name, sizeof(dest_name), tag_name, instance_name); // Enumerate the key - if (MsIsNt()) - { - key_list = MsRegEnumKey(REG_LOCAL_MACHINE, - "SYSTEM\\CurrentControlSet\\Control\\Class\\{4D36E972-E325-11CE-BFC1-08002bE10318}"); - } - else - { - key_list = MsRegEnumKey(REG_LOCAL_MACHINE, - "System\\CurrentControlSet\\Services\\Class\\Net"); - } + key_list = MsRegEnumKey(REG_LOCAL_MACHINE, + "SYSTEM\\CurrentControlSet\\Control\\Class\\{4D36E972-E325-11CE-BFC1-08002bE10318}"); if (key_list == NULL) { @@ -9336,18 +8241,9 @@ char *MsGetMacAddress(char *tag_name, char *instance_name) char full_key_name[MAX_SIZE]; char *driver_desc; - if (MsIsNt()) - { - Format(full_key_name, sizeof(full_key_name), - "SYSTEM\\CurrentControlSet\\Control\\Class\\{4D36E972-E325-11CE-BFC1-08002bE10318}\\%s", - key_name); - } - else - { - Format(full_key_name, sizeof(full_key_name), - "System\\CurrentControlSet\\Services\\Class\\Net\\%s", - key_name); - } + Format(full_key_name, sizeof(full_key_name), + "SYSTEM\\CurrentControlSet\\Control\\Class\\{4D36E972-E325-11CE-BFC1-08002bE10318}\\%s", + key_name); // Read the DriverDesc driver_desc = MsRegReadStr(REG_LOCAL_MACHINE, full_key_name, "DriverDesc"); @@ -9399,16 +8295,8 @@ bool MsCheckVLanDeviceIdFromRootEnum(char *name) return false; } - if (MsIsNt()) - { - root = "SYSTEM\\CurrentControlSet\\Enum\\Root\\NET"; - keyname = "HardwareID"; - } - else - { - root = "Enum\\Root\\Net"; - keyname = "CompatibleIDs"; - } + root = "SYSTEM\\CurrentControlSet\\Enum\\Root\\NET"; + keyname = "HardwareID"; t = MsRegEnumKey(REG_LOCAL_MACHINE, root); if (t == NULL) @@ -9464,16 +8352,9 @@ char *MsGetNetworkAdapterGuid(char *tag_name, char *instance_name) Format(dest_name, sizeof(dest_name), tag_name, instance_name); // Enumerate the key - if (MsIsNt()) - { - key_list = MsRegEnumKey(REG_LOCAL_MACHINE, - "SYSTEM\\CurrentControlSet\\Control\\Class\\{4D36E972-E325-11CE-BFC1-08002bE10318}"); - } - else - { - key_list = MsRegEnumKey(REG_LOCAL_MACHINE, - "System\\CurrentControlSet\\Services\\Class\\Net"); - } + key_list = MsRegEnumKey(REG_LOCAL_MACHINE, + "SYSTEM\\CurrentControlSet\\Control\\Class\\{4D36E972-E325-11CE-BFC1-08002bE10318}"); + if (key_list == NULL) { return NULL; @@ -9486,18 +8367,9 @@ char *MsGetNetworkAdapterGuid(char *tag_name, char *instance_name) char *driver_desc; char *device_id; - if (MsIsNt()) - { - Format(full_key_name, sizeof(full_key_name), - "SYSTEM\\CurrentControlSet\\Control\\Class\\{4D36E972-E325-11CE-BFC1-08002bE10318}\\%s", - key_name); - } - else - { - Format(full_key_name, sizeof(full_key_name), - "System\\CurrentControlSet\\Services\\Class\\Net\\%s", - key_name); - } + Format(full_key_name, sizeof(full_key_name), + "SYSTEM\\CurrentControlSet\\Control\\Class\\{4D36E972-E325-11CE-BFC1-08002bE10318}\\%s", + key_name); device_id = MsRegReadStr(REG_LOCAL_MACHINE, full_key_name, "MatchingDeviceId"); @@ -9512,14 +8384,8 @@ char *MsGetNetworkAdapterGuid(char *tag_name, char *instance_name) if (StrCmpi(dest_name, driver_desc) == 0) { // Read the NetCfgInstanceId - if (MsIsNt()) - { - ret = MsRegReadStr(REG_LOCAL_MACHINE, full_key_name, "NetCfgInstanceId"); - } - else - { - ret = CopyStr(""); - } + ret = MsRegReadStr(REG_LOCAL_MACHINE, full_key_name, "NetCfgInstanceId"); + Free(driver_desc); Free(device_id); break; @@ -9657,16 +8523,9 @@ TOKEN_LIST *MsEnumNetworkAdaptersNeo() UINT i; // Enumerate the key - if (MsIsNt()) - { - key_list = MsRegEnumKey(REG_LOCAL_MACHINE, - "SYSTEM\\CurrentControlSet\\Control\\Class\\{4D36E972-E325-11CE-BFC1-08002bE10318}"); - } - else - { - key_list = MsRegEnumKey(REG_LOCAL_MACHINE, - "System\\CurrentControlSet\\Services\\Class\\Net"); - } + key_list = MsRegEnumKey(REG_LOCAL_MACHINE, + "SYSTEM\\CurrentControlSet\\Control\\Class\\{4D36E972-E325-11CE-BFC1-08002bE10318}"); + if (key_list == NULL) { return NULL; @@ -9681,18 +8540,9 @@ TOKEN_LIST *MsEnumNetworkAdaptersNeo() char *driver_desc; char *device_id; - if (MsIsNt()) - { - Format(full_key_name, sizeof(full_key_name), - "SYSTEM\\CurrentControlSet\\Control\\Class\\{4D36E972-E325-11CE-BFC1-08002bE10318}\\%s", - key_name); - } - else - { - Format(full_key_name, sizeof(full_key_name), - "System\\CurrentControlSet\\Services\\Class\\Net\\%s", - key_name); - } + Format(full_key_name, sizeof(full_key_name), + "SYSTEM\\CurrentControlSet\\Control\\Class\\{4D36E972-E325-11CE-BFC1-08002bE10318}\\%s", + key_name); // Read the DriverDesc driver_desc = MsRegReadStr(REG_LOCAL_MACHINE, full_key_name, "DriverDesc"); @@ -9745,16 +8595,9 @@ TOKEN_LIST *MsEnumNetworkAdapters(char *start_with_name, char *start_with_name_2 UINT i; // Enumerate the key - if (MsIsNt()) - { - key_list = MsRegEnumKey(REG_LOCAL_MACHINE, - "SYSTEM\\CurrentControlSet\\Control\\Class\\{4D36E972-E325-11CE-BFC1-08002bE10318}"); - } - else - { - key_list = MsRegEnumKey(REG_LOCAL_MACHINE, - "System\\CurrentControlSet\\Services\\Class\\Net"); - } + key_list = MsRegEnumKey(REG_LOCAL_MACHINE, + "SYSTEM\\CurrentControlSet\\Control\\Class\\{4D36E972-E325-11CE-BFC1-08002bE10318}"); + if (key_list == NULL) { return NULL; @@ -9769,18 +8612,9 @@ TOKEN_LIST *MsEnumNetworkAdapters(char *start_with_name, char *start_with_name_2 char *driver_desc; char *device_id; - if (MsIsNt()) - { - Format(full_key_name, sizeof(full_key_name), - "SYSTEM\\CurrentControlSet\\Control\\Class\\{4D36E972-E325-11CE-BFC1-08002bE10318}\\%s", - key_name); - } - else - { - Format(full_key_name, sizeof(full_key_name), - "System\\CurrentControlSet\\Services\\Class\\Net\\%s", - key_name); - } + Format(full_key_name, sizeof(full_key_name), + "SYSTEM\\CurrentControlSet\\Control\\Class\\{4D36E972-E325-11CE-BFC1-08002bE10318}\\%s", + key_name); // Read the DriverDesc driver_desc = MsRegReadStr(REG_LOCAL_MACHINE, full_key_name, "DriverDesc"); @@ -9851,16 +8685,11 @@ bool MsCheckLogon(wchar_t *username, char *password) return false; } - if (MsIsNt() == false) - { - return false; - } - StrToUni(password_unicode, sizeof(password_unicode), password); if (GET_KETA(GetOsInfo()->OsType, 100) >= 2) { - if (ms->nt->LogonUserW(username, NULL, password_unicode, LOGON32_LOGON_NETWORK, LOGON32_PROVIDER_DEFAULT, &h) == false) + if (LogonUserW(username, NULL, password_unicode, LOGON32_LOGON_NETWORK, LOGON32_PROVIDER_DEFAULT, &h) == false) { // Logon failure return false; @@ -9871,7 +8700,7 @@ bool MsCheckLogon(wchar_t *username, char *password) char username_ansi[MAX_SIZE]; UniToStr(username_ansi, sizeof(username_ansi), username); - if (ms->nt->LogonUserA(username_ansi, NULL, password, LOGON32_LOGON_NETWORK, LOGON32_PROVIDER_DEFAULT, &h) == false) + if (LogonUserA(username_ansi, NULL, password, LOGON32_LOGON_NETWORK, LOGON32_PROVIDER_DEFAULT, &h) == false) { // Logon failure return false; @@ -9913,7 +8742,6 @@ bool MsShutdown(bool reboot, bool force) bool MsEnablePrivilege(char *name, bool enable) { HANDLE hToken; - NT_API *nt = ms->nt; LUID luid; TOKEN_PRIVILEGES *tp; bool ret; @@ -9922,19 +8750,15 @@ bool MsEnablePrivilege(char *name, bool enable) { return false; } - if (MsIsNt() == false) - { - return true; - } // Open the process token - if (nt->OpenProcessToken(ms->hCurrentProcess, TOKEN_ADJUST_PRIVILEGES, &hToken) == false) + if (OpenProcessToken(ms->hCurrentProcess, TOKEN_ADJUST_PRIVILEGES, &hToken) == false) { return false; } // Get a local unique identifier - if (nt->LookupPrivilegeValue(NULL, name, &luid) == FALSE) + if (LookupPrivilegeValue(NULL, name, &luid) == FALSE) { CloseHandle(hToken); return false; @@ -9947,7 +8771,7 @@ bool MsEnablePrivilege(char *name, bool enable) Copy(&tp->Privileges[0].Luid, &luid, sizeof(LUID)); // Manipulate the privilege - ret = nt->AdjustTokenPrivileges(hToken, false, tp, sizeof(TOKEN_PRIVILEGES), 0, 0); + ret = AdjustTokenPrivileges(hToken, false, tp, sizeof(TOKEN_PRIVILEGES), 0, 0); Free(tp); CloseHandle(hToken); @@ -9955,28 +8779,6 @@ bool MsEnablePrivilege(char *name, bool enable) return ret; } -// Get whether the current OS is a NT system -bool MsIsNt() -{ - if (ms == NULL) - { - OSVERSIONINFO os; - Zero(&os, sizeof(os)); - os.dwOSVersionInfoSize = sizeof(os); - GetVersionEx(&os); - if (os.dwPlatformId == VER_PLATFORM_WIN32_NT) - { - return true; - } - else - { - return false; - } - } - - return ms->IsNt; -} - // Get whether the current system is WINE bool MsIsWine() { @@ -10010,463 +8812,10 @@ bool MsIsAdmin() return ms->IsAdmin; } -// Load the NT system function -NT_API *MsLoadNtApiFunctions() -{ - NT_API *nt = ZeroMalloc(sizeof(NT_API)); - OSVERSIONINFO info; - - Zero(&info, sizeof(info)); - info.dwOSVersionInfoSize = sizeof(info); - GetVersionEx(&info); - - nt->hKernel32 = LoadLibrary("kernel32.dll"); - if (nt->hKernel32 == NULL) - { - Free(nt); - return NULL; - } - - nt->hAdvapi32 = LoadLibrary("advapi32.dll"); - if (nt->hAdvapi32 == NULL) - { - Free(nt); - return NULL; - } - - nt->hShell32 = LoadLibrary("shell32.dll"); - if (nt->hShell32 == NULL) - { - FreeLibrary(nt->hAdvapi32); - Free(nt); - return NULL; - } - - nt->hPsApi = LoadLibrary("psapi.dll"); - - if (info.dwMajorVersion >= 5) - { - nt->hNewDev = LoadLibrary("newdev.dll"); - if (nt->hNewDev == NULL) - { - FreeLibrary(nt->hShell32); - FreeLibrary(nt->hAdvapi32); - Free(nt); - return NULL; - } - - nt->hSetupApi = LoadLibrary("setupapi.dll"); - } - - nt->hSecur32 = LoadLibrary("secur32.dll"); - - nt->hUser32 = LoadLibrary("user32.dll"); - - nt->hDbgHelp = LoadLibrary("dbghelp.dll"); - - nt->hWcmapi = LoadLibrary("wcmapi.dll"); - - nt->hDwmapi = LoadLibrary("dwmapi.dll"); - - // Read the function - nt->GetComputerNameExW = - (BOOL (__stdcall *)(COMPUTER_NAME_FORMAT,LPWSTR,LPDWORD)) - GetProcAddress(nt->hKernel32, "GetComputerNameExW"); - - nt->IsWow64Process = - (BOOL (__stdcall *)(HANDLE,BOOL *)) - GetProcAddress(nt->hKernel32, "IsWow64Process"); - - nt->GetFileInformationByHandle = - (BOOL (__stdcall *)(HANDLE,LPBY_HANDLE_FILE_INFORMATION)) - GetProcAddress(nt->hKernel32, "GetFileInformationByHandle"); - - nt->GetProcessHeap = - (HANDLE (__stdcall *)()) - GetProcAddress(nt->hKernel32, "GetProcessHeap"); - - nt->SetProcessShutdownParameters = - (BOOL (__stdcall *)(DWORD,DWORD)) - GetProcAddress(nt->hKernel32, "SetProcessShutdownParameters"); - - nt->GetNativeSystemInfo = - (void (__stdcall *)(SYSTEM_INFO *)) - GetProcAddress(nt->hKernel32, "GetNativeSystemInfo"); - - nt->AdjustTokenPrivileges = - (BOOL (__stdcall *)(HANDLE,BOOL,PTOKEN_PRIVILEGES,DWORD,PTOKEN_PRIVILEGES,PDWORD)) - GetProcAddress(nt->hAdvapi32, "AdjustTokenPrivileges"); - - nt->LookupPrivilegeValue = - (BOOL (__stdcall *)(char *,char *,PLUID)) - GetProcAddress(nt->hAdvapi32, "LookupPrivilegeValueA"); - - nt->OpenProcessToken = - (BOOL (__stdcall *)(HANDLE,DWORD,PHANDLE)) - GetProcAddress(nt->hAdvapi32, "OpenProcessToken"); - - nt->InitiateSystemShutdown = - (BOOL (__stdcall *)(LPTSTR,LPTSTR,DWORD,BOOL,BOOL)) - GetProcAddress(nt->hAdvapi32, "InitiateSystemShutdownA"); - - nt->LogonUserW = - (BOOL (__stdcall *)(wchar_t *,wchar_t *,wchar_t *,DWORD,DWORD,HANDLE *)) - GetProcAddress(nt->hAdvapi32, "LogonUserW"); - - nt->LogonUserA = - (BOOL (__stdcall *)(char *,char *,char *,DWORD,DWORD,HANDLE * )) - GetProcAddress(nt->hAdvapi32, "LogonUserA"); - - nt->DuplicateTokenEx = - (BOOL (__stdcall *)(HANDLE,DWORD,SECURITY_ATTRIBUTES *,SECURITY_IMPERSONATION_LEVEL,TOKEN_TYPE,HANDLE *)) - GetProcAddress(nt->hAdvapi32, "DuplicateTokenEx"); - - nt->ConvertStringSidToSidA = - (BOOL (__stdcall *)(LPCSTR,PSID *)) - GetProcAddress(nt->hAdvapi32, "ConvertStringSidToSidA"); - - nt->GetTokenInformation = - (BOOL (__stdcall *)(HANDLE,TOKEN_INFORMATION_CLASS,void *,DWORD,PDWORD)) - GetProcAddress(nt->hAdvapi32, "GetTokenInformation"); - - nt->SetTokenInformation = - (BOOL (__stdcall *)(HANDLE,TOKEN_INFORMATION_CLASS,void *,DWORD)) - GetProcAddress(nt->hAdvapi32, "SetTokenInformation"); - - nt->CreateProcessAsUserA = - (BOOL (__stdcall *)(HANDLE,LPCSTR,LPSTR,LPSECURITY_ATTRIBUTES,LPSECURITY_ATTRIBUTES,BOOL,DWORD,void *,LPCSTR,LPSTARTUPINFOA,LPPROCESS_INFORMATION)) - GetProcAddress(nt->hAdvapi32, "CreateProcessAsUserA"); - - nt->CreateProcessAsUserW = - (BOOL (__stdcall *)(HANDLE,LPCWSTR,LPWSTR,LPSECURITY_ATTRIBUTES,LPSECURITY_ATTRIBUTES,BOOL,DWORD,void *,LPCWSTR,LPSTARTUPINFOW,LPPROCESS_INFORMATION)) - GetProcAddress(nt->hAdvapi32, "CreateProcessAsUserW"); - - nt->LookupAccountSidA = - (BOOL (__stdcall *)(LPCSTR,PSID,LPSTR,LPDWORD,LPSTR,LPDWORD,PSID_NAME_USE)) - GetProcAddress(nt->hAdvapi32, "LookupAccountSidA"); - - nt->LookupAccountNameA = - (BOOL (__stdcall *)(LPCSTR,LPCSTR,PSID,LPDWORD,LPSTR,LPDWORD,PSID_NAME_USE)) - GetProcAddress(nt->hAdvapi32, "LookupAccountNameA"); - - nt->SetNamedSecurityInfoW = - (DWORD (__stdcall *)(LPWSTR,DWORD,SECURITY_INFORMATION,PSID,PSID,PACL,PACL)) - GetProcAddress(nt->hAdvapi32, "SetNamedSecurityInfoW"); - - nt->AddAccessAllowedAceEx = - (BOOL (__stdcall *)(PACL,DWORD,DWORD,DWORD,PSID)) - GetProcAddress(nt->hAdvapi32, "AddAccessAllowedAceEx"); - - nt->QueryFullProcessImageNameA = - (BOOL (__stdcall *)(HANDLE,DWORD,LPSTR,PDWORD)) - GetProcAddress(nt->hKernel32, "QueryFullProcessImageNameA"); - - nt->QueryFullProcessImageNameW = - (BOOL (__stdcall *)(HANDLE,DWORD,LPWSTR,PDWORD)) - GetProcAddress(nt->hKernel32, "QueryFullProcessImageNameW"); - - nt->RegLoadKeyW = - (LSTATUS (__stdcall *)(HKEY,LPCWSTR,LPCWSTR)) - GetProcAddress(nt->hAdvapi32, "RegLoadKeyW"); - - nt->RegUnLoadKeyW = - (LSTATUS (__stdcall *)(HKEY,LPCWSTR)) - GetProcAddress(nt->hAdvapi32, "RegUnLoadKeyW"); - - if (info.dwMajorVersion >= 5) - { - nt->UpdateDriverForPlugAndPlayDevicesW = - (BOOL (__stdcall *)(HWND,LPCWSTR,LPCWSTR,DWORD,PBOOL)) - GetProcAddress(nt->hNewDev, "UpdateDriverForPlugAndPlayDevicesW"); - - nt->CM_Get_Device_ID_ExA = - (DWORD (__stdcall *)(DWORD,LPSTR,ULONG,ULONG,HANDLE)) - GetProcAddress(nt->hSetupApi, "CM_Get_Device_ID_ExA"); - - nt->CM_Get_DevNode_Status_Ex = - (DWORD (__stdcall *)(PULONG,PULONG,DWORD,ULONG,HANDLE)) - GetProcAddress(nt->hSetupApi, "CM_Get_DevNode_Status_Ex"); - } - - nt->hWtsApi32 = LoadLibrary("wtsapi32.dll"); - if (nt->hWtsApi32 != NULL) - { - // Terminal Services related API - nt->WTSQuerySessionInformation = - (BOOL (__stdcall *)(HANDLE,DWORD,WTS_INFO_CLASS,wchar_t *,DWORD *)) - GetProcAddress(nt->hWtsApi32, "WTSQuerySessionInformationW"); - nt->WTSFreeMemory = - (void (__stdcall *)(void *)) - GetProcAddress(nt->hWtsApi32, "WTSFreeMemory"); - nt->WTSDisconnectSession = - (BOOL (__stdcall *)(HANDLE,DWORD,BOOL)) - GetProcAddress(nt->hWtsApi32, "WTSDisconnectSession"); - nt->WTSEnumerateSessionsA = - (BOOL (__stdcall *)(HANDLE,DWORD,DWORD,PWTS_SESSION_INFOA *,DWORD *)) - GetProcAddress(nt->hWtsApi32, "WTSEnumerateSessionsA"); - nt->WTSRegisterSessionNotification = - (BOOL (__stdcall *)(HWND,DWORD)) - GetProcAddress(nt->hWtsApi32, "WTSRegisterSessionNotification"); - nt->WTSUnRegisterSessionNotification = - (BOOL (__stdcall *)(HWND)) - GetProcAddress(nt->hWtsApi32, "WTSUnRegisterSessionNotification"); - } - - // Service related API - nt->OpenSCManager = - (SC_HANDLE (__stdcall *)(LPCTSTR,LPCTSTR,DWORD)) - GetProcAddress(nt->hAdvapi32, "OpenSCManagerA"); - nt->CreateServiceA = - (SC_HANDLE (__stdcall *)(SC_HANDLE,LPCTSTR,LPCTSTR,DWORD,DWORD,DWORD,DWORD,LPCTSTR,LPCTSTR,LPDWORD,LPCTSTR,LPCTSTR,LPCTSTR)) - GetProcAddress(nt->hAdvapi32, "CreateServiceA"); - nt->CreateServiceW = - (SC_HANDLE (__stdcall *)(SC_HANDLE,LPCWSTR,LPCWSTR,DWORD,DWORD,DWORD,DWORD,LPCWSTR,LPCWSTR,LPDWORD,LPCWSTR,LPCWSTR,LPCWSTR)) - GetProcAddress(nt->hAdvapi32, "CreateServiceW"); - nt->ChangeServiceConfig2 = - (BOOL (__stdcall *)(SC_HANDLE,DWORD,LPVOID)) - GetProcAddress(nt->hAdvapi32, "ChangeServiceConfig2W"); - nt->CloseServiceHandle = - (BOOL (__stdcall *)(SC_HANDLE)) - GetProcAddress(nt->hAdvapi32, "CloseServiceHandle"); - nt->OpenService = - (SC_HANDLE (__stdcall *)(SC_HANDLE,LPCTSTR,DWORD)) - GetProcAddress(nt->hAdvapi32, "OpenServiceA"); - nt->QueryServiceStatus = - (BOOL (__stdcall *)(SC_HANDLE,LPSERVICE_STATUS)) - GetProcAddress(nt->hAdvapi32, "QueryServiceStatus"); - nt->StartService = - (BOOL (__stdcall *)(SC_HANDLE,DWORD,LPCTSTR)) - GetProcAddress(nt->hAdvapi32, "StartServiceA"); - nt->ControlService = - (BOOL (__stdcall *)(SC_HANDLE,DWORD,LPSERVICE_STATUS)) - GetProcAddress(nt->hAdvapi32, "ControlService"); - nt->SetServiceStatus = - (BOOL (__stdcall *)(SERVICE_STATUS_HANDLE,LPSERVICE_STATUS)) - GetProcAddress(nt->hAdvapi32, "SetServiceStatus"); - nt->RegisterServiceCtrlHandler = - (SERVICE_STATUS_HANDLE (__stdcall *)(LPCTSTR,LPHANDLER_FUNCTION)) - GetProcAddress(nt->hAdvapi32, "RegisterServiceCtrlHandlerW"); - nt->StartServiceCtrlDispatcher = - (BOOL (__stdcall *)(const LPSERVICE_TABLE_ENTRY)) - GetProcAddress(nt->hAdvapi32, "StartServiceCtrlDispatcherW"); - nt->DeleteService = - (BOOL (__stdcall *)(SC_HANDLE)) - GetProcAddress(nt->hAdvapi32, "DeleteService"); - nt->RegisterEventSourceW = - (HANDLE (__stdcall *)(LPCWSTR,LPCWSTR)) - GetProcAddress(nt->hAdvapi32, "RegisterEventSourceW"); - nt->ReportEventW = - (BOOL (__stdcall *)(HANDLE,WORD,WORD,DWORD,PSID,WORD,DWORD,LPCWSTR *,LPVOID)) - GetProcAddress(nt->hAdvapi32, "ReportEventW"); - nt->DeregisterEventSource = - (BOOL (__stdcall *)(HANDLE)) - GetProcAddress(nt->hAdvapi32, "DeregisterEventSource"); - nt->Wow64DisableWow64FsRedirection = - (BOOL (__stdcall *)(void **)) - GetProcAddress(nt->hKernel32, "Wow64DisableWow64FsRedirection"); - nt->Wow64EnableWow64FsRedirection = - (BOOLEAN (__stdcall *)(BOOLEAN)) - GetProcAddress(nt->hKernel32, "Wow64EnableWow64FsRedirection"); - nt->Wow64RevertWow64FsRedirection = - (BOOL (__stdcall *)(void *)) - GetProcAddress(nt->hKernel32, "Wow64RevertWow64FsRedirection"); - - if (nt->hPsApi != NULL) - { - // Process related API - nt->EnumProcesses = - (BOOL (__stdcall *)(DWORD *,DWORD,DWORD *)) - GetProcAddress(nt->hPsApi, "EnumProcesses"); - - nt->EnumProcessModules = - (BOOL (__stdcall *)(HANDLE,HMODULE * ,DWORD,DWORD *)) - GetProcAddress(nt->hPsApi, "EnumProcessModules"); - - nt->GetModuleFileNameExA = - (DWORD (__stdcall *)(HANDLE,HMODULE,LPSTR,DWORD)) - GetProcAddress(nt->hPsApi, "GetModuleFileNameExA"); - - nt->GetModuleFileNameExW = - (DWORD (__stdcall *)(HANDLE,HMODULE,LPWSTR,DWORD)) - GetProcAddress(nt->hPsApi, "GetModuleFileNameExW"); - - nt->GetProcessImageFileNameA = - (DWORD (__stdcall *)(HANDLE,LPSTR,DWORD)) - GetProcAddress(nt->hPsApi, "GetProcessImageFileNameA"); - - nt->GetProcessImageFileNameW = - (DWORD (__stdcall *)(HANDLE,LPWSTR,DWORD)) - GetProcAddress(nt->hPsApi, "GetProcessImageFileNameW"); - } - - // Registry related API - nt->RegDeleteKeyExA = - (LONG (__stdcall *)(HKEY,LPCTSTR,REGSAM,DWORD)) - GetProcAddress(nt->hAdvapi32, "RegDeleteKeyExA"); - - // Security related API - if (nt->hSecur32 != NULL) - { - nt->GetUserNameExA = - (BOOL (__stdcall *)(EXTENDED_NAME_FORMAT,LPSTR,PULONG)) - GetProcAddress(nt->hSecur32, "GetUserNameExA"); - - nt->GetUserNameExW = - (BOOL (__stdcall *)(EXTENDED_NAME_FORMAT,LPWSTR,PULONG)) - GetProcAddress(nt->hSecur32, "GetUserNameExW"); - - nt->LsaConnectUntrusted = - (NTSTATUS (__stdcall *)(PHANDLE)) - GetProcAddress(nt->hSecur32, "LsaConnectUntrusted"); - - nt->LsaLookupAuthenticationPackage = - (NTSTATUS (__stdcall *)(HANDLE,PLSA_STRING,PULONG)) - GetProcAddress(nt->hSecur32, "LsaLookupAuthenticationPackage"); - - nt->LsaLogonUser = - (NTSTATUS (__stdcall *)(HANDLE,PLSA_STRING,SECURITY_LOGON_TYPE,ULONG,PVOID,ULONG,PTOKEN_GROUPS,PTOKEN_SOURCE,PVOID,PULONG,PLUID,PHANDLE,PQUOTA_LIMITS,PNTSTATUS)) - GetProcAddress(nt->hSecur32, "LsaLogonUser"); - - nt->LsaDeregisterLogonProcess = - (NTSTATUS (__stdcall *)(HANDLE)) - GetProcAddress(nt->hSecur32, "LsaDeregisterLogonProcess"); - - nt->LsaFreeReturnBuffer = - (NTSTATUS (__stdcall *)(PVOID)) - GetProcAddress(nt->hSecur32, "LsaFreeReturnBuffer"); - } - - // WCM related API of Windows 8 - if (nt->hWcmapi != NULL) - { - nt->WcmQueryProperty = - (DWORD (__stdcall *)(const GUID *,LPCWSTR,MS_WCM_PROPERTY,PVOID,PDWORD,PBYTE *)) - GetProcAddress(nt->hWcmapi, "WcmQueryProperty"); - - nt->WcmSetProperty = - (DWORD (__stdcall *)(const GUID *,LPCWSTR,MS_WCM_PROPERTY,PVOID,DWORD,const BYTE *)) - GetProcAddress(nt->hWcmapi, "WcmSetProperty"); - - nt->WcmFreeMemory = - (void (__stdcall *)(PVOID)) - GetProcAddress(nt->hWcmapi, "WcmFreeMemory"); - - nt->WcmGetProfileList = - (DWORD (__stdcall *)(PVOID,MS_WCM_PROFILE_INFO_LIST **)) - GetProcAddress(nt->hWcmapi, "WcmGetProfileList"); - } - - nt->AllocateLocallyUniqueId = - (BOOL (__stdcall *)(PLUID)) - GetProcAddress(nt->hAdvapi32, "AllocateLocallyUniqueId"); - - // Desktop related API - if (nt->hUser32 != NULL) - { - nt->SwitchDesktop = - (BOOL (__stdcall *)(HDESK)) - GetProcAddress(nt->hUser32, "SwitchDesktop"); - nt->OpenDesktopA = - (HDESK (__stdcall *)(LPTSTR,DWORD,BOOL,ACCESS_MASK)) - GetProcAddress(nt->hUser32, "OpenDesktopA"); - nt->CloseDesktop = - (BOOL (__stdcall *)(HDESK)) - GetProcAddress(nt->hUser32, "CloseDesktop"); - } - - // DWM API - if (nt->hDwmapi) - { - nt->DwmIsCompositionEnabled = - (HRESULT (__stdcall *)(BOOL *)) - GetProcAddress(nt->hDwmapi, "DwmIsCompositionEnabled"); - } - - // Debug related API - if (nt->hDbgHelp != NULL) - { - nt->MiniDumpWriteDump = - (BOOL (__stdcall *)(HANDLE,DWORD,HANDLE,MINIDUMP_TYPE,PMINIDUMP_EXCEPTION_INFORMATION,PMINIDUMP_USER_STREAM_INFORMATION,PMINIDUMP_CALLBACK_INFORMATION)) - GetProcAddress(nt->hDbgHelp, "MiniDumpWriteDump"); - } - - return nt; -} - -// Release of NT system function -void MsFreeNtApiFunctions(NT_API *nt) -{ - // Validate arguments - if (nt == NULL) - { - return; - } - - if (nt->hSecur32 != NULL) - { - FreeLibrary(nt->hSecur32); - } - - if (nt->hNewDev != NULL) - { - FreeLibrary(nt->hSetupApi); - FreeLibrary(nt->hNewDev); - } - - FreeLibrary(nt->hAdvapi32); - - FreeLibrary(nt->hShell32); - - if (nt->hWtsApi32 != NULL) - { - FreeLibrary(nt->hWtsApi32); - } - - if (nt->hPsApi != NULL) - { - FreeLibrary(nt->hPsApi); - } - - if (nt->hUser32 != NULL) - { - FreeLibrary(nt->hUser32); - } - - if (nt->hDbgHelp != NULL) - { - FreeLibrary(nt->hDbgHelp); - } - - if (nt->hWcmapi != NULL) - { - FreeLibrary(nt->hWcmapi); - } - - if (nt->hDwmapi != NULL) - { - FreeLibrary(nt->hDwmapi); - } - - FreeLibrary(nt->hKernel32); - - Free(nt); -} - // Get whether the screen color is like to Aero of Windows Vista or later bool MsIsAeroColor() { - UINT r; - if (MsIsNt() == false) - { - return false; - } - - if (MsIsVista() == false) - { - return false; - } - - r = GetSysColor(COLOR_MENU); + UINT r = GetSysColor(COLOR_MENU); if (r == 0xFFFFFF || r == 0xF0F0F0 || r >= 0xF00000) { return true; @@ -10483,20 +8832,8 @@ bool MsIsAeroColor() // Get whether Aero is enabled bool MsIsAeroEnabled() { - BOOL ret; - if (MsIsNt() == false) - { - return false; - } - - if (ms->nt->DwmIsCompositionEnabled == NULL) - { - return false; - } - - ret = false; - - if (ms->nt->DwmIsCompositionEnabled(&ret) != S_OK) + BOOL ret = false; + if (DwmIsCompositionEnabled(&ret) != S_OK) { return false; } @@ -10532,14 +8869,7 @@ bool MsRegLoadHive(UINT root, wchar_t *keyname, wchar_t *filename) WHERE; return false; } - - if (ms->nt == NULL || ms->nt->RegLoadKeyW == NULL || ms->nt->RegUnLoadKeyW == NULL) - { - WHERE; - return false; - } - - ret = ms->nt->RegLoadKeyW(MsGetRootKeyFromInt(root), keyname, filename); + ret = RegLoadKeyW(MsGetRootKeyFromInt(root), keyname, filename); if (ret != ERROR_SUCCESS) { @@ -10560,12 +8890,7 @@ bool MsRegUnloadHive(UINT root, wchar_t *keyname) return false; } - if (ms->nt == NULL || ms->nt->RegLoadKeyW == NULL || ms->nt->RegUnLoadKeyW == NULL) - { - return false; - } - - ret = ms->nt->RegUnLoadKeyW(MsGetRootKeyFromInt(root), keyname); + ret = RegUnLoadKeyW(MsGetRootKeyFromInt(root), keyname); if (ret != ERROR_SUCCESS) { @@ -10631,19 +8956,9 @@ bool MsRegDeleteKeyEx2(UINT root, char *keyname, bool force32bit, bool force64bi return false; } - if (MsIsNt() && ms->nt->RegDeleteKeyExA != NULL) + if (RegDeleteKeyExA(MsGetRootKeyFromInt(root), keyname, MsRegAccessMaskFor64BitEx(force32bit, force64bit), 0) != ERROR_SUCCESS) { - if (ms->nt->RegDeleteKeyExA(MsGetRootKeyFromInt(root), keyname, MsRegAccessMaskFor64BitEx(force32bit, force64bit), 0) != ERROR_SUCCESS) - { - return false; - } - } - else - { - if (RegDeleteKey(MsGetRootKeyFromInt(root), keyname) != ERROR_SUCCESS) - { - return false; - } + return false; } return true; @@ -11851,68 +10166,29 @@ void MsGetSpecialDirs() ms->ProgramFilesDirX64W = CopyUniStr(ms->ProgramFilesDirW); } - if (MsIsNt()) - { - // Common start menu - ms->CommonStartMenuDir = MsGetSpecialDir(CSIDL_COMMON_STARTMENU); - ms->CommonStartMenuDirW = MsGetSpecialDirW(CSIDL_COMMON_STARTMENU); + // Common start menu + ms->CommonStartMenuDir = MsGetSpecialDir(CSIDL_COMMON_STARTMENU); + ms->CommonStartMenuDirW = MsGetSpecialDirW(CSIDL_COMMON_STARTMENU); - // Common program - ms->CommonProgramsDir = MsGetSpecialDir(CSIDL_COMMON_PROGRAMS); - ms->CommonProgramsDirW = MsGetSpecialDirW(CSIDL_COMMON_PROGRAMS); + // Common program + ms->CommonProgramsDir = MsGetSpecialDir(CSIDL_COMMON_PROGRAMS); + ms->CommonProgramsDirW = MsGetSpecialDirW(CSIDL_COMMON_PROGRAMS); - // Common startup - ms->CommonStartupDir = MsGetSpecialDir(CSIDL_COMMON_STARTUP); - ms->CommonStartupDirW = MsGetSpecialDirW(CSIDL_COMMON_STARTUP); + // Common startup + ms->CommonStartupDir = MsGetSpecialDir(CSIDL_COMMON_STARTUP); + ms->CommonStartupDirW = MsGetSpecialDirW(CSIDL_COMMON_STARTUP); - // Common application data - ms->CommonAppDataDir = MsGetSpecialDir(CSIDL_COMMON_APPDATA); - ms->CommonAppDataDirW = MsGetSpecialDirW(CSIDL_COMMON_APPDATA); + // Common application data + ms->CommonAppDataDir = MsGetSpecialDir(CSIDL_COMMON_APPDATA); + ms->CommonAppDataDirW = MsGetSpecialDirW(CSIDL_COMMON_APPDATA); - // Common desktop - ms->CommonDesktopDir = MsGetSpecialDir(CSIDL_COMMON_DESKTOPDIRECTORY); - ms->CommonDesktopDirW = MsGetSpecialDirW(CSIDL_COMMON_DESKTOPDIRECTORY); + // Common desktop + ms->CommonDesktopDir = MsGetSpecialDir(CSIDL_COMMON_DESKTOPDIRECTORY); + ms->CommonDesktopDirW = MsGetSpecialDirW(CSIDL_COMMON_DESKTOPDIRECTORY); - // Local Settings - ms->LocalAppDataDir = MsGetSpecialDir(CSIDL_LOCAL_APPDATA); - ms->LocalAppDataDirW = MsGetSpecialDirW(CSIDL_LOCAL_APPDATA); - } - else - { - // Start menu of the individual - ms->PersonalStartMenuDir = MsGetSpecialDir(CSIDL_STARTMENU); - ms->CommonStartMenuDir = CopyStr(ms->PersonalStartMenuDir); - ms->PersonalStartMenuDirW = MsGetSpecialDirW(CSIDL_STARTMENU); - ms->CommonStartMenuDirW = CopyUniStr(ms->PersonalStartMenuDirW); - - // Program of the individual - ms->PersonalProgramsDir = MsGetSpecialDir(CSIDL_PROGRAMS); - ms->CommonProgramsDir = CopyStr(ms->PersonalProgramsDir); - ms->PersonalProgramsDirW = MsGetSpecialDirW(CSIDL_PROGRAMS); - ms->CommonProgramsDirW = CopyUniStr(ms->PersonalProgramsDirW); - - // Start-up of the individual - ms->PersonalStartupDir = MsGetSpecialDir(CSIDL_STARTUP); - ms->CommonStartupDir = CopyStr(ms->PersonalStartupDir); - ms->PersonalStartupDirW = MsGetSpecialDirW(CSIDL_STARTUP); - ms->CommonStartupDirW = CopyUniStr(ms->PersonalStartupDirW); - - // Application data of the individual - ms->PersonalAppDataDir = MsGetSpecialDir(CSIDL_APPDATA); - ms->CommonAppDataDir = CopyStr(ms->PersonalAppDataDir); - ms->PersonalAppDataDirW = MsGetSpecialDirW(CSIDL_APPDATA); - ms->CommonAppDataDirW = CopyUniStr(ms->PersonalAppDataDirW); - - // Desktops of the individual - ms->PersonalDesktopDir = MsGetSpecialDir(CSIDL_DESKTOP); - ms->CommonDesktopDir = CopyStr(ms->PersonalDesktopDir); - ms->PersonalDesktopDirW = MsGetSpecialDirW(CSIDL_DESKTOP); - ms->CommonDesktopDirW = CopyUniStr(ms->PersonalDesktopDirW); - - // Local Settings - ms->LocalAppDataDir = CopyStr(ms->PersonalAppDataDir); - ms->LocalAppDataDirW = CopyUniStr(ms->PersonalAppDataDirW); - } + // Local Settings + ms->LocalAppDataDir = MsGetSpecialDir(CSIDL_LOCAL_APPDATA); + ms->LocalAppDataDirW = MsGetSpecialDirW(CSIDL_LOCAL_APPDATA); } // Check whether the current user is a Administrators @@ -11997,29 +10273,8 @@ void MsInit() os.dwOSVersionInfoSize = sizeof(os); GetVersionEx(&os); - if (os.dwPlatformId == VER_PLATFORM_WIN32_NT) - { - // NT series - ms->IsNt = true; - ms->nt = MsLoadNtApiFunctions(); - - if (ms->nt == NULL) - { - ms->IsNt = false; - ms->IsAdmin = true; - } - else - { - // Whether I am an Administrators - ms->IsAdmin = MsCheckIsAdmin(); - } - } - else - { - // In 9x system: Impersonate a Administrators always - ms->IsAdmin = true; - } + ms->IsAdmin = MsCheckIsAdmin(); if (GetProcAddress(ms->hKernel32, "wine_get_unix_file_name") != NULL) { @@ -12065,36 +10320,24 @@ void MsInit() ms->UserName = CopyStr(tmp); // Get the user name (Unicode) - if (IsNt()) - { - wchar_t tmp_w[MAX_PATH]; + wchar_t tmp_w[MAX_PATH]; - size = sizeof(tmp_w); + size = sizeof(tmp_w); - GetUserNameW(tmp_w, &size); - ms->UserNameW = CopyUniStr(tmp_w); - } - else - { - ms->UserNameW = CopyStrToUni(ms->UserName); - } + GetUserNameW(tmp_w, &size); + ms->UserNameW = CopyUniStr(tmp_w); // Get the full user name - if (ms->nt != NULL && ms->nt->GetUserNameExA != NULL) + size = sizeof(tmp); + if (GetUserNameExA(NameSamCompatible, tmp, &size)) { - wchar_t tmp_w[MAX_PATH]; + ms->UserNameEx = CopyStr(tmp); + } - size = sizeof(tmp); - if (ms->nt->GetUserNameExA(NameSamCompatible, tmp, &size)) - { - ms->UserNameEx = CopyStr(tmp); - } - - size = sizeof(tmp_w); - if (ms->nt->GetUserNameExW(NameSamCompatible, tmp_w, &size)) - { - ms->UserNameExW = CopyUniStr(tmp_w); - } + size = sizeof(tmp_w); + if (GetUserNameExW(NameSamCompatible, tmp_w, &size)) + { + ms->UserNameExW = CopyUniStr(tmp_w); } if (ms->UserNameEx == NULL) @@ -12125,58 +10368,41 @@ void MsInit() } MsSetEnableMinidump(true); - - if (MsIsNt()) - { - if (ms->nt->MiniDumpWriteDump != NULL) - { - SetUnhandledExceptionFilter(MsExceptionHandler); - } - } + SetUnhandledExceptionFilter(MsExceptionHandler); // Open a LSA handle hLsa = NULL; lsa_package_id = 0; - if (MsIsNt()) + + MsEnablePrivilege(SE_TCB_NAME, true); + + HANDLE h = NULL; + NTSTATUS ret = LsaConnectUntrusted(&h); + + if (ret == 0) { - MsEnablePrivilege(SE_TCB_NAME, true); + LSA_STRING pkg_name; + ULONG ul = 0; - if (ms->nt->AllocateLocallyUniqueId != NULL && - ms->nt->LsaConnectUntrusted != NULL && - ms->nt->LsaLookupAuthenticationPackage != NULL && - ms->nt->LsaLogonUser != NULL && - ms->nt->LsaDeregisterLogonProcess != NULL && - ms->nt->LsaFreeReturnBuffer != NULL) + Zero(&pkg_name, sizeof(pkg_name)); + pkg_name.Buffer = MSV1_0_PACKAGE_NAME; + pkg_name.Length = pkg_name.MaximumLength = StrLen(MSV1_0_PACKAGE_NAME); + + ret = LsaLookupAuthenticationPackage(h, &pkg_name, &ul); + + if (ret == 0) { - HANDLE h = NULL; - NTSTATUS ret = ms->nt->LsaConnectUntrusted(&h); + Zero(&lsa_token_source, sizeof(lsa_token_source)); - if (ret == 0) - { - LSA_STRING pkg_name; - ULONG ul = 0; + AllocateLocallyUniqueId(&lsa_token_source.SourceIdentifier); + Copy(lsa_token_source.SourceName, "SE-VPN ", 8); - Zero(&pkg_name, sizeof(pkg_name)); - pkg_name.Buffer = MSV1_0_PACKAGE_NAME; - pkg_name.Length = pkg_name.MaximumLength = StrLen(MSV1_0_PACKAGE_NAME); - - ret = ms->nt->LsaLookupAuthenticationPackage(h, &pkg_name, &ul); - - if (ret == 0) - { - Zero(&lsa_token_source, sizeof(lsa_token_source)); - - ms->nt->AllocateLocallyUniqueId(&lsa_token_source.SourceIdentifier); - Copy(lsa_token_source.SourceName, "SE-VPN ", 8); - - lsa_package_id = ul; - hLsa = h; - } - else - { - ms->nt->LsaDeregisterLogonProcess(h); - } - } + lsa_package_id = ul; + hLsa = h; + } + else + { + LsaDeregisterLogonProcess(h); } } @@ -12345,7 +10571,7 @@ void MsWriteMinidump(wchar_t *filename, void *ex) NULL); if (h != INVALID_HANDLE_VALUE) { - ms->nt->MiniDumpWriteDump(ms->hCurrentProcess, ms->CurrentProcessId, + MiniDumpWriteDump(ms->hCurrentProcess, ms->CurrentProcessId, h, MiniDumpNormal | MiniDumpWithFullMemory | MiniDumpWithDataSegs | MiniDumpWithHandleData @@ -12380,7 +10606,7 @@ void MsFree() // Release the LSA if (hLsa != NULL) { - ms->nt->LsaDeregisterLogonProcess(hLsa); + LsaDeregisterLogonProcess(hLsa); hLsa = NULL; } @@ -12391,12 +10617,6 @@ void MsFree() // Release of the temporary directory MsFreeTempDir(); - if (ms->IsNt) - { - // Release of NT series API - MsFreeNtApiFunctions(ms->nt); - } - // Memory release // ANSI Free(ms->WindowsDir); diff --git a/src/Mayaqua/Microsoft.h b/src/Mayaqua/Microsoft.h index 17ff0a13..dbdf4067 100644 --- a/src/Mayaqua/Microsoft.h +++ b/src/Mayaqua/Microsoft.h @@ -47,9 +47,6 @@ typedef unsigned long DWORD; #define SVC_ARG_SERVICE "/service" #define SVC_ARG_SETUP_INSTALL "/setup_install" #define SVC_ARG_SETUP_UNINSTALL "/setup_uninstall" -#define SVC_ARG_WIN9X_SERVICE "/win9x_service" -#define SVC_ARG_WIN9X_INSTALL "/win9x_install" -#define SVC_ARG_WIN9X_UNINSTALL "/win9x_uninstall" #define SVC_ARG_TCP "/tcp" #define SVC_ARG_TCP_UAC "/tcp_uac" #define SVC_ARG_TCP_UAC_W L"/tcp_uac" @@ -92,19 +89,12 @@ typedef unsigned long DWORD; #define SVC_MODE_SERVICE 7 #define SVC_MODE_SETUP_INSTALL 8 #define SVC_MODE_SETUP_UNINSTALL 9 -#define SVC_MODE_WIN9X_SERVICE 10 -#define SVC_MODE_WIN9X_INSTALL 11 -#define SVC_MODE_WIN9X_UNINSTALL 12 #define SVC_MODE_TCP 13 #define SVC_MODE_TCPSETUP 14 #define SVC_MODE_TRAFFIC 15 #define SVC_MODE_UIHELP 16 #define SVC_MODE_TCP_UAC 17 - -#define WIN9X_SVC_REGKEY_1 "Software\\Microsoft\\Windows\\CurrentVersion\\RunServices" -#define WIN9X_SVC_REGKEY_2 "Software\\Microsoft\\Windows\\CurrentVersion\\Run" - #define VISTA_MMCSS_KEYNAME "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Multimedia\\SystemProfile\\Tasks" #define VISTA_MMCSS_FILENAME "mmcss_backup.dat" @@ -138,69 +128,23 @@ typedef unsigned long DWORD; #define DRIVER_DEVICE_ID_TAG "NeoAdapter_%s" - -#if (defined(MICROSOFT_C) || defined(NETWORK_C)) && (defined(OS_WIN32)) - -typedef enum __TCP_TABLE_CLASS { - _TCP_TABLE_BASIC_LISTENER, - _TCP_TABLE_BASIC_CONNECTIONS, - _TCP_TABLE_BASIC_ALL, - _TCP_TABLE_OWNER_PID_LISTENER, - _TCP_TABLE_OWNER_PID_CONNECTIONS, - _TCP_TABLE_OWNER_PID_ALL, - _TCP_TABLE_OWNER_MODULE_LISTENER, - _TCP_TABLE_OWNER_MODULE_CONNECTIONS, - _TCP_TABLE_OWNER_MODULE_ALL -} _TCP_TABLE_CLASS, *_PTCP_TABLE_CLASS; - -// A pointer to the network related Win32 API function -typedef struct NETWORK_WIN32_FUNCTIONS -{ - HINSTANCE hIpHlpApi32; - HINSTANCE hIcmp; - DWORD (WINAPI *DeleteIpForwardEntry)(PMIB_IPFORWARDROW); - DWORD (WINAPI *CreateIpForwardEntry)(PMIB_IPFORWARDROW); - DWORD (WINAPI *GetIpForwardTable)(PMIB_IPFORWARDTABLE, PULONG, BOOL); - DWORD (WINAPI *GetNetworkParams)(PFIXED_INFO, PULONG); - ULONG (WINAPI *GetAdaptersAddresses)(ULONG, ULONG, PVOID, PIP_ADAPTER_ADDRESSES, PULONG); - DWORD (WINAPI *GetIfTable)(PMIB_IFTABLE, PULONG, BOOL); - DWORD (WINAPI *GetIfTable2)(void **); - void (WINAPI *FreeMibTable)(PVOID); - DWORD (WINAPI *IpRenewAddress)(PIP_ADAPTER_INDEX_MAP); - DWORD (WINAPI *IpReleaseAddress)(PIP_ADAPTER_INDEX_MAP); - DWORD (WINAPI *GetInterfaceInfo)(PIP_INTERFACE_INFO, PULONG); - DWORD (WINAPI *GetAdaptersInfo)(PIP_ADAPTER_INFO, PULONG); - DWORD (WINAPI *GetExtendedTcpTable)(PVOID, PDWORD, BOOL, ULONG, _TCP_TABLE_CLASS, ULONG); - DWORD (WINAPI *AllocateAndGetTcpExTableFromStack)(PVOID *, BOOL, HANDLE, DWORD, DWORD); - DWORD (WINAPI *GetTcpTable)(PMIB_TCPTABLE, PULONG, BOOL); - DWORD (WINAPI *NotifyRouteChange)(PHANDLE, LPOVERLAPPED); - BOOL (WINAPI *CancelIPChangeNotify)(LPOVERLAPPED); - DWORD (WINAPI *NhpAllocateAndGetInterfaceInfoFromStack)(IP_INTERFACE_NAME_INFO **, - PDWORD, BOOL, HANDLE, DWORD); - HANDLE (WINAPI *IcmpCreateFile)(); - BOOL (WINAPI *IcmpCloseHandle)(HANDLE); - DWORD (WINAPI *IcmpSendEcho)(HANDLE, IPAddr, LPVOID, WORD, PIP_OPTION_INFORMATION, - LPVOID, DWORD, DWORD); -} NETWORK_WIN32_FUNCTIONS; -#endif - -#ifdef MICROSOFT_C +#ifdef MICROSOFT_C // WCM related code on Windows 8 typedef enum _MS_WCM_PROPERTY { ms_wcm_global_property_domain_policy, ms_wcm_global_property_minimize_policy, - ms_wcm_global_property_roaming_policy, + ms_wcm_global_property_roaming_policy, ms_wcm_global_property_powermanagement_policy, ms_wcm_intf_property_connection_cost, //used to set/get cost level and flags for the connection ms_wcm_intf_property_dataplan_status, //used by MNO to indicate plan data associated with new cost ms_wcm_intf_property_hotspot_profile, //used to store hotspot profile (WISPr credentials) -} MS_WCM_PROPERTY, *MS_PWCM_PROPERTY; +} MS_WCM_PROPERTY, * MS_PWCM_PROPERTY; typedef struct _MS_WCM_POLICY_VALUE { BOOL fValue; BOOL fIsGroupPolicy; -} MS_WCM_POLICY_VALUE, *MS_PWCM_POLICY_VALUE; +} MS_WCM_POLICY_VALUE, * MS_PWCM_POLICY_VALUE; #define MS_WCM_MAX_PROFILE_NAME 256 @@ -212,21 +156,20 @@ typedef enum _MS_WCM_MEDIA_TYPE ms_wcm_media_mbn, ms_wcm_media_invalid, ms_wcm_media_max -} MS_WCM_MEDIA_TYPE, *MS_PWCM_MEDIA_TYPE; +} MS_WCM_MEDIA_TYPE, * MS_PWCM_MEDIA_TYPE; typedef struct _MS_WCM_PROFILE_INFO { WCHAR strProfileName[MS_WCM_MAX_PROFILE_NAME]; GUID AdapterGUID; MS_WCM_MEDIA_TYPE Media; -} MS_WCM_PROFILE_INFO, *MS_PWCM_PROFILE_INFO; +} MS_WCM_PROFILE_INFO, * MS_PWCM_PROFILE_INFO; typedef struct _MS_WCM_PROFILE_INFO_LIST { UINT dwNumberOfItems; MS_WCM_PROFILE_INFO ProfileInfo[1]; -} MS_WCM_PROFILE_INFO_LIST, *MS_PWCM_PROFILE_INFO_LIST; - +} MS_WCM_PROFILE_INFO_LIST, * MS_PWCM_PROFILE_INFO_LIST; // Internal structure typedef struct MS @@ -235,7 +178,6 @@ typedef struct MS HINSTANCE hKernel32; bool IsNt; bool IsAdmin; - struct NT_API *nt; HANDLE hCurrentProcess; UINT CurrentProcessId; bool MiniDumpEnabled; @@ -294,112 +236,11 @@ typedef struct MS bool IsWine; } MS; -// For Windows NT API -typedef struct NT_API -{ - HINSTANCE hAdvapi32; - HINSTANCE hShell32; - HINSTANCE hNewDev; - HINSTANCE hSetupApi; - HINSTANCE hWtsApi32; - HINSTANCE hPsApi; - HINSTANCE hKernel32; - HINSTANCE hSecur32; - HINSTANCE hUser32; - HINSTANCE hDbgHelp; - HINSTANCE hWcmapi; - HINSTANCE hDwmapi; - BOOL (WINAPI *OpenProcessToken)(HANDLE, DWORD, PHANDLE); - BOOL (WINAPI *LookupPrivilegeValue)(char *, char *, PLUID); - BOOL (WINAPI *AdjustTokenPrivileges)(HANDLE, BOOL, PTOKEN_PRIVILEGES, DWORD, PTOKEN_PRIVILEGES, PDWORD); - BOOL (WINAPI *InitiateSystemShutdown)(LPTSTR, LPTSTR, DWORD, BOOL, BOOL); - BOOL (WINAPI *LogonUserW)(wchar_t *, wchar_t *, wchar_t *, DWORD, DWORD, HANDLE *); - BOOL (WINAPI *LogonUserA)(char *, char *, char *, DWORD, DWORD, HANDLE *); - BOOL (WINAPI *UpdateDriverForPlugAndPlayDevicesW)(HWND hWnd, LPCWSTR hardware_id, LPCWSTR inf_path, DWORD flag, PBOOL need_reboot); - DWORD (WINAPI *CM_Get_DevNode_Status_Ex)(PULONG, PULONG, DWORD, ULONG, HANDLE); - DWORD (WINAPI *CM_Get_Device_ID_ExA)(DWORD, LPSTR, ULONG, ULONG, HANDLE); - BOOL (WINAPI *WTSQuerySessionInformation)(HANDLE, DWORD, WTS_INFO_CLASS, wchar_t *, DWORD *); - void (WINAPI *WTSFreeMemory)(void *); - BOOL (WINAPI *WTSDisconnectSession)(HANDLE, DWORD, BOOL); - BOOL (WINAPI *WTSEnumerateSessions)(HANDLE, DWORD, DWORD, PWTS_SESSION_INFO *, DWORD *); - BOOL (WINAPI *WTSRegisterSessionNotification)(HWND, DWORD); - BOOL (WINAPI *WTSUnRegisterSessionNotification)(HWND); - SC_HANDLE (WINAPI *OpenSCManager)(LPCTSTR, LPCTSTR, DWORD); - SC_HANDLE (WINAPI *CreateServiceA)(SC_HANDLE, LPCTSTR, LPCTSTR, DWORD, DWORD, DWORD, DWORD, LPCTSTR, LPCTSTR, LPDWORD, LPCTSTR, LPCTSTR, LPCTSTR); - SC_HANDLE (WINAPI *CreateServiceW)(SC_HANDLE, LPCWSTR, LPCWSTR, DWORD, DWORD, DWORD, DWORD, LPCWSTR, LPCWSTR, LPDWORD, LPCWSTR, LPCWSTR, LPCWSTR); - BOOL (WINAPI *ChangeServiceConfig2)(SC_HANDLE, DWORD, LPVOID); - BOOL (WINAPI *CloseServiceHandle)(SC_HANDLE); - SC_HANDLE (WINAPI *OpenService)(SC_HANDLE, LPCTSTR, DWORD); - BOOL (WINAPI *QueryServiceStatus)(SC_HANDLE, LPSERVICE_STATUS); - BOOL (WINAPI *StartService)(SC_HANDLE, DWORD, LPCTSTR); - BOOL (WINAPI *ControlService)(SC_HANDLE, DWORD, LPSERVICE_STATUS); - BOOL (WINAPI *SetServiceStatus)(SERVICE_STATUS_HANDLE, LPSERVICE_STATUS); - SERVICE_STATUS_HANDLE (WINAPI *RegisterServiceCtrlHandler)(LPCTSTR, LPHANDLER_FUNCTION); - BOOL (WINAPI *StartServiceCtrlDispatcher)(CONST LPSERVICE_TABLE_ENTRY); - BOOL (WINAPI *DeleteService)(SC_HANDLE); - BOOL (WINAPI *EnumProcesses)(DWORD *, DWORD, DWORD *); - BOOL (WINAPI *EnumProcessModules)(HANDLE, HMODULE *, DWORD, DWORD *); - DWORD (WINAPI *GetModuleFileNameExA)(HANDLE, HMODULE, LPSTR, DWORD); - DWORD (WINAPI *GetModuleFileNameExW)(HANDLE, HMODULE, LPWSTR, DWORD); - DWORD (WINAPI *GetProcessImageFileNameA)(HANDLE, LPSTR, DWORD); - DWORD (WINAPI *GetProcessImageFileNameW)(HANDLE, LPWSTR, DWORD); - BOOL (WINAPI *QueryFullProcessImageNameA)(HANDLE, DWORD, LPSTR, PDWORD); - BOOL (WINAPI *QueryFullProcessImageNameW)(HANDLE, DWORD, LPWSTR, PDWORD); - LONG (WINAPI *RegDeleteKeyExA)(HKEY, LPCTSTR, REGSAM, DWORD); - BOOL (WINAPI *IsWow64Process)(HANDLE, BOOL *); - void (WINAPI *GetNativeSystemInfo)(SYSTEM_INFO *); - BOOL (WINAPI *DuplicateTokenEx)(HANDLE, DWORD, SECURITY_ATTRIBUTES *, SECURITY_IMPERSONATION_LEVEL, TOKEN_TYPE, HANDLE *); - BOOL (WINAPI *ConvertStringSidToSidA)(LPCSTR, PSID *); - BOOL (WINAPI *SetTokenInformation)(HANDLE, TOKEN_INFORMATION_CLASS, void *, DWORD); - BOOL (WINAPI *GetTokenInformation)(HANDLE, TOKEN_INFORMATION_CLASS, void *, DWORD, PDWORD); - BOOL (WINAPI *CreateProcessAsUserA)(HANDLE, LPCSTR, LPSTR, LPSECURITY_ATTRIBUTES, LPSECURITY_ATTRIBUTES, BOOL, DWORD, void *, LPCSTR, LPSTARTUPINFOA, LPPROCESS_INFORMATION); - BOOL (WINAPI *CreateProcessAsUserW)(HANDLE, LPCWSTR, LPWSTR, LPSECURITY_ATTRIBUTES, LPSECURITY_ATTRIBUTES, BOOL, DWORD, void *, LPCWSTR, LPSTARTUPINFOW, LPPROCESS_INFORMATION); - BOOL (WINAPI *LookupAccountSidA)(LPCSTR,PSID,LPSTR,LPDWORD,LPSTR,LPDWORD,PSID_NAME_USE); - BOOL (WINAPI *LookupAccountNameA)(LPCSTR,LPCSTR,PSID,LPDWORD,LPSTR,LPDWORD,PSID_NAME_USE); - BOOL (WINAPI *GetUserNameExA)(EXTENDED_NAME_FORMAT, LPSTR, PULONG); - BOOL (WINAPI *GetUserNameExW)(EXTENDED_NAME_FORMAT, LPWSTR, PULONG); - BOOL (WINAPI *SwitchDesktop)(HDESK); - HDESK (WINAPI *OpenDesktopA)(LPTSTR, DWORD, BOOL, ACCESS_MASK); - BOOL (WINAPI *CloseDesktop)(HDESK); - BOOL (WINAPI *SetProcessShutdownParameters)(DWORD, DWORD); - HANDLE (WINAPI *RegisterEventSourceW)(LPCWSTR, LPCWSTR); - BOOL (WINAPI *ReportEventW)(HANDLE, WORD, WORD, DWORD, PSID, WORD, DWORD, LPCWSTR *, LPVOID); - BOOL (WINAPI *DeregisterEventSource)(HANDLE); - BOOL (WINAPI *Wow64DisableWow64FsRedirection)(void **); - BOOLEAN (WINAPI *Wow64EnableWow64FsRedirection)(BOOLEAN); - BOOL (WINAPI *Wow64RevertWow64FsRedirection)(void *); - BOOL (WINAPI *GetFileInformationByHandle)(HANDLE, LPBY_HANDLE_FILE_INFORMATION); - HANDLE (WINAPI *GetProcessHeap)(); - BOOL (WINAPI *MiniDumpWriteDump)(HANDLE, DWORD, HANDLE, MINIDUMP_TYPE, - PMINIDUMP_EXCEPTION_INFORMATION, PMINIDUMP_USER_STREAM_INFORMATION, - PMINIDUMP_CALLBACK_INFORMATION); - BOOL (WINAPI *AllocateLocallyUniqueId)(PLUID); - NTSTATUS (NTAPI *LsaConnectUntrusted)(PHANDLE); - NTSTATUS (NTAPI *LsaLookupAuthenticationPackage)(HANDLE, PLSA_STRING, PULONG); - NTSTATUS (NTAPI *LsaLogonUser)(HANDLE, PLSA_STRING, SECURITY_LOGON_TYPE, ULONG, - PVOID, ULONG, PTOKEN_GROUPS, PTOKEN_SOURCE, PVOID, PULONG, PLUID, PHANDLE, - PQUOTA_LIMITS, PNTSTATUS); - NTSTATUS (NTAPI *LsaDeregisterLogonProcess)(HANDLE); - NTSTATUS (NTAPI *LsaFreeReturnBuffer)(PVOID); - DWORD (WINAPI *WcmQueryProperty)(const GUID *, LPCWSTR, MS_WCM_PROPERTY, PVOID, PDWORD, PBYTE *); - DWORD (WINAPI *WcmSetProperty)(const GUID *, LPCWSTR, MS_WCM_PROPERTY, PVOID, DWORD, const BYTE *); - void (WINAPI *WcmFreeMemory)(PVOID); - DWORD (WINAPI *WcmGetProfileList)(PVOID, MS_WCM_PROFILE_INFO_LIST **ppProfileList); - DWORD (WINAPI *SetNamedSecurityInfoW)(LPWSTR, DWORD, SECURITY_INFORMATION, PSID, PSID, PACL, PACL); - BOOL (WINAPI *AddAccessAllowedAceEx)(PACL, DWORD, DWORD, DWORD, PSID); - HRESULT (WINAPI *DwmIsCompositionEnabled)(BOOL *); - BOOL (WINAPI *GetComputerNameExW)(COMPUTER_NAME_FORMAT, LPWSTR, LPDWORD); - LONG (WINAPI *RegLoadKeyW)(HKEY, LPCWSTR, LPCWSTR); - LONG (WINAPI *RegUnLoadKeyW)(HKEY, LPCWSTR); -} NT_API; - typedef struct MS_EVENTLOG { HANDLE hEventLog; } MS_EVENTLOG; -extern NETWORK_WIN32_FUNCTIONS *w32net; - typedef struct MS_USERMODE_SVC_PULSE_THREAD_PARAM { void *hWnd; @@ -613,7 +454,6 @@ bool MsRegDeleteValueEx2(UINT root, char *keyname, char *valuename, bool force32 bool MsRegLoadHive(UINT root, wchar_t *keyname, wchar_t *filename); bool MsRegUnloadHive(UINT root, wchar_t *keyname); -bool MsIsNt(); bool MsIsAdmin(); bool MsIsWine(); bool MsEnablePrivilege(char *name, bool enable); @@ -740,10 +580,7 @@ bool MsIsUserMode(); void MsTestOnly(); void MsPlaySound(char *name); void MsSetThreadSingleCpu(); -void MsWin9xTest(); bool MsCheckVLanDeviceIdFromRootEnum(char *name); -bool MsInstallVLan9x(char *instance_name, MS_DRIVER_VER *ver); -void MsUpdateCompatibleIDs(char *instance_name); LIST *MsGetProcessList(); LIST *MsGetProcessList9x(); LIST *MsGetProcessListNt(); @@ -825,9 +662,6 @@ LIST *EnumAllChildWindowEx(HWND hWnd, bool no_recursion, bool include_ipcontrol, LIST *EnumAllTopWindow(); bool MsExecDriverInstaller(char *arg); -bool MsIsVista(); -bool MsIsWin2000OrGreater(); -bool MsIsWinXPOrGreater(); void MsRegistWindowsFirewallEx(char *title, char *exe); void MsRegistWindowsFirewallEx2(char *title, char *exe, char *dir); bool MsIs64BitWindows(); @@ -937,8 +771,6 @@ UINT64 MsGetSuspendModeBeginTick(); LONG CALLBACK MsExceptionHandler(struct _EXCEPTION_POINTERS *ExceptionInfo); HKEY MsGetRootKeyFromInt(UINT root); -NT_API *MsLoadNtApiFunctions(); -void MsFreeNtApiFunctions(NT_API *nt); void MsDestroyDevInfo(HDEVINFO info); HDEVINFO MsGetDevInfoFromDeviceId(SP_DEVINFO_DATA *dev_info_data, char *device_id); bool MsStartDevice(HDEVINFO info, SP_DEVINFO_DATA *dev_info_data); diff --git a/src/Mayaqua/Network.c b/src/Mayaqua/Network.c index d193e121..81625307 100644 --- a/src/Mayaqua/Network.c +++ b/src/Mayaqua/Network.c @@ -14,8 +14,8 @@ #ifdef WIN32 // Include windows.h for Socket API -#define _WIN32_WINNT 0x0502 -#define WINVER 0x0502 +#define _WIN32_WINNT 0x0600 +#define WINVER 0x0600 #include #include #include @@ -48,15 +48,14 @@ #include #endif // UNIX_MACOS -#ifdef OS_WIN32 -NETWORK_WIN32_FUNCTIONS *w32net; +#ifdef OS_WIN32 struct ROUTE_CHANGE_DATA { OVERLAPPED Overlapped; HANDLE Handle; UINT NumCalled; }; -#endif // OS_WIN32 +#endif // Whether the blocking occurs in SSL #if defined(UNIX_BSD) || defined(UNIX_MACOS) @@ -6031,7 +6030,7 @@ void IcmpApiFreeResult(ICMP_RESULT *ret) // Send an ICMP Echo using ICMP API ICMP_RESULT *IcmpApiEchoSend(IP *dest_ip, UCHAR ttl, UCHAR *data, UINT size, UINT timeout) { -#ifdef OS_WIN32 +#ifdef OS_WIN32 // Validate arguments if (dest_ip == NULL || IsIP4(dest_ip) == false || (size != 0 && data == NULL)) { @@ -6042,7 +6041,7 @@ ICMP_RESULT *IcmpApiEchoSend(IP *dest_ip, UCHAR ttl, UCHAR *data, UINT size, UIN ttl = 127; } - if (IsIcmpApiSupported()) + if (true) { HANDLE h; DWORD dw; @@ -6052,7 +6051,7 @@ ICMP_RESULT *IcmpApiEchoSend(IP *dest_ip, UCHAR ttl, UCHAR *data, UINT size, UIN ICMP_RESULT *ret = NULL; IP_OPTION_INFORMATION opt; - h = w32net->IcmpCreateFile(); + h = IcmpCreateFile(); if (h == INVALID_HANDLE_VALUE) { @@ -6067,7 +6066,7 @@ ICMP_RESULT *IcmpApiEchoSend(IP *dest_ip, UCHAR ttl, UCHAR *data, UINT size, UIN reply_size = sizeof(*reply) + size + 64; reply = ZeroMalloc(reply_size); - dw = w32net->IcmpSendEcho(h, dest_addr, data, size, &opt, reply, reply_size, timeout); + dw = IcmpSendEcho(h, dest_addr, data, size, &opt, reply, reply_size, timeout); ret = ZeroMalloc(sizeof(ICMP_RESULT)); @@ -6130,7 +6129,7 @@ ICMP_RESULT *IcmpApiEchoSend(IP *dest_ip, UCHAR ttl, UCHAR *data, UINT size, UIN Free(reply); - w32net->IcmpCloseHandle(h); + IcmpCloseHandle(h); return ret; } @@ -6144,21 +6143,6 @@ ICMP_RESULT *IcmpApiEchoSend(IP *dest_ip, UCHAR ttl, UCHAR *data, UINT size, UIN #endif // OS_WIN32 } -// Detect whether the ICMP API is supported -bool IsIcmpApiSupported() -{ -#ifdef OS_WIN32 - if (w32net->IcmpCloseHandle != NULL && - w32net->IcmpCreateFile != NULL && - w32net->IcmpSendEcho != NULL) - { - return true; - } -#endif // OS_WIN32 - - return false; -} - // Initialize the routing table change detector ROUTE_CHANGE *NewRouteChange() { @@ -6194,24 +6178,13 @@ ROUTE_CHANGE *Win32NewRouteChange() ROUTE_CHANGE *r; BOOL ret; - if (MsIsNt() == false) - { - return NULL; - } - - if (w32net->CancelIPChangeNotify == NULL || - w32net->NotifyRouteChange == NULL) - { - return NULL; - } - r = ZeroMalloc(sizeof(ROUTE_CHANGE)); r->Data = ZeroMalloc(sizeof(ROUTE_CHANGE_DATA)); r->Data->Overlapped.hEvent = CreateEventA(NULL, false, true, NULL); - ret = w32net->NotifyRouteChange(&r->Data->Handle, &r->Data->Overlapped); + ret = NotifyRouteChange(&r->Data->Handle, &r->Data->Overlapped); if (!(ret == NO_ERROR || ret == WSA_IO_PENDING || WSAGetLastError() == WSA_IO_PENDING)) { Free(r->Data); @@ -6231,7 +6204,7 @@ void Win32FreeRouteChange(ROUTE_CHANGE *r) return; } - w32net->CancelIPChangeNotify(&r->Data->Overlapped); + CancelIPChangeNotify(&r->Data->Overlapped); CloseHandle(r->Data->Overlapped.hEvent); Free(r->Data); @@ -6253,7 +6226,7 @@ bool Win32IsRouteChanged(ROUTE_CHANGE *r) if (WaitForSingleObject(r->Data->Overlapped.hEvent, 0) == WAIT_OBJECT_0) { - w32net->NotifyRouteChange(&r->Data->Handle, &r->Data->Overlapped); + NotifyRouteChange(&r->Data->Handle, &r->Data->Overlapped); return true; } @@ -8779,9 +8752,7 @@ void UnixFreeSocketLibrary() #endif // OS_UNIX -#ifdef OS_WIN32 // Code for Windows - -NETWORK_WIN32_FUNCTIONS *w32net; +#ifdef OS_WIN32 // Code for Windows // Comparison of IP_ADAPTER_INDEX_MAP int CompareIpAdapterIndexMap(void *p1, void *p2) @@ -8838,12 +8809,8 @@ bool Win32RenewAddress(void *a) { return false; } - if (w32net->IpRenewAddress == NULL) - { - return false; - } - ret = w32net->IpRenewAddress(a); + ret = IpRenewAddress(a); if (ret == NO_ERROR) { @@ -8865,12 +8832,12 @@ bool Win32ReleaseAddress(void *a) { return false; } - if (w32net->IpReleaseAddress == NULL) + if (IpReleaseAddress == NULL) { return false; } - ret = w32net->IpReleaseAddress(a); + ret = IpReleaseAddress(a); if (ret == NO_ERROR) { @@ -9025,23 +8992,19 @@ bool Win32GetAdapterFromGuid(void *a, char *guid) { return false; } - if (w32net->GetInterfaceInfo == NULL) - { - return false; - } UniFormat(tmp, sizeof(tmp), L"\\DEVICE\\TCPIP_%S", guid); size = sizeof(IP_INTERFACE_INFO); info = ZeroMallocFast(size); - if (w32net->GetInterfaceInfo(info, &size) == ERROR_INSUFFICIENT_BUFFER) + if (GetInterfaceInfo(info, &size) == ERROR_INSUFFICIENT_BUFFER) { Free(info); info = ZeroMallocFast(size); } - if (w32net->GetInterfaceInfo(info, &size) != NO_ERROR) + if (GetInterfaceInfo(info, &size) != NO_ERROR) { Free(info); return false; @@ -9099,13 +9062,13 @@ void Win32RenewDhcp9x(UINT if_id) size = sizeof(IP_INTERFACE_INFO); info = ZeroMallocFast(size); - if (w32net->GetInterfaceInfo(info, &size) == ERROR_INSUFFICIENT_BUFFER) + if (GetInterfaceInfo(info, &size) == ERROR_INSUFFICIENT_BUFFER) { Free(info); info = ZeroMallocFast(size); } - if (w32net->GetInterfaceInfo(info, &size) != NO_ERROR) + if (GetInterfaceInfo(info, &size) != NO_ERROR) { Free(info); return; @@ -9155,13 +9118,13 @@ void Win32ReleaseDhcp9x(UINT if_id, bool wait) size = sizeof(IP_INTERFACE_INFO); info = ZeroMallocFast(size); - if (w32net->GetInterfaceInfo(info, &size) == ERROR_INSUFFICIENT_BUFFER) + if (GetInterfaceInfo(info, &size) == ERROR_INSUFFICIENT_BUFFER) { Free(info); info = ZeroMallocFast(size); } - if (w32net->GetInterfaceInfo(info, &size) != NO_ERROR) + if (GetInterfaceInfo(info, &size) != NO_ERROR) { Free(info); return; @@ -9216,7 +9179,7 @@ RETRY: size_needed = 0; // Examine the needed size - ret = w32net->GetIfTable(p, &size_needed, 0); + ret = GetIfTable(p, &size_needed, 0); if (ret == ERROR_INSUFFICIENT_BUFFER) { // Re-allocate the memory block of the needed size @@ -9232,7 +9195,7 @@ FAILED: } // Actually get - ret = w32net->GetIfTable(p, &size_needed, FALSE); + ret = GetIfTable(p, &size_needed, FALSE); if (ret != NO_ERROR) { // Acquisition failure @@ -9297,7 +9260,7 @@ RETRY: size_needed = 0; // Examine the needed size - ret = w32net->GetIfTable(p, &size_needed, 0); + ret = GetIfTable(p, &size_needed, 0); if (ret == ERROR_INSUFFICIENT_BUFFER) { // Re-allocate the memory block of the needed size @@ -9314,7 +9277,7 @@ FAILED: } // Actually get - ret = w32net->GetIfTable(p, &size_needed, FALSE); + ret = GetIfTable(p, &size_needed, FALSE); if (ret != NO_ERROR) { // Acquisition failure @@ -9379,19 +9342,15 @@ bool Win32GetDnsSuffix(char *domain, UINT size) { return false; } - if (w32net->GetAdaptersAddresses == NULL) - { - return false; - } info_size = 0; info = ZeroMalloc(sizeof(IP_ADAPTER_ADDRESSES_XP)); - if (w32net->GetAdaptersAddresses(AF_INET, 0, NULL, info, &info_size) == ERROR_BUFFER_OVERFLOW) + if (GetAdaptersAddresses(AF_INET, 0, NULL, info, &info_size) == ERROR_BUFFER_OVERFLOW) { Free(info); info = ZeroMalloc(info_size); } - if (w32net->GetAdaptersAddresses(AF_INET, 0, NULL, info, &info_size) != NO_ERROR) + if (GetAdaptersAddresses(AF_INET, 0, NULL, info, &info_size) != NO_ERROR) { Free(info); return false; @@ -9429,18 +9388,15 @@ bool Win32GetDefaultDns(IP *ip, char *domain, UINT size) return false; } Zero(ip, sizeof(IP)); - if (w32net->GetNetworkParams == NULL) - { - return false; - } + info_size = 0; info = ZeroMallocFast(sizeof(FIXED_INFO)); - if (w32net->GetNetworkParams(info, &info_size) == ERROR_BUFFER_OVERFLOW) + if (GetNetworkParams(info, &info_size) == ERROR_BUFFER_OVERFLOW) { Free(info); info = ZeroMallocFast(info_size); } - if (w32net->GetNetworkParams(info, &info_size) != NO_ERROR) + if (GetNetworkParams(info, &info_size) != NO_ERROR) { Free(info); return false; @@ -9485,9 +9441,7 @@ void Win32DeleteRouteEntry(ROUTE_ENTRY *e) p = ZeroMallocFast(sizeof(MIB_IPFORWARDROW)); Win32RouteEntryToIpForwardRow(p, e); - // Delete - w32net->DeleteIpForwardEntry(p); - + DeleteIpForwardEntry(p); Free(p); } @@ -9513,8 +9467,7 @@ bool Win32AddRouteEntry(ROUTE_ENTRY *e, bool *already_exists) p = ZeroMallocFast(sizeof(MIB_IPFORWARDROW)); Win32RouteEntryToIpForwardRow(p, e); - // Adding - err = w32net->CreateIpForwardEntry(p); + err = CreateIpForwardEntry(p); if (err != 0) { if (err == ERROR_OBJECT_ALREADY_EXISTS) @@ -9556,7 +9509,7 @@ RETRY: size_needed = 0; // Examine the needed size - ret = w32net->GetIpForwardTable(p, &size_needed, 0); + ret = GetIpForwardTable(p, &size_needed, 0); if (ret == ERROR_INSUFFICIENT_BUFFER) { // Re-allocate the memory block of the needed size @@ -9573,7 +9526,7 @@ FAILED: } // Actually get - ret = w32net->GetIpForwardTable(p, &size_needed, FALSE); + ret = GetIpForwardTable(p, &size_needed, FALSE); if (ret != NO_ERROR) { // Acquisition failure @@ -9676,16 +9629,8 @@ void Win32RouteEntryToIpForwardRow(void *ip_forward_row, ROUTE_ENTRY *entry) } // Metric r->dwForwardMetric1 = entry->Metric; - - if (MsIsVista() == false) - { - r->dwForwardMetric2 = r->dwForwardMetric3 = r->dwForwardMetric4 = r->dwForwardMetric5 = INFINITE; - } - else - { - r->dwForwardMetric2 = r->dwForwardMetric3 = r->dwForwardMetric4 = r->dwForwardMetric5 = 0; - r->dwForwardAge = 163240; - } + r->dwForwardMetric2 = r->dwForwardMetric3 = r->dwForwardMetric4 = r->dwForwardMetric5 = 0; + r->dwForwardAge = 163240; // Interface ID r->dwForwardIfIndex = entry->InterfaceID; @@ -9746,144 +9691,11 @@ void Win32InitSocketLibrary() WSADATA data; Zero(&data, sizeof(data)); WSAStartup(MAKEWORD(2, 2), &data); - - // Load the DLL functions - w32net = ZeroMalloc(sizeof(NETWORK_WIN32_FUNCTIONS)); - w32net->hIpHlpApi32 = LoadLibrary("iphlpapi.dll"); - w32net->hIcmp = LoadLibrary("icmp.dll"); - - if (w32net->hIpHlpApi32 != NULL) - { - w32net->CreateIpForwardEntry = - (DWORD (__stdcall *)(PMIB_IPFORWARDROW)) - GetProcAddress(w32net->hIpHlpApi32, "CreateIpForwardEntry"); - - w32net->DeleteIpForwardEntry = - (DWORD (__stdcall *)(PMIB_IPFORWARDROW)) - GetProcAddress(w32net->hIpHlpApi32, "DeleteIpForwardEntry"); - - w32net->GetIfTable = - (DWORD (__stdcall *)(PMIB_IFTABLE, PULONG, BOOL)) - GetProcAddress(w32net->hIpHlpApi32, "GetIfTable"); - - w32net->GetIfTable2 = - (DWORD (__stdcall *)(void **)) - GetProcAddress(w32net->hIpHlpApi32, "GetIfTable2"); - - w32net->FreeMibTable = - (void (__stdcall *)(PVOID)) - GetProcAddress(w32net->hIpHlpApi32, "FreeMibTable"); - - w32net->GetIpForwardTable = - (DWORD (__stdcall *)(PMIB_IPFORWARDTABLE, PULONG, BOOL)) - GetProcAddress(w32net->hIpHlpApi32, "GetIpForwardTable"); - - w32net->GetNetworkParams = - (DWORD (__stdcall *)(PFIXED_INFO,PULONG)) - GetProcAddress(w32net->hIpHlpApi32, "GetNetworkParams"); - - w32net->GetAdaptersAddresses = - (ULONG (__stdcall *)(ULONG,ULONG,PVOID,PIP_ADAPTER_ADDRESSES,PULONG)) - GetProcAddress(w32net->hIpHlpApi32, "GetAdaptersAddresses"); - - w32net->IpRenewAddress = - (DWORD (__stdcall *)(PIP_ADAPTER_INDEX_MAP)) - GetProcAddress(w32net->hIpHlpApi32, "IpRenewAddress"); - - w32net->IpReleaseAddress = - (DWORD (__stdcall *)(PIP_ADAPTER_INDEX_MAP)) - GetProcAddress(w32net->hIpHlpApi32, "IpReleaseAddress"); - - w32net->GetInterfaceInfo = - (DWORD (__stdcall *)(PIP_INTERFACE_INFO, PULONG)) - GetProcAddress(w32net->hIpHlpApi32, "GetInterfaceInfo"); - - w32net->GetAdaptersInfo = - (DWORD (__stdcall *)(PIP_ADAPTER_INFO, PULONG)) - GetProcAddress(w32net->hIpHlpApi32, "GetAdaptersInfo"); - - w32net->GetExtendedTcpTable = - (DWORD (__stdcall *)(PVOID,PDWORD,BOOL,ULONG,_TCP_TABLE_CLASS,ULONG)) - GetProcAddress(w32net->hIpHlpApi32, "GetExtendedTcpTable"); - - w32net->AllocateAndGetTcpExTableFromStack = - (DWORD (__stdcall *)(PVOID *,BOOL,HANDLE,DWORD,DWORD)) - GetProcAddress(w32net->hIpHlpApi32, "AllocateAndGetTcpExTableFromStack"); - - w32net->GetTcpTable = - (DWORD (__stdcall *)(PMIB_TCPTABLE,PDWORD,BOOL)) - GetProcAddress(w32net->hIpHlpApi32, "GetTcpTable"); - - w32net->NotifyRouteChange = - (DWORD (__stdcall *)(PHANDLE,LPOVERLAPPED)) - GetProcAddress(w32net->hIpHlpApi32, "NotifyRouteChange"); - - w32net->CancelIPChangeNotify = - (BOOL (__stdcall *)(LPOVERLAPPED)) - GetProcAddress(w32net->hIpHlpApi32, "CancelIPChangeNotify"); - - w32net->NhpAllocateAndGetInterfaceInfoFromStack = - (DWORD (__stdcall *)(IP_INTERFACE_NAME_INFO **,PDWORD,BOOL,HANDLE,DWORD)) - GetProcAddress(w32net->hIpHlpApi32, "NhpAllocateAndGetInterfaceInfoFromStack"); - - w32net->IcmpCreateFile = - (HANDLE (__stdcall *)()) - GetProcAddress(w32net->hIpHlpApi32, "IcmpCreateFile"); - - w32net->IcmpCloseHandle = - (BOOL (__stdcall *)(HANDLE)) - GetProcAddress(w32net->hIpHlpApi32, "IcmpCloseHandle"); - - w32net->IcmpSendEcho = - (DWORD (__stdcall *)(HANDLE,IPAddr,LPVOID,WORD,PIP_OPTION_INFORMATION,LPVOID,DWORD,DWORD)) - GetProcAddress(w32net->hIpHlpApi32, "IcmpSendEcho"); - } - - if (w32net->hIcmp != NULL) - { - if (w32net->IcmpCreateFile == NULL || w32net->IcmpCloseHandle == NULL || w32net->IcmpSendEcho == NULL) - { - w32net->IcmpCreateFile = - (HANDLE (__stdcall *)()) - GetProcAddress(w32net->hIcmp, "IcmpCreateFile"); - - w32net->IcmpCloseHandle = - (BOOL (__stdcall *)(HANDLE)) - GetProcAddress(w32net->hIcmp, "IcmpCloseHandle"); - - w32net->IcmpSendEcho = - (DWORD (__stdcall *)(HANDLE,IPAddr,LPVOID,WORD,PIP_OPTION_INFORMATION,LPVOID,DWORD,DWORD)) - GetProcAddress(w32net->hIcmp, "IcmpSendEcho"); - } - } - - if (w32net->IcmpCreateFile == NULL || w32net->IcmpCloseHandle == NULL || w32net->IcmpSendEcho == NULL) - { - w32net->IcmpCreateFile = NULL; - w32net->IcmpCloseHandle = NULL; - w32net->IcmpSendEcho = NULL; - } } // Release of the socket library void Win32FreeSocketLibrary() { - if (w32net != NULL) - { - if (w32net->hIpHlpApi32 != NULL) - { - FreeLibrary(w32net->hIpHlpApi32); - } - - if (w32net->hIcmp != NULL) - { - FreeLibrary(w32net->hIcmp); - } - - Free(w32net); - w32net = NULL; - } - WSACleanup(); } @@ -10715,16 +10527,6 @@ ROUTE_ENTRY *GetBestRouteEntryFromRouteTableEx(ROUTE_TABLE *table, IP *ip, UINT dest = IPToUINT(&tmp->DestIP); gateway = IPToUINT(&tmp->GatewayIP); mask = IPToUINT(&tmp->DestMask); - if ((dest & mask) == (gateway & mask)) - { -#ifdef OS_WIN32 - if (MsIsVista() == false) - { - // Adjust for Windows - ret->PPPConnection = true; - } -#endif // OS_WIN32 - } } return ret; @@ -13277,14 +13079,6 @@ SOCK *ListenEx62(UINT port, bool local_only, bool enable_ca) return NULL; } -#ifdef OS_WIN32 - if (MsIsVista() == false) - { - // Disable the Conditional Accept due to a bug in Windows - enable_ca = false; - } -#endif // OS_WIN32 - // Initialization Zero(&addr, sizeof(addr)); Zero(&in, sizeof(in)); @@ -13323,17 +13117,13 @@ SOCK *ListenEx62(UINT port, bool local_only, bool enable_ca) return NULL; } -#ifdef OS_WIN32 +#ifdef OS_WIN32 if (enable_ca) { - if (MsIsWinXPOrGreater()) - { - setsockopt(s, SOL_SOCKET, SO_CONDITIONAL_ACCEPT, (char *)&true_flag, sizeof(bool)); - - backlog = 1; - } + setsockopt(s, SOL_SOCKET, SO_CONDITIONAL_ACCEPT, (char *)&true_flag, sizeof(bool)); + backlog = 1; } -#endif // OS_WIN32 +#endif if (listen(s, backlog)) { @@ -13382,14 +13172,6 @@ SOCK *ListenEx2(UINT port, bool local_only, bool enable_ca, IP *listen_ip) return NULL; } -#ifdef OS_WIN32 - if (MsIsVista() == false) - { - // Disable the Conditional Accept due to a bug in Windows - enable_ca = false; - } -#endif // OS_WIN32 - // Initialization Zero(&addr, sizeof(addr)); Zero(&in, sizeof(in)); @@ -13437,12 +13219,8 @@ SOCK *ListenEx2(UINT port, bool local_only, bool enable_ca, IP *listen_ip) #ifdef OS_WIN32 if (enable_ca) { - if (MsIsWinXPOrGreater()) - { - setsockopt(s, SOL_SOCKET, SO_CONDITIONAL_ACCEPT, (char *)&true_flag, sizeof(bool)); - - backlog = 1; - } + setsockopt(s, SOL_SOCKET, SO_CONDITIONAL_ACCEPT, (char *)&true_flag, sizeof(bool)); + backlog = 1; } #endif // OS_WIN32 @@ -13874,7 +13652,6 @@ int connect_timeout(SOCKET s, struct sockaddr *addr, int size, int timeout, bool UINT zero = 0; UINT tmp = 0; DWORD ret_size = 0; - bool is_nt = false; // Validate arguments if (s == INVALID_SOCKET || addr == NULL) { @@ -13885,8 +13662,6 @@ int connect_timeout(SOCKET s, struct sockaddr *addr, int size, int timeout, bool timeout = TIMEOUT_TCP_PORT_CHECK; } - is_nt = OS_IS_WINDOWS_NT(GetOsInfo()->OsType); - // Create an event hEvent = CreateEvent(NULL, FALSE, FALSE, NULL); @@ -13911,7 +13686,7 @@ int connect_timeout(SOCKET s, struct sockaddr *addr, int size, int timeout, bool int err = WSAGetLastError(); //Debug("err=%u\n", err); //Debug("cancel_flag=%u\n", *cancel_flag); - if (timeouted && ((err == WSAEALREADY) || (err == WSAEWOULDBLOCK && !is_nt))) + if (timeouted && err == WSAEALREADY) { // Time-out ok = false; @@ -13923,12 +13698,12 @@ int connect_timeout(SOCKET s, struct sockaddr *addr, int size, int timeout, bool ok = false; break; } - if (err == WSAEISCONN || (err == WSAEINVAL && is_nt)) + if (err == WSAEISCONN || err == WSAEINVAL) { ok = true; break; } - if (((start_time + (UINT64)timeout) <= Tick64()) || (err != WSAEWOULDBLOCK && err != WSAEALREADY && (is_nt || err != WSAEINVAL))) + if (((start_time + (UINT64)timeout) <= Tick64()) || (err != WSAEWOULDBLOCK && err != WSAEALREADY)) { // Failure (timeout) break; diff --git a/src/Mayaqua/Network.h b/src/Mayaqua/Network.h index bd4b535d..9c01bb51 100644 --- a/src/Mayaqua/Network.h +++ b/src/Mayaqua/Network.h @@ -976,7 +976,7 @@ void RUDPAddIpToValidateList(RUDP_STACK *r, IP *ip); bool GetBestLocalIpForTarget(IP *local_ip, IP *target_ip); SOCK *NewUDP4ForSpecificIp(IP *target_ip, UINT port); -#ifdef OS_WIN32 +#ifdef OS_WIN32 // Function prototype for Win32 void Win32InitSocketLibrary(); @@ -1004,7 +1004,6 @@ void Win32CleanupSockEvent(SOCK_EVENT *event); bool Win32WaitSockEvent(SOCK_EVENT *event, UINT timeout); bool Win32GetDefaultDns(IP *ip, char *domain, UINT size); bool Win32GetDnsSuffix(char *domain, UINT size); -void Win32RenewDhcp9x(UINT if_id); void Win32ReleaseDhcp9x(UINT if_id, bool wait); void Win32FlushDnsCache(); int CompareIpAdapterIndexMap(void *p1, void *p2); @@ -1403,7 +1402,6 @@ void InjectNewReverseSocketToAccept(SOCK *listen_sock, SOCK *s, IP *client_ip, U bool NewTcpPair(SOCK **s1, SOCK **s2); SOCK *ListenAnyPortEx2(bool local_only, bool disable_ca); -bool IsIcmpApiSupported(); ICMP_RESULT *IcmpApiEchoSend(IP *dest_ip, UCHAR ttl, UCHAR *data, UINT size, UINT timeout); void IcmpApiFreeResult(ICMP_RESULT *ret); diff --git a/src/Mayaqua/Table.c b/src/Mayaqua/Table.c index 084b04d7..294df20b 100644 --- a/src/Mayaqua/Table.c +++ b/src/Mayaqua/Table.c @@ -630,22 +630,6 @@ char *GetTableStr(char *name) return ""; } -#ifdef OS_WIN32 - if (StrCmpi(name, "DEFAULT_FONT") == 0) - { - if (_II("LANG") == 2) - { - UINT os_type = GetOsType(); - if (OS_IS_WINDOWS_9X(os_type) || - GET_KETA(os_type, 100) <= 4) - { - // Use the SimSun font in Windows 9x, Windows NT 4.0, Windows 2000, Windows XP, and Windows Server 2003 - return "SimSun"; - } - } - } -#endif // OS_WIN32 - // Search t = FindTable(name); if (t == NULL) diff --git a/src/Mayaqua/Win32.c b/src/Mayaqua/Win32.c index f60d1b87..797b0249 100644 --- a/src/Mayaqua/Win32.c +++ b/src/Mayaqua/Win32.c @@ -9,8 +9,8 @@ #ifdef WIN32 -#define _WIN32_WINNT 0x0502 -#define WINVER 0x0502 +#define _WIN32_WINNT 0x0600 +#define WINVER 0x0600 #include #include #include @@ -501,7 +501,7 @@ DIRLIST *Win32EnumDirExW(wchar_t *dirname, COMPARE *compare) CombinePathW(fullpath, sizeof(fullpath), dirname2, f->FileNameW); // Attempt to get the file information - if (MsIsNt()) + if (true) { HANDLE h = CreateFileW(fullpath, 0, FILE_SHARE_DELETE | FILE_SHARE_READ | FILE_SHARE_WRITE, @@ -913,7 +913,7 @@ void Win32GetOsInfo(OS_INFO *info) info->OsType = Win32GetOsType(); info->OsServicePack = os.wServicePackMajor; - if (OS_IS_WINDOWS_NT(info->OsType)) + if (true) { char *s; char *keyname = "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion"; @@ -951,19 +951,6 @@ void Win32GetOsInfo(OS_INFO *info) } info->KernelVersion = CopyStr(tmp); } - else - { - OSVERSIONINFO os; - Zero(&os, sizeof(os)); - os.dwOSVersionInfoSize = sizeof(os); - GetVersionEx(&os); - Format(tmp, sizeof(tmp), "Build %u %s", LOWORD(os.dwBuildNumber), os.szCSDVersion); - Trim(tmp); - info->OsVersion = CopyStr(tmp); - info->OsSystemName = CopyStr("Windows"); - info->KernelName = CopyStr("Windows 9x Kernel"); - info->KernelVersion = CopyStr(tmp); - } info->OsProductName = CopyStr(OsTypeToStr(info->OsType)); info->OsVendorName = CopyStr("Microsoft Corporation");