diff options
author | Brooks Davis <brooks@FreeBSD.org> | 2019-10-08 18:20:02 +0000 |
---|---|---|
committer | Brooks Davis <brooks@FreeBSD.org> | 2019-10-08 18:20:02 +0000 |
commit | 320f2946781af5deaf568d19136cf96fe2c436dd (patch) | |
tree | 355c6156ea44fef5f9233dbbf7b8ecae06287ee7 /win32 | |
parent | 48eb25df687d51c9bdb4677c72e08ed3fde1b186 (diff) |
Notes
Diffstat (limited to 'win32')
-rw-r--r-- | win32/BSDLOGO.RC | 1 | ||||
-rw-r--r-- | win32/Makefile.win32 | 39 | ||||
-rw-r--r-- | win32/README.NT | 46 | ||||
-rw-r--r-- | win32/bogus.c | 1 | ||||
-rw-r--r-- | win32/clip.c | 439 | ||||
-rw-r--r-- | win32/console.c | 1 | ||||
-rw-r--r-- | win32/dirent.c | 1 | ||||
-rw-r--r-- | win32/dirent.h | 1 | ||||
-rw-r--r-- | win32/fork.c | 7 | ||||
-rw-r--r-- | win32/forkdata.h | 1 | ||||
-rw-r--r-- | win32/globals.c | 1 | ||||
-rw-r--r-- | win32/io.c | 7 | ||||
-rw-r--r-- | win32/nt.bind.c | 1 | ||||
-rw-r--r-- | win32/nt.char.c | 1 | ||||
-rw-r--r-- | win32/nt.const.c | 1 | ||||
-rw-r--r-- | win32/nt.screen.c | 1 | ||||
-rw-r--r-- | win32/nt.who.c | 1 | ||||
-rw-r--r-- | win32/ntb1.c | 1 | ||||
-rw-r--r-- | win32/ntb2.c | 1 | ||||
-rw-r--r-- | win32/ntfunc.c | 3 | ||||
-rw-r--r-- | win32/ntport.h | 1 | ||||
-rw-r--r-- | win32/ps.c | 309 | ||||
-rw-r--r-- | win32/signal.c | 1 | ||||
-rw-r--r-- | win32/stdio.c | 13 | ||||
-rw-r--r-- | win32/support.c | 22 | ||||
-rw-r--r-- | win32/version.h | 1 |
26 files changed, 40 insertions, 862 deletions
diff --git a/win32/BSDLOGO.RC b/win32/BSDLOGO.RC index 2973a877b203..f5afaea74341 100644 --- a/win32/BSDLOGO.RC +++ b/win32/BSDLOGO.RC @@ -1,2 +1 @@ -/*$Header: /p/tcsh/cvsroot/tcsh/win32/BSDLOGO.RC,v 1.3 2004/05/19 18:22:27 christos Exp $*/ IDI_ICON1 ICON DISCARDABLE "win32/BSDLOGO.ICO" diff --git a/win32/Makefile.win32 b/win32/Makefile.win32 index ca662ef5a688..4d673dee1616 100644 --- a/win32/Makefile.win32 +++ b/win32/Makefile.win32 @@ -1,5 +1,3 @@ -# $Id: Makefile.win32,v 1.17 2014/08/17 02:56:37 amold Exp $ -# Makefile.std 4.3 6/11/83 # # C Shell with process control; VM/UNIX VAX Makefile # Bill Joy UC Berkeley; Jim Kulp IIASA, Austria @@ -23,11 +21,11 @@ CF=-c -nologo INCLUDES=-I. -I.. -Iwin32 -DEBUG_CRTLIBS= libcmtd.lib oldnames.lib libcpmtd.lib -CRTLIBS= libcmt.lib oldnames.lib libcpmt.lib +DEBUG_CRTLIBS= libcmtd.lib oldnames.lib libcpmtd.lib libvcruntimed.lib libucrtd.lib legacy_stdio_definitions.lib legacy_stdio_wide_specifiers.lib +CRTLIBS= libcmt.lib oldnames.lib libcpmt.lib libvcruntime.lib libucrt.lib legacy_stdio_definitions.lib legacy_stdio_wide_specifiers.lib EXTRAFLAGS = -DWINNT_NATIVE -DNO_CRYPT -DHAVE_DIRENT_H $(EFL) \ - -wd28159 -wd28218 -wd28199 -wd6387 + -wd28159 -wd28218 -wd28199 -wd6387 -wd6385 WINDOWS_WARNING_LEVEL=-W4 -WX REST_WARNING_LEVEL=-WX -W3 @@ -39,7 +37,7 @@ ANALYZE_FLAGS = -analyze REST_WARNING_LEVEL= -W3 ANALYZE_FLAGS= -IGNORE_64= -wd4244 -wd4267 +IGNORE_64= -wd4244 -wd4267 -wd4311 !if "$(WIN64)" == "" !Message @@ -88,7 +86,7 @@ NTCFLAGS = $(NTCFLAGS) -Zp8 !endif CFLAGS= -MT $(NTCFLAGS) $(INCLUDES) -LDFLAGS= -nodefaultlib $(NTLDFLAGS) -stack:1048576,524288 -dynamicbase:no +LDFLAGS= -nodefaultlib $(NTLDFLAGS) -stack:1048576,524288 -dynamicbase:no -ignore:4099 CC= cl @@ -136,11 +134,11 @@ NTSRCS = win32\io.c win32\stdio.c win32\dirent.c win32\signal.c\ win32\support.c \ win32\nt.char.c win32\bogus.c win32\console.c win32\fork.c \ win32\ntfunc.c win32\ntb1.c win32\ntb2.c win32\globals.c \ - win32\nt.who.c win32\ps.c win32\clip.c win32\nt.const.c \ + win32\ps.c win32\nt.const.c win32\clip.c\ win32\nt.bind.c win32\nt.screen.c NTOBJS = io.$(SUF) stdio.$(SUF) dirent.$(SUF) signal.$(SUF) support.$(SUF) \ nt.char.$(SUF) bogus.$(SUF) console.$(SUF) fork.$(SUF) ntfunc.$(SUF) \ - globals.$(SUF) nt.who.$(SUF) ps.$(SUF) \ + globals.$(SUF) ps.$(SUF) \ clip.$(SUF) nt.const.$(SUF) nt.bind.$(SUF) nt.screen.$(SUF) VHSRCS=$(PVSRCS) $(AVSRCS) @@ -228,6 +226,7 @@ clean: cleanall: clean -del $(BUILD) + -del *nativecodeanalysi*.xml config.h: config_f.h @@ -267,6 +266,28 @@ ed.chared.$(SUF): ed.chared.c $(CC) $(CF) $(CFLAGS) $(DFLAGS) $(EXTRAFLAGS) $(IGNORE_64) ed.chared.c ed.inputl.$(SUF): ed.inputl.c $(CC) $(CF) $(CFLAGS) $(DFLAGS) $(EXTRAFLAGS) $(IGNORE_64) ed.inputl.c +sh.dol.$(SUF): sh.dol.c + $(CC) $(CF) $(CFLAGS) $(DFLAGS) $(EXTRAFLAGS) $(IGNORE_64) sh.dol.c +sh.func.$(SUF): sh.func.c + $(CC) $(CF) $(CFLAGS) $(DFLAGS) $(EXTRAFLAGS) $(IGNORE_64) sh.func.c +sh.glob.$(SUF): sh.glob.c + $(CC) $(CF) $(CFLAGS) $(DFLAGS) $(EXTRAFLAGS) $(IGNORE_64) sh.glob.c +tw.parse.$(SUF): tw.parse.c + $(CC) $(CF) $(CFLAGS) $(DFLAGS) $(EXTRAFLAGS) $(IGNORE_64) tw.parse.c +tw.comp.$(SUF): tw.comp.c + $(CC) $(CF) $(CFLAGS) $(DFLAGS) $(EXTRAFLAGS) $(IGNORE_64) tw.comp.c +tw.color.$(SUF): tw.color.c + $(CC) $(CF) $(CFLAGS) $(DFLAGS) $(EXTRAFLAGS) $(IGNORE_64) tw.color.c +ed.refresh.$(SUF): ed.refresh.c + $(CC) $(CF) $(CFLAGS) $(DFLAGS) $(EXTRAFLAGS) $(IGNORE_64) ed.refresh.c +tc.alloc.$(SUF): tc.alloc.c + $(CC) $(CF) $(CFLAGS) $(DFLAGS) $(EXTRAFLAGS) $(IGNORE_64) tc.alloc.c +tc.bind.$(SUF): tc.bind.c + $(CC) $(CF) $(CFLAGS) $(DFLAGS) $(EXTRAFLAGS) $(IGNORE_64) tc.bind.c +tc.printf.$(SUF): tc.printf.c + $(CC) $(CF) $(CFLAGS) $(DFLAGS) $(EXTRAFLAGS) $(IGNORE_64) tc.printf.c +tc.prompt.$(SUF): tc.prompt.c + $(CC) $(CF) $(CFLAGS) $(DFLAGS) $(EXTRAFLAGS) $(IGNORE_64) tc.prompt.c # turn optimizations off just for these files otherwise fork doesn't work sh.sem.$(SUF): sh.sem.c diff --git a/win32/README.NT b/win32/README.NT index 021c60c3add5..e17cb9c10a8f 100644 --- a/win32/README.NT +++ b/win32/README.NT @@ -234,27 +234,6 @@ NT-specific Builtins * start: like cmd.exe's start * title: change the shell title * cls: Clear the entire console buffer instead of just the visible window. -* ps: list processes running currently. With -w, list window titles as well. - -* shutdown: (works on Windows NT only) - - shutdown -[r|l|f] now - -(Even though no time argument is supported, "now" must be specified, EXCEPT -with -l .This is to prevent you from accidentally shutting the machine down.) - -r reboots, -l logs you off and -f forces apps to terminate. - -The default action is to shut the machine down. - - -* sourcerc: tcsh can be compiled with a stringtable resource that can be - sourced using this command. This feature is designed as a way to avoid - having to copy the .tcshrc to every computer you run tcsh on. The default - resource is a simple version of my .tcshrc. More complicated settings can - then be copied when needed. - -* printrc: print the compiled-in resource that will be sourced by sourcerc. - Notes: ----- @@ -351,31 +330,6 @@ To bind ctrl or alt combinations, use the following as examples. For Shift combinations: bindkey -b N-S-1 backward-word -Clipboard support ------------------ -Since version 3.58, you can cut and paste to and from the clipboard -directly from the shell. To do this, use bindings like the following: - - bindkey -b M-x e_copy_to_clipboard - bindkey -b M-y e_paste_from_clipboard - -Then, to paste text from the clipboard into the current input line, you -can type: - M-y -And to copy the current shell's kill buffer to the clipboard, - M-x - -(The kill buffer contains the last deletion from an editing command. Sort -of like an 'undo' buffer). - -You can also use the clipboard to redirect I/O, with /dev/clipboard as -the destination/source file. - - -NOTE: From version 6.00 onwards, the e_paste operation does NOT copy the -clipboard contents to the shell kill buffer. - - e_dosify_next ------------- diff --git a/win32/bogus.c b/win32/bogus.c index 5e34c4d8ee8c..22d9ba3af0de 100644 --- a/win32/bogus.c +++ b/win32/bogus.c @@ -1,4 +1,3 @@ -/*$Header: /p/tcsh/cvsroot/tcsh/win32/bogus.c,v 1.9 2008/10/11 12:47:39 christos Exp $*/ /*- * Copyright (c) 1980, 1991 The Regents of the University of California. * All rights reserved. diff --git a/win32/clip.c b/win32/clip.c index 1b7637ef2ec6..98704ebf9138 100644 --- a/win32/clip.c +++ b/win32/clip.c @@ -1,4 +1,3 @@ -/*$Header: /p/tcsh/cvsroot/tcsh/win32/clip.c,v 1.10 2014/08/13 23:39:34 amold Exp $*/ /*- * Copyright (c) 1980, 1991 The Regents of the University of California. * All rights reserved. @@ -39,446 +38,8 @@ #include "sh.h" #include "ed.h" -BOOL InitApplication(HINSTANCE); -BOOL InitInstance(HINSTANCE, int); -LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM); -HWND ghwndmain; - -extern int ctrl_handler(DWORD); -extern void c_insert(int); - -/* - * Creating a hidden window may not be strictly necessary on - * NT, but why tempt fate ? - * -amol - */ - -void clipper_thread(void) { - - MSG msg; - HINSTANCE hInstance = GetModuleHandle(NULL); - - - if (!InitApplication(hInstance)) { - return ; - } - - if (!InitInstance(hInstance, 0)) { - return ; - } - // Main message loop: - while (GetMessage(&msg, NULL, 0, 0)) { - TranslateMessage(&msg); - DispatchMessage(&msg); - } - if ( !ctrl_handler(CTRL_CLOSE_EVENT)) - init_clipboard(); - return; -} -void init_clipboard(void) { - HANDLE ht; - DWORD tid; - - ht = CreateThread(NULL,gdwStackSize, - (LPTHREAD_START_ROUTINE)clipper_thread, NULL,0,&tid); - - if (!ht) - abort(); - CloseHandle(ht); -} - -BOOL InitApplication(HINSTANCE hInstance) -{ - WNDCLASS wc; - - - // Fill in window class structure with parameters that describe - // the main window. - wc.style = CS_HREDRAW | CS_VREDRAW; - wc.lpfnWndProc = (WNDPROC)WndProc; - wc.cbClsExtra = 0; - wc.cbWndExtra = 0; - wc.hInstance = hInstance; - wc.hIcon = NULL;//LoadIcon (hInstance, szAppName); - wc.hCursor = NULL;//LoadCursor(NULL, IDC_ARROW); - wc.hbrBackground = (HBRUSH)IntToPtr(COLOR_WINDOW+1); - - wc.lpszMenuName = NULL; - wc.lpszClassName = "tcshclipboard"; - - return RegisterClass(&wc); -} - -// -// FUNCTION: InitInstance(HANDLE, int) -// -// PURPOSE: Saves instance handle and creates main window -// -// COMMENTS: -// -// In this function, we save the instance handle in a global variable and -// create and display the main program window. -// -BOOL InitInstance(HINSTANCE hInstance, int nCmdShow) { - HWND hWnd; - - - UNREFERENCED_PARAMETER(nCmdShow); - - hWnd = CreateWindow("tcshclipboard", "tcshclipboard", - WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, - NULL, NULL, hInstance, NULL); - - if (!hWnd) { - return (FALSE); - } - - UpdateWindow(hWnd); - ghwndmain = hWnd; - - return (TRUE); -} - -LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) -{ - - switch (message) { - - case WM_DESTROYCLIPBOARD: - break; - case WM_DESTROY: - PostQuitMessage(0); - break; - - default: - return (DefWindowProc(hWnd, message, wParam, lParam)); - } - return (0); -} - -CCRETVAL e_copy_to_clipboard(Char c) { - unsigned char *cbp; - Char *kp; - int err; - size_t len; - unsigned char *clipbuf; - HANDLE hclipbuf; - - UNREFERENCED_PARAMETER(c); - - if (!ghwndmain) - return (CC_ERROR); - - if (KillRingLen == 0) - return (CC_ERROR); - - len = Strlen(KillRing[YankPos].buf); - - hclipbuf = GlobalAlloc(GMEM_MOVEABLE|GMEM_DDESHARE, len+2); - if (!hclipbuf) - return (CC_ERROR); - clipbuf = (unsigned char*)GlobalLock(hclipbuf); - - if (!clipbuf){ - err = GetLastError(); - GlobalFree(hclipbuf); - return (CC_ERROR); - } - - kp = KillRing[YankPos].buf; - cbp = clipbuf; - - while(*kp != '\0') { - *cbp = (u_char)(*kp & CHAR); - cbp++;kp++; - } - *cbp = 0; - - GlobalUnlock(clipbuf); - - if (!OpenClipboard(ghwndmain)) - goto error; - - if (!EmptyClipboard()) - goto error; - - if (SetClipboardData(CF_TEXT,hclipbuf) != hclipbuf){ - err = GetLastError(); - goto error; - - } - - CloseClipboard(); - return (CC_NORM); -error: - GlobalFree(hclipbuf); - CloseClipboard(); - return (CC_ERROR); -} -CCRETVAL e_paste_from_clipboard(Char c) { - HANDLE hclip; - unsigned char *cbp; - Char *cp; - int len; - unsigned char *clipbuf; - - - - UNREFERENCED_PARAMETER(c); - - if (!ghwndmain) - return (CC_ERROR); - if (!IsClipboardFormatAvailable(CF_TEXT)) - return CC_ERROR; - - if (!OpenClipboard(ghwndmain)) - return CC_ERROR; - - - hclip = GetClipboardData(CF_TEXT); - if (hclip) { - clipbuf = (unsigned char*)GlobalLock(hclip); - if(!clipbuf) { - return CC_ERROR; - } - - cbp = clipbuf; - len = 0; - - while(*cbp && *cbp != '\r') { - len++; - cbp++; - } - cbp = clipbuf; - - cp = Cursor; - - c_insert(len); - - if (LastChar + len >= InputLim) - goto error; - - while(*cbp && *cbp !='\r' && (cp <LastChar) ) { - *cp = *cbp ; - cp++;cbp++; - } - Cursor = cp; - GlobalUnlock(hclip); - } - CloseClipboard(); - - return (CC_REFRESH); -error: - return (CC_ERROR); -} - -int is_dev_clipboard_active=0; -HANDLE ghdevclipthread; - -/* Reads from pipe and write to clipboard */ -void clip_writer_proc(HANDLE hinpipe) { - unsigned char *realbuf; - unsigned char *clipbuf; - unsigned char *ptr; - DWORD bread=0,spleft,err,i,rbsize; - DWORD ptrloc; - HANDLE hclipbuf; - - - rbsize = 4096; - realbuf = heap_alloc(rbsize); - ptr = realbuf; - ptrloc = 0; - spleft = rbsize; - - while(spleft) { - if (!ReadFile(hinpipe,ptr,spleft,&bread,NULL)) { - spleft = GetLastError(); - dprintf("hinpipe returend %d\n",spleft); - if (spleft == ERROR_BROKEN_PIPE) - break; - } - if (bread == 0) - break; - ptr += bread; - ptrloc += bread; - spleft -=bread; - - if (spleft <=0){ - u_char *tmp; - - rbsize <<=1; - - tmp = realbuf; - realbuf = heap_realloc(realbuf,rbsize); - if (!realbuf) { - realbuf = tmp; - break; - } - spleft += rbsize >> 1; - - ptr = realbuf+ptrloc; - - dprintf("updated size now %d, splef %d, ptrloc %d, ptr 0x%08x, realbuf 0x%08x\n",rbsize,spleft,ptrloc,ptr,realbuf); - } - } - CloseHandle(hinpipe); - - bread = rbsize-spleft; - - hclipbuf = GlobalAlloc(GMEM_MOVEABLE|GMEM_DDESHARE, bread+256); - if (!hclipbuf) { - is_dev_clipboard_active=0; - return; - } - clipbuf = (u_char*)GlobalLock(hclipbuf); - - if (!clipbuf){ - err = GetLastError(); - GlobalFree(hclipbuf); - is_dev_clipboard_active=0; - return ; - } - ptr = clipbuf; - for (i=0;i <bread;i++) { - - if (realbuf[i] == '\n' && (i >0 && realbuf[i-1] != '\r') ) - *ptr++ = '\r'; - - *ptr++ =realbuf[i]; - - if ((ptr - clipbuf) >= rbsize) - break; - } - *ptr=0; - - heap_free(realbuf); - - GlobalUnlock(clipbuf); - - if (!OpenClipboard(ghwndmain)) - goto error; - - if (!EmptyClipboard()) - goto error; - - if (SetClipboardData(CF_TEXT,hclipbuf) != hclipbuf){ - err = GetLastError(); - goto error; - - } - CloseClipboard(); - is_dev_clipboard_active=0; - return ; -error: - is_dev_clipboard_active=0; - GlobalFree(hclipbuf); - CloseClipboard(); -} -HANDLE create_clip_writer_thread(void) { - HANDLE hread,hwrite; - DWORD tid; - SECURITY_ATTRIBUTES secd; - - if (is_dev_clipboard_active) - return INVALID_HANDLE_VALUE; - secd.nLength=sizeof(secd); - secd.lpSecurityDescriptor=NULL; - secd.bInheritHandle=FALSE; - - if (!CreatePipe(&hread,&hwrite,&secd,0)) { - abort(); - } - is_dev_clipboard_active = 1; - ghdevclipthread = CreateThread(NULL,gdwStackSize, - (LPTHREAD_START_ROUTINE)clip_writer_proc, hread,0,&tid); -// CloseHandle(ht); - return hwrite; -} - -/* Read from clipboard and write to pipe */ -void clip_reader_proc(HANDLE houtpipe) { - - HANDLE hclip; - unsigned char *cbp; - unsigned char *clipbuf; - unsigned char * outbuf,*ptr; - DWORD bwrote, len; - DWORD obsize; - - obsize = 4096; - outbuf = heap_alloc(obsize); - if(!outbuf) { - return; - } - ptr = outbuf; - - - if (!IsClipboardFormatAvailable(CF_TEXT)) - goto done ; - - if (!OpenClipboard(ghwndmain)) - goto done ; - - - len = 0; - hclip = GetClipboardData(CF_TEXT); - if (hclip) { - clipbuf = (unsigned char*)GlobalLock(hclip); - if(!clipbuf) { - goto done; - } - - cbp = clipbuf; - - while(*cbp ) { - *ptr++ = *cbp++; - len++; - if (len == obsize) { - obsize <<= 1; - outbuf = heap_realloc(outbuf,obsize); - if (!outbuf) - break; - ptr = outbuf+len; - } - } - GlobalUnlock(hclip); - } - CloseClipboard(); - - if (!WriteFile(houtpipe,outbuf,len,&bwrote,NULL)) { - ; - } - CloseHandle(houtpipe); - heap_free(outbuf); - -done: - is_dev_clipboard_active=0; - return; -} -HANDLE create_clip_reader_thread(void) { - HANDLE hread,hwrite; - DWORD tid; - SECURITY_ATTRIBUTES secd; - - if (is_dev_clipboard_active) - return INVALID_HANDLE_VALUE; - - secd.nLength=sizeof(secd); - secd.lpSecurityDescriptor=NULL; - secd.bInheritHandle=FALSE; - - if (!CreatePipe(&hread,&hwrite,&secd,0)) { - abort(); - } - is_dev_clipboard_active = 1; - ghdevclipthread = CreateThread(NULL,gdwStackSize, - (LPTHREAD_START_ROUTINE)clip_reader_proc, hwrite,0,&tid); - return hread; -} - CCRETVAL e_dosify_next(Char c) { diff --git a/win32/console.c b/win32/console.c index 220d56eaea94..65e7922e06c5 100644 --- a/win32/console.c +++ b/win32/console.c @@ -1,4 +1,3 @@ -/*$Header: /p/tcsh/cvsroot/tcsh/win32/console.c,v 1.9 2006/08/27 01:13:28 amold Exp $*/ /*- * Copyright (c) 1980, 1991 The Regents of the University of California. * All rights reserved. diff --git a/win32/dirent.c b/win32/dirent.c index fe7e2507faa2..28d638bb1af6 100644 --- a/win32/dirent.c +++ b/win32/dirent.c @@ -1,4 +1,3 @@ -/*$Header: /p/tcsh/cvsroot/tcsh/win32/dirent.c,v 1.10 2014/08/13 23:39:34 amold Exp $*/ /*- * Copyright (c) 1980, 1991 The Regents of the University of California. * All rights reserved. diff --git a/win32/dirent.h b/win32/dirent.h index 95fb8b38dd5a..af8328f041d8 100644 --- a/win32/dirent.h +++ b/win32/dirent.h @@ -1,4 +1,3 @@ -/*$Header: /p/tcsh/cvsroot/tcsh/win32/dirent.h,v 1.6 2006/03/03 22:08:45 amold Exp $*/ /*- * Copyright (c) 1980, 1991 The Regents of the University of California. * All rights reserved. diff --git a/win32/fork.c b/win32/fork.c index 84ace76c7d46..9115b412ce2d 100644 --- a/win32/fork.c +++ b/win32/fork.c @@ -1,4 +1,3 @@ -/*$Header: /p/tcsh/cvsroot/tcsh/win32/fork.c,v 1.13 2014/08/17 02:56:37 amold Exp $*/ /*- * Copyright (c) 1980, 1991 The Regents of the University of California. * All rights reserved. @@ -167,7 +166,7 @@ int fork_init(void) { #ifdef _M_IX86 _old_exr = __fork_context[6]; __fork_context[6] =(int)GETEXCEPTIONREGIST();//tmp; -#endif _M_ALPHA +#endif // // Whee ! longjmp(__fork_context,1); @@ -213,7 +212,9 @@ int fork(void) { __hforkparent = CreateEvent(&sa,TRUE,FALSE,NULL); rc = setjmp(__fork_context); - + #if _M_AMD64 + ((_JUMP_BUFFER *)&__fork_context)->Frame = 0; //https://stackoverflow.com/questions/26605063/an-invalid-or-unaligned-stack-was-encountered-during-an-unwind-operation +#endif if (rc) { // child #ifdef _M_IX86 // diff --git a/win32/forkdata.h b/win32/forkdata.h index 5d3f30a37f4e..74d08ed28eed 100644 --- a/win32/forkdata.h +++ b/win32/forkdata.h @@ -1,4 +1,3 @@ -/*$Header: /p/tcsh/cvsroot/tcsh/win32/forkdata.h,v 1.4 2004/05/19 18:22:27 christos Exp $*/ /*- * Copyright (c) 1980, 1991 The Regents of the University of California. * All rights reserved. diff --git a/win32/globals.c b/win32/globals.c index 7129c9bc2d08..3bbc284dbaae 100644 --- a/win32/globals.c +++ b/win32/globals.c @@ -1,4 +1,3 @@ -/*$Header: /p/tcsh/cvsroot/tcsh/win32/globals.c,v 1.12 2014/08/13 23:39:34 amold Exp $*/ /*- * Copyright (c) 1980, 1991 The Regents of the University of California. * All rights reserved. diff --git a/win32/io.c b/win32/io.c index 0124f1b2a028..50a701ec9880 100644 --- a/win32/io.c +++ b/win32/io.c @@ -1,4 +1,3 @@ -/*$Header: /p/tcsh/cvsroot/tcsh/win32/io.c,v 1.9 2006/04/13 00:59:02 amold Exp $*/ /*- * Copyright (c) 1980, 1991 The Regents of the University of California. * All rights reserved. @@ -59,9 +58,9 @@ int consoleread(HANDLE , unsigned char * ,size_t ) ; INPUT_RECORD girec[2048]; unsigned short __nt_want_vcode=0,__nt_vcode=0; -HANDLE __h_con_alarm=0; -HANDLE __h_con_int=0; -HANDLE __h_con_hup=0; +HANDLE __h_con_alarm; +HANDLE __h_con_int; +HANDLE __h_con_hup; extern int NoNLSRebind; diff --git a/win32/nt.bind.c b/win32/nt.bind.c index 17e5a75910ca..7a8b9f4b8559 100644 --- a/win32/nt.bind.c +++ b/win32/nt.bind.c @@ -1,4 +1,3 @@ -/*$Header: /p/tcsh/cvsroot/tcsh/win32/nt.bind.c,v 1.6 2006/03/05 08:59:36 amold Exp $*/ /*- * Copyright (c) 1980, 1991 The Regents of the University of California. * All rights reserved. diff --git a/win32/nt.char.c b/win32/nt.char.c index f76bfefd9cb9..fa82bd8c1c0b 100644 --- a/win32/nt.char.c +++ b/win32/nt.char.c @@ -1,4 +1,3 @@ -/*$Header: /p/tcsh/cvsroot/tcsh/win32/nt.char.c,v 1.10 2008/10/11 12:47:39 christos Exp $*/ /*- * Copyright (c) 1980, 1991 The Regents of the University of California. * All rights reserved. diff --git a/win32/nt.const.c b/win32/nt.const.c index daee2881ee41..3316e80dc6bf 100644 --- a/win32/nt.const.c +++ b/win32/nt.const.c @@ -1,4 +1,3 @@ -/*$Header: /p/tcsh/cvsroot/tcsh/win32/nt.const.c,v 1.4 2003/02/08 20:03:29 christos Exp $*/ /* * nt.const.c: NT-specific String constants for tcsh. */ diff --git a/win32/nt.screen.c b/win32/nt.screen.c index 702591506cf5..6ced512fb267 100644 --- a/win32/nt.screen.c +++ b/win32/nt.screen.c @@ -1,4 +1,3 @@ -/*$Header: /p/tcsh/cvsroot/tcsh/win32/nt.screen.c,v 1.14 2006/03/14 01:22:57 mitr Exp $*/ /* * ed.screen.c: Editor/termcap-curses interface */ diff --git a/win32/nt.who.c b/win32/nt.who.c index 59ef39eec42d..5667ab1737b0 100644 --- a/win32/nt.who.c +++ b/win32/nt.who.c @@ -1,4 +1,3 @@ -/*$Header: /p/tcsh/cvsroot/tcsh/win32/nt.who.c,v 1.6 2006/03/05 08:59:36 amold Exp $*/ /*- * Copyright (c) 1980, 1991 The Regents of the University of California. * All rights reserved. diff --git a/win32/ntb1.c b/win32/ntb1.c index ccc54451c116..1bb073c734d8 100644 --- a/win32/ntb1.c +++ b/win32/ntb1.c @@ -1,4 +1,3 @@ -/*$Header: /p/tcsh/cvsroot/tcsh/win32/ntb1.c,v 1.4 2004/05/19 18:22:28 christos Exp $*/ /*- * Copyright (c) 1980, 1991 The Regents of the University of California. * All rights reserved. diff --git a/win32/ntb2.c b/win32/ntb2.c index 99a119917185..c4f5fb7c9ef7 100644 --- a/win32/ntb2.c +++ b/win32/ntb2.c @@ -1,4 +1,3 @@ -/*$Header: /p/tcsh/cvsroot/tcsh/win32/ntb2.c,v 1.4 2004/05/19 18:22:28 christos Exp $*/ /*- * Copyright (c) 1980, 1991 The Regents of the University of California. * All rights reserved. diff --git a/win32/ntfunc.c b/win32/ntfunc.c index 874b65f1ca99..a7da6e070ad4 100644 --- a/win32/ntfunc.c +++ b/win32/ntfunc.c @@ -1,4 +1,3 @@ -/*$Header: /p/tcsh/cvsroot/tcsh/win32/ntfunc.c,v 1.22 2016/08/12 14:54:41 amold Exp $*/ /*- * Copyright (c) 1980, 1991 The Regents of the University of California. * All rights reserved. @@ -67,8 +66,6 @@ struct biltins nt_bfunc[] = { #ifdef NTDBG { "debugbreak", dodebugbreak, 0, 0 }, #endif /* NTDBG */ - { "ps", dops, 0, 1 }, - { "shutdown", doshutdown, 0, 2 }, { "start", dostart, 1, INF }, { "title", dotitle, 1, INF }, }; diff --git a/win32/ntport.h b/win32/ntport.h index 3692d2f802db..5729e6886eb9 100644 --- a/win32/ntport.h +++ b/win32/ntport.h @@ -1,4 +1,3 @@ -/*$Header: /p/tcsh/cvsroot/tcsh/win32/ntport.h,v 1.15 2014/08/13 23:39:34 amold Exp $*/ /*- * Copyright (c) 1980, 1991 The Regents of the University of California. * All rights reserved. diff --git a/win32/ps.c b/win32/ps.c index bc81f1c954ee..46e80cedfe3c 100644 --- a/win32/ps.c +++ b/win32/ps.c @@ -1,4 +1,3 @@ -/*$Header: /p/tcsh/cvsroot/tcsh/win32/ps.c,v 1.9 2006/03/14 01:22:58 mitr Exp $*/ /*- * Copyright (c) 1980, 1991 The Regents of the University of California. * All rights reserved. @@ -40,69 +39,6 @@ #include <sh.h> #include <errno.h> - -#define REGKEY_PERF "software\\microsoft\\windows nt\\currentversion\\perflib" -#define REGSUBKEY_COUNTERS "Counters" -#define PROCESS_COUNTER "process" -#define PROCESSID_COUNTER "id process" - -typedef struct _pslist { - DWORD pid; - HANDLE hwnd; - char exename[MAX_PATH]; - char title[80]; -}pslist; - - -typedef BOOL (WINAPI *walker)(HANDLE,LPPROCESSENTRY32); -typedef HANDLE (WINAPI *create_snapshot)(DWORD,DWORD); -static walker proc32First; -static walker proc32Next; -static create_snapshot createSnapshot; - -typedef BOOL (WINAPI *enumproc)(DWORD *,DWORD,DWORD *); -typedef BOOL (WINAPI *enummod)(HANDLE,HMODULE*,DWORD,DWORD*); -typedef DWORD(WINAPI *getfilename_ex)(HANDLE,HANDLE , char*,DWORD); -typedef DWORD (WINAPI *getbasename)(HANDLE,HMODULE,char*,DWORD); -static enumproc enum_processes; -static enummod enum_process_modules; -static getfilename_ex getfilenameex; -static getbasename GetModuleBaseNameA; - -typedef DWORD (*plist_proc)(void); - -DWORD Win95Lister(void); -DWORD NTLister(void); - -plist_proc ProcessListFunc; -pslist *processlist; -static unsigned long numprocs, g_dowindows; - -static HMODULE hlib; - -extern DWORD gdwPlatform; -extern void make_err_str(int,char *,int); - -BOOL CALLBACK enum_wincb(HWND hwnd,LPARAM nump) { - - unsigned int i; - DWORD pid = 0; - - if (!GetWindowThreadProcessId(hwnd,&pid)) - return TRUE; - - for (i =0;i < nump;i++) { - if (processlist[i].pid == pid){ - processlist[i].hwnd = hwnd; - if (processlist[i].title[0] !=0) - break;; - GetWindowText(hwnd,processlist[i].title, - sizeof(processlist[i].title)); - break; - } - } - return TRUE; -} static HWND ghwndtokillbywm_close; BOOL CALLBACK enum_wincb2(HWND hwnd,LPARAM pidtokill) { DWORD pid = 0; @@ -124,248 +60,3 @@ int kill_by_wm_close(int pid) { ghwndtokillbywm_close = NULL; return 0; } -DWORD Win95Lister(void) { - - HANDLE hsnap; - PROCESSENTRY32 pe; - unsigned long nump =0; - - - hsnap = createSnapshot(TH32CS_SNAPPROCESS,0); - if (hsnap == INVALID_HANDLE_VALUE) - return 0; - - // if (processlist) - // p_free(processlist); - - pe.dwSize = sizeof(PROCESSENTRY32); - if (proc32First(hsnap,&pe) ) { - processlist = heap_alloc(100*sizeof(pslist)); - if (!processlist) - goto done; - - do { - StringCbCopy(processlist[nump].exename, - sizeof(processlist[nump].exename),pe.szExeFile); - - processlist[nump].title[0] = 0; - processlist[nump].pid = pe.th32ProcessID; - nump++; - }while(proc32Next(hsnap,&pe)); - } -done: - CloseHandle(hsnap); - - if (g_dowindows) { - EnumWindows(enum_wincb,(LPARAM)nump); - } - return nump; -} - -DWORD NTLister(void) { - - DWORD procs[200],dummy,ignore; - HANDLE hproc; - HMODULE hmod; - unsigned int i; - - - // if (processlist) - // p_free(processlist); - - if (!enum_processes(procs,sizeof(procs),&dummy) ) { - return 0; - } - - dummy = dummy/sizeof(DWORD); // number of entries filled - - processlist = heap_alloc(dummy*sizeof(pslist)); - if (!processlist){ - return 0; - } - - for(i=0 ; i< dummy;i++) { - processlist[i].pid = procs[i]; - processlist[i].title[0] = 0; - hproc = OpenProcess(PROCESS_QUERY_INFORMATION |PROCESS_VM_READ, - FALSE,procs[i]); - if (hproc) { - if (enum_process_modules(hproc,&hmod,sizeof(hmod),&ignore)) { - GetModuleBaseNameA(hproc,hmod, processlist[i].exename,MAX_PATH); - } - else - StringCbCopy(processlist[i].exename, - sizeof(processlist[i].exename),"(unknown)"); - CloseHandle(hproc); - } - else - StringCbCopy(processlist[i].exename, - sizeof(processlist[i].exename),"(unknown)"); - - } - if (g_dowindows) { - EnumWindows(enum_wincb,(LPARAM)dummy); - } - return dummy; -} - -void init_plister(void) { - - - hlib = LoadLibrary("kernel32.dll"); - if (!hlib) - return ; - - - ProcessListFunc = Win95Lister; - - proc32First = (walker)GetProcAddress(hlib,"Process32First"); - proc32Next = (walker)GetProcAddress(hlib,"Process32Next"); - createSnapshot= (create_snapshot)GetProcAddress(hlib, - "CreateToolhelp32Snapshot"); - - FreeLibrary(hlib); - if (!proc32First || !proc32Next || !createSnapshot) { - ProcessListFunc = NULL; - } -} -void dops(Char ** vc, struct command *c) { - - DWORD nump; - unsigned int i,k; - char **v; - - UNREFERENCED_PARAMETER(c); - - if (!ProcessListFunc) - return; - vc = glob_all_or_error(vc); - v = short2blk(vc); - blkfree(vc); - for (k = 0; v[k] != NULL ; k++){ - if ( v[k][0] == '-' ) { - if( (v[k][1] == 'W') || (v[k][1] == 'w')) - g_dowindows = 1; - } - } - blkfree((Char**)v); - nump = ProcessListFunc(); - - for(i=0; i< nump; i++) { - if (gdwPlatform == VER_PLATFORM_WIN32_NT) - xprintf("%6u %-20s %-30s\n",processlist[i].pid, - processlist[i].exename, - g_dowindows?processlist[i].title:""); - else - xprintf("0x%08x %-20s %-30s\n",processlist[i].pid, - processlist[i].exename, - g_dowindows?processlist[i].title:""); - } - g_dowindows =0; - - if (processlist) - heap_free(processlist); - -} -static char shutdown_usage[]= {"shutdown -[r|l][f] now\n-r reboots, -l logs\ - off the current user\n-f forces termination of running applications.\n\ - The default action is to shutdown without a reboot.\n\"now\" must be \ - specified to actually shutdown or reboot\n"}; - -void doshutdown(Char **vc, struct command *c) { - - unsigned int flags = 0; - unsigned char reboot,shutdown,logoff,shutdown_ok; - char **v; - char *ptr; - char errbuf[128]; - int k; - HANDLE hToken; - TOKEN_PRIVILEGES tp,tpPrevious; - LUID luid; - DWORD cbPrevious = sizeof(TOKEN_PRIVILEGES); - - UNREFERENCED_PARAMETER(c); - - if (gdwPlatform != VER_PLATFORM_WIN32_NT) { - stderror(ERR_SYSTEM,"shutdown","Sorry,not supported on win95"); - } - - shutdown_ok = reboot = shutdown = logoff = 0; - vc = glob_all_or_error(vc); - v = short2blk(vc); - blkfree(vc); - cleanup_push((Char **)v, blk_cleanup); - for (k = 0; v[k] != NULL ; k++){ - if ( v[k][0] == '-' ) { - ptr = v[k]; - ptr++; - while( ptr && *ptr) { - if (*ptr == 'f') - flags |= EWX_FORCE; - if (*ptr == 'r') - reboot =1; - else if (*ptr == 'l') - logoff =1; - else - stderror(ERR_SYSTEM,"Usage",shutdown_usage); - ptr++; - } - } - else if (!_stricmp(v[k],"now")) { - shutdown_ok = 1; - } - } - if (k == 0) - stderror(ERR_SYSTEM,"Usage",shutdown_usage); - if (!reboot && !logoff){ - flags |= EWX_SHUTDOWN; - shutdown = 1; - } - if (reboot && logoff ) - stderror(ERR_SYSTEM,"Usage",shutdown_usage); - if (reboot) - flags |= EWX_REBOOT; - if (logoff) - flags |= EWX_LOGOFF; - - if ((reboot || shutdown) && (!shutdown_ok) ) - stderror(ERR_SYSTEM,"shutdown","Specify \"now\" to really shutdown"); - - - if (!OpenProcessToken(GetCurrentProcess(), - TOKEN_ADJUST_PRIVILEGES| TOKEN_QUERY, - &hToken) ){ - make_err_str(GetLastError(),errbuf,128); - stderror(ERR_SYSTEM,"shutdown failed",errbuf); - } - - - if (!LookupPrivilegeValue(NULL,SE_SHUTDOWN_NAME,&luid)) { - make_err_str(GetLastError(),errbuf,128); - stderror(ERR_SYSTEM,"shutdown failed",errbuf); - } - tp.PrivilegeCount = 1; - tp.Privileges[0].Luid = luid; - tp.Privileges[0].Attributes = 0; - - if (!AdjustTokenPrivileges(hToken,FALSE,&tp,sizeof(tp),&tpPrevious, - &cbPrevious)){ - make_err_str(GetLastError(),errbuf,128); - stderror(ERR_SYSTEM,"shutdown failed",errbuf); - } - tpPrevious.PrivilegeCount = 1; - tpPrevious.Privileges[0].Luid = luid; - tpPrevious.Privileges[0].Attributes |= SE_PRIVILEGE_ENABLED; - - if (!AdjustTokenPrivileges(hToken,FALSE,&tpPrevious,cbPrevious,NULL, - NULL)){ - make_err_str(GetLastError(),errbuf,128); - stderror(ERR_SYSTEM,"shutdown failed",errbuf); - } - if ( !ExitWindowsEx(flags,0) ) { - make_err_str(GetLastError(),errbuf,128); - stderror(ERR_SYSTEM,"shutdown failed",errbuf); - } - cleanup_until((Char **)v); -} diff --git a/win32/signal.c b/win32/signal.c index c72107975f0c..a0b243646491 100644 --- a/win32/signal.c +++ b/win32/signal.c @@ -1,4 +1,3 @@ -/*$Header: /p/tcsh/cvsroot/tcsh/win32/signal.c,v 1.13 2014/08/13 23:39:34 amold Exp $*/ /*- * Copyright (c) 1980, 1991 The Regents of the University of California. * All rights reserved. diff --git a/win32/stdio.c b/win32/stdio.c index 47d977f76c4a..634879eb26d7 100644 --- a/win32/stdio.c +++ b/win32/stdio.c @@ -1,4 +1,3 @@ -/*$Header: /p/tcsh/cvsroot/tcsh/win32/stdio.c,v 1.11 2012/03/05 14:03:23 christos Exp $*/ /*- * Copyright (c) 1980, 1991 The Regents of the University of California. * All rights reserved. @@ -460,12 +459,6 @@ int nt_creat(const char *filename, int mode) { else if (!_stricmp(filename,"/dev/null") ){ filename = "NUL"; } - else if (!_stricmp(filename,"/dev/clipboard")) { - retval = create_clip_writer_thread(); - if (retval == INVHL) - return -1; - goto get_fd; - } retval = CreateFile(filename, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, @@ -478,7 +471,6 @@ int nt_creat(const char *filename, int mode) { errno = EACCES; return -1; } -get_fd: fd = __nt_open_osfhandle((intptr_t)retval,_O_BINARY); if (fd <0) { //should never happen @@ -516,10 +508,6 @@ int nt_open(const char *filename, int perms,...) { else if (!lstrcmp(filename,"/dev/null") ){ filename = "NUL"; } - else if (!_stricmp(filename,"/dev/clipboard")) { - retval = create_clip_reader_thread(); - goto get_fd; - } security.nLength = sizeof(security); security.lpSecurityDescriptor = NULL; security.bInheritHandle = FALSE; @@ -577,7 +565,6 @@ int nt_open(const char *filename, int perms,...) { if (perms & O_APPEND) { SetFilePointer(retval,0,NULL,FILE_END); } -get_fd: fd = __nt_open_osfhandle((intptr_t)retval,_O_BINARY); if (fd <0) { //should never happen diff --git a/win32/support.c b/win32/support.c index acc0f4e906f9..e76dbfceed30 100644 --- a/win32/support.c +++ b/win32/support.c @@ -1,4 +1,3 @@ -/*$Header: /p/tcsh/cvsroot/tcsh/win32/support.c,v 1.16 2014/08/17 02:56:37 amold Exp $*/ /*- * Copyright (c) 1980, 1991 The Regents of the University of California. * All rights reserved. @@ -92,15 +91,12 @@ void nt_init(void) { init_hb_subst(); setlocale(LC_ALL,""); init_shell_dll(); - init_plister(); fork_init(); - init_clipboard(); return; } void nt_cleanup(void){ nt_term_cleanup(); nt_cleanup_signals(); - cleanup_netbios(); } void caseify_pwd(char *curwd) { char *sp, *dp, p,*s; @@ -454,19 +450,6 @@ re_cp: (void)GetExitCodeProcess(pi.hProcess,&exitcode); CloseHandle(pi.hProcess); CloseHandle(pi.hThread); - /* - * If output was redirected to /dev/clipboard, - * we need to close the pipe handles - */ - if (is_dev_clipboard_active) { - CloseHandle((HANDLE)_get_osfhandle(0)); - CloseHandle((HANDLE)_get_osfhandle(1)); - CloseHandle((HANDLE)_get_osfhandle(2)); - CloseHandle(si.hStdInput); - CloseHandle(si.hStdOutput); - CloseHandle(si.hStdError); - WaitForSingleObject(ghdevclipthread,60*1000); - } ExitProcess(exitcode); } } @@ -544,6 +527,7 @@ void init_wow64(void) { FreeLibrary(hlib); return; } +#pragma warning(suppress:28278) if (!pfnIsWow64(GetCurrentProcess(),&bIsWow64Process) ) bIsWow64Process = FALSE; @@ -836,7 +820,7 @@ char *concat_args_and_quote(char **args, char **poriginalPtr,char **cstr, if (arglen + cmdlen +4 > *cmdsize) { // +4 is if we have to quote - tempptr = heap_realloc(*poriginalPtr,*cmdsize<<1); + tempptr = heap_realloc(*poriginalPtr,(long long)(*cmdsize)<<1LL); if(!tempptr) return NULL; @@ -862,7 +846,7 @@ char *concat_args_and_quote(char **args, char **poriginalPtr,char **cstr, while(rc == ERROR_BUFFER_OVERFLOW) { char *tmp = tempquotedbuf; - tempquotedbuf = heap_realloc(tempquotedbuf,tqlen <<1); + tempquotedbuf = heap_realloc(tempquotedbuf,(long long)tqlen <<1); if(!tempquotedbuf) { heap_free(tmp); return NULL; diff --git a/win32/version.h b/win32/version.h index 44d425764877..49831a8fc281 100644 --- a/win32/version.h +++ b/win32/version.h @@ -1,4 +1,3 @@ -/*$Header: /p/tcsh/cvsroot/tcsh/win32/version.h,v 1.24 2008/09/10 20:34:21 amold Exp $*/ #ifndef VERSION_H #define VERSION_H |