From 010ebe020c87eaef56ede12c9f9ef287dc6deaa4 Mon Sep 17 00:00:00 2001 From: Ilya Shipitsin Date: Wed, 30 May 2018 02:20:47 +0500 Subject: [PATCH] src/Mayaqua/Microsoft: remove unused functions (#543) [src/Mayaqua/Microsoft.c:8773]: (style) The function 'EnumAllWindow' is never used. [src/Mayaqua/Microsoft.c:1411]: (style) The function 'MsBufToRegSubkeys' is never used. [src/Mayaqua/Microsoft.c:5373]: (style) The function 'MsChangeIconOnTrayEx2' is never used. [src/Mayaqua/Microsoft.c:3426]: (style) The function 'MsCheckFileDigitalSignature' is never used. [src/Mayaqua/Microsoft.c:10764]: (style) The function 'MsCreateTempFile' is never used. [src/Mayaqua/Microsoft.c:10702]: (style) The function 'MsCreateTempFileByExt' is never used. [src/Mayaqua/Microsoft.c:1290]: (style) The function 'MsDeleteClipboard' is never used. [src/Mayaqua/Microsoft.c:12300]: (style) The function 'MsDetermineIsLockedByWtsApi' is never used. [src/Mayaqua/Microsoft.c:7296]: (style) The function 'MsEnableRemoteDesktop' is never used. [src/Mayaqua/Microsoft.c:2076]: (style) The function 'MsExecuteExW' is never used. [src/Mayaqua/Microsoft.c:2454]: (style) The function 'MsExtractCab' is never used. [src/Mayaqua/Microsoft.c:2383]: (style) The function 'MsExtractCabFromMsi' is never used. [src/Mayaqua/Microsoft.c:2549]: (style) The function 'MsExtractCabinetFileFromExe' is never used. [src/Mayaqua/Microsoft.c:2575]: (style) The function 'MsExtractCabinetFileFromExeW' is never used. [src/Mayaqua/Microsoft.c:1236]: (style) The function 'MsFreeEventLog' is never used. [src/Mayaqua/Microsoft.c:12450]: (style) The function 'MsFreeIsLocked' is never used. [src/Mayaqua/Microsoft.c:4101]: (style) The function 'MsFreeLibrary' is never used. [src/Mayaqua/Microsoft.c:2503]: (style) The function 'MsGetCabarcExeFilename' is never used. [src/Mayaqua/Microsoft.c:1300]: (style) The function 'MsGetClipboardOwnerProcessId' is never used. [src/Mayaqua/Microsoft.c:15237]: (style) The function 'MsGetCommonAppDataDir' is never used. [src/Mayaqua/Microsoft.c:15406]: (style) The function 'MsGetCommonAppDataDirW' is never used. [src/Mayaqua/Microsoft.c:15289]: (style) The function 'MsGetCommonDesktopDir' is never used. [src/Mayaqua/Microsoft.c:15281]: (style) The function 'MsGetCommonProgramsDir' is never used. [src/Mayaqua/Microsoft.c:15277]: (style) The function 'MsGetCommonStartMenuDir' is never used. [src/Mayaqua/Microsoft.c:3136]: (style) The function 'MsGetComputerNameFull' is never used. [src/Mayaqua/Microsoft.c:4984]: (style) The function 'MsGetCurrentProcessExeName' is never used. [src/Mayaqua/Microsoft.c:2763]: (style) The function 'MsGetFileVersionW' is never used. [src/Mayaqua/Microsoft.c:15241]: (style) The function 'MsGetLocalAppDataDir' is never used. [src/Mayaqua/Microsoft.c:15468]: (style) The function 'MsGetLocalAppDataDirW' is never used. [src/Mayaqua/Microsoft.c:8081]: (style) The function 'MsGetMs' is never used. [src/Mayaqua/Microsoft.c:15333]: (style) The function 'MsGetMyDocumentsDir' is never used. [src/Mayaqua/Microsoft.c:15459]: (style) The function 'MsGetMyDocumentsDirW' is never used. [src/Mayaqua/Microsoft.c:11583]: (style) The function 'MsGetNetCfgRegKeyName' is never used. [src/Mayaqua/Microsoft.c:15317]: (style) The function 'MsGetPersonalAppDataDir' is never used. [src/Mayaqua/Microsoft.c:15325]: (style) The function 'MsGetPersonalDesktopDir' is never used. [src/Mayaqua/Microsoft.c:15301]: (style) The function 'MsGetPersonalProgramsDir' is never used. [src/Mayaqua/Microsoft.c:15293]: (style) The function 'MsGetPersonalStartMenuDir' is never used. [src/Mayaqua/Microsoft.c:15309]: (style) The function 'MsGetPersonalStartupDir' is never used. [src/Mayaqua/Microsoft.c:1737]: (style) The function 'MsGetPhysicalMacAddress' is never used. [src/Mayaqua/Microsoft.c:4113]: (style) The function 'MsGetProcAddress' is never used. [src/Mayaqua/Microsoft.c:15382]: (style) The function 'MsGetProgramFilesDirW' is never used. [src/Mayaqua/Microsoft.c:15273]: (style) The function 'MsGetProgramFilesDirX64' is never used. [src/Mayaqua/Microsoft.c:15269]: (style) The function 'MsGetProgramFilesDirX86' is never used. [src/Mayaqua/Microsoft.c:15394]: (style) The function 'MsGetProgramFilesDirX86W' is never used. [src/Mayaqua/Microsoft.c:715]: (style) The function 'MsGetSystemLocaleId' is never used. [src/Mayaqua/Microsoft.c:15345]: (style) The function 'MsGetUserName' is never used. [src/Mayaqua/Microsoft.c:15349]: (style) The function 'MsGetUserNameEx' is never used. [src/Mayaqua/Microsoft.c:15480]: (style) The function 'MsGetUserNameExW' is never used. [src/Mayaqua/Microsoft.c:15353]: (style) The function 'MsGetWinTempDir' is never used. [src/Mayaqua/Microsoft.c:15484]: (style) The function 'MsGetWinTempDirW' is never used. [src/Mayaqua/Microsoft.c:15366]: (style) The function 'MsGetWindowDirW' is never used. [src/Mayaqua/Microsoft.c:9042]: (style) The function 'MsGetWindowOwnerProcessExeNameW' is never used. [src/Mayaqua/Microsoft.c:15261]: (style) The function 'MsGetWindowsDrive' is never used. [src/Mayaqua/Microsoft.c:15378]: (style) The function 'MsGetWindowsDriveW' is never used. [src/Mayaqua/Microsoft.c:1251]: (style) The function 'MsInitEventLog' is never used. [src/Mayaqua/Microsoft.c:7937]: (style) The function 'MsInstallService' is never used. [src/Mayaqua/Microsoft.c:7128]: (style) The function 'MsIsCurrentDesktopAvailableForVnc' is never used. [src/Mayaqua/Microsoft.c:2352]: (style) The function 'MsIsDirectoryW' is never used. [src/Mayaqua/Microsoft.c:1979]: (style) The function 'MsIsFileLockedW' is never used. [src/Mayaqua/Microsoft.c:1947]: (style) The function 'MsIsLocalDriveW' is never used. [src/Mayaqua/Microsoft.c:12241]: (style) The function 'MsIsPasswordEmpty' is never used. [src/Mayaqua/Microsoft.c:1587]: (style) The function 'MsIsProcessExists' is never used. [src/Mayaqua/Microsoft.c:1618]: (style) The function 'MsIsProcessExistsW' is never used. [src/Mayaqua/Microsoft.c:1581]: (style) The function 'MsIsProcessIdExists' is never used. [src/Mayaqua/Microsoft.c:7386]: (style) The function 'MsIsRemoteDesktopCanEnableByRegistry' is never used. [src/Mayaqua/Microsoft.c:7228]: (style) The function 'MsIsTerminalServiceMultiUserInstalled' is never used. [src/Mayaqua/Microsoft.c:5349]: (style) The function 'MsIsTrayInited' is never used. [src/Mayaqua/Microsoft.c:1707]: (style) The function 'MsIsUseWelcomeLogin' is never used. [src/Mayaqua/Microsoft.c:7407]: (style) The function 'MsIsWin2000' is never used. [src/Mayaqua/Microsoft.c:4017]: (style) The function 'MsLoadLibraryRawW' is never used. [src/Mayaqua/Microsoft.c:2220]: (style) The function 'MsMakeDirEx' is never used. [src/Mayaqua/Microsoft.c:12425]: (style) The function 'MsNewIsLocked' is never used. [src/Mayaqua/Microsoft.c:3112]: (style) The function 'MsNoSleepEnd' is never used. [src/Mayaqua/Microsoft.c:3079]: (style) The function 'MsNoSleepStart' is never used. [src/Mayaqua/Microsoft.c:5083]: (style) The function 'MsPrintProcessList' is never used. [src/Mayaqua/Microsoft.c:13117]: (style) The function 'MsRegAccessMaskFor64Bit' is never used. [src/Mayaqua/Microsoft.c:1382]: (style) The function 'MsRegDeleteSubkeys' is never used. [src/Mayaqua/Microsoft.c:14064]: (style) The function 'MsRegGetValueTypeAndSize' is never used. [src/Mayaqua/Microsoft.c:14109]: (style) The function 'MsRegGetValueTypeAndSizeW' is never used. [src/Mayaqua/Microsoft.c:14226]: (style) The function 'MsRegNewKey' is never used. [src/Mayaqua/Microsoft.c:13903]: (style) The function 'MsRegReadValue' is never used. [src/Mayaqua/Microsoft.c:13964]: (style) The function 'MsRegReadValueW' is never used. [src/Mayaqua/Microsoft.c:1472]: (style) The function 'MsRegSubkeysToBuf' is never used. [src/Mayaqua/Microsoft.c:13528]: (style) The function 'MsRegWriteValue' is never used. [src/Mayaqua/Microsoft.c:13566]: (style) The function 'MsRegWriteValueW' is never used. [src/Mayaqua/Microsoft.c:3205]: (style) The function 'MsRunAsUserEx' is never used. [src/Mayaqua/Microsoft.c:6401]: (style) The function 'MsScmDispatcher' is never used. [src/Mayaqua/Microsoft.c:2849]: (style) The function 'MsSetFileToHiddenW' is never used. [src/Mayaqua/Microsoft.c:8099]: (style) The function 'MsSetThreadPriorityLow' is never used. [src/Mayaqua/Microsoft.c:3511]: (style) The function 'MsSetWow64FileSystemRedirectionEnable' is never used. [src/Mayaqua/Microsoft.c:12469]: (style) The function 'MsShutdownEx' is never used. [src/Mayaqua/Microsoft.c:5740]: (style) The function 'MsStopUserModeFromService' is never used. [src/Mayaqua/Microsoft.c:2260]: (style) The function 'MsUniDirectoryDelete' is never used. [src/Mayaqua/Microsoft.c:2290]: (style) The function 'MsUniFileDelete' is never used. [src/Mayaqua/Microsoft.c:6053]: (style) The function 'MsUserMode' is never used. [src/Mayaqua/Microsoft.c:1200]: (style) The function 'MsWriteEventLog' is never used. [src/Mayaqua/Microsoft.c:7684]: (style) The function 'EnumAllWindowEx' is never used. [src/Mayaqua/Microsoft.c:9587]: (style) The function 'MsCreateTempFileNameByExt' is never used. [src/Mayaqua/Microsoft.c:1794]: (style) The function 'MsDirectoryDelete' is never used. [src/Mayaqua/Microsoft.c:1876]: (style) The function 'MsExtractCabFromMsiW' is never used. [src/Mayaqua/Microsoft.c:1937]: (style) The function 'MsExtractCabW' is never used. [src/Mayaqua/Microsoft.c:2047]: (style) The function 'MsExtractResourceFromExeW' is never used. [src/Mayaqua/Microsoft.c:1806]: (style) The function 'MsFileDelete' is never used. [src/Mayaqua/Microsoft.c:13842]: (style) The function 'MsGetCommonAppDataDir' is never used. [src/Mayaqua/Microsoft.c:2105]: (style) The function 'MsGetFileVersion' is never used. [src/Mayaqua/Microsoft.c:1344]: (style) The function 'MsGetPhysicalMacAddressFromApi' is never used. [src/Mayaqua/Microsoft.c:1415]: (style) The function 'MsGetPhysicalMacAddressFromNetbios' is never used. [src/Mayaqua/Microsoft.c:7975]: (style) The function 'MsGetProcessExeNameW' is never used. [src/Mayaqua/Microsoft.c:1253]: (style) The function 'MsGetProcessNameFromId' is never used. [src/Mayaqua/Microsoft.c:1534]: (style) The function 'MsIsFileLocked' is never used. [src/Mayaqua/Microsoft.c:1495]: (style) The function 'MsIsLocalDrive' is never used. [src/Mayaqua/Microsoft.c:11079]: (style) The function 'MsIsLockedThreadProc' is never used. [src/Mayaqua/Microsoft.c:6314]: (style) The function 'MsIsRemoteDesktopEnabled' is never used. [src/Mayaqua/Microsoft.c:2184]: (style) The function 'MsNoSleepThread' is never used. [src/Mayaqua/Microsoft.c:2224]: (style) The function 'MsNoSleepThreadVista' is never used. [src/Mayaqua/Microsoft.c:12681]: (style) The function 'MsRegGetValueTypeAndSizeEx' is never used. [src/Mayaqua/Microsoft.c:12722]: (style) The function 'MsRegGetValueTypeAndSizeExW' is never used. [src/Mayaqua/Microsoft.c:12835]: (style) The function 'MsRegNewKeyEx' is never used. [src/Mayaqua/Microsoft.c:12528]: (style) The function 'MsRegReadValueEx' is never used. [src/Mayaqua/Microsoft.c:12585]: (style) The function 'MsRegReadValueExW' is never used. [src/Mayaqua/Microsoft.c:12161]: (style) The function 'MsRegWriteValueEx' is never used. [src/Mayaqua/Microsoft.c:12195]: (style) The function 'MsRegWriteValueExW' is never used. [src/Mayaqua/Microsoft.c:2460]: (style) The function 'MsRunAsUserExInner' is never used. [src/Mayaqua/Microsoft.c:2162]: (style) The function 'MsSetFileToHidden' is never used. [src/Mayaqua/Microsoft.c:1818]: (style) The function 'MsUniIsDirectory' is never used. [src/Mayaqua/Microsoft.c:8771]: (style) The function 'MsCreateTempFileName' is never used. [src/Mayaqua/Microsoft.c:1619]: (style) The function 'MsExtractResourceFromExe' is never used. [src/Mayaqua/Microsoft.c:1595]: (style) The function 'MsGetCabarcExeFilenameW' is never used. [src/Mayaqua/Microsoft.c:1568]: (style) The function 'MsIsDirectory' is never used. [src/Mayaqua/Microsoft.c:10153]: (style) The function 'MsIsLockedWindowHandlerWindowProc' is never used. [src/Mayaqua/Microsoft.c:5621]: (style) The function 'MsIsRemoteDesktopAvailable' is never used. [src/Mayaqua/Microsoft.c:11787]: (style) The function 'MsRegGetValueTypeAndSizeEx2W' is never used. [src/Mayaqua/Microsoft.c:11502]: (style) The function 'MsRegGetValueTypeAndSizeEx2' is never used. --- src/Mayaqua/Microsoft.c | 2825 --------------------------------------- src/Mayaqua/Microsoft.h | 134 -- 2 files changed, 2959 deletions(-) diff --git a/src/Mayaqua/Microsoft.c b/src/Mayaqua/Microsoft.c index c557016c..d2eb611c 100644 --- a/src/Mayaqua/Microsoft.c +++ b/src/Mayaqua/Microsoft.c @@ -711,19 +711,6 @@ UINT MsGetUserLocaleId() return lcid_cache; } -// Get the locale ID of the system -UINT MsGetSystemLocaleId() -{ - static UINT lcid_cache = 0; - - if (lcid_cache == 0) - { - lcid_cache = (UINT)GetSystemDefaultLCID(); - } - - return lcid_cache; -} - // Set a secure ACL to the specified file or directory bool MsSetFileSecureAcl(wchar_t *path) { @@ -1196,122 +1183,6 @@ bool MsIsWinXPOrWinVista() return false; } -// Write to the event log -bool MsWriteEventLog(void *p, UINT type, wchar_t *str) -{ - MS_EVENTLOG *g = (MS_EVENTLOG *)p; - wchar_t *strings[2]; - UINT id = 0; - UINT typeapi = 0; - // Validate arguments - if (g == NULL || type >= 5 || str == NULL) - { - return false; - } - - strings[0] = str; - - switch (type) - { - case MS_EVENTLOG_TYPE_INFORMATION: - id = MS_RC_EVENTLOG_TYPE_INFORMATION; - typeapi = EVENTLOG_INFORMATION_TYPE; - break; - - case MS_EVENTLOG_TYPE_WARNING: - id = MS_RC_EVENTLOG_TYPE_WARNING; - typeapi = EVENTLOG_WARNING_TYPE; - break; - - case MS_EVENTLOG_TYPE_ERROR: - id = MS_RC_EVENTLOG_TYPE_ERROR; - typeapi = EVENTLOG_ERROR_TYPE; - break; - } - - return ms->nt->ReportEventW(g->hEventLog, typeapi, 0, id, NULL, 1, 0, strings, NULL); -} - -// Release of the event log -void MsFreeEventLog(void *p) -{ - MS_EVENTLOG *g = (MS_EVENTLOG *)p; - // Validate arguments - if (g == NULL) - { - return; - } - - ms->nt->DeregisterEventSource(g->hEventLog); - - Free(g); -} - -// Initialization of the event log -void *MsInitEventLog(wchar_t *src_name) -{ - MS_EVENTLOG *g; - HANDLE h; - wchar_t keyname[MAX_PATH]; - char keyname_a[MAX_PATH]; - wchar_t *exename; - // Validate arguments - if (src_name == NULL) - { - return NULL; - } - - // Write the key to the registry - exename = MsGetExeFileNameW(); - UniFormat(keyname, sizeof(keyname), - L"SYSTEM\\CurrentControlSet\\Services\\Eventlog\\Application\\%s", - src_name); - UniToStr(keyname_a, sizeof(keyname_a), keyname); - - MsRegWriteStrExpandExW(REG_LOCAL_MACHINE, keyname_a, "EventMessageFile", - exename, false); - - MsRegWriteIntEx(REG_LOCAL_MACHINE, keyname_a, "TypesSupported", 7, false); - - h = ms->nt->RegisterEventSourceW(NULL, src_name); - if (h == NULL) - { - return NULL; - } - - g = ZeroMalloc(sizeof(MS_EVENTLOG)); - - g->hEventLog = h; - - return (void *)g; -} - -// Empty the clipboard -void MsDeleteClipboard() -{ - OpenClipboard(NULL); - - EmptyClipboard(); - - CloseClipboard(); -} - -// Get the process ID of the clipboard owner -UINT MsGetClipboardOwnerProcessId() -{ - HWND hWnd = GetClipboardOwner(); - DWORD pid = 0; - - if (hWnd == NULL) - { - return 0; - } - - GetWindowThreadProcessId(hWnd, &pid); - - return pid; -} - // Restart of MMCSS void MsRestartMMCSS() { @@ -1378,275 +1249,6 @@ bool MsIsMMCSSNetworkThrottlingEnabled() return false; } -// Delete all the subkeys -void MsRegDeleteSubkeys(UINT root, char *keyname, bool force32bit, bool force64bit) -{ - TOKEN_LIST *t; - UINT i; - // Validate arguments - if (keyname == NULL) - { - return; - } - - t = MsRegEnumKeyEx2(root, keyname, force32bit, force64bit); - if (t == NULL) - { - return; - } - - for (i = 0;i < t->NumTokens;i++) - { - char tmp[MAX_PATH]; - - Format(tmp, sizeof(tmp), "%s\\%s", keyname, t->Token[i]); - - MsRegDeleteKeyEx2(root, tmp, force32bit, force64bit); - } - - FreeToken(t); -} - -// Convert the data in the buffer to the subkey of the registry -void MsBufToRegSubkeys(UINT root, char *keyname, BUF *b, bool overwrite, bool force32bit, bool force64bit) -{ - UINT i; - UINT a; - UINT num_keys; - // Validate arguments - if (keyname == NULL || b == NULL) - { - return; - } - - SeekBuf(b, 0, 0); - - num_keys = ReadBufInt(b); - - for (i = 0;i < num_keys;i++) - { - char subkeyname[MAX_PATH]; - char fullkeyname[MAX_PATH]; - UINT j; - UINT num_values; - - Zero(subkeyname, sizeof(subkeyname)); - ReadBufStr(b, subkeyname, sizeof(subkeyname)); - - Format(fullkeyname, sizeof(fullkeyname), "%s\\%s", keyname, subkeyname); - - num_values = ReadBufInt(b); - - for (j = 0;j < num_values;j++) - { - char valuename[MAX_PATH]; - char data[MAX_SIZE]; - - Zero(valuename, sizeof(valuename)); - ReadBufStr(b, valuename, sizeof(valuename)); - - a = ReadBufInt(b); - - if (a == 0) - { - Zero(data, sizeof(data)); - ReadBufStr(b, data, sizeof(data)); - - if (overwrite || MsRegIsValueEx2(root, fullkeyname, valuename, force32bit, force64bit) == false) - { - MsRegWriteStrEx2(root, fullkeyname, valuename, data, force32bit, force64bit); - } - } - else - { - if (overwrite || MsRegIsValueEx2(root, fullkeyname, valuename, force32bit, force64bit) == false) - { - MsRegWriteIntEx2(root, fullkeyname, valuename, ReadBufInt(b), force32bit, force64bit); - } - } - } - } -} - -// Convert data in the registry subkey to the buffer -BUF *MsRegSubkeysToBuf(UINT root, char *keyname, bool force32bit, bool force64bit) -{ - TOKEN_LIST *t; - UINT i; - BUF *b; - // Validate arguments - if (keyname == NULL) - { - return NULL; - } - - t = MsRegEnumKeyEx2(root, keyname, force32bit, force64bit); - - if (t == NULL) - { - return NULL; - } - - b = NewBuf(); - - WriteBufInt(b, t->NumTokens); - - for (i = 0;i < t->NumTokens;i++) - { - char *name = t->Token[i]; - char tmp[MAX_PATH]; - TOKEN_LIST *v; - - Format(tmp, sizeof(tmp), "%s\\%s", keyname, name); - - WriteBufStr(b, name); - - v = MsRegEnumValueEx2(root, tmp, force32bit, force64bit); - if (v == NULL) - { - WriteBufInt(b, 0); - } - else - { - UINT j; - - WriteBufInt(b, v->NumTokens); - - for (j = 0;j < v->NumTokens;j++) - { - char *valuename = v->Token[j]; - char *str; - - WriteBufStr(b, valuename); - - str = MsRegReadStrEx2(root, tmp, valuename, force32bit, force64bit); - if (str != NULL) - { - WriteBufInt(b, 0); - WriteBufStr(b, str); - Free(str); - } - else - { - WriteBufInt(b, 1); - WriteBufInt(b, MsRegReadIntEx2(root, tmp, valuename, force32bit, force64bit)); - } - } - - FreeToken(v); - } - } - - FreeToken(t); - - return b; -} - -// Get the process name of the specified process ID -bool MsGetProcessNameFromId(wchar_t *exename, UINT exename_size, UINT pid) -{ - LIST *o; - bool ret = false; - UINT i; - // Validate arguments - if (pid == 0) - { - return false; - } - - o = MsGetProcessList(); - - for (i = 0;i < LIST_NUM(o);i++) - { - MS_PROCESS *proc = LIST_DATA(o, i); - - if (proc->ProcessId == pid) - { - if (exename != NULL) - { - UniStrCpy(exename, exename_size, proc->ExeFilenameW); - } - - ret = true; - break; - } - } - - MsFreeProcessList(o); - - return ret; -} - -// Check whether the specified process ID exists -bool MsIsProcessIdExists(UINT pid) -{ - return MsGetProcessNameFromId(NULL, 0, pid); -} - -// Check whether the process of specified EXE file name exists -bool MsIsProcessExists(char *exename) -{ - LIST *o; - bool ret = false; - UINT i; - // Validate arguments - if (exename == NULL) - { - return false; - } - - o = MsGetProcessList(); - - for (i = 0;i < LIST_NUM(o);i++) - { - MS_PROCESS *proc = LIST_DATA(o, i); - char exe[MAX_PATH]; - - GetFileNameFromFilePath(exe, sizeof(exe), proc->ExeFilename); - - if (StrCmpi(exename, exe) == 0) - { - ret = true; - break; - } - } - - MsFreeProcessList(o); - - return ret; -} -bool MsIsProcessExistsW(wchar_t *exename) -{ - LIST *o; - bool ret = false; - UINT i; - // Validate arguments - if (exename == NULL) - { - return false; - } - - o = MsGetProcessList(); - - for (i = 0;i < LIST_NUM(o);i++) - { - MS_PROCESS *proc = LIST_DATA(o, i); - wchar_t exe[MAX_PATH]; - - GetFileNameFromFilePathW(exe, sizeof(exe), proc->ExeFilenameW); - - if (UniStrCmpi(exename, exe) == 0) - { - ret = true; - break; - } - } - - MsFreeProcessList(o); - - return ret; -} - typedef struct _ASTAT_ { ADAPTER_STATUS adapt; @@ -1703,186 +1305,6 @@ UINT64 MsGetHiResCounter() return ret; } -// Whether the Welcome screen is used -bool MsIsUseWelcomeLogin() -{ - UINT os_type; - if (MsIsNt() == false) - { - return false; - } - - os_type = GetOsInfo()->OsType; - - if (OS_IS_WINDOWS_NT(os_type)) - { - if (GET_KETA(os_type, 100) == 3) - { - if (MsRegReadIntEx2(REG_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon", - "LogonType", false, true) == 0) - { - return false; - } - else - { - return true; - } - } - } - - return false; -} - -// Get a physical MAC address of the computer -bool MsGetPhysicalMacAddress(void *address) -{ - // Validate arguments - if (address == NULL) - { - return false; - } - - if (MsGetPhysicalMacAddressFromApi(address)) - { - return true; - } - - if (MsGetPhysicalMacAddressFromNetbios(address)) - { - return true; - } - - return false; -} - -// Get the physical MAC address (from API) -bool MsGetPhysicalMacAddressFromApi(void *address) -{ - MS_ADAPTER_LIST *o; - UINT i; - bool ret = false; - // Validate arguments - if (address == NULL) - { - return false; - } - - Zero(address, 6); - - o = MsCreateAdapterList(); - - for (i = 0;i < o->Num;i++) - { - MS_ADAPTER *a = o->Adapters[i]; - - if (a->AddressSize == 6 && a->Mtu == 1500) - { - bool b = false; - switch (a->Type) - { - case MIB_IF_TYPE_OTHER: - case MIB_IF_TYPE_ETHERNET: - b = true; - break; - - case MIB_IF_TYPE_TOKENRING: - case MIB_IF_TYPE_FDDI: - case MIB_IF_TYPE_PPP: - case MIB_IF_TYPE_LOOPBACK: - case MIB_IF_TYPE_SLIP: - b = false; - break; - - default: - b = true; - break; - } - - if (b) - { - if (SearchStrEx(a->Title, "WAN", 0, false) == INFINITE) - { - if (a->Status == MIB_IF_OPER_STATUS_CONNECTED || a->Status == MIB_IF_OPER_STATUS_OPERATIONAL) - { - if (a->AddressSize == 6) - { - if (IsZero(a->Address, 6) == false) - { - if (Cmp(address, a->Address, 6) <= 0) - { - Copy(address, a->Address, 6); - ret = true; - } - } - } - } - } - } - } - } - - MsFreeAdapterList(o); - - return ret; -} - -// Get the physical MAC address (from NetBIOS) -bool MsGetPhysicalMacAddressFromNetbios(void *address) -{ - NCB ncb; - UCHAR ret; - LANA_ENUM lenum; - UINT i; - ASTAT adapter; - bool b = false; - // Validate arguments - if (address == NULL) - { - return false; - } - - Zero(&ncb, sizeof(ncb)); - Zero(&lenum, sizeof(lenum)); - - ncb.ncb_command = NCBENUM; - ncb.ncb_buffer = (UCHAR *)&lenum; - ncb.ncb_length = sizeof(lenum); - ret = Netbios(&ncb); - - Zero(address, 6); - - for (i = 0;i < lenum.length;i++) - { - Zero(&ncb, sizeof(ncb)); - ncb.ncb_command = NCBRESET; - ncb.ncb_lana_num = lenum.lana[i]; - - ret = Netbios(&ncb); - - Zero(&ncb, sizeof(ncb)); - ncb.ncb_command = NCBASTAT; - ncb.ncb_lana_num = lenum.lana[i]; - - StrCpy(ncb.ncb_callname, sizeof(ncb.ncb_callname), "* "); - Zero(&adapter, sizeof(adapter)); - ncb.ncb_buffer = (char *)&adapter; - ncb.ncb_length = sizeof(adapter); - - ret = Netbios(&ncb); - - if (ret == 0) - { - if (Cmp(address, adapter.adapt.adapter_address, 6) <= 0) - { - Copy(address, adapter.adapt.adapter_address, 6); - b = true; - } - } - } - - return b; -} - // System-wide updating notification void MsUpdateSystem() { @@ -1906,108 +1328,6 @@ void MsUpdateSystem() SleepThread(25); } -// Get whether the specified path points to a local drive -bool MsIsLocalDrive(char *name) -{ - char tmp[MAX_PATH]; - UINT ret; - - // Validate arguments - if (name == NULL) - { - return false; - } - - Zero(tmp, sizeof(tmp)); - InnerFilePath(tmp, sizeof(tmp), name); - - if (StartWith(tmp, "\\\\")) - { - // Network directory - return false; - } - - if (tmp[1] != ':' || tmp[2] != '\\') - { - // Not a drive letter - return false; - } - - tmp[3] = 0; - - ret = GetDriveType(tmp); - - if (ret == DRIVE_REMOTE || ret == DRIVE_CDROM || ret == DRIVE_RAMDISK) - { - return false; - } - - return true; -} -bool MsIsLocalDriveW(wchar_t *name) -{ - char name_a[MAX_PATH]; - - UniToStr(name_a, sizeof(name_a), name); - - return MsIsLocalDrive(name_a); -} - -// Get whether the specified file is locked -bool MsIsFileLocked(char *name) -{ - HANDLE h; - char tmp[MAX_PATH]; - // Validate arguments - if (name == NULL) - { - return false; - } - - InnerFilePath(tmp, sizeof(tmp), name); - - h = CreateFile(tmp, GENERIC_READ | GENERIC_WRITE, 0, 0, OPEN_EXISTING, 0, NULL); - if (h == INVALID_HANDLE_VALUE) - { - return true; - } - - CloseHandle(h); - - return false; -} -bool MsIsFileLockedW(wchar_t *name) -{ - HANDLE h; - wchar_t tmp[MAX_PATH]; - // Validate arguments - if (name == NULL) - { - return false; - } - - if (IsNt() == false) - { - char name_a[MAX_SIZE]; - - UniToStr(name_a, sizeof(name_a), name); - - return MsIsFileLocked(name_a); - } - - InnerFilePathW(tmp, sizeof(tmp), name); - - h = CreateFileW(tmp, GENERIC_READ | GENERIC_WRITE, 0, 0, OPEN_EXISTING, 0, NULL); - if (h == INVALID_HANDLE_VALUE) - { - return true; - } - - CloseHandle(h); - - return false; -} - // Wait for the process termination UINT MsWaitProcessExit(void *process_handle) { @@ -2073,10 +1393,6 @@ bool MsExecuteEx2(char *exe, char *arg, void **process_handle, bool runas) return true; } -bool MsExecuteExW(wchar_t *exe, wchar_t *arg, void **process_handle) -{ - return MsExecuteEx2W(exe, arg, process_handle, false); -} bool MsExecuteEx2W(wchar_t *exe, wchar_t *arg, void **process_handle, bool runas) { SHELLEXECUTEINFOW info; @@ -2217,14 +1533,6 @@ void MsUniMakeDirEx(wchar_t *name) MsUniMakeDir(name); } -void MsMakeDirEx(char *name) -{ - wchar_t *name_w = CopyStrToUni(name); - - MsUniMakeDirEx(name_w); - - Free(name_w); -} // Create a directory bool MsUniMakeDir(wchar_t *name) @@ -2256,887 +1564,9 @@ bool MsMakeDir(char *name) return CreateDirectoryA(name, NULL); } -// Delete the directory -bool MsUniDirectoryDelete(wchar_t *name) -{ - // Validate arguments - if (name == NULL) - { - return false; - } - - if (MsIsNt() == false) - { - char *s = CopyUniToStr(name); - bool ret = MsDirectoryDelete(s); - Free(s); - return ret; - } - - return RemoveDirectoryW(name); -} -bool MsDirectoryDelete(char *name) -{ - // Validate arguments - if (name == NULL) - { - return false; - } - - return RemoveDirectoryA(name); -} - -// Delete the File -bool MsUniFileDelete(wchar_t *name) -{ - // Validate arguments - if (name == NULL) - { - return false; - } - - if (MsIsNt() == false) - { - bool ret; - char *s = CopyUniToStr(name); - ret = MsFileDelete(s); - Free(s); - return ret; - } - - return DeleteFileW(name); -} -bool MsFileDelete(char *name) -{ - // Validate arguments - if (name == NULL) - { - return false; - } - - return DeleteFileA(name); -} - -// Get whether the specified file name is a directory -bool MsUniIsDirectory(wchar_t *name) -{ - DWORD ret; - // Validate arguments - if (name == NULL) - { - return false; - } - - if (MsIsNt() == false) - { - char *s = CopyUniToStr(name); - ret = MsIsDirectory(s); - Free(s); - - return ret; - } - - ret = GetFileAttributesW(name); - if (ret == 0xffffffff) - { - return false; - } - - if (ret & FILE_ATTRIBUTE_DIRECTORY) - { - return true; - } - - return false; -} -bool MsIsDirectoryW(wchar_t *name) -{ - return MsUniIsDirectory(name); -} -bool MsIsDirectory(char *name) -{ - DWORD ret; - char tmp[MAX_PATH]; - // Validate arguments - if (name == NULL) - { - return false; - } - - InnerFilePath(tmp, sizeof(tmp), name); - - ret = GetFileAttributesA(tmp); - if (ret == 0xffffffff) - { - return false; - } - - if (ret & FILE_ATTRIBUTE_DIRECTORY) - { - return true; - } - - return false; -} - -// Extract the Cabinet from the MSI file -bool MsExtractCabFromMsi(char *msi, char *cab) -{ - wchar_t msi_w[MAX_PATH]; - wchar_t cab_w[MAX_PATH]; - - StrToUni(msi_w, sizeof(msi_w), msi); - StrToUni(cab_w, sizeof(cab_w), cab); - - return MsExtractCabFromMsiW(msi_w, cab_w); -} -bool MsExtractCabFromMsiW(wchar_t *msi, wchar_t *cab) -{ - BUF *b; - bool ret = false; - UINT i; - char sign[] = {'M', 'S', 'C', 'F', 0, 0, 0, 0,}; - void *pointer = NULL; - UINT current_pos = 0; - UINT sign_size; - // Validate arguments - if (msi == NULL || cab == NULL) - { - return false; - } - - // Read the MSI - b = ReadDumpW(msi); - if (b == NULL) - { - return false; - } - - if (b->Size < 128) - { - FreeBuf(b); - return false; - } - - sign_size = sizeof(sign); - - // Search for "MSCF" - for (i = 0;i < (b->Size - sign_size);i++) - { - char *p = ((UCHAR *)b->Buf) + i; - - if (Cmp(p, sign, sign_size) == 0) - { - pointer = p; - current_pos = i; - } - } - - if (pointer != NULL) - { - UINT size = b->Size - current_pos; - BUF *b2 = NewBuf(); - - WriteBuf(b2, pointer, size); - - ret = DumpBufW(b2, cab); - - FreeBuf(b2); - - } - - FreeBuf(b); - - return ret; -} - -// Retrieve a file from Cabinet file -bool MsExtractCab(char *cab_name, char *dest_dir_name) -{ - wchar_t cab_name_w[MAX_SIZE]; - wchar_t dest_dir_name_w[MAX_SIZE]; - - StrToUni(cab_name_w, sizeof(cab_name_w), cab_name); - StrToUni(dest_dir_name_w, sizeof(dest_dir_name_w), dest_dir_name); - - return MsExtractCabW(cab_name_w, dest_dir_name_w); -} -bool MsExtractCabW(wchar_t *cab_name, wchar_t *dest_dir_name) -{ - wchar_t cabarc[MAX_PATH]; - wchar_t arg[MAX_PATH * 2]; - wchar_t tmp[MAX_PATH]; - - // Validate arguments - if (cab_name == NULL || dest_dir_name == NULL) - { - return false; - } - - if (MsGetCabarcExeFilenameW(cabarc, sizeof(cabarc)) == false) - { - return false; - } - - UniStrCpy(tmp, sizeof(tmp), dest_dir_name); - if (UniEndWith(tmp, L"\\")) - { - tmp[UniStrLen(tmp) - 1] = 0; - } - - UniFormat(arg, sizeof(arg), - L"-o X \"%s\" * \"%s\"\\", - cab_name, - tmp); - - MakeDirW(dest_dir_name); - - if (RunW(cabarc, arg, true, true) == false) - { - return false; - } - - return true; -} - -// Extract of cabarc.exe -bool MsGetCabarcExeFilename(char *name, UINT size) -{ - // Validate arguments - if (name == NULL) - { - return false; - } - - ConbinePath(name, size, MsGetMyTempDir(), "cabarc.exe"); - - if (IsFileExists(name)) - { - return true; - } - - if (FileCopy("|cabarc.exe", name) == false) - { - return false; - } - - return true; -} -bool MsGetCabarcExeFilenameW(wchar_t *name, UINT size) -{ - // Validate arguments - if (name == NULL) - { - return false; - } - - ConbinePathW(name, size, MsGetMyTempDirW(), L"cabarc.exe"); - - if (IsFileExistsW(name)) - { - return true; - } - - if (FileCopyW(L"|cabarc.exe", name) == false) - { - return false; - } - - return true; -} - -// Extract the Cabinet file from EXE file -bool MsExtractCabinetFileFromExe(char *exe, char *cab) -{ - BUF *b; - // Validate arguments - if (exe == NULL || cab == NULL) - { - return false; - } - - b = MsExtractResourceFromExe(exe, RT_RCDATA, "CABINET"); - if (b == NULL) - { - return false; - } - - if (DumpBuf(b, cab) == false) - { - FreeBuf(b); - - return false; - } - - FreeBuf(b); - - return true; -} -bool MsExtractCabinetFileFromExeW(wchar_t *exe, wchar_t *cab) -{ - BUF *b; - // Validate arguments - if (exe == NULL || cab == NULL) - { - return false; - } - - b = MsExtractResourceFromExeW(exe, RT_RCDATA, "CABINET"); - if (b == NULL) - { - return false; - } - - if (DumpBufW(b, cab) == false) - { - FreeBuf(b); - - return false; - } - - FreeBuf(b); - - return true; -} - -// Extract the resource from EXE file -BUF *MsExtractResourceFromExe(char *exe, char *type, char *name) -{ - HINSTANCE h; - HRSRC hr; - HGLOBAL hg; - UINT size; - void *data; - BUF *buf; - // Validate arguments - if (exe == NULL || type == NULL || name == NULL) - { - return NULL; - } - - h = LoadLibraryExA(exe, NULL, LOAD_LIBRARY_AS_DATAFILE); - if (h == NULL) - { - return NULL; - } - - hr = FindResourceA(h, name, type); - if (hr == NULL) - { - FreeLibrary(h); - return NULL; - } - - hg = LoadResource(h, hr); - if (hg == NULL) - { - FreeLibrary(h); - return NULL; - } - - size = SizeofResource(h, hr); - data = (void *)LockResource(hg); - - buf = NewBuf(); - WriteBuf(buf, data, size); - - FreeResource(hg); - FreeLibrary(h); - - SeekBuf(buf, 0, 0); - - return buf; -} -BUF *MsExtractResourceFromExeW(wchar_t *exe, char *type, char *name) -{ - HINSTANCE h; - HRSRC hr; - HGLOBAL hg; - UINT size; - void *data; - BUF *buf; - // Validate arguments - if (exe == NULL || type == NULL || name == NULL) - { - return NULL; - } - - if (IsNt() == false) - { - char exe_a[MAX_PATH]; - - UniToStr(exe_a, sizeof(exe_a), exe); - - return MsExtractResourceFromExe(exe_a, type, name); - } - - h = LoadLibraryExW(exe, NULL, LOAD_LIBRARY_AS_DATAFILE); - if (h == NULL) - { - return NULL; - } - - hr = FindResource(h, name, type); - if (hr == NULL) - { - FreeLibrary(h); - return NULL; - } - - hg = LoadResource(h, hr); - if (hg == NULL) - { - FreeLibrary(h); - return NULL; - } - - size = SizeofResource(h, hr); - data = (void *)LockResource(hg); - - buf = NewBuf(); - WriteBuf(buf, data, size); - - FreeResource(hg); - FreeLibrary(h); - - SeekBuf(buf, 0, 0); - - return buf; -} - -// Get the version information of the file -bool MsGetFileVersion(char *name, UINT *v1, UINT *v2, UINT *v3, UINT *v4) -{ - void *data; - UINT size; - DWORD h; - bool ret = false; - // Validate arguments - if (name == NULL) - { - return false; - } - - h = 0; - size = GetFileVersionInfoSize(name, &h); - if (size == 0) - { - return false; - } - - data = ZeroMalloc(size); - - if (GetFileVersionInfoA(name, 0, size, data)) - { - VS_FIXEDFILEINFO *info = NULL; - UINT info_size = 0; - if (VerQueryValueA(data, "\\", &info, &info_size)) - { - if (v1 != NULL) - { - *v1 = HIWORD(info->dwFileVersionMS); - } - - if (v2 != NULL) - { - *v2 = LOWORD(info->dwFileVersionMS); - } - - if (v3 != NULL) - { - *v3 = HIWORD(info->dwFileVersionLS); - } - - if (v4 != NULL) - { - *v4 = LOWORD(info->dwFileVersionLS); - } - - ret = true; - } - } - - Free(data); - - return ret; -} -bool MsGetFileVersionW(wchar_t *name, UINT *v1, UINT *v2, UINT *v3, UINT *v4) -{ - void *data; - UINT size; - DWORD h; - bool ret = false; - // Validate arguments - if (name == NULL) - { - return false; - } - - if (IsNt() == false) - { - char name_a[MAX_PATH]; - - UniToStr(name_a, sizeof(name_a), name); - - return MsGetFileVersion(name_a, v1, v2, v3, v4); - } - - h = 0; - size = GetFileVersionInfoSizeW(name, &h); - if (size == 0) - { - return false; - } - - data = ZeroMalloc(size); - - if (GetFileVersionInfoW(name, 0, size, data)) - { - VS_FIXEDFILEINFO *info = NULL; - UINT info_size = 0; - if (VerQueryValue(data, "\\", &info, &info_size)) - { - if (v1 != NULL) - { - *v1 = HIWORD(info->dwFileVersionMS); - } - - if (v2 != NULL) - { - *v2 = LOWORD(info->dwFileVersionMS); - } - - if (v3 != NULL) - { - *v3 = HIWORD(info->dwFileVersionLS); - } - - if (v4 != NULL) - { - *v4 = LOWORD(info->dwFileVersionLS); - } - - ret = true; - } - } - - Free(data); - - return ret; -} - -// Set the file to a hidden file -void MsSetFileToHidden(char *name) -{ - char tmp[MAX_PATH]; - DWORD d; - // Validate arguments - if (name == NULL) - { - return; - } - - NormalizePath(tmp, sizeof(tmp), name); - - d = GetFileAttributesA(tmp); - if (d != INVALID_FILE_ATTRIBUTES) - { - d |= FILE_ATTRIBUTE_HIDDEN; - - SetFileAttributesA(tmp, d); - } -} -void MsSetFileToHiddenW(wchar_t *name) -{ - wchar_t tmp[MAX_PATH]; - DWORD d; - // Validate arguments - if (name == NULL) - { - return; - } - - if (IsNt() == false) - { - char name_a[MAX_SIZE]; - - UniToStr(name_a, sizeof(name_a), name); - - MsSetFileToHidden(name_a); - - return; - } - - NormalizePathW(tmp, sizeof(tmp), name); - - d = GetFileAttributesW(tmp); - if (d != INVALID_FILE_ATTRIBUTES) - { - d |= FILE_ATTRIBUTE_HIDDEN; - - SetFileAttributesW(tmp, d); - } -} - -// Sleep prevention thread -void MsNoSleepThread(THREAD *thread, void *param) -{ - MS_NOSLEEP *e; - EXECUTION_STATE (WINAPI *_SetThreadExecutionState)(EXECUTION_STATE); - HINSTANCE hKernel32; - // Validate arguments - if (thread == NULL || param == NULL) - { - return; - } - - hKernel32 = LoadLibrary("kernel32.dll"); - - _SetThreadExecutionState = - (EXECUTION_STATE (__stdcall *)(EXECUTION_STATE)) - GetProcAddress(hKernel32, "SetThreadExecutionState"); - - e = (MS_NOSLEEP *)param; - - while (e->Halt == false) - { - DWORD flag = ES_SYSTEM_REQUIRED; - - if (e->NoScreenSaver) - { - flag |= ES_DISPLAY_REQUIRED; - } - - if (_SetThreadExecutionState != NULL) - { - _SetThreadExecutionState(flag); - } - - Wait(e->HaltEvent, 30 * 1000); - } - - FreeLibrary(hKernel32); -} - -// Sleep prevention thread (for Windows Vista) -void MsNoSleepThreadVista(THREAD *thread, void *param) -{ - MS_NOSLEEP *e; - char *key = "Control Panel\\Desktop"; - UINT64 last_set_flag = 0; - UINT last_c_x = INFINITE, last_c_y = INFINITE; - UINT64 last_mouse_move_time = 0; - EXECUTION_STATE (WINAPI *_SetThreadExecutionState)(EXECUTION_STATE); - HINSTANCE hKernel32; - // Validate arguments - if (thread == NULL || param == NULL) - { - return; - } - - hKernel32 = LoadLibrary("kernel32.dll"); - - _SetThreadExecutionState = - (EXECUTION_STATE (__stdcall *)(EXECUTION_STATE)) - GetProcAddress(hKernel32, "SetThreadExecutionState"); - - e = (MS_NOSLEEP *)param; - - while (e->Halt == false) - { - DWORD flag = ES_SYSTEM_REQUIRED; - UINT64 now = Tick64(); - POINT p; - bool mouse_move = false; - - Zero(&p, sizeof(p)); - GetCursorPos(&p); - - if (p.x != last_c_x || p.y != last_c_y) - { - if (last_c_x != INFINITE && last_c_y != INFINITE) - { - mouse_move = true; - } - - last_c_x = p.x; - last_c_y = p.y; - } - - if (mouse_move) - { - last_mouse_move_time = now; - } - - if (last_mouse_move_time == 0 || (now > (last_mouse_move_time + 50000ULL))) - { - wchar_t *active; - wchar_t *exe; - // Remove the configuration of the screen saver If the mouse does not move more than 50 seconds - - active = MsRegReadStrW(REG_CURRENT_USER, key, "ScreenSaveActive"); - exe = MsRegReadStrW(REG_CURRENT_USER, key, "SCRNSAVE.EXE"); - - if (UniToInt(active) != 0 && UniIsEmptyStr(exe) == false) - { - // Screen saver is set - UniStrCpy(e->ScreenSaveActive, sizeof(e->ScreenSaveActive), active); - UniStrCpy(e->SCRNSAVE_EXE, sizeof(e->SCRNSAVE_EXE), exe); - - MsRegWriteStrW(REG_CURRENT_USER, key, "ScreenSaveActive", L"0"); - MsRegDeleteValue(REG_CURRENT_USER, key, "SCRNSAVE.EXE"); - - Debug("Push SS Settings.\n"); - } - - Free(active); - Free(exe); - - last_mouse_move_time = now; - } - else - { - if (mouse_move) - { - if (UniIsEmptyStr(e->ScreenSaveActive) == false && UniIsEmptyStr(e->SCRNSAVE_EXE) == false) - { - // Restore the settings of screen saver if the screen saver - // is not set when the mouse is moved - wchar_t *active; - wchar_t *exe; - - active = MsRegReadStrW(REG_CURRENT_USER, key, "ScreenSaveActive"); - exe = MsRegReadStrW(REG_CURRENT_USER, key, "SCRNSAVE.EXE"); - - if (UniToInt(active) != 0 && UniIsEmptyStr(exe) == false) - { - } - else - { - MsRegWriteStrW(REG_CURRENT_USER, key, "ScreenSaveActive", e->ScreenSaveActive); - MsRegWriteStrW(REG_CURRENT_USER, key, "SCRNSAVE.EXE", e->SCRNSAVE_EXE); - - Zero(e->ScreenSaveActive, sizeof(e->ScreenSaveActive)); - Zero(e->SCRNSAVE_EXE, sizeof(e->SCRNSAVE_EXE)); - - Debug("Pop SS Settings.\n"); - } - - Free(active); - Free(exe); - } - } - } - - if (last_set_flag == 0 || (now > (last_set_flag + 50000ULL))) - { - // Flag set (interval 50 seconds) - last_set_flag = now; - - if (_SetThreadExecutionState != NULL) - { - _SetThreadExecutionState(flag); - } - } - - Wait(e->HaltEvent, 512); - } - - if (true) - { - // Restore the settings of the screen saver - wchar_t *active; - wchar_t *exe; - - if (UniIsEmptyStr(e->ScreenSaveActive) == false && UniIsEmptyStr(e->SCRNSAVE_EXE) == false) - { - active = MsRegReadStrW(REG_CURRENT_USER, key, "ScreenSaveActive"); - exe = MsRegReadStrW(REG_CURRENT_USER, key, "SCRNSAVE.EXE"); - - if (UniToInt(active) != 0 && UniIsEmptyStr(exe) != 0) - { - } - else - { - MsRegWriteStrW(REG_CURRENT_USER, key, "ScreenSaveActive", e->ScreenSaveActive); - MsRegWriteStrW(REG_CURRENT_USER, key, "SCRNSAVE.EXE", e->SCRNSAVE_EXE); - - Zero(e->ScreenSaveActive, sizeof(e->ScreenSaveActive)); - Zero(e->SCRNSAVE_EXE, sizeof(e->SCRNSAVE_EXE)); - - Debug("Pop SS Settings.\n"); - } - - Free(active); - Free(exe); - } - } - - FreeLibrary(hKernel32); -} - -// The start of the sleep prevention -void *MsNoSleepStart(bool no_screensaver) -{ - MS_NOSLEEP *e; - bool is_vista = MsIsVista(); - bool is_nt_4 = false; - UINT os_type = GetOsInfo()->OsType; - - if (OS_IS_WINDOWS_NT(os_type)) - { - if (GET_KETA(os_type, 100) == 1) - { - is_nt_4 = true; - } - } - - e = ZeroMalloc(sizeof(MS_NOSLEEP)); - - e->HaltEvent = NewEvent(); - e->NoScreenSaver = no_screensaver; - - if (e->NoScreenSaver == false || (is_vista == false && is_nt_4 == false)) - { - e->Thread = NewThread(MsNoSleepThread, e); - } - else - { - e->Thread = NewThread(MsNoSleepThreadVista, e); - } - - return (void *)e; -} - -// Stop the Sleep prevention -void MsNoSleepEnd(void *p) -{ - MS_NOSLEEP *e; - // Validate arguments - if (p == NULL) - { - return; - } - - e = (MS_NOSLEEP *)p; - - e->Halt = true; - Set(e->HaltEvent); - - WaitThread(e->Thread, INFINITE); - ReleaseThread(e->Thread); - ReleaseEvent(e->HaltEvent); - - Free(e); -} - static wchar_t ms_computer_name_full_cache[MAX_SIZE] = {0}; // Get the full name of the computer -void MsGetComputerNameFull(wchar_t *name, UINT size) -{ - MsGetComputerNameFullEx(name, size, false); -} void MsGetComputerNameFullEx(wchar_t *name, UINT size, bool with_cache) { UINT size2 = size; @@ -3202,18 +1632,6 @@ UINT MsGetCursorPosHash() } // Start the process as a standard user privileges -void *MsRunAsUserEx(char *filename, char *arg, bool hide) -{ - void *ret = MsRunAsUserExInner(filename, arg, hide); - - if (ret == NULL) - { - Debug("MsRunAsUserExInner Failed.\n"); - ret = Win32RunEx(filename, arg, hide); - } - - return ret; -} void *MsRunAsUserExW(wchar_t *filename, wchar_t *arg, bool hide) { void *ret = MsRunAsUserExInnerW(filename, arg, hide); @@ -3226,22 +1644,6 @@ void *MsRunAsUserExW(wchar_t *filename, wchar_t *arg, bool hide) return ret; } -void *MsRunAsUserExInner(char *filename, char *arg, bool hide) -{ - void *ret; - wchar_t *filename_w; - wchar_t *arg_w; - - filename_w = CopyStrToUni(filename); - arg_w = CopyStrToUni(arg); - - ret = MsRunAsUserExInnerW(filename_w, arg_w, hide); - - Free(filename_w); - Free(arg_w); - - return ret; -} void *MsRunAsUserExInnerW(wchar_t *filename, wchar_t *arg, bool hide) { STARTUPINFOW info; @@ -3423,14 +1825,6 @@ HANDLE MsCreateUserToken() // Check the digital signature of the file -bool MsCheckFileDigitalSignature(HWND hWnd, char *name, bool *danger) -{ - wchar_t tmp[MAX_PATH]; - - swprintf(tmp, sizeof(tmp), L"%S", name); - - return MsCheckFileDigitalSignatureW(hWnd, tmp, danger); -} bool MsCheckFileDigitalSignatureW(HWND hWnd, wchar_t *name, bool *danger) { HRESULT ret = S_OK; @@ -3507,22 +1901,6 @@ bool MsCheckFileDigitalSignatureW(HWND hWnd, wchar_t *name, bool *danger) return true; } -// Enable or disable the WoW64 redirection -void MsSetWow64FileSystemRedirectionEnable(bool enable) -{ - if (MsIs64BitWindows() == false) - { - return; - } - - if (ms->nt->Wow64EnableWow64FsRedirection == NULL) - { - return; - } - - ms->nt->Wow64EnableWow64FsRedirection(enable ? 1 : 0); -} - // Disable the WoW64 redirection void *MsDisableWow64FileSystemRedirection() { @@ -4013,29 +2391,6 @@ void *MsLoadLibraryAsDataFile(char *name) return MsLoadLibraryAsDataFileW(name_w); } -// Simple LoadLibrary -void *MsLoadLibraryRawW(wchar_t *name) -{ - // Validate arguments - if (name == NULL) - { - return NULL; - } - - if (MsIsNt()) - { - return LoadLibraryW(name); - } - else - { - char tmp[MAX_PATH]; - - UniToStr(tmp, sizeof(tmp), name); - - return LoadLibraryA(tmp); - } -} - // LoadLibrary (compatible for Hamcore) void *MsLoadLibraryW(wchar_t *name) { @@ -4097,30 +2452,6 @@ void *MsLoadLibrary(char *name) return MsLoadLibraryW(name_w); } -// Release of the library -void MsFreeLibrary(void *h) -{ - // Validate arguments - if (h == NULL) - { - return; - } - - FreeLibrary(h); -} - -// Get the function pointer in the DLL -void *MsGetProcAddress(void *h, char *name) -{ - // Validate arguments - if (h == NULL || name == NULL) - { - return NULL; - } - - return (void *)GetProcAddress(h, name); -} - // Search for the adapter by GUID MS_ADAPTER *MsGetAdapterByGuid(char *guid) { @@ -4981,31 +3312,6 @@ bool MsKillProcess(UINT id) } // Get the current EXE file name -void MsGetCurrentProcessExeName(char *name, UINT size) -{ - UINT id; - LIST *o; - MS_PROCESS *p; - // Validate arguments - if (name == NULL) - { - return; - } - - id = MsGetCurrentProcessId(); - o = MsGetProcessList(); - p = MsSearchProcessById(o, id); - if (p != NULL) - { - p = MsSearchProcessById(o, id); - StrCpy(name, size, p->ExeFilename); - } - else - { - StrCpy(name, size, MsGetExeFileName()); - } - MsFreeProcessList(o); -} void MsGetCurrentProcessExeNameW(wchar_t *name, UINT size) { UINT id; @@ -5079,23 +3385,6 @@ int MsCompareProcessList(void *p1, void *p2) } } -// Display the process list -void MsPrintProcessList(LIST *o) -{ - UINT i; - // Validate arguments - if (o == NULL) - { - return; - } - - for (i = 0;i < LIST_NUM(o);i++) - { - MS_PROCESS *p = LIST_DATA(o, i); - UniPrint(L"%-4u: %s\n", p->ProcessId, p->ExeFilenameW); - } -} - // Release of the process list void MsFreeProcessList(LIST *o) { @@ -5345,12 +3634,6 @@ bool MsShowIconOnTray(HWND hWnd, HICON icon, wchar_t *tooltip, UINT msg) return ret; } -// Check whether the task tray has been initialized -bool MsIsTrayInited() -{ - return tray_inited; -} - // Restore the icon in the task tray void MsRestoreIconOnTray() { @@ -5369,12 +3652,6 @@ void MsRestoreIconOnTray() } } -// Change the icon in the task tray (go over!) -void MsChangeIconOnTrayEx2(void *icon, wchar_t *tooltip, wchar_t *info_title, wchar_t *info, UINT info_flags) -{ - MsChangeIconOnTrayEx((HICON)icon, tooltip, info_title, info, info_flags, false); -} - // Change the icon in the task tray void MsChangeIconOnTray(HICON icon, wchar_t *tooltip) { @@ -5736,15 +4013,6 @@ bool MsIsUserMode() return is_usermode; } -// Command to terminate the user-mode from the service side -void MsStopUserModeFromService() -{ - if (hWndUsermode != NULL) - { - PostMessage(hWndUsermode, WM_CLOSE, 0, 0); - } -} - // Only run the test (for debugging) void MsTestOnly() { @@ -6050,14 +4318,6 @@ void MsFreeSuspendHandler(MS_SUSPEND_HANDLER *h) } // Start in user mode -void MsUserMode(char *title, SERVICE_FUNCTION *start, SERVICE_FUNCTION *stop, UINT icon) -{ - wchar_t *title_w = CopyStrToUni(title); - - MsUserModeW(title_w, start, stop, icon); - - Free(title_w); -} void MsUserModeW(wchar_t *title, SERVICE_FUNCTION *start, SERVICE_FUNCTION *stop, UINT icon) { WNDCLASS wc; @@ -6397,11 +4657,6 @@ UINT MsReadCallingServiceManagerProcessId(char *svcname, bool current_user) return MsRegReadInt(current_user ? REG_CURRENT_USER : REG_LOCAL_MACHINE, tmp, SVC_CALLING_SM_PROCESS_ID_VALUE); } -// Dispatch function of the service -void CALLBACK MsScmDispatcher(DWORD argc, LPTSTR *argv) -{ -} - // Service main function UINT MsService(char *name, SERVICE_FUNCTION *start, SERVICE_FUNCTION *stop, UINT icon, char *cmd_line) { @@ -7124,42 +5379,6 @@ wchar_t *MsGetSessionUserName(UINT session_id) return NULL; } -// Get whether the current desktop is available for the VNC -bool MsIsCurrentDesktopAvailableForVnc() -{ - if (MsIsNt() == false) - { - return true; - } - - if (MsIsCurrentTerminalSessionActive() == false) - { - return false; - } - - if (ms->nt->OpenDesktopA == NULL || - ms->nt->CloseDesktop == NULL || - ms->nt->SwitchDesktop == NULL) - { - return true; - } - else - { - HDESK hDesk = ms->nt->OpenDesktopA("default", 0, false, DESKTOP_SWITCHDESKTOP); - bool ret; - - if (hDesk == NULL) - { - return false; - } - - ret = ms->nt->SwitchDesktop(hDesk); - ms->nt->CloseDesktop(hDesk); - - return ret; - } -} - // Get whether the current terminal session is active bool MsIsCurrentTerminalSessionActive() { @@ -7224,36 +5443,6 @@ UINT MsGetCurrentTerminalSessionId() return 0; } -// Examine whether the Terminal Services is installed and the multiple sessions can log in -bool MsIsTerminalServiceMultiUserInstalled() -{ - OS_INFO *info = GetOsInfo(); - OSVERSIONINFOEX i; - if (MsIsTerminalServiceInstalled() == false) - { - return false; - } - - if (OS_IS_SERVER(info->OsType) == false) - { - return false; - } - - Zero(&i, sizeof(i)); - i.dwOSVersionInfoSize = sizeof(i); - if (GetVersionEx((OSVERSIONINFO *)&i) == false) - { - return false; - } - - if (i.wSuiteMask & VER_SUITE_SINGLEUSERTS) - { - return false; - } - - return true; -} - // Examine whether the user switching is installed bool MsIsUserSwitchingInstalled() { @@ -7292,135 +5481,6 @@ bool MsIsUserSwitchingInstalled() return false; } -// Enable the remote desktop -bool MsEnableRemoteDesktop() -{ - OS_INFO *info = GetOsInfo(); - - if (MsIsRemoteDesktopAvailable() == false) - { - return false; - } - - if (MsIsRemoteDesktopEnabled()) - { - return true; - } - - if (GET_KETA(info->OsType, 100) == 2) - { - // Windows 2000 - return false; - } - - if (MsRegWriteInt(REG_LOCAL_MACHINE, - "SYSTEM\\CurrentControlSet\\Control\\Terminal Server", - "fDenyTSConnections", 0) == false) - { - return false; - } - - if (MsIsVista()) - { - if (MsRegWriteInt(REG_LOCAL_MACHINE, - "SYSTEM\\CurrentControlSet\\Control\\Terminal Server\\WinStations\\RDP-Tcp", - "UserAuthentication", 0) == false) - { - return false; - } - } - - return true; -} - -// Examine whether the Remote Desktop is enabled -bool MsIsRemoteDesktopEnabled() -{ - OS_INFO *info = GetOsInfo(); - - if (MsIsRemoteDesktopAvailable() == false) - { - return false; - } - - if (GET_KETA(info->OsType, 100) == 2) - { - // Windows 2000 - return MsIsServiceRunning("TermService"); - } - else - { - // Windows XP or later - bool b = MsRegReadInt(REG_LOCAL_MACHINE, - "SYSTEM\\CurrentControlSet\\Control\\Terminal Server", - "fDenyTSConnections"); - - if (MsIsVista() == false) - { - return b ? false : true; - } - else - { - if (b) - { - return false; - } - else - { - if (MsRegReadInt(REG_LOCAL_MACHINE, - "SYSTEM\\CurrentControlSet\\Control\\Terminal Server\\WinStations\\RDP-Tcp", - "UserAuthentication")) - { - return false; - } - else - { - return true; - } - } - } - } -} - -// Examine whether the remote desktop becomes available by registry operation -bool MsIsRemoteDesktopCanEnableByRegistry() -{ - OS_INFO *info = GetOsInfo(); - if (MsIsRemoteDesktopAvailable() == false) - { - return false; - } - - if (GET_KETA(info->OsType, 100) == 2) - { - // Windows 2000 - return false; - } - else - { - // Others - return true; - } -} - -// Examine whether it's running on Windows 2000 -bool MsIsWin2000() -{ - 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 2000 or later bool MsIsWin2000OrGreater() { @@ -7457,74 +5517,6 @@ bool MsIsWinXPOrGreater() return false; } -// Examine whether the remote desktop is available -bool MsIsRemoteDesktopAvailable() -{ - OS_INFO *info = GetOsInfo(); - if (MsIsTerminalServiceInstalled() == false) - { - return false; - } - - if (GET_KETA(info->OsType, 100) == 2) - { - // Windows 2000 - if (info->OsType == 2200) - { - // Windows 2000 Professional - return false; - } - else - { - // Windows 2000 server series - return true; - } - } - else if (GET_KETA(info->OsType, 100) == 3) - { - // Windows XP - if (info->OsType == OSTYPE_WINDOWS_XP_HOME) - { - // Home Edition - return false; - } - else - { - // Professional Edition - return true; - } - } - else if (GET_KETA(info->OsType, 100) == 4) - { - // Windows Server 2003 - return true; - } - else if (GET_KETA(info->OsType, 100) >= 5) - { - // Windows Vista or later - OSVERSIONINFOEX i; - - Zero(&i, sizeof(i)); - i.dwOSVersionInfoSize = sizeof(i); - if (GetVersionEx((OSVERSIONINFO *)&i) == false) - { - return false; - } - - if (i.wSuiteMask & VER_SUITE_PERSONAL) - { - // Home series - return false; - } - else - { - return true; - } - } - - return false; -} - // Examine whether the Terminal Services is installed bool MsIsTerminalServiceInstalled() { @@ -7934,21 +5926,6 @@ bool MsInstallDeviceDriverW(char *name, wchar_t *title, wchar_t *path, UINT *err } // Install the service -bool MsInstallService(char *name, char *title, wchar_t *description, char *path) -{ - wchar_t title_w[MAX_PATH]; - wchar_t path_w[MAX_PATH]; - // Validate arguments - if (name == NULL || title == NULL || path == NULL) - { - return false; - } - - StrToUni(title_w, sizeof(title_w), title); - StrToUni(path_w, sizeof(path_w), path); - - return MsInstallServiceW(name, title_w, description, path_w); -} bool MsInstallServiceW(char *name, wchar_t *title, wchar_t *description, wchar_t *path) { return MsInstallServiceExW(name, title, description, path, NULL); @@ -8077,12 +6054,6 @@ UINT MsGetProcessId() return GetCurrentProcessId(); } -// Get the MS structure -MS *MsGetMs() -{ - return ms; -} - // Lower the priority of the thread to lowest void MsSetThreadPriorityIdle() { @@ -8095,12 +6066,6 @@ void MsSetThreadPriorityHigh() SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_ABOVE_NORMAL); } -// Lower the priority of the thread -void MsSetThreadPriorityLow() -{ - SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_BELOW_NORMAL); -} - // Raise the priority of the thread to highest void MsSetThreadPriorityRealtime() { @@ -8770,24 +6735,6 @@ BOOL CALLBACK EnumChildWindowProc(HWND hWnd, LPARAM lParam) return TRUE; } -LIST *EnumAllWindow() -{ - return EnumAllWindowEx(false, false); -} -LIST *EnumAllWindowEx(bool no_recursion, bool include_ipcontrol) -{ - ENUM_CHILD_WINDOW_PARAM p; - LIST *o = NewWindowList(); - - Zero(&p, sizeof(p)); - p.o = o; - p.no_recursion = no_recursion; - p.include_ipcontrol = include_ipcontrol; - - EnumWindows(EnumChildWindowProc, (LPARAM)&p); - - return o; -} LIST *EnumAllTopWindow() { LIST *o = NewWindowList(); @@ -9039,28 +6986,6 @@ bool MsGetWindowOwnerProcessExeName(char *path, UINT size, HWND hWnd) return true; } -bool MsGetWindowOwnerProcessExeNameW(wchar_t *path, UINT size, HWND hWnd) -{ - DWORD procId = 0; - // Validate arguments - if (path == NULL || hWnd == NULL) - { - return false; - } - - GetWindowThreadProcessId(hWnd, &procId); - if (procId == 0) - { - return false; - } - - if (MsGetProcessExeNameW(path, size, procId) == false) - { - return false; - } - - return true; -} // Get the process path from process ID bool MsGetProcessExeName(char *path, UINT size, UINT id) @@ -9087,30 +7012,6 @@ bool MsGetProcessExeName(char *path, UINT size, UINT id) return ret; } -bool MsGetProcessExeNameW(wchar_t *path, UINT size, UINT id) -{ - LIST *o; - MS_PROCESS *proc; - bool ret = false; - // Validate arguments - if (path == NULL) - { - return false; - } - - o = MsGetProcessList(); - proc = MsSearchProcessById(o, id); - - if (proc != NULL) - { - ret = true; - UniStrCpy(path, size, proc->ExeFilenameW); - } - - MsFreeProcessList(o); - - return ret; -} // Close the alert dialog bool MsCloseWarningWindow(NO_WARNING *nw, UINT thread_id) @@ -10698,106 +8599,6 @@ bool MsIsVLanExists(char *tag_name, char *instance_name) return true; } -// Create a temporary file based on the extension -IO *MsCreateTempFileByExt(char *ext) -{ - char *tmp = MsCreateTempFileNameByExt(ext); - IO *ret; - - if (tmp == NULL) - { - return NULL; - } - - ret = FileCreate(tmp); - Free(tmp); - - return ret; -} - -// Create a temporary file with the specified extension -char *MsCreateTempFileNameByExt(char *ext) -{ - UCHAR rand[2]; - char *ret = NULL; - // Validate arguments - if (ext == NULL) - { - ext = "tmp"; - } - if (ext[0] == '.') - { - ext++; - } - if (StrLen(ext) == 0) - { - ext = "tmp"; - } - - while (true) - { - char new_filename[MAX_PATH]; - char *fullpath; - char rand_str[MAX_PATH]; - IO *io; - Rand(rand, sizeof(rand)); - - BinToStr(rand_str, sizeof(rand_str), rand, sizeof(rand)); - Format(new_filename, sizeof(new_filename), "__%s.%s", rand_str, ext); - - fullpath = MsCreateTempFileName(new_filename); - io = FileOpen(fullpath, false); - if (io == NULL) - { - ret = fullpath; - break; - } - FileClose(io); - - Free(fullpath); - } - - return ret; -} - -// Create a temporary file -IO *MsCreateTempFile(char *name) -{ - IO *ret; - char *tmp; - // Validate arguments - if (name == NULL) - { - return NULL; - } - - tmp = MsCreateTempFileName(name); - if (tmp == NULL) - { - return NULL; - } - - ret = FileCreate(tmp); - Free(tmp); - - return ret; -} - -// Create a temporary file name -char *MsCreateTempFileName(char *name) -{ - char tmp[MAX_PATH]; - // Validate arguments - if (name == NULL) - { - return NULL; - } - - Format(tmp, sizeof(tmp), "%s\\%s", ms->MyTempDir, name); - - return CopyStr(tmp); -} - // Delete VPN temporary directories that remain in the system but not used void MsDeleteTempDir() { @@ -11579,78 +9380,6 @@ char *MsGetDriverVersion(char *tag_name, char *instance_name) return ret; } -// Get the registry key of the NETCFG of the virtual LAN card -char *MsGetNetCfgRegKeyName(char *tag_name, char *instance_name) -{ - TOKEN_LIST *key_list; - UINT i; - char *ret = NULL; - char dest_name[MAX_SIZE]; - // Validate arguments - if (tag_name == NULL || instance_name == NULL) - { - return NULL; - } - - // Generate the desired 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"); - } - - if (key_list == NULL) - { - return NULL; - } - - for (i = 0;i < key_list->NumTokens;i++) - { - char *key_name = key_list->Token[i]; - 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); - } - - // Read the DriverDesc - driver_desc = MsRegReadStr(REG_LOCAL_MACHINE, full_key_name, "DriverDesc"); - if (driver_desc != NULL) - { - if (StrCmpi(dest_name, driver_desc) == 0) - { - ret = CopyStr(full_key_name); - - Free(driver_desc); - break; - } - Free(driver_desc); - } - } - - FreeToken(key_list); - - return ret; -} - // Get the MAC address char *MsGetMacAddress(char *tag_name, char *instance_name) { @@ -12237,261 +9966,6 @@ bool MsCheckLogon(wchar_t *username, char *password) return true; } -// Attempt to logon to the domain -bool MsIsPasswordEmpty(wchar_t *username) -{ - HANDLE h; - // Validate arguments - if (username == NULL) - { - return false; - } - - if (MsIsNt() == false) - { - return false; - } - - if (GET_KETA(GetOsInfo()->OsType, 100) >= 2) - { - if (ms->nt->LogonUserW(username, NULL, L"", LOGON32_LOGON_NETWORK, LOGON32_PROVIDER_DEFAULT, &h) == false) - { - // Logon failure - if (GetLastError() == 1327) - { - // Password is empty - return true; - } - else - { - // The password is not correct - return false; - } - } - } - else - { - char username_ansi[MAX_SIZE]; - UniToStr(username_ansi, sizeof(username_ansi), username); - - if (ms->nt->LogonUserA(username_ansi, NULL, "", LOGON32_LOGON_NETWORK, LOGON32_PROVIDER_DEFAULT, &h) == false) - { - // Logon failure - if (GetLastError() == 1327) - { - // Password is empty - return true; - } - else - { - // The password is not correct - return false; - } - } - } - - CloseHandle(h); - - // Since successful logon, the password should be empty - return false; -} - -// Determine if the workstation is locked by using WTS API -bool MsDetermineIsLockedByWtsApi() -{ - return wts_is_locked_flag; -} - -// IsLocked Window Proc -LRESULT CALLBACK MsIsLockedWindowHandlerWindowProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) -{ - MS_ISLOCKED *d = NULL; - CREATESTRUCT *cs; - // Validate arguments - if (hWnd == NULL) - { - return 0; - } - - d = (MS_ISLOCKED *)GetWindowLongPtrA(hWnd, GWLP_USERDATA); - if (d == NULL && msg != WM_CREATE) - { - goto LABEL_END; - } - - switch (msg) - { - case WM_CREATE: - cs = (CREATESTRUCT *)lParam; - d = (MS_ISLOCKED *)cs->lpCreateParams; - SetWindowLongPtrA(hWnd, GWLP_USERDATA, (LONG_PTR)d); - - ms->nt->WTSRegisterSessionNotification(hWnd, NOTIFY_FOR_THIS_SESSION); - - wts_is_locked_flag = false; - - break; - - case WM_WTSSESSION_CHANGE: - { - char tmp[MAX_SIZE]; - - GetDateTimeStr64(tmp, sizeof(tmp), LocalTime64()); - - switch (wParam) - { - case WTS_SESSION_LOCK: - Debug("%s: Enter Lock\n", tmp); - d->IsLockedFlag = true; - wts_is_locked_flag = true; - break; - - case WTS_SESSION_UNLOCK: - Debug("%s: Enter Unlock\n", tmp); - d->IsLockedFlag = false; - wts_is_locked_flag = false; - break; - } - } - - break; - - case WM_DESTROY: - Debug("Unregister\n"); - ms->nt->WTSUnRegisterSessionNotification(hWnd); - PostQuitMessage(0); - break; - } - -LABEL_END: - return DefWindowProc(hWnd, msg, wParam, lParam); -} - -// IsLocked thread proc -void MsIsLockedThreadProc(THREAD *thread, void *param) -{ - MS_ISLOCKED *d = (MS_ISLOCKED *)param; - char wndclass_name[MAX_PATH]; - WNDCLASS wc; - HWND hWnd; - MSG msg; - // Validate arguments - if (d == NULL || thread == NULL) - { - return; - } - - Format(wndclass_name, sizeof(wndclass_name), "WNDCLASS_%X", Rand32()); - - Zero(&wc, sizeof(wc)); - wc.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH); - wc.hCursor = LoadCursor(NULL, IDC_ARROW); - wc.hIcon = NULL; - wc.hInstance = ms->hInst; - wc.lpfnWndProc = MsIsLockedWindowHandlerWindowProc; - wc.lpszClassName = wndclass_name; - if (RegisterClassA(&wc) == 0) - { - NoticeThreadInit(thread); - return; - } - - hWnd = CreateWindowA(wndclass_name, wndclass_name, WS_OVERLAPPEDWINDOW, - CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, - NULL, NULL, ms->hInst, d); - - d->hWnd = hWnd; - - NoticeThreadInit(thread); - - if (hWnd == NULL) - { - UnregisterClassA(wndclass_name, ms->hInst); - return; - } - - while (GetMessage(&msg, NULL, 0, 0)) - { - TranslateMessage(&msg); - DispatchMessage(&msg); - } - - DestroyWindow(hWnd); - - UnregisterClassA(wndclass_name, ms->hInst); -} - -// Create new IsLocked thread -MS_ISLOCKED *MsNewIsLocked() -{ - MS_ISLOCKED *d; - THREAD *t; - - SleepThread(5000); - - if (IsNt() == false || ms->nt->WTSRegisterSessionNotification == NULL || - ms->nt->WTSUnRegisterSessionNotification == NULL) - { - return NULL; - } - - d = ZeroMalloc(sizeof(MS_ISLOCKED)); - - t = NewThread(MsIsLockedThreadProc, d); - - WaitThreadInit(t); - - d->Thread = t; - - return d; -} - -// Stop and free the IsLocked thread -void MsFreeIsLocked(MS_ISLOCKED *d) -{ - if (d == NULL) - { - return; - } - - if (d->hWnd != NULL) - { - PostMessageA(d->hWnd, WM_CLOSE, 0, 0); - } - - WaitThread(d->Thread, INFINITE); - ReleaseThread(d->Thread); - - Free(d); -} - -// Execution of shutdown (NT) -bool MsShutdownEx(bool reboot, bool force, UINT time_limit, char *message) -{ - if (MsIsNt() == false) - { - return MsShutdown(reboot, force); - } - - // Get the privilege - if (MsEnablePrivilege(SE_SHUTDOWN_NAME, true) == false) - { - return false; - } - - // Execute the shutdown - if (ms->nt->InitiateSystemShutdown(NULL, message, time_limit, force, reboot) == false) - { - MsEnablePrivilege(SE_SHUTDOWN_NAME, false); - return false; - } - - // Release of privilege - MsEnablePrivilege(SE_SHUTDOWN_NAME, false); - - return true; -} - // Execute the shutdown bool MsShutdown(bool reboot, bool force) { @@ -13114,10 +10588,6 @@ bool MsIsAeroEnabled() } // Generate an access mask to force accessing to the 32 bit registry key for 64 bit application -DWORD MsRegAccessMaskFor64Bit(bool force32bit) -{ - return MsRegAccessMaskFor64BitEx(force32bit, false); -} DWORD MsRegAccessMaskFor64BitEx(bool force32bit, bool force64bit) { if (MsIs64BitWindows() == false) @@ -13525,14 +10995,6 @@ bool MsRegWriteStrEx2W(UINT root, char *keyname, char *valuename, wchar_t *str, } // Set the value -bool MsRegWriteValue(UINT root, char *keyname, char *valuename, UINT type, void *data, UINT size) -{ - return MsRegWriteValueEx(root, keyname, valuename, type, data, size, false); -} -bool MsRegWriteValueEx(UINT root, char *keyname, char *valuename, UINT type, void *data, UINT size, bool force32bit) -{ - return MsRegWriteValueEx2(root, keyname, valuename, type, data, size, force32bit, false); -} bool MsRegWriteValueEx2(UINT root, char *keyname, char *valuename, UINT type, void *data, UINT size, bool force32bit, bool force64bit) { HKEY h; @@ -13563,14 +11025,6 @@ bool MsRegWriteValueEx2(UINT root, char *keyname, char *valuename, UINT type, vo return true; } -bool MsRegWriteValueW(UINT root, char *keyname, char *valuename, UINT type, void *data, UINT size) -{ - return MsRegWriteValueExW(root, keyname, valuename, type, data, size, false); -} -bool MsRegWriteValueExW(UINT root, char *keyname, char *valuename, UINT type, void *data, UINT size, bool force32bit) -{ - return MsRegWriteValueEx2W(root, keyname, valuename, type, data, size, force32bit, false); -} bool MsRegWriteValueEx2W(UINT root, char *keyname, char *valuename, UINT type, void *data, UINT size, bool force32bit, bool force64bit) { HKEY h; @@ -13900,14 +11354,6 @@ wchar_t *MsRegReadStrEx2W(UINT root, char *keyname, char *valuename, bool force3 } // Read the value -bool MsRegReadValue(UINT root, char *keyname, char *valuename, void **data, UINT *type, UINT *size) -{ - return MsRegReadValueEx(root, keyname, valuename, data, type, size, false); -} -bool MsRegReadValueEx(UINT root, char *keyname, char *valuename, void **data, UINT *type, UINT *size, bool force32bit) -{ - return MsRegReadValueEx2(root, keyname, valuename, data, type, size, force32bit, false); -} bool MsRegReadValueEx2(UINT root, char *keyname, char *valuename, void **data, UINT *type, UINT *size, bool force32bit, bool force64bit) { HKEY h; @@ -13961,14 +11407,6 @@ bool MsRegReadValueEx2(UINT root, char *keyname, char *valuename, void **data, U return true; } -bool MsRegReadValueW(UINT root, char *keyname, char *valuename, void **data, UINT *type, UINT *size) -{ - return MsRegReadValueExW(root, keyname, valuename, data, type, size, false); -} -bool MsRegReadValueExW(UINT root, char *keyname, char *valuename, void **data, UINT *type, UINT *size, bool force32bit) -{ - return MsRegReadValueEx2W(root, keyname, valuename, data, type, size, force32bit, false); -} bool MsRegReadValueEx2W(UINT root, char *keyname, char *valuename, void **data, UINT *type, UINT *size, bool force32bit, bool force64bit) { HKEY h; @@ -14060,127 +11498,6 @@ bool MsRegReadValueEx2W(UINT root, char *keyname, char *valuename, void **data, return true; } -// Get the size and type of value -bool MsRegGetValueTypeAndSize(UINT root, char *keyname, char *valuename, UINT *type, UINT *size) -{ - return MsRegGetValueTypeAndSizeEx(root, keyname, valuename, type, size, false); -} -bool MsRegGetValueTypeAndSizeEx(UINT root, char *keyname, char *valuename, UINT *type, UINT *size, bool force32bit) -{ - return MsRegGetValueTypeAndSizeEx2(root, keyname, valuename, type, size, force32bit, false); -} -bool MsRegGetValueTypeAndSizeEx2(UINT root, char *keyname, char *valuename, UINT *type, UINT *size, bool force32bit, bool force64bit) -{ - HKEY h; - UINT ret; - // Validate arguments - if (keyname == NULL) - { - return false; - } - if (type != NULL) - { - *type = 0; - } - if (size != NULL) - { - *size = 0; - } - - // Open the key - if (RegOpenKeyEx(MsGetRootKeyFromInt(root), keyname, 0, KEY_READ | MsRegAccessMaskFor64BitEx(force32bit, force64bit), &h) != ERROR_SUCCESS) - { - return false; - } - - // Open up the value - ret = RegQueryValueEx(h, valuename, 0, type, NULL, size); - - if (ret == ERROR_SUCCESS || ret == ERROR_MORE_DATA) - { - RegCloseKey(h); - return true; - } - - RegCloseKey(h); - - return false; -} -bool MsRegGetValueTypeAndSizeW(UINT root, char *keyname, char *valuename, UINT *type, UINT *size) -{ - return MsRegGetValueTypeAndSizeExW(root, keyname, valuename, type, size, false); -} -bool MsRegGetValueTypeAndSizeExW(UINT root, char *keyname, char *valuename, UINT *type, UINT *size, bool force32bit) -{ - return MsRegGetValueTypeAndSizeEx2W(root, keyname, valuename, type, size, force32bit, false); -} -bool MsRegGetValueTypeAndSizeEx2W(UINT root, char *keyname, char *valuename, UINT *type, UINT *size, bool force32bit, bool force64bit) -{ - HKEY h; - UINT ret; - wchar_t *valuename_w; - // Validate arguments - if (keyname == NULL) - { - return false; - } - if (type != NULL) - { - *type = 0; - } - if (size != NULL) - { - *size = 0; - } - if (IsNt() == false) - { - UINT type_a = 0; - UINT size_a = 0; - - bool ret = MsRegGetValueTypeAndSizeEx2(root, keyname, valuename, &type_a, &size_a, force32bit, force64bit); - - if (type_a == REG_SZ || type_a == REG_MULTI_SZ || type_a == REG_EXPAND_SZ) - { - size_a = size_a * sizeof(wchar_t); - } - - if (type != NULL) - { - *type = type_a; - } - - if (size != NULL) - { - *size = size_a; - } - - return ret; - } - - // Open the key - if (RegOpenKeyEx(MsGetRootKeyFromInt(root), keyname, 0, KEY_READ | MsRegAccessMaskFor64BitEx(force32bit, force64bit), &h) != ERROR_SUCCESS) - { - return false; - } - - valuename_w = CopyStrToUni(valuename); - - // Open up the value - ret = RegQueryValueExW(h, valuename_w, 0, type, NULL, size); - - Free(valuename_w); - - if (ret == ERROR_SUCCESS || ret == ERROR_MORE_DATA) - { - RegCloseKey(h); - return true; - } - - RegCloseKey(h); - - return false; -} - // Confirm that the specified value exists on the registry bool MsRegIsValue(UINT root, char *keyname, char *valuename) { @@ -14223,14 +11540,6 @@ bool MsRegIsValueEx2(UINT root, char *keyname, char *valuename, bool force32bit, } // Create a key in the registry -bool MsRegNewKey(UINT root, char *keyname) -{ - return MsRegNewKeyEx(root, keyname, false); -} -bool MsRegNewKeyEx(UINT root, char *keyname, bool force32bit) -{ - return MsRegNewKeyEx2(root, keyname, force32bit, false); -} bool MsRegNewKeyEx2(UINT root, char *keyname, bool force32bit, bool force64bit) { HKEY h; @@ -15234,14 +12543,6 @@ void MsFree() } // Directory acquisition related -char *MsGetCommonAppDataDir() -{ - return ms->CommonAppDataDir; -} -char *MsGetLocalAppDataDir() -{ - return ms->LocalAppDataDir; -} char *MsGetWindowsDir() { return ms->WindowsDir; @@ -15258,102 +12559,18 @@ char *MsGetTempDir() { return ms->TempDir; } -char *MsGetWindowsDrive() -{ - return ms->WindowsDrive; -} char *MsGetProgramFilesDir() { return ms->ProgramFilesDir; } -char *MsGetProgramFilesDirX86() -{ - return ms->ProgramFilesDirX86; -} -char *MsGetProgramFilesDirX64() -{ - return ms->ProgramFilesDirX64; -} -char *MsGetCommonStartMenuDir() -{ - return ms->CommonStartMenuDir; -} -char *MsGetCommonProgramsDir() -{ - return ms->CommonProgramsDir; -} char *MsGetCommonStartupDir() { return ms->CommonStartupDir; } -char *MsGetCommonDesktopDir() -{ - return ms->CommonDesktopDir; -} -char *MsGetPersonalStartMenuDir() -{ - if (ms->PersonalStartMenuDir == NULL) - { - ms->PersonalStartMenuDir = MsGetSpecialDir(CSIDL_STARTMENU); - } - return ms->PersonalStartMenuDir; -} -char *MsGetPersonalProgramsDir() -{ - if (ms->PersonalProgramsDir == NULL) - { - ms->PersonalProgramsDir = MsGetSpecialDir(CSIDL_PROGRAMS); - } - return ms->PersonalProgramsDir; -} -char *MsGetPersonalStartupDir() -{ - if (ms->PersonalStartupDir == NULL) - { - ms->PersonalStartupDir = MsGetSpecialDir(CSIDL_STARTUP); - } - return ms->PersonalStartupDir; -} -char *MsGetPersonalAppDataDir() -{ - if (ms->PersonalAppDataDir == NULL) - { - ms->PersonalAppDataDir = MsGetSpecialDir(CSIDL_APPDATA); - } - return ms->PersonalAppDataDir; -} -char *MsGetPersonalDesktopDir() -{ - if (ms->PersonalDesktopDir == NULL) - { - ms->PersonalDesktopDir = MsGetSpecialDir(CSIDL_DESKTOP); - } - return ms->PersonalDesktopDir; -} -char *MsGetMyDocumentsDir() -{ - if (ms->MyDocumentsDir == NULL) - { - ms->MyDocumentsDir = MsGetSpecialDir(CSIDL_PERSONAL); - } - return ms->MyDocumentsDir; -} char *MsGetMyTempDir() { return ms->MyTempDir; } -char *MsGetUserName() -{ - return ms->UserName; -} -char *MsGetUserNameEx() -{ - return ms->UserNameEx; -} -char *MsGetWinTempDir() -{ - return ms->WinTempDir; -} wchar_t *MsGetExeFileNameW() { @@ -15363,10 +12580,6 @@ wchar_t *MsGetExeFileDirW() { return ms->ExeFileDirW; } -wchar_t *MsGetWindowDirW() -{ - return ms->WindowsDirW; -} wchar_t *MsGetSystem32DirW() { return ms->System32DirW; @@ -15375,14 +12588,6 @@ wchar_t *MsGetTempDirW() { return ms->TempDirW; } -wchar_t *MsGetWindowsDriveW() -{ - return ms->WindowsDriveW; -} -wchar_t *MsGetProgramFilesDirW() -{ - return ms->ProgramFilesDirW; -} wchar_t *MsGetCommonStartMenuDirW() { return ms->CommonStartMenuDirW; @@ -15391,10 +12596,6 @@ wchar_t *MsGetCommonProgramsDirW() { return ms->CommonProgramsDirW; } -wchar_t *MsGetProgramFilesDirX86W() -{ - return ms->ProgramFilesDirX86W; -} wchar_t *MsGetProgramFilesDirX64W() { return ms->ProgramFilesDirX64W; @@ -15403,10 +12604,6 @@ wchar_t *MsGetCommonStartupDirW() { return ms->CommonStartupDirW; } -wchar_t *MsGetCommonAppDataDirW() -{ - return ms->CommonAppDataDirW; -} wchar_t *MsGetCommonDesktopDirW() { return ms->CommonDesktopDirW; @@ -15456,19 +12653,6 @@ wchar_t *MsGetPersonalDesktopDirW() return ms->PersonalDesktopDirW; } -wchar_t *MsGetMyDocumentsDirW() -{ - if (ms->MyDocumentsDirW == NULL) - { - ms->MyDocumentsDirW = MsGetSpecialDirW(CSIDL_PERSONAL); - } - - return ms->MyDocumentsDirW; -} -wchar_t *MsGetLocalAppDataDirW() -{ - return ms->LocalAppDataDirW; -} wchar_t *MsGetMyTempDirW() { return ms->MyTempDirW; @@ -15477,15 +12661,6 @@ wchar_t *MsGetUserNameW() { return ms->UserNameW; } -wchar_t *MsGetUserNameExW() -{ - return ms->UserNameExW; -} -wchar_t *MsGetWinTempDirW() -{ - return ms->WinTempDirW; -} - #endif // WIN32 diff --git a/src/Mayaqua/Microsoft.h b/src/Mayaqua/Microsoft.h index bac5cf75..09dc0146 100644 --- a/src/Mayaqua/Microsoft.h +++ b/src/Mayaqua/Microsoft.h @@ -649,7 +649,6 @@ void MsFree(); char *MsCutExeNameFromCommandLine(char *str); wchar_t *MsCutExeNameFromUniCommandLine(wchar_t *str); -DWORD MsRegAccessMaskFor64Bit(bool force32bit); DWORD MsRegAccessMaskFor64BitEx(bool force32bit, bool force64bit); bool MsRegIsKey(UINT root, char *name); @@ -660,18 +659,7 @@ bool MsRegIsValue(UINT root, char *keyname, char *valuename); bool MsRegIsValueEx(UINT root, char *keyname, char *valuename, bool force32bit); bool MsRegIsValueEx2(UINT root, char *keyname, char *valuename, bool force32bit, bool force64bit); -bool MsRegGetValueTypeAndSize(UINT root, char *keyname, char *valuename, UINT *type, UINT *size); -bool MsRegGetValueTypeAndSizeEx(UINT root, char *keyname, char *valuename, UINT *type, UINT *size, bool force32bit); -bool MsRegGetValueTypeAndSizeEx2(UINT root, char *keyname, char *valuename, UINT *type, UINT *size, bool force32bit, bool force64bit); -bool MsRegGetValueTypeAndSizeW(UINT root, char *keyname, char *valuename, UINT *type, UINT *size); -bool MsRegGetValueTypeAndSizeExW(UINT root, char *keyname, char *valuename, UINT *type, UINT *size, bool force32bit); -bool MsRegGetValueTypeAndSizeEx2W(UINT root, char *keyname, char *valuename, UINT *type, UINT *size, bool force32bit, bool force64bit); - -bool MsRegReadValue(UINT root, char *keyname, char *valuename, void **data, UINT *type, UINT *size); -bool MsRegReadValueEx(UINT root, char *keyname, char *valuename, void **data, UINT *type, UINT *size, bool force32bit); bool MsRegReadValueEx2(UINT root, char *keyname, char *valuename, void **data, UINT *type, UINT *size, bool force32bit, bool force64bit); -bool MsRegReadValueW(UINT root, char *keyname, char *valuename, void **data, UINT *type, UINT *size); -bool MsRegReadValueExW(UINT root, char *keyname, char *valuename, void **data, UINT *type, UINT *size, bool force32bit); bool MsRegReadValueEx2W(UINT root, char *keyname, char *valuename, void **data, UINT *type, UINT *size, bool force32bit, bool force64bit); char *MsRegReadStr(UINT root, char *keyname, char *valuename); @@ -692,15 +680,9 @@ BUF *MsRegReadBin(UINT root, char *keyname, char *valuename); BUF *MsRegReadBinEx(UINT root, char *keyname, char *valuename, bool force32bit); BUF *MsRegReadBinEx2(UINT root, char *keyname, char *valuename, bool force32bit, bool force64bit); -bool MsRegNewKey(UINT root, char *keyname); -bool MsRegNewKeyEx(UINT root, char *keyname, bool force32bit); bool MsRegNewKeyEx2(UINT root, char *keyname, bool force32bit, bool force64bit); -bool MsRegWriteValue(UINT root, char *keyname, char *valuename, UINT type, void *data, UINT size); -bool MsRegWriteValueEx(UINT root, char *keyname, char *valuename, UINT type, void *data, UINT size, bool force32bit); bool MsRegWriteValueEx2(UINT root, char *keyname, char *valuename, UINT type, void *data, UINT size, bool force32bit, bool force64bit); -bool MsRegWriteValueW(UINT root, char *keyname, char *valuename, UINT type, void *data, UINT size); -bool MsRegWriteValueExW(UINT root, char *keyname, char *valuename, UINT type, void *data, UINT size, bool force32bit); bool MsRegWriteValueEx2W(UINT root, char *keyname, char *valuename, UINT type, void *data, UINT size, bool force32bit, bool force64bit); bool MsRegWriteStr(UINT root, char *keyname, char *valuename, char *str); @@ -750,18 +732,11 @@ char *MsGetExeFileName(); char *MsGetExeDirName(); wchar_t *MsGetExeDirNameW(); -void MsIsLockedThreadProc(THREAD *thread, void *param); -MS_ISLOCKED *MsNewIsLocked(); -void MsFreeIsLocked(MS_ISLOCKED *d); void MsStartIsLockedThread(); void MsStopIsLockedThread(); -bool MsDetermineIsLockedByWtsApi(); - bool MsShutdown(bool reboot, bool force); -bool MsShutdownEx(bool reboot, bool force, UINT time_limit, char *message); bool MsCheckLogon(wchar_t *username, char *password); -bool MsIsPasswordEmpty(wchar_t *username); TOKEN_LIST *MsEnumNetworkAdapters(char *start_with_name, char *start_with_name_2); TOKEN_LIST *MsEnumNetworkAdaptersNeo(); bool MsGetNeoDriverFilename(char *name, UINT size, char *instance_name); @@ -786,10 +761,6 @@ void MsGenLockFile(wchar_t *name, UINT size, wchar_t *temp_dir); void MsDeleteTempDir(); void MsDeleteAllFile(char *dir); void MsDeleteAllFileW(wchar_t *dir); -char *MsCreateTempFileName(char *name); -char *MsCreateTempFileNameByExt(char *ext); -IO *MsCreateTempFile(char *name); -IO *MsCreateTempFileByExt(char *ext); bool MsInstallVLan(char *tag_name, char *connection_tag_name, char *instance_name, MS_DRIVER_VER *ver); bool MsInstallVLanWithoutLock(char *tag_name, char *connection_tag_name, char *instance_name, MS_DRIVER_VER *ver); @@ -816,7 +787,6 @@ void MsGetDriverPath(char *instance_name, wchar_t *src_inf, wchar_t *src_sys, wc void MsGetDriverPathA(char *instance_name, char *src_inf, char *src_sys, char *dest_inf, char *dest_sys, char *src_cat, char *dst_cat, char *neo_sys); void MsGenMacAddress(UCHAR *mac); char *MsGetMacAddress(char *tag_name, char *instance_name); -char *MsGetNetCfgRegKeyName(char *tag_name, char *instance_name); void MsSetMacAddress(char *tag_name, char *instance_name, char *mac_address); char *MsGetDriverVersion(char *tag_name, char *instance_name); char *MsGetDriverFileName(char *tag_name, char *instance_name); @@ -824,65 +794,36 @@ void MsTest(); void MsInitGlobalNetworkConfig(); void MsDisableNetworkOffloadingEtc(); void MsSetThreadPriorityHigh(); -void MsSetThreadPriorityLow(); void MsSetThreadPriorityIdle(); void MsSetThreadPriorityRealtime(); void MsRestoreThreadPriority(); -char *MsGetLocalAppDataDir(); -char *MsGetCommonAppDataDir(); char *MsGetWindowsDir(); char *MsGetSystem32Dir(); char *MsGetTempDir(); -char *MsGetWindowsDrive(); char *MsGetProgramFilesDir(); -char *MsGetProgramFilesDirX86(); -char *MsGetProgramFilesDirX64(); -char *MsGetCommonStartMenuDir(); -char *MsGetCommonProgramsDir(); char *MsGetCommonStartupDir(); -char *MsGetCommonAppDataDir(); -char *MsGetCommonDesktopDir(); -char *MsGetPersonalStartMenuDir(); -char *MsGetPersonalProgramsDir(); -char *MsGetPersonalStartupDir(); -char *MsGetPersonalAppDataDir(); -char *MsGetPersonalDesktopDir(); -char *MsGetMyDocumentsDir(); char *MsGetMyTempDir(); -char *MsGetUserName(); -char *MsGetUserNameEx(); -char *MsGetWinTempDir(); wchar_t *MsGetWindowsDirW(); wchar_t *MsGetExeFileNameW(); wchar_t *MsGetExeFileDirW(); -wchar_t *MsGetWindowDirW(); wchar_t *MsGetSystem32DirW(); wchar_t *MsGetTempDirW(); -wchar_t *MsGetWindowsDriveW(); -wchar_t *MsGetProgramFilesDirW(); -wchar_t *MsGetProgramFilesDirX86W(); wchar_t *MsGetProgramFilesDirX64W(); wchar_t *MsGetCommonStartMenuDirW(); wchar_t *MsGetCommonProgramsDirW(); wchar_t *MsGetCommonStartupDirW(); -wchar_t *MsGetCommonAppDataDirW(); wchar_t *MsGetCommonDesktopDirW(); wchar_t *MsGetPersonalStartMenuDirW(); wchar_t *MsGetPersonalProgramsDirW(); wchar_t *MsGetPersonalStartupDirW(); wchar_t *MsGetPersonalAppDataDirW(); wchar_t *MsGetPersonalDesktopDirW(); -wchar_t *MsGetMyDocumentsDirW(); -wchar_t *MsGetLocalAppDataDirW(); wchar_t *MsGetMyTempDirW(); wchar_t *MsGetUserNameW(); -wchar_t *MsGetUserNameExW(); -wchar_t *MsGetWinTempDirW(); struct SAFE_TABLE *MsGetSafeTable(); UINT MsGetProcessId(); void MsTerminateProcess(); bool MsIsServiceInstalled(char *name); -bool MsInstallService(char *name, char *title, wchar_t *description, char *path); bool MsInstallServiceExW(char *name, wchar_t *title, wchar_t *description, wchar_t *path, UINT *error_code); bool MsInstallServiceW(char *name, wchar_t *title, wchar_t *description, wchar_t *path); bool MsInstallDeviceDriverW(char *name, wchar_t *title, wchar_t *path, UINT *error_code); @@ -895,21 +836,17 @@ bool MsStopService(char *name); bool MsIsServiceRunning(char *name); bool MsIsTerminalServiceInstalled(); bool MsIsUserSwitchingInstalled(); -bool MsIsTerminalServiceMultiUserInstalled(); UINT MsGetCurrentTerminalSessionId(); bool MsIsTerminalSessionActive(UINT session_id); bool MsIsCurrentTerminalSessionActive(); -bool MsIsCurrentDesktopAvailableForVnc(); wchar_t *MsGetSessionUserName(UINT session_id); UINT MsService(char *name, SERVICE_FUNCTION *start, SERVICE_FUNCTION *stop, UINT icon, char *cmd_line); void MsTestModeW(wchar_t *title, SERVICE_FUNCTION *start, SERVICE_FUNCTION *stop); void MsTestMode(char *title, SERVICE_FUNCTION *start, SERVICE_FUNCTION *stop); void MsServiceMode(SERVICE_FUNCTION *start, SERVICE_FUNCTION *stop); void MsUserModeW(wchar_t *title, SERVICE_FUNCTION *start, SERVICE_FUNCTION *stop, UINT icon); -void MsUserMode(char *title, SERVICE_FUNCTION *start, SERVICE_FUNCTION *stop, UINT icon); bool MsIsUserMode(); void MsTestOnly(); -void MsStopUserModeFromService(); char *MsGetPenCoreDllFileName(); void MsPlaySound(char *name); void MsSetThreadSingleCpu(); @@ -921,10 +858,8 @@ LIST *MsGetProcessList(); LIST *MsGetProcessList9x(); LIST *MsGetProcessListNt(); void MsFreeProcessList(LIST *o); -void MsPrintProcessList(LIST *o); int MsCompareProcessList(void *p1, void *p2); MS_PROCESS *MsSearchProcessById(LIST *o, UINT id); -void MsGetCurrentProcessExeName(char *name, UINT size); void MsGetCurrentProcessExeNameW(wchar_t *name, UINT size); bool MsKillProcess(UINT id); UINT MsKillProcessByExeName(wchar_t *name); @@ -966,9 +901,6 @@ void *MsLoadLibrary(char *name); void *MsLoadLibraryW(wchar_t *name); void *MsLoadLibraryAsDataFile(char *name); void *MsLoadLibraryAsDataFileW(wchar_t *name); -void *MsLoadLibraryRawW(wchar_t *name); -void MsFreeLibrary(void *h); -void *MsGetProcAddress(void *h, char *name); void MsPrintTick(); bool MsDisableIme(); @@ -1000,13 +932,10 @@ void AddWindow(LIST *o, HWND hWnd); void FreeWindowList(LIST *o); LIST *EnumAllChildWindow(HWND hWnd); LIST *EnumAllChildWindowEx(HWND hWnd, bool no_recursion, bool include_ipcontrol, bool no_self); -LIST *EnumAllWindow(); -LIST *EnumAllWindowEx(bool no_recursion, bool include_ipcontrol); LIST *EnumAllTopWindow(); bool MsExecDriverInstaller(char *arg); bool MsIsVista(); -bool MsIsWin2000(); bool MsIsWin2000OrGreater(); bool MsIsWinXPOrGreater(); void MsRegistWindowsFirewallEx(char *title, char *exe); @@ -1016,108 +945,47 @@ bool MsIsX64(); bool MsIsIA64(); void *MsDisableWow64FileSystemRedirection(); void MsRestoreWow64FileSystemRedirection(void *p); -void MsSetWow64FileSystemRedirectionEnable(bool enable); bool MsIsWindows10(); bool MsIsWindows81(); bool MsIsWindows8(); bool MsIsWindows7(); bool MsIsInfCatalogRequired(); -bool MsCheckFileDigitalSignature(HWND hWnd, char *name, bool *danger); bool MsCheckFileDigitalSignatureW(HWND hWnd, wchar_t *name, bool *danger); bool MsGetProcessExeName(char *path, UINT size, UINT id); -bool MsGetProcessExeNameW(wchar_t *path, UINT size, UINT id); bool MsGetWindowOwnerProcessExeName(char *path, UINT size, HWND hWnd); -bool MsGetWindowOwnerProcessExeNameW(wchar_t *path, UINT size, HWND hWnd); -void *MsRunAsUserEx(char *filename, char *arg, bool hide); void *MsRunAsUserExW(wchar_t *filename, wchar_t *arg, bool hide); -void *MsRunAsUserExInner(char *filename, char *arg, bool hide); void *MsRunAsUserExInnerW(wchar_t *filename, wchar_t *arg, bool hide); UINT MsGetCursorPosHash(); -bool MsIsProcessExists(char *exename); -bool MsIsProcessExistsW(wchar_t *exename); -bool MsGetProcessNameFromId(wchar_t *exename, UINT exename_size, UINT pid); -bool MsIsProcessIdExists(UINT pid); void MsGetComputerName(char *name, UINT size); -void MsGetComputerNameFull(wchar_t *name, UINT size); void MsGetComputerNameFullEx(wchar_t *name, UINT size, bool with_cache); -void MsNoSleepThread(THREAD *thread, void *param); -void MsNoSleepThreadVista(THREAD *thread, void *param); UINT64 MsGetScreenSaverTimeout(); -void *MsNoSleepStart(bool no_screensaver); -void MsNoSleepEnd(void *p); -bool MsIsRemoteDesktopAvailable(); -bool MsIsRemoteDesktopCanEnableByRegistry(); -bool MsIsRemoteDesktopEnabled(); -bool MsEnableRemoteDesktop(); -void MsSetFileToHidden(char *name); -void MsSetFileToHiddenW(wchar_t *name); -bool MsGetFileVersion(char *name, UINT *v1, UINT *v2, UINT *v3, UINT *v4); -bool MsGetFileVersionW(wchar_t *name, UINT *v1, UINT *v2, UINT *v3, UINT *v4); - -bool MsExtractCabinetFileFromExe(char *exe, char *cab); -bool MsExtractCabinetFileFromExeW(wchar_t *exe, wchar_t *cab); -BUF *MsExtractResourceFromExe(char *exe, char *type, char *name); -BUF *MsExtractResourceFromExeW(wchar_t *exe, char *type, char *name); -bool MsExtractCab(char *cab_name, char *dest_dir_name); -bool MsExtractCabW(wchar_t *cab_name, wchar_t *dest_dir_name); -bool MsGetCabarcExeFilename(char *name, UINT size); -bool MsGetCabarcExeFilenameW(wchar_t *name, UINT size); -bool MsExtractCabFromMsi(char *msi, char *cab); -bool MsExtractCabFromMsiW(wchar_t *msi, wchar_t *cab); -bool MsIsDirectory(char *name); -bool MsIsDirectoryW(wchar_t *name); -bool MsUniIsDirectory(wchar_t *name); -bool MsUniFileDelete(wchar_t *name); -bool MsUniDirectoryDelete(wchar_t *name); bool MsUniMakeDir(wchar_t *name); void MsUniMakeDirEx(wchar_t *name); -void MsMakeDirEx(char *name); bool MsMakeDir(char *name); -bool MsDirectoryDelete(char *name); -bool MsFileDelete(char *name); bool MsExecute(char *exe, char *arg); bool MsExecute2(char *exe, char *arg, bool runas); bool MsExecuteW(wchar_t *exe, wchar_t *arg); bool MsExecute2W(wchar_t *exe, wchar_t *arg, bool runas); bool MsExecuteEx(char *exe, char *arg, void **process_handle); bool MsExecuteEx2(char *exe, char *arg, void **process_handle, bool runas); -bool MsExecuteExW(wchar_t *exe, wchar_t *arg, void **process_handle); bool MsExecuteEx2W(wchar_t *exe, wchar_t *arg, void **process_handle, bool runas); void MsCloseHandle(void *handle); UINT MsWaitProcessExit(void *process_handle); -bool MsIsFileLocked(char *name); -bool MsIsFileLockedW(wchar_t *name); -bool MsIsLocalDrive(char *name); -bool MsIsLocalDriveW(wchar_t *name); void MsUpdateSystem(); -bool MsGetPhysicalMacAddressFromNetbios(void *address); -bool MsGetPhysicalMacAddressFromApi(void *address); -bool MsGetPhysicalMacAddress(void *address); -bool MsIsUseWelcomeLogin(); UINT64 MsGetHiResCounter(); double MsGetHiResTimeSpan(UINT64 diff); UINT64 MsGetHiResTimeSpanUSec(UINT64 diff); -BUF *MsRegSubkeysToBuf(UINT root, char *keyname, bool force32bit, bool force64bit); -void MsBufToRegSubkeys(UINT root, char *keyname, BUF *b, bool overwrite, bool force32bit, bool force64bit); -void MsRegDeleteSubkeys(UINT root, char *keyname, bool force32bit, bool force64bit); void MsRestartMMCSS(); bool MsIsMMCSSNetworkThrottlingEnabled(); void MsSetMMCSSNetworkThrottlingEnable(bool enable); void MsSetShutdownParameters(UINT level, UINT flag); -void MsChangeIconOnTrayEx2(void *icon, wchar_t *tooltip, wchar_t *info_title, wchar_t *info, UINT info_flags); -bool MsIsTrayInited(); -UINT MsGetClipboardOwnerProcessId(); -void MsDeleteClipboard(); -void *MsInitEventLog(wchar_t *src_name); -void MsFreeEventLog(void *p); -bool MsWriteEventLog(void *p, UINT type, wchar_t *str); bool MsIsWinXPOrWinVista(); bool MsGetFileInformation(void *h, void *info); void MsSetErrorModeToSilent(); @@ -1144,7 +1012,6 @@ bool MsGetMsiInstalledDir(char *component_code, wchar_t *dir, UINT dir_size); bool MsMsiUninstall(char *product_code, HWND hWnd, bool *reboot_required); UINT MsGetUserLocaleId(); -UINT MsGetSystemLocaleId(); bool MsIsCurrentUserLocaleIdJapanese(); TOKEN_LIST *MsEnumResources(void *hModule, char *type); @@ -1206,7 +1073,6 @@ HANDLE MsCreateUserToken(); SID *MsGetSidFromAccountName(char *name); void MsFreeSid(SID *sid); bool CALLBACK MsEnumResourcesInternalProc(HMODULE hModule, const char *type, char *name, LONG_PTR lParam); -void CALLBACK MsScmDispatcher(DWORD argc, LPTSTR *argv); LRESULT CALLBACK MsSuspendHandlerWindowProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam); void MsSuspendHandlerThreadProc(THREAD *thread, void *param);