function_name
stringlengths 1
80
| function
stringlengths 14
10.6k
| comment
stringlengths 12
8.02k
| normalized_comment
stringlengths 6
6.55k
|
|---|---|---|---|
MsGetShortPathNameA
|
bool MsGetShortPathNameA(char *long_path, char *short_path, UINT short_path_size)
{
// Validate arguments
if (long_path == NULL || short_path == NULL)
{
return false;
}
if (GetShortPathNameA(long_path, short_path, short_path_size) == 0)
{
StrCpy(short_path, short_path_size, long_path);
return false;
}
return true;
}
|
/* Get the short file name*/
|
Get the short file name
|
MsKillProcess
|
bool MsKillProcess(UINT id)
{
HANDLE h;
// Validate arguments
if (id == 0)
{
return false;
}
h = OpenProcess(PROCESS_TERMINATE, FALSE, id);
if (h == NULL)
{
return false;
}
if (TerminateProcess(h, 0) == FALSE)
{
CloseHandle(h);
return false;
}
CloseHandle(h);
return true;
}
|
/* Kill the specified process*/
|
Kill the specified process
|
MsGetCurrentProcessExeNameW
|
void MsGetCurrentProcessExeNameW(wchar_t *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);
UniStrCpy(name, size, p->ExeFilenameW);
}
else
{
UniStrCpy(name, size, MsGetExeFileNameW());
}
MsFreeProcessList(o);
}
|
/* Get the current EXE file name*/
|
Get the current EXE file name
|
MsSearchProcessById
|
MS_PROCESS *MsSearchProcessById(LIST *o, UINT id)
{
MS_PROCESS *p, t;
// Validate arguments
if (o == NULL)
{
return NULL;
}
Zero(&t, sizeof(t));
t.ProcessId = id;
p = Search(o, &t);
return p;
}
|
/* Search the process by the process ID*/
|
Search the process by the process ID
|
MsCompareProcessList
|
int MsCompareProcessList(void *p1, void *p2)
{
MS_PROCESS *e1, *e2;
if (p1 == NULL || p2 == NULL)
{
return 0;
}
e1 = *(MS_PROCESS **)p1;
e2 = *(MS_PROCESS **)p2;
if (e1 == NULL || e2 == NULL)
{
return 0;
}
if (e1->ProcessId > e2->ProcessId)
{
return 1;
}
else if (e1->ProcessId < e2->ProcessId)
{
return -1;
}
else
{
return 0;
}
}
|
/* Compare the Process List items*/
|
Compare the Process List items
|
MsFreeProcessList
|
void MsFreeProcessList(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);
Free(p);
}
ReleaseList(o);
}
|
/* Release of the process list*/
|
Release of the process list
|
MsGetProcessList
|
LIST *MsGetProcessList()
{
if (MsIsNt() == false)
{
// Windows 9x
return MsGetProcessList9x();
}
else
{
// Windows NT, 2000, XP
return MsGetProcessListNt();
}
}
|
/* Get the Process List*/
|
Get the Process List
|
MsSetThreadSingleCpu
|
void MsSetThreadSingleCpu()
{
SetThreadAffinityMask(GetCurrentThread(), 1);
}
|
/* Force to run the current thread on a single CPU*/
|
Force to run the current thread on a single CPU
|
MsPlaySound
|
void MsPlaySound(char *name)
{
char tmp[MAX_SIZE];
char wav[MAX_SIZE];
char *temp;
BUF *b;
// Validate arguments
if (name == NULL)
{
return;
}
Format(tmp, sizeof(tmp), "|%s", name);
b = ReadDump(tmp);
if (b == NULL)
{
return;
}
temp = MsGetMyTempDir();
Format(wav, sizeof(tmp), "%s\\%s", temp, name);
DumpBuf(b, wav);
PlaySound(wav, NULL, SND_ASYNC | SND_FILENAME | SND_NODEFAULT);
FreeBuf(b);
}
|
/* Playback of sound*/
|
Playback of sound
|
MsRestoreIconOnTray
|
void MsRestoreIconOnTray()
{
if (tray_inited == false)
{
return;
}
if (MsIsNt() == false)
{
Shell_NotifyIcon(NIM_ADD, &nid);
}
else
{
Shell_NotifyIconW(NIM_ADD, &nid_nt);
}
}
|
/* Restore the icon in the task tray*/
|
Restore the icon in the task tray
|
MsChangeIconOnTray
|
void MsChangeIconOnTray(HICON icon, wchar_t *tooltip)
{
MsChangeIconOnTrayEx(icon, tooltip, NULL, NULL, NIIF_NONE, false);
}
|
/* Change the icon in the task tray*/
|
Change the icon in the task tray
|
MsHideIconOnTray
|
void MsHideIconOnTray()
{
if (MsIsNt() == false)
{
Shell_NotifyIcon(NIM_DELETE, &nid);
}
else
{
Shell_NotifyIconW(NIM_DELETE, &nid_nt);
}
tray_inited = false;
}
|
/* Remove the icon in the task tray*/
|
Remove the icon in the task tray
|
MsInsertMenu
|
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;
}
|
/* Insert a menu item*/
|
Insert a menu item
|
MsAppendMenu
|
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;
}
|
/* Adding a menu item*/
|
Adding a menu item
|
MsGetPenCoreDllFileName
|
char *MsGetPenCoreDllFileName()
{
/*if (Is64())
{
if (IsX64())
{
return PENCORE_DLL_NAME_X64;
}
else
{
return PENCORE_DLL_NAME_IA64;
}
}
else*/
{
return PENCORE_DLL_NAME;
}
}
|
/* Get the name of PenCore.dll*/
|
Get the name of PenCore.dll
|
MsIsUserMode
|
bool MsIsUserMode()
{
return is_usermode;
}
|
/* Get whether this instance is in user mode*/
|
Get whether this instance is in user mode
|
MsTestOnly
|
void MsTestOnly()
{
g_start();
GetLine(NULL, 0);
g_stop();
_exit(0);
}
|
/* Only run the test (for debugging)*/
|
Only run the test (for debugging)
|
MsStopUserModeSvc
|
void MsStopUserModeSvc(char *svc_name)
{
void *p;
// Validate arguments
if (svc_name == NULL)
{
return;
}
p = MsCreateUserModeSvcGlocalPulse(svc_name);
if (p == NULL)
{
return;
}
MsSendGlobalPulse(p);
MsCloseGlobalPulse(p);
}
|
/* Stop the user-mode service*/
|
Stop the user-mode service
|
MsCreateUserModeSvcGlocalPulse
|
void *MsCreateUserModeSvcGlocalPulse(char *svc_name)
{
char name[MAX_SIZE];
// Validate arguments
if (svc_name == NULL)
{
return NULL;
}
MsGenerateUserModeSvcGlobalPulseName(name, sizeof(name), svc_name);
return MsOpenOrCreateGlobalPulse(name);
}
|
/* Creating a global pulse for user-mode service*/
|
Creating a global pulse for user-mode service
|
MsGenerateUserModeSvcGlobalPulseName
|
void MsGenerateUserModeSvcGlobalPulseName(char *name, UINT size, char *svc_name)
{
wchar_t tmp[MAX_SIZE];
UCHAR hash[SHA1_SIZE];
// Validate arguments
if (name == NULL || svc_name == NULL)
{
return;
}
UniFormat(tmp, sizeof(tmp), L"usersvc_%S_@_%s", svc_name, MsGetUserNameW());
UniTrim(tmp);
UniStrUpper(tmp);
Sha1(hash, tmp, UniStrLen(tmp) * sizeof(wchar_t));
BinToStr(name, size, hash, sizeof(hash));
}
|
/* Get the global pulse name for the user-mode service*/
|
Get the global pulse name for the user-mode service
|
MsBeginVLanCard
|
void MsBeginVLanCard()
{
Inc(vlan_card_counter);
}
|
/* Declare the beginning of use of a VLAN card*/
|
Declare the beginning of use of a VLAN card
|
MsEndVLanCard
|
void MsEndVLanCard()
{
Dec(vlan_card_counter);
}
|
/* Declare the ending of use of a VLAN card*/
|
Declare the ending of use of a VLAN card
|
MsIsVLanCardShouldStop
|
bool MsIsVLanCardShouldStop()
{
return vlan_card_should_stop_flag;
}
|
/* Return the flag whether the VLAN cards must be stopped*/
|
Return the flag whether the VLAN cards must be stopped
|
MsNewSuspendHandler
|
MS_SUSPEND_HANDLER *MsNewSuspendHandler()
{
THREAD *t;
MS_SUSPEND_HANDLER *h;
if (Inc(suspend_handler_singleton) >= 2)
{
Dec(suspend_handler_singleton);
return NULL;
}
vlan_card_should_stop_flag = false;
vlan_is_in_suspend_mode = false;
vlan_suspend_mode_begin_tick = 0;
h = ZeroMalloc(sizeof(MS_SUSPEND_HANDLER));
t = NewThread(MsSuspendHandlerThreadProc, h);
WaitThreadInit(t);
h->Thread = t;
return h;
}
|
/* New suspend handler*/
|
New suspend handler
|
MsUserModeGlobalPulseRecvThread
|
void MsUserModeGlobalPulseRecvThread(THREAD *thread, void *param)
{
MS_USERMODE_SVC_PULSE_THREAD_PARAM *p = (MS_USERMODE_SVC_PULSE_THREAD_PARAM *)param;
// Validate arguments
if (thread == NULL || p == NULL)
{
return;
}
while (p->Halt == false)
{
if (MsWaitForGlobalPulse(p->GlobalPulse, INFINITE))
{
break;
}
}
if (p->hWnd != NULL)
{
PostMessageA(p->hWnd, WM_CLOSE, 0, 0);
}
}
|
/* The thread that wait for global pulse to stop the user mode service*/
|
The thread that wait for global pulse to stop the user mode service
|
MsServiceStoperMainThread
|
void MsServiceStoperMainThread(THREAD *t, void *p)
{
// Stopping procedure
g_stop();
}
|
/* Service stopping procedure main thread*/
|
Service stopping procedure main thread
|
MsTestMode
|
void MsTestMode(char *title, SERVICE_FUNCTION *start, SERVICE_FUNCTION *stop)
{
wchar_t *title_w = CopyStrToUni(title);
MsTestModeW(title_w, start, stop);
Free(title_w);
}
|
/* Start as a test mode*/
|
Start as a test mode
|
MsWriteCallingServiceManagerProcessId
|
void MsWriteCallingServiceManagerProcessId(char *svcname, UINT pid)
{
char tmp[MAX_PATH];
Format(tmp, sizeof(tmp), SVC_CALLING_SM_PROCESS_ID_KEY, svcname);
if (pid != 0)
{
MsRegWriteInt(REG_LOCAL_MACHINE, tmp, SVC_CALLING_SM_PROCESS_ID_VALUE, pid);
MsRegWriteInt(REG_CURRENT_USER, tmp, SVC_CALLING_SM_PROCESS_ID_VALUE, pid);
}
else
{
MsRegDeleteValue(REG_LOCAL_MACHINE, tmp, SVC_CALLING_SM_PROCESS_ID_VALUE);
MsRegDeleteKey(REG_LOCAL_MACHINE, tmp);
MsRegDeleteValue(REG_CURRENT_USER, tmp, SVC_CALLING_SM_PROCESS_ID_VALUE);
MsRegDeleteKey(REG_CURRENT_USER, tmp);
}
}
|
/* Write the process ID of the process which is calling the service manager*/
|
Write the process ID of the process which is calling the service manager
|
MsReadCallingServiceManagerProcessId
|
UINT MsReadCallingServiceManagerProcessId(char *svcname, bool current_user)
{
char tmp[MAX_PATH];
// Validate arguments
if (svcname == NULL)
{
return 0;
}
Format(tmp, sizeof(tmp), SVC_CALLING_SM_PROCESS_ID_KEY, svcname);
return MsRegReadInt(current_user ? REG_CURRENT_USER : REG_LOCAL_MACHINE, tmp, SVC_CALLING_SM_PROCESS_ID_VALUE);
}
|
/* Get the process ID of the process which is calling the service manager*/
|
Get the process ID of the process which is calling the service manager
|
MsGetSessionUserName
|
wchar_t *MsGetSessionUserName(UINT session_id)
{
if (MsIsTerminalServiceInstalled() || MsIsUserSwitchingInstalled())
{
wchar_t *ret;
wchar_t *name;
UINT size = 0;
if (ms->nt->WTSQuerySessionInformation(WTS_CURRENT_SERVER_HANDLE, session_id,
WTSUserName, (wchar_t *)&name, &size) == false)
{
return NULL;
}
if (name == NULL || UniStrLen(name) == 0)
{
ret = NULL;
}
else
{
ret = UniCopyStr(name);
}
ms->nt->WTSFreeMemory(name);
return ret;
}
return NULL;
}
|
/* Get the user name of the specified session*/
|
Get the user name of the specified session
|
MsIsCurrentTerminalSessionActive
|
bool MsIsCurrentTerminalSessionActive()
{
return MsIsTerminalSessionActive(MsGetCurrentTerminalSessionId());
}
|
/* Get whether the current terminal session is active*/
|
Get whether the current terminal session is active
|
MsIsTerminalSessionActive
|
bool MsIsTerminalSessionActive(UINT session_id)
{
if (MsIsTerminalServiceInstalled() || MsIsUserSwitchingInstalled())
{
UINT *status = NULL;
UINT size = sizeof(status);
bool active = true;
if (ms->nt->WTSQuerySessionInformation(WTS_CURRENT_SERVER_HANDLE, session_id,
WTSConnectState, (wchar_t *)&status, &size) == false)
{
return true;
}
switch (*status)
{
case WTSDisconnected:
case WTSShadow:
case WTSIdle:
case WTSDown:
case WTSReset:
active = false;
break;
}
ms->nt->WTSFreeMemory(status);
return active;
}
return true;
}
|
/* Get whether the specified terminal session is active*/
|
Get whether the specified terminal session is active
|
MsGetCurrentTerminalSessionId
|
UINT MsGetCurrentTerminalSessionId()
{
if (MsIsTerminalServiceInstalled() || MsIsUserSwitchingInstalled())
{
UINT ret;
UINT *session_id = NULL;
UINT size = sizeof(session_id);
if (ms->nt->WTSQuerySessionInformation(WTS_CURRENT_SERVER_HANDLE, WTS_CURRENT_SESSION,
WTSSessionId, (wchar_t *)&session_id, &size) == false)
{
return 0;
}
ret = *session_id;
ms->nt->WTSFreeMemory(session_id);
return ret;
}
return 0;
}
|
/* Get the current terminal session ID*/
|
Get the current terminal session ID
|
MsIsWin2000OrGreater
|
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 2000 or later*/
|
Examine whether Windows 2000 or later
|
MsIsWinXPOrGreater
|
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 Windows XP or later*/
|
Examine whether Windows XP or later
|
MsStartService
|
bool MsStartService(char *name)
{
return MsStartServiceEx(name, NULL);
}
|
/* Start the service*/
|
Start the service
|
MsInstallServiceW
|
bool MsInstallServiceW(char *name, wchar_t *title, wchar_t *description, wchar_t *path)
{
return MsInstallServiceExW(name, title, description, path, NULL);
}
|
/* Install the service*/
|
Install the service
|
MsIsServiceInstalled
|
bool MsIsServiceInstalled(char *name)
{
SC_HANDLE sc;
SC_HANDLE service;
bool ret = false;
// Validate arguments
if (name == NULL)
{
return false;
}
if (ms->IsNt == false)
{
return false;
}
sc = ms->nt->OpenSCManager(NULL, NULL, GENERIC_READ);
if (sc == NULL)
{
return false;
}
service = ms->nt->OpenService(sc, name, GENERIC_READ);
if (service != NULL)
{
ret = true;
}
ms->nt->CloseServiceHandle(service);
ms->nt->CloseServiceHandle(sc);
return ret;
}
|
/* Check whether the specified service is installed*/
|
Check whether the specified service is installed
|
MsTerminateProcess
|
void MsTerminateProcess()
{
TerminateProcess(GetCurrentProcess(), 0);
_exit(0);
}
|
/* Kill the process*/
|
Kill the process
|
MsGetProcessId
|
UINT MsGetProcessId()
{
return GetCurrentProcessId();
}
|
/* Get the Process ID*/
|
Get the Process ID
|
MsSetThreadPriorityIdle
|
void MsSetThreadPriorityIdle()
{
SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_IDLE);
}
|
/* Lower the priority of the thread to lowest*/
|
Lower the priority of the thread to lowest
|
MsSetThreadPriorityHigh
|
void MsSetThreadPriorityHigh()
{
SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_ABOVE_NORMAL);
}
|
/* Raise the priority of a thread*/
|
Raise the priority of a thread
|
MsSetThreadPriorityRealtime
|
void MsSetThreadPriorityRealtime()
{
SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_ABOVE_NORMAL);
SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_HIGHEST);
SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_TIME_CRITICAL);
}
|
/* Raise the priority of the thread to highest*/
|
Raise the priority of the thread to highest
|
MsRestoreThreadPriority
|
void MsRestoreThreadPriority()
{
SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_NORMAL);
}
|
/* Restore the priority of the thread*/
|
Restore the priority of the thread
|
MsIsShouldShowTcpConfigApp
|
bool MsIsShouldShowTcpConfigApp()
{
MS_TCP tcp1, tcp2;
if (MsIsTcpConfigSupported() == false)
{
return false;
}
MsGetTcpConfig(&tcp1);
if (MsLoadTcpConfigReg(&tcp2) == false)
{
return true;
}
if (Cmp(&tcp1, &tcp2, sizeof(MS_TCP) != 0))
{
return true;
}
return false;
}
|
/* Check whether should show the TCP setting application*/
|
Check whether should show the TCP setting application
|
MsApplyTcpConfig
|
void MsApplyTcpConfig()
{
if (MsIsTcpConfigSupported())
{
MS_TCP tcp;
if (MsLoadTcpConfigReg(&tcp))
{
MsSetTcpConfig(&tcp);
}
}
}
|
/* Apply the temporary settings data of registry to the TCP parameter of the Windows*/
|
Apply the temporary settings data of registry to the TCP parameter of the Windows
|
MsIsTcpConfigSupported
|
bool MsIsTcpConfigSupported()
{
if (MsIsNt() && MsIsAdmin())
{
UINT type = GetOsInfo()->OsType;
if (GET_KETA(type, 100) >= 2)
{
return true;
}
}
return false;
}
|
/* Check whether the dynamic configuration of TCP is supported in current state*/
|
Check whether the dynamic configuration of TCP is supported in current state
|
MsLoadTcpConfigReg
|
bool MsLoadTcpConfigReg(MS_TCP *tcp)
{
// Validate arguments
if (tcp == NULL)
{
return false;
}
if (MsIsNt())
{
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
{
return false;
}
}
|
/* Read the TCP settings from the registry setting*/
|
Read the TCP settings from the registry setting
|
MsDeleteTcpConfigReg
|
void MsDeleteTcpConfigReg()
{
if (MsIsNt() && MsIsAdmin())
{
MsRegDeleteKeyEx(REG_LOCAL_MACHINE, MS_REG_TCP_SETTING_KEY, true);
}
}
|
/* Remove the TCP settings from the registry*/
|
Remove the TCP settings from the registry
|
MsSaveTcpConfigReg
|
void MsSaveTcpConfigReg(MS_TCP *tcp)
{
// Validate arguments
if (tcp == NULL)
{
return;
}
if (MsIsNt() && 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);
}
}
|
/* Write the TCP settings to the registry setting*/
|
Write the TCP settings to the registry setting
|
MsUpgradeVLan
|
bool MsUpgradeVLan(char *tag_name, char *connection_tag_name, char *instance_name, MS_DRIVER_VER *ver)
{
bool ret;
Lock(vlan_lock);
{
ret = MsUpgradeVLanWithoutLock(tag_name, connection_tag_name, instance_name, ver);
}
Unlock(vlan_lock);
return ret;
}
|
/* Upgrade the virtual LAN card*/
|
Upgrade the virtual LAN card
|
MsWin9xTest
|
void MsWin9xTest()
{
}
|
/* Test for Windows 9x*/
|
Test for Windows 9x
|
MsEnumChildWindowProc
|
bool CALLBACK MsEnumChildWindowProc(HWND hWnd, LPARAM lParam)
{
LIST *o = (LIST *)lParam;
if (o != NULL)
{
MsEnumChildWindows(o, hWnd);
}
return true;
}
|
/* Child window enumeration procedure*/
|
Child window enumeration procedure
|
MsEnumChildWindows
|
LIST *MsEnumChildWindows(LIST *o, HWND hWnd)
{
// Validate arguments
if (hWnd == NULL)
{
return NULL;
}
if (o == NULL)
{
o = NewListFast(NULL);
}
MsAddWindowToList(o, hWnd);
EnumChildWindows(hWnd, MsEnumChildWindowProc, (LPARAM)o);
return o;
}
|
/* Enumerate specified window and all the its child windows*/
|
Enumerate specified window and all the its child windows
|
MsAddWindowToList
|
void MsAddWindowToList(LIST *o, HWND hWnd)
{
// Validate arguments
if (o == NULL || hWnd == NULL)
{
return;
}
if (IsInList(o, hWnd) == false)
{
Add(o, hWnd);
}
}
|
/* Add a window to the list*/
|
Add a window to the list
|
MsEnumThreadWindowProc
|
bool CALLBACK MsEnumThreadWindowProc(HWND hWnd, LPARAM lParam)
{
LIST *o = (LIST *)lParam;
if (o == NULL)
{
return false;
}
MsEnumChildWindows(o, hWnd);
return true;
}
|
/* Enumeration of the window that the thread owns*/
|
Enumeration of the window that the thread owns
|
EnumAllChildWindow
|
LIST *EnumAllChildWindow(HWND hWnd)
{
return EnumAllChildWindowEx(hWnd, false, false, false);
}
|
/* Enumerate the child windows of all that is in the specified window*/
|
Enumerate the child windows of all that is in the specified window
|
FreeWindowList
|
void FreeWindowList(LIST *o)
{
UINT i;
// Validate arguments
if (o == NULL)
{
return;
}
for (i = 0;i < LIST_NUM(o);i++)
{
HWND *e = LIST_DATA(o, i);
Free(e);
}
ReleaseList(o);
}
|
/* Release of the window list*/
|
Release of the window list
|
AddWindow
|
void AddWindow(LIST *o, HWND hWnd)
{
HWND t, *e;
// Validate arguments
if (o == NULL || hWnd == NULL)
{
return;
}
t = hWnd;
if (Search(o, &t) != NULL)
{
return;
}
e = ZeroMalloc(sizeof(HWND));
*e = hWnd;
Insert(o, e);
}
|
/* Add a window to the window list*/
|
Add a window to the window list
|
CmpWindowList
|
int CmpWindowList(void *p1, void *p2)
{
HWND *h1, *h2;
if (p1 == NULL || p2 == NULL)
{
return 0;
}
h1 = *(HWND **)p1;
h2 = *(HWND **)p2;
if (h1 == NULL || h2 == NULL)
{
return 0;
}
return Cmp(h1, h2, sizeof(HWND));
}
|
/* Comparison of the window list items*/
|
Comparison of the window list items
|
NewWindowList
|
LIST *NewWindowList()
{
return NewListFast(CmpWindowList);
}
|
/* Creating a new window list*/
|
Creating a new window list
|
MsIsVista
|
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 Vista or later*/
|
Determine whether it's Windows Vista or later
|
MsIsWindows7
|
bool MsIsWindows7()
{
OS_INFO *info = GetOsInfo();
if (info == NULL)
{
return false;
}
if (OS_IS_WINDOWS_NT(info->OsType))
{
if (GET_KETA(info->OsType, 100) >= 6)
{
return true;
}
}
return false;
}
|
/* Determine whether it's Windows 7 or later*/
|
Determine whether it's Windows 7 or later
|
MsIsWindows10
|
bool MsIsWindows10()
{
OS_INFO *info = GetOsInfo();
if (info == NULL)
{
return false;
}
if (OS_IS_WINDOWS_NT(info->OsType))
{
if (GET_KETA(info->OsType, 100) == 7)
{
if (GET_KETA(info->OsType, 1) >= 2)
{
return true;
}
}
if (GET_KETA(info->OsType, 100) >= 8)
{
return true;
}
}
return false;
}
|
/* Determine whether it's Windows 10 or later*/
|
Determine whether it's Windows 10 or later
|
MsIsWindows81
|
bool MsIsWindows81()
{
OS_INFO *info = GetOsInfo();
if (info == NULL)
{
return false;
}
if (OS_IS_WINDOWS_NT(info->OsType))
{
if (GET_KETA(info->OsType, 100) == 7)
{
if (GET_KETA(info->OsType, 1) >= 1)
{
return true;
}
}
if (GET_KETA(info->OsType, 100) >= 8)
{
return true;
}
}
return false;
}
|
/* Determine whether it's Windows 8.1 or later*/
|
Determine whether it's Windows 8.1 or later
|
MsIsWindows8
|
bool MsIsWindows8()
{
OS_INFO *info = GetOsInfo();
if (info == NULL)
{
return false;
}
if (OS_IS_WINDOWS_NT(info->OsType))
{
if (GET_KETA(info->OsType, 100) >= 7)
{
return true;
}
}
return false;
}
|
/* Determine whether it's Windows 8 or later*/
|
Determine whether it's Windows 8 or later
|
MsIsInfCatalogRequired
|
bool MsIsInfCatalogRequired()
{
return MsIsWindows8();
}
|
/* Whether INF catalog signature is required*/
|
Whether INF catalog signature is required
|
MsGetWindowOwnerProcessExeName
|
bool MsGetWindowOwnerProcessExeName(char *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 (MsGetProcessExeName(path, size, procId) == false)
{
return false;
}
return true;
}
|
/* Get the process path of the owner of the window*/
|
Get the process path of the owner of the window
|
MsGetProcessExeName
|
bool MsGetProcessExeName(char *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;
StrCpy(path, size, proc->ExeFilename);
}
MsFreeProcessList(o);
return ret;
}
|
/* Get the process path from process ID*/
|
Get the process path from process ID
|
MsNoWarningSoundInit
|
char *MsNoWarningSoundInit()
{
char *ret = MsRegReadStr(REG_CURRENT_USER, "AppEvents\\Schemes\\Apps\\.Default\\SystemAsterisk\\.Current", "");
if (IsEmptyStr(ret))
{
Free(ret);
ret = NULL;
}
else
{
MsRegWriteStr(REG_CURRENT_USER,
"AppEvents\\Schemes\\Apps\\.Default\\SystemAsterisk\\.Current",
"", "");
}
return ret;
}
|
/* Initialize the procedure to turn off the warning sound*/
|
Initialize the procedure to turn off the warning sound
|
MsNoWarningSoundFree
|
void MsNoWarningSoundFree(char *s)
{
// Validate arguments
if (s == NULL)
{
return;
}
MsRegWriteStrExpand(REG_CURRENT_USER,
"AppEvents\\Schemes\\Apps\\.Default\\SystemAsterisk\\.Current",
"", s);
Free(s);
}
|
/* Release of procedure to turn off the warning sound*/
|
Release of procedure to turn off the warning sound
|
MsInitNoWarning
|
NO_WARNING *MsInitNoWarning()
{
return MsInitNoWarningEx(0);
}
|
/* The start of the procedure to suppress the warning*/
|
The start of the procedure to suppress the warning
|
MsFreeNoWarning
|
void MsFreeNoWarning(NO_WARNING *nw)
{
// Validate arguments
if (nw == NULL)
{
return;
}
nw->Halt = true;
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);
}
|
/* End of the procedure to suppress the warning*/
|
End of the procedure to suppress the warning
|
MsGetInfCatalogDir
|
void MsGetInfCatalogDir(char *dst, UINT size)
{
// Validate arguments
if (dst == NULL)
{
return;
}
Format(dst, size, "|DriverPackages\\%s\\%s", (MsIsWindows10() ? "Neo6_Win10" : "Neo6_Win8"), (MsIsX64() ? "x64" : "x86"));
}
|
/* Obtain the name of the directory that the inf catalog file is stored*/
|
Obtain the name of the directory that the inf catalog file is stored
|
MsIsValidVLanInstanceNameForInfCatalog
|
bool MsIsValidVLanInstanceNameForInfCatalog(char *instance_name)
{
char src_dir[MAX_SIZE];
char tmp[MAX_SIZE];
bool ret;
// Validate arguments
if (instance_name == NULL)
{
return false;
}
MsGetInfCatalogDir(src_dir, sizeof(src_dir));
Format(tmp, sizeof(tmp), "%s\\Neo6_%s_%s.inf", src_dir, (MsIsX64() ? "x64" : "x86"), instance_name);
ret = IsFile(tmp);
return ret;
}
|
/* Examine whether the virtual LAN card name can be used as a instance name of the VLAN*/
|
Examine whether the virtual LAN card name can be used as a instance name of the VLAN
|
MsInstallVLan
|
bool MsInstallVLan(char *tag_name, char *connection_tag_name, char *instance_name, MS_DRIVER_VER *ver)
{
bool ret;
Lock(vlan_lock);
{
ret = MsInstallVLanWithoutLock(tag_name, connection_tag_name, instance_name, ver);
}
Unlock(vlan_lock);
return ret;
}
|
/* Install a virtual LAN card*/
|
Install a virtual LAN card
|
MsIsDeviceRunning
|
bool MsIsDeviceRunning(HDEVINFO info, SP_DEVINFO_DATA *dev_info_data)
{
SP_DEVINFO_LIST_DETAIL_DATA detail;
UINT status = 0, problem = 0;
// Validate arguments
if (info == NULL || dev_info_data == NULL)
{
return false;
}
Zero(&detail, sizeof(detail));
detail.cbSize = sizeof(detail);
if (SetupDiGetDeviceInfoListDetail(info, &detail) == false ||
ms->nt->CM_Get_DevNode_Status_Ex(&status, &problem, dev_info_data->DevInst,
0, detail.RemoteMachineHandle) != CR_SUCCESS)
{
return false;
}
if (status & 8)
{
return true;
}
else
{
return false;
}
}
|
/* Examine whether the specified device is operating*/
|
Examine whether the specified device is operating
|
MsStopDevice
|
bool MsStopDevice(HDEVINFO info, SP_DEVINFO_DATA *dev_info_data)
{
SP_PROPCHANGE_PARAMS p;
// Validate arguments
if (info == NULL || dev_info_data == NULL)
{
return false;
}
Zero(&p, sizeof(p));
p.ClassInstallHeader.cbSize = sizeof(SP_CLASSINSTALL_HEADER);
p.ClassInstallHeader.InstallFunction = DIF_PROPERTYCHANGE;
p.StateChange = DICS_DISABLE;
p.Scope = DICS_FLAG_CONFIGSPECIFIC;
if (SetupDiSetClassInstallParams(info, dev_info_data, &p.ClassInstallHeader, sizeof(p)) == false ||
SetupDiCallClassInstaller(DIF_PROPERTYCHANGE, info, dev_info_data) == false)
{
return false;
}
return true;
}
|
/* Stop the specified device*/
|
Stop the specified device
|
MsEnableVLan
|
bool MsEnableVLan(char *instance_name)
{
bool ret;
Lock(vlan_lock);
{
ret = MsEnableVLanWithoutLock(instance_name);
}
Unlock(vlan_lock);
return ret;
}
|
/* Enable the virtual LAN card*/
|
Enable the virtual LAN card
|
MsDisableVLan
|
bool MsDisableVLan(char *instance_name)
{
bool ret;
Lock(vlan_lock);
{
ret = MsDisableVLanWithoutLock(instance_name);
}
Unlock(vlan_lock);
return ret;
}
|
/* Disable the virtual LAN card*/
|
Disable the virtual LAN card
|
MsRestartVLan
|
void MsRestartVLan(char *instance_name)
{
Lock(vlan_lock);
{
MsRestartVLanWithoutLock(instance_name);
}
Unlock(vlan_lock);
}
|
/* Restart the virtual LAN card*/
|
Restart the virtual LAN card
|
MsIsVLanEnabled
|
bool MsIsVLanEnabled(char *instance_name)
{
bool ret;
Lock(vlan_lock);
{
ret = MsIsVLanEnabledWithoutLock(instance_name);
}
Unlock(vlan_lock);
return ret;
}
|
/* Get whether the virtual LAN card is working*/
|
Get whether the virtual LAN card is working
|
MsUninstallVLan
|
bool MsUninstallVLan(char *instance_name)
{
bool ret;
Lock(vlan_lock);
{
ret = MsUninstallVLanWithoutLock(instance_name);
}
Unlock(vlan_lock);
return ret;
}
|
/* Uninstall the virtual LAN card*/
|
Uninstall the virtual LAN card
|
MsDestroyDevInfo
|
void MsDestroyDevInfo(HDEVINFO info)
{
// Validate arguments
if (info == NULL)
{
return;
}
SetupDiDestroyDeviceInfoList(info);
}
|
/* Dispose the device information*/
|
Dispose the device information
|
MsGenMacAddress
|
void MsGenMacAddress(UCHAR *mac)
{
UCHAR hash_src[40];
UCHAR hash[20];
UINT64 now;
// Validate arguments
if (mac == NULL)
{
return;
}
Rand(hash_src, 40);
now = SystemTime64();
Copy(hash_src, &now, sizeof(now));
Sha0(hash, hash_src, sizeof(hash_src));
mac[0] = 0x5E;
mac[1] = hash[0];
mac[2] = hash[1];
mac[3] = hash[2];
mac[4] = hash[3];
mac[5] = hash[4];
}
|
/* Generation of the MAC address*/
|
Generation of the MAC address
|
MsFinishDriverInstall
|
void MsFinishDriverInstall(char *instance_name, char *neo_sys)
{
wchar_t src_inf[MAX_PATH];
wchar_t src_sys[MAX_PATH];
wchar_t dest_inf[MAX_PATH];
wchar_t dest_sys[MAX_PATH];
wchar_t src_cat[MAX_SIZE];
wchar_t dst_cat[MAX_SIZE];
// Validate arguments
if (instance_name == NULL)
{
return;
}
MsGetDriverPath(instance_name, src_inf, src_sys, dest_inf, dest_sys, src_cat, dst_cat, neo_sys);
// Delete the files
FileDeleteW(dest_inf);
FileDeleteW(dest_sys);
if (IsEmptyUniStr(dst_cat) == false)
{
FileDeleteW(dst_cat);
}
}
|
/* Finish the driver installation*/
|
Finish the driver installation
|
MsIsVLanExists
|
bool MsIsVLanExists(char *tag_name, char *instance_name)
{
char *guid;
// Validate arguments
if (instance_name == NULL || tag_name == NULL)
{
return false;
}
guid = MsGetNetworkAdapterGuid(tag_name, instance_name);
if (guid == NULL)
{
return false;
}
Free(guid);
return true;
}
|
/* Examine whether the virtual LAN card with the specified name has already registered*/
|
Examine whether the virtual LAN card with the specified name has already registered
|
MsFreeTempDir
|
void MsFreeTempDir()
{
wchar_t lock_file_name[MAX_SIZE];
// Delete the lock file
MsGenLockFile(lock_file_name, sizeof(lock_file_name), ms->MyTempDirW);
FileClose(ms->LockFile);
// Memory release
Free(ms->MyTempDir);
Free(ms->MyTempDirW);
ms->MyTempDir = NULL;
ms->MyTempDirW = NULL;
// Delete directory
MsDeleteTempDir();
}
|
/* Release the temporary directory*/
|
Release the temporary directory
|
MsGenLockFile
|
void MsGenLockFile(wchar_t *name, UINT size, wchar_t *temp_dir)
{
// Validate arguments
if (name == NULL || temp_dir == NULL)
{
return;
}
UniFormat(name, size, L"%s\\VPN_Lock.dat", temp_dir);
}
|
/* Generation of the name of the lock file*/
|
Generation of the name of the lock file
|
MsGetNetworkConfigRegKeyNameFromInstanceName
|
char *MsGetNetworkConfigRegKeyNameFromInstanceName(char *tag_name, char *instance_name)
{
char *guid, *ret;
// Validate arguments
if (tag_name == NULL || instance_name == NULL)
{
return NULL;
}
guid = MsGetNetworkAdapterGuid(tag_name, instance_name);
if (guid == NULL)
{
return NULL;
}
ret = MsGetNetworkConfigRegKeyNameFromGuid(guid);
Free(guid);
return ret;
}
|
/* Get the network configuration key name by the instance name*/
|
Get the network configuration key name by the instance name
|
MsGetNetworkConfigRegKeyNameFromGuid
|
char *MsGetNetworkConfigRegKeyNameFromGuid(char *guid)
{
char tmp[MAX_SIZE];
// Validate arguments
if (guid == NULL)
{
return NULL;
}
Format(tmp, sizeof(tmp),
"SYSTEM\\CurrentControlSet\\Control\\Network\\{4D36E972-E325-11CE-BFC1-08002BE10318}\\%s\\Connection",
guid);
return CopyStr(tmp);
}
|
/* Get the network configuration key name by the GUID*/
|
Get the network configuration key name by the GUID
|
MsGetNetworkConnectionName
|
wchar_t *MsGetNetworkConnectionName(char *guid)
{
wchar_t *ncname = NULL;
// Validate arguments
if (guid == NULL)
{
return NULL;
}
// Get the network connection name
if (IsNt() != false && GetOsInfo()->OsType >= OSTYPE_WINDOWS_2000_PROFESSIONAL)
{
char tmp[MAX_SIZE];
Format(tmp, sizeof(tmp), "SYSTEM\\CurrentControlSet\\Control\\Network\\{4D36E972-E325-11CE-BFC1-08002BE10318}\\%s\\Connection", guid);
ncname = MsRegReadStrW(REG_LOCAL_MACHINE, tmp, "Name");
}
return ncname;
}
|
/* Get the network connection name*/
|
Get the network connection name
|
MsMakeNewNeoDriverFilename
|
bool MsMakeNewNeoDriverFilename(char *name, UINT size)
{
TOKEN_LIST *t = MsEnumNeoDriverFilenames();
UINT i;
bool ret = false;
i = 0;
while (true)
{
char tmp[MAX_PATH];
UINT n;
i++;
if (i >= 10000)
{
break;
}
n = Rand32() % DRIVER_INSTALL_SYS_NAME_TAG_MAXID;
MsGenerateNeoDriverFilenameFromInt(tmp, sizeof(tmp), n);
if (IsInToken(t, tmp) == false)
{
StrCpy(name, size, tmp);
ret = true;
break;
}
}
FreeToken(t);
return ret;
}
|
/* Generate driver file name for the new Neo*/
|
Generate driver file name for the new Neo
|
MsGenerateNeoDriverFilenameFromInt
|
void MsGenerateNeoDriverFilenameFromInt(char *name, UINT size, UINT n)
{
Format(name, size, DRIVER_INSTALL_SYS_NAME_TAG_NEW, n);
}
|
/* Generate the driver file name of Neo from a integer*/
|
Generate the driver file name of Neo from a integer
|
MsEnumNeoDriverFilenames
|
TOKEN_LIST *MsEnumNeoDriverFilenames()
{
TOKEN_LIST *neos = MsEnumNetworkAdaptersNeo();
LIST *o = NewListFast(NULL);
TOKEN_LIST *ret;
UINT i;
for (i = 0;i < neos->NumTokens;i++)
{
char filename[MAX_PATH];
if (MsGetNeoDriverFilename(filename, sizeof(filename), neos->Token[i]))
{
Add(o, CopyStr(filename));
}
}
FreeToken(neos);
ret = ListToTokenList(o);
FreeStrList(o);
return ret;
}
|
/* Enumeration of the driver file names of installed Neo*/
|
Enumeration of the driver file names of installed Neo
|
MsGetNeoDriverFilename
|
bool MsGetNeoDriverFilename(char *name, UINT size, char *instance_name)
{
char tmp[MAX_SIZE];
char *ret;
// Validate arguments
if (name == NULL || instance_name == NULL)
{
return false;
}
Format(tmp, sizeof(tmp), "SYSTEM\\CurrentControlSet\\Services\\Neo_%s", instance_name);
ret = MsRegReadStr(REG_LOCAL_MACHINE, tmp, "ImagePath");
if (ret == NULL)
{
return false;
}
GetFileNameFromFilePath(name, size, ret);
Free(ret);
return true;
}
|
/* Get the driver file name of Neo*/
|
Get the driver file name of Neo
|
MsShutdown
|
bool MsShutdown(bool reboot, bool force)
{
UINT flag = 0;
// Get the privilege
if (MsEnablePrivilege(SE_SHUTDOWN_NAME, true) == false)
{
return false;
}
flag |= (reboot ? EWX_REBOOT : EWX_SHUTDOWN);
flag |= (force ? EWX_FORCE : 0);
// Execute the shutdown
if (ExitWindowsEx(flag, 0) == false)
{
MsEnablePrivilege(SE_SHUTDOWN_NAME, false);
return false;
}
// Release of privilege
MsEnablePrivilege(SE_SHUTDOWN_NAME, false);
return true;
}
|
/* Execute the shutdown*/
|
Execute the shutdown
|
MsIsNt
|
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 OS is a NT system*/
|
Get whether the current OS is a NT system
|
MsIsWine
|
bool MsIsWine()
{
bool ret = false;
if (ms == NULL)
{
HINSTANCE h = LoadLibrary("kernel32.dll");
if (h != NULL)
{
if (GetProcAddress(h, "wine_get_unix_file_name") != NULL)
{
ret = true;
}
FreeLibrary(h);
}
}
else
{
ret = ms->IsWine;
}
return ret;
}
|
/* Get whether the current system is WINE*/
|
Get whether the current system is WINE
|
MsIsAdmin
|
bool MsIsAdmin()
{
return ms->IsAdmin;
}
|
/* Get whether the current user is an Admin*/
|
Get whether the current user is an Admin
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.