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);
159 typedef NET_API_STATUS (WINAPI *pfn4)(LPCWSTR, DWORD, LPBYTE*, DWORD, LPDWORD,
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;
224 for (
n = 0;
n < length;
n += nrecv) {
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;
275 for (
n = 0;
n < length;
n += nsent) {
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
685 static BOOL IsShortcut(
const char *filename)
688 const char *extLnk =
".lnk";
689 if (filename != NULL) {
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();
1156 const char *symbol=
name;
1159 while ( (*symbol ==
' ' || *symbol ==
'\t') && *symbol) symbol++;
1162 if (isalpha(symbol[idx]) && symbol[idx+1] ==
':') idx = 2;
1163 if ( (symbol[idx] ==
'/' || symbol[idx] ==
'\\') && symbol[idx+1] ==
'\0') {
1168 Error(
"BaseName",
"name = 0");
1172 char *bslash = (
char *)strrchr(&symbol[idx],
'\\');
1173 char *rslash = (
char *)strrchr(&symbol[idx],
'/');
1174 if (cp = (std::max)(rslash, bslash)) {
1179 return &symbol[idx];
1181 Error(
"BaseName",
"name = 0");
1192 char *dot =
nullptr;
1194 char *fullname =
nullptr;
1197 size_t namelen =
name ? strlen(
name) : 0;
1198 if (
name && namelen > 0) {
1200 fullname =
new char[namelen+5];
1201 strlcpy(fullname,
name,namelen+5);
1202 if ( !strrchr(fullname,
'.') )
1203 strlcat(fullname,
".exe",namelen+5);
1206 dot = strrchr(progname,
'.');
1207 idot = dot ? (size_t)(dot - progname) : strlen(progname);
1209 char *which =
nullptr;
1212 which =
StrDup(fullname);
1223 dirname.
Form(
"%c:%s", driveletter,
d.Data());
1238 progname[idot] =
'\0';
1240 if (which)
delete [] which;
1244 if (::NeedSplash()) {
1257 if (err < 0 || err >= sys_nerr) {
1259 error_msg.
Form(
"errno out of range %d", err);
1262 return sys_errlist[err];
1275 DWORD il =
sizeof(hn);
1276 ::GetComputerName(hn, &il);
1292 if (freq < 37) freq = 440;
1293 if (duration < 0) duration = 100;
1302 gGUIThreadMsgFunc = func;
1325 int fd =
h->GetFd();
1328 if (
h->HasReadInterest()) {
1331 if (
h->HasWriteInterest()) {
1343 if (!
h)
return nullptr;
1363 set_console =
kTRUE;
1376 ::SetConsoleCtrlHandler((PHANDLER_ROUTINE)ConsoleSigHandler,
TRUE);
1387 if (!
h)
return nullptr;
1402 ::SetConsoleCtrlHandler((PHANDLER_ROUTINE)ConsoleSigHandler,
FALSE);
1446 HANDLE snapshot = ::CreateToolhelp32Snapshot(TH32CS_SNAPTHREAD,::GetCurrentProcessId());
1451 if (!InitImagehlpFunctions()) {
1452 std::cerr <<
"No stack trace: cannot find (functions in) dbghelp.dll!" << std::endl;
1457 SYSTEM_INFO sysInfo;
1458 ::GetSystemInfo(&sysInfo);
1459 DWORD machineType = IMAGE_FILE_MACHINE_I386;
1460 switch (sysInfo.wProcessorArchitecture) {
1461 case PROCESSOR_ARCHITECTURE_AMD64:
1462 machineType = IMAGE_FILE_MACHINE_AMD64;
1464 case PROCESSOR_ARCHITECTURE_IA64:
1465 machineType = IMAGE_FILE_MACHINE_IA64;
1469 DWORD currentThreadID = ::GetCurrentThreadId();
1470 DWORD currentProcessID = ::GetCurrentProcessId();
1474 THREADENTRY32 threadentry;
1475 threadentry.dwSize =
sizeof(THREADENTRY32);
1476 if (!::Thread32First(snapshot, &threadentry))
return;
1478 std::cerr << std::endl <<
"==========================================" << std::endl;
1479 std::cerr <<
"=============== STACKTRACE ===============" << std::endl;
1480 std::cerr <<
"==========================================" << std::endl << std::endl;
1483 if (threadentry.th32OwnerProcessID != currentProcessID)
1485 HANDLE thread = ::OpenThread(THREAD_GET_CONTEXT|THREAD_SUSPEND_RESUME|THREAD_QUERY_INFORMATION,
1486 FALSE, threadentry.th32ThreadID);
1488 memset(&context, 0,
sizeof(CONTEXT));
1490 if (threadentry.th32ThreadID != currentThreadID) {
1491 ::SuspendThread(thread);
1492 context.ContextFlags = CONTEXT_ALL;
1493 ::GetThreadContext(thread, &context);
1494 ::ResumeThread(thread);
1496 if (fgXcptContext) {
1497 context = *fgXcptContext;
1499 typedef void (WINAPI *RTLCCTXT)(PCONTEXT);
1500 RTLCCTXT p2RtlCCtxt = (RTLCCTXT) ::GetProcAddress(
1501 GetModuleHandle(
"kernel32.dll"),
"RtlCaptureContext");
1503 context.ContextFlags = CONTEXT_ALL;
1504 p2RtlCCtxt(&context);
1510 ::ZeroMemory(&frame,
sizeof(frame));
1512 frame.AddrPC.Mode = AddrModeFlat;
1513 frame.AddrFrame.Mode = AddrModeFlat;
1514 frame.AddrStack.Mode = AddrModeFlat;
1516 frame.AddrPC.Offset = context.Eip;
1517 frame.AddrFrame.Offset = context.Ebp;
1518 frame.AddrStack.Offset = context.Esp;
1519#elif defined(_M_X64)
1520 frame.AddrPC.Offset = context.Rip;
1521 frame.AddrFrame.Offset = context.Rsp;
1522 frame.AddrStack.Offset = context.Rsp;
1523#elif defined(_M_IA64)
1524 frame.AddrPC.Offset = context.StIIP;
1525 frame.AddrFrame.Offset = context.IntSp;
1526 frame.AddrStack.Offset = context.IntSp;
1527 frame.AddrBStore.Offset= context.RsBSP;
1529 std::cerr <<
"Stack traces not supported on your architecture yet." << std::endl;
1534 while (_StackWalk64(machineType, (HANDLE)::GetCurrentProcess(), thread, (LPSTACKFRAME64)&frame,
1535 (LPVOID)&context, (PREAD_PROCESS_MEMORY_ROUTINE)NULL, (PFUNCTION_TABLE_ACCESS_ROUTINE)_SymFunctionTableAccess64,
1536 (PGET_MODULE_BASE_ROUTINE)_SymGetModuleBase64, NULL)) {
1538 std::cerr << std::endl <<
"================ Thread " << iThread++ <<
" ================" << std::endl;
1539 if (!bFirst || threadentry.th32ThreadID != currentThreadID) {
1540 const std::string moduleName = GetModuleName(frame.AddrPC.Offset);
1541 const std::string functionName = GetFunctionName(frame.AddrPC.Offset);
1542 std::cerr <<
" " << moduleName << functionName << std::endl;
1546 ::CloseHandle(thread);
1547 }
while (::Thread32Next(snapshot, &threadentry));
1549 std::cerr << std::endl <<
"==========================================" << std::endl;
1550 std::cerr <<
"============= END STACKTRACE =============" << std::endl;
1551 std::cerr <<
"==========================================" << std::endl << std::endl;
1552 ::CloseHandle(snapshot);
1553 _SymCleanup(GetCurrentProcess());
1562 UInt_t oldmask = _statusfp( );
1564 if (oldmask & _EM_INVALID ) mask |=
kInvalid;
1565 if (oldmask & _EM_ZERODIVIDE) mask |=
kDivByZero;
1566 if (oldmask & _EM_OVERFLOW ) mask |=
kOverflow;
1567 if (oldmask & _EM_UNDERFLOW) mask |=
kUnderflow;
1568 if (oldmask & _EM_INEXACT ) mask |=
kInexact;
1582 if (mask &
kInvalid ) newm |= _EM_INVALID;
1583 if (mask &
kDivByZero) newm |= _EM_ZERODIVIDE;
1584 if (mask &
kOverflow ) newm |= _EM_OVERFLOW;
1585 if (mask &
kUnderflow) newm |= _EM_UNDERFLOW;
1586 if (mask &
kInexact ) newm |= _EM_INEXACT;
1588 UInt_t cm = ::_statusfp();
1590 ::_controlfp(cm , _MCW_EM);
1609 if (pendingOnly && gGlobalEvent) ::SetEvent(gGlobalEvent);
1611 Bool_t pollOnce = pendingOnly;
1615 if (
gROOT->GetApplication()) {
1631 ::WaitForSingleObject(gGlobalEvent, 1);
1632 ::ResetEvent(gGlobalEvent);
1658 if (pendingOnly && !pollOnce)
1697 if (!pendingOnly && gGlobalEvent) {
1698 ::WaitForSingleObject(gGlobalEvent, 1);
1699 ::ResetEvent(gGlobalEvent);
1718 rc = WinNTSelect(&t, 0, 0);
1719 if (rc < 0 && rc != -2) {
1720 ::SysError(
"DispatchOneEvent",
"select: read error on %d\n", fd);
1732 rc = WinNTSelect(0, &t, 0);
1733 if (rc < 0 && rc != -2) {
1734 ::SysError(
"DispatchOneEvent",
"select: write error on %d\n", fd);
1796 if (sync == sh->
IsSync()) {
1798 if ((
fSignals->
IsSet(sig) && sigdone == -1) || sigdone == sig) {
1799 if (sigdone == -1) {
1809 if (sigdone != -1)
return kTRUE;
1831 (fddone == fd && read)) {
1841 (fddone == fd && !read)) {
1851 if (fddone != -1)
return kTRUE;
1868 if (dirname.
Length() == 0) {
1885 if (res)
return res;
1905 const char *
proto = (strstr(
name,
"file:///")) ?
"file://" :
"file:";
1908 if (!
name)
return 0;
1912 if (!
name)
return 0;
1944 HANDLE searchFile = (HANDLE)dirp;
1978 return (psz[0] == TEXT(
'\\') && psz[1] == TEXT(
'\\'));
1998#pragma data_seg(".text", "CODE")
2013 if (!IsDBCSLeadByte(*pPath)) {
2018 if ((*pPath == TEXT(
'\\')) && (*(pPath + 1) == 0))
2024 int cBackslashes = 0;
2025 for (p = pPath + 2; *p; p = CharNext(p)) {
2026 if (*p == TEXT(
'\\') && (++cBackslashes > 1))
2046 const char *
proto = (strstr(fdir,
"file:///")) ?
"file://" :
"file:";
2049 char *dir =
new char[MAX_PATH];
2050 if (IsShortcut(sdir)) {
2051 if (!ResolveShortCut(sdir, dir, MAX_PATH))
2052 strlcpy(dir, sdir,MAX_PATH);
2055 strlcpy(dir, sdir,MAX_PATH);
2057 size_t nche = strlen(dir)+3;
2058 char *entry =
new char[nche];
2059 struct _stati64 finfo;
2062 strlcpy(entry, dir,nche);
2063 if ((entry[strlen(dir)-1] ==
'/') || (entry[strlen(dir)-1] ==
'\\' )) {
2064 entry[strlen(dir)-1] =
'\0';
2067 strlcat(entry,
"\\",nche);
2069 if (_stati64(entry, &finfo) < 0) {
2075 strlcpy(entry, dir,nche);
2076 if ((entry[strlen(dir)-1] ==
'/') || (entry[strlen(dir)-1] ==
'\\' )) {
2078 entry[strlen(dir)-1] =
'\0';
2080 if (_stati64(entry, &finfo) < 0) {
2087 if (finfo.st_mode & S_IFDIR) {
2088 strlcpy(entry, dir,nche);
2089 if (!(entry[strlen(dir)-1] ==
'/' || entry[strlen(dir)-1] ==
'\\' )) {
2090 strlcat(entry,
"\\",nche);
2092 if (entry[strlen(dir)-1] ==
' ')
2093 entry[strlen(dir)-1] =
'\0';
2094 strlcat(entry,
"*",nche);
2162 char *wdpath =
nullptr;
2163 char drive = driveletter ? toupper( driveletter ) -
'A' + 1 : 0;
2169 if (!(wdpath = ::_getdcwd( (
int)drive, wdpath,
kMAXPATHLEN))) {
2171 Warning(
"WorkingDirectory",
"getcwd() failed");
2195 return std::string(mydir);
2203 const char *
h =
nullptr;
2204 if (!(
h = ::getenv(
"home")))
h = ::getenv(
"HOME");
2211 h = ::getenv(
"HOMESHARE");
2212 if (!
h)
h = ::getenv(
"HOMEDRIVE");
2215 h = ::getenv(
"HOMEPATH");
2220 h = ::getenv(
"USERPROFILE");
2225 if (mydir[1] ==
':')
2226 mydir[0] = toupper(mydir[0]);
2242 if (!dir) dir =
"c:\\";
2258 char tmpName[MAX_PATH];
2262 FILE *fp = fopen(tmpName,
"w+");
2264 if (!fp)
::SysError(
"TempFileName",
"error opening %s", tmpName);
2282 if (!opt || !opt[0]) {
2287 UINT nOldErrorMode = ::SetErrorMode(SEM_FAILCRITICALERRORS);
2291 curdrive = _getdrive();
2292 if (strstr(opt,
"cur")) {
2294 sDrive.
Form(
"%c:", (curdrive +
'A' - 1));
2295 sType.
Form(
"Unknown Drive (%s)", sDrive.
Data());
2296 ::GetVolumeInformation(
Form(
"%s\\", sDrive.
Data()), NULL, 0, NULL, NULL,
2297 NULL, (LPSTR)szFs, 32);
2298 type = ::GetDriveType(sDrive.
Data());
2301 case DRIVE_NO_ROOT_DIR:
2303 case DRIVE_REMOVABLE:
2304 sType.
Form(
"Removable Disk (%s)", sDrive.
Data());
2307 sType.
Form(
"Local Disk (%s)", sDrive.
Data());
2310 sType.
Form(
"Network Drive (%s) (%s)", szFs, sDrive.
Data());
2313 sType.
Form(
"CD/DVD Drive (%s)", sDrive.
Data());
2316 sType.
Form(
"RAM Disk (%s)", sDrive.
Data());
2321 else if (strstr(opt,
"all")) {
2324 if (::GetLogicalDriveStrings(511, szTemp)) {
2325 TCHAR szDrive[3] = TEXT(
" :");
2331 sDrive.
Form(
"%s", szDrive);
2333 if ((sDrive ==
"A:") || (sDrive ==
"B:")) {
2337 sType.
Form(
"Unknown Drive (%s)", sDrive.
Data());
2338 ::GetVolumeInformation(
Form(
"%s\\", sDrive.
Data()), NULL, 0, NULL,
2339 NULL, NULL, (LPSTR)szFs, 32);
2340 type = ::GetDriveType(sDrive.
Data());
2343 case DRIVE_NO_ROOT_DIR:
2345 case DRIVE_REMOVABLE:
2346 sType.
Form(
"Removable Disk (%s)", sDrive.
Data());
2349 sType.
Form(
"Local Disk (%s)", sDrive.
Data());
2352 sType.
Form(
"Network Drive (%s) (%s)", szFs, sDrive.
Data());
2355 sType.
Form(
"CD/DVD Drive (%s)", sDrive.
Data());
2358 sType.
Form(
"RAM Disk (%s)", sDrive.
Data());
2368 ::SetErrorMode(nOldErrorMode);
2391 if (strchr(pathname,
'/') || strchr(pathname,
'\\')) {
2392 const char *rslash = strrchr(pathname,
'/');
2393 const char *bslash = strrchr(pathname,
'\\');
2394 const char *
r = std::max(rslash, bslash);
2395 const char *ptr = pathname;
2405 int len =
r - pathname;
2407 return TString(pathname, len);
2430 if (!pathname)
return 0;
2431 if (!pathname[0])
return 0;
2437 while(*lpchar ==
' ') lpchar++;
2439 if (isalpha((
int)*lpchar) && *(lpchar+1) ==
':') {
2443 if ( (*lpchar ==
'\\' || *lpchar ==
'/' ) &&
2444 (*(lpchar+1) ==
'\\' || *(lpchar+1) ==
'/') )
return 0;
2457 if (strchr(dir,
':')) idx = 2;
2458 return (dir[idx] ==
'/' || dir[idx] ==
'\\');
2491 const int kBufSize = 1024;
2492 TTHREAD_TLS_ARRAY(
char, kBufSize, temp);
2494 strlcpy(temp,
name, kBufSize);
2495 char *currentChar = temp;
2498 while (*currentChar !=
'\0') {
2499 if (*currentChar ==
'\\') *currentChar =
'/';
2517 UINT nOldErrorMode = ::SetErrorMode(SEM_FAILCRITICALERRORS);
2521 const char *
proto = (strstr(path,
"file:///")) ?
"file://" :
"file:";
2524 ::SetErrorMode(nOldErrorMode);
2529 ::SetErrorMode(nOldErrorMode);
2552 if (dir && dir[0]) {
2554 char last = dir[strlen(dir) - 1];
2555 if (last !=
'/' && last !=
'\\') {
2559 name.ReplaceAll(
"/",
"\\");
2576 if (!ret)
return -1;
2585 int ret = ::rename(
f, t);
2602 struct _stati64 sbuf;
2605 const char *
proto = (strstr(path,
"file:///")) ?
"file://" :
"file:";
2607 size_t l = strlen(newpath);
2609 if (newpath[--
l] !=
'\\' || newpath[--
l] !=
'/') {
2615 if (newpath && ::_stati64(newpath, &sbuf) >= 0) {
2617 buf.
fDev = sbuf.st_dev;
2618 buf.
fIno = sbuf.st_ino;
2619 buf.
fMode = sbuf.st_mode;
2620 buf.
fUid = sbuf.st_uid;
2621 buf.
fGid = sbuf.st_gid;
2622 buf.
fSize = sbuf.st_size;
2623 buf.
fMtime = sbuf.st_mtime;
2624 buf.
fIsLink = IsShortcut(newpath);
2626 char *lpath =
new char[MAX_PATH];
2627 if (IsShortcut(newpath)) {
2628 struct _stati64 sbuf2;
2629 if (ResolveShortCut(newpath, lpath, MAX_PATH)) {
2630 if (::_stati64(lpath, &sbuf2) >= 0) {
2631 buf.
fMode = sbuf2.st_mode;
2657 LPCTSTR lpRootPathName = path;
2660 LPTSTR lpVolumeNameBuffer = 0;
2661 DWORD nVolumeNameSize = 0;
2663 DWORD volumeSerialNumber;
2664 DWORD maximumComponentLength;
2667 DWORD fileSystemFlags;
2670 char fileSystemNameBuffer[512];
2671 DWORD nFileSystemNameSize =
sizeof(fileSystemNameBuffer);
2674 UINT nOldErrorMode = ::SetErrorMode(SEM_FAILCRITICALERRORS);
2675 if (!::GetVolumeInformation(lpRootPathName,
2676 lpVolumeNameBuffer, nVolumeNameSize,
2677 &volumeSerialNumber,
2678 &maximumComponentLength,
2680 fileSystemNameBuffer, nFileSystemNameSize)) {
2682 ::SetErrorMode(nOldErrorMode);
2686 const char *fsNames[] = {
"FAT",
"NTFS" };
2688 for (i = 0; i < 2; i++) {
2689 if (!strncmp(fileSystemNameBuffer, fsNames[i], nFileSystemNameSize))
2694 DWORD sectorsPerCluster;
2695 DWORD bytesPerSector;
2696 DWORD numberOfFreeClusters;
2697 DWORD totalNumberOfClusters;
2699 if (!::GetDiskFreeSpace(lpRootPathName,
2702 &numberOfFreeClusters,
2703 &totalNumberOfClusters)) {
2705 ::SetErrorMode(nOldErrorMode);
2709 ::SetErrorMode(nOldErrorMode);
2711 *bsize = sectorsPerCluster * bytesPerSector;
2712 *blocks = totalNumberOfClusters;
2713 *bfree = numberOfFreeClusters;
2723 struct _stati64 finfo;
2728 char linkname[1024];
2729 LPTSTR lpszFilePart;
2730 TCHAR szPath[MAX_PATH];
2733 typedef BOOL (__stdcall *CREATEHARDLINKPROC)( LPCTSTR, LPCTSTR, LPSECURITY_ATTRIBUTES );
2734 static CREATEHARDLINKPROC _CreateHardLink = 0;
2736 HMODULE hModImagehlp = LoadLibrary(
"Kernel32.dll" );
2741 _CreateHardLink = (CREATEHARDLINKPROC) GetProcAddress( hModImagehlp,
"CreateHardLinkW" );
2743 _CreateHardLink = (CREATEHARDLINKPROC) GetProcAddress( hModImagehlp,
"CreateHardLinkA" );
2745 if (!_CreateHardLink)
2748 dwRet = GetFullPathName(from,
sizeof(szPath) /
sizeof(TCHAR),
2749 szPath, &lpszFilePart);
2751 if (_stati64(szPath, &finfo) < 0)
2754 if (finfo.st_mode & S_IFDIR)
2758 _splitpath(linkname,winDrive,winDir,winName,winExt);
2759 if ((!winDrive[0] ) &&
2761 _splitpath(szPath,winDrive,winDir,winName,winExt);
2762 snprintf(linkname,1024,
"%s\\%s\\%s", winDrive, winDir, to);
2764 else if (!winDrive[0]) {
2765 _splitpath(szPath,winDrive,winDir,winName,winExt);
2766 snprintf(linkname,1024,
"%s\\%s", winDrive, to);
2769 if (!_CreateHardLink(linkname, szPath, NULL))
2782 IShellLink* pShellLink;
2783 IPersistFile* pPersistFile;
2784 WCHAR wszLinkfile[MAX_PATH];
2785 int iWideCharsWritten;
2787 LPTSTR lpszFilePart;
2788 TCHAR szPath[MAX_PATH];
2790 hRes = E_INVALIDARG;
2791 if ((from == NULL) || (!from[0]) || (to == NULL) ||
2797 typedef HRESULT (__stdcall *COINITIALIZEPROC)( LPVOID );
2798 static COINITIALIZEPROC _CoInitialize = 0;
2799 typedef void (__stdcall *COUNINITIALIZEPROC)(
void );
2800 static COUNINITIALIZEPROC _CoUninitialize = 0;
2801 typedef HRESULT (__stdcall *COCREATEINSTANCEPROC)( REFCLSID, LPUNKNOWN, DWORD, REFIID, LPVOID );
2802 static COCREATEINSTANCEPROC _CoCreateInstance = 0;
2804 HMODULE hModImagehlp = LoadLibrary(
"ole32.dll" );
2808 _CoInitialize = (COINITIALIZEPROC) GetProcAddress( hModImagehlp,
"CoInitialize" );
2811 _CoUninitialize = (COUNINITIALIZEPROC) GetProcAddress( hModImagehlp,
"CoUninitialize" );
2812 if (!_CoUninitialize)
2814 _CoCreateInstance = (COCREATEINSTANCEPROC) GetProcAddress( hModImagehlp,
"CoCreateInstance" );
2815 if (!_CoCreateInstance)
2822 _CoInitialize(NULL);
2825 dwRet = GetFullPathName(from,
sizeof(szPath) /
sizeof(TCHAR),
2826 szPath, &lpszFilePart);
2827 hRes = _CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER,
2828 IID_IShellLink, (LPVOID *)&pShellLink);
2829 if (SUCCEEDED(hRes)) {
2831 hRes = pShellLink->SetPath(szPath);
2833 hRes = pShellLink->QueryInterface(IID_IPersistFile, (
void **)&pPersistFile);
2834 if (SUCCEEDED(hRes)){
2835 iWideCharsWritten = MultiByteToWideChar(CP_ACP, 0, linkname.
Data(), -1,
2836 wszLinkfile, MAX_PATH);
2837 hRes = pPersistFile->Save(wszLinkfile,
TRUE);
2838 pPersistFile->Release();
2840 pShellLink->Release();
2858 struct _stati64 finfo;
2860 if (_stati64(
name, &finfo) < 0) {
2864 if (finfo.st_mode & S_IFDIR) {
2865 return ::_rmdir(
name);
2867 return ::_unlink(
name);
2876 if (::ioctlsocket(fd, FIONBIO, (u_long *)1) == SOCKET_ERROR) {
2895 const char *patbuf = (
const char *)patbuf0;
2897 char *cmd =
nullptr;
2903 const char driveletter =
DriveName(patbuf);
2912 if (!
proto.EqualTo(
"file"))
2920 while (*patbuf ==
' ') {
2925 while (*patbuf ==
':') {
2930 while (*patbuf ==
';') {
2936 for (
q = (
char*)patbuf; *
q;
q++) {
2940 if ( (((
q-2)>patbuf) && ( (*(
q-2)!=
';') || !isalpha(*(
q-1)) )) &&
2947 for (p = patbuf; *p; p++) {
2964 char replacement[4];
2967 for (
int k = 0; k<3; k++) replacement[k] = 0x1;
2969 replacement[3] = 0x0;
2973 while ( (pos = patbuf0.
Index(TildaNum,pos)) !=
kNPOS ) {
2974 patbuf0.
Replace(pos, 1, replacement);
2980 Int_t lbuf = ::ExpandEnvironmentStrings(
2986 cmd =
new char[lbuf+1];
2987 ::ExpandEnvironmentStrings(
3006 char newpath[MAX_PATH];
3007 if (IsShortcut(path)) {
3008 if (!ResolveShortCut(path, newpath, MAX_PATH))
3009 strlcpy(newpath, path, MAX_PATH);
3012 strlcpy(newpath, path, MAX_PATH);
3028 return ::_chmod(
file, mode);
3036 return ::umask(mask);
3046 Error(
"Utime",
"need write permission for %s to change utime",
file);
3049 if (!actime) actime = modtime;
3052 t.actime = (time_t)actime;
3053 t.modtime = (time_t)modtime;
3054 return ::utime(
file, &t);
3073 return infile.
Data();
3081 Int_t lastDelim = -1;
3082 for(
int i=0; i < exsearch.
Length(); ++i) {
3083 switch( exsearch[i] ) {
3086 if (i-lastDelim!=2) exsearch[i] =
';';
3089 case ';': lastDelim = i;
break;
3096 char *lpFilePart =
nullptr;
3098 ::access(
name, mode) == 0 && stat(
name, &finfo) == 0 &&
3099 finfo.st_mode & S_IFREG) {
3104 return infile.
Data();
3118 if ((
gEnv->
GetValue(
"WinNT.UseNetAPI", 0)) && (::GetVersion() < 0x80000000)) {
3121 HINSTANCE netapi = ::LoadLibrary(
"netapi32.DLL");
3122 if (!netapi)
return kFALSE;
3124 p2NetApiBufferFree = (pfn1)::GetProcAddress(netapi,
"NetApiBufferFree");
3125 p2NetUserGetInfo = (pfn2)::GetProcAddress(netapi,
"NetUserGetInfo");
3126 p2NetLocalGroupGetMembers = (pfn3)::GetProcAddress(netapi,
"NetLocalGroupGetMembers");
3127 p2NetLocalGroupEnum = (pfn4)::GetProcAddress(netapi,
"NetLocalGroupEnum");
3129 if (!p2NetApiBufferFree || !p2NetUserGetInfo ||
3130 !p2NetLocalGroupGetMembers || !p2NetLocalGroupEnum)
return kFALSE;
3141 ::FreeLibrary(netapi);
3151 NET_API_STATUS NetStatus = NERR_Success;
3153 DWORD Index = 0, ResumeHandle = 0, Total = 0;
3154 LOCALGROUP_MEMBERS_INFO_1 *MemberInfo;
3155 WCHAR wszGroupName[256];
3157 DWORD dwLastError = 0;
3159 iRetOp = MultiByteToWideChar (
3161 (DWORD)MB_PRECOMPOSED,
3162 (LPCSTR)lpszGroupName,
3164 (LPWSTR)wszGroupName,
3165 (
int)
sizeof(wszGroupName) );
3168 dwLastError = GetLastError();
3170 p2NetApiBufferFree(Data);
3176 NetStatus = p2NetLocalGroupGetMembers (NULL, wszGroupName, 1,
3177 &Data, 8192, &Index, &Total, &ResumeHandle );
3179 if (NetStatus != NERR_Success || Data == NULL) {
3180 dwLastError = GetLastError();
3182 if (dwLastError == ERROR_ENVVAR_NOT_FOUND) {
3188 NetStatus = p2NetLocalGroupGetMembers ( NULL, wszGroupName, 0,
3189 &Data, 8192, &Index, &Total, &ResumeHandle );
3193 p2NetApiBufferFree(Data);
3198 MemberInfo = (LOCALGROUP_MEMBERS_INFO_1 *)Data;
3201 p2NetApiBufferFree(Data);
3210 NET_API_STATUS NetStatus = NERR_Success;
3212 DWORD Index = 0, ResumeHandle = 0, Total = 0, i;
3213 LOCALGROUP_INFO_0 *GroupInfo;
3214 char szAnsiName[256];
3215 DWORD dwLastError = 0;
3218 NetStatus = p2NetLocalGroupEnum(NULL, 0, &Data, 8192, &Index,
3219 &Total, &ResumeHandle );
3221 if (NetStatus != NERR_Success || Data == NULL) {
3222 dwLastError = GetLastError();
3224 p2NetApiBufferFree(Data);
3229 GroupInfo = (LOCALGROUP_INFO_0 *)Data;
3230 for (i=0; i < Total; i++) {
3232 iRetOp = WideCharToMultiByte (
3235 (LPCWSTR)(GroupInfo->lgrpi0_name),
3238 (
int)(
sizeof(szAnsiName)),
3250 p2NetApiBufferFree(Data);
3262 int &groupIdx,
int &memberIdx)
3264 BOOL bRetOp =
FALSE;
3266 DWORD dwSidSize, dwDomainNameSize;
3269 SID_NAME_USE sidType;
3270 PUCHAR puchar_SubAuthCount = NULL;
3271 SID_IDENTIFIER_AUTHORITY sid_identifier_authority;
3272 PSID_IDENTIFIER_AUTHORITY psid_identifier_authority = NULL;
3273 unsigned char j = 0;
3274 DWORD dwLastError = 0;
3276 pSid = (PSID)bySidBuffer;
3277 dwSidSize =
sizeof(bySidBuffer);
3278 dwDomainNameSize =
sizeof(szDomainName);
3280 bRetOp = LookupAccountName (
3282 (LPCTSTR)lpszAccountName,
3284 (LPDWORD)&dwSidSize,
3285 (LPTSTR)szDomainName,
3286 (LPDWORD)&dwDomainNameSize,
3287 (PSID_NAME_USE)&sidType );
3289 if (bRetOp ==
FALSE) {
3290 dwLastError = GetLastError();
3294 bRetOp = IsValidSid((PSID)pSid);
3296 if (bRetOp ==
FALSE) {
3297 dwLastError = GetLastError();
3302 psid_identifier_authority = GetSidIdentifierAuthority ((PSID)pSid);
3305 memcpy (&sid_identifier_authority, psid_identifier_authority,
3306 sizeof(SID_IDENTIFIER_AUTHORITY));
3309 puchar_SubAuthCount = (PUCHAR)GetSidSubAuthorityCount((PSID)pSid);
3311 j = (
unsigned char)(*puchar_SubAuthCount);
3313 DWORD dwSubAuth = 0;
3314 PDWORD pdwSubAuth = NULL;
3316 pdwSubAuth = (PDWORD)GetSidSubAuthority (
3319 dwSubAuth = *pdwSubAuth;
3338 NET_API_STATUS NetStatus = NERR_Success;
3340 DWORD Index = 0, ResumeHandle = 0, Total = 0, i;
3341 LOCALGROUP_MEMBERS_INFO_1 *MemberInfo;
3342 char szAnsiMemberName[256];
3343 char szFullMemberName[256];
3344 char szMemberHomeDir[256];
3345 WCHAR wszGroupName[256];
3348 DWORD length =
sizeof (act_name);
3349 DWORD dwLastError = 0;
3350 LPUSER_INFO_11 pUI11Buf = NULL;
3351 NET_API_STATUS nStatus;
3353 iRetOp = MultiByteToWideChar (
3355 (DWORD)MB_PRECOMPOSED,
3356 (LPCSTR)lpszGroupName,
3358 (LPWSTR)wszGroupName,
3359 (
int)
sizeof(wszGroupName) );
3362 dwLastError = GetLastError();
3364 p2NetApiBufferFree(Data);
3368 GetUserName (act_name, &length);
3372 NetStatus = p2NetLocalGroupGetMembers (NULL, wszGroupName, 1,
3373 &Data, 8192, &Index, &Total, &ResumeHandle );
3375 if (NetStatus != NERR_Success || Data == NULL) {
3376 dwLastError = GetLastError();
3378 if (dwLastError == ERROR_ENVVAR_NOT_FOUND) {
3384 NetStatus = p2NetLocalGroupGetMembers ( NULL, wszGroupName, 0,
3385 &Data, 8192, &Index, &Total, &ResumeHandle );
3389 p2NetApiBufferFree(Data);
3393 MemberInfo = (LOCALGROUP_MEMBERS_INFO_1 *)Data;
3394 for (i=0; i < Total; i++) {
3395 iRetOp = WideCharToMultiByte (
3398 (LPCWSTR)(MemberInfo->lgrmi1_name),
3400 (LPSTR)szAnsiMemberName,
3401 (
int)(
sizeof(szAnsiMemberName)),
3406 dwLastError = GetLastError();
3417 TCHAR szUserName[255]=TEXT(
"");
3418 MultiByteToWideChar(CP_ACP, 0, szAnsiMemberName, -1, (LPWSTR)szUserName, 255);
3422 nStatus = p2NetUserGetInfo(NULL, (LPCWSTR)szUserName, 11, (LPBYTE *)&pUI11Buf);
3426 if (nStatus == NERR_Success) {
3427 if (pUI11Buf != NULL) {
3428 wsprintf(szFullMemberName,
"%S",pUI11Buf->usri11_full_name);
3430 wsprintf(szMemberHomeDir,
"%S",pUI11Buf->usri11_home_dir);
3441 if (pUI11Buf != NULL) {
3442 p2NetApiBufferFree(pUI11Buf);
3447 if (getenv(
"SHELL") == NULL)
3448 putenv ((GetVersion () & 0x80000000) ?
"SHELL=command" :
"SHELL=cmd");
3461 p2NetApiBufferFree(Data);
3471 NET_API_STATUS NetStatus = NERR_Success;
3473 DWORD Index = 0, ResumeHandle = 0, Total = 0, i;
3474 LOCALGROUP_INFO_0 *GroupInfo;
3475 char szAnsiName[256];
3476 DWORD dwLastError = 0;
3477 int iRetOp = 0, iGroupIdx = 0, iMemberIdx = 0;
3479 NetStatus = p2NetLocalGroupEnum(NULL, 0, &Data, 8192, &Index,
3480 &Total, &ResumeHandle );
3482 if (NetStatus != NERR_Success || Data == NULL) {
3483 dwLastError = GetLastError();
3485 p2NetApiBufferFree(Data);
3489 GroupInfo = (LOCALGROUP_INFO_0 *)Data;
3490 for (i=0; i < Total; i++) {
3492 iRetOp = WideCharToMultiByte (
3495 (LPCWSTR)(GroupInfo->lgrpi0_name),
3498 (
int)(
sizeof(szAnsiName)),
3516 p2NetApiBufferFree(Data);
3530 if ((!
gEnv->
GetValue(
"WinNT.UseNetAPI", 0)) || (::GetVersion() >= 0x80000000)) {
3533 DWORD length =
sizeof (
name);
3534 if (::GetUserName (
name, &length)) {
3535 if (stricmp (
"administrator",
name) == 0)
3545 if (!user || !user[0])
3550 if (!stricmp (user,
fPasswords[i].pw_name)) {
3571 if ((!
gEnv->
GetValue(
"WinNT.UseNetAPI", 0)) || (::GetVersion() >= 0x80000000)) {
3574 DWORD length =
sizeof (
name);
3575 if (::GetUserName (
name, &length)) {
3576 if (stricmp (
"administrator",
name) == 0)
3598 if ((!
gEnv->
GetValue(
"WinNT.UseNetAPI", 0)) || (::GetVersion() >= 0x80000000)) {
3601 DWORD length =
sizeof (
name);
3602 if (::GetUserName (
name, &length)) {
3603 if (stricmp (
"administrator",
name) == 0)
3616 struct group *grp =
nullptr;
3639 if ((!
gEnv->
GetValue(
"WinNT.UseNetAPI", 0)) || (::GetVersion() >= 0x80000000)) {
3642 DWORD length =
sizeof (
name);
3643 if (::GetUserName (
name, &length)) {
3644 if (stricmp (
"administrator",
name) == 0)
3667 if ((!
gEnv->
GetValue(
"WinNT.UseNetAPI", 0)) || (::GetVersion() >= 0x80000000)) {
3669 DWORD length =
sizeof (
name);
3671 if (::GetUserName (
name, &length)) {
3673 if (stricmp (
"administrator",
name) == 0) {
3675 ug->
fGroup =
"administrators";
3684 ug->
fUser =
"unknown";
3697 for (
int i = 0; i <
fNbUsers; i++) {
3741 if ((!
gEnv->
GetValue(
"WinNT.UseNetAPI", 0)) || (::GetVersion() >= 0x80000000)) {
3743 DWORD length =
sizeof (
name);
3745 if (::GetUserName (
name, &length)) {
3746 if (stricmp (
"administrator",
name) == 0) {
3747 gr->fGroup =
"administrators";
3751 gr->fGroup =
"users";
3756 gr->fGroup =
"unknown";
3762 struct group *grp =
nullptr;
3764 if (gid ==
fGroups[i].gr_gid) {
3806 const char *env = ::getenv(
name);
3808 if (::_stricmp(
name,
"home") == 0 ) {
3810 }
else if (::_stricmp(
name,
"rootsys") == 0 ) {
3824 return ::system(shellcmd);
3832 return ::_popen(command, mode);
3840 return ::_pclose(pipe);
3868 gROOT->CloseFiles();
3869 if (
gROOT->GetListOfBrowsers()) {
3872 if (
gROOT->IsBatch())
3873 gROOT->GetListOfBrowsers()->Delete();
3878 if (
b->GetBrowserImp() &&
b->GetBrowserImp()->GetMainFrame())
3880 (((TBrowser*)0x%zx)->GetBrowserImp()->GetMainFrame()->CloseWindow();",
3922 static int fd1=0, fd2=0;
3923 static fpos_t pos1=0, pos2=0;
3933 const char *
m = (mode[0] ==
'a' || mode[0] ==
'w') ? mode :
"a";
3946 fgetpos(stdout, &pos1);
3947 fd1 = _dup(fileno(stdout));
3949 if ((fout = freopen(
file,
m, stdout)) == 0) {
3950 SysError(
"RedirectOutput",
"could not freopen stdout");
3952 _dup2(fd1, fileno(stdout));
3956 fsetpos(stdout, &pos1);
3961 fgetpos(stderr, &pos2);
3962 fd2 = _dup(fileno(stderr));
3963 if ((ferr = freopen(
file,
m, stderr)) == 0) {
3964 SysError(
"RedirectOutput",
"could not freopen stderr");
3966 _dup2(fd1, fileno(stdout));
3970 fsetpos(stdout, &pos1);
3972 _dup2(fd2, fileno(stderr));
3976 fsetpos(stderr, &pos2);
3981 fseek(fout, 0, SEEK_END);
3982 fseek(ferr, 0, SEEK_END);
3989 if (_dup2(fd1, fileno(stdout))) {
3990 SysError(
"RedirectOutput",
"could not restore stdout");
3996 fsetpos(stdout, &pos1);
4003 if (_dup2(fd2, fileno(stderr))) {
4004 SysError(
"RedirectOutput",
"could not restore stderr");
4010 fsetpos(stderr, &pos2);
4065 if (len > 4 && (!stricmp(sLib.
Data()+len-4,
".dll"))) {
4078 Error(
"DynamicPathName",
4079 "%s does not exist in %s,\nor has wrong file extension (.dll)",
4096#pragma warning(push)
4097#pragma warning(disable:4200)
4114 if (!linkedLibs.
IsNull())
4127 HANDLE hFile, hMapping;
4130 if((hFile = CreateFile(exe,GENERIC_READ,FILE_SHARE_READ,0,OPEN_EXISTING,FILE_FLAG_SEQUENTIAL_SCAN,0))==
INVALID_HANDLE_VALUE) {
4134 if(!(hMapping = CreateFileMapping(hFile,0,PAGE_READONLY|SEC_COMMIT,0,0,0))) {
4139 if(!(basepointer = MapViewOfFile(hMapping,FILE_MAP_READ,0,0,0))) {
4140 CloseHandle(hMapping);
4147 IMAGE_DOS_HEADER *dos_head = (IMAGE_DOS_HEADER *)basepointer;
4150 IMAGE_FILE_HEADER _head;
4151 IMAGE_OPTIONAL_HEADER opt_head;
4152 IMAGE_SECTION_HEADER section_header[];
4154 struct header *pheader;
4155 const IMAGE_SECTION_HEADER * section_header;
4157 if(dos_head->e_magic!=
'ZM') {
4162 pheader = (
struct header *)((
char*)dos_head + dos_head->e_lfanew);
4164 if(IsBadReadPtr(pheader,
sizeof(
struct header))) {
4168 if(pheader->signature!=IMAGE_NT_SIGNATURE) {
4169 switch((
unsigned short)pheader->signature) {
4170 case IMAGE_DOS_SIGNATURE:
4173 case IMAGE_OS2_SIGNATURE:
4176 case IMAGE_OS2_SIGNATURE_LE:
4184#define isin(address,start,length) ((address)>=(start) && (address)<(start)+(length))
4187 for(sect=0,section_header=pheader->section_header;
4188 sect<pheader->_head.NumberOfSections;sect++,section_header++) {
4190 const void *
const section_data =
4191 (
char*)basepointer + section_header->PointerToRawData;
4192 for(directory=0;directory<IMAGE_NUMBEROF_DIRECTORY_ENTRIES;directory++) {
4193 if(
isin(pheader->opt_head.DataDirectory[directory].VirtualAddress,
4194 section_header->VirtualAddress,
4195 section_header->SizeOfRawData)) {
4196 const IMAGE_IMPORT_DESCRIPTOR *stuff_start =
4197 (IMAGE_IMPORT_DESCRIPTOR *)((
char*)section_data +
4198 (pheader->opt_head.DataDirectory[directory].VirtualAddress -
4199 section_header->VirtualAddress));
4202 const unsigned stuff_length =
4203 pheader->opt_head.DataDirectory[directory].Size;
4204 if(directory == IMAGE_DIRECTORY_ENTRY_IMPORT) {
4205 while(!IsBadReadPtr(stuff_start,
sizeof(*stuff_start)) &&
4206 stuff_start->Name) {
4207 TString dll = (
char*)section_data +
4208 ((DWORD)(stuff_start->Name)) -
4209 section_header->VirtualAddress;
4213 char *winPath = getenv(
"windir");
4214 _splitpath(winPath,winDrive,winDir,winName,winExt);
4215 if(!strstr(dllPath, winDir)) {
4216 if (!linkedLibs.
IsNull())
4218 linkedLibs += dllPath;
4230 UnmapViewOfFile(basepointer);
4231 CloseHandle(hMapping);
4262 char drive[_MAX_DRIVE], dir[_MAX_DIR], fname[_MAX_FNAME], ext[_MAX_EXT];
4265 std::vector<std::string> all_libs, libpaths;
4271 while (getline(libenv, str,
';')) {
4272 libpaths.push_back(str);
4275 std::stringstream libraries(libs.
Data());
4276 while (getline(libraries, str,
' ')) {
4277 std::string::size_type
first, last;
4280 if (str.rfind(
"-L", 0) == 0) {
4281 first = str.find_first_of(
'%');
4282 last = str.find_last_of(
'%');
4283 if ((
first != std::string::npos) && (last != std::string::npos) &&
4288 std::string var = str.substr(
first+1, last-
first-1);
4293 env += str.substr(last+1);
4294 libpaths.push_back(env);
4298 ntlibs.
Append(str.c_str());
4303 last = str.rfind(
".dll");
4304 if (last != std::string::npos)
4305 str.replace(last, 4,
".lib");
4306 last = str.rfind(
".DLL");
4307 if (last != std::string::npos)
4308 str.replace(last, 4,
".lib");
4309 if (str.rfind(
".lib") != std::string::npos ||
4310 str.rfind(
".LIB") != std::string::npos) {
4312 if (_stat( str.c_str(), &buf ) == 0) {
4314 ntlibs.
Append(str.c_str());
4322 _splitpath(str.c_str(), drive, dir, fname, ext);
4323 std::string libname(fname);
4325 all_libs.push_back(libname);
4327 for (
auto lib : all_libs) {
4329 for (
auto libpath : libpaths) {
4331 std::string path_lib(libpath);
4334 if (_stat( path_lib.c_str(), &buf ) == 0) {
4336 ntlibs.
Append(lib.c_str());
4365 if (!ti)
return nullptr;
4400 if (mode && t->
IsSync()) {
4404 }
else if (!mode && t->
IsAsync()) {
4422 FILETIME ftFileTime;
4426 ::GetSystemTimeAsFileTime(&ftRealTime.ftFileTime);
4435 OSVERSIONINFO OsVersionInfo;
4444 OsVersionInfo.dwOSVersionInfoSize =
sizeof(OSVERSIONINFO);
4445 GetVersionEx(&OsVersionInfo);
4446 if (OsVersionInfo.dwPlatformId == VER_PLATFORM_WIN32_NT) {
4452 FILETIME ftFileTime;
4457 FILETIME ftFileTime;
4461 HANDLE hThread = GetCurrentThread();
4462 ret = GetThreadTimes (hThread, &ftCreate, &ftExit,
4463 &ftKernel.ftFileTime,
4464 &ftUser.ftFileTime);
4466 ret = ::GetLastError();
4467 ::Error(
"GetCPUTime",
" Error on GetProcessTimes 0x%lx", (
int)ret);
4487 static time_t jan95 = 0;
4498 jan95 = mktime(&tp);
4499 if ((
int)jan95 == -1) {
4500 ::SysError(
"TWinNTSystem::Now",
"error converting 950001 0:00 to time_t");
4507 return TTime((now.time-(
Long_t)jan95)*1000 + now.millitm);
4533 if (
h->HasReadInterest())
4535 if (
h->HasWriteInterest())
4537 h->ResetReadyMask();
4539 rc = WinNTSelect(&rd, &wr, to);
4568 if (
h->HasReadInterest())
4570 if (
h->HasWriteInterest())
4572 h->ResetReadyMask();
4573 rc = WinNTSelect(&rd, &wr, to);
4595 if ((sp = ::getservbyname(servicename,
kProtocolName)) == 0) {
4596 Error(
"GetServiceByName",
"no service \"%s\" with protocol \"%s\"\n",
4600 return ::ntohs(sp->s_port);
4611 if ((sp = ::getservbyport(::htons(port),
kProtocolName)) == 0) {
4612 return Form(
"%d", port);
4622 struct hostent *host_ptr;
4627 if ((addr = ::inet_addr(hostname)) != INADDR_NONE) {
4629 if ((host_ptr = ::gethostbyaddr((
const char *)&addr,
4630 sizeof(addr), AF_INET))) {
4631 host = host_ptr->h_name;
4635 for (i = 1; host_ptr->h_addr_list[i]; i++) {
4636 memcpy(&addr2, host_ptr->h_addr_list[i], host_ptr->h_length);
4637 a.AddAddress(ntohl(addr2));
4639 for (i = 0; host_ptr->h_aliases[i]; i++)
4640 a.AddAlias(host_ptr->h_aliases[i]);
4643 host =
"UnNamedHost";
4645 }
else if ((host_ptr = ::gethostbyname(hostname))) {
4647 if (host_ptr->h_addrtype != AF_INET) {
4648 Error(
"GetHostByName",
"%s is not an internet host\n", hostname);
4651 memcpy(&addr, host_ptr->h_addr, host_ptr->h_length);
4652 host = host_ptr->h_name;
4653 type = host_ptr->h_addrtype;
4657 for (i = 1; host_ptr->h_addr_list[i]; i++) {
4658 memcpy(&addr2, host_ptr->h_addr_list[i], host_ptr->h_length);
4659 a.AddAddress(ntohl(addr2));
4661 for (i = 0; host_ptr->h_aliases[i]; i++)
4662 a.AddAlias(host_ptr->h_aliases[i]);
4665 if (
gDebug > 0)
Error(
"GetHostByName",
"unknown host %s", hostname);
4678 struct sockaddr_in addr;
4679 int len =
sizeof(addr);
4681 if (::getpeername(sock, (
struct sockaddr *)&addr, &len) == SOCKET_ERROR) {
4686 struct hostent *host_ptr;
4687 const char *hostname;
4691 if ((host_ptr = ::gethostbyaddr((
const char *)&addr.sin_addr,
4692 sizeof(addr.sin_addr), AF_INET))) {
4693 memcpy(&iaddr, host_ptr->h_addr, host_ptr->h_length);
4694 hostname = host_ptr->h_name;
4695 family = host_ptr->h_addrtype;
4697 memcpy(&iaddr, &addr.sin_addr,
sizeof(addr.sin_addr));
4702 return TInetAddress(hostname, ::ntohl(iaddr), family, ::ntohs(addr.sin_port));
4711 struct sockaddr_in addr;
4712 int len =
sizeof(addr);
4714 if (::getsockname(sock, (
struct sockaddr *)&addr, &len) == SOCKET_ERROR) {
4719 struct hostent *host_ptr;
4720 const char *hostname;
4724 if ((host_ptr = ::gethostbyaddr((
const char *)&addr.sin_addr,
4725 sizeof(addr.sin_addr), AF_INET))) {
4726 memcpy(&iaddr, host_ptr->h_addr, host_ptr->h_length);
4727 hostname = host_ptr->h_name;
4728 family = host_ptr->h_addrtype;
4730 memcpy(&iaddr, &addr.sin_addr,
sizeof(addr.sin_addr));
4735 return TInetAddress(hostname, ::ntohl(iaddr), family, ::ntohs(addr.sin_port));
4747 ::SysError(
"TWinNTSystem::AnnounceUnixService",
"socket");
4751 struct sockaddr_in inserver;
4752 memset(&inserver, 0,
sizeof(inserver));
4753 inserver.sin_family = AF_INET;
4754 inserver.sin_addr.s_addr = ::htonl(INADDR_LOOPBACK);
4755 inserver.sin_port = port;
4759 if (::bind(sock, (
struct sockaddr*) &inserver,
sizeof(inserver)) == SOCKET_ERROR) {
4760 ::SysError(
"TWinNTSystem::AnnounceUnixService",
"bind");
4765 if (::listen(sock, backlog)) {
4766 ::SysError(
"TWinNTSystem::AnnounceUnixService",
"listen");
4778 if (!sockpath || strlen(sockpath) <= 0) {
4779 ::SysError(
"TWinNTSystem::AnnounceUnixService",
"socket path undefined");
4783 struct sockaddr_in myaddr;
4785 int len =
sizeof myaddr;
4790 if ((sock =
socket(AF_INET, SOCK_STREAM, 0)) < 0) {
4791 ::SysError(
"TWinNTSystem::AnnounceUnixService",
"socket");
4795 memset(&myaddr, 0,
sizeof(myaddr));
4796 myaddr.sin_port = 0;
4797 myaddr.sin_family = AF_INET;
4798 myaddr.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
4800 rc = bind(sock, (
struct sockaddr *)&myaddr, len);
4802 ::SysError(
"TWinNTSystem::AnnounceUnixService",
"bind");
4805 rc = getsockname(sock, (
struct sockaddr *)&myaddr, &len);
4807 ::SysError(
"TWinNTSystem::AnnounceUnixService",
"getsockname");
4810 TString socketpath = sockpath;
4812 fp = fopen(socketpath,
"wb");
4814 ::SysError(
"TWinNTSystem::AnnounceUnixService",
"fopen");
4817 fprintf(fp,
"%d", myaddr.sin_port);
4821 if (listen(sock, backlog)) {
4822 ::SysError(
"TWinNTSystem::AnnounceUnixService",
"listen");
4834 if (
socket == -1)
return;
4838 ::shutdown(sock, 2);
4840 struct linger linger = {0, 0};
4841 ::setsockopt(sock, SOL_SOCKET, SO_LINGER, (
char *) &linger,
sizeof(linger));
4842 while (
::closesocket(sock) == SOCKET_ERROR && WSAGetLastError() == WSAEINTR) {
4856 if (WinNTRecv(sock, &header,
sizeof(header), 0) > 0) {
4857 int count = ::ntohl(header);
4859 if (count > length) {
4860 Error(
"RecvBuf",
"record header exceeds buffer size");
4862 }
else if (count > 0) {
4863 if (WinNTRecv(sock, buf, count, 0) < 0) {
4864 Error(
"RecvBuf",
"cannot receive buffer");
4879 Int_t header = ::htonl(length);
4881 if (WinNTSend(sock, &header,
sizeof(header), 0) < 0) {
4882 Error(
"SendBuf",
"cannot send header");
4886 if (WinNTSend(sock, buf, length, 0) < 0) {
4887 Error(
"SendBuf",
"cannot send buffer");
4927 if ((
n = WinNTRecv(sock, buf, length, flag)) <= 0) {
4929 Error(
"RecvRaw",
"cannot receive buffer");
4963 if ((
n = WinNTSend(sock, buf, length, flag)) <= 0) {
4965 Error(
"SendRaw",
"cannot send buffer");
4978 if (
socket == -1)
return -1;
4983 if (::setsockopt(sock, SOL_SOCKET, SO_SNDBUF, (
char*)&val,
sizeof(val)) == SOCKET_ERROR) {
4984 ::SysError(
"SetSockOpt",
"setsockopt(SO_SNDBUF)");
4989 if (::setsockopt(sock, SOL_SOCKET, SO_RCVBUF, (
char*)&val,
sizeof(val)) == SOCKET_ERROR) {
4990 ::SysError(
"SetSockOpt",
"setsockopt(SO_RCVBUF)");
4995 if (::setsockopt(sock, SOL_SOCKET, SO_OOBINLINE, (
char*)&val,
sizeof(val)) == SOCKET_ERROR) {
4996 SysError(
"SetSockOpt",
"setsockopt(SO_OOBINLINE)");
5001 if (::setsockopt(sock, SOL_SOCKET, SO_KEEPALIVE, (
char*)&val,
sizeof(val)) == SOCKET_ERROR) {
5002 ::SysError(
"SetSockOpt",
"setsockopt(SO_KEEPALIVE)");
5007 if (::setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (
char*)&val,
sizeof(val)) == SOCKET_ERROR) {
5008 ::SysError(
"SetSockOpt",
"setsockopt(SO_REUSEADDR)");
5013 if (::setsockopt(sock, IPPROTO_TCP, TCP_NODELAY, (
char*)&val,
sizeof(val)) == SOCKET_ERROR) {
5014 ::SysError(
"SetSockOpt",
"setsockopt(TCP_NODELAY)");
5019 if (::ioctlsocket(sock, FIONBIO, &val) == SOCKET_ERROR) {
5026 if (::ioctl(sock, SIOCSPGRP, &val) == -1) {
5027 ::SysError(
"SetSockOpt",
"ioctl(SIOCSPGRP)");
5035 Error(
"SetSockOpt",
"illegal option (%d)", opt);
5047 if (
socket == -1)
return -1;
5050 int optlen =
sizeof(*val);
5054 if (::getsockopt(sock, SOL_SOCKET, SO_SNDBUF, (
char*)val, &optlen) == SOCKET_ERROR) {
5055 ::SysError(
"GetSockOpt",
"getsockopt(SO_SNDBUF)");
5060 if (::getsockopt(sock, SOL_SOCKET, SO_RCVBUF, (
char*)val, &optlen) == SOCKET_ERROR) {
5061 ::SysError(
"GetSockOpt",
"getsockopt(SO_RCVBUF)");
5066 if (::getsockopt(sock, SOL_SOCKET, SO_OOBINLINE, (
char*)val, &optlen) == SOCKET_ERROR) {
5067 ::SysError(
"GetSockOpt",
"getsockopt(SO_OOBINLINE)");
5072 if (::getsockopt(sock, SOL_SOCKET, SO_KEEPALIVE, (
char*)val, &optlen) == SOCKET_ERROR) {
5073 ::SysError(
"GetSockOpt",
"getsockopt(SO_KEEPALIVE)");
5078 if (::getsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (
char*)val, &optlen) == SOCKET_ERROR) {
5079 ::SysError(
"GetSockOpt",
"getsockopt(SO_REUSEADDR)");
5084 if (::getsockopt(sock, IPPROTO_TCP, TCP_NODELAY, (
char*)val, &optlen) == SOCKET_ERROR) {
5085 ::SysError(
"GetSockOpt",
"getsockopt(TCP_NODELAY)");
5101 if (::ioctlsocket(sock, SIOCGPGRP, (u_long*)val) == SOCKET_ERROR) {
5102 ::SysError(
"GetSockOpt",
"ioctl(SIOCGPGRP)");
5108 if (::ioctlsocket(sock, SIOCATMARK, (u_long*)val) == SOCKET_ERROR) {
5109 ::SysError(
"GetSockOpt",
"ioctl(SIOCATMARK)");
5114 if (::ioctlsocket(sock, FIONREAD, (u_long*)val) == SOCKET_ERROR) {
5120 Error(
"GetSockOpt",
"illegal option (%d)", opt);
5132 int tcpwindowsize,
const char *protocol)
5137 if (!strcmp(servername,
"unix")) {
5141 (servername[1] ==
':' && servername[2] ==
'/')) {
5145 if (!strcmp(protocol,
"udp")){
5152 sport = ::htons(port);
5156 if (!addr.
IsValid())
return -1;
5159 struct sockaddr_in server;
5160 memset(&server, 0,
sizeof(server));
5161 memcpy(&server.sin_addr, &adr,
sizeof(adr));
5163 server.sin_port = sport;
5168 ::SysError(
"TWinNTSystem::WinNTConnectTcp",
"socket");
5172 if (tcpwindowsize > 0) {
5177 if (::connect(sock, (
struct sockaddr*) &server,
sizeof(server)) ==
INVALID_SOCKET) {
5190 struct sockaddr_in myaddr;
5193 memset(&myaddr, 0,
sizeof(myaddr));
5194 myaddr.sin_family = AF_INET;
5195 myaddr.sin_port = port;
5196 myaddr.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
5199 if ((sock =
socket(AF_INET, SOCK_STREAM, 0)) < 0) {
5200 ::SysError(
"TWinNTSystem::WinNTUnixConnect",
"socket");
5204 while ((connect(sock, (
struct sockaddr *)&myaddr,
sizeof myaddr)) == -1) {
5208 ::SysError(
"TWinNTSystem::WinNTUnixConnect",
"connect");
5224 if (!sockpath || strlen(sockpath) <= 0) {
5225 ::SysError(
"TWinNTSystem::WinNTUnixConnect",
"socket path undefined");
5228 TString socketpath = sockpath;
5230 fp = fopen(socketpath.
Data(),
"rb");
5232 ::SysError(
"TWinNTSystem::WinNTUnixConnect",
"fopen");
5235 fscanf(fp,
"%d", &port);
5238 if (port < 0 || port > 65535) {
5239 ::SysError(
"TWinNTSystem::WinNTUnixConnect",
"invalid port");
5257 sport = htons(port);
5260 if (!addr.
IsValid())
return -1;
5263 struct sockaddr_in server;
5264 memset(&server, 0,
sizeof(server));
5265 memcpy(&server.sin_addr, &adr,
sizeof(adr));
5267 server.sin_port = sport;
5271 if ((sock =
socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) < 0) {
5272 ::SysError(
"TWinNTSystem::WinNTUdpConnect",
"socket (%s:%d)",
5277 while (connect(sock, (
struct sockaddr*) &server,
sizeof(server)) == -1) {
5281 ::SysError(
"TWinNTSystem::WinNTUdpConnect",
"connect (%s:%d)",
5299 const char *protocol)
5320 const short kSOCKET_MINPORT = 5000, kSOCKET_MAXPORT = 15000;
5321 short tryport = kSOCKET_MINPORT;
5326 sport = ::htons(port);
5329 if (port == 0 && reuse) {
5330 ::Error(
"TWinNTSystem::WinNTTcpService",
"cannot do a port scan while reuse is true");
5337 sport = ::htons(port);
5342 if ((sock =
::socket(AF_INET, SOCK_STREAM, 0)) < 0) {
5343 ::SysError(
"TWinNTSystem::WinNTTcpService",
"socket");
5351 if (tcpwindowsize > 0) {
5356 struct sockaddr_in inserver;
5357 memset(&inserver, 0,
sizeof(inserver));
5358 inserver.sin_family = AF_INET;
5359 inserver.sin_addr.s_addr = ::htonl(INADDR_ANY);
5360 inserver.sin_port = sport;
5364 if (::bind(sock, (
struct sockaddr*) &inserver,
sizeof(inserver)) == SOCKET_ERROR) {
5365 ::SysError(
"TWinNTSystem::WinNTTcpService",
"bind");
5371 inserver.sin_port = ::htons(tryport);
5372 bret = ::bind(sock, (
struct sockaddr*) &inserver,
sizeof(inserver));
5374 }
while (bret == SOCKET_ERROR && WSAGetLastError() == WSAEADDRINUSE &&
5375 tryport < kSOCKET_MAXPORT);
5376 if (bret == SOCKET_ERROR) {
5377 ::SysError(
"TWinNTSystem::WinNTTcpService",
"bind (port scan)");
5383 if (::listen(sock, backlog) == SOCKET_ERROR) {
5384 ::SysError(
"TWinNTSystem::WinNTTcpService",
"listen");
5401 const short kSOCKET_MINPORT = 5000, kSOCKET_MAXPORT = 15000;
5402 short sport, tryport = kSOCKET_MINPORT;
5408 sport = htons(port);
5412 if ((sock =
socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) < 0) {
5413 ::SysError(
"TUnixSystem::UnixUdpService",
"socket");
5417 struct sockaddr_in inserver;
5418 memset(&inserver, 0,
sizeof(inserver));
5419 inserver.sin_family = AF_INET;
5420 inserver.sin_addr.s_addr = htonl(INADDR_ANY);
5421 inserver.sin_port = sport;
5425 if (bind(sock, (
struct sockaddr*) &inserver,
sizeof(inserver))) {
5426 ::SysError(
"TWinNTSystem::AnnounceUdpService",
"bind");
5432 inserver.sin_port = htons(tryport);
5433 bret = bind(sock, (
struct sockaddr*) &inserver,
sizeof(inserver));
5435 }
while (bret == SOCKET_ERROR && WSAGetLastError() == WSAEADDRINUSE &&
5436 tryport < kSOCKET_MAXPORT);
5438 ::SysError(
"TWinNTSystem::AnnounceUdpService",
"bind (port scan)");
5444 if (listen(sock, backlog)) {
5445 ::SysError(
"TWinNTSystem::AnnounceUdpService",
"listen");
5463 (::WSAGetLastError() == WSAEINTR)) {
5468 if (::WSAGetLastError() == WSAEWOULDBLOCK) {
5482#define SystemBasicInformation 0
5483#define SystemPerformanceInformation 2
5523#define Li2Double(x) ((double)((x).HighPart) * 4.294967296E9 + (double)((x).LowPart))
5531 LARGE_INTEGER ulFreq, ulTicks, ulValue, ulStartCounter;
5535 if (QueryPerformanceFrequency(&ulFreq)) {
5537 QueryPerformanceCounter(&ulTicks);
5540 ulValue.QuadPart = ulTicks.QuadPart + ulFreq.QuadPart/10;
5541 ulStartCounter.QuadPart =
__rdtsc();
5545 QueryPerformanceCounter(&ulTicks);
5546 }
while (ulTicks.QuadPart <= ulValue.QuadPart);
5548 return (DWORD)((
__rdtsc() - ulStartCounter.QuadPart)/100000);
5556#define SM_SERVERR2 89
5563 OSVERSIONINFOEX osvi;
5566 BOOL bOsVersionInfoEx;
5567 static char *strReturn =
nullptr;
5571 strReturn =
new char[2048];
5575 ZeroMemory(&si,
sizeof(SYSTEM_INFO));
5576 ZeroMemory(&osvi,
sizeof(OSVERSIONINFOEX));
5581 osvi.dwOSVersionInfoSize =
sizeof(OSVERSIONINFOEX);
5583 if( !(bOsVersionInfoEx = GetVersionEx ((OSVERSIONINFO *) &osvi)) )
5585 osvi.dwOSVersionInfoSize =
sizeof (OSVERSIONINFO);
5586 if (! GetVersionEx ( (OSVERSIONINFO *) &osvi) )
5591 pGNSI = (
PGNSI) GetProcAddress( GetModuleHandle(
"kernel32.dll"),
5592 "GetNativeSystemInfo");
5595 else GetSystemInfo(&si);
5597 switch (osvi.dwPlatformId)
5600 case VER_PLATFORM_WIN32_NT:
5603 if ( osvi.dwMajorVersion == 6 && osvi.dwMinorVersion == 0 )
5605 if( osvi.wProductType == VER_NT_WORKSTATION )
5606 strlcpy(strReturn,
"Microsoft Windows Vista ",2048);
5607 else strlcpy(strReturn,
"Windows Server \"Longhorn\" " ,2048);
5609 if ( osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 2 )
5612 strlcpy(strReturn,
"Microsoft Windows Server 2003 \"R2\" ",2048);
5613 else if( osvi.wProductType == VER_NT_WORKSTATION &&
5614 si.wProcessorArchitecture==PROCESSOR_ARCHITECTURE_AMD64)
5616 strlcpy(strReturn,
"Microsoft Windows XP Professional x64 Edition ",2048);
5618 else strlcpy(strReturn,
"Microsoft Windows Server 2003, ",2048);
5620 if ( osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 1 )
5621 strlcpy(strReturn,
"Microsoft Windows XP ",2048);
5623 if ( osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 0 )
5624 strlcpy(strReturn,
"Microsoft Windows 2000 ",2048);
5626 if ( osvi.dwMajorVersion <= 4 )
5627 strlcpy(strReturn,
"Microsoft Windows NT ",2048);
5630 if( bOsVersionInfoEx )
5633 if ( osvi.wProductType == VER_NT_WORKSTATION &&
5634 si.wProcessorArchitecture!=PROCESSOR_ARCHITECTURE_AMD64)
5636 if( osvi.dwMajorVersion == 4 )
5637 strlcat(strReturn,
"Workstation 4.0 ",2048 );
5638 else if( osvi.wSuiteMask & VER_SUITE_PERSONAL )
5639 strlcat(strReturn,
"Home Edition " ,2048);
5640 else strlcat(strReturn,
"Professional " ,2048);
5643 else if ( osvi.wProductType == VER_NT_SERVER ||
5644 osvi.wProductType == VER_NT_DOMAIN_CONTROLLER )
5646 if(osvi.dwMajorVersion==5 && osvi.dwMinorVersion==2)
5648 if ( si.wProcessorArchitecture==PROCESSOR_ARCHITECTURE_IA64 )
5650 if( osvi.wSuiteMask & VER_SUITE_DATACENTER )
5651 strlcat(strReturn,
"Datacenter Edition for Itanium-based Systems",2048 );
5652 else if( osvi.wSuiteMask & VER_SUITE_ENTERPRISE )
5653 strlcat(strReturn,
"Enterprise Edition for Itanium-based Systems" ,2048);
5655 else if ( si.wProcessorArchitecture==PROCESSOR_ARCHITECTURE_AMD64 )
5657 if( osvi.wSuiteMask & VER_SUITE_DATACENTER )
5658 strlcat(strReturn,
"Datacenter x64 Edition ",2048 );
5659 else if( osvi.wSuiteMask & VER_SUITE_ENTERPRISE )
5660 strlcat(strReturn,
"Enterprise x64 Edition ",2048 );
5661 else strlcat(strReturn,
"Standard x64 Edition ",2048 );
5665 if( osvi.wSuiteMask & VER_SUITE_DATACENTER )
5666 strlcat(strReturn,
"Datacenter Edition ",2048 );
5667 else if( osvi.wSuiteMask & VER_SUITE_ENTERPRISE )
5668 strlcat(strReturn,
"Enterprise Edition ",2048 );
5669 else if ( osvi.wSuiteMask == VER_SUITE_BLADE )
5670 strlcat(strReturn,
"Web Edition " ,2048);
5671 else strlcat(strReturn,
"Standard Edition ",2048 );
5674 else if(osvi.dwMajorVersion==5 && osvi.dwMinorVersion==0)
5676 if( osvi.wSuiteMask & VER_SUITE_DATACENTER )
5677 strlcat(strReturn,
"Datacenter Server ",2048 );
5678 else if( osvi.wSuiteMask & VER_SUITE_ENTERPRISE )
5679 strlcat(strReturn,
"Advanced Server ",2048 );
5680 else strlcat(strReturn,
"Server ",2048 );
5684 if( osvi.wSuiteMask & VER_SUITE_ENTERPRISE )
5685 strlcat(strReturn,
"Server 4.0, Enterprise Edition " ,2048);
5686 else strlcat(strReturn,
"Server 4.0 ",2048 );
5695 DWORD dwBufLen=
BUFSIZE*
sizeof(TCHAR);
5698 lRet = RegOpenKeyEx( HKEY_LOCAL_MACHINE,
5699 "SYSTEM\\CurrentControlSet\\Control\\ProductOptions",
5700 0, KEY_QUERY_VALUE, &hKey );
5701 if( lRet != ERROR_SUCCESS )
5704 lRet = RegQueryValueEx( hKey,
"ProductType", NULL, NULL,
5705 (LPBYTE) szProductType, &dwBufLen);
5706 RegCloseKey( hKey );
5708 if( (lRet != ERROR_SUCCESS) || (dwBufLen >
BUFSIZE*
sizeof(TCHAR)) )
5711 if ( lstrcmpi(
"WINNT", szProductType) == 0 )
5712 strlcat(strReturn,
"Workstation " ,2048);
5713 if ( lstrcmpi(
"LANMANNT", szProductType) == 0 )
5714 strlcat(strReturn,
"Server " ,2048);
5715 if ( lstrcmpi(
"SERVERNT", szProductType) == 0 )
5716 strlcat(strReturn,
"Advanced Server " ,2048);
5717 snprintf(temp,512,
"%d.%d ", osvi.dwMajorVersion, osvi.dwMinorVersion);
5718 strlcat(strReturn, temp,2048);
5723 if( osvi.dwMajorVersion == 4 &&
5724 lstrcmpi( osvi.szCSDVersion,
"Service Pack 6" ) == 0 )
5730 lRet = RegOpenKeyEx( HKEY_LOCAL_MACHINE,
5731 "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Hotfix\\Q246009",
5732 0, KEY_QUERY_VALUE, &hKey );
5733 if( lRet == ERROR_SUCCESS ) {
5734 snprintf(temp, 512,
"Service Pack 6a (Build %d)", osvi.dwBuildNumber & 0xFFFF );
5735 strlcat(strReturn, temp,2048 );
5739 snprintf(temp,512,
"%s (Build %d)", osvi.szCSDVersion, osvi.dwBuildNumber & 0xFFFF);
5740 strlcat(strReturn, temp,2048 );
5743 RegCloseKey( hKey );
5747 snprintf(temp, 512,
"%s (Build %d)", osvi.szCSDVersion, osvi.dwBuildNumber & 0xFFFF);
5748 strlcat(strReturn, temp,2048 );
5754 case VER_PLATFORM_WIN32_WINDOWS:
5756 if (osvi.dwMajorVersion == 4 && osvi.dwMinorVersion == 0)
5758 strlcpy(strReturn,
"Microsoft Windows 95 ",2048);
5759 if (osvi.szCSDVersion[1]==
'C' || osvi.szCSDVersion[1]==
'B')
5760 strlcat(strReturn,
"OSR2 " ,2048);
5763 if (osvi.dwMajorVersion == 4 && osvi.dwMinorVersion == 10)
5765 strlcpy(strReturn,
"Microsoft Windows 98 ",2048);
5766 if ( osvi.szCSDVersion[1]==
'A' || osvi.szCSDVersion[1]==
'B')
5767 strlcat(strReturn,
"SE ",2048 );
5770 if (osvi.dwMajorVersion == 4 && osvi.dwMinorVersion == 90)
5772 strlcpy(strReturn,
"Microsoft Windows Millennium Edition",2048);
5776 case VER_PLATFORM_WIN32s:
5777 strlcpy(strReturn,
"Microsoft Win32s",2048);
5788 unsigned nHighestFeatureEx;
5792 nHighestFeatureEx = (unsigned)nBuff[0];
5794 if (nHighestFeatureEx >= 0x80000006) {
5796 return (((
unsigned)nBuff[2])>>16);
5807 SYSTEM_INFO sysInfo;
5808 MEMORYSTATUSEX statex;
5809 OSVERSIONINFO OsVersionInfo;
5811 char szKeyValueString[80];
5812 DWORD szKeyValueDword;
5817 NtQuerySystemInformation = (
PROCNTQSI)GetProcAddress(
5818 GetModuleHandle(
"ntdll"),
"NtQuerySystemInformation");
5820 if (!NtQuerySystemInformation) {
5822 "Error on GetProcAddress(NtQuerySystemInformation)");
5827 &SysPerfInfo,
sizeof(SysPerfInfo),
5829 OsVersionInfo.dwOSVersionInfoSize =
sizeof(OSVERSIONINFO);
5830 GetVersionEx(&OsVersionInfo);
5831 GetSystemInfo(&sysInfo);
5832 statex.dwLength =
sizeof(statex);
5833 if (!GlobalMemoryStatusEx(&statex)) {
5834 ::Error(
"GetWinNTSysInfo",
"Error on GlobalMemoryStatusEx()");
5837 sysinfo->
fCpus = sysInfo.dwNumberOfProcessors;
5846 status = RegOpenKeyEx(HKEY_LOCAL_MACHINE,
"HARDWARE\\DESCRIPTION\\System",
5847 0, KEY_QUERY_VALUE, &hKey);
5848 if (status == ERROR_SUCCESS) {
5849 dwBufLen =
sizeof(szKeyValueString);
5850 RegQueryValueEx(hKey,
"Identifier", NULL, NULL,(LPBYTE)szKeyValueString,
5852 sysinfo->
fModel = szKeyValueString;
5855 status = RegOpenKeyEx(HKEY_LOCAL_MACHINE,
5856 "Hardware\\Description\\System\\CentralProcessor\\0",
5857 0, KEY_QUERY_VALUE, &hKey);
5858 if (status == ERROR_SUCCESS) {
5859 dwBufLen =
sizeof(szKeyValueString);
5860 status = RegQueryValueEx(hKey,
"ProcessorNameString", NULL, NULL,
5861 (LPBYTE)szKeyValueString, &dwBufLen);
5862 if (status == ERROR_SUCCESS)
5863 sysinfo->
fCpuType = szKeyValueString;
5864 dwBufLen =
sizeof(DWORD);
5865 status = RegQueryValueEx(hKey,
"~MHz",NULL,NULL,(LPBYTE)&szKeyValueDword,
5867 if ((status == ERROR_SUCCESS) && ((sysinfo->
fCpuSpeed <= 0) ||
5868 (sysinfo->
fCpuSpeed < (szKeyValueDword >> 1))))
5882 SYSTEM_INFO sysInfo;
5883 Float_t idle_ratio, kernel_ratio, user_ratio, total_ratio;
5884 FILETIME ft_sys_idle, ft_sys_kernel, ft_sys_user, ft_fun_time;
5885 SYSTEMTIME st_fun_time;
5887 ULARGE_INTEGER ul_sys_idle, ul_sys_kernel, ul_sys_user;
5888 static ULARGE_INTEGER ul_sys_idleold = {0, 0};
5889 static ULARGE_INTEGER ul_sys_kernelold = {0, 0};
5890 static ULARGE_INTEGER ul_sys_userold = {0, 0};
5891 ULARGE_INTEGER ul_sys_idle_diff, ul_sys_kernel_diff, ul_sys_user_diff;
5893 ULARGE_INTEGER ul_fun_time;
5894 ULARGE_INTEGER ul_fun_timeold = {0, 0};
5895 ULARGE_INTEGER ul_fun_time_diff;
5897 typedef BOOL (__stdcall *GetSystemTimesProc)( LPFILETIME lpIdleTime,
5898 LPFILETIME lpKernelTime, LPFILETIME lpUserTime );
5899 static GetSystemTimesProc pGetSystemTimes = 0;
5901 HMODULE hModImagehlp = LoadLibrary(
"Kernel32.dll" );
5902 if (!hModImagehlp) {
5903 ::Error(
"GetWinNTCpuInfo",
"Error on LoadLibrary(Kernel32.dll)");
5907 pGetSystemTimes = (GetSystemTimesProc) GetProcAddress( hModImagehlp,
5909 if (!pGetSystemTimes) {
5910 ::Error(
"GetWinNTCpuInfo",
"Error on GetProcAddress(GetSystemTimes)");
5913 GetSystemInfo(&sysInfo);
5916 pGetSystemTimes(&ft_sys_idle,&ft_sys_kernel,&ft_sys_user);
5917 GetSystemTime(&st_fun_time);
5918 SystemTimeToFileTime(&st_fun_time,&ft_fun_time);
5920 memcpy(&ul_sys_idle, &ft_sys_idle,
sizeof(FILETIME));
5921 memcpy(&ul_sys_kernel, &ft_sys_kernel,
sizeof(FILETIME));
5922 memcpy(&ul_sys_user, &ft_sys_user,
sizeof(FILETIME));
5923 memcpy(&ul_fun_time, &ft_fun_time,
sizeof(FILETIME));
5925 ul_sys_idle_diff.QuadPart = ul_sys_idle.QuadPart -
5926 ul_sys_idleold.QuadPart;
5927 ul_sys_kernel_diff.QuadPart = ul_sys_kernel.QuadPart -
5928 ul_sys_kernelold.QuadPart;
5929 ul_sys_user_diff.QuadPart = ul_sys_user.QuadPart -
5930 ul_sys_userold.QuadPart;
5932 ul_fun_time_diff.QuadPart = ul_fun_time.QuadPart -
5933 ul_fun_timeold.QuadPart;
5935 ul_sys_idleold.QuadPart = ul_sys_idle.QuadPart;
5936 ul_sys_kernelold.QuadPart = ul_sys_kernel.QuadPart;
5937 ul_sys_userold.QuadPart = ul_sys_user.QuadPart;
5939 if (ul_fun_timeold.QuadPart == 0) {
5941 ul_fun_timeold.QuadPart = ul_fun_time.QuadPart;
5944 ul_fun_timeold.QuadPart = ul_fun_time.QuadPart;
5952 idle_ratio /= (
Float_t)sysInfo.dwNumberOfProcessors;
5953 user_ratio /= (
Float_t)sysInfo.dwNumberOfProcessors;
5954 kernel_ratio /= (
Float_t)sysInfo.dwNumberOfProcessors;
5955 total_ratio = 100.0 - idle_ratio;
5960 cpuinfo->
fUser = user_ratio;
5961 cpuinfo->
fSys = kernel_ratio;
5962 cpuinfo->
fTotal = total_ratio;
5963 cpuinfo->
fIdle = idle_ratio;
5972 MEMORYSTATUSEX statex;
5973 statex.dwLength =
sizeof(statex);
5974 if (!GlobalMemoryStatusEx(&statex)) {
5975 ::Error(
"GetWinNTMemInfo",
"Error on GlobalMemoryStatusEx()");
5978 used = (
Long64_t)(statex.ullTotalPhys - statex.ullAvailPhys);
5986 swap_total = (
Long64_t)(statex.ullTotalPageFile - statex.ullTotalPhys);
5987 swap_avail = (
Long64_t)(statex.ullAvailPageFile - statex.ullAvailPhys);
5988 swap_used = swap_total - swap_avail;
6001 FILETIME starttime, exittime, kerneltime, usertime;
6002 timeval ru_stime, ru_utime;
6005 typedef BOOL (__stdcall *GetProcessMemoryInfoProc)( HANDLE Process,
6007 static GetProcessMemoryInfoProc pGetProcessMemoryInfo = 0;
6009 HMODULE hModImagehlp = LoadLibrary(
"Psapi.dll" );
6010 if (!hModImagehlp) {
6011 ::Error(
"GetWinNTProcInfo",
"Error on LoadLibrary(Psapi.dll)");
6015 pGetProcessMemoryInfo = (GetProcessMemoryInfoProc) GetProcAddress(
6016 hModImagehlp,
"GetProcessMemoryInfo" );
6017 if (!pGetProcessMemoryInfo) {
6019 "Error on GetProcAddress(GetProcessMemoryInfo)");
6023 if ( pGetProcessMemoryInfo( GetCurrentProcess(), &pmc,
sizeof(pmc)) ) {
6027 if ( GetProcessTimes(GetCurrentProcess(), &starttime, &exittime,
6028 &kerneltime, &usertime)) {
6031 memcpy(&li, &kerneltime,
sizeof(FILETIME));
6033 ru_stime.tv_sec = li.QuadPart / 1000000L;
6034 ru_stime.tv_usec = li.QuadPart % 1000000L;
6036 memcpy(&li, &usertime,
sizeof(FILETIME));
6038 ru_utime.tv_sec = li.QuadPart / 1000000L;
6039 ru_utime.tv_usec = li.QuadPart % 1000000L;
6042 ((
Float_t)(ru_utime.tv_usec) / 1000000.);
6044 ((
Float_t)(ru_stime.tv_usec) / 1000000.);
6055 if (!info)
return -1;
6067 if (!info)
return -1;
6078 if (!info)
return -1;
6089 if (!info)
return -1;
The file contains utilities which are foundational and could be used across the core component of ROO...
typedef void(GLAPIENTRYP _GLUfuncptr)(void)
R__EXTERN TApplication * gApplication
include TDocParser_001 C image html pict1_TDocParser_001 png width
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 Int_t gErrorIgnoreLevel
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
#define INVALID_HANDLE_VALUE
char * Form(const char *fmt,...)
void Printf(const char *fmt,...)
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 void SigHandler(ESignals sig)
Unix signal handler.
const char * kProtocolName
static const char * DynamicPath(const char *newpath=0, Bool_t reset=kFALSE)
Get shared library search path. Static utility function.
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[HOWMANY(kFDSETSIZE, kNFDBITS)]
TFdSet & operator=(const TFdSet &fd)
void Copy(TFdSet &fd) const
virtual Bool_t Notify()
Notify when event occurred on descriptor associated with this handler.
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.
This class represents an Internet Protocol (IP) address.
UInt_t GetAddress() const
TObject * Next()
Return next object in the list. Returns 0 when no more objects in list.
virtual void Add(TObject *obj)
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()
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.
virtual Bool_t Notify()
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 FreeDirectory(void *dirp)
Free a directory.
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 const char * GetDirEntry(void *dirp)
Get a directory entry. Returns 0 if no more entries.
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.
WIN32_FIND_DATA fFindFileData
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()
SIZE_T QuotaNonPagedPoolUsage
SIZE_T PeakWorkingSetSize
SIZE_T QuotaPeakNonPagedPoolUsage
SIZE_T QuotaPeakPagedPoolUsage
SIZE_T QuotaPagedPoolUsage