66#if defined (_MSC_VER) && (_MSC_VER >= 1400)
68#elif defined (_M_IX86)
69 static void __cpuid(
int* cpuid_data,
int info_type)
96 static void __cpuid(
int* cpuid_data,
int) {
97 cpuid_data[0] = 0x00000000;
98 cpuid_data[1] = 0x00000000;
99 cpuid_data[2] = 0x00000000;
100 cpuid_data[3] = 0x00000000;
123 if (
fds_bits->fd_count < FD_SETSIZE-1)
126 ::SysError(
"TFdSet::Set",
"fd_count will exeed FD_SETSIZE");
131 for (i=0; i<
fds_bits->fd_count; i++) {
133 while (i<fds_bits->fd_count-1) {
153 static HANDLE gGlobalEvent;
154 static HANDLE gTimerThreadHandle;
155 typedef NET_API_STATUS (WINAPI *pfn1)(LPVOID);
156 typedef NET_API_STATUS (WINAPI *pfn2)(LPCWSTR, LPCWSTR, DWORD, LPBYTE*);
157 typedef NET_API_STATUS (WINAPI *pfn3)(LPCWSTR, LPCWSTR, DWORD, LPBYTE*,
158 DWORD, LPDWORD, LPDWORD, PDWORD_PTR);
159 typedef NET_API_STATUS (WINAPI *pfn4)(LPCWSTR, DWORD, LPBYTE*, DWORD, LPDWORD,
160 LPDWORD, PDWORD_PTR);
161 static pfn1 p2NetApiBufferFree;
162 static pfn2 p2NetUserGetInfo;
163 static pfn3 p2NetLocalGroupGetMembers;
164 static pfn4 p2NetLocalGroupEnum;
166 static struct signal_map {
172 SIGSEGV, 0,
"segmentation violation",
173 -1 , 0,
"bad argument to system call",
174 -1 , 0,
"write on a pipe with no one to read it",
175 SIGILL, 0,
"illegal instruction",
178 SIGINT, 0,
"interrupt",
179 -1 , 0,
"window size change",
180 -1 , 0,
"alarm clock",
181 -1 , 0,
"death of a child",
182 -1 , 0,
"urgent data arrived on an I/O channel",
183 SIGFPE, 0,
"floating point exception",
184 SIGTERM, 0,
"termination signal",
185 -1 , 0,
"user-defined signal 1",
186 -1 , 0,
"user-defined signal 2"
207 static int WinNTRecv(
int socket,
void *buffer,
int length,
int flag)
209 if (
socket == -1)
return -1;
217 if (flag == MSG_PEEK) {
222 char *buf = (
char *)buffer;
225 if ((nrecv = ::recv(sock, buf+
n,
length-
n, flag)) <= 0) {
229 if (flag == MSG_OOB) {
230 if (::WSAGetLastError() == WSAEWOULDBLOCK) {
232 }
else if (::WSAGetLastError() == WSAEINVAL) {
236 if (::WSAGetLastError() == WSAEWOULDBLOCK) {
239 if (::WSAGetLastError() != WSAEINTR)
240 ::SysError(
"TWinNTSystem::WinNTRecv",
"recv");
241 if (::WSAGetLastError() == EPIPE ||
242 ::WSAGetLastError() == WSAECONNRESET)
261 static int WinNTSend(
int socket,
const void *buffer,
int length,
int flag)
263 if (
socket < 0)
return -1;
273 const char *buf = (
const char *)buffer;
276 if ((nsent = ::send(sock, buf+
n,
length-
n, flag)) <= 0) {
280 if (::WSAGetLastError() == WSAEWOULDBLOCK) {
283 if (::WSAGetLastError() != WSAEINTR)
284 ::SysError(
"TWinNTSystem::WinNTSend",
"send");
285 if (::WSAGetLastError() == EPIPE ||
286 ::WSAGetLastError() == WSAECONNRESET)
306 fd_set* rbits = readready ? (fd_set*)readready->
GetBits() : 0;
307 fd_set* wbits = writeready ? (fd_set*)writeready->
GetBits() : 0;
311 tv.tv_sec = timeout / 1000;
312 tv.tv_usec = (timeout % 1000) * 1000;
314 retcode = ::select(0, rbits, wbits, 0, &tv);
316 retcode = ::select(0, rbits, wbits, 0, 0);
319 if (retcode == SOCKET_ERROR) {
320 int errcode = ::WSAGetLastError();
324 if (errcode == WSAENOTSOCK) {
326 int result = _fstat64( readready->
GetFd(0), &buf );
334 ::WaitForSingleObject(gGlobalEvent, 1);
335 ::ResetEvent(gGlobalEvent);
340 if ( errcode == WSAEINTR) {
344 if (errcode == EBADF) {
359 if (reset || newpath) {
364 }
else if (dynpath ==
"") {
368 if (rdynpath ==
"") {
396 if (signal_map[i].code == sig) {
397 (*signal_map[i].handler)((
ESignals)i);
408 signal_map[sig].handler = handler;
409 if (signal_map[sig].code != -1)
416 static const char *WinNTSigname(
ESignals sig)
418 return signal_map[sig].signame;
424 static BOOL ConsoleSigHandler(DWORD sig)
432 Break(
"TInterruptHandler::Notify",
"keyboard interrupt");
438 case CTRL_BREAK_EVENT:
439 case CTRL_LOGOFF_EVENT:
440 case CTRL_SHUTDOWN_EVENT:
441 case CTRL_CLOSE_EVENT:
443 printf(
"\n *** Break *** keyboard interrupt - ROOT is terminated\n");
449 static CONTEXT *fgXcptContext = 0;
463 LONG WINAPI ExceptionFilter(LPEXCEPTION_POINTERS pXcp)
465 fgXcptContext = pXcp->ContextRecord;
467 return EXCEPTION_CONTINUE_SEARCH;
471#pragma intrinsic(_ReturnAddress)
472#pragma auto_inline(off)
473 DWORD_PTR GetProgramCounter()
478#pragma auto_inline(on)
489 static DWORD WINAPI GUIThreadMessageProcessingLoop(
void *
p)
494 ::PeekMessage(&msg, NULL, WM_USER, WM_USER, PM_NOREMOVE);
499 if (gGlobalEvent) ::SetEvent(gGlobalEvent);
500 erret = ::GetMessage(&msg, NULL, NULL, NULL);
501 if (erret <= 0) endLoop =
kTRUE;
502 if (gGUIThreadMsgFunc)
503 endLoop = (*gGUIThreadMsgFunc)(&msg);
510 erret = ::GetLastError();
511 Error(
"MsgLoop",
"Error in GetMessage");
525 typedef BOOL (__stdcall *SYMINITIALIZEPROC)( HANDLE, LPSTR,
BOOL );
526 typedef BOOL (__stdcall *SYMCLEANUPPROC)( HANDLE );
527 typedef BOOL (__stdcall *STACKWALK64PROC)
528 ( DWORD, HANDLE, HANDLE, LPSTACKFRAME64, LPVOID,
529 PREAD_PROCESS_MEMORY_ROUTINE,PFUNCTION_TABLE_ACCESS_ROUTINE,
530 PGET_MODULE_BASE_ROUTINE, PTRANSLATE_ADDRESS_ROUTINE );
531 typedef LPVOID (__stdcall *SYMFUNCTIONTABLEACCESS64PROC)( HANDLE, DWORD64 );
532 typedef DWORD (__stdcall *SYMGETMODULEBASE64PROC)( HANDLE, DWORD64 );
533 typedef BOOL (__stdcall *SYMGETMODULEINFO64PROC)(HANDLE, DWORD64, PIMAGEHLP_MODULE64);
534 typedef BOOL (__stdcall *SYMGETSYMFROMADDR64PROC)( HANDLE, DWORD64, PDWORD64, PIMAGEHLP_SYMBOL64);
535 typedef BOOL (__stdcall *SYMGETLINEFROMADDR64PROC)(HANDLE, DWORD64, PDWORD, PIMAGEHLP_LINE64);
536 typedef DWORD (__stdcall *UNDECORATESYMBOLNAMEPROC)(PCSTR, PSTR, DWORD, DWORD);
539 static SYMINITIALIZEPROC _SymInitialize = 0;
540 static SYMCLEANUPPROC _SymCleanup = 0;
541 static STACKWALK64PROC _StackWalk64 = 0;
542 static SYMFUNCTIONTABLEACCESS64PROC _SymFunctionTableAccess64 = 0;
543 static SYMGETMODULEBASE64PROC _SymGetModuleBase64 = 0;
544 static SYMGETMODULEINFO64PROC _SymGetModuleInfo64 = 0;
545 static SYMGETSYMFROMADDR64PROC _SymGetSymFromAddr64 = 0;
546 static SYMGETLINEFROMADDR64PROC _SymGetLineFromAddr64 = 0;
547 static UNDECORATESYMBOLNAMEPROC _UnDecorateSymbolName = 0;
549 BOOL InitImagehlpFunctions()
557 HMODULE hModImagehlp = LoadLibrary(
"IMAGEHLP.DLL" );
561 _SymInitialize = (SYMINITIALIZEPROC) GetProcAddress( hModImagehlp,
"SymInitialize" );
565 _SymCleanup = (SYMCLEANUPPROC) GetProcAddress( hModImagehlp,
"SymCleanup" );
569 _StackWalk64 = (STACKWALK64PROC) GetProcAddress( hModImagehlp,
"StackWalk64" );
573 _SymFunctionTableAccess64 = (SYMFUNCTIONTABLEACCESS64PROC) GetProcAddress(hModImagehlp,
"SymFunctionTableAccess64" );
574 if (!_SymFunctionTableAccess64)
577 _SymGetModuleBase64=(SYMGETMODULEBASE64PROC)GetProcAddress(hModImagehlp,
"SymGetModuleBase64");
578 if (!_SymGetModuleBase64)
581 _SymGetModuleInfo64=(SYMGETMODULEINFO64PROC)GetProcAddress(hModImagehlp,
"SymGetModuleInfo64");
582 if (!_SymGetModuleInfo64)
585 _SymGetSymFromAddr64=(SYMGETSYMFROMADDR64PROC)GetProcAddress(hModImagehlp,
"SymGetSymFromAddr64");
586 if (!_SymGetSymFromAddr64)
589 _SymGetLineFromAddr64=(SYMGETLINEFROMADDR64PROC)GetProcAddress(hModImagehlp,
"SymGetLineFromAddr64");
590 if (!_SymGetLineFromAddr64)
593 _UnDecorateSymbolName=(UNDECORATESYMBOLNAMEPROC)GetProcAddress(hModImagehlp,
"UnDecorateSymbolName");
594 if (!_UnDecorateSymbolName)
597 if (!_SymInitialize(GetCurrentProcess(), 0,
TRUE ))
613 std::string GetModuleName(DWORD64 address)
617 std::ostringstream out;
618 HANDLE process = ::GetCurrentProcess();
620 DWORD lineDisplacement = 0;
621 IMAGEHLP_LINE64
line;
624 if(_SymGetLineFromAddr64(process, address, &lineDisplacement, &
line)) {
625 out <<
line.FileName <<
"(" <<
line.LineNumber <<
"): ";
627 IMAGEHLP_MODULE64 module;
628 ::ZeroMemory(&module,
sizeof(module));
629 module.SizeOfStruct =
sizeof(module);
630 if(_SymGetModuleInfo64(process, address, &module)) {
631 out << module.ModuleName <<
"!";
633 out <<
"0x" << std::hex << address << std::dec <<
" ";
640 std::string GetFunctionName(DWORD64 address)
644 DWORD64 symbolDisplacement = 0;
645 HANDLE process = ::GetCurrentProcess();
647 const unsigned int SYMBOL_BUFFER_SIZE = 8192;
648 char symbolBuffer[SYMBOL_BUFFER_SIZE];
649 PIMAGEHLP_SYMBOL64 symbol =
reinterpret_cast<PIMAGEHLP_SYMBOL64
>(symbolBuffer);
650 ::ZeroMemory(symbol, SYMBOL_BUFFER_SIZE);
651 symbol->SizeOfStruct = SYMBOL_BUFFER_SIZE;
652 symbol->MaxNameLength = SYMBOL_BUFFER_SIZE -
sizeof(IMAGEHLP_SYMBOL64);
654 if(_SymGetSymFromAddr64(process, address, &symbolDisplacement, symbol)) {
656 const unsigned int NAME_SIZE = 8192;
657 char name[NAME_SIZE];
658 _UnDecorateSymbolName(
663 UNDNAME_NO_THISTYPE |
664 UNDNAME_NO_SPECIAL_SYMS |
665 UNDNAME_NO_MEMBER_TYPE |
666 UNDNAME_NO_MS_KEYWORDS |
667 UNDNAME_NO_ACCESS_SPECIFIERS
688 const char *extLnk =
".lnk";
692 if (strfilename.EndsWith(extLnk))
701 static BOOL ResolveShortCut(LPCSTR pszShortcutFile,
char *pszPath,
int maxbuf)
705 char szGotPath[MAX_PATH];
712 typedef HRESULT (__stdcall *COINITIALIZEPROC)( LPVOID );
713 static COINITIALIZEPROC _CoInitialize = 0;
714 typedef void (__stdcall *COUNINITIALIZEPROC)(
void );
715 static COUNINITIALIZEPROC _CoUninitialize = 0;
716 typedef HRESULT (__stdcall *COCREATEINSTANCEPROC)( REFCLSID, LPUNKNOWN,
717 DWORD, REFIID, LPVOID );
718 static COCREATEINSTANCEPROC _CoCreateInstance = 0;
720 HMODULE hModImagehlp = LoadLibrary(
"ole32.dll" );
724 _CoInitialize = (COINITIALIZEPROC) GetProcAddress( hModImagehlp,
"CoInitialize" );
727 _CoUninitialize = (COUNINITIALIZEPROC) GetProcAddress( hModImagehlp,
"CoUninitialize");
728 if (!_CoUninitialize)
730 _CoCreateInstance = (COCREATEINSTANCEPROC) GetProcAddress( hModImagehlp,
"CoCreateInstance" );
731 if (!_CoCreateInstance)
736 hres = _CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER,
737 IID_IShellLink, (
void **) &psl);
738 if (SUCCEEDED(hres)) {
741 hres = psl->QueryInterface(IID_IPersistFile, (
void **) &ppf);
742 if (SUCCEEDED(hres)) {
744 MultiByteToWideChar(CP_ACP, 0, pszShortcutFile, -1, wsz, MAX_PATH);
746 hres = ppf->Load(wsz, STGM_READ);
747 if (SUCCEEDED(hres)) {
748 hres = psl->Resolve(HWND_DESKTOP, SLR_ANY_MATCH | SLR_NO_UI | SLR_UPDATE);
749 if (SUCCEEDED(hres)) {
750 strlcpy(szGotPath, pszShortcutFile,MAX_PATH);
751 hres = psl->GetPath(szGotPath, MAX_PATH, (WIN32_FIND_DATA *)&wfd,
752 SLGP_UNCPRIORITY | SLGP_RAWPATH);
753 strlcpy(pszPath,szGotPath, maxbuf);
754 if (maxbuf) pszPath[maxbuf-1] = 0;
763 return SUCCEEDED(hres);
769 if (strcmp(sys->TWinNTSystem::BaseName(buf),
"root.exe"))
772 if (!::RegOpenKeyEx(HKEY_CURRENT_USER,
"Software", 0, KEY_READ, ®CUS) == ERROR_SUCCESS)
775 if (!::RegOpenKeyEx(regCUS,
"Classes", 0, KEY_READ, ®CUSC) == ERROR_SUCCESS) {
776 ::RegCloseKey(regCUS);
781 bool regROOTwrite =
false;
785 if (::RegOpenKeyEx(regCUSC,
"ROOTDEV.ROOT", 0, KEY_READ, ®ROOT) != ERROR_SUCCESS) {
786 ::RegCloseKey(regCUSC);
787 if (::RegOpenKeyEx(regCUS,
"Classes", 0, KEY_READ | KEY_WRITE, ®CUSC) == ERROR_SUCCESS &&
788 ::RegCreateKeyEx(regCUSC,
"ROOTDEV.ROOT", 0, NULL, 0, KEY_READ | KEY_WRITE,
789 NULL, ®ROOT, NULL) == ERROR_SUCCESS) {
794 if (::RegOpenKeyEx(regROOT,
"DefaultIcon", 0, KEY_READ, ®ROOTIcon) == ERROR_SUCCESS) {
795 char bufIconLoc[1024];
797 DWORD dwSize =
sizeof(bufIconLoc);
799 if (::RegQueryValueEx(regROOTIcon, NULL, NULL, &dwType, (BYTE*)bufIconLoc, &dwSize) == ERROR_SUCCESS)
800 regROOTwrite = (iconloc != bufIconLoc);
803 ::RegCloseKey(regROOTIcon);
808 ::RegCloseKey(regCUSC);
809 ::RegCloseKey(regROOT);
810 if (::RegOpenKeyEx(regCUS,
"Classes", 0, KEY_READ | KEY_WRITE, ®CUSC) != ERROR_SUCCESS) {
812 regROOTwrite =
false;
814 if (::RegOpenKeyEx(regCUSC,
"ROOTDEV.ROOT", 0, KEY_WRITE, ®ROOT) != ERROR_SUCCESS) {
816 regROOTwrite =
false;
817 ::RegCloseKey(regCUSC);
824 TString fileopen =
"fileopen.C";
825 TString rootmacrodir =
"macros";
835 ::RegCloseKey(regROOT);
836 ::RegCloseKey(regCUSC);
837 ::RegCloseKey(regCUS);
841 static const char apptitle[] =
"ROOT data file";
842 ::RegSetValueEx(regROOT, NULL, 0, REG_SZ, (BYTE*)apptitle,
sizeof(apptitle));
843 DWORD editflags = 0x00010000;
844 ::RegSetValueEx(regROOT,
"EditFlags", 0, REG_DWORD, (BYTE*)&editflags,
sizeof(editflags));
847 if (::RegCreateKeyEx(regROOT,
"DefaultIcon", 0, NULL, 0, KEY_READ | KEY_WRITE,
848 NULL, ®ROOTIcon, NULL) == ERROR_SUCCESS) {
851 ::RegSetValueEx(regROOTIcon, NULL, 0, REG_SZ, (BYTE*)iconloc.Data(), iconloc.Length() + 1);
852 ::RegCloseKey(regROOTIcon);
857 if (::RegCreateKeyEx(regROOT,
"shell", 0, NULL, 0, KEY_READ | KEY_WRITE,
858 NULL, ®ROOTshell, NULL) == ERROR_SUCCESS) {
860 if (::RegCreateKeyEx(regROOTshell,
"open", 0, NULL, 0, KEY_READ | KEY_WRITE,
861 NULL, ®ShellOpen, NULL) == ERROR_SUCCESS) {
862 HKEY regShellOpenCmd;
863 if (::RegCreateKeyEx(regShellOpen,
"command", 0, NULL, 0, KEY_READ | KEY_WRITE,
864 NULL, ®ShellOpenCmd, NULL) == ERROR_SUCCESS) {
866 cmd +=
" -l \"%1\" \"";
869 ::RegSetValueEx(regShellOpenCmd, NULL, 0, REG_SZ, (BYTE*)cmd.Data(), cmd.Length() + 1);
870 ::RegCloseKey(regShellOpenCmd);
872 ::RegCloseKey(regShellOpen);
874 ::RegCloseKey(regROOTshell);
876 ::RegCloseKey(regROOT);
878 if (::RegCreateKeyEx(regCUSC,
".root", 0, NULL, 0, KEY_READ | KEY_WRITE,
879 NULL, ®ROOT, NULL) == ERROR_SUCCESS) {
880 static const char appname[] =
"ROOTDEV.ROOT";
881 ::RegSetValueEx(regROOT, NULL, 0, REG_SZ, (BYTE*)appname,
sizeof(appname));
883 ::RegCloseKey(regCUSC);
884 ::RegCloseKey(regCUS);
887 ::SHChangeNotify(SHCNE_ASSOCCHANGED, SHCNF_IDLIST, NULL, NULL);
895 static bool once =
true;
898 if (!once ||
gROOT->IsBatch())
return false;
899 TString cmdline(::GetCommandLine());
900 Int_t i = 0, from = 0;
901 while (cmdline.Tokenize(arg, from,
" ")) {
903 if (i == 0 && ((arg !=
"root") && (arg !=
"rootn") &&
904 (arg !=
"root.exe") && (arg !=
"rootn.exe")))
return false;
905 else if ((arg ==
"-l") || (arg ==
"-b"))
return false;
917 static void SetConsoleWindowName()
919 char pszNewWindowTitle[1024];
920 char pszOldWindowTitle[1024];
922 CONSOLE_SCREEN_BUFFER_INFO csbiInfo;
924 if (!::GetConsoleTitle(pszOldWindowTitle, 1024))
927 wsprintf(pszNewWindowTitle,
"%d/%d", ::GetTickCount(), ::GetCurrentProcessId());
929 if (!::SetConsoleTitle(pszNewWindowTitle))
939 ::SetConsoleTitle(
"ROOT session");
941 hStdout = GetStdHandle(STD_OUTPUT_HANDLE);
944 ::SetConsoleMode(hStdout, ENABLE_PROCESSED_OUTPUT |
945 ENABLE_WRAP_AT_EOL_OUTPUT);
946 if (!::GetConsoleScreenBufferInfo(hStdout, &csbiInfo))
989 if (initwinsock = ::WSAStartup(MAKEWORD(2, 0), &WSAData)) {
990 Error(
"TWinNTSystem()",
"Starting sockets failed");
1001 char *buf =
new char[MAX_MODULE_NAME32 + 1];
1007 HMODULE hModCore = ::GetModuleHandle(
"libCore.dll");
1009 ::GetModuleFileName(hModCore, buf, MAX_MODULE_NAME32 + 1);
1010 char *pLibName = strstr(buf,
"libCore.dll");
1013 while (--pLibName >= buf && *pLibName !=
'\\' && *pLibName !=
'/');
1016 check_path +=
"\\etc";
1018 while (buf[0] && GetFileAttributes(check_path.
Data()) == INVALID_FILE_ATTRIBUTES) {
1019 while (--pLibName >= buf && *pLibName !=
'\\' && *pLibName !=
'/');
1022 check_path +=
"\\etc";
1037 UpdateRegistry(
this, buf);
1048 typedef UINT (WINAPI* LPTIMEENDPERIOD)( UINT uPeriod );
1049 HINSTANCE hInstWinMM = LoadLibrary(
"winmm.dll" );
1051 LPTIMEENDPERIOD pTimeEndPeriod = (LPTIMEENDPERIOD)GetProcAddress( hInstWinMM,
"timeEndPeriod" );
1052 if( NULL != pTimeEndPeriod )
1054 FreeLibrary(hInstWinMM);
1060 ::ResetEvent(gGlobalEvent);
1061 ::CloseHandle(gGlobalEvent);
1064 if (gTimerThreadHandle) {
1065 ::TerminateThread(gTimerThreadHandle, 0);
1066 ::CloseHandle(gTimerThreadHandle);
1099 ::SetUnhandledExceptionFilter(ExceptionFilter);
1107 typedef UINT (WINAPI* LPTIMEBEGINPERIOD)( UINT uPeriod );
1108 HINSTANCE hInstWinMM = LoadLibrary(
"winmm.dll" );
1110 LPTIMEBEGINPERIOD pTimeBeginPeriod = (LPTIMEBEGINPERIOD)GetProcAddress( hInstWinMM,
"timeBeginPeriod" );
1111 if( NULL != pTimeBeginPeriod )
1112 pTimeBeginPeriod(1);
1113 FreeLibrary(hInstWinMM);
1115 gTimerThreadHandle = ::CreateThread(NULL, NULL, (LPTHREAD_START_ROUTINE)
ThreadStub,
1118 gGlobalEvent = ::CreateEvent(NULL,
TRUE,
FALSE, NULL);
1121 char *buf =
new char[MAX_MODULE_NAME32 + 1];
1122 HMODULE hModCore = ::GetModuleHandle(
"libCore.dll");
1124 ::GetModuleFileName(hModCore, buf, MAX_MODULE_NAME32 + 1);
1125 char *pLibName = strstr(buf,
"libCore.dll");
1132 SetConsoleWindowName();
1155 const char *symbol=
name;
1158 while ( (*symbol ==
' ' || *symbol ==
'\t') && *symbol) symbol++;
1161 if (isalpha(symbol[idx]) && symbol[idx+1] ==
':') idx = 2;
1162 if ( (symbol[idx] ==
'/' || symbol[idx] ==
'\\') && symbol[idx+1] ==
'\0') {
1167 Error(
"BaseName",
"name = 0");
1171 char *bslash = (
char *)strrchr(&symbol[idx],
'\\');
1172 char *rslash = (
char *)strrchr(&symbol[idx],
'/');
1173 if (cp = (std::max)(rslash, bslash)) {
1178 return &symbol[idx];
1180 Error(
"BaseName",
"name = 0");
1191 char *dot =
nullptr;
1193 char *fullname =
nullptr;
1196 size_t namelen =
name ? strlen(
name) : 0;
1197 if (
name && namelen > 0) {
1199 fullname =
new char[namelen+5];
1200 strlcpy(fullname,
name,namelen+5);
1201 if ( !strrchr(fullname,
'.') )
1202 strlcat(fullname,
".exe",namelen+5);
1205 dot = strrchr(progname,
'.');
1206 idot = dot ? (size_t)(dot - progname) : strlen(progname);
1208 char *which =
nullptr;
1211 which =
StrDup(fullname);
1222 dirname.
Form(
"%c:%s", driveletter,
d.Data());
1237 progname[idot] =
'\0';
1239 if (which)
delete [] which;
1243 if (::NeedSplash()) {
1256 if (err < 0 || err >= sys_nerr) {
1258 error_msg.
Form(
"errno out of range %d", err);
1261 return sys_errlist[err];
1274 DWORD il =
sizeof(hn);
1275 ::GetComputerName(hn, &il);
1291 if (freq < 37) freq = 440;
1292 if (duration < 0) duration = 100;
1301 gGUIThreadMsgFunc = func;
1324 int fd =
h->GetFd();
1327 if (
h->HasReadInterest()) {
1330 if (
h->HasWriteInterest()) {
1342 if (!
h)
return nullptr;
1362 set_console =
kTRUE;
1375 ::SetConsoleCtrlHandler((PHANDLER_ROUTINE)ConsoleSigHandler,
TRUE);
1386 if (!
h)
return nullptr;
1401 ::SetConsoleCtrlHandler((PHANDLER_ROUTINE)ConsoleSigHandler,
FALSE);
1445 HANDLE snapshot = ::CreateToolhelp32Snapshot(TH32CS_SNAPTHREAD,::GetCurrentProcessId());
1450 if (!InitImagehlpFunctions()) {
1451 std::cerr <<
"No stack trace: cannot find (functions in) dbghelp.dll!" << std::endl;
1456 SYSTEM_INFO sysInfo;
1457 ::GetSystemInfo(&sysInfo);
1458 DWORD machineType = IMAGE_FILE_MACHINE_I386;
1459 switch (sysInfo.wProcessorArchitecture) {
1460 case PROCESSOR_ARCHITECTURE_AMD64:
1461 machineType = IMAGE_FILE_MACHINE_AMD64;
1463 case PROCESSOR_ARCHITECTURE_IA64:
1464 machineType = IMAGE_FILE_MACHINE_IA64;
1468 DWORD currentThreadID = ::GetCurrentThreadId();
1469 DWORD currentProcessID = ::GetCurrentProcessId();
1473 THREADENTRY32 threadentry;
1474 threadentry.dwSize =
sizeof(THREADENTRY32);
1475 if (!::Thread32First(snapshot, &threadentry))
return;
1477 std::cerr << std::endl <<
"==========================================" << std::endl;
1478 std::cerr <<
"=============== STACKTRACE ===============" << std::endl;
1479 std::cerr <<
"==========================================" << std::endl << std::endl;
1482 if (threadentry.th32OwnerProcessID != currentProcessID)
1484 HANDLE thread = ::OpenThread(THREAD_GET_CONTEXT|THREAD_SUSPEND_RESUME|THREAD_QUERY_INFORMATION,
1485 FALSE, threadentry.th32ThreadID);
1487 memset(&context, 0,
sizeof(CONTEXT));
1489 if (threadentry.th32ThreadID != currentThreadID) {
1490 ::SuspendThread(thread);
1491 context.ContextFlags = CONTEXT_ALL;
1492 ::GetThreadContext(thread, &context);
1493 ::ResumeThread(thread);
1495 if (fgXcptContext) {
1496 context = *fgXcptContext;
1498 typedef void (WINAPI *RTLCCTXT)(PCONTEXT);
1499 RTLCCTXT p2RtlCCtxt = (RTLCCTXT) ::GetProcAddress(
1500 GetModuleHandle(
"kernel32.dll"),
"RtlCaptureContext");
1502 context.ContextFlags = CONTEXT_ALL;
1503 p2RtlCCtxt(&context);
1509 ::ZeroMemory(&frame,
sizeof(frame));
1511 frame.AddrPC.Mode = AddrModeFlat;
1512 frame.AddrFrame.Mode = AddrModeFlat;
1513 frame.AddrStack.Mode = AddrModeFlat;
1515 frame.AddrPC.Offset = context.Eip;
1516 frame.AddrFrame.Offset = context.Ebp;
1517 frame.AddrStack.Offset = context.Esp;
1518#elif defined(_M_X64)
1519 frame.AddrPC.Offset = context.Rip;
1520 frame.AddrFrame.Offset = context.Rsp;
1521 frame.AddrStack.Offset = context.Rsp;
1522#elif defined(_M_IA64)
1523 frame.AddrPC.Offset = context.StIIP;
1524 frame.AddrFrame.Offset = context.IntSp;
1525 frame.AddrStack.Offset = context.IntSp;
1526 frame.AddrBStore.Offset= context.RsBSP;
1528 std::cerr <<
"Stack traces not supported on your architecture yet." << std::endl;
1533 while (_StackWalk64(machineType, (HANDLE)::GetCurrentProcess(), thread, (LPSTACKFRAME64)&frame,
1534 (LPVOID)&context, (PREAD_PROCESS_MEMORY_ROUTINE)NULL, (PFUNCTION_TABLE_ACCESS_ROUTINE)_SymFunctionTableAccess64,
1535 (PGET_MODULE_BASE_ROUTINE)_SymGetModuleBase64, NULL)) {
1537 std::cerr << std::endl <<
"================ Thread " << iThread++ <<
" ================" << std::endl;
1538 if (!bFirst || threadentry.th32ThreadID != currentThreadID) {
1539 const std::string moduleName = GetModuleName(frame.AddrPC.Offset);
1540 const std::string functionName = GetFunctionName(frame.AddrPC.Offset);
1541 std::cerr <<
" " << moduleName << functionName << std::endl;
1545 ::CloseHandle(thread);
1546 }
while (::Thread32Next(snapshot, &threadentry));
1548 std::cerr << std::endl <<
"==========================================" << std::endl;
1549 std::cerr <<
"============= END STACKTRACE =============" << std::endl;
1550 std::cerr <<
"==========================================" << std::endl << std::endl;
1551 ::CloseHandle(snapshot);
1552 _SymCleanup(GetCurrentProcess());
1561 UInt_t oldmask = _statusfp( );
1587 UInt_t cm = ::_statusfp();
1589 ::_controlfp(cm , _MCW_EM);
1608 if (pendingOnly && gGlobalEvent) ::SetEvent(gGlobalEvent);
1610 Bool_t pollOnce = pendingOnly;
1614 if (
gROOT->GetApplication()) {
1630 ::WaitForSingleObject(gGlobalEvent, 1);
1631 ::ResetEvent(gGlobalEvent);
1657 if (pendingOnly && !pollOnce)
1696 if (!pendingOnly && gGlobalEvent) {
1697 ::WaitForSingleObject(gGlobalEvent, 1);
1698 ::ResetEvent(gGlobalEvent);
1717 rc = WinNTSelect(&t, 0, 0);
1718 if (rc < 0 && rc != -2) {
1719 ::SysError(
"DispatchOneEvent",
"select: read error on %d\n", fd);
1731 rc = WinNTSelect(0, &t, 0);
1732 if (rc < 0 && rc != -2) {
1733 ::SysError(
"DispatchOneEvent",
"select: write error on %d\n", fd);
1795 if (sync == sh->
IsSync()) {
1797 if ((
fSignals->
IsSet(sig) && sigdone == -1) || sigdone == sig) {
1798 if (sigdone == -1) {
1808 if (sigdone != -1)
return kTRUE;
1830 (fddone == fd && read)) {
1840 (fddone == fd && !read)) {
1850 if (fddone != -1)
return kTRUE;
1867 if (dirname.
Length() == 0) {
1884 if (res)
return res;
1904 const char *
proto = (strstr(
name,
"file:///")) ?
"file://" :
"file:";
1907 if (!
name)
return 0;
1911 if (!
name)
return 0;
1934 helper->FreeDirectory(dirp);
1938 ::FindClose(tsfd->fSearchFile);
1950 return helper->GetDirEntry(dirp);
1953 if (tsfd->fFirstFile) {
1958 return (
const char *)tsfd->fFindFileData.cFileName;
1960 if (::FindNextFile(tsfd->fSearchFile, &tsfd->fFindFileData)) {
1961 return (
const char *)tsfd->fFindFileData.cFileName;
1985 return (psz[0] == TEXT(
'\\') && psz[1] == TEXT(
'\\'));
2005#pragma data_seg(".text", "CODE")
2020 if (!IsDBCSLeadByte(*pPath)) {
2025 if ((*pPath == TEXT(
'\\')) && (*(pPath + 1) == 0))
2031 int cBackslashes = 0;
2032 for (
p = pPath + 2; *
p;
p = CharNext(
p)) {
2033 if (*
p == TEXT(
'\\') && (++cBackslashes > 1))
2053 const char *
proto = (strstr(fdir,
"file:///")) ?
"file://" :
"file:";
2056 char *dir =
new char[MAX_PATH];
2057 if (IsShortcut(sdir)) {
2058 if (!ResolveShortCut(sdir, dir, MAX_PATH))
2059 strlcpy(dir, sdir,MAX_PATH);
2062 strlcpy(dir, sdir,MAX_PATH);
2064 size_t nche = strlen(dir)+3;
2065 char *entry =
new char[nche];
2066 struct _stati64 finfo;
2069 strlcpy(entry, dir,nche);
2070 if ((entry[strlen(dir)-1] ==
'/') || (entry[strlen(dir)-1] ==
'\\' )) {
2071 entry[strlen(dir)-1] =
'\0';
2074 strlcat(entry,
"\\",nche);
2076 if (_stati64(entry, &finfo) < 0) {
2082 strlcpy(entry, dir,nche);
2083 if ((entry[strlen(dir)-1] ==
'/') || (entry[strlen(dir)-1] ==
'\\' )) {
2085 entry[strlen(dir)-1] =
'\0';
2087 if (_stati64(entry, &finfo) < 0) {
2094 if (finfo.st_mode & S_IFDIR) {
2095 strlcpy(entry, dir,nche);
2096 if (!(entry[strlen(dir)-1] ==
'/' || entry[strlen(dir)-1] ==
'\\' )) {
2097 strlcat(entry,
"\\",nche);
2099 if (entry[strlen(dir)-1] ==
' ')
2100 entry[strlen(dir)-1] =
'\0';
2101 strlcat(entry,
"*",nche);
2170 char *wdpath =
nullptr;
2171 char drive = driveletter ? toupper( driveletter ) -
'A' + 1 : 0;
2177 if (!(wdpath = ::_getdcwd( (
int)drive, wdpath,
kMAXPATHLEN))) {
2179 Warning(
"WorkingDirectory",
"getcwd() failed");
2203 return std::string(mydir);
2211 const char *
h =
nullptr;
2212 if (!(
h = ::getenv(
"home")))
h = ::getenv(
"HOME");
2219 h = ::getenv(
"HOMESHARE");
2220 if (!
h)
h = ::getenv(
"HOMEDRIVE");
2223 h = ::getenv(
"HOMEPATH");
2228 h = ::getenv(
"USERPROFILE");
2233 if (mydir[1] ==
':')
2234 mydir[0] = toupper(mydir[0]);
2250 if (!dir) dir =
"c:\\";
2266 char tmpName[MAX_PATH];
2270 FILE *fp = fopen(tmpName,
"w+");
2272 if (!fp)
::SysError(
"TempFileName",
"error opening %s", tmpName);
2290 if (!opt || !opt[0]) {
2295 UINT nOldErrorMode = ::SetErrorMode(SEM_FAILCRITICALERRORS);
2299 curdrive = _getdrive();
2300 if (strstr(opt,
"cur")) {
2302 sDrive.
Form(
"%c:", (curdrive +
'A' - 1));
2303 sType.
Form(
"Unknown Drive (%s)", sDrive.
Data());
2304 ::GetVolumeInformation(
Form(
"%s\\", sDrive.
Data()), NULL, 0, NULL, NULL,
2305 NULL, (LPSTR)szFs, 32);
2306 type = ::GetDriveType(sDrive.
Data());
2309 case DRIVE_NO_ROOT_DIR:
2311 case DRIVE_REMOVABLE:
2312 sType.
Form(
"Removable Disk (%s)", sDrive.
Data());
2315 sType.
Form(
"Local Disk (%s)", sDrive.
Data());
2318 sType.
Form(
"Network Drive (%s) (%s)", szFs, sDrive.
Data());
2321 sType.
Form(
"CD/DVD Drive (%s)", sDrive.
Data());
2324 sType.
Form(
"RAM Disk (%s)", sDrive.
Data());
2329 else if (strstr(opt,
"all")) {
2332 if (::GetLogicalDriveStrings(511, szTemp)) {
2333 TCHAR szDrive[3] = TEXT(
" :");
2339 sDrive.
Form(
"%s", szDrive);
2341 if ((sDrive ==
"A:") || (sDrive ==
"B:")) {
2345 sType.
Form(
"Unknown Drive (%s)", sDrive.
Data());
2346 ::GetVolumeInformation(
Form(
"%s\\", sDrive.
Data()), NULL, 0, NULL,
2347 NULL, NULL, (LPSTR)szFs, 32);
2348 type = ::GetDriveType(sDrive.
Data());
2351 case DRIVE_NO_ROOT_DIR:
2353 case DRIVE_REMOVABLE:
2354 sType.
Form(
"Removable Disk (%s)", sDrive.
Data());
2357 sType.
Form(
"Local Disk (%s)", sDrive.
Data());
2360 sType.
Form(
"Network Drive (%s) (%s)", szFs, sDrive.
Data());
2363 sType.
Form(
"CD/DVD Drive (%s)", sDrive.
Data());
2366 sType.
Form(
"RAM Disk (%s)", sDrive.
Data());
2376 ::SetErrorMode(nOldErrorMode);
2399 if (strchr(pathname,
'/') || strchr(pathname,
'\\')) {
2400 const char *rslash = strrchr(pathname,
'/');
2401 const char *bslash = strrchr(pathname,
'\\');
2402 const char *
r = std::max(rslash, bslash);
2403 const char *ptr = pathname;
2413 int len =
r - pathname;
2438 if (!pathname)
return 0;
2439 if (!pathname[0])
return 0;
2445 while(*lpchar ==
' ') lpchar++;
2447 if (isalpha((
int)*lpchar) && *(lpchar+1) ==
':') {
2451 if ( (*lpchar ==
'\\' || *lpchar ==
'/' ) &&
2452 (*(lpchar+1) ==
'\\' || *(lpchar+1) ==
'/') )
return 0;
2465 if (strchr(dir,
':')) idx = 2;
2466 return (dir[idx] ==
'/' || dir[idx] ==
'\\');
2499 const int kBufSize = 1024;
2500 TTHREAD_TLS_ARRAY(
char, kBufSize, temp);
2502 strlcpy(temp,
name, kBufSize);
2503 char *currentChar = temp;
2506 while (*currentChar !=
'\0') {
2507 if (*currentChar ==
'\\') *currentChar =
'/';
2525 UINT nOldErrorMode = ::SetErrorMode(SEM_FAILCRITICALERRORS);
2529 const char *
proto = (strstr(path,
"file:///")) ?
"file://" :
"file:";
2532 ::SetErrorMode(nOldErrorMode);
2537 ::SetErrorMode(nOldErrorMode);
2560 if (dir && dir[0]) {
2562 char last = dir[strlen(dir) - 1];
2563 if (last !=
'/' && last !=
'\\') {
2567 name.ReplaceAll(
"/",
"\\");
2584 if (!ret)
return -1;
2593 int ret = ::rename(
f, t);
2610 struct _stati64 sbuf;
2613 const char *
proto = (strstr(path,
"file:///")) ?
"file://" :
"file:";
2615 size_t l = strlen(newpath);
2617 if (newpath[--
l] !=
'\\' || newpath[--
l] !=
'/') {
2623 if (newpath && ::_stati64(newpath, &sbuf) >= 0) {
2625 buf.
fDev = sbuf.st_dev;
2626 buf.
fIno = sbuf.st_ino;
2627 buf.
fMode = sbuf.st_mode;
2628 buf.
fUid = sbuf.st_uid;
2629 buf.
fGid = sbuf.st_gid;
2630 buf.
fSize = sbuf.st_size;
2631 buf.
fMtime = sbuf.st_mtime;
2632 buf.
fIsLink = IsShortcut(newpath);
2634 char *lpath =
new char[MAX_PATH];
2635 if (IsShortcut(newpath)) {
2636 struct _stati64 sbuf2;
2637 if (ResolveShortCut(newpath, lpath, MAX_PATH)) {
2638 if (::_stati64(lpath, &sbuf2) >= 0) {
2639 buf.
fMode = sbuf2.st_mode;
2665 LPCTSTR lpRootPathName = path;
2668 LPTSTR lpVolumeNameBuffer = 0;
2669 DWORD nVolumeNameSize = 0;
2671 DWORD volumeSerialNumber;
2672 DWORD maximumComponentLength;
2675 DWORD fileSystemFlags;
2678 char fileSystemNameBuffer[512];
2679 DWORD nFileSystemNameSize =
sizeof(fileSystemNameBuffer);
2682 UINT nOldErrorMode = ::SetErrorMode(SEM_FAILCRITICALERRORS);
2683 if (!::GetVolumeInformation(lpRootPathName,
2684 lpVolumeNameBuffer, nVolumeNameSize,
2685 &volumeSerialNumber,
2686 &maximumComponentLength,
2688 fileSystemNameBuffer, nFileSystemNameSize)) {
2690 ::SetErrorMode(nOldErrorMode);
2694 const char *fsNames[] = {
"FAT",
"NTFS" };
2696 for (i = 0; i < 2; i++) {
2697 if (!strncmp(fileSystemNameBuffer, fsNames[i], nFileSystemNameSize))
2702 DWORD sectorsPerCluster;
2703 DWORD bytesPerSector;
2704 DWORD numberOfFreeClusters;
2705 DWORD totalNumberOfClusters;
2707 if (!::GetDiskFreeSpace(lpRootPathName,
2710 &numberOfFreeClusters,
2711 &totalNumberOfClusters)) {
2713 ::SetErrorMode(nOldErrorMode);
2717 ::SetErrorMode(nOldErrorMode);
2719 *bsize = sectorsPerCluster * bytesPerSector;
2720 *blocks = totalNumberOfClusters;
2721 *bfree = numberOfFreeClusters;
2731 struct _stati64 finfo;
2736 char linkname[1024];
2737 LPTSTR lpszFilePart;
2738 TCHAR szPath[MAX_PATH];
2741 typedef BOOL (__stdcall *CREATEHARDLINKPROC)( LPCTSTR, LPCTSTR, LPSECURITY_ATTRIBUTES );
2742 static CREATEHARDLINKPROC _CreateHardLink = 0;
2744 HMODULE hModImagehlp = LoadLibrary(
"Kernel32.dll" );
2749 _CreateHardLink = (CREATEHARDLINKPROC) GetProcAddress( hModImagehlp,
"CreateHardLinkW" );
2751 _CreateHardLink = (CREATEHARDLINKPROC) GetProcAddress( hModImagehlp,
"CreateHardLinkA" );
2753 if (!_CreateHardLink)
2756 dwRet = GetFullPathName(from,
sizeof(szPath) /
sizeof(TCHAR),
2757 szPath, &lpszFilePart);
2759 if (_stati64(szPath, &finfo) < 0)
2762 if (finfo.st_mode & S_IFDIR)
2766 _splitpath(linkname,winDrive,winDir,winName,winExt);
2767 if ((!winDrive[0] ) &&
2769 _splitpath(szPath,winDrive,winDir,winName,winExt);
2770 snprintf(linkname,1024,
"%s\\%s\\%s", winDrive, winDir, to);
2772 else if (!winDrive[0]) {
2773 _splitpath(szPath,winDrive,winDir,winName,winExt);
2774 snprintf(linkname,1024,
"%s\\%s", winDrive, to);
2777 if (!_CreateHardLink(linkname, szPath, NULL))
2790 IShellLink* pShellLink;
2791 IPersistFile* pPersistFile;
2792 WCHAR wszLinkfile[MAX_PATH];
2793 int iWideCharsWritten;
2795 LPTSTR lpszFilePart;
2796 TCHAR szPath[MAX_PATH];
2798 hRes = E_INVALIDARG;
2799 if ((from == NULL) || (!from[0]) || (to == NULL) ||
2805 typedef HRESULT (__stdcall *COINITIALIZEPROC)( LPVOID );
2806 static COINITIALIZEPROC _CoInitialize = 0;
2807 typedef void (__stdcall *COUNINITIALIZEPROC)( void );
2808 static COUNINITIALIZEPROC _CoUninitialize = 0;
2809 typedef HRESULT (__stdcall *COCREATEINSTANCEPROC)( REFCLSID, LPUNKNOWN, DWORD, REFIID, LPVOID );
2810 static COCREATEINSTANCEPROC _CoCreateInstance = 0;
2812 HMODULE hModImagehlp = LoadLibrary(
"ole32.dll" );
2816 _CoInitialize = (COINITIALIZEPROC) GetProcAddress( hModImagehlp,
"CoInitialize" );
2819 _CoUninitialize = (COUNINITIALIZEPROC) GetProcAddress( hModImagehlp,
"CoUninitialize" );
2820 if (!_CoUninitialize)
2822 _CoCreateInstance = (COCREATEINSTANCEPROC) GetProcAddress( hModImagehlp,
"CoCreateInstance" );
2823 if (!_CoCreateInstance)
2830 _CoInitialize(NULL);
2833 dwRet = GetFullPathName(from,
sizeof(szPath) /
sizeof(TCHAR),
2834 szPath, &lpszFilePart);
2835 hRes = _CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER,
2836 IID_IShellLink, (LPVOID *)&pShellLink);
2837 if (SUCCEEDED(hRes)) {
2839 hRes = pShellLink->SetPath(szPath);
2841 hRes = pShellLink->QueryInterface(IID_IPersistFile, (
void **)&pPersistFile);
2842 if (SUCCEEDED(hRes)){
2843 iWideCharsWritten = MultiByteToWideChar(CP_ACP, 0, linkname.
Data(), -1,
2844 wszLinkfile, MAX_PATH);
2845 hRes = pPersistFile->Save(wszLinkfile,
TRUE);
2846 pPersistFile->Release();
2848 pShellLink->Release();
2866 struct _stati64 finfo;
2868 if (_stati64(
name, &finfo) < 0) {
2872 if (finfo.st_mode & S_IFDIR) {
2873 return ::_rmdir(
name);
2875 return ::_unlink(
name);
2884 if (::ioctlsocket(fd, FIONBIO, (u_long *)1) == SOCKET_ERROR) {
2903 const char *patbuf = (
const char *)patbuf0;
2905 char *cmd =
nullptr;
2911 const char driveletter =
DriveName(patbuf);
2920 if (!
proto.EqualTo(
"file"))
2928 while (*patbuf ==
' ') {
2933 while (*patbuf ==
':') {
2938 while (*patbuf ==
';') {
2944 for (
q = (
char*)patbuf; *
q;
q++) {
2948 if ( (((
q-2)>patbuf) && ( (*(
q-2)!=
';') || !isalpha(*(
q-1)) )) &&
2955 for (
p = patbuf; *
p;
p++) {
2972 char replacement[4];
2975 for (
int k = 0; k<3; k++) replacement[k] = 0x1;
2977 replacement[3] = 0x0;
2981 while ( (pos = patbuf0.
Index(TildaNum,pos)) !=
kNPOS ) {
2982 patbuf0.
Replace(pos, 1, replacement);
2988 Int_t lbuf = ::ExpandEnvironmentStrings(
2994 cmd =
new char[lbuf+1];
2995 ::ExpandEnvironmentStrings(
3014 char newpath[MAX_PATH];
3015 if (IsShortcut(path)) {
3016 if (!ResolveShortCut(path, newpath, MAX_PATH))
3017 strlcpy(newpath, path, MAX_PATH);
3020 strlcpy(newpath, path, MAX_PATH);
3044 return ::umask(
mask);
3054 Error(
"Utime",
"need write permission for %s to change utime",
file);
3057 if (!actime) actime = modtime;
3060 t.actime = (time_t)actime;
3061 t.modtime = (time_t)modtime;
3062 return ::utime(
file, &t);
3081 return infile.
Data();
3089 Int_t lastDelim = -1;
3090 for(
int i=0; i < exsearch.
Length(); ++i) {
3091 switch( exsearch[i] ) {
3094 if (i-lastDelim!=2) exsearch[i] =
';';
3097 case ';': lastDelim = i;
break;
3104 char *lpFilePart =
nullptr;
3106 ::access(
name,
mode) == 0 && stat(
name, &finfo) == 0 &&
3107 finfo.st_mode & S_IFREG) {
3112 return infile.
Data();
3126 if ((
gEnv->
GetValue(
"WinNT.UseNetAPI", 0)) && (::GetVersion() < 0x80000000)) {
3129 HINSTANCE netapi = ::LoadLibrary(
"netapi32.DLL");
3130 if (!netapi)
return kFALSE;
3132 p2NetApiBufferFree = (pfn1)::GetProcAddress(netapi,
"NetApiBufferFree");
3133 p2NetUserGetInfo = (pfn2)::GetProcAddress(netapi,
"NetUserGetInfo");
3134 p2NetLocalGroupGetMembers = (pfn3)::GetProcAddress(netapi,
"NetLocalGroupGetMembers");
3135 p2NetLocalGroupEnum = (pfn4)::GetProcAddress(netapi,
"NetLocalGroupEnum");
3137 if (!p2NetApiBufferFree || !p2NetUserGetInfo ||
3138 !p2NetLocalGroupGetMembers || !p2NetLocalGroupEnum)
return kFALSE;
3149 ::FreeLibrary(netapi);
3159 NET_API_STATUS NetStatus = NERR_Success;
3161 DWORD Index = 0, Total = 0;
3162 DWORD_PTR ResumeHandle = 0;
3163 LOCALGROUP_MEMBERS_INFO_1 *MemberInfo;
3164 WCHAR wszGroupName[256];
3166 DWORD dwLastError = 0;
3168 iRetOp = MultiByteToWideChar (
3170 (DWORD)MB_PRECOMPOSED,
3171 (LPCSTR)lpszGroupName,
3173 (LPWSTR)wszGroupName,
3174 (
int)
sizeof(wszGroupName) );
3177 dwLastError = GetLastError();
3179 p2NetApiBufferFree(Data);
3185 NetStatus = p2NetLocalGroupGetMembers (NULL, wszGroupName, 1,
3186 &Data, 8192, &Index, &Total, &ResumeHandle );
3188 if (NetStatus != NERR_Success || Data == NULL) {
3189 dwLastError = GetLastError();
3191 if (dwLastError == ERROR_ENVVAR_NOT_FOUND) {
3197 NetStatus = p2NetLocalGroupGetMembers ( NULL, wszGroupName, 0,
3198 &Data, 8192, &Index, &Total, &ResumeHandle );
3202 p2NetApiBufferFree(Data);
3207 MemberInfo = (LOCALGROUP_MEMBERS_INFO_1 *)Data;
3210 p2NetApiBufferFree(Data);
3219 NET_API_STATUS NetStatus = NERR_Success;
3221 DWORD Index = 0, Total = 0, i;
3222 DWORD_PTR ResumeHandle = 0;
3223 LOCALGROUP_INFO_0 *GroupInfo;
3224 char szAnsiName[256];
3225 DWORD dwLastError = 0;
3228 NetStatus = p2NetLocalGroupEnum(NULL, 0, &Data, 8192, &Index,
3229 &Total, &ResumeHandle );
3231 if (NetStatus != NERR_Success || Data == NULL) {
3232 dwLastError = GetLastError();
3234 p2NetApiBufferFree(Data);
3239 GroupInfo = (LOCALGROUP_INFO_0 *)Data;
3240 for (i=0; i < Total; i++) {
3242 iRetOp = WideCharToMultiByte (
3245 (LPCWSTR)(GroupInfo->lgrpi0_name),
3248 (
int)(
sizeof(szAnsiName)),
3260 p2NetApiBufferFree(Data);
3272 int &groupIdx,
int &memberIdx)
3274 BOOL bRetOp =
FALSE;
3276 DWORD dwSidSize, dwDomainNameSize;
3279 SID_NAME_USE sidType;
3280 PUCHAR puchar_SubAuthCount = NULL;
3281 SID_IDENTIFIER_AUTHORITY sid_identifier_authority;
3282 PSID_IDENTIFIER_AUTHORITY psid_identifier_authority = NULL;
3283 unsigned char j = 0;
3284 DWORD dwLastError = 0;
3286 pSid = (PSID)bySidBuffer;
3287 dwSidSize =
sizeof(bySidBuffer);
3288 dwDomainNameSize =
sizeof(szDomainName);
3290 bRetOp = LookupAccountName (
3292 (LPCTSTR)lpszAccountName,
3294 (LPDWORD)&dwSidSize,
3295 (LPTSTR)szDomainName,
3296 (LPDWORD)&dwDomainNameSize,
3297 (PSID_NAME_USE)&sidType );
3299 if (bRetOp ==
FALSE) {
3300 dwLastError = GetLastError();
3304 bRetOp = IsValidSid((PSID)pSid);
3306 if (bRetOp ==
FALSE) {
3307 dwLastError = GetLastError();
3312 psid_identifier_authority = GetSidIdentifierAuthority ((PSID)pSid);
3315 memcpy (&sid_identifier_authority, psid_identifier_authority,
3316 sizeof(SID_IDENTIFIER_AUTHORITY));
3319 puchar_SubAuthCount = (PUCHAR)GetSidSubAuthorityCount((PSID)pSid);
3321 j = (
unsigned char)(*puchar_SubAuthCount);
3323 DWORD dwSubAuth = 0;
3324 PDWORD pdwSubAuth = NULL;
3326 pdwSubAuth = (PDWORD)GetSidSubAuthority (
3329 dwSubAuth = *pdwSubAuth;
3348 NET_API_STATUS NetStatus = NERR_Success;
3350 DWORD Index = 0, Total = 0, i;
3351 DWORD_PTR ResumeHandle = 0;
3352 LOCALGROUP_MEMBERS_INFO_1 *MemberInfo;
3353 char szAnsiMemberName[256];
3354 char szFullMemberName[256];
3355 char szMemberHomeDir[256];
3356 WCHAR wszGroupName[256];
3359 DWORD
length =
sizeof (act_name);
3360 DWORD dwLastError = 0;
3361 LPUSER_INFO_11 pUI11Buf = NULL;
3362 NET_API_STATUS nStatus;
3364 iRetOp = MultiByteToWideChar (
3366 (DWORD)MB_PRECOMPOSED,
3367 (LPCSTR)lpszGroupName,
3369 (LPWSTR)wszGroupName,
3370 (
int)
sizeof(wszGroupName) );
3373 dwLastError = GetLastError();
3375 p2NetApiBufferFree(Data);
3379 GetUserName (act_name, &
length);
3383 NetStatus = p2NetLocalGroupGetMembers (NULL, wszGroupName, 1,
3384 &Data, 8192, &Index, &Total, &ResumeHandle );
3386 if (NetStatus != NERR_Success || Data == NULL) {
3387 dwLastError = GetLastError();
3389 if (dwLastError == ERROR_ENVVAR_NOT_FOUND) {
3395 NetStatus = p2NetLocalGroupGetMembers ( NULL, wszGroupName, 0,
3396 &Data, 8192, &Index, &Total, &ResumeHandle );
3400 p2NetApiBufferFree(Data);
3404 MemberInfo = (LOCALGROUP_MEMBERS_INFO_1 *)Data;
3405 for (i=0; i < Total; i++) {
3406 iRetOp = WideCharToMultiByte (
3409 (LPCWSTR)(MemberInfo->lgrmi1_name),
3411 (LPSTR)szAnsiMemberName,
3412 (
int)(
sizeof(szAnsiMemberName)),
3417 dwLastError = GetLastError();
3428 TCHAR szUserName[255]=TEXT(
"");
3429 MultiByteToWideChar(CP_ACP, 0, szAnsiMemberName, -1, (LPWSTR)szUserName, 255);
3433 nStatus = p2NetUserGetInfo(NULL, (LPCWSTR)szUserName, 11, (LPBYTE *)&pUI11Buf);
3437 if (nStatus == NERR_Success) {
3438 if (pUI11Buf != NULL) {
3439 wsprintf(szFullMemberName,
"%S",pUI11Buf->usri11_full_name);
3441 wsprintf(szMemberHomeDir,
"%S",pUI11Buf->usri11_home_dir);
3452 if (pUI11Buf != NULL) {
3453 p2NetApiBufferFree(pUI11Buf);
3458 if (getenv(
"SHELL") == NULL)
3459 putenv ((GetVersion () & 0x80000000) ?
"SHELL=command" :
"SHELL=cmd");
3472 p2NetApiBufferFree(Data);
3482 NET_API_STATUS NetStatus = NERR_Success;
3484 DWORD Index = 0, Total = 0, i;
3485 DWORD_PTR ResumeHandle = 0;
3486 LOCALGROUP_INFO_0 *GroupInfo;
3487 char szAnsiName[256];
3488 DWORD dwLastError = 0;
3489 int iRetOp = 0, iGroupIdx = 0, iMemberIdx = 0;
3491 NetStatus = p2NetLocalGroupEnum(NULL, 0, &Data, 8192, &Index,
3492 &Total, &ResumeHandle );
3494 if (NetStatus != NERR_Success || Data == NULL) {
3495 dwLastError = GetLastError();
3497 p2NetApiBufferFree(Data);
3501 GroupInfo = (LOCALGROUP_INFO_0 *)Data;
3502 for (i=0; i < Total; i++) {
3504 iRetOp = WideCharToMultiByte (
3507 (LPCWSTR)(GroupInfo->lgrpi0_name),
3510 (
int)(
sizeof(szAnsiName)),
3528 p2NetApiBufferFree(Data);
3542 if ((!
gEnv->
GetValue(
"WinNT.UseNetAPI", 0)) || (::GetVersion() >= 0x80000000)) {
3547 if (stricmp (
"administrator",
name) == 0)
3557 if (!user || !user[0])
3562 if (!stricmp (user,
fPasswords[i].pw_name)) {
3583 if ((!
gEnv->
GetValue(
"WinNT.UseNetAPI", 0)) || (::GetVersion() >= 0x80000000)) {
3588 if (stricmp (
"administrator",
name) == 0)
3610 if ((!
gEnv->
GetValue(
"WinNT.UseNetAPI", 0)) || (::GetVersion() >= 0x80000000)) {
3615 if (stricmp (
"administrator",
name) == 0)
3628 struct group *grp =
nullptr;
3651 if ((!
gEnv->
GetValue(
"WinNT.UseNetAPI", 0)) || (::GetVersion() >= 0x80000000)) {
3656 if (stricmp (
"administrator",
name) == 0)
3679 if ((!
gEnv->
GetValue(
"WinNT.UseNetAPI", 0)) || (::GetVersion() >= 0x80000000)) {
3685 if (stricmp (
"administrator",
name) == 0) {
3687 ug->
fGroup =
"administrators";
3696 ug->
fUser =
"unknown";
3709 for (
int i = 0; i <
fNbUsers; i++) {
3753 if ((!
gEnv->
GetValue(
"WinNT.UseNetAPI", 0)) || (::GetVersion() >= 0x80000000)) {
3758 if (stricmp (
"administrator",
name) == 0) {
3759 gr->fGroup =
"administrators";
3763 gr->fGroup =
"users";
3768 gr->fGroup =
"unknown";
3774 struct group *grp =
nullptr;
3776 if (gid ==
fGroups[i].gr_gid) {
3818 const char *env = ::getenv(
name);
3820 if (::_stricmp(
name,
"home") == 0 ) {
3822 }
else if (::_stricmp(
name,
"rootsys") == 0 ) {
3836 return ::system(shellcmd);
3844 return ::_popen(command,
mode);
3852 return ::_pclose(pipe);
3880 gROOT->CloseFiles();
3881 if (
gROOT->GetListOfBrowsers()) {
3884 if (
gROOT->IsBatch())
3885 gROOT->GetListOfBrowsers()->Delete();
3890 if (
b->GetBrowserImp() &&
b->GetBrowserImp()->GetMainFrame())
3892 (((TBrowser*)0x%zx)->GetBrowserImp()->GetMainFrame()->CloseWindow();",
3934 static int fd1=0, fd2=0;
3935 static fpos_t pos1=0, pos2=0;
3945 const char *
m = (
mode[0] ==
'a' ||
mode[0] ==
'w') ?
mode :
"a";
3958 fgetpos(stdout, &pos1);
3959 fd1 = _dup(fileno(stdout));
3961 if ((fout = freopen(
file,
m, stdout)) == 0) {
3962 SysError(
"RedirectOutput",
"could not freopen stdout");
3964 _dup2(fd1, fileno(stdout));
3968 fsetpos(stdout, &pos1);
3973 fgetpos(stderr, &pos2);
3974 fd2 = _dup(fileno(stderr));
3975 if ((ferr = freopen(
file,
m, stderr)) == 0) {
3976 SysError(
"RedirectOutput",
"could not freopen stderr");
3978 _dup2(fd1, fileno(stdout));
3982 fsetpos(stdout, &pos1);
3984 _dup2(fd2, fileno(stderr));
3988 fsetpos(stderr, &pos2);
3993 fseek(fout, 0, SEEK_END);
3994 fseek(ferr, 0, SEEK_END);
4001 if (_dup2(fd1, fileno(stdout))) {
4002 SysError(
"RedirectOutput",
"could not restore stdout");
4008 fsetpos(stdout, &pos1);
4015 if (_dup2(fd2, fileno(stderr))) {
4016 SysError(
"RedirectOutput",
"could not restore stderr");
4022 fsetpos(stderr, &pos2);
4077 if (
len > 4 && (!stricmp(sLib.
Data()+
len-4,
".dll"))) {
4090 Error(
"DynamicPathName",
4091 "%s does not exist in %s,\nor has wrong file extension (.dll)",
4108#pragma warning(push)
4109#pragma warning(disable:4200)
4126 if (!linkedLibs.
IsNull())
4139 HANDLE hFile, hMapping;
4142 if((hFile = CreateFile(exe,GENERIC_READ,FILE_SHARE_READ,0,OPEN_EXISTING,FILE_FLAG_SEQUENTIAL_SCAN,0))==
INVALID_HANDLE_VALUE) {
4146 if(!(hMapping = CreateFileMapping(hFile,0,PAGE_READONLY|SEC_COMMIT,0,0,0))) {
4151 if(!(basepointer = MapViewOfFile(hMapping,FILE_MAP_READ,0,0,0))) {
4152 CloseHandle(hMapping);
4159 IMAGE_DOS_HEADER *dos_head = (IMAGE_DOS_HEADER *)basepointer;
4162 IMAGE_FILE_HEADER _head;
4163 IMAGE_OPTIONAL_HEADER opt_head;
4164 IMAGE_SECTION_HEADER section_header[];
4166 struct header *pheader;
4167 const IMAGE_SECTION_HEADER * section_header;
4169 if(dos_head->e_magic!=
'ZM') {
4174 pheader = (
struct header *)((
char*)dos_head + dos_head->e_lfanew);
4176 if(IsBadReadPtr(pheader,
sizeof(
struct header))) {
4180 if(pheader->signature!=IMAGE_NT_SIGNATURE) {
4181 switch((
unsigned short)pheader->signature) {
4182 case IMAGE_DOS_SIGNATURE:
4185 case IMAGE_OS2_SIGNATURE:
4188 case IMAGE_OS2_SIGNATURE_LE:
4196#define isin(address,start,length) ((address)>=(start) && (address)<(start)+(length))
4199 for(sect=0,section_header=pheader->section_header;
4200 sect<pheader->_head.NumberOfSections;sect++,section_header++) {
4202 const void *
const section_data =
4203 (
char*)basepointer + section_header->PointerToRawData;
4204 for(directory=0;directory<IMAGE_NUMBEROF_DIRECTORY_ENTRIES;directory++) {
4205 if(
isin(pheader->opt_head.DataDirectory[directory].VirtualAddress,
4206 section_header->VirtualAddress,
4207 section_header->SizeOfRawData)) {
4208 const IMAGE_IMPORT_DESCRIPTOR *stuff_start =
4209 (IMAGE_IMPORT_DESCRIPTOR *)((
char*)section_data +
4210 (pheader->opt_head.DataDirectory[directory].VirtualAddress -
4211 section_header->VirtualAddress));
4214 const unsigned stuff_length =
4215 pheader->opt_head.DataDirectory[directory].Size;
4216 if(directory == IMAGE_DIRECTORY_ENTRY_IMPORT) {
4217 while(!IsBadReadPtr(stuff_start,
sizeof(*stuff_start)) &&
4218 stuff_start->Name) {
4219 TString dll = (
char*)section_data +
4220 ((DWORD)(stuff_start->Name)) -
4221 section_header->VirtualAddress;
4225 char *winPath = getenv(
"windir");
4226 _splitpath(winPath,winDrive,winDir,winName,winExt);
4227 if(!strstr(dllPath, winDir)) {
4228 if (!linkedLibs.
IsNull())
4230 linkedLibs += dllPath;
4242 UnmapViewOfFile(basepointer);
4243 CloseHandle(hMapping);
4274 char drive[_MAX_DRIVE], dir[_MAX_DIR], fname[_MAX_FNAME], ext[_MAX_EXT];
4277 std::vector<std::string> all_libs, libpaths;
4283 while (getline(libenv, str,
';')) {
4284 libpaths.push_back(str);
4287 std::stringstream libraries(libs.
Data());
4288 while (getline(libraries, str,
' ')) {
4289 std::string::size_type
first, last;
4292 if (str.rfind(
"-L", 0) == 0) {
4293 first = str.find_first_of(
'%');
4294 last = str.find_last_of(
'%');
4295 if ((
first != std::string::npos) && (last != std::string::npos) &&
4300 std::string var = str.substr(
first+1, last-
first-1);
4305 env += str.substr(last+1);
4306 libpaths.push_back(env);
4310 ntlibs.
Append(str.c_str());
4315 last = str.rfind(
".dll");
4316 if (last != std::string::npos)
4317 str.replace(last, 4,
".lib");
4318 last = str.rfind(
".DLL");
4319 if (last != std::string::npos)
4320 str.replace(last, 4,
".lib");
4321 if (str.rfind(
".lib") != std::string::npos ||
4322 str.rfind(
".LIB") != std::string::npos) {
4324 if (_stat( str.c_str(), &buf ) == 0) {
4326 ntlibs.
Append(str.c_str());
4334 _splitpath(str.c_str(), drive, dir, fname, ext);
4335 std::string libname(fname);
4337 all_libs.push_back(libname);
4339 for (
auto lib : all_libs) {
4341 for (
auto libpath : libpaths) {
4343 std::string path_lib(libpath);
4346 if (_stat( path_lib.c_str(), &buf ) == 0) {
4348 ntlibs.
Append(lib.c_str());
4377 if (!ti)
return nullptr;
4434 FILETIME ftFileTime;
4438 ::GetSystemTimeAsFileTime(&ftRealTime.ftFileTime);
4447 OSVERSIONINFO OsVersionInfo;
4456 OsVersionInfo.dwOSVersionInfoSize =
sizeof(OSVERSIONINFO);
4457 GetVersionEx(&OsVersionInfo);
4458 if (OsVersionInfo.dwPlatformId == VER_PLATFORM_WIN32_NT) {
4464 FILETIME ftFileTime;
4469 FILETIME ftFileTime;
4473 HANDLE hThread = GetCurrentThread();
4474 ret = GetThreadTimes (hThread, &ftCreate, &ftExit,
4475 &ftKernel.ftFileTime,
4476 &ftUser.ftFileTime);
4478 ret = ::GetLastError();
4479 ::Error(
"GetCPUTime",
" Error on GetProcessTimes 0x%lx", (
int)ret);
4499 static time_t jan95 = 0;
4510 jan95 = mktime(&tp);
4511 if ((
int)jan95 == -1) {
4512 ::SysError(
"TWinNTSystem::Now",
"error converting 950001 0:00 to time_t");
4519 return TTime((now.time-(
Long_t)jan95)*1000 + now.millitm);
4545 if (
h->HasReadInterest())
4547 if (
h->HasWriteInterest())
4549 h->ResetReadyMask();
4551 rc = WinNTSelect(&rd, &wr, to);
4580 if (
h->HasReadInterest())
4582 if (
h->HasWriteInterest())
4584 h->ResetReadyMask();
4585 rc = WinNTSelect(&rd, &wr, to);
4607 if ((sp = ::getservbyname(servicename,
kProtocolName)) == 0) {
4608 Error(
"GetServiceByName",
"no service \"%s\" with protocol \"%s\"\n",
4612 return ::ntohs(sp->s_port);
4623 if ((sp = ::getservbyport(::htons(port),
kProtocolName)) == 0) {
4624 return Form(
"%d", port);
4634 struct hostent *host_ptr;
4639 if ((addr = ::inet_addr(hostname)) != INADDR_NONE) {
4641 if ((host_ptr = ::gethostbyaddr((
const char *)&addr,
4642 sizeof(addr), AF_INET))) {
4643 host = host_ptr->h_name;
4647 for (i = 1; host_ptr->h_addr_list[i]; i++) {
4648 memcpy(&addr2, host_ptr->h_addr_list[i], host_ptr->h_length);
4649 a.AddAddress(ntohl(addr2));
4651 for (i = 0; host_ptr->h_aliases[i]; i++)
4652 a.AddAlias(host_ptr->h_aliases[i]);
4655 host =
"UnNamedHost";
4657 }
else if ((host_ptr = ::gethostbyname(hostname))) {
4659 if (host_ptr->h_addrtype != AF_INET) {
4660 Error(
"GetHostByName",
"%s is not an internet host\n", hostname);
4663 memcpy(&addr, host_ptr->h_addr, host_ptr->h_length);
4664 host = host_ptr->h_name;
4665 type = host_ptr->h_addrtype;
4669 for (i = 1; host_ptr->h_addr_list[i]; i++) {
4670 memcpy(&addr2, host_ptr->h_addr_list[i], host_ptr->h_length);
4671 a.AddAddress(ntohl(addr2));
4673 for (i = 0; host_ptr->h_aliases[i]; i++)
4674 a.AddAlias(host_ptr->h_aliases[i]);
4677 if (
gDebug > 0)
Error(
"GetHostByName",
"unknown host %s", hostname);
4690 struct sockaddr_in addr;
4691 int len =
sizeof(addr);
4693 if (::getpeername(sock, (
struct sockaddr *)&addr, &
len) == SOCKET_ERROR) {
4698 struct hostent *host_ptr;
4699 const char *hostname;
4703 if ((host_ptr = ::gethostbyaddr((
const char *)&addr.sin_addr,
4704 sizeof(addr.sin_addr), AF_INET))) {
4705 memcpy(&iaddr, host_ptr->h_addr, host_ptr->h_length);
4706 hostname = host_ptr->h_name;
4707 family = host_ptr->h_addrtype;
4709 memcpy(&iaddr, &addr.sin_addr,
sizeof(addr.sin_addr));
4714 return TInetAddress(hostname, ::ntohl(iaddr), family, ::ntohs(addr.sin_port));
4723 struct sockaddr_in addr;
4724 int len =
sizeof(addr);
4726 if (::getsockname(sock, (
struct sockaddr *)&addr, &
len) == SOCKET_ERROR) {
4731 struct hostent *host_ptr;
4732 const char *hostname;
4736 if ((host_ptr = ::gethostbyaddr((
const char *)&addr.sin_addr,
4737 sizeof(addr.sin_addr), AF_INET))) {
4738 memcpy(&iaddr, host_ptr->h_addr, host_ptr->h_length);
4739 hostname = host_ptr->h_name;
4740 family = host_ptr->h_addrtype;
4742 memcpy(&iaddr, &addr.sin_addr,
sizeof(addr.sin_addr));
4747 return TInetAddress(hostname, ::ntohl(iaddr), family, ::ntohs(addr.sin_port));
4759 ::SysError(
"TWinNTSystem::AnnounceUnixService",
"socket");
4763 struct sockaddr_in inserver;
4764 memset(&inserver, 0,
sizeof(inserver));
4765 inserver.sin_family = AF_INET;
4766 inserver.sin_addr.s_addr = ::htonl(INADDR_LOOPBACK);
4767 inserver.sin_port = port;
4771 if (::bind(sock, (
struct sockaddr*) &inserver,
sizeof(inserver)) == SOCKET_ERROR) {
4772 ::SysError(
"TWinNTSystem::AnnounceUnixService",
"bind");
4777 if (::listen(sock, backlog)) {
4778 ::SysError(
"TWinNTSystem::AnnounceUnixService",
"listen");
4790 if (!sockpath || strlen(sockpath) <= 0) {
4791 ::SysError(
"TWinNTSystem::AnnounceUnixService",
"socket path undefined");
4795 struct sockaddr_in myaddr;
4797 int len =
sizeof myaddr;
4802 if ((sock =
socket(AF_INET, SOCK_STREAM, 0)) < 0) {
4803 ::SysError(
"TWinNTSystem::AnnounceUnixService",
"socket");
4807 memset(&myaddr, 0,
sizeof(myaddr));
4808 myaddr.sin_port = 0;
4809 myaddr.sin_family = AF_INET;
4810 myaddr.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
4812 rc = bind(sock, (
struct sockaddr *)&myaddr,
len);
4814 ::SysError(
"TWinNTSystem::AnnounceUnixService",
"bind");
4817 rc = getsockname(sock, (
struct sockaddr *)&myaddr, &
len);
4819 ::SysError(
"TWinNTSystem::AnnounceUnixService",
"getsockname");
4822 TString socketpath = sockpath;
4824 fp = fopen(socketpath,
"wb");
4826 ::SysError(
"TWinNTSystem::AnnounceUnixService",
"fopen");
4829 fprintf(fp,
"%d", myaddr.sin_port);
4833 if (listen(sock, backlog)) {
4834 ::SysError(
"TWinNTSystem::AnnounceUnixService",
"listen");
4846 if (
socket == -1)
return;
4850 ::shutdown(sock, 2);
4852 struct linger linger = {0, 0};
4853 ::setsockopt(sock, SOL_SOCKET, SO_LINGER, (
char *) &linger,
sizeof(linger));
4854 while (
::closesocket(sock) == SOCKET_ERROR && WSAGetLastError() == WSAEINTR) {
4868 if (WinNTRecv(sock, &header,
sizeof(header), 0) > 0) {
4869 int count = ::ntohl(header);
4872 Error(
"RecvBuf",
"record header exceeds buffer size");
4874 }
else if (count > 0) {
4875 if (WinNTRecv(sock, buf, count, 0) < 0) {
4876 Error(
"RecvBuf",
"cannot receive buffer");
4893 if (WinNTSend(sock, &header,
sizeof(header), 0) < 0) {
4894 Error(
"SendBuf",
"cannot send header");
4898 if (WinNTSend(sock, buf,
length, 0) < 0) {
4899 Error(
"SendBuf",
"cannot send buffer");
4939 if ((
n = WinNTRecv(sock, buf,
length, flag)) <= 0) {
4941 Error(
"RecvRaw",
"cannot receive buffer");
4975 if ((
n = WinNTSend(sock, buf,
length, flag)) <= 0) {
4977 Error(
"SendRaw",
"cannot send buffer");
4990 if (
socket == -1)
return -1;
4995 if (::setsockopt(sock, SOL_SOCKET, SO_SNDBUF, (
char*)&val,
sizeof(val)) == SOCKET_ERROR) {
4996 ::SysError(
"SetSockOpt",
"setsockopt(SO_SNDBUF)");
5001 if (::setsockopt(sock, SOL_SOCKET, SO_RCVBUF, (
char*)&val,
sizeof(val)) == SOCKET_ERROR) {
5002 ::SysError(
"SetSockOpt",
"setsockopt(SO_RCVBUF)");
5007 if (::setsockopt(sock, SOL_SOCKET, SO_OOBINLINE, (
char*)&val,
sizeof(val)) == SOCKET_ERROR) {
5008 SysError(
"SetSockOpt",
"setsockopt(SO_OOBINLINE)");
5013 if (::setsockopt(sock, SOL_SOCKET, SO_KEEPALIVE, (
char*)&val,
sizeof(val)) == SOCKET_ERROR) {
5014 ::SysError(
"SetSockOpt",
"setsockopt(SO_KEEPALIVE)");
5019 if (::setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (
char*)&val,
sizeof(val)) == SOCKET_ERROR) {
5020 ::SysError(
"SetSockOpt",
"setsockopt(SO_REUSEADDR)");
5025 if (::setsockopt(sock, IPPROTO_TCP, TCP_NODELAY, (
char*)&val,
sizeof(val)) == SOCKET_ERROR) {
5026 ::SysError(
"SetSockOpt",
"setsockopt(TCP_NODELAY)");
5031 if (::ioctlsocket(sock, FIONBIO, &val) == SOCKET_ERROR) {
5038 if (::ioctl(sock, SIOCSPGRP, &val) == -1) {
5039 ::SysError(
"SetSockOpt",
"ioctl(SIOCSPGRP)");
5047 Error(
"SetSockOpt",
"illegal option (%d)", opt);
5059 if (
socket == -1)
return -1;
5062 int optlen =
sizeof(*val);
5066 if (::getsockopt(sock, SOL_SOCKET, SO_SNDBUF, (
char*)val, &optlen) == SOCKET_ERROR) {
5067 ::SysError(
"GetSockOpt",
"getsockopt(SO_SNDBUF)");
5072 if (::getsockopt(sock, SOL_SOCKET, SO_RCVBUF, (
char*)val, &optlen) == SOCKET_ERROR) {
5073 ::SysError(
"GetSockOpt",
"getsockopt(SO_RCVBUF)");
5078 if (::getsockopt(sock, SOL_SOCKET, SO_OOBINLINE, (
char*)val, &optlen) == SOCKET_ERROR) {
5079 ::SysError(
"GetSockOpt",
"getsockopt(SO_OOBINLINE)");
5084 if (::getsockopt(sock, SOL_SOCKET, SO_KEEPALIVE, (
char*)val, &optlen) == SOCKET_ERROR) {
5085 ::SysError(
"GetSockOpt",
"getsockopt(SO_KEEPALIVE)");
5090 if (::getsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (
char*)val, &optlen) == SOCKET_ERROR) {
5091 ::SysError(
"GetSockOpt",
"getsockopt(SO_REUSEADDR)");
5096 if (::getsockopt(sock, IPPROTO_TCP, TCP_NODELAY, (
char*)val, &optlen) == SOCKET_ERROR) {
5097 ::SysError(
"GetSockOpt",
"getsockopt(TCP_NODELAY)");
5113 if (::ioctlsocket(sock, SIOCGPGRP, (u_long*)val) == SOCKET_ERROR) {
5114 ::SysError(
"GetSockOpt",
"ioctl(SIOCGPGRP)");
5120 if (::ioctlsocket(sock, SIOCATMARK, (u_long*)val) == SOCKET_ERROR) {
5121 ::SysError(
"GetSockOpt",
"ioctl(SIOCATMARK)");
5126 if (::ioctlsocket(sock, FIONREAD, (u_long*)val) == SOCKET_ERROR) {
5132 Error(
"GetSockOpt",
"illegal option (%d)", opt);
5144 int tcpwindowsize,
const char *protocol)
5149 if (!strcmp(servername,
"unix")) {
5153 (servername[1] ==
':' && servername[2] ==
'/')) {
5157 if (!strcmp(protocol,
"udp")){
5164 sport = ::htons(port);
5168 if (!addr.
IsValid())
return -1;
5171 struct sockaddr_in server;
5172 memset(&server, 0,
sizeof(server));
5173 memcpy(&server.sin_addr, &adr,
sizeof(adr));
5175 server.sin_port = sport;
5180 ::SysError(
"TWinNTSystem::WinNTConnectTcp",
"socket");
5184 if (tcpwindowsize > 0) {
5189 if (::connect(sock, (
struct sockaddr*) &server,
sizeof(server)) ==
INVALID_SOCKET) {
5202 struct sockaddr_in myaddr;
5205 memset(&myaddr, 0,
sizeof(myaddr));
5206 myaddr.sin_family = AF_INET;
5207 myaddr.sin_port = port;
5208 myaddr.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
5211 if ((sock =
socket(AF_INET, SOCK_STREAM, 0)) < 0) {
5212 ::SysError(
"TWinNTSystem::WinNTUnixConnect",
"socket");
5216 while ((connect(sock, (
struct sockaddr *)&myaddr,
sizeof myaddr)) == -1) {
5220 ::SysError(
"TWinNTSystem::WinNTUnixConnect",
"connect");
5236 if (!sockpath || strlen(sockpath) <= 0) {
5237 ::SysError(
"TWinNTSystem::WinNTUnixConnect",
"socket path undefined");
5240 TString socketpath = sockpath;
5242 fp = fopen(socketpath.
Data(),
"rb");
5244 ::SysError(
"TWinNTSystem::WinNTUnixConnect",
"fopen");
5247 fscanf(fp,
"%d", &port);
5250 if (port < 0 || port > 65535) {
5251 ::SysError(
"TWinNTSystem::WinNTUnixConnect",
"invalid port");
5269 sport = htons(port);
5272 if (!addr.
IsValid())
return -1;
5275 struct sockaddr_in server;
5276 memset(&server, 0,
sizeof(server));
5277 memcpy(&server.sin_addr, &adr,
sizeof(adr));
5279 server.sin_port = sport;
5283 if ((sock =
socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) < 0) {
5284 ::SysError(
"TWinNTSystem::WinNTUdpConnect",
"socket (%s:%d)",
5289 while (connect(sock, (
struct sockaddr*) &server,
sizeof(server)) == -1) {
5293 ::SysError(
"TWinNTSystem::WinNTUdpConnect",
"connect (%s:%d)",
5311 const char *protocol)
5332 const short kSOCKET_MINPORT = 5000, kSOCKET_MAXPORT = 15000;
5333 short tryport = kSOCKET_MINPORT;
5338 sport = ::htons(port);
5341 if (port == 0 && reuse) {
5342 ::Error(
"TWinNTSystem::WinNTTcpService",
"cannot do a port scan while reuse is true");
5349 sport = ::htons(port);
5354 if ((sock =
::socket(AF_INET, SOCK_STREAM, 0)) < 0) {
5355 ::SysError(
"TWinNTSystem::WinNTTcpService",
"socket");
5363 if (tcpwindowsize > 0) {
5368 struct sockaddr_in inserver;
5369 memset(&inserver, 0,
sizeof(inserver));
5370 inserver.sin_family = AF_INET;
5371 inserver.sin_addr.s_addr = ::htonl(INADDR_ANY);
5372 inserver.sin_port = sport;
5376 if (::bind(sock, (
struct sockaddr*) &inserver,
sizeof(inserver)) == SOCKET_ERROR) {
5377 ::SysError(
"TWinNTSystem::WinNTTcpService",
"bind");
5383 inserver.sin_port = ::htons(tryport);
5384 bret = ::bind(sock, (
struct sockaddr*) &inserver,
sizeof(inserver));
5386 }
while (bret == SOCKET_ERROR && WSAGetLastError() == WSAEADDRINUSE &&
5387 tryport < kSOCKET_MAXPORT);
5388 if (bret == SOCKET_ERROR) {
5389 ::SysError(
"TWinNTSystem::WinNTTcpService",
"bind (port scan)");
5395 if (::listen(sock, backlog) == SOCKET_ERROR) {
5396 ::SysError(
"TWinNTSystem::WinNTTcpService",
"listen");
5413 const short kSOCKET_MINPORT = 5000, kSOCKET_MAXPORT = 15000;
5414 short sport, tryport = kSOCKET_MINPORT;
5420 sport = htons(port);
5424 if ((sock =
socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) < 0) {
5425 ::SysError(
"TUnixSystem::UnixUdpService",
"socket");
5429 struct sockaddr_in inserver;
5430 memset(&inserver, 0,
sizeof(inserver));
5431 inserver.sin_family = AF_INET;
5432 inserver.sin_addr.s_addr = htonl(INADDR_ANY);
5433 inserver.sin_port = sport;
5437 if (bind(sock, (
struct sockaddr*) &inserver,
sizeof(inserver))) {
5438 ::SysError(
"TWinNTSystem::AnnounceUdpService",
"bind");
5444 inserver.sin_port = htons(tryport);
5445 bret = bind(sock, (
struct sockaddr*) &inserver,
sizeof(inserver));
5447 }
while (bret == SOCKET_ERROR && WSAGetLastError() == WSAEADDRINUSE &&
5448 tryport < kSOCKET_MAXPORT);
5450 ::SysError(
"TWinNTSystem::AnnounceUdpService",
"bind (port scan)");
5456 if (listen(sock, backlog)) {
5457 ::SysError(
"TWinNTSystem::AnnounceUdpService",
"listen");
5475 (::WSAGetLastError() == WSAEINTR)) {
5480 if (::WSAGetLastError() == WSAEWOULDBLOCK) {
5494#define SystemBasicInformation 0
5495#define SystemPerformanceInformation 2
5535#define Li2Double(x) ((double)((x).HighPart) * 4.294967296E9 + (double)((x).LowPart))
5543 LARGE_INTEGER ulFreq, ulTicks, ulValue, ulStartCounter;
5547 if (QueryPerformanceFrequency(&ulFreq)) {
5549 QueryPerformanceCounter(&ulTicks);
5552 ulValue.QuadPart = ulTicks.QuadPart + ulFreq.QuadPart/10;
5553 ulStartCounter.QuadPart =
__rdtsc();
5557 QueryPerformanceCounter(&ulTicks);
5558 }
while (ulTicks.QuadPart <= ulValue.QuadPart);
5560 return (DWORD)((
__rdtsc() - ulStartCounter.QuadPart)/100000);
5568#define SM_SERVERR2 89
5569typedef void (WINAPI *
PGNSI)(LPSYSTEM_INFO);
5575 OSVERSIONINFOEX osvi;
5578 BOOL bOsVersionInfoEx;
5579 static char *strReturn =
nullptr;
5583 strReturn =
new char[2048];
5587 ZeroMemory(&si,
sizeof(SYSTEM_INFO));
5588 ZeroMemory(&osvi,
sizeof(OSVERSIONINFOEX));
5593 osvi.dwOSVersionInfoSize =
sizeof(OSVERSIONINFOEX);
5595 if( !(bOsVersionInfoEx = GetVersionEx ((OSVERSIONINFO *) &osvi)) )
5597 osvi.dwOSVersionInfoSize =
sizeof (OSVERSIONINFO);
5598 if (! GetVersionEx ( (OSVERSIONINFO *) &osvi) )
5603 pGNSI = (
PGNSI) GetProcAddress( GetModuleHandle(
"kernel32.dll"),
5604 "GetNativeSystemInfo");
5607 else GetSystemInfo(&si);
5609 switch (osvi.dwPlatformId)
5612 case VER_PLATFORM_WIN32_NT:
5615 if ( osvi.dwMajorVersion == 6 && osvi.dwMinorVersion == 0 )
5617 if( osvi.wProductType == VER_NT_WORKSTATION )
5618 strlcpy(strReturn,
"Microsoft Windows Vista ",2048);
5619 else strlcpy(strReturn,
"Windows Server \"Longhorn\" " ,2048);
5621 if ( osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 2 )
5624 strlcpy(strReturn,
"Microsoft Windows Server 2003 \"R2\" ",2048);
5625 else if( osvi.wProductType == VER_NT_WORKSTATION &&
5626 si.wProcessorArchitecture==PROCESSOR_ARCHITECTURE_AMD64)
5628 strlcpy(strReturn,
"Microsoft Windows XP Professional x64 Edition ",2048);
5630 else strlcpy(strReturn,
"Microsoft Windows Server 2003, ",2048);
5632 if ( osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 1 )
5633 strlcpy(strReturn,
"Microsoft Windows XP ",2048);
5635 if ( osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 0 )
5636 strlcpy(strReturn,
"Microsoft Windows 2000 ",2048);
5638 if ( osvi.dwMajorVersion <= 4 )
5639 strlcpy(strReturn,
"Microsoft Windows NT ",2048);
5642 if( bOsVersionInfoEx )
5645 if ( osvi.wProductType == VER_NT_WORKSTATION &&
5646 si.wProcessorArchitecture!=PROCESSOR_ARCHITECTURE_AMD64)
5648 if( osvi.dwMajorVersion == 4 )
5649 strlcat(strReturn,
"Workstation 4.0 ",2048 );
5650 else if( osvi.wSuiteMask & VER_SUITE_PERSONAL )
5651 strlcat(strReturn,
"Home Edition " ,2048);
5652 else strlcat(strReturn,
"Professional " ,2048);
5655 else if ( osvi.wProductType == VER_NT_SERVER ||
5656 osvi.wProductType == VER_NT_DOMAIN_CONTROLLER )
5658 if(osvi.dwMajorVersion==5 && osvi.dwMinorVersion==2)
5660 if ( si.wProcessorArchitecture==PROCESSOR_ARCHITECTURE_IA64 )
5662 if( osvi.wSuiteMask & VER_SUITE_DATACENTER )
5663 strlcat(strReturn,
"Datacenter Edition for Itanium-based Systems",2048 );
5664 else if( osvi.wSuiteMask & VER_SUITE_ENTERPRISE )
5665 strlcat(strReturn,
"Enterprise Edition for Itanium-based Systems" ,2048);
5667 else if ( si.wProcessorArchitecture==PROCESSOR_ARCHITECTURE_AMD64 )
5669 if( osvi.wSuiteMask & VER_SUITE_DATACENTER )
5670 strlcat(strReturn,
"Datacenter x64 Edition ",2048 );
5671 else if( osvi.wSuiteMask & VER_SUITE_ENTERPRISE )
5672 strlcat(strReturn,
"Enterprise x64 Edition ",2048 );
5673 else strlcat(strReturn,
"Standard x64 Edition ",2048 );
5677 if( osvi.wSuiteMask & VER_SUITE_DATACENTER )
5678 strlcat(strReturn,
"Datacenter Edition ",2048 );
5679 else if( osvi.wSuiteMask & VER_SUITE_ENTERPRISE )
5680 strlcat(strReturn,
"Enterprise Edition ",2048 );
5681 else if ( osvi.wSuiteMask == VER_SUITE_BLADE )
5682 strlcat(strReturn,
"Web Edition " ,2048);
5683 else strlcat(strReturn,
"Standard Edition ",2048 );
5686 else if(osvi.dwMajorVersion==5 && osvi.dwMinorVersion==0)
5688 if( osvi.wSuiteMask & VER_SUITE_DATACENTER )
5689 strlcat(strReturn,
"Datacenter Server ",2048 );
5690 else if( osvi.wSuiteMask & VER_SUITE_ENTERPRISE )
5691 strlcat(strReturn,
"Advanced Server ",2048 );
5692 else strlcat(strReturn,
"Server ",2048 );
5696 if( osvi.wSuiteMask & VER_SUITE_ENTERPRISE )
5697 strlcat(strReturn,
"Server 4.0, Enterprise Edition " ,2048);
5698 else strlcat(strReturn,
"Server 4.0 ",2048 );
5707 DWORD dwBufLen=
BUFSIZE*
sizeof(TCHAR);
5710 lRet = RegOpenKeyEx( HKEY_LOCAL_MACHINE,
5711 "SYSTEM\\CurrentControlSet\\Control\\ProductOptions",
5712 0, KEY_QUERY_VALUE, &hKey );
5713 if( lRet != ERROR_SUCCESS )
5716 lRet = RegQueryValueEx( hKey,
"ProductType", NULL, NULL,
5717 (LPBYTE) szProductType, &dwBufLen);
5718 RegCloseKey( hKey );
5720 if( (lRet != ERROR_SUCCESS) || (dwBufLen >
BUFSIZE*
sizeof(TCHAR)) )
5723 if ( lstrcmpi(
"WINNT", szProductType) == 0 )
5724 strlcat(strReturn,
"Workstation " ,2048);
5725 if ( lstrcmpi(
"LANMANNT", szProductType) == 0 )
5726 strlcat(strReturn,
"Server " ,2048);
5727 if ( lstrcmpi(
"SERVERNT", szProductType) == 0 )
5728 strlcat(strReturn,
"Advanced Server " ,2048);
5729 snprintf(temp,512,
"%d.%d ", osvi.dwMajorVersion, osvi.dwMinorVersion);
5730 strlcat(strReturn, temp,2048);
5735 if( osvi.dwMajorVersion == 4 &&
5736 lstrcmpi( osvi.szCSDVersion,
"Service Pack 6" ) == 0 )
5742 lRet = RegOpenKeyEx( HKEY_LOCAL_MACHINE,
5743 "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Hotfix\\Q246009",
5744 0, KEY_QUERY_VALUE, &hKey );
5745 if( lRet == ERROR_SUCCESS ) {
5746 snprintf(temp, 512,
"Service Pack 6a (Build %d)", osvi.dwBuildNumber & 0xFFFF );
5747 strlcat(strReturn, temp,2048 );
5751 snprintf(temp,512,
"%s (Build %d)", osvi.szCSDVersion, osvi.dwBuildNumber & 0xFFFF);
5752 strlcat(strReturn, temp,2048 );
5755 RegCloseKey( hKey );
5759 snprintf(temp, 512,
"%s (Build %d)", osvi.szCSDVersion, osvi.dwBuildNumber & 0xFFFF);
5760 strlcat(strReturn, temp,2048 );
5766 case VER_PLATFORM_WIN32_WINDOWS:
5768 if (osvi.dwMajorVersion == 4 && osvi.dwMinorVersion == 0)
5770 strlcpy(strReturn,
"Microsoft Windows 95 ",2048);
5771 if (osvi.szCSDVersion[1]==
'C' || osvi.szCSDVersion[1]==
'B')
5772 strlcat(strReturn,
"OSR2 " ,2048);
5775 if (osvi.dwMajorVersion == 4 && osvi.dwMinorVersion == 10)
5777 strlcpy(strReturn,
"Microsoft Windows 98 ",2048);
5778 if ( osvi.szCSDVersion[1]==
'A' || osvi.szCSDVersion[1]==
'B')
5779 strlcat(strReturn,
"SE ",2048 );
5782 if (osvi.dwMajorVersion == 4 && osvi.dwMinorVersion == 90)
5784 strlcpy(strReturn,
"Microsoft Windows Millennium Edition",2048);
5788 case VER_PLATFORM_WIN32s:
5789 strlcpy(strReturn,
"Microsoft Win32s",2048);
5800 unsigned nHighestFeatureEx;
5804 nHighestFeatureEx = (unsigned)nBuff[0];
5806 if (nHighestFeatureEx >= 0x80000006) {
5808 return (((
unsigned)nBuff[2])>>16);
5819 SYSTEM_INFO sysInfo;
5820 MEMORYSTATUSEX statex;
5821 OSVERSIONINFO OsVersionInfo;
5823 char szKeyValueString[80];
5824 DWORD szKeyValueDword;
5829 NtQuerySystemInformation = (
PROCNTQSI)GetProcAddress(
5830 GetModuleHandle(
"ntdll"),
"NtQuerySystemInformation");
5832 if (!NtQuerySystemInformation) {
5834 "Error on GetProcAddress(NtQuerySystemInformation)");
5839 &SysPerfInfo,
sizeof(SysPerfInfo),
5841 OsVersionInfo.dwOSVersionInfoSize =
sizeof(OSVERSIONINFO);
5842 GetVersionEx(&OsVersionInfo);
5843 GetSystemInfo(&sysInfo);
5844 statex.dwLength =
sizeof(statex);
5845 if (!GlobalMemoryStatusEx(&statex)) {
5846 ::Error(
"GetWinNTSysInfo",
"Error on GlobalMemoryStatusEx()");
5849 sysinfo->
fCpus = sysInfo.dwNumberOfProcessors;
5858 status = RegOpenKeyEx(HKEY_LOCAL_MACHINE,
"HARDWARE\\DESCRIPTION\\System",
5859 0, KEY_QUERY_VALUE, &hKey);
5860 if (status == ERROR_SUCCESS) {
5861 dwBufLen =
sizeof(szKeyValueString);
5862 RegQueryValueEx(hKey,
"Identifier", NULL, NULL,(LPBYTE)szKeyValueString,
5864 sysinfo->
fModel = szKeyValueString;
5867 status = RegOpenKeyEx(HKEY_LOCAL_MACHINE,
5868 "Hardware\\Description\\System\\CentralProcessor\\0",
5869 0, KEY_QUERY_VALUE, &hKey);
5870 if (status == ERROR_SUCCESS) {
5871 dwBufLen =
sizeof(szKeyValueString);
5872 status = RegQueryValueEx(hKey,
"ProcessorNameString", NULL, NULL,
5873 (LPBYTE)szKeyValueString, &dwBufLen);
5874 if (status == ERROR_SUCCESS)
5875 sysinfo->
fCpuType = szKeyValueString;
5876 dwBufLen =
sizeof(DWORD);
5877 status = RegQueryValueEx(hKey,
"~MHz",NULL,NULL,(LPBYTE)&szKeyValueDword,
5879 if ((status == ERROR_SUCCESS) && ((sysinfo->
fCpuSpeed <= 0) ||
5880 (sysinfo->
fCpuSpeed < (szKeyValueDword >> 1))))
5894 SYSTEM_INFO sysInfo;
5895 Float_t idle_ratio, kernel_ratio, user_ratio, total_ratio;
5896 FILETIME ft_sys_idle, ft_sys_kernel, ft_sys_user, ft_fun_time;
5897 SYSTEMTIME st_fun_time;
5899 ULARGE_INTEGER ul_sys_idle, ul_sys_kernel, ul_sys_user;
5900 static ULARGE_INTEGER ul_sys_idleold = {0, 0};
5901 static ULARGE_INTEGER ul_sys_kernelold = {0, 0};
5902 static ULARGE_INTEGER ul_sys_userold = {0, 0};
5903 ULARGE_INTEGER ul_sys_idle_diff, ul_sys_kernel_diff, ul_sys_user_diff;
5905 ULARGE_INTEGER ul_fun_time;
5906 ULARGE_INTEGER ul_fun_timeold = {0, 0};
5907 ULARGE_INTEGER ul_fun_time_diff;
5909 typedef BOOL (__stdcall *GetSystemTimesProc)( LPFILETIME lpIdleTime,
5910 LPFILETIME lpKernelTime, LPFILETIME lpUserTime );
5911 static GetSystemTimesProc pGetSystemTimes = 0;
5913 HMODULE hModImagehlp = LoadLibrary(
"Kernel32.dll" );
5914 if (!hModImagehlp) {
5915 ::Error(
"GetWinNTCpuInfo",
"Error on LoadLibrary(Kernel32.dll)");
5919 pGetSystemTimes = (GetSystemTimesProc) GetProcAddress( hModImagehlp,
5921 if (!pGetSystemTimes) {
5922 ::Error(
"GetWinNTCpuInfo",
"Error on GetProcAddress(GetSystemTimes)");
5925 GetSystemInfo(&sysInfo);
5928 pGetSystemTimes(&ft_sys_idle,&ft_sys_kernel,&ft_sys_user);
5929 GetSystemTime(&st_fun_time);
5930 SystemTimeToFileTime(&st_fun_time,&ft_fun_time);
5932 memcpy(&ul_sys_idle, &ft_sys_idle,
sizeof(FILETIME));
5933 memcpy(&ul_sys_kernel, &ft_sys_kernel,
sizeof(FILETIME));
5934 memcpy(&ul_sys_user, &ft_sys_user,
sizeof(FILETIME));
5935 memcpy(&ul_fun_time, &ft_fun_time,
sizeof(FILETIME));
5937 ul_sys_idle_diff.QuadPart = ul_sys_idle.QuadPart -
5938 ul_sys_idleold.QuadPart;
5939 ul_sys_kernel_diff.QuadPart = ul_sys_kernel.QuadPart -
5940 ul_sys_kernelold.QuadPart;
5941 ul_sys_user_diff.QuadPart = ul_sys_user.QuadPart -
5942 ul_sys_userold.QuadPart;
5944 ul_fun_time_diff.QuadPart = ul_fun_time.QuadPart -
5945 ul_fun_timeold.QuadPart;
5947 ul_sys_idleold.QuadPart = ul_sys_idle.QuadPart;
5948 ul_sys_kernelold.QuadPart = ul_sys_kernel.QuadPart;
5949 ul_sys_userold.QuadPart = ul_sys_user.QuadPart;
5951 if (ul_fun_timeold.QuadPart == 0) {
5953 ul_fun_timeold.QuadPart = ul_fun_time.QuadPart;
5956 ul_fun_timeold.QuadPart = ul_fun_time.QuadPart;
5964 idle_ratio /= (
Float_t)sysInfo.dwNumberOfProcessors;
5965 user_ratio /= (
Float_t)sysInfo.dwNumberOfProcessors;
5966 kernel_ratio /= (
Float_t)sysInfo.dwNumberOfProcessors;
5967 total_ratio = 100.0 - idle_ratio;
5972 cpuinfo->
fUser = user_ratio;
5973 cpuinfo->
fSys = kernel_ratio;
5974 cpuinfo->
fTotal = total_ratio;
5975 cpuinfo->
fIdle = idle_ratio;
5984 MEMORYSTATUSEX statex;
5985 statex.dwLength =
sizeof(statex);
5986 if (!GlobalMemoryStatusEx(&statex)) {
5987 ::Error(
"GetWinNTMemInfo",
"Error on GlobalMemoryStatusEx()");
5990 used = (
Long64_t)(statex.ullTotalPhys - statex.ullAvailPhys);
5998 swap_total = (
Long64_t)(statex.ullTotalPageFile - statex.ullTotalPhys);
5999 swap_avail = (
Long64_t)(statex.ullAvailPageFile - statex.ullAvailPhys);
6000 swap_used = swap_total - swap_avail;
6013 FILETIME starttime, exittime, kerneltime, usertime;
6014 timeval ru_stime, ru_utime;
6017 typedef BOOL (__stdcall *GetProcessMemoryInfoProc)( HANDLE Process,
6019 static GetProcessMemoryInfoProc pGetProcessMemoryInfo = 0;
6021 HMODULE hModImagehlp = LoadLibrary(
"Psapi.dll" );
6022 if (!hModImagehlp) {
6023 ::Error(
"GetWinNTProcInfo",
"Error on LoadLibrary(Psapi.dll)");
6027 pGetProcessMemoryInfo = (GetProcessMemoryInfoProc) GetProcAddress(
6028 hModImagehlp,
"GetProcessMemoryInfo" );
6029 if (!pGetProcessMemoryInfo) {
6031 "Error on GetProcAddress(GetProcessMemoryInfo)");
6035 if ( pGetProcessMemoryInfo( GetCurrentProcess(), &pmc,
sizeof(pmc)) ) {
6039 if ( GetProcessTimes(GetCurrentProcess(), &starttime, &exittime,
6040 &kerneltime, &usertime)) {
6043 memcpy(&li, &kerneltime,
sizeof(FILETIME));
6045 ru_stime.tv_sec = li.QuadPart / 1000000L;
6046 ru_stime.tv_usec = li.QuadPart % 1000000L;
6048 memcpy(&li, &usertime,
sizeof(FILETIME));
6050 ru_utime.tv_sec = li.QuadPart / 1000000L;
6051 ru_utime.tv_usec = li.QuadPart % 1000000L;
6054 ((
Float_t)(ru_utime.tv_usec) / 1000000.);
6056 ((
Float_t)(ru_stime.tv_usec) / 1000000.);
6067 if (!info)
return -1;
6079 if (!info)
return -1;
6090 if (!info)
return -1;
6101 if (!info)
return -1;
The file contains utilities which are foundational and could be used across the core component of ROO...
R__EXTERN TApplication * gApplication
void Error(const char *location, const char *msgfmt,...)
Use this function in case an error occurred.
void SysError(const char *location, const char *msgfmt,...)
Use this function in case a system (OS or GUI) related error occurred.
void Break(const char *location, const char *msgfmt,...)
Use this function in case an error occurred.
R__EXTERN TExceptionHandler * gExceptionHandler
R__EXTERN void Throw(int code)
If an exception context has been set (using the TRY and RETRY macros) jump back to where it was set.
static unsigned int total
winID h TVirtualViewer3D TVirtualGLPainter p
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t mask
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char filename
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t r
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t result
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h length
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void value
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t UChar_t len
Option_t Option_t TPoint TPoint const char mode
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t type
#define INVALID_HANDLE_VALUE
char * Form(const char *fmt,...)
Formats a string in a circular formatting buffer.
void Printf(const char *fmt,...)
Formats a string in a circular formatting buffer and prints the string.
char * StrDup(const char *str)
Duplicate the string str.
@ kSigSegmentationViolation
R__EXTERN const char * gProgName
R__EXTERN const char * gRootDir
R__EXTERN TSystem * gSystem
R__EXTERN TFileHandler * gXDisplay
R__EXTERN const char * gProgPath
static void sighandler(int sig)
Call the signal handler associated with the signal.
static const char * DynamicPath(const char *newpath=nullptr, Bool_t reset=kFALSE)
Get shared library search path. Static utility function.
static void SigHandler(ESignals sig)
Unix signal handler.
const char * kProtocolName
void(* SigHandler_t)(ESignals)
R__EXTERN TWin32SplashThread * gSplash
static void __cpuid(int *cpuid_data, int)
static const char * shellMeta
BOOL PathIsRoot(LPCTSTR pPath)
check if a path is a root
static void GetWinNTProcInfo(ProcInfo_t *procinfo)
Get process info for this process on Windows NT.
static int GetL2CacheSize()
Use assembly to retrieve the L2 cache information ...
struct _PROCESS_MEMORY_COUNTERS * PPROCESS_MEMORY_COUNTERS
static void GetWinNTCpuInfo(CpuInfo_t *cpuinfo, Int_t sampleTime)
Get CPU stat for Window.
void Gl_setwidth(int width)
void(WINAPI * PGNSI)(LPSYSTEM_INFO)
#define SystemPerformanceInformation
ULongptr_t gConsoleWindow
BOOL PathIsUNC(LPCTSTR pszPath)
Returns TRUE if the given string is a UNC path.
static const char shellEscape
const TCHAR c_szColonSlash[]
static void GetWinNTMemInfo(MemInfo_t *meminfo)
Get VM stat for Windows NT.
static DWORD GetCPUSpeed()
Calculate the CPU clock speed using the 'rdtsc' instruction.
struct _PROCESS_MEMORY_COUNTERS PROCESS_MEMORY_COUNTERS
#define isin(address, start, length)
static const char * shellStuff
__inline BOOL DBL_BSLASH(LPCTSTR psz)
Inline function to check for a double-backslash at the beginning of a string.
static void GetWinNTSysInfo(SysInfo_t *sysinfo)
Get system info for Windows NT.
static const char * GetWindowsVersion()
void * _ReturnAddress(void)
LONG(WINAPI * PROCNTQSI)(UINT, PVOID, ULONG, PULONG)
virtual Bool_t HandleTermInput()
Using a TBrowser one can browse all ROOT objects.
virtual void SetOwner(Bool_t enable=kTRUE)
Set whether this collection is the owner (enable==true) of its content.
virtual Int_t GetSize() const
Return the capacity of the collection, i.e.
virtual Int_t GetValue(const char *name, Int_t dflt) const
Returns the integer value for a resource.
virtual void HandleException(int sig)=0
ULong_t fds_bits[(((kFDSETSIZE)+((kNFDBITS) -1))/(kNFDBITS))]
TFdSet & operator=(const TFdSet &fd)
void Copy(TFdSet &fd) const
virtual Bool_t WriteNotify()
Notify when something can be written to the descriptor associated with this handler.
virtual Bool_t ReadNotify()
Notify when something can be read from the descriptor associated with this handler.
Bool_t Notify() override
Notify when event occurred on descriptor associated with this handler.
This class represents an Internet Protocol (IP) address.
UInt_t GetAddress() const
TObject * Next() override
Return next object in the list. Returns 0 when no more objects in list.
void Add(TObject *obj) override
virtual void SysError(const char *method, const char *msgfmt,...) const
Issue system error message.
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Iterator of ordered collection.
TObject * Next() override
Return next object in collection.
static const TString & GetBinDir()
Get the binary directory in the installation. Static utility function.
static void ShutDown()
Shut down ROOT.
static Bool_t Initialized()
Return kTRUE if the TROOT object has been initialized.
static const TString & GetLibDir()
Get the library directory in the installation. Static utility function.
Regular expression class.
Bool_t Notify() override
Notify when signal occurs.
ESignals GetSignal() const
Bool_t EndsWith(const char *pat, ECaseCompare cmp=kExact) const
Return true if string ends with the specified string.
TSubString Strip(EStripType s=kTrailing, char c=' ') const
Return a substring of self stripped at beginning and/or end.
TString & Replace(Ssiz_t pos, Ssiz_t n, const char *s)
Ssiz_t First(char c) const
Find first occurrence of a character c.
const char * Data() const
TString & ReplaceAll(const TString &s1, const TString &s2)
Bool_t BeginsWith(const char *s, ECaseCompare cmp=kExact) const
TString & Prepend(const char *cs)
TString & Swap(TString &other)
TString & Remove(Ssiz_t pos)
TString & Append(const char *cs)
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString.
void Form(const char *fmt,...)
Formats a string using a printf style format descriptor.
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
Ssiz_t Index(const char *pat, Ssiz_t i=0, ECaseCompare cmp=kExact) const
Abstract base class defining a generic interface to the underlying Operating System.
TSeqCollection * fFileHandler
virtual void AddFileHandler(TFileHandler *fh)
Add a file handler to the list of system file handlers.
TString & GetLastErrorString()
Return the thread local storage for the custom last error message.
void Beep(Int_t freq=-1, Int_t duration=-1, Bool_t setDefault=kFALSE)
Beep for duration milliseconds with a tone of frequency freq.
static void ResetErrno()
Static function resetting system error number.
virtual Bool_t ExpandPathName(TString &path)
Expand a pathname getting rid of special shell characters like ~.
static Int_t GetErrno()
Static function returning system error number.
virtual void * OpenDirectory(const char *name)
Open a directory. Returns 0 if directory does not exist.
virtual Long_t NextTimeOut(Bool_t mode)
Time when next timer of mode (synchronous=kTRUE or asynchronous=kFALSE) will time-out (in ms).
virtual int SetSockOpt(int sock, int kind, int val)
Set socket option.
virtual const char * Getenv(const char *env)
Get environment variable.
TFdSet * fWritemask
Files that should be checked for read events.
TFdSet * fSignals
Files with writes waiting.
virtual Bool_t IsPathLocal(const char *path)
Returns TRUE if the url in 'path' points to the local file system.
virtual const char * FindFile(const char *search, TString &file, EAccessMode mode=kFileExists)
Find location of file in a search path.
virtual int MakeDirectory(const char *name)
Make a directory.
virtual const char * ExpandFileName(const char *fname)
Expand a pathname getting rid of special shell characters like ~.
virtual TFileHandler * RemoveFileHandler(TFileHandler *fh)
Remove a file handler from the list of file handlers.
virtual int Load(const char *module, const char *entry="", Bool_t system=kFALSE)
Load a shared library.
int GetPathInfo(const char *path, Long_t *id, Long_t *size, Long_t *flags, Long_t *modtime)
Get info about a file: id, size, flags, modification time.
virtual Bool_t AccessPathName(const char *path, EAccessMode mode=kFileExists)
Returns FALSE if one can access a file using the specified access mode.
virtual void ExitLoop()
Exit from event loop.
virtual Bool_t Init()
Initialize the OS interface.
virtual void AddTimer(TTimer *t)
Add timer to list of system timers.
TFdSet * fWriteready
Files with reads waiting.
virtual void AddSignalHandler(TSignalHandler *sh)
Add a signal handler to list of system signal handlers.
TSeqCollection * fSignalHandler
virtual void Exit(int code, Bool_t mode=kTRUE)
Exit the application.
TFdSet * fReadready
Files that should be checked for write events.
TSystem * FindHelper(const char *path, void *dirptr=nullptr)
Create helper TSystem to handle file and directory operations that might be special for remote file a...
Int_t fNfd
Signals that were trapped.
std::atomic< Bool_t > fInsideNotify
virtual char * Which(const char *search, const char *file, EAccessMode mode=kFileExists)
Find location of file in a search path.
virtual TInetAddress GetHostByName(const char *server)
Get Internet Protocol (IP) address of host.
virtual const char * GetLibraries(const char *regexp="", const char *option="", Bool_t isRegexp=kTRUE)
Return a space separated list of loaded shared libraries.
virtual TSignalHandler * RemoveSignalHandler(TSignalHandler *sh)
Remove a signal handler from list of signal handlers.
static const char * StripOffProto(const char *path, const char *proto)
Strip off protocol string from specified path.
virtual Bool_t ProcessEvents()
Process pending events (GUI, timers, sockets).
virtual TTimer * RemoveTimer(TTimer *t)
Remove timer from list of system timers.
virtual int Unlink(const char *name)
Unlink, i.e.
virtual void StackTrace()
Print a stack trace.
char * DynamicPathName(const char *lib, Bool_t quiet=kFALSE)
Find a dynamic library called lib using the system search paths.
Basic time type with millisecond precision.
Handles synchronous and a-synchronous timer events.
Bool_t CheckTimer(const TTime &now)
Check if timer timed out.
This class represents a WWW compatible URL.
const char * GetProtocol() const
void CloseConnection(int sock, Bool_t force=kFALSE) override
Close socket.
TList * GetVolumes(Option_t *opt="") const override
Get list of volumes (drives) mounted on the system.
FILE * OpenPipe(const char *shellcmd, const char *mode) override
Open a pipe.
void IgnoreSignal(ESignals sig, Bool_t ignore=kTRUE) override
If ignore is true ignore the specified signal, else restore previous behaviour.
Bool_t HandleConsoleEvent()
int Utime(const char *file, Long_t modtime, Long_t actime) override
Set a files modification and access times.
void Sleep(UInt_t milliSec) override
Sleep milliSec milli seconds.
TTime Now() override
Get current time in milliseconds since 0:00 Jan 1 1995.
const char * HostName() override
Return the system's host name.
virtual ~TWinNTSystem()
dtor
void ExitLoop() override
Exit from event loop.
FILE * TempFileName(TString &base, const char *dir=nullptr) override
Create a secure temporary file by appending a unique 6 letter string to base.
int SetNonBlock(int fd)
Make descriptor fd non-blocking.
int AnnounceUnixService(int port, int backlog) override
Announce unix domain service.
const char * GetLinkedLibraries() override
Get list of shared libraries loaded at the start of the executable.
void AddSignalHandler(TSignalHandler *sh) override
Add a signal handler to list of system signal handlers.
const char * PrependPathName(const char *dir, TString &name) override
Concatenate a directory and a file name.
void SetGUIThreadMsgHandler(ThreadMsgFunc_t func)
Set the (static part of) the event handler func for GUI messages.
Bool_t ProcessEvents() override
process pending events, i.e. DispatchOneEvent(kTRUE)
const char DriveName(const char *pathname="/")
Return the drive letter in pathname.
int SetSockOpt(int sock, int opt, int val) override
Set socket option.
struct passwd * fPasswords
Int_t GetCpuInfo(CpuInfo_t *info, Int_t sampleTime=1000) const override
Returns cpu load average and load info into the CpuInfo_t structure.
Int_t SetFPEMask(Int_t mask=kDefaultMask) override
Set which conditions trigger a floating point exception.
int GetPathInfo(const char *path, FileStat_t &buf) override
Get info about a file.
static void ThreadStub(void *Parameter)
void FreeDirectory(void *dirp) override
Close a WinNT file system directory.
static int WinNTUdpConnect(const char *hostname, int port)
Creates a UDP socket connection Is called via the TSocket constructor.
Int_t GetSysInfo(SysInfo_t *info) const override
Returns static system info, like OS type, CPU type, number of CPUs RAM size, etc into the SysInfo_t s...
void * OpenDirectory(const char *name) override
Open a directory. Returns 0 if directory does not exist.
int AnnounceTcpService(int port, Bool_t reuse, int backlog, int tcpwindowsize=-1) override
Announce TCP/IP service.
const char * Getenv(const char *name) override
Get environment variable.
UserGroup_t * GetGroupInfo(Int_t gid) override
Returns all group info in the UserGroup_t structure.
void AddTimer(TTimer *ti) override
Add timer to list of system timers.
int RecvBuf(int sock, void *buffer, int length) override
Receive a buffer headed by a length indicator.
void DoBeep(Int_t freq=-1, Int_t duration=-1) const override
Beep.
void TimerThread()
Special Thread to check asynchronous timers.
const char * GetDynamicPath() override
Return the dynamic path (used to find shared libraries).
Bool_t ExpandPathName(TString &patbuf) override
Expand a pathname getting rid of special shell characaters like ~.$, etc.
int GetServiceByName(const char *service) override
Get port # of internet service.
int OpenConnection(const char *server, int port, int tcpwindowsize=-1, const char *protocol="tcp") override
Open a connection to a service on a server.
int ConnectService(const char *servername, int port, int tcpwindowsize, const char *protocol="tcp")
Connect to service servicename on server servername.
TString GetDirName(const char *pathname) override
Return the directory name in pathname.
int SendRaw(int sock, const void *buffer, int length, int flag) override
Send exactly length bytes from buffer.
const char * TempDirectory() const override
Return a user configured or systemwide directory to create temporary files in.
void DispatchSignals(ESignals sig)
Handle and dispatch signals.
int AnnounceUdpService(int port, int backlog) override
Announce UDP service.
int Exec(const char *shellcmd) override
Execute a command.
Long_t LookupSID(const char *lpszAccountName, int what, int &groupIdx, int &memberIdx)
Take the name and look up a SID so that we can get full domain/user information.
Int_t GetEffectiveUid() override
Returns the effective user id.
void NotifyApplicationCreated() override
Hook to tell TSystem that the TApplication object has been created.
void Abort(int code=0) override
Abort the application.
Int_t Select(TList *active, Long_t timeout) override
Select on file descriptors. The timeout to is in millisec.
Int_t GetMemInfo(MemInfo_t *info) const override
Returns ram and swap memory usage info into the MemInfo_t structure.
Int_t GetProcInfo(ProcInfo_t *info) const override
Returns cpu and memory used by this process into the ProcInfo_t structure.
TFileHandler * RemoveFileHandler(TFileHandler *fh) override
Remove a file handler from the list of file handlers.
Bool_t DispatchTimers(Bool_t mode)
Handle and dispatch timers.
const char * DirName(const char *pathname) override
Return the directory name in pathname.
Bool_t IsPathLocal(const char *path) override
Returns TRUE if the url in 'path' points to the local file system.
int SendBuf(int sock, const void *buffer, int length) override
Send a buffer headed by a length indicator.
TInetAddress GetHostByName(const char *server) override
Get Internet Protocol (IP) address of host.
Bool_t ChangeDirectory(const char *path) override
Change directory.
int AcceptConnection(int sock) override
Accept a connection.
int GetPid() override
Get process id.
const char * WorkingDirectory() override
Return the working directory for the default drive.
void SetProgname(const char *name) override
Set the application name (from command line, argv[0]) and copy it in gProgName.
int GetSockOpt(int sock, int opt, int *val) override
Get socket option.
int GetFsInfo(const char *path, Long_t *id, Long_t *bsize, Long_t *blocks, Long_t *bfree) override
Get info about a file system: id, bsize, bfree, blocks.
int CopyFile(const char *from, const char *to, Bool_t overwrite=kFALSE) override
Copy a file.
Int_t RedirectOutput(const char *name, const char *mode="a", RedirectHandle_t *h=nullptr) override
Redirect standard output (stdout, stderr) to the specified file.
Bool_t IsAbsoluteFileName(const char *dir) override
Return true if dir is an absolute pathname.
int mkdir(const char *name, Bool_t recursive=kFALSE) override
Make a file system directory.
const char * UnixPathName(const char *unixpathname) override
Convert a pathname to a unix pathname.
Bool_t CheckSignals(Bool_t sync)
Check if some signals were raised and call their Notify() member.
int Symlink(const char *from, const char *to) override
Create a symlink from file1 to file2.
void DispatchOneEvent(Bool_t pendingOnly=kFALSE) override
Dispatch a single event in TApplication::Run() loop.
int Load(const char *module, const char *entry="", Bool_t system=kFALSE) override
Load a shared library.
TSignalHandler * RemoveSignalHandler(TSignalHandler *sh) override
Remove a signal handler from list of signal handlers.
const char * GetError() override
Return system error string.
void StackTrace() override
Print a stack trace, if gEnv entry "Root.Stacktrace" is unset or 1, and if the image helper functions...
int Unlink(const char *name) override
Unlink, i.e.
void ResetSignals() override
Reset signals handlers to previous behaviour.
int RecvRaw(int sock, void *buffer, int length, int flag) override
Receive exactly length bytes into buffer.
const char * BaseName(const char *name) override
Base name of a file name.
TTimer * RemoveTimer(TTimer *ti) override
Remove timer from list of system timers.
void Exit(int code, Bool_t mode=kTRUE) override
Exit the application.
void AddDynamicPath(const char *dir) override
Add a new directory to the dynamic path.
int Umask(Int_t mask) override
Set the process file creation mode mask.
void AddFileHandler(TFileHandler *fh) override
Add a file handler to the list of system file handlers.
std::string fDirNameBuffer
Bool_t CheckDescriptors()
Check if there is activity on some file descriptors and call their Notify() member.
static int WinNTUnixConnect(int port)
Connect to a Unix domain socket.
int Chmod(const char *file, UInt_t mode) override
Set the file permission bits.
Bool_t Init() override
Initialize WinNT system interface.
const char * GetDirEntry(void *dirp) override
Returns the next directory entry.
TInetAddress GetSockName(int sock) override
Get Internet Protocol (IP) address of host and port #.
Bool_t(* ThreadMsgFunc_t)(MSG *)
TInetAddress GetPeerName(int sock) override
Get Internet Protocol (IP) address of remote host and port #.
Int_t GetUid(const char *user=nullptr) override
Returns the user's id. If user = 0, returns current user's id.
const char * FindFile(const char *search, TString &file, EAccessMode mode=kFileExists) override
Find location of file in a search path.
const char * FindDynamicLibrary(TString &lib, Bool_t quiet=kFALSE) override
Returns and updates sLib to the path of a dynamic library (searches for library in the dynamic librar...
void ResetSignal(ESignals sig, Bool_t reset=kTRUE) override
If reset is true reset the signal handler for the specified signal to the default handler,...
Bool_t CollectMembers(const char *lpszGroupName, int &groupIdx, int &memberIdx)
Bool_t CountMembers(const char *lpszGroupName)
std::string GetHomeDirectory(const char *userName=nullptr) const override
Return the user's home directory.
Bool_t AccessPathName(const char *path, EAccessMode mode=kFileExists) override
Returns FALSE if one can access a file using the specified access mode.
void FillWithHomeDirectory(const char *userName, char *mydir) const
Fill buffer with user's home directory.
char * GetServiceByPort(int port) override
Get name of internet service.
Bool_t InitUsersGroups()
Collect local users and groups accounts information.
Int_t GetGid(const char *group=nullptr) override
Returns the group's id. If group = 0, returns current user's group.
const char * HomeDirectory(const char *userName=0) override
Return the user's home directory.
Int_t GetEffectiveGid() override
Returns the effective group id.
void Setenv(const char *name, const char *value) override
Set environment variable.
void SetDynamicPath(const char *path) override
Set the dynamic path to a new value.
std::string GetWorkingDirectory() const override
Return the working directory for the default drive.
HANDLE GetProcess()
Get current process handle.
UserGroup_t * GetUserInfo(Int_t uid) override
Returns all user info in the UserGroup_t structure.
int Rename(const char *from, const char *to) override
Rename a file. Returns 0 when successful, -1 in case of failure.
int MakeDirectory(const char *name) override
Make a WinNT file system directory.
int Link(const char *from, const char *to) override
Create a link from file1 to file2.
const char * GetLibraries(const char *regexp="", const char *option="", Bool_t isRegexp=kTRUE) override
Return a space separated list of loaded shared libraries.
int ClosePipe(FILE *pipe) override
Close the pipe.
Int_t GetFPEMask() override
Return the bitmap of conditions that trigger a floating point exception.
const std::string & GetFallbackRootSys()
void(off) SmallVectorTemplateBase< T
Struct used to pass information between OpenDirectory and GetDirEntry in a thread safe way (each thre...
WIN32_FIND_DATA fFindFileData
SIZE_T QuotaNonPagedPoolUsage
SIZE_T PeakWorkingSetSize
SIZE_T QuotaPeakNonPagedPoolUsage
SIZE_T QuotaPeakPagedPoolUsage
SIZE_T QuotaPagedPoolUsage