64#if defined (_MSC_VER) && (_MSC_VER >= 1400)
66#elif defined (_M_IX86)
67 static void __cpuid(
int* cpuid_data,
int info_type)
94 static void __cpuid(
int* cpuid_data,
int) {
95 cpuid_data[0] = 0x00000000;
96 cpuid_data[1] = 0x00000000;
97 cpuid_data[2] = 0x00000000;
98 cpuid_data[3] = 0x00000000;
113 TFdSet() { fds_bits =
new fd_set; fds_bits->fd_count = 0; }
114 virtual ~TFdSet() {
delete fds_bits; }
115 void Copy(TFdSet &fd)
const { memcpy((
void*)fd.fds_bits, fds_bits,
sizeof(fd_set)); }
116 TFdSet(
const TFdSet& fd) { fd.Copy(*
this); }
117 TFdSet&
operator=(
const TFdSet& fd) { fd.Copy(*
this);
return *
this; }
118 void Zero() { fds_bits->fd_count = 0; }
121 if (fds_bits->fd_count < FD_SETSIZE-1)
122 fds_bits->fd_array[fds_bits->fd_count++] = (
SOCKET)fd;
124 ::SysError(
"TFdSet::Set",
"fd_count will exeed FD_SETSIZE");
129 for (i=0; i<fds_bits->fd_count; i++) {
130 if (fds_bits->fd_array[i]==(
SOCKET)fd) {
131 while (i<fds_bits->fd_count-1) {
132 fds_bits->fd_array[i] = fds_bits->fd_array[i+1];
135 fds_bits->fd_count--;
141 Int_t *GetBits() {
return fds_bits && fds_bits->fd_count ? (
Int_t*)fds_bits : 0; }
142 UInt_t GetCount() {
return (
UInt_t)fds_bits->fd_count; }
143 Int_t GetFd(
Int_t i) {
return i<fds_bits->fd_count ? fds_bits->fd_array[i] : 0; }
151 static HANDLE gGlobalEvent;
152 static HANDLE gTimerThreadHandle;
153 typedef NET_API_STATUS (WINAPI *pfn1)(LPVOID);
154 typedef NET_API_STATUS (WINAPI *pfn2)(LPCWSTR, LPCWSTR, DWORD, LPBYTE*);
155 typedef NET_API_STATUS (WINAPI *pfn3)(LPCWSTR, LPCWSTR, DWORD, LPBYTE*,
156 DWORD, LPDWORD, LPDWORD, PDWORD);
157 typedef NET_API_STATUS (WINAPI *pfn4)(LPCWSTR, DWORD, LPBYTE*, DWORD, LPDWORD,
159 static pfn1 p2NetApiBufferFree;
160 static pfn2 p2NetUserGetInfo;
161 static pfn3 p2NetLocalGroupGetMembers;
162 static pfn4 p2NetLocalGroupEnum;
164 static struct signal_map {
170 SIGSEGV, 0,
"segmentation violation",
171 -1 , 0,
"bad argument to system call",
172 -1 , 0,
"write on a pipe with no one to read it",
173 SIGILL, 0,
"illegal instruction",
176 SIGINT, 0,
"interrupt",
177 -1 , 0,
"window size change",
178 -1 , 0,
"alarm clock",
179 -1 , 0,
"death of a child",
180 -1 , 0,
"urgent data arrived on an I/O channel",
181 SIGFPE, 0,
"floating point exception",
182 SIGTERM, 0,
"termination signal",
183 -1 , 0,
"user-defined signal 1",
184 -1 , 0,
"user-defined signal 2"
205 static int WinNTRecv(
int socket,
void *buffer,
int length,
int flag)
207 if (socket == -1)
return -1;
215 if (flag == MSG_PEEK) {
220 char *buf = (
char *)buffer;
222 for (
n = 0;
n < length;
n += nrecv) {
223 if ((nrecv = ::recv(sock, buf+
n, length-
n, flag)) <= 0) {
227 if (flag == MSG_OOB) {
228 if (::WSAGetLastError() == WSAEWOULDBLOCK) {
230 }
else if (::WSAGetLastError() == WSAEINVAL) {
234 if (::WSAGetLastError() == WSAEWOULDBLOCK) {
237 if (::WSAGetLastError() != WSAEINTR)
238 ::SysError(
"TWinNTSystem::WinNTRecv",
"recv");
239 if (::WSAGetLastError() == EPIPE ||
240 ::WSAGetLastError() == WSAECONNRESET)
259 static int WinNTSend(
int socket,
const void *buffer,
int length,
int flag)
261 if (socket < 0)
return -1;
271 const char *buf = (
const char *)buffer;
273 for (
n = 0;
n < length;
n += nsent) {
274 if ((nsent = ::send(sock, buf+
n, length-
n, flag)) <= 0) {
278 if (::WSAGetLastError() == WSAEWOULDBLOCK) {
281 if (::WSAGetLastError() != WSAEINTR)
282 ::SysError(
"TWinNTSystem::WinNTSend",
"send");
283 if (::WSAGetLastError() == EPIPE ||
284 ::WSAGetLastError() == WSAECONNRESET)
301 static int WinNTSelect(TFdSet *readready, TFdSet *writeready,
Long_t timeout)
304 fd_set* rbits = readready ? (fd_set*)readready->GetBits() : 0;
305 fd_set* wbits = writeready ? (fd_set*)writeready->GetBits() : 0;
309 tv.tv_sec = timeout / 1000;
310 tv.tv_usec = (timeout % 1000) * 1000;
312 retcode = ::select(0, rbits, wbits, 0, &tv);
314 retcode = ::select(0, rbits, wbits, 0, 0);
317 if (retcode == SOCKET_ERROR) {
318 int errcode = ::WSAGetLastError();
322 if (errcode == WSAENOTSOCK) {
324 int result = _fstat64( readready->GetFd(0), &buf );
332 ::WaitForSingleObject(gGlobalEvent, 1);
333 ::ResetEvent(gGlobalEvent);
338 if ( errcode == WSAEINTR) {
342 if (errcode == EBADF) {
357 if (reset || newpath) {
362 }
else if (dynpath ==
"") {
366 if (rdynpath ==
"") {
394 if (signal_map[i].code == sig) {
395 (*signal_map[i].handler)((
ESignals)i);
406 signal_map[sig].handler = handler;
407 if (signal_map[sig].code != -1)
414 static const char *WinNTSigname(
ESignals sig)
416 return signal_map[sig].signame;
422 static BOOL ConsoleSigHandler(DWORD sig)
430 Break(
"TInterruptHandler::Notify",
"keyboard interrupt");
436 case CTRL_BREAK_EVENT:
437 case CTRL_LOGOFF_EVENT:
438 case CTRL_SHUTDOWN_EVENT:
439 case CTRL_CLOSE_EVENT:
441 printf(
"\n *** Break *** keyboard interrupt - ROOT is terminated\n");
447 static CONTEXT *fgXcptContext = 0;
461 LONG WINAPI ExceptionFilter(LPEXCEPTION_POINTERS pXcp)
463 fgXcptContext = pXcp->ContextRecord;
465 return EXCEPTION_CONTINUE_SEARCH;
469#pragma intrinsic(_ReturnAddress)
470#pragma auto_inline(off)
471 DWORD_PTR GetProgramCounter()
476#pragma auto_inline(on)
487 static DWORD WINAPI GUIThreadMessageProcessingLoop(
void *p)
492 ::PeekMessage(&msg, NULL, WM_USER, WM_USER, PM_NOREMOVE);
497 if (gGlobalEvent) ::SetEvent(gGlobalEvent);
498 erret = ::GetMessage(&msg, NULL, NULL, NULL);
499 if (erret <= 0) endLoop =
kTRUE;
500 if (gGUIThreadMsgFunc)
501 endLoop = (*gGUIThreadMsgFunc)(&msg);
508 erret = ::GetLastError();
509 Error(
"MsgLoop",
"Error in GetMessage");
523 typedef BOOL (__stdcall *SYMINITIALIZEPROC)( HANDLE, LPSTR, BOOL );
524 typedef BOOL (__stdcall *SYMCLEANUPPROC)( HANDLE );
525 typedef BOOL (__stdcall *STACKWALK64PROC)
526 ( DWORD, HANDLE, HANDLE, LPSTACKFRAME64, LPVOID,
527 PREAD_PROCESS_MEMORY_ROUTINE,PFUNCTION_TABLE_ACCESS_ROUTINE,
528 PGET_MODULE_BASE_ROUTINE, PTRANSLATE_ADDRESS_ROUTINE );
529 typedef LPVOID (__stdcall *SYMFUNCTIONTABLEACCESS64PROC)( HANDLE, DWORD64 );
530 typedef DWORD (__stdcall *SYMGETMODULEBASE64PROC)( HANDLE, DWORD64 );
531 typedef BOOL (__stdcall *SYMGETMODULEINFO64PROC)(HANDLE, DWORD64, PIMAGEHLP_MODULE64);
532 typedef BOOL (__stdcall *SYMGETSYMFROMADDR64PROC)( HANDLE, DWORD64, PDWORD64, PIMAGEHLP_SYMBOL64);
533 typedef BOOL (__stdcall *SYMGETLINEFROMADDR64PROC)(HANDLE, DWORD64, PDWORD, PIMAGEHLP_LINE64);
534 typedef DWORD (__stdcall *UNDECORATESYMBOLNAMEPROC)(PCSTR, PSTR, DWORD, DWORD);
537 static SYMINITIALIZEPROC _SymInitialize = 0;
538 static SYMCLEANUPPROC _SymCleanup = 0;
539 static STACKWALK64PROC _StackWalk64 = 0;
540 static SYMFUNCTIONTABLEACCESS64PROC _SymFunctionTableAccess64 = 0;
541 static SYMGETMODULEBASE64PROC _SymGetModuleBase64 = 0;
542 static SYMGETMODULEINFO64PROC _SymGetModuleInfo64 = 0;
543 static SYMGETSYMFROMADDR64PROC _SymGetSymFromAddr64 = 0;
544 static SYMGETLINEFROMADDR64PROC _SymGetLineFromAddr64 = 0;
545 static UNDECORATESYMBOLNAMEPROC _UnDecorateSymbolName = 0;
547 BOOL InitImagehlpFunctions()
555 HMODULE hModImagehlp = LoadLibrary(
"IMAGEHLP.DLL" );
559 _SymInitialize = (SYMINITIALIZEPROC) GetProcAddress( hModImagehlp,
"SymInitialize" );
563 _SymCleanup = (SYMCLEANUPPROC) GetProcAddress( hModImagehlp,
"SymCleanup" );
567 _StackWalk64 = (STACKWALK64PROC) GetProcAddress( hModImagehlp,
"StackWalk64" );
571 _SymFunctionTableAccess64 = (SYMFUNCTIONTABLEACCESS64PROC) GetProcAddress(hModImagehlp,
"SymFunctionTableAccess64" );
572 if (!_SymFunctionTableAccess64)
575 _SymGetModuleBase64=(SYMGETMODULEBASE64PROC)GetProcAddress(hModImagehlp,
"SymGetModuleBase64");
576 if (!_SymGetModuleBase64)
579 _SymGetModuleInfo64=(SYMGETMODULEINFO64PROC)GetProcAddress(hModImagehlp,
"SymGetModuleInfo64");
580 if (!_SymGetModuleInfo64)
583 _SymGetSymFromAddr64=(SYMGETSYMFROMADDR64PROC)GetProcAddress(hModImagehlp,
"SymGetSymFromAddr64");
584 if (!_SymGetSymFromAddr64)
587 _SymGetLineFromAddr64=(SYMGETLINEFROMADDR64PROC)GetProcAddress(hModImagehlp,
"SymGetLineFromAddr64");
588 if (!_SymGetLineFromAddr64)
591 _UnDecorateSymbolName=(UNDECORATESYMBOLNAMEPROC)GetProcAddress(hModImagehlp,
"UnDecorateSymbolName");
592 if (!_UnDecorateSymbolName)
595 if (!_SymInitialize(GetCurrentProcess(), 0,
TRUE ))
611 std::string GetModuleName(DWORD64 address)
615 std::ostringstream out;
616 HANDLE process = ::GetCurrentProcess();
618 DWORD lineDisplacement = 0;
619 IMAGEHLP_LINE64
line;
622 if(_SymGetLineFromAddr64(process, address, &lineDisplacement, &
line)) {
623 out <<
line.FileName <<
"(" <<
line.LineNumber <<
"): ";
626 ::ZeroMemory(&module,
sizeof(module));
628 if(_SymGetModuleInfo64(process, address, &module)) {
629 out <<
module.ModuleName <<
"!";
631 out <<
"0x" << std::hex << address << std::dec <<
" ";
638 std::string GetFunctionName(DWORD64 address)
642 DWORD64 symbolDisplacement = 0;
643 HANDLE process = ::GetCurrentProcess();
645 const unsigned int SYMBOL_BUFFER_SIZE = 8192;
646 char symbolBuffer[SYMBOL_BUFFER_SIZE];
647 PIMAGEHLP_SYMBOL64 symbol =
reinterpret_cast<PIMAGEHLP_SYMBOL64
>(symbolBuffer);
648 ::ZeroMemory(symbol, SYMBOL_BUFFER_SIZE);
649 symbol->SizeOfStruct = SYMBOL_BUFFER_SIZE;
650 symbol->MaxNameLength = SYMBOL_BUFFER_SIZE -
sizeof(IMAGEHLP_SYMBOL64);
652 if(_SymGetSymFromAddr64(process, address, &symbolDisplacement, symbol)) {
654 const unsigned int NAME_SIZE = 8192;
655 char name[NAME_SIZE];
656 _UnDecorateSymbolName(
661 UNDNAME_NO_THISTYPE |
662 UNDNAME_NO_SPECIAL_SYMS |
663 UNDNAME_NO_MEMBER_TYPE |
664 UNDNAME_NO_MS_KEYWORDS |
665 UNDNAME_NO_ACCESS_SPECIFIERS
683 static BOOL IsShortcut(
const char *filename)
686 const char *extLnk =
".lnk";
687 if (filename != NULL) {
690 if (strfilename.EndsWith(extLnk))
699 static BOOL ResolveShortCut(LPCSTR pszShortcutFile,
char *pszPath,
int maxbuf)
703 char szGotPath[MAX_PATH];
710 typedef HRESULT (__stdcall *COINITIALIZEPROC)( LPVOID );
711 static COINITIALIZEPROC _CoInitialize = 0;
712 typedef void (__stdcall *COUNINITIALIZEPROC)(
void );
713 static COUNINITIALIZEPROC _CoUninitialize = 0;
714 typedef HRESULT (__stdcall *COCREATEINSTANCEPROC)( REFCLSID, LPUNKNOWN,
715 DWORD, REFIID, LPVOID );
716 static COCREATEINSTANCEPROC _CoCreateInstance = 0;
718 HMODULE hModImagehlp = LoadLibrary(
"ole32.dll" );
722 _CoInitialize = (COINITIALIZEPROC) GetProcAddress( hModImagehlp,
"CoInitialize" );
725 _CoUninitialize = (COUNINITIALIZEPROC) GetProcAddress( hModImagehlp,
"CoUninitialize");
726 if (!_CoUninitialize)
728 _CoCreateInstance = (COCREATEINSTANCEPROC) GetProcAddress( hModImagehlp,
"CoCreateInstance" );
729 if (!_CoCreateInstance)
734 hres = _CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER,
735 IID_IShellLink, (
void **) &psl);
736 if (SUCCEEDED(hres)) {
739 hres = psl->QueryInterface(IID_IPersistFile, (
void **) &ppf);
740 if (SUCCEEDED(hres)) {
742 MultiByteToWideChar(CP_ACP, 0, pszShortcutFile, -1, wsz, MAX_PATH);
744 hres = ppf->Load(wsz, STGM_READ);
745 if (SUCCEEDED(hres)) {
746 hres = psl->Resolve(HWND_DESKTOP, SLR_ANY_MATCH | SLR_NO_UI | SLR_UPDATE);
747 if (SUCCEEDED(hres)) {
748 strlcpy(szGotPath, pszShortcutFile,MAX_PATH);
749 hres = psl->GetPath(szGotPath, MAX_PATH, (WIN32_FIND_DATA *)&wfd,
750 SLGP_UNCPRIORITY | SLGP_RAWPATH);
751 strlcpy(pszPath,szGotPath, maxbuf);
752 if (maxbuf) pszPath[maxbuf-1] = 0;
761 return SUCCEEDED(hres);
767 if (strcmp(sys->TWinNTSystem::BaseName(buf),
"root.exe"))
770 if (!::RegOpenKeyEx(HKEY_CURRENT_USER,
"Software", 0, KEY_READ, ®CUS) == ERROR_SUCCESS)
773 if (!::RegOpenKeyEx(regCUS,
"Classes", 0, KEY_READ, ®CUSC) == ERROR_SUCCESS) {
774 ::RegCloseKey(regCUS);
779 bool regROOTwrite =
false;
783 if (::RegOpenKeyEx(regCUSC,
"ROOTDEV.ROOT", 0, KEY_READ, ®ROOT) != ERROR_SUCCESS) {
784 ::RegCloseKey(regCUSC);
785 if (::RegOpenKeyEx(regCUS,
"Classes", 0, KEY_READ | KEY_WRITE, ®CUSC) == ERROR_SUCCESS &&
786 ::RegCreateKeyEx(regCUSC,
"ROOTDEV.ROOT", 0, NULL, 0, KEY_READ | KEY_WRITE,
787 NULL, ®ROOT, NULL) == ERROR_SUCCESS) {
792 if (::RegOpenKeyEx(regROOT,
"DefaultIcon", 0, KEY_READ, ®ROOTIcon) == ERROR_SUCCESS) {
793 char bufIconLoc[1024];
795 DWORD dwSize =
sizeof(bufIconLoc);
797 if (::RegQueryValueEx(regROOTIcon, NULL, NULL, &dwType, (BYTE*)bufIconLoc, &dwSize) == ERROR_SUCCESS)
798 regROOTwrite = (iconloc != bufIconLoc);
801 ::RegCloseKey(regROOTIcon);
806 ::RegCloseKey(regCUSC);
807 ::RegCloseKey(regROOT);
808 if (::RegOpenKeyEx(regCUS,
"Classes", 0, KEY_READ | KEY_WRITE, ®CUSC) != ERROR_SUCCESS) {
810 regROOTwrite =
false;
812 if (::RegOpenKeyEx(regCUSC,
"ROOTDEV.ROOT", 0, KEY_WRITE, ®ROOT) != ERROR_SUCCESS) {
814 regROOTwrite =
false;
815 ::RegCloseKey(regCUSC);
822 TString fileopen =
"fileopen.C";
823 TString rootmacrodir =
"macros";
833 ::RegCloseKey(regROOT);
834 ::RegCloseKey(regCUSC);
835 ::RegCloseKey(regCUS);
839 static const char apptitle[] =
"ROOT data file";
840 ::RegSetValueEx(regROOT, NULL, 0, REG_SZ, (BYTE*)apptitle,
sizeof(apptitle));
841 DWORD editflags = 0x00010000;
842 ::RegSetValueEx(regROOT,
"EditFlags", 0, REG_DWORD, (BYTE*)&editflags,
sizeof(editflags));
845 if (::RegCreateKeyEx(regROOT,
"DefaultIcon", 0, NULL, 0, KEY_READ | KEY_WRITE,
846 NULL, ®ROOTIcon, NULL) == ERROR_SUCCESS) {
849 ::RegSetValueEx(regROOTIcon, NULL, 0, REG_SZ, (BYTE*)iconloc.Data(), iconloc.Length() + 1);
850 ::RegCloseKey(regROOTIcon);
855 if (::RegCreateKeyEx(regROOT,
"shell", 0, NULL, 0, KEY_READ | KEY_WRITE,
856 NULL, ®ROOTshell, NULL) == ERROR_SUCCESS) {
858 if (::RegCreateKeyEx(regROOTshell,
"open", 0, NULL, 0, KEY_READ | KEY_WRITE,
859 NULL, ®ShellOpen, NULL) == ERROR_SUCCESS) {
860 HKEY regShellOpenCmd;
861 if (::RegCreateKeyEx(regShellOpen,
"command", 0, NULL, 0, KEY_READ | KEY_WRITE,
862 NULL, ®ShellOpenCmd, NULL) == ERROR_SUCCESS) {
864 cmd +=
" -l \"%1\" \"";
867 ::RegSetValueEx(regShellOpenCmd, NULL, 0, REG_SZ, (BYTE*)cmd.Data(), cmd.Length() + 1);
868 ::RegCloseKey(regShellOpenCmd);
870 ::RegCloseKey(regShellOpen);
872 ::RegCloseKey(regROOTshell);
874 ::RegCloseKey(regROOT);
876 if (::RegCreateKeyEx(regCUSC,
".root", 0, NULL, 0, KEY_READ | KEY_WRITE,
877 NULL, ®ROOT, NULL) == ERROR_SUCCESS) {
878 static const char appname[] =
"ROOTDEV.ROOT";
879 ::RegSetValueEx(regROOT, NULL, 0, REG_SZ, (BYTE*)appname,
sizeof(appname));
881 ::RegCloseKey(regCUSC);
882 ::RegCloseKey(regCUS);
885 ::SHChangeNotify(SHCNE_ASSOCCHANGED, SHCNF_IDLIST, NULL, NULL);
893 static bool once =
true;
896 if (!once ||
gROOT->IsBatch())
return false;
897 TString cmdline(::GetCommandLine());
898 Int_t i = 0, from = 0;
899 while (cmdline.Tokenize(arg, from,
" ")) {
901 if (i == 0 && ((arg !=
"root") && (arg !=
"rootn") &&
902 (arg !=
"root.exe") && (arg !=
"rootn.exe")))
return false;
903 else if ((arg ==
"-l") || (arg ==
"-b"))
return false;
915 static void SetConsoleWindowName()
917 char pszNewWindowTitle[1024];
918 char pszOldWindowTitle[1024];
920 CONSOLE_SCREEN_BUFFER_INFO csbiInfo;
922 if (!::GetConsoleTitle(pszOldWindowTitle, 1024))
925 wsprintf(pszNewWindowTitle,
"%d/%d", ::GetTickCount(), ::GetCurrentProcessId());
927 if (!::SetConsoleTitle(pszNewWindowTitle))
937 ::SetConsoleTitle(
"ROOT session");
939 hStdout = GetStdHandle(STD_OUTPUT_HANDLE);
942 ::SetConsoleMode(hStdout, ENABLE_PROCESSED_OUTPUT |
943 ENABLE_WRAP_AT_EOL_OUTPUT);
944 if (!::GetConsoleScreenBufferInfo(hStdout, &csbiInfo))
987 if (initwinsock = ::WSAStartup(MAKEWORD(2, 0), &WSAData)) {
988 Error(
"TWinNTSystem()",
"Starting sockets failed");
999 char *buf =
new char[MAX_MODULE_NAME32 + 1];
1005 HMODULE hModCore = ::GetModuleHandle(
"libCore.dll");
1007 ::GetModuleFileName(hModCore, buf, MAX_MODULE_NAME32 + 1);
1008 char *pLibName = strstr(buf,
"libCore.dll");
1011 while (--pLibName >= buf && *pLibName !=
'\\' && *pLibName !=
'/');
1014 check_path +=
"\\etc";
1016 while (buf[0] && GetFileAttributes(check_path.
Data()) == INVALID_FILE_ATTRIBUTES) {
1017 while (--pLibName >= buf && *pLibName !=
'\\' && *pLibName !=
'/');
1020 check_path +=
"\\etc";
1035 UpdateRegistry(
this, buf);
1046 typedef UINT (WINAPI* LPTIMEENDPERIOD)( UINT uPeriod );
1047 HINSTANCE hInstWinMM = LoadLibrary(
"winmm.dll" );
1049 LPTIMEENDPERIOD pTimeEndPeriod = (LPTIMEENDPERIOD)GetProcAddress( hInstWinMM,
"timeEndPeriod" );
1050 if( NULL != pTimeEndPeriod )
1052 FreeLibrary(hInstWinMM);
1058 ::ResetEvent(gGlobalEvent);
1059 ::CloseHandle(gGlobalEvent);
1062 if (gTimerThreadHandle) {
1063 ::TerminateThread(gTimerThreadHandle, 0);
1064 ::CloseHandle(gTimerThreadHandle);
1097 ::SetUnhandledExceptionFilter(ExceptionFilter);
1105 typedef UINT (WINAPI* LPTIMEBEGINPERIOD)( UINT uPeriod );
1106 HINSTANCE hInstWinMM = LoadLibrary(
"winmm.dll" );
1108 LPTIMEBEGINPERIOD pTimeBeginPeriod = (LPTIMEBEGINPERIOD)GetProcAddress( hInstWinMM,
"timeBeginPeriod" );
1109 if( NULL != pTimeBeginPeriod )
1110 pTimeBeginPeriod(1);
1111 FreeLibrary(hInstWinMM);
1113 gTimerThreadHandle = ::CreateThread(NULL, NULL, (LPTHREAD_START_ROUTINE)
ThreadStub,
1116 gGlobalEvent = ::CreateEvent(NULL,
TRUE,
FALSE, NULL);
1119 char *buf =
new char[MAX_MODULE_NAME32 + 1];
1120 HMODULE hModCore = ::GetModuleHandle(
"libCore.dll");
1122 ::GetModuleFileName(hModCore, buf, MAX_MODULE_NAME32 + 1);
1123 char *pLibName = strstr(buf,
"libCore.dll");
1130 SetConsoleWindowName();
1154 const char *symbol=
name;
1157 while ( (*symbol ==
' ' || *symbol ==
'\t') && *symbol) symbol++;
1160 if (isalpha(symbol[idx]) && symbol[idx+1] ==
':') idx = 2;
1161 if ( (symbol[idx] ==
'/' || symbol[idx] ==
'\\') && symbol[idx+1] ==
'\0') {
1166 Error(
"BaseName",
"name = 0");
1170 char *bslash = (
char *)strrchr(&symbol[idx],
'\\');
1171 char *rslash = (
char *)strrchr(&symbol[idx],
'/');
1172 if (cp = (std::max)(rslash, bslash)) {
1177 return &symbol[idx];
1179 Error(
"BaseName",
"name = 0");
1190 char *dot =
nullptr;
1192 char *fullname =
nullptr;
1196 if (
name && namelen > 0) {
1198 fullname =
new char[namelen+5];
1199 strlcpy(fullname,
name,namelen+5);
1200 if ( !strrchr(fullname,
'.') )
1201 strlcat(fullname,
".exe",namelen+5);
1204 dot = strrchr(progname,
'.');
1205 idot = dot ? (
ULong_t)(dot - progname) : strlen(progname);
1207 char *which =
nullptr;
1210 which =
StrDup(fullname);
1221 dirname.
Form(
"%c:%s", driveletter,
d.Data());
1236 progname[idot] =
'\0';
1238 if (which)
delete [] which;
1242 if (::NeedSplash()) {
1255 if (err < 0 || err >= sys_nerr) {
1257 error_msg.
Form(
"errno out of range %d", err);
1260 return sys_errlist[err];
1273 DWORD il =
sizeof(hn);
1274 ::GetComputerName(hn, &il);
1290 if (freq < 37) freq = 440;
1291 if (duration < 0) duration = 100;
1300 gGUIThreadMsgFunc = func;
1323 int fd =
h->GetFd();
1326 if (
h->HasReadInterest()) {
1329 if (
h->HasWriteInterest()) {
1341 if (!
h)
return nullptr;
1361 set_console =
kTRUE;
1374 ::SetConsoleCtrlHandler((PHANDLER_ROUTINE)ConsoleSigHandler,
TRUE);
1385 if (!
h)
return nullptr;
1400 ::SetConsoleCtrlHandler((PHANDLER_ROUTINE)ConsoleSigHandler,
FALSE);
1444 HANDLE snapshot = ::CreateToolhelp32Snapshot(TH32CS_SNAPTHREAD,::GetCurrentProcessId());
1449 if (!InitImagehlpFunctions()) {
1450 std::cerr <<
"No stack trace: cannot find (functions in) dbghelp.dll!" << std::endl;
1455 SYSTEM_INFO sysInfo;
1456 ::GetSystemInfo(&sysInfo);
1457 DWORD machineType = IMAGE_FILE_MACHINE_I386;
1458 switch (sysInfo.wProcessorArchitecture) {
1459 case PROCESSOR_ARCHITECTURE_AMD64:
1460 machineType = IMAGE_FILE_MACHINE_AMD64;
1462 case PROCESSOR_ARCHITECTURE_IA64:
1463 machineType = IMAGE_FILE_MACHINE_IA64;
1467 DWORD currentThreadID = ::GetCurrentThreadId();
1468 DWORD currentProcessID = ::GetCurrentProcessId();
1472 THREADENTRY32 threadentry;
1473 threadentry.dwSize =
sizeof(THREADENTRY32);
1474 if (!::Thread32First(snapshot, &threadentry))
return;
1476 std::cerr << std::endl <<
"==========================================" << std::endl;
1477 std::cerr <<
"=============== STACKTRACE ===============" << std::endl;
1478 std::cerr <<
"==========================================" << std::endl << std::endl;
1481 if (threadentry.th32OwnerProcessID != currentProcessID)
1483 HANDLE thread = ::OpenThread(THREAD_GET_CONTEXT|THREAD_SUSPEND_RESUME|THREAD_QUERY_INFORMATION,
1484 FALSE, threadentry.th32ThreadID);
1486 memset(&context, 0,
sizeof(CONTEXT));
1488 if (threadentry.th32ThreadID != currentThreadID) {
1489 ::SuspendThread(thread);
1490 context.ContextFlags = CONTEXT_ALL;
1491 ::GetThreadContext(thread, &context);
1492 ::ResumeThread(thread);
1494 if (fgXcptContext) {
1495 context = *fgXcptContext;
1497 typedef void (WINAPI *RTLCCTXT)(PCONTEXT);
1498 RTLCCTXT p2RtlCCtxt = (RTLCCTXT) ::GetProcAddress(
1499 GetModuleHandle(
"kernel32.dll"),
"RtlCaptureContext");
1501 context.ContextFlags = CONTEXT_ALL;
1502 p2RtlCCtxt(&context);
1508 ::ZeroMemory(&frame,
sizeof(frame));
1510 frame.AddrPC.Mode = AddrModeFlat;
1511 frame.AddrFrame.Mode = AddrModeFlat;
1512 frame.AddrStack.Mode = AddrModeFlat;
1514 frame.AddrPC.Offset = context.Eip;
1515 frame.AddrFrame.Offset = context.Ebp;
1516 frame.AddrStack.Offset = context.Esp;
1517#elif defined(_M_X64)
1518 frame.AddrPC.Offset = context.Rip;
1519 frame.AddrFrame.Offset = context.Rsp;
1520 frame.AddrStack.Offset = context.Rsp;
1521#elif defined(_M_IA64)
1522 frame.AddrPC.Offset = context.StIIP;
1523 frame.AddrFrame.Offset = context.IntSp;
1524 frame.AddrStack.Offset = context.IntSp;
1525 frame.AddrBStore.Offset= context.RsBSP;
1527 std::cerr <<
"Stack traces not supported on your architecture yet." << std::endl;
1532 while (_StackWalk64(machineType, (HANDLE)::GetCurrentProcess(), thread, (LPSTACKFRAME64)&frame,
1533 (LPVOID)&context, (PREAD_PROCESS_MEMORY_ROUTINE)NULL, (PFUNCTION_TABLE_ACCESS_ROUTINE)_SymFunctionTableAccess64,
1534 (PGET_MODULE_BASE_ROUTINE)_SymGetModuleBase64, NULL)) {
1536 std::cerr << std::endl <<
"================ Thread " << iThread++ <<
" ================" << std::endl;
1537 if (!bFirst || threadentry.th32ThreadID != currentThreadID) {
1538 const std::string moduleName = GetModuleName(frame.AddrPC.Offset);
1539 const std::string functionName = GetFunctionName(frame.AddrPC.Offset);
1540 std::cerr <<
" " << moduleName << functionName << std::endl;
1544 ::CloseHandle(thread);
1545 }
while (::Thread32Next(snapshot, &threadentry));
1547 std::cerr << std::endl <<
"==========================================" << std::endl;
1548 std::cerr <<
"============= END STACKTRACE =============" << std::endl;
1549 std::cerr <<
"==========================================" << std::endl << std::endl;
1550 ::CloseHandle(snapshot);
1551 _SymCleanup(GetCurrentProcess());
1560 UInt_t oldmask = _statusfp( );
1562 if (oldmask & _EM_INVALID ) mask |=
kInvalid;
1563 if (oldmask & _EM_ZERODIVIDE) mask |=
kDivByZero;
1564 if (oldmask & _EM_OVERFLOW ) mask |=
kOverflow;
1565 if (oldmask & _EM_UNDERFLOW) mask |=
kUnderflow;
1566 if (oldmask & _EM_INEXACT ) mask |=
kInexact;
1580 if (mask &
kInvalid ) newm |= _EM_INVALID;
1581 if (mask &
kDivByZero) newm |= _EM_ZERODIVIDE;
1582 if (mask &
kOverflow ) newm |= _EM_OVERFLOW;
1583 if (mask &
kUnderflow) newm |= _EM_UNDERFLOW;
1584 if (mask &
kInexact ) newm |= _EM_INEXACT;
1586 UInt_t cm = ::_statusfp();
1588 ::_controlfp(cm , _MCW_EM);
1607 if (pendingOnly && gGlobalEvent) ::SetEvent(gGlobalEvent);
1609 Bool_t pollOnce = pendingOnly;
1613 if (
gROOT->GetApplication()) {
1629 ::WaitForSingleObject(gGlobalEvent, 1);
1630 ::ResetEvent(gGlobalEvent);
1656 if (pendingOnly && !pollOnce)
1695 if (!pendingOnly && gGlobalEvent) {
1696 ::WaitForSingleObject(gGlobalEvent, 1);
1697 ::ResetEvent(gGlobalEvent);
1711 for (i = 0; i <
fReadmask->GetCount(); i++) {
1716 rc = WinNTSelect(&t, 0, 0);
1717 if (rc < 0 && rc != -2) {
1718 ::SysError(
"DispatchOneEvent",
"select: read error on %d\n", fd);
1724 for (i = 0; i <
fWritemask->GetCount(); i++) {
1730 rc = WinNTSelect(0, &t, 0);
1731 if (rc < 0 && rc != -2) {
1732 ::SysError(
"DispatchOneEvent",
"select: write error on %d\n", fd);
1794 if (sync == sh->
IsSync()) {
1796 if ((
fSignals->IsSet(sig) && sigdone == -1) || sigdone == sig) {
1797 if (sigdone == -1) {
1807 if (sigdone != -1)
return kTRUE;
1828 if ((
fReadready->IsSet(fd) && fddone == -1) ||
1829 (fddone == fd && read)) {
1839 (fddone == fd && !read)) {
1849 if (fddone != -1)
return kTRUE;
1866 if (dirname.
Length() == 0) {
1883 if (res)
return res;
1903 const char *
proto = (strstr(
name,
"file:///")) ?
"file://" :
"file:";
1906 if (!
name)
return 0;
1910 if (!
name)
return 0;
1942 HANDLE searchFile = (HANDLE)dirp;
1976 return (psz[0] == TEXT(
'\\') && psz[1] == TEXT(
'\\'));
1996#pragma data_seg(".text", "CODE")
2011 if (!IsDBCSLeadByte(*pPath)) {
2016 if ((*pPath == TEXT(
'\\')) && (*(pPath + 1) == 0))
2022 int cBackslashes = 0;
2023 for (p = pPath + 2; *p; p = CharNext(p)) {
2024 if (*p == TEXT(
'\\') && (++cBackslashes > 1))
2044 const char *
proto = (strstr(fdir,
"file:///")) ?
"file://" :
"file:";
2047 char *dir =
new char[MAX_PATH];
2048 if (IsShortcut(sdir)) {
2049 if (!ResolveShortCut(sdir, dir, MAX_PATH))
2050 strlcpy(dir, sdir,MAX_PATH);
2053 strlcpy(dir, sdir,MAX_PATH);
2055 int nche = strlen(dir)+3;
2056 char *entry =
new char[nche];
2057 struct _stati64 finfo;
2060 strlcpy(entry, dir,nche);
2061 if ((entry[strlen(dir)-1] ==
'/') || (entry[strlen(dir)-1] ==
'\\' )) {
2062 entry[strlen(dir)-1] =
'\0';
2065 strlcat(entry,
"\\",nche);
2067 if (_stati64(entry, &finfo) < 0) {
2073 strlcpy(entry, dir,nche);
2074 if ((entry[strlen(dir)-1] ==
'/') || (entry[strlen(dir)-1] ==
'\\' )) {
2076 entry[strlen(dir)-1] =
'\0';
2078 if (_stati64(entry, &finfo) < 0) {
2085 if (finfo.st_mode & S_IFDIR) {
2086 strlcpy(entry, dir,nche);
2087 if (!(entry[strlen(dir)-1] ==
'/' || entry[strlen(dir)-1] ==
'\\' )) {
2088 strlcat(entry,
"\\",nche);
2090 if (entry[strlen(dir)-1] ==
' ')
2091 entry[strlen(dir)-1] =
'\0';
2092 strlcat(entry,
"*",nche);
2160 char *wdpath =
nullptr;
2161 char drive = driveletter ? toupper( driveletter ) -
'A' + 1 : 0;
2167 if (!(wdpath = ::_getdcwd( (
int)drive, wdpath,
kMAXPATHLEN))) {
2169 Warning(
"WorkingDirectory",
"getcwd() failed");
2193 return std::string(mydir);
2201 const char *
h =
nullptr;
2202 if (!(
h = ::getenv(
"home")))
h = ::getenv(
"HOME");
2209 h = ::getenv(
"HOMESHARE");
2210 if (!
h)
h = ::getenv(
"HOMEDRIVE");
2213 h = ::getenv(
"HOMEPATH");
2218 h = ::getenv(
"USERPROFILE");
2223 if (mydir[1] ==
':')
2224 mydir[0] = toupper(mydir[0]);
2240 if (!dir) dir =
"c:\\";
2256 char tmpName[MAX_PATH];
2260 FILE *fp = fopen(tmpName,
"w+");
2262 if (!fp)
::SysError(
"TempFileName",
"error opening %s", tmpName);
2280 if (!opt || !opt[0]) {
2285 UINT nOldErrorMode = ::SetErrorMode(SEM_FAILCRITICALERRORS);
2289 curdrive = _getdrive();
2290 if (strstr(opt,
"cur")) {
2292 sDrive.
Form(
"%c:", (curdrive +
'A' - 1));
2293 sType.
Form(
"Unknown Drive (%s)", sDrive.
Data());
2294 ::GetVolumeInformation(
Form(
"%s\\", sDrive.
Data()), NULL, 0, NULL, NULL,
2295 NULL, (LPSTR)szFs, 32);
2296 type = ::GetDriveType(sDrive.
Data());
2299 case DRIVE_NO_ROOT_DIR:
2301 case DRIVE_REMOVABLE:
2302 sType.
Form(
"Removable Disk (%s)", sDrive.
Data());
2305 sType.
Form(
"Local Disk (%s)", sDrive.
Data());
2308 sType.
Form(
"Network Drive (%s) (%s)", szFs, sDrive.
Data());
2311 sType.
Form(
"CD/DVD Drive (%s)", sDrive.
Data());
2314 sType.
Form(
"RAM Disk (%s)", sDrive.
Data());
2319 else if (strstr(opt,
"all")) {
2322 if (::GetLogicalDriveStrings(511, szTemp)) {
2323 TCHAR szDrive[3] = TEXT(
" :");
2329 sDrive.
Form(
"%s", szDrive);
2331 if ((sDrive ==
"A:") || (sDrive ==
"B:")) {
2335 sType.
Form(
"Unknown Drive (%s)", sDrive.
Data());
2336 ::GetVolumeInformation(
Form(
"%s\\", sDrive.
Data()), NULL, 0, NULL,
2337 NULL, NULL, (LPSTR)szFs, 32);
2338 type = ::GetDriveType(sDrive.
Data());
2341 case DRIVE_NO_ROOT_DIR:
2343 case DRIVE_REMOVABLE:
2344 sType.
Form(
"Removable Disk (%s)", sDrive.
Data());
2347 sType.
Form(
"Local Disk (%s)", sDrive.
Data());
2350 sType.
Form(
"Network Drive (%s) (%s)", szFs, sDrive.
Data());
2353 sType.
Form(
"CD/DVD Drive (%s)", sDrive.
Data());
2356 sType.
Form(
"RAM Disk (%s)", sDrive.
Data());
2366 ::SetErrorMode(nOldErrorMode);
2389 if (strchr(pathname,
'/') || strchr(pathname,
'\\')) {
2390 const char *rslash = strrchr(pathname,
'/');
2391 const char *bslash = strrchr(pathname,
'\\');
2392 const char *
r = std::max(rslash, bslash);
2393 const char *ptr = pathname;
2403 int len =
r - pathname;
2405 return TString(pathname, len);
2428 if (!pathname)
return 0;
2429 if (!pathname[0])
return 0;
2435 while(*lpchar ==
' ') lpchar++;
2437 if (isalpha((
int)*lpchar) && *(lpchar+1) ==
':') {
2441 if ( (*lpchar ==
'\\' || *lpchar ==
'/' ) &&
2442 (*(lpchar+1) ==
'\\' || *(lpchar+1) ==
'/') )
return 0;
2455 if (strchr(dir,
':')) idx = 2;
2456 return (dir[idx] ==
'/' || dir[idx] ==
'\\');
2489 const int kBufSize = 1024;
2490 TTHREAD_TLS_ARRAY(
char, kBufSize, temp);
2492 strlcpy(temp,
name, kBufSize);
2493 char *currentChar = temp;
2496 while (*currentChar !=
'\0') {
2497 if (*currentChar ==
'\\') *currentChar =
'/';
2515 UINT nOldErrorMode = ::SetErrorMode(SEM_FAILCRITICALERRORS);
2519 const char *
proto = (strstr(path,
"file:///")) ?
"file://" :
"file:";
2522 ::SetErrorMode(nOldErrorMode);
2527 ::SetErrorMode(nOldErrorMode);
2550 if (dir && dir[0]) {
2552 char last = dir[strlen(dir) - 1];
2553 if (last !=
'/' && last !=
'\\') {
2557 name.ReplaceAll(
"/",
"\\");
2574 if (!ret)
return -1;
2583 int ret = ::rename(
f, t);
2600 struct _stati64 sbuf;
2603 const char *
proto = (strstr(path,
"file:///")) ?
"file://" :
"file:";
2605 int l = strlen(newpath);
2607 if (newpath[--
l] !=
'\\' || newpath[--
l] !=
'/') {
2613 if (newpath && ::_stati64(newpath, &sbuf) >= 0) {
2615 buf.
fDev = sbuf.st_dev;
2616 buf.
fIno = sbuf.st_ino;
2617 buf.
fMode = sbuf.st_mode;
2618 buf.
fUid = sbuf.st_uid;
2619 buf.
fGid = sbuf.st_gid;
2620 buf.
fSize = sbuf.st_size;
2621 buf.
fMtime = sbuf.st_mtime;
2622 buf.
fIsLink = IsShortcut(newpath);
2624 char *lpath =
new char[MAX_PATH];
2625 if (IsShortcut(newpath)) {
2626 struct _stati64 sbuf2;
2627 if (ResolveShortCut(newpath, lpath, MAX_PATH)) {
2628 if (::_stati64(lpath, &sbuf2) >= 0) {
2629 buf.
fMode = sbuf2.st_mode;
2655 LPCTSTR lpRootPathName = path;
2658 LPTSTR lpVolumeNameBuffer = 0;
2659 DWORD nVolumeNameSize = 0;
2661 DWORD volumeSerialNumber;
2662 DWORD maximumComponentLength;
2665 DWORD fileSystemFlags;
2668 char fileSystemNameBuffer[512];
2669 DWORD nFileSystemNameSize =
sizeof(fileSystemNameBuffer);
2672 UINT nOldErrorMode = ::SetErrorMode(SEM_FAILCRITICALERRORS);
2673 if (!::GetVolumeInformation(lpRootPathName,
2674 lpVolumeNameBuffer, nVolumeNameSize,
2675 &volumeSerialNumber,
2676 &maximumComponentLength,
2678 fileSystemNameBuffer, nFileSystemNameSize)) {
2680 ::SetErrorMode(nOldErrorMode);
2684 const char *fsNames[] = {
"FAT",
"NTFS" };
2686 for (i = 0; i < 2; i++) {
2687 if (!strncmp(fileSystemNameBuffer, fsNames[i], nFileSystemNameSize))
2692 DWORD sectorsPerCluster;
2693 DWORD bytesPerSector;
2694 DWORD numberOfFreeClusters;
2695 DWORD totalNumberOfClusters;
2697 if (!::GetDiskFreeSpace(lpRootPathName,
2700 &numberOfFreeClusters,
2701 &totalNumberOfClusters)) {
2703 ::SetErrorMode(nOldErrorMode);
2707 ::SetErrorMode(nOldErrorMode);
2709 *bsize = sectorsPerCluster * bytesPerSector;
2710 *blocks = totalNumberOfClusters;
2711 *bfree = numberOfFreeClusters;
2721 struct _stati64 finfo;
2726 char linkname[1024];
2727 LPTSTR lpszFilePart;
2728 TCHAR szPath[MAX_PATH];
2731 typedef BOOL (__stdcall *CREATEHARDLINKPROC)( LPCTSTR, LPCTSTR, LPSECURITY_ATTRIBUTES );
2732 static CREATEHARDLINKPROC _CreateHardLink = 0;
2734 HMODULE hModImagehlp = LoadLibrary(
"Kernel32.dll" );
2739 _CreateHardLink = (CREATEHARDLINKPROC) GetProcAddress( hModImagehlp,
"CreateHardLinkW" );
2741 _CreateHardLink = (CREATEHARDLINKPROC) GetProcAddress( hModImagehlp,
"CreateHardLinkA" );
2743 if (!_CreateHardLink)
2746 dwRet = GetFullPathName(from,
sizeof(szPath) /
sizeof(TCHAR),
2747 szPath, &lpszFilePart);
2749 if (_stati64(szPath, &finfo) < 0)
2752 if (finfo.st_mode & S_IFDIR)
2756 _splitpath(linkname,winDrive,winDir,winName,winExt);
2757 if ((!winDrive[0] ) &&
2759 _splitpath(szPath,winDrive,winDir,winName,winExt);
2760 snprintf(linkname,1024,
"%s\\%s\\%s", winDrive, winDir, to);
2762 else if (!winDrive[0]) {
2763 _splitpath(szPath,winDrive,winDir,winName,winExt);
2764 snprintf(linkname,1024,
"%s\\%s", winDrive, to);
2767 if (!_CreateHardLink(linkname, szPath, NULL))
2780 IShellLink* pShellLink;
2781 IPersistFile* pPersistFile;
2782 WCHAR wszLinkfile[MAX_PATH];
2783 int iWideCharsWritten;
2785 LPTSTR lpszFilePart;
2786 TCHAR szPath[MAX_PATH];
2788 hRes = E_INVALIDARG;
2789 if ((from == NULL) || (!from[0]) || (to == NULL) ||
2795 typedef HRESULT (__stdcall *COINITIALIZEPROC)( LPVOID );
2796 static COINITIALIZEPROC _CoInitialize = 0;
2797 typedef void (__stdcall *COUNINITIALIZEPROC)(
void );
2798 static COUNINITIALIZEPROC _CoUninitialize = 0;
2799 typedef HRESULT (__stdcall *COCREATEINSTANCEPROC)( REFCLSID, LPUNKNOWN, DWORD, REFIID, LPVOID );
2800 static COCREATEINSTANCEPROC _CoCreateInstance = 0;
2802 HMODULE hModImagehlp = LoadLibrary(
"ole32.dll" );
2806 _CoInitialize = (COINITIALIZEPROC) GetProcAddress( hModImagehlp,
"CoInitialize" );
2809 _CoUninitialize = (COUNINITIALIZEPROC) GetProcAddress( hModImagehlp,
"CoUninitialize" );
2810 if (!_CoUninitialize)
2812 _CoCreateInstance = (COCREATEINSTANCEPROC) GetProcAddress( hModImagehlp,
"CoCreateInstance" );
2813 if (!_CoCreateInstance)
2820 _CoInitialize(NULL);
2823 dwRet = GetFullPathName(from,
sizeof(szPath) /
sizeof(TCHAR),
2824 szPath, &lpszFilePart);
2825 hRes = _CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER,
2826 IID_IShellLink, (LPVOID *)&pShellLink);
2827 if (SUCCEEDED(hRes)) {
2829 hRes = pShellLink->SetPath(szPath);
2831 hRes = pShellLink->QueryInterface(IID_IPersistFile, (
void **)&pPersistFile);
2832 if (SUCCEEDED(hRes)){
2833 iWideCharsWritten = MultiByteToWideChar(CP_ACP, 0, linkname.
Data(), -1,
2834 wszLinkfile, MAX_PATH);
2835 hRes = pPersistFile->Save(wszLinkfile,
TRUE);
2836 pPersistFile->Release();
2838 pShellLink->Release();
2856 struct _stati64 finfo;
2858 if (_stati64(
name, &finfo) < 0) {
2862 if (finfo.st_mode & S_IFDIR) {
2863 return ::_rmdir(
name);
2865 return ::_unlink(
name);
2874 if (::ioctlsocket(fd, FIONBIO, (u_long *)1) == SOCKET_ERROR) {
2893 const char *patbuf = (
const char *)patbuf0;
2895 char *cmd =
nullptr;
2901 const char driveletter =
DriveName(patbuf);
2910 if (!
proto.EqualTo(
"file"))
2918 while (*patbuf ==
' ') {
2923 while (*patbuf ==
':') {
2928 while (*patbuf ==
';') {
2934 for (
q = (
char*)patbuf; *
q;
q++) {
2938 if ( (((
q-2)>patbuf) && ( (*(
q-2)!=
';') || !isalpha(*(
q-1)) )) &&
2945 for (p = patbuf; *p; p++) {
2962 char replacement[4];
2965 for (
int k = 0; k<3; k++) replacement[k] = 0x1;
2967 replacement[3] = 0x0;
2971 while ( (pos = patbuf0.
Index(TildaNum,pos)) !=
kNPOS ) {
2972 patbuf0.
Replace(pos, 1, replacement);
2978 Int_t lbuf = ::ExpandEnvironmentStrings(
2984 cmd =
new char[lbuf+1];
2985 ::ExpandEnvironmentStrings(
3004 char newpath[MAX_PATH];
3005 if (IsShortcut(path)) {
3006 if (!ResolveShortCut(path, newpath, MAX_PATH))
3007 strlcpy(newpath, path, MAX_PATH);
3010 strlcpy(newpath, path, MAX_PATH);
3026 return ::_chmod(
file, mode);
3034 return ::umask(mask);
3044 Error(
"Utime",
"need write permission for %s to change utime",
file);
3047 if (!actime) actime = modtime;
3050 t.actime = (time_t)actime;
3051 t.modtime = (time_t)modtime;
3052 return ::utime(
file, &t);
3071 return infile.
Data();
3079 Int_t lastDelim = -1;
3080 for(
int i=0; i < exsearch.
Length(); ++i) {
3081 switch( exsearch[i] ) {
3084 if (i-lastDelim!=2) exsearch[i] =
';';
3087 case ';': lastDelim = i;
break;
3094 char *lpFilePart =
nullptr;
3096 ::access(
name, mode) == 0 && stat(
name, &finfo) == 0 &&
3097 finfo.st_mode & S_IFREG) {
3102 return infile.
Data();
3116 if ((
gEnv->
GetValue(
"WinNT.UseNetAPI", 0)) && (::GetVersion() < 0x80000000)) {
3119 HINSTANCE netapi = ::LoadLibrary(
"netapi32.DLL");
3120 if (!netapi)
return kFALSE;
3122 p2NetApiBufferFree = (pfn1)::GetProcAddress(netapi,
"NetApiBufferFree");
3123 p2NetUserGetInfo = (pfn2)::GetProcAddress(netapi,
"NetUserGetInfo");
3124 p2NetLocalGroupGetMembers = (pfn3)::GetProcAddress(netapi,
"NetLocalGroupGetMembers");
3125 p2NetLocalGroupEnum = (pfn4)::GetProcAddress(netapi,
"NetLocalGroupEnum");
3127 if (!p2NetApiBufferFree || !p2NetUserGetInfo ||
3128 !p2NetLocalGroupGetMembers || !p2NetLocalGroupEnum)
return kFALSE;
3139 ::FreeLibrary(netapi);
3149 NET_API_STATUS NetStatus = NERR_Success;
3151 DWORD Index = 0, ResumeHandle = 0, Total = 0;
3152 LOCALGROUP_MEMBERS_INFO_1 *MemberInfo;
3153 WCHAR wszGroupName[256];
3155 DWORD dwLastError = 0;
3157 iRetOp = MultiByteToWideChar (
3159 (DWORD)MB_PRECOMPOSED,
3160 (LPCSTR)lpszGroupName,
3162 (LPWSTR)wszGroupName,
3163 (
int)
sizeof(wszGroupName) );
3166 dwLastError = GetLastError();
3168 p2NetApiBufferFree(Data);
3174 NetStatus = p2NetLocalGroupGetMembers (NULL, wszGroupName, 1,
3175 &Data, 8192, &Index, &Total, &ResumeHandle );
3177 if (NetStatus != NERR_Success || Data == NULL) {
3178 dwLastError = GetLastError();
3180 if (dwLastError == ERROR_ENVVAR_NOT_FOUND) {
3186 NetStatus = p2NetLocalGroupGetMembers ( NULL, wszGroupName, 0,
3187 &Data, 8192, &Index, &Total, &ResumeHandle );
3191 p2NetApiBufferFree(Data);
3196 MemberInfo = (LOCALGROUP_MEMBERS_INFO_1 *)Data;
3199 p2NetApiBufferFree(Data);
3208 NET_API_STATUS NetStatus = NERR_Success;
3210 DWORD Index = 0, ResumeHandle = 0, Total = 0, i;
3211 LOCALGROUP_INFO_0 *GroupInfo;
3212 char szAnsiName[256];
3213 DWORD dwLastError = 0;
3216 NetStatus = p2NetLocalGroupEnum(NULL, 0, &Data, 8192, &Index,
3217 &Total, &ResumeHandle );
3219 if (NetStatus != NERR_Success || Data == NULL) {
3220 dwLastError = GetLastError();
3222 p2NetApiBufferFree(Data);
3227 GroupInfo = (LOCALGROUP_INFO_0 *)Data;
3228 for (i=0; i < Total; i++) {
3230 iRetOp = WideCharToMultiByte (
3233 (LPCWSTR)(GroupInfo->lgrpi0_name),
3236 (
int)(
sizeof(szAnsiName)),
3248 p2NetApiBufferFree(Data);
3260 int &groupIdx,
int &memberIdx)
3262 BOOL bRetOp =
FALSE;
3264 DWORD dwSidSize, dwDomainNameSize;
3267 SID_NAME_USE sidType;
3268 PUCHAR puchar_SubAuthCount = NULL;
3269 SID_IDENTIFIER_AUTHORITY sid_identifier_authority;
3270 PSID_IDENTIFIER_AUTHORITY psid_identifier_authority = NULL;
3271 unsigned char j = 0;
3272 DWORD dwLastError = 0;
3274 pSid = (PSID)bySidBuffer;
3275 dwSidSize =
sizeof(bySidBuffer);
3276 dwDomainNameSize =
sizeof(szDomainName);
3278 bRetOp = LookupAccountName (
3280 (LPCTSTR)lpszAccountName,
3282 (LPDWORD)&dwSidSize,
3283 (LPTSTR)szDomainName,
3284 (LPDWORD)&dwDomainNameSize,
3285 (PSID_NAME_USE)&sidType );
3287 if (bRetOp ==
FALSE) {
3288 dwLastError = GetLastError();
3292 bRetOp = IsValidSid((PSID)pSid);
3294 if (bRetOp ==
FALSE) {
3295 dwLastError = GetLastError();
3300 psid_identifier_authority = GetSidIdentifierAuthority ((PSID)pSid);
3303 memcpy (&sid_identifier_authority, psid_identifier_authority,
3304 sizeof(SID_IDENTIFIER_AUTHORITY));
3307 puchar_SubAuthCount = (PUCHAR)GetSidSubAuthorityCount((PSID)pSid);
3309 j = (
unsigned char)(*puchar_SubAuthCount);
3311 DWORD dwSubAuth = 0;
3312 PDWORD pdwSubAuth = NULL;
3314 pdwSubAuth = (PDWORD)GetSidSubAuthority (
3317 dwSubAuth = *pdwSubAuth;
3336 NET_API_STATUS NetStatus = NERR_Success;
3338 DWORD Index = 0, ResumeHandle = 0, Total = 0, i;
3339 LOCALGROUP_MEMBERS_INFO_1 *MemberInfo;
3340 char szAnsiMemberName[256];
3341 char szFullMemberName[256];
3342 char szMemberHomeDir[256];
3343 WCHAR wszGroupName[256];
3346 DWORD length =
sizeof (act_name);
3347 DWORD dwLastError = 0;
3348 LPUSER_INFO_11 pUI11Buf = NULL;
3349 NET_API_STATUS nStatus;
3351 iRetOp = MultiByteToWideChar (
3353 (DWORD)MB_PRECOMPOSED,
3354 (LPCSTR)lpszGroupName,
3356 (LPWSTR)wszGroupName,
3357 (
int)
sizeof(wszGroupName) );
3360 dwLastError = GetLastError();
3362 p2NetApiBufferFree(Data);
3366 GetUserName (act_name, &length);
3370 NetStatus = p2NetLocalGroupGetMembers (NULL, wszGroupName, 1,
3371 &Data, 8192, &Index, &Total, &ResumeHandle );
3373 if (NetStatus != NERR_Success || Data == NULL) {
3374 dwLastError = GetLastError();
3376 if (dwLastError == ERROR_ENVVAR_NOT_FOUND) {
3382 NetStatus = p2NetLocalGroupGetMembers ( NULL, wszGroupName, 0,
3383 &Data, 8192, &Index, &Total, &ResumeHandle );
3387 p2NetApiBufferFree(Data);
3391 MemberInfo = (LOCALGROUP_MEMBERS_INFO_1 *)Data;
3392 for (i=0; i < Total; i++) {
3393 iRetOp = WideCharToMultiByte (
3396 (LPCWSTR)(MemberInfo->lgrmi1_name),
3398 (LPSTR)szAnsiMemberName,
3399 (
int)(
sizeof(szAnsiMemberName)),
3404 dwLastError = GetLastError();
3415 TCHAR szUserName[255]=TEXT(
"");
3416 MultiByteToWideChar(CP_ACP, 0, szAnsiMemberName, -1, (LPWSTR)szUserName, 255);
3420 nStatus = p2NetUserGetInfo(NULL, (LPCWSTR)szUserName, 11, (LPBYTE *)&pUI11Buf);
3424 if (nStatus == NERR_Success) {
3425 if (pUI11Buf != NULL) {
3426 wsprintf(szFullMemberName,
"%S",pUI11Buf->usri11_full_name);
3428 wsprintf(szMemberHomeDir,
"%S",pUI11Buf->usri11_home_dir);
3439 if (pUI11Buf != NULL) {
3440 p2NetApiBufferFree(pUI11Buf);
3445 if (getenv(
"SHELL") == NULL)
3446 putenv ((GetVersion () & 0x80000000) ?
"SHELL=command" :
"SHELL=cmd");
3459 p2NetApiBufferFree(Data);
3469 NET_API_STATUS NetStatus = NERR_Success;
3471 DWORD Index = 0, ResumeHandle = 0, Total = 0, i;
3472 LOCALGROUP_INFO_0 *GroupInfo;
3473 char szAnsiName[256];
3474 DWORD dwLastError = 0;
3475 int iRetOp = 0, iGroupIdx = 0, iMemberIdx = 0;
3477 NetStatus = p2NetLocalGroupEnum(NULL, 0, &Data, 8192, &Index,
3478 &Total, &ResumeHandle );
3480 if (NetStatus != NERR_Success || Data == NULL) {
3481 dwLastError = GetLastError();
3483 p2NetApiBufferFree(Data);
3487 GroupInfo = (LOCALGROUP_INFO_0 *)Data;
3488 for (i=0; i < Total; i++) {
3490 iRetOp = WideCharToMultiByte (
3493 (LPCWSTR)(GroupInfo->lgrpi0_name),
3496 (
int)(
sizeof(szAnsiName)),
3514 p2NetApiBufferFree(Data);
3528 if ((!
gEnv->
GetValue(
"WinNT.UseNetAPI", 0)) || (::GetVersion() >= 0x80000000)) {
3531 DWORD length =
sizeof (
name);
3532 if (::GetUserName (
name, &length)) {
3533 if (stricmp (
"administrator",
name) == 0)
3543 if (!user || !user[0])
3548 if (!stricmp (user,
fPasswords[i].pw_name)) {
3569 if ((!
gEnv->
GetValue(
"WinNT.UseNetAPI", 0)) || (::GetVersion() >= 0x80000000)) {
3572 DWORD length =
sizeof (
name);
3573 if (::GetUserName (
name, &length)) {
3574 if (stricmp (
"administrator",
name) == 0)
3596 if ((!
gEnv->
GetValue(
"WinNT.UseNetAPI", 0)) || (::GetVersion() >= 0x80000000)) {
3599 DWORD length =
sizeof (
name);
3600 if (::GetUserName (
name, &length)) {
3601 if (stricmp (
"administrator",
name) == 0)
3614 struct group *grp =
nullptr;
3637 if ((!
gEnv->
GetValue(
"WinNT.UseNetAPI", 0)) || (::GetVersion() >= 0x80000000)) {
3640 DWORD length =
sizeof (
name);
3641 if (::GetUserName (
name, &length)) {
3642 if (stricmp (
"administrator",
name) == 0)
3665 if ((!
gEnv->
GetValue(
"WinNT.UseNetAPI", 0)) || (::GetVersion() >= 0x80000000)) {
3667 DWORD length =
sizeof (
name);
3669 if (::GetUserName (
name, &length)) {
3671 if (stricmp (
"administrator",
name) == 0) {
3673 ug->
fGroup =
"administrators";
3682 ug->
fUser =
"unknown";
3695 for (
int i = 0; i <
fNbUsers; i++) {
3739 if ((!
gEnv->
GetValue(
"WinNT.UseNetAPI", 0)) || (::GetVersion() >= 0x80000000)) {
3741 DWORD length =
sizeof (
name);
3743 if (::GetUserName (
name, &length)) {
3744 if (stricmp (
"administrator",
name) == 0) {
3745 gr->fGroup =
"administrators";
3749 gr->fGroup =
"users";
3754 gr->fGroup =
"unknown";
3760 struct group *grp =
nullptr;
3762 if (gid ==
fGroups[i].gr_gid) {
3804 const char *env = ::getenv(
name);
3806 if (::_stricmp(
name,
"home") == 0 ) {
3808 }
else if (::_stricmp(
name,
"rootsys") == 0 ) {
3822 return ::system(shellcmd);
3830 return ::_popen(command, mode);
3838 return ::_pclose(pipe);
3866 gROOT->CloseFiles();
3867 if (
gROOT->GetListOfBrowsers()) {
3870 if (
gROOT->IsBatch())
3871 gROOT->GetListOfBrowsers()->Delete();
3877 if (((TBrowser*)0x%lx)->GetBrowserImp() &&\
3878 ((TBrowser*)0x%lx)->GetBrowserImp()->GetMainFrame()) \
3879 ((TBrowser*)0x%lx)->GetBrowserImp()->GetMainFrame()->CloseWindow();\
3921 static int fd1=0, fd2=0;
3922 static fpos_t pos1=0, pos2=0;
3932 const char *
m = (mode[0] ==
'a' || mode[0] ==
'w') ? mode :
"a";
3945 fgetpos(stdout, &pos1);
3946 fd1 = _dup(fileno(stdout));
3948 if ((fout = freopen(
file,
m, stdout)) == 0) {
3949 SysError(
"RedirectOutput",
"could not freopen stdout");
3951 _dup2(fd1, fileno(stdout));
3955 fsetpos(stdout, &pos1);
3960 fgetpos(stderr, &pos2);
3961 fd2 = _dup(fileno(stderr));
3962 if ((ferr = freopen(
file,
m, stderr)) == 0) {
3963 SysError(
"RedirectOutput",
"could not freopen stderr");
3965 _dup2(fd1, fileno(stdout));
3969 fsetpos(stdout, &pos1);
3971 _dup2(fd2, fileno(stderr));
3975 fsetpos(stderr, &pos2);
3980 fseek(fout, 0, SEEK_END);
3981 fseek(ferr, 0, SEEK_END);
3988 if (_dup2(fd1, fileno(stdout))) {
3989 SysError(
"RedirectOutput",
"could not restore stdout");
3995 fsetpos(stdout, &pos1);
4002 if (_dup2(fd2, fileno(stderr))) {
4003 SysError(
"RedirectOutput",
"could not restore stderr");
4009 fsetpos(stderr, &pos2);
4064 if (len > 4 && (!stricmp(sLib.
Data()+len-4,
".dll"))) {
4077 Error(
"DynamicPathName",
4078 "%s does not exist in %s,\nor has wrong file extension (.dll)",
4095#pragma warning(push)
4096#pragma warning(disable:4200)
4113 if (!linkedLibs.
IsNull())
4126 HANDLE hFile, hMapping;
4129 if((hFile = CreateFile(exe,GENERIC_READ,FILE_SHARE_READ,0,OPEN_EXISTING,FILE_FLAG_SEQUENTIAL_SCAN,0))==
INVALID_HANDLE_VALUE) {
4133 if(!(hMapping = CreateFileMapping(hFile,0,PAGE_READONLY|SEC_COMMIT,0,0,0))) {
4138 if(!(basepointer = MapViewOfFile(hMapping,FILE_MAP_READ,0,0,0))) {
4139 CloseHandle(hMapping);
4146 IMAGE_DOS_HEADER *dos_head = (IMAGE_DOS_HEADER *)basepointer;
4149 IMAGE_FILE_HEADER _head;
4150 IMAGE_OPTIONAL_HEADER opt_head;
4151 IMAGE_SECTION_HEADER section_header[];
4153 struct header *pheader;
4154 const IMAGE_SECTION_HEADER * section_header;
4156 if(dos_head->e_magic!=
'ZM') {
4161 pheader = (
struct header *)((
char*)dos_head + dos_head->e_lfanew);
4163 if(IsBadReadPtr(pheader,
sizeof(
struct header))) {
4167 if(pheader->signature!=IMAGE_NT_SIGNATURE) {
4168 switch((
unsigned short)pheader->signature) {
4169 case IMAGE_DOS_SIGNATURE:
4172 case IMAGE_OS2_SIGNATURE:
4175 case IMAGE_OS2_SIGNATURE_LE:
4183#define isin(address,start,length) ((address)>=(start) && (address)<(start)+(length))
4186 for(sect=0,section_header=pheader->section_header;
4187 sect<pheader->_head.NumberOfSections;sect++,section_header++) {
4189 const void *
const section_data =
4190 (
char*)basepointer + section_header->PointerToRawData;
4191 for(directory=0;directory<IMAGE_NUMBEROF_DIRECTORY_ENTRIES;directory++) {
4192 if(
isin(pheader->opt_head.DataDirectory[directory].VirtualAddress,
4193 section_header->VirtualAddress,
4194 section_header->SizeOfRawData)) {
4195 const IMAGE_IMPORT_DESCRIPTOR *stuff_start =
4196 (IMAGE_IMPORT_DESCRIPTOR *)((
char*)section_data +
4197 (pheader->opt_head.DataDirectory[directory].VirtualAddress -
4198 section_header->VirtualAddress));
4201 const unsigned stuff_length =
4202 pheader->opt_head.DataDirectory[directory].Size;
4203 if(directory == IMAGE_DIRECTORY_ENTRY_IMPORT) {
4204 while(!IsBadReadPtr(stuff_start,
sizeof(*stuff_start)) &&
4205 stuff_start->Name) {
4206 TString dll = (
char*)section_data +
4207 ((DWORD)(stuff_start->Name)) -
4208 section_header->VirtualAddress;
4212 char *winPath = getenv(
"windir");
4213 _splitpath(winPath,winDrive,winDir,winName,winExt);
4214 if(!strstr(dllPath, winDir)) {
4215 if (!linkedLibs.
IsNull())
4217 linkedLibs += dllPath;
4229 UnmapViewOfFile(basepointer);
4230 CloseHandle(hMapping);
4261 char drive[_MAX_DRIVE], dir[_MAX_DIR], fname[_MAX_FNAME], ext[_MAX_EXT];
4264 std::vector<std::string> all_libs, libpaths;
4270 while (getline(libenv, str,
';')) {
4271 libpaths.push_back(str);
4274 std::stringstream libraries(libs.
Data());
4275 while (getline(libraries, str,
' ')) {
4276 std::string::size_type
first, last;
4279 if (str.rfind(
"-L", 0) == 0) {
4280 first = str.find_first_of(
'%');
4281 last = str.find_last_of(
'%');
4282 if ((
first != std::string::npos) && (last != std::string::npos) &&
4287 std::string var = str.substr(
first+1, last-
first-1);
4292 env += str.substr(last+1);
4293 libpaths.push_back(env);
4297 ntlibs.
Append(str.c_str());
4302 last = str.rfind(
".dll");
4303 if (last != std::string::npos)
4304 str.replace(last, 4,
".lib");
4305 last = str.rfind(
".DLL");
4306 if (last != std::string::npos)
4307 str.replace(last, 4,
".lib");
4308 if (str.rfind(
".lib") != std::string::npos ||
4309 str.rfind(
".LIB") != std::string::npos) {
4311 if (_stat( str.c_str(), &buf ) == 0) {
4313 ntlibs.
Append(str.c_str());
4321 _splitpath(str.c_str(), drive, dir, fname, ext);
4322 std::string libname(fname);
4324 all_libs.push_back(libname);
4326 for (
auto lib : all_libs) {
4328 for (
auto libpath : libpaths) {
4330 std::string path_lib(libpath);
4333 if (_stat( path_lib.c_str(), &buf ) == 0) {
4335 ntlibs.
Append(lib.c_str());
4364 if (!ti)
return nullptr;
4399 if (mode && t->
IsSync()) {
4403 }
else if (!mode && t->
IsAsync()) {
4421 FILETIME ftFileTime;
4425 ::GetSystemTimeAsFileTime(&ftRealTime.ftFileTime);
4434 OSVERSIONINFO OsVersionInfo;
4443 OsVersionInfo.dwOSVersionInfoSize =
sizeof(OSVERSIONINFO);
4444 GetVersionEx(&OsVersionInfo);
4445 if (OsVersionInfo.dwPlatformId == VER_PLATFORM_WIN32_NT) {
4451 FILETIME ftFileTime;
4456 FILETIME ftFileTime;
4460 HANDLE hThread = GetCurrentThread();
4461 ret = GetThreadTimes (hThread, &ftCreate, &ftExit,
4462 &ftKernel.ftFileTime,
4463 &ftUser.ftFileTime);
4465 ret = ::GetLastError();
4466 ::Error(
"GetCPUTime",
" Error on GetProcessTimes 0x%lx", (
int)ret);
4486 static time_t jan95 = 0;
4497 jan95 = mktime(&tp);
4498 if ((
int)jan95 == -1) {
4499 ::SysError(
"TWinNTSystem::Now",
"error converting 950001 0:00 to time_t");
4506 return TTime((now.time-(
Long_t)jan95)*1000 + now.millitm);
4532 if (
h->HasReadInterest())
4534 if (
h->HasWriteInterest())
4536 h->ResetReadyMask();
4538 rc = WinNTSelect(&rd, &wr, to);
4567 if (
h->HasReadInterest())
4569 if (
h->HasWriteInterest())
4571 h->ResetReadyMask();
4572 rc = WinNTSelect(&rd, &wr, to);
4594 if ((sp = ::getservbyname(servicename,
kProtocolName)) == 0) {
4595 Error(
"GetServiceByName",
"no service \"%s\" with protocol \"%s\"\n",
4599 return ::ntohs(sp->s_port);
4610 if ((sp = ::getservbyport(::htons(port),
kProtocolName)) == 0) {
4611 return Form(
"%d", port);
4621 struct hostent *host_ptr;
4626 if ((addr = ::inet_addr(hostname)) != INADDR_NONE) {
4628 if ((host_ptr = ::gethostbyaddr((
const char *)&addr,
4629 sizeof(addr), AF_INET))) {
4630 host = host_ptr->h_name;
4634 for (i = 1; host_ptr->h_addr_list[i]; i++) {
4635 memcpy(&addr2, host_ptr->h_addr_list[i], host_ptr->h_length);
4636 a.AddAddress(ntohl(addr2));
4638 for (i = 0; host_ptr->h_aliases[i]; i++)
4639 a.AddAlias(host_ptr->h_aliases[i]);
4642 host =
"UnNamedHost";
4644 }
else if ((host_ptr = ::gethostbyname(hostname))) {
4646 if (host_ptr->h_addrtype != AF_INET) {
4647 Error(
"GetHostByName",
"%s is not an internet host\n", hostname);
4650 memcpy(&addr, host_ptr->h_addr, host_ptr->h_length);
4651 host = host_ptr->h_name;
4652 type = host_ptr->h_addrtype;
4656 for (i = 1; host_ptr->h_addr_list[i]; i++) {
4657 memcpy(&addr2, host_ptr->h_addr_list[i], host_ptr->h_length);
4658 a.AddAddress(ntohl(addr2));
4660 for (i = 0; host_ptr->h_aliases[i]; i++)
4661 a.AddAlias(host_ptr->h_aliases[i]);
4664 if (
gDebug > 0)
Error(
"GetHostByName",
"unknown host %s", hostname);
4677 struct sockaddr_in addr;
4678 int len =
sizeof(addr);
4680 if (::getpeername(sock, (
struct sockaddr *)&addr, &len) == SOCKET_ERROR) {
4685 struct hostent *host_ptr;
4686 const char *hostname;
4690 if ((host_ptr = ::gethostbyaddr((
const char *)&addr.sin_addr,
4691 sizeof(addr.sin_addr), AF_INET))) {
4692 memcpy(&iaddr, host_ptr->h_addr, host_ptr->h_length);
4693 hostname = host_ptr->h_name;
4694 family = host_ptr->h_addrtype;
4696 memcpy(&iaddr, &addr.sin_addr,
sizeof(addr.sin_addr));
4701 return TInetAddress(hostname, ::ntohl(iaddr), family, ::ntohs(addr.sin_port));
4710 struct sockaddr_in addr;
4711 int len =
sizeof(addr);
4713 if (::getsockname(sock, (
struct sockaddr *)&addr, &len) == SOCKET_ERROR) {
4718 struct hostent *host_ptr;
4719 const char *hostname;
4723 if ((host_ptr = ::gethostbyaddr((
const char *)&addr.sin_addr,
4724 sizeof(addr.sin_addr), AF_INET))) {
4725 memcpy(&iaddr, host_ptr->h_addr, host_ptr->h_length);
4726 hostname = host_ptr->h_name;
4727 family = host_ptr->h_addrtype;
4729 memcpy(&iaddr, &addr.sin_addr,
sizeof(addr.sin_addr));
4734 return TInetAddress(hostname, ::ntohl(iaddr), family, ::ntohs(addr.sin_port));
4745 if ((sock = ::socket(AF_INET, SOCK_STREAM, 0)) ==
INVALID_SOCKET) {
4746 ::SysError(
"TWinNTSystem::AnnounceUnixService",
"socket");
4750 struct sockaddr_in inserver;
4751 memset(&inserver, 0,
sizeof(inserver));
4752 inserver.sin_family = AF_INET;
4753 inserver.sin_addr.s_addr = ::htonl(INADDR_LOOPBACK);
4754 inserver.sin_port = port;
4758 if (::bind(sock, (
struct sockaddr*) &inserver,
sizeof(inserver)) == SOCKET_ERROR) {
4759 ::SysError(
"TWinNTSystem::AnnounceUnixService",
"bind");
4764 if (::listen(sock, backlog)) {
4765 ::SysError(
"TWinNTSystem::AnnounceUnixService",
"listen");
4777 if (!sockpath || strlen(sockpath) <= 0) {
4778 ::SysError(
"TWinNTSystem::AnnounceUnixService",
"socket path undefined");
4782 struct sockaddr_in myaddr;
4784 int len =
sizeof myaddr;
4789 if ((sock = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
4790 ::SysError(
"TWinNTSystem::AnnounceUnixService",
"socket");
4794 memset(&myaddr, 0,
sizeof(myaddr));
4795 myaddr.sin_port = 0;
4796 myaddr.sin_family = AF_INET;
4797 myaddr.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
4799 rc = bind(sock, (
struct sockaddr *)&myaddr, len);
4801 ::SysError(
"TWinNTSystem::AnnounceUnixService",
"bind");
4804 rc = getsockname(sock, (
struct sockaddr *)&myaddr, &len);
4806 ::SysError(
"TWinNTSystem::AnnounceUnixService",
"getsockname");
4809 TString socketpath = sockpath;
4811 fp = fopen(socketpath,
"wb");
4813 ::SysError(
"TWinNTSystem::AnnounceUnixService",
"fopen");
4816 fprintf(fp,
"%d", myaddr.sin_port);
4820 if (listen(sock, backlog)) {
4821 ::SysError(
"TWinNTSystem::AnnounceUnixService",
"listen");
4833 if (socket == -1)
return;
4837 ::shutdown(sock, 2);
4839 struct linger linger = {0, 0};
4840 ::setsockopt(sock, SOL_SOCKET, SO_LINGER, (
char *) &linger,
sizeof(linger));
4841 while (
::closesocket(sock) == SOCKET_ERROR && WSAGetLastError() == WSAEINTR) {
4855 if (WinNTRecv(sock, &header,
sizeof(header), 0) > 0) {
4856 int count = ::ntohl(header);
4858 if (count > length) {
4859 Error(
"RecvBuf",
"record header exceeds buffer size");
4861 }
else if (count > 0) {
4862 if (WinNTRecv(sock, buf, count, 0) < 0) {
4863 Error(
"RecvBuf",
"cannot receive buffer");
4878 Int_t header = ::htonl(length);
4880 if (WinNTSend(sock, &header,
sizeof(header), 0) < 0) {
4881 Error(
"SendBuf",
"cannot send header");
4885 if (WinNTSend(sock, buf, length, 0) < 0) {
4886 Error(
"SendBuf",
"cannot send buffer");
4926 if ((
n = WinNTRecv(sock, buf, length, flag)) <= 0) {
4928 Error(
"RecvRaw",
"cannot receive buffer");
4962 if ((
n = WinNTSend(sock, buf, length, flag)) <= 0) {
4964 Error(
"SendRaw",
"cannot send buffer");
4977 if (socket == -1)
return -1;
4982 if (::setsockopt(sock, SOL_SOCKET, SO_SNDBUF, (
char*)&val,
sizeof(val)) == SOCKET_ERROR) {
4983 ::SysError(
"SetSockOpt",
"setsockopt(SO_SNDBUF)");
4988 if (::setsockopt(sock, SOL_SOCKET, SO_RCVBUF, (
char*)&val,
sizeof(val)) == SOCKET_ERROR) {
4989 ::SysError(
"SetSockOpt",
"setsockopt(SO_RCVBUF)");
4994 if (::setsockopt(sock, SOL_SOCKET, SO_OOBINLINE, (
char*)&val,
sizeof(val)) == SOCKET_ERROR) {
4995 SysError(
"SetSockOpt",
"setsockopt(SO_OOBINLINE)");
5000 if (::setsockopt(sock, SOL_SOCKET, SO_KEEPALIVE, (
char*)&val,
sizeof(val)) == SOCKET_ERROR) {
5001 ::SysError(
"SetSockOpt",
"setsockopt(SO_KEEPALIVE)");
5006 if (::setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (
char*)&val,
sizeof(val)) == SOCKET_ERROR) {
5007 ::SysError(
"SetSockOpt",
"setsockopt(SO_REUSEADDR)");
5012 if (::setsockopt(sock, IPPROTO_TCP, TCP_NODELAY, (
char*)&val,
sizeof(val)) == SOCKET_ERROR) {
5013 ::SysError(
"SetSockOpt",
"setsockopt(TCP_NODELAY)");
5018 if (::ioctlsocket(sock, FIONBIO, &val) == SOCKET_ERROR) {
5025 if (::ioctl(sock, SIOCSPGRP, &val) == -1) {
5026 ::SysError(
"SetSockOpt",
"ioctl(SIOCSPGRP)");
5034 Error(
"SetSockOpt",
"illegal option (%d)", opt);
5046 if (socket == -1)
return -1;
5049 int optlen =
sizeof(*val);
5053 if (::getsockopt(sock, SOL_SOCKET, SO_SNDBUF, (
char*)val, &optlen) == SOCKET_ERROR) {
5054 ::SysError(
"GetSockOpt",
"getsockopt(SO_SNDBUF)");
5059 if (::getsockopt(sock, SOL_SOCKET, SO_RCVBUF, (
char*)val, &optlen) == SOCKET_ERROR) {
5060 ::SysError(
"GetSockOpt",
"getsockopt(SO_RCVBUF)");
5065 if (::getsockopt(sock, SOL_SOCKET, SO_OOBINLINE, (
char*)val, &optlen) == SOCKET_ERROR) {
5066 ::SysError(
"GetSockOpt",
"getsockopt(SO_OOBINLINE)");
5071 if (::getsockopt(sock, SOL_SOCKET, SO_KEEPALIVE, (
char*)val, &optlen) == SOCKET_ERROR) {
5072 ::SysError(
"GetSockOpt",
"getsockopt(SO_KEEPALIVE)");
5077 if (::getsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (
char*)val, &optlen) == SOCKET_ERROR) {
5078 ::SysError(
"GetSockOpt",
"getsockopt(SO_REUSEADDR)");
5083 if (::getsockopt(sock, IPPROTO_TCP, TCP_NODELAY, (
char*)val, &optlen) == SOCKET_ERROR) {
5084 ::SysError(
"GetSockOpt",
"getsockopt(TCP_NODELAY)");
5100 if (::ioctlsocket(sock, SIOCGPGRP, (u_long*)val) == SOCKET_ERROR) {
5101 ::SysError(
"GetSockOpt",
"ioctl(SIOCGPGRP)");
5107 if (::ioctlsocket(sock, SIOCATMARK, (u_long*)val) == SOCKET_ERROR) {
5108 ::SysError(
"GetSockOpt",
"ioctl(SIOCATMARK)");
5113 if (::ioctlsocket(sock, FIONREAD, (u_long*)val) == SOCKET_ERROR) {
5119 Error(
"GetSockOpt",
"illegal option (%d)", opt);
5131 int tcpwindowsize,
const char *protocol)
5136 if (!strcmp(servername,
"unix")) {
5140 (servername[1] ==
':' && servername[2] ==
'/')) {
5144 if (!strcmp(protocol,
"udp")){
5151 sport = ::htons(port);
5155 if (!addr.
IsValid())
return -1;
5158 struct sockaddr_in server;
5159 memset(&server, 0,
sizeof(server));
5160 memcpy(&server.sin_addr, &adr,
sizeof(adr));
5162 server.sin_port = sport;
5166 if ((sock = ::socket(AF_INET, SOCK_STREAM, 0)) ==
INVALID_SOCKET) {
5167 ::SysError(
"TWinNTSystem::WinNTConnectTcp",
"socket");
5171 if (tcpwindowsize > 0) {
5176 if (::connect(sock, (
struct sockaddr*) &server,
sizeof(server)) ==
INVALID_SOCKET) {
5189 struct sockaddr_in myaddr;
5192 memset(&myaddr, 0,
sizeof(myaddr));
5193 myaddr.sin_family = AF_INET;
5194 myaddr.sin_port = port;
5195 myaddr.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
5198 if ((sock = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
5199 ::SysError(
"TWinNTSystem::WinNTUnixConnect",
"socket");
5203 while ((connect(sock, (
struct sockaddr *)&myaddr,
sizeof myaddr)) == -1) {
5207 ::SysError(
"TWinNTSystem::WinNTUnixConnect",
"connect");
5223 if (!sockpath || strlen(sockpath) <= 0) {
5224 ::SysError(
"TWinNTSystem::WinNTUnixConnect",
"socket path undefined");
5227 TString socketpath = sockpath;
5229 fp = fopen(socketpath.
Data(),
"rb");
5231 ::SysError(
"TWinNTSystem::WinNTUnixConnect",
"fopen");
5234 fscanf(fp,
"%d", &port);
5237 if (port < 0 || port > 65535) {
5238 ::SysError(
"TWinNTSystem::WinNTUnixConnect",
"invalid port");
5256 sport = htons(port);
5259 if (!addr.
IsValid())
return -1;
5262 struct sockaddr_in server;
5263 memset(&server, 0,
sizeof(server));
5264 memcpy(&server.sin_addr, &adr,
sizeof(adr));
5266 server.sin_port = sport;
5270 if ((sock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) < 0) {
5271 ::SysError(
"TWinNTSystem::WinNTUdpConnect",
"socket (%s:%d)",
5276 while (connect(sock, (
struct sockaddr*) &server,
sizeof(server)) == -1) {
5280 ::SysError(
"TWinNTSystem::WinNTUdpConnect",
"connect (%s:%d)",
5298 const char *protocol)
5319 const short kSOCKET_MINPORT = 5000, kSOCKET_MAXPORT = 15000;
5320 short tryport = kSOCKET_MINPORT;
5325 sport = ::htons(port);
5328 if (port == 0 && reuse) {
5329 ::Error(
"TWinNTSystem::WinNTTcpService",
"cannot do a port scan while reuse is true");
5336 sport = ::htons(port);
5341 if ((sock = ::socket(AF_INET, SOCK_STREAM, 0)) < 0) {
5342 ::SysError(
"TWinNTSystem::WinNTTcpService",
"socket");
5350 if (tcpwindowsize > 0) {
5355 struct sockaddr_in inserver;
5356 memset(&inserver, 0,
sizeof(inserver));
5357 inserver.sin_family = AF_INET;
5358 inserver.sin_addr.s_addr = ::htonl(INADDR_ANY);
5359 inserver.sin_port = sport;
5363 if (::bind(sock, (
struct sockaddr*) &inserver,
sizeof(inserver)) == SOCKET_ERROR) {
5364 ::SysError(
"TWinNTSystem::WinNTTcpService",
"bind");
5370 inserver.sin_port = ::htons(tryport);
5371 bret = ::bind(sock, (
struct sockaddr*) &inserver,
sizeof(inserver));
5373 }
while (bret == SOCKET_ERROR && WSAGetLastError() == WSAEADDRINUSE &&
5374 tryport < kSOCKET_MAXPORT);
5375 if (bret == SOCKET_ERROR) {
5376 ::SysError(
"TWinNTSystem::WinNTTcpService",
"bind (port scan)");
5382 if (::listen(sock, backlog) == SOCKET_ERROR) {
5383 ::SysError(
"TWinNTSystem::WinNTTcpService",
"listen");
5400 const short kSOCKET_MINPORT = 5000, kSOCKET_MAXPORT = 15000;
5401 short sport, tryport = kSOCKET_MINPORT;
5407 sport = htons(port);
5411 if ((sock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) < 0) {
5412 ::SysError(
"TUnixSystem::UnixUdpService",
"socket");
5416 struct sockaddr_in inserver;
5417 memset(&inserver, 0,
sizeof(inserver));
5418 inserver.sin_family = AF_INET;
5419 inserver.sin_addr.s_addr = htonl(INADDR_ANY);
5420 inserver.sin_port = sport;
5424 if (bind(sock, (
struct sockaddr*) &inserver,
sizeof(inserver))) {
5425 ::SysError(
"TWinNTSystem::AnnounceUdpService",
"bind");
5431 inserver.sin_port = htons(tryport);
5432 bret = bind(sock, (
struct sockaddr*) &inserver,
sizeof(inserver));
5434 }
while (bret == SOCKET_ERROR && WSAGetLastError() == WSAEADDRINUSE &&
5435 tryport < kSOCKET_MAXPORT);
5437 ::SysError(
"TWinNTSystem::AnnounceUdpService",
"bind (port scan)");
5443 if (listen(sock, backlog)) {
5444 ::SysError(
"TWinNTSystem::AnnounceUdpService",
"listen");
5462 (::WSAGetLastError() == WSAEINTR)) {
5467 if (::WSAGetLastError() == WSAEWOULDBLOCK) {
5481#define SystemBasicInformation 0
5482#define SystemPerformanceInformation 2
5487 ULONG uKeMaximumIncrement;
5489 ULONG uMmNumberOfPhysicalPages;
5490 ULONG uMmLowestPhysicalPage;
5491 ULONG UMmHighestPhysicalPage;
5492 ULONG uAllocationGranularity;
5493 PVOID pLowestUserAddress;
5494 PVOID pMmHighestUserAddress;
5495 ULONG uKeActiveProcessors;
5496 BYTE bKeNumberProcessors;
5499} SYSTEM_BASIC_INFORMATION;
5503 LARGE_INTEGER liIdleTime;
5505} SYSTEM_PERFORMANCE_INFORMATION;
5507typedef struct _PROCESS_MEMORY_COUNTERS {
5509 DWORD PageFaultCount;
5510 SIZE_T PeakWorkingSetSize;
5511 SIZE_T WorkingSetSize;
5512 SIZE_T QuotaPeakPagedPoolUsage;
5513 SIZE_T QuotaPagedPoolUsage;
5514 SIZE_T QuotaPeakNonPagedPoolUsage;
5515 SIZE_T QuotaNonPagedPoolUsage;
5516 SIZE_T PagefileUsage;
5517 SIZE_T PeakPagefileUsage;
5522#define Li2Double(x) ((double)((x).HighPart) * 4.294967296E9 + (double)((x).LowPart))
5530 LARGE_INTEGER ulFreq, ulTicks, ulValue, ulStartCounter;
5534 if (QueryPerformanceFrequency(&ulFreq)) {
5536 QueryPerformanceCounter(&ulTicks);
5539 ulValue.QuadPart = ulTicks.QuadPart + ulFreq.QuadPart/10;
5540 ulStartCounter.QuadPart =
__rdtsc();
5544 QueryPerformanceCounter(&ulTicks);
5545 }
while (ulTicks.QuadPart <= ulValue.QuadPart);
5547 return (DWORD)((
__rdtsc() - ulStartCounter.QuadPart)/100000);
5555#define SM_SERVERR2 89
5562 OSVERSIONINFOEX osvi;
5565 BOOL bOsVersionInfoEx;
5566 static char *strReturn =
nullptr;
5570 strReturn =
new char[2048];
5574 ZeroMemory(&si,
sizeof(SYSTEM_INFO));
5575 ZeroMemory(&osvi,
sizeof(OSVERSIONINFOEX));
5580 osvi.dwOSVersionInfoSize =
sizeof(OSVERSIONINFOEX);
5582 if( !(bOsVersionInfoEx = GetVersionEx ((OSVERSIONINFO *) &osvi)) )
5584 osvi.dwOSVersionInfoSize =
sizeof (OSVERSIONINFO);
5585 if (! GetVersionEx ( (OSVERSIONINFO *) &osvi) )
5590 pGNSI = (
PGNSI) GetProcAddress( GetModuleHandle(
"kernel32.dll"),
5591 "GetNativeSystemInfo");
5594 else GetSystemInfo(&si);
5596 switch (osvi.dwPlatformId)
5599 case VER_PLATFORM_WIN32_NT:
5602 if ( osvi.dwMajorVersion == 6 && osvi.dwMinorVersion == 0 )
5604 if( osvi.wProductType == VER_NT_WORKSTATION )
5605 strlcpy(strReturn,
"Microsoft Windows Vista ",2048);
5606 else strlcpy(strReturn,
"Windows Server \"Longhorn\" " ,2048);
5608 if ( osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 2 )
5611 strlcpy(strReturn,
"Microsoft Windows Server 2003 \"R2\" ",2048);
5612 else if( osvi.wProductType == VER_NT_WORKSTATION &&
5613 si.wProcessorArchitecture==PROCESSOR_ARCHITECTURE_AMD64)
5615 strlcpy(strReturn,
"Microsoft Windows XP Professional x64 Edition ",2048);
5617 else strlcpy(strReturn,
"Microsoft Windows Server 2003, ",2048);
5619 if ( osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 1 )
5620 strlcpy(strReturn,
"Microsoft Windows XP ",2048);
5622 if ( osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 0 )
5623 strlcpy(strReturn,
"Microsoft Windows 2000 ",2048);
5625 if ( osvi.dwMajorVersion <= 4 )
5626 strlcpy(strReturn,
"Microsoft Windows NT ",2048);
5629 if( bOsVersionInfoEx )
5632 if ( osvi.wProductType == VER_NT_WORKSTATION &&
5633 si.wProcessorArchitecture!=PROCESSOR_ARCHITECTURE_AMD64)
5635 if( osvi.dwMajorVersion == 4 )
5636 strlcat(strReturn,
"Workstation 4.0 ",2048 );
5637 else if( osvi.wSuiteMask & VER_SUITE_PERSONAL )
5638 strlcat(strReturn,
"Home Edition " ,2048);
5639 else strlcat(strReturn,
"Professional " ,2048);
5642 else if ( osvi.wProductType == VER_NT_SERVER ||
5643 osvi.wProductType == VER_NT_DOMAIN_CONTROLLER )
5645 if(osvi.dwMajorVersion==5 && osvi.dwMinorVersion==2)
5647 if ( si.wProcessorArchitecture==PROCESSOR_ARCHITECTURE_IA64 )
5649 if( osvi.wSuiteMask & VER_SUITE_DATACENTER )
5650 strlcat(strReturn,
"Datacenter Edition for Itanium-based Systems",2048 );
5651 else if( osvi.wSuiteMask & VER_SUITE_ENTERPRISE )
5652 strlcat(strReturn,
"Enterprise Edition for Itanium-based Systems" ,2048);
5654 else if ( si.wProcessorArchitecture==PROCESSOR_ARCHITECTURE_AMD64 )
5656 if( osvi.wSuiteMask & VER_SUITE_DATACENTER )
5657 strlcat(strReturn,
"Datacenter x64 Edition ",2048 );
5658 else if( osvi.wSuiteMask & VER_SUITE_ENTERPRISE )
5659 strlcat(strReturn,
"Enterprise x64 Edition ",2048 );
5660 else strlcat(strReturn,
"Standard x64 Edition ",2048 );
5664 if( osvi.wSuiteMask & VER_SUITE_DATACENTER )
5665 strlcat(strReturn,
"Datacenter Edition ",2048 );
5666 else if( osvi.wSuiteMask & VER_SUITE_ENTERPRISE )
5667 strlcat(strReturn,
"Enterprise Edition ",2048 );
5668 else if ( osvi.wSuiteMask == VER_SUITE_BLADE )
5669 strlcat(strReturn,
"Web Edition " ,2048);
5670 else strlcat(strReturn,
"Standard Edition ",2048 );
5673 else if(osvi.dwMajorVersion==5 && osvi.dwMinorVersion==0)
5675 if( osvi.wSuiteMask & VER_SUITE_DATACENTER )
5676 strlcat(strReturn,
"Datacenter Server ",2048 );
5677 else if( osvi.wSuiteMask & VER_SUITE_ENTERPRISE )
5678 strlcat(strReturn,
"Advanced Server ",2048 );
5679 else strlcat(strReturn,
"Server ",2048 );
5683 if( osvi.wSuiteMask & VER_SUITE_ENTERPRISE )
5684 strlcat(strReturn,
"Server 4.0, Enterprise Edition " ,2048);
5685 else strlcat(strReturn,
"Server 4.0 ",2048 );
5694 DWORD dwBufLen=
BUFSIZE*
sizeof(TCHAR);
5697 lRet = RegOpenKeyEx( HKEY_LOCAL_MACHINE,
5698 "SYSTEM\\CurrentControlSet\\Control\\ProductOptions",
5699 0, KEY_QUERY_VALUE, &hKey );
5700 if( lRet != ERROR_SUCCESS )
5703 lRet = RegQueryValueEx( hKey,
"ProductType", NULL, NULL,
5704 (LPBYTE) szProductType, &dwBufLen);
5705 RegCloseKey( hKey );
5707 if( (lRet != ERROR_SUCCESS) || (dwBufLen >
BUFSIZE*
sizeof(TCHAR)) )
5710 if ( lstrcmpi(
"WINNT", szProductType) == 0 )
5711 strlcat(strReturn,
"Workstation " ,2048);
5712 if ( lstrcmpi(
"LANMANNT", szProductType) == 0 )
5713 strlcat(strReturn,
"Server " ,2048);
5714 if ( lstrcmpi(
"SERVERNT", szProductType) == 0 )
5715 strlcat(strReturn,
"Advanced Server " ,2048);
5716 snprintf(temp,512,
"%d.%d ", osvi.dwMajorVersion, osvi.dwMinorVersion);
5717 strlcat(strReturn, temp,2048);
5722 if( osvi.dwMajorVersion == 4 &&
5723 lstrcmpi( osvi.szCSDVersion,
"Service Pack 6" ) == 0 )
5729 lRet = RegOpenKeyEx( HKEY_LOCAL_MACHINE,
5730 "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Hotfix\\Q246009",
5731 0, KEY_QUERY_VALUE, &hKey );
5732 if( lRet == ERROR_SUCCESS ) {
5733 snprintf(temp, 512,
"Service Pack 6a (Build %d)", osvi.dwBuildNumber & 0xFFFF );
5734 strlcat(strReturn, temp,2048 );
5738 snprintf(temp,512,
"%s (Build %d)", osvi.szCSDVersion, osvi.dwBuildNumber & 0xFFFF);
5739 strlcat(strReturn, temp,2048 );
5742 RegCloseKey( hKey );
5746 snprintf(temp, 512,
"%s (Build %d)", osvi.szCSDVersion, osvi.dwBuildNumber & 0xFFFF);
5747 strlcat(strReturn, temp,2048 );
5753 case VER_PLATFORM_WIN32_WINDOWS:
5755 if (osvi.dwMajorVersion == 4 && osvi.dwMinorVersion == 0)
5757 strlcpy(strReturn,
"Microsoft Windows 95 ",2048);
5758 if (osvi.szCSDVersion[1]==
'C' || osvi.szCSDVersion[1]==
'B')
5759 strlcat(strReturn,
"OSR2 " ,2048);
5762 if (osvi.dwMajorVersion == 4 && osvi.dwMinorVersion == 10)
5764 strlcpy(strReturn,
"Microsoft Windows 98 ",2048);
5765 if ( osvi.szCSDVersion[1]==
'A' || osvi.szCSDVersion[1]==
'B')
5766 strlcat(strReturn,
"SE ",2048 );
5769 if (osvi.dwMajorVersion == 4 && osvi.dwMinorVersion == 90)
5771 strlcpy(strReturn,
"Microsoft Windows Millennium Edition",2048);
5775 case VER_PLATFORM_WIN32s:
5776 strlcpy(strReturn,
"Microsoft Win32s",2048);
5787 unsigned nHighestFeatureEx;
5791 nHighestFeatureEx = (unsigned)nBuff[0];
5793 if (nHighestFeatureEx >= 0x80000006) {
5795 return (((
unsigned)nBuff[2])>>16);
5805 SYSTEM_PERFORMANCE_INFORMATION SysPerfInfo;
5806 SYSTEM_INFO sysInfo;
5807 MEMORYSTATUSEX statex;
5808 OSVERSIONINFO OsVersionInfo;
5810 char szKeyValueString[80];
5811 DWORD szKeyValueDword;
5816 NtQuerySystemInformation = (
PROCNTQSI)GetProcAddress(
5817 GetModuleHandle(
"ntdll"),
"NtQuerySystemInformation");
5819 if (!NtQuerySystemInformation) {
5821 "Error on GetProcAddress(NtQuerySystemInformation)");
5826 &SysPerfInfo,
sizeof(SysPerfInfo),
5828 OsVersionInfo.dwOSVersionInfoSize =
sizeof(OSVERSIONINFO);
5829 GetVersionEx(&OsVersionInfo);
5830 GetSystemInfo(&sysInfo);
5831 statex.dwLength =
sizeof(statex);
5832 if (!GlobalMemoryStatusEx(&statex)) {
5833 ::Error(
"GetWinNTSysInfo",
"Error on GlobalMemoryStatusEx()");
5836 sysinfo->
fCpus = sysInfo.dwNumberOfProcessors;
5845 status = RegOpenKeyEx(HKEY_LOCAL_MACHINE,
"HARDWARE\\DESCRIPTION\\System",
5846 0, KEY_QUERY_VALUE, &hKey);
5847 if (status == ERROR_SUCCESS) {
5848 dwBufLen =
sizeof(szKeyValueString);
5849 RegQueryValueEx(hKey,
"Identifier", NULL, NULL,(LPBYTE)szKeyValueString,
5851 sysinfo->
fModel = szKeyValueString;
5854 status = RegOpenKeyEx(HKEY_LOCAL_MACHINE,
5855 "Hardware\\Description\\System\\CentralProcessor\\0",
5856 0, KEY_QUERY_VALUE, &hKey);
5857 if (status == ERROR_SUCCESS) {
5858 dwBufLen =
sizeof(szKeyValueString);
5859 status = RegQueryValueEx(hKey,
"ProcessorNameString", NULL, NULL,
5860 (LPBYTE)szKeyValueString, &dwBufLen);
5861 if (status == ERROR_SUCCESS)
5862 sysinfo->
fCpuType = szKeyValueString;
5863 dwBufLen =
sizeof(DWORD);
5864 status = RegQueryValueEx(hKey,
"~MHz",NULL,NULL,(LPBYTE)&szKeyValueDword,
5866 if ((status == ERROR_SUCCESS) && ((sysinfo->
fCpuSpeed <= 0) ||
5867 (sysinfo->
fCpuSpeed < (szKeyValueDword >> 1))))
5881 SYSTEM_INFO sysInfo;
5882 Float_t idle_ratio, kernel_ratio, user_ratio, total_ratio;
5883 FILETIME ft_sys_idle, ft_sys_kernel, ft_sys_user, ft_fun_time;
5884 SYSTEMTIME st_fun_time;
5886 ULARGE_INTEGER ul_sys_idle, ul_sys_kernel, ul_sys_user;
5887 static ULARGE_INTEGER ul_sys_idleold = {0, 0};
5888 static ULARGE_INTEGER ul_sys_kernelold = {0, 0};
5889 static ULARGE_INTEGER ul_sys_userold = {0, 0};
5890 ULARGE_INTEGER ul_sys_idle_diff, ul_sys_kernel_diff, ul_sys_user_diff;
5892 ULARGE_INTEGER ul_fun_time;
5893 ULARGE_INTEGER ul_fun_timeold = {0, 0};
5894 ULARGE_INTEGER ul_fun_time_diff;
5896 typedef BOOL (__stdcall *GetSystemTimesProc)( LPFILETIME lpIdleTime,
5897 LPFILETIME lpKernelTime, LPFILETIME lpUserTime );
5898 static GetSystemTimesProc pGetSystemTimes = 0;
5900 HMODULE hModImagehlp = LoadLibrary(
"Kernel32.dll" );
5901 if (!hModImagehlp) {
5902 ::Error(
"GetWinNTCpuInfo",
"Error on LoadLibrary(Kernel32.dll)");
5906 pGetSystemTimes = (GetSystemTimesProc) GetProcAddress( hModImagehlp,
5908 if (!pGetSystemTimes) {
5909 ::Error(
"GetWinNTCpuInfo",
"Error on GetProcAddress(GetSystemTimes)");
5912 GetSystemInfo(&sysInfo);
5915 pGetSystemTimes(&ft_sys_idle,&ft_sys_kernel,&ft_sys_user);
5916 GetSystemTime(&st_fun_time);
5917 SystemTimeToFileTime(&st_fun_time,&ft_fun_time);
5919 memcpy(&ul_sys_idle, &ft_sys_idle,
sizeof(FILETIME));
5920 memcpy(&ul_sys_kernel, &ft_sys_kernel,
sizeof(FILETIME));
5921 memcpy(&ul_sys_user, &ft_sys_user,
sizeof(FILETIME));
5922 memcpy(&ul_fun_time, &ft_fun_time,
sizeof(FILETIME));
5924 ul_sys_idle_diff.QuadPart = ul_sys_idle.QuadPart -
5925 ul_sys_idleold.QuadPart;
5926 ul_sys_kernel_diff.QuadPart = ul_sys_kernel.QuadPart -
5927 ul_sys_kernelold.QuadPart;
5928 ul_sys_user_diff.QuadPart = ul_sys_user.QuadPart -
5929 ul_sys_userold.QuadPart;
5931 ul_fun_time_diff.QuadPart = ul_fun_time.QuadPart -
5932 ul_fun_timeold.QuadPart;
5934 ul_sys_idleold.QuadPart = ul_sys_idle.QuadPart;
5935 ul_sys_kernelold.QuadPart = ul_sys_kernel.QuadPart;
5936 ul_sys_userold.QuadPart = ul_sys_user.QuadPart;
5938 if (ul_fun_timeold.QuadPart == 0) {
5940 ul_fun_timeold.QuadPart = ul_fun_time.QuadPart;
5943 ul_fun_timeold.QuadPart = ul_fun_time.QuadPart;
5951 idle_ratio /= (
Float_t)sysInfo.dwNumberOfProcessors;
5952 user_ratio /= (
Float_t)sysInfo.dwNumberOfProcessors;
5953 kernel_ratio /= (
Float_t)sysInfo.dwNumberOfProcessors;
5954 total_ratio = 100.0 - idle_ratio;
5959 cpuinfo->
fUser = user_ratio;
5960 cpuinfo->
fSys = kernel_ratio;
5961 cpuinfo->
fTotal = total_ratio;
5962 cpuinfo->
fIdle = idle_ratio;
5971 MEMORYSTATUSEX statex;
5972 statex.dwLength =
sizeof(statex);
5973 if (!GlobalMemoryStatusEx(&statex)) {
5974 ::Error(
"GetWinNTMemInfo",
"Error on GlobalMemoryStatusEx()");
5977 used = (
Long64_t)(statex.ullTotalPhys - statex.ullAvailPhys);
5985 swap_total = (
Long64_t)(statex.ullTotalPageFile - statex.ullTotalPhys);
5986 swap_avail = (
Long64_t)(statex.ullAvailPageFile - statex.ullAvailPhys);
5987 swap_used = swap_total - swap_avail;
6000 FILETIME starttime, exittime, kerneltime, usertime;
6001 timeval ru_stime, ru_utime;
6004 typedef BOOL (__stdcall *GetProcessMemoryInfoProc)( HANDLE Process,
6006 static GetProcessMemoryInfoProc pGetProcessMemoryInfo = 0;
6008 HMODULE hModImagehlp = LoadLibrary(
"Psapi.dll" );
6009 if (!hModImagehlp) {
6010 ::Error(
"GetWinNTProcInfo",
"Error on LoadLibrary(Psapi.dll)");
6014 pGetProcessMemoryInfo = (GetProcessMemoryInfoProc) GetProcAddress(
6015 hModImagehlp,
"GetProcessMemoryInfo" );
6016 if (!pGetProcessMemoryInfo) {
6018 "Error on GetProcAddress(GetProcessMemoryInfo)");
6022 if ( pGetProcessMemoryInfo( GetCurrentProcess(), &pmc,
sizeof(pmc)) ) {
6026 if ( GetProcessTimes(GetCurrentProcess(), &starttime, &exittime,
6027 &kerneltime, &usertime)) {
6030 memcpy(&li, &kerneltime,
sizeof(FILETIME));
6032 ru_stime.tv_sec = li.QuadPart / 1000000L;
6033 ru_stime.tv_usec = li.QuadPart % 1000000L;
6035 memcpy(&li, &usertime,
sizeof(FILETIME));
6037 ru_utime.tv_sec = li.QuadPart / 1000000L;
6038 ru_utime.tv_usec = li.QuadPart % 1000000L;
6041 ((
Float_t)(ru_utime.tv_usec) / 1000000.);
6043 ((
Float_t)(ru_stime.tv_usec) / 1000000.);
6054 if (!info)
return -1;
6066 if (!info)
return -1;
6077 if (!info)
return -1;
6088 if (!info)
return -1;
The file contains utilities which are foundational and could be used across the core component of ROO...
R__EXTERN TApplication * gApplication
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
Binding & operator=(OUT(*fun)(void))
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
typedef void((*Func_t)())
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
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
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
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.
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()
void Copy(void *source, void *dest)