1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
-
+
|
/*
* tclWinFCmd.c
*
* This file implements the Windows specific portion of file manipulation
* subcommands of the "file" command.
*
* Copyright (c) 1996-1998 Sun Microsystems, Inc.
*
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
* RCS: @(#) $Id: tclWinFCmd.c,v 1.32 2003/01/16 19:01:59 mdejong Exp $
* RCS: @(#) $Id: tclWinFCmd.c,v 1.33 2003/01/25 14:11:33 mdejong Exp $
*/
#include "tclWinInt.h"
/*
* The following constants specify the type of callback when
* TraverseWinTree() calls the traverseProc()
|
| ︙ | | |
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
|
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
|
-
-
-
-
+
+
+
+
+
+
+
+
|
{GetWinFileAttributes, SetWinFileAttributes},
{GetWinFileAttributes, SetWinFileAttributes},
{GetWinFileLongName, CannotSetAttribute},
{GetWinFileAttributes, SetWinFileAttributes},
{GetWinFileShortName, CannotSetAttribute},
{GetWinFileAttributes, SetWinFileAttributes}};
#ifdef HAVE_NO_SEH
static void *ESP;
static void *EBP;
#endif /* HAVE_NO_SEH */
#if defined(HAVE_NO_SEH) && defined(TCL_MEM_DEBUG)
static void *INITIAL_ESP,
*INITIAL_EBP,
*INITIAL_HANDLER,
*RESTORED_ESP,
*RESTORED_EBP,
*RESTORED_HANDLER;
#endif /* HAVE_NO_SEH && TCL_MEM_DEBUG */
/*
* Prototype for the TraverseWinTree callback function.
*/
typedef int (TraversalProc)(CONST TCHAR *srcPtr, CONST TCHAR *dstPtr,
int type, Tcl_DString *errorPtr);
|
| ︙ | | |
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
|
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
|
+
-
-
+
+
+
+
+
+
+
+
-
+
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
|
/*
* The MoveFile API would throw an exception under NT
* if one of the arguments is a char block device.
*/
#ifdef HAVE_NO_SEH
# ifdef TCL_MEM_DEBUG
__asm__ __volatile__ (
"movl %esp, _ESP" "\n\t"
"movl %ebp, _EBP");
"movl %%esp, %0" "\n\t"
"movl %%ebp, %1" "\n\t"
"movl %%fs:0, %2" "\n\t"
: "=m"(INITIAL_ESP),
"=m"(INITIAL_EBP),
"=r"(INITIAL_HANDLER) );
# endif /* TCL_MEM_DEBUG */
__asm__ __volatile__ (
"pushl %ebp" "\n\t"
"pushl $__except_dorenamefile_handler" "\n\t"
"pushl %fs:0" "\n\t"
"mov %esp, %fs:0");
"movl %esp, %fs:0");
#else
__try {
#endif /* HAVE_NO_SEH */
if ((*tclWinProcs->moveFileProc)(nativeSrc, nativeDst) != FALSE) {
retval = TCL_OK;
}
#ifdef HAVE_NO_SEH
__asm__ __volatile__ (
"jmp dorenamefile_pop" "\n"
"dorenamefile_reentry:" "\n\t"
"movl _ESP, %esp" "\n\t"
"movl _EBP, %ebp");
"jmp dorenamefile_pop" "\n"
"dorenamefile_reentry:" "\n\t"
"movl %%fs:0, %%eax" "\n\t"
"movl 0x8(%%eax), %%esp" "\n\t"
"movl 0x8(%%esp), %%ebp" "\n"
"dorenamefile_pop:" "\n\t"
"movl (%%esp), %%eax" "\n\t"
"movl %%eax, %%fs:0" "\n\t"
"add $12, %%esp" "\n\t"
:
:
: "%eax");
# ifdef TCL_MEM_DEBUG
__asm__ __volatile__ (
"dorenamefile_pop:" "\n\t"
"mov (%esp), %eax" "\n\t"
"mov %eax, %fs:0" "\n\t"
"add $8, %esp");
"movl %%esp, %0" "\n\t"
"movl %%ebp, %1" "\n\t"
"movl %%fs:0, %2" "\n\t"
: "=m"(RESTORED_ESP),
"=m"(RESTORED_EBP),
"=r"(RESTORED_HANDLER) );
if (INITIAL_ESP != RESTORED_ESP)
panic("ESP restored incorrectly");
if (INITIAL_EBP != RESTORED_EBP)
panic("EBP restored incorrectly");
if (INITIAL_HANDLER != RESTORED_HANDLER)
panic("HANDLER restored incorrectly");
# endif /* TCL_MEM_DEBUG */
#else
} __except (EXCEPTION_EXECUTE_HANDLER) {}
#endif /* HAVE_NO_SEH */
/*
* Avoid using control flow statements in the SEH guarded block!
*/
|
| ︙ | | |
446
447
448
449
450
451
452
453
454
455
456
457
458
459
|
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
|
+
+
|
struct _EXCEPTION_RECORD *ExceptionRecord,
void *EstablisherFrame,
struct _CONTEXT *ContextRecord,
void *DispatcherContext)
{
__asm__ __volatile__ (
"jmp dorenamefile_reentry");
/* Nuke compiler warning about unused static function */
_except_dorenamefile_handler(NULL, NULL, NULL, NULL);
return 0; /* Function does not return */
}
#endif /* HAVE_NO_SEH */
/*
*---------------------------------------------------------------------------
*
|
| ︙ | | |
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
|
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
|
+
-
-
+
+
+
+
+
+
+
+
-
+
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
|
/*
* The CopyFile API would throw an exception under NT if one
* of the arguments is a char block device.
*/
#ifdef HAVE_NO_SEH
# ifdef TCL_MEM_DEBUG
__asm__ __volatile__ (
"movl %esp, _ESP" "\n\t"
"movl %ebp, _EBP");
"movl %%esp, %0" "\n\t"
"movl %%ebp, %1" "\n\t"
"movl %%fs:0, %2" "\n\t"
: "=m"(INITIAL_ESP),
"=m"(INITIAL_EBP),
"=r"(INITIAL_HANDLER) );
# endif /* TCL_MEM_DEBUG */
__asm__ __volatile__ (
"pushl %ebp" "\n\t"
"pushl $__except_docopyfile_handler" "\n\t"
"pushl %fs:0" "\n\t"
"mov %esp, %fs:0");
"movl %esp, %fs:0");
#else
__try {
#endif /* HAVE_NO_SEH */
if ((*tclWinProcs->copyFileProc)(nativeSrc, nativeDst, 0) != FALSE) {
retval = TCL_OK;
}
#ifdef HAVE_NO_SEH
__asm__ __volatile__ (
"jmp docopyfile_pop" "\n"
"docopyfile_reentry:" "\n\t"
"movl _ESP, %esp" "\n\t"
"movl _EBP, %ebp");
"jmp docopyfile_pop" "\n"
"docopyfile_reentry:" "\n\t"
"movl %%fs:0, %%eax" "\n\t"
"movl 0x8(%%eax), %%esp" "\n\t"
"movl 0x8(%%esp), %%ebp" "\n"
"docopyfile_pop:" "\n\t"
"movl (%%esp), %%eax" "\n\t"
"movl %%eax, %%fs:0" "\n\t"
"add $12, %%esp" "\n\t"
:
:
: "%eax");
# ifdef TCL_MEM_DEBUG
__asm__ __volatile__ (
"docopyfile_pop:" "\n\t"
"mov (%esp), %eax" "\n\t"
"mov %eax, %fs:0" "\n\t"
"add $8, %esp");
"movl %%esp, %0" "\n\t"
"movl %%ebp, %1" "\n\t"
"movl %%fs:0, %2" "\n\t"
: "=m"(RESTORED_ESP),
"=m"(RESTORED_EBP),
"=r"(RESTORED_HANDLER) );
if (INITIAL_ESP != RESTORED_ESP)
panic("ESP restored incorrectly");
if (INITIAL_EBP != RESTORED_EBP)
panic("EBP restored incorrectly");
if (INITIAL_HANDLER != RESTORED_HANDLER)
panic("HANDLER restored incorrectly");
# endif /* TCL_MEM_DEBUG */
#else
} __except (EXCEPTION_EXECUTE_HANDLER) {}
#endif /* HAVE_NO_SEH */
/*
* Avoid using control flow statements in the SEH guarded block!
*/
|
| ︙ | | |
600
601
602
603
604
605
606
607
608
609
610
611
612
613
|
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
|
+
|
struct _EXCEPTION_RECORD *ExceptionRecord,
void *EstablisherFrame,
struct _CONTEXT *ContextRecord,
void *DispatcherContext)
{
__asm__ __volatile__ (
"jmp docopyfile_reentry");
_except_docopyfile_handler(NULL,NULL,NULL,NULL);
return 0; /* Function does not return */
}
#endif /* HAVE_NO_SEH */
/*
*---------------------------------------------------------------------------
*
|
| ︙ | | |
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
|
1889
1890
1891
1892
1893
1894
1895
|
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
|
Tcl_ListObjAppendElement(NULL, resultPtr, elemPtr);
}
}
Tcl_IncrRefCount(resultPtr);
return resultPtr;
}
#ifdef HAVE_NO_SEH
/*
* This method exists only to stop the compiler from emitting
* warnings about variables and methods accessed only from asm.
*/
static void squelch_warnings()
{
void *ptr;
ptr = _except_dorenamefile_handler;
ptr = _except_docopyfile_handler;
ESP = 0;
EBP = 0;
squelch_warnings();
}
#endif /* HAVE_NO_SEH */
|