home *** CD-ROM | disk | FTP | other *** search
/ ftp.wwiv.com / ftp.wwiv.com.zip / ftp.wwiv.com / pub / MISC / ARTFIX09.ZIP / TIMED / TIM386.PSC < prev    next >
Text File  |  1998-05-05  |  15KB  |  357 lines

  1. ;
  2. ; ==========================================================================
  3. ;            Patch script for timEd/386 v1.10  (DOS-386 Version)
  4. ;                      Version 1.00 - 05. May 1998
  5. ;
  6. ;     Created by Wilfried Brinkmann, Fido 2:2448/6001, e-mail tsc@cww.de
  7. ; ==========================================================================
  8. ;
  9. ; NOTE: This patch script will modify timedp.exe and add a lot of new
  10. ;       routines to handle the necessary modifications.
  11. ;       There is no additional program required to run the patched
  12. ;       tim386.exe!
  13. ;
  14. ;       If you wish to understand this patch, you will want to see what
  15. ;       the added service routines do. The source code is added as comment.
  16. ;
  17. SIZE 366498                ; filesize tim386.exe
  18. ;
  19. COPY UNPATCH\TIM386.EXE    ; make a backup copy in <TimedPath>\unpatch
  20. ;
  21. ; --------------------------------------------------------------------------
  22. ; Fix handling of a UNIX time_t timestamp from 2038 on. Previously, it
  23. ; was treated as a signed long (which led to an overflow on 18/01/2038).
  24. ; Now we treat it as an unsigned long.
  25. ;
  26. ; The fix itself is a little bit tricky ;-)
  27. ; I must insert a call in a 3 byte wide area (cwd, idiv ecx), but a normal
  28. ; call has 5 bytes. So I have made a special service at the routine entry.
  29. ; The first normal call returns a virtual call address for the division
  30. ; service in esi and a virtual address in edi for the final exit service.
  31. ; At the same time, the first (unsigned) divison is executed.
  32. ;
  33. VER 38D61 53+              ; push     ebx
  34.           51+              ; push     ecx
  35.           52+              ; push     edx
  36.           8B18+            ; mov      ebx,[eax]
  37.           89D8+            ; mov      eax,ebx
  38.           B93C000000+      ; mov      ecx,0000003C
  39.           99+              ; cwd
  40.           F7F9             ; idiv     ecx
  41.           ;
  42. CHA $     60+              ; pushad                ; push all regs
  43.           8B18+            ; mov      ebx,[eax]
  44.           89D8+            ; mov      eax,ebx
  45.           B93C000000+      ; mov      ecx,0000003C
  46.           ;
  47.           ; now call the first service to get the virtual address
  48.           ; (esi - unsigned division, edi - exit service)
  49.           ;
  50.           E800ADFFFF       ; call     -00005300 (00033A70)
  51. ;
  52. VER 38D78 99+              ; cwd
  53.           F7F9             ; idiv     ecx
  54. CHA $     90+              ; nop                   ; call unsigned division
  55.           FFD6             ; call     esi          ; (addr in esi)
  56. ;
  57. VER 38D7D 99+              ; cwd
  58.           F7F9             ; idiv     ecx
  59. CHA $     90+              ; nop
  60.           FFD6             ; call     esi
  61. ;
  62. VER 38D88 99+              ; cwd
  63.           F7F9             ; idiv     ecx
  64. CHA $     90+              ; nop
  65.           FFD6             ; call     esi
  66. ;
  67. VER 38D92 99+              ; cwd
  68.           F7F9             ; idiv     ecx
  69. CHA $     90+              ; nop
  70.           FFD6             ; call     esi
  71. ;
  72. VER 38D9D 99+              ; cwd
  73.           F7F9             ; idiv     ecx
  74. CHA $     90+              ; nop
  75.           FFD6             ; call     esi
  76. ;
  77. VER 38DAA 99+              ; cwd
  78.           F7F9             ; idiv     ecx
  79. CHA $     90+              ; nop
  80.           FFD6             ; call     esi
  81. ;
  82. VER 38DBA 99+              ; cwd
  83.           F7F9             ; idiv     ecx
  84. CHA $     90+              ; nop
  85.           FFD6             ; call     esi
  86. ;
  87. VER 38E8E 5A+              ; pop      edx
  88.           59+              ; pop      ecx
  89.           5B               ; pop      ebx
  90.           ;
  91. CHA $     FFD7+            ; call     edi          ; call final exit service
  92.           61               ; popad                 ; and restore all regs
  93. ;
  94. ; My special handling routine ...
  95. ; At the first entry this servive will returns the virtual call address
  96. ; for the unsigned division in esi and the final call address in edi.
  97. ; After the virtual address is calculated, the first divison is made.
  98. ;
  99. VER 33A70 00000000000000000000000000000000+
  100.           0000000000000000000000
  101.           ;
  102.           ; local call to get the entry address in esi
  103.           ;
  104. CHA $     E80D000000+      ; call     +0000000D (@33A82)
  105.           ;
  106.           89F7+            ; mov      edi,esi      ; addr from stack to esi
  107.           83C608+          ; add      esi,08       ; offs to idiv service
  108.           83C711+          ; add      edi,11       ; offs to exit service
  109.           ;
  110.           ; unsigned division service (call esi entry point)
  111.           ;
  112.           31D2+            ; xor      edx,edx      ; clear edx to make
  113.           F7F9+            ; idiv     ecx          ; unsigned divison
  114.           C3+              ; ret
  115.           ;
  116. @33A82:   8B3424+          ; mov      esi,[esp]    ; entry addr to esi
  117.           C3+              ; ret
  118.           ;
  119.           ; final exit servive (call edi entry point)
  120.           ;
  121.           89442420+        ; mov      [esp+20],eax ; store changed eax at
  122.           C3               ; ret                   ; old eax pos on stack.
  123.  
  124. ;
  125. ; ---------------------------------------------------------------------------
  126. ; Fix date display of the message info screen ('110 instead of '10 and so on)
  127. ;
  128. VER 2EACB FF31+            ; push     dword ptr [ecx]
  129.           FF7104+          ; push     dword ptr [ecx+04]
  130.           FF7108+          ; push     dword ptr [ecx+08]
  131.           8B4110+          ; mov      eax,[ecx+10]
  132.           FF7114           ; push     dword ptr [ecx+14]
  133.           ;
  134. CHA $     E8B7E80000+      ; call     +0000E8B7 (0003D387)
  135.           8B4110+          ; mov      eax,[ecx+10]
  136.           90+              ; nop
  137.           90+              ; nop
  138.           90+              ; nop
  139.           90+              ; nop
  140.           90+              ; nop
  141.           90               ; nop
  142. ;
  143. ; --------------------------------------------------------------------------
  144. ; Fix three digit year in the FTSC date field in the squish message base
  145. ; ("100" instead of "00"). Previously, a three digit number was pushed
  146. ; to the stack from 2000 on.
  147. ;
  148. VER 3CC71 FF30+            ; push     dword ptr [eax]
  149.           FF7004+          ; push     dword ptr [eax+04]
  150.           8B5010+          ; mov      edx,[eax+10]
  151.           FF7008+          ; push     dword ptr [eax+08]
  152.           C1E202+          ; shl      edx,02
  153.           FF7014           ; push     dword ptr [eax+14]
  154.           ;
  155. CHA $     91+              ; xchg     ecx,eax
  156.           E810070000+      ; call     +00000710 (0003D387)
  157.           91+              ; xchg     ecx,eax
  158.           8B5010+          ; mov      edx,[eax+10]
  159.           C1E202+          ; shl      edx,02
  160.           90+              ; nop
  161.           90+              ; nop
  162.           90+              ; nop
  163.           90               ; nop
  164. ;
  165. ; --------------------------------------------------------------------------
  166. ; Fix three digit year in the FTSC date field in *.MSG files
  167. ; ("100" instead of "00"). Previously, a three digit number was pushed
  168. ; to the stack from 2000 on.
  169. ;
  170. VER 414A1 FF30+            ; push     dword ptr [eax]
  171.           FF7004+          ; push     dword ptr [eax+04]
  172.           8B5010+          ; mov      edx,[eax+10]
  173.           FF7008+          ; push     dword ptr [eax+08]
  174.           C1E202+          ; shl      edx,02
  175.           FF7014           ; push     dword ptr [eax+14]
  176.           ;
  177. CHA $     91+              ; xchg     ecx,eax
  178.           E8E0BEFFFF+      ; call     -00004120 (0003D387)
  179.           91+              ; xchg     ecx,eax
  180.           8B5010+          ; mov      edx,[eax+10]
  181.           C1E202+          ; shl      edx,02
  182.           90+              ; nop
  183.           90+              ; nop
  184.           90+              ; nop
  185.           90               ; nop
  186. ;
  187. ; The added routine for the three above patches. (info scrn, squish, *.msg)
  188. ; This routine is called when writing a FTSC date stamp into a *.squish or
  189. ; *.msg base and writing the info screen. It prevents the 2 digit date field
  190. ; from spilling (without the modulo 100 operation, "100" would be written
  191. ; there in the year 2000 instead of 00).
  192. ;
  193. VER 3D387 0000000000000000000000000000000000000000000+
  194.           00000000000000000000000000000
  195.           ;
  196. CHA $     FF7104+          ; push     dword ptr [ecx+04]
  197.           FF7108+          ; push     dword ptr [ecx+08]
  198.           50+              ; push     eax          ; room for two values
  199.           50+              ; push     eax
  200.           51+              ; push     ecx
  201.           52+              ; push     edx
  202.           8B4114+          ; mov      eax,[ecx+14] ; get year
  203.           31C9+            ; xor      ecx,ecx
  204.           B164+            ; mov      cl,64
  205.           99+              ; cwd
  206.           F7F9+            ; idiv     ecx          ; modulo 100
  207.           8954240C+        ; mov      [esp+0C],edx ; save year on stack
  208.           5A+              ; pop      edx
  209.           59+              ; pop      ecx
  210.           8B01+            ; mov      eax,[ecx]    ; get value to push
  211.           87442410+        ; xchg     [esp+10],eax ; swap ret addr/eax
  212.           870424+          ; xchg     [esp],eax    ; swap eax/ret addr
  213.           C3               ; ret
  214.  
  215. ;
  216. ; ---------------------------------------------------------------------------
  217. ; Fix interpretation of a two digit year number when reading Squish and
  218. ; *.MSG style message bsaes. Previously, it was always interpreted as 19xx,
  219. ; Now, we use the following logic: 19xx if xx>=80, 20xx if xx<80
  220. ;
  221. VER 48B8B 83E850+          ; sub      eax,50
  222.           30E4             ; xor      ah,ah
  223.           ;
  224. CHA $     E81B48FFFF       ; call     -0000B7E5 (0003D3AB)
  225. ;
  226. ; Convert a two digit year number that is stored in eax into a DOS time
  227. ; compliant year number (which gives the number of years that have been passed
  228. ; since 1980). The method we use is save until 2080. Prevent wrong binary
  229. ; timestamps (TimEd derives them from the two digit FTSC date) in Squish and
  230. ; MSG areas.
  231. ;
  232. VER 3D3AB 0000000000000000000000
  233.           ;
  234. CHA $     83E850+          ; sub      eax,50       ; sub 80
  235.           7703+            ; jnbe     +03 (@3D2B3) ; no overflow, done
  236.           83C064+          ; add      eax,64       ; else add 100
  237. @3D3B3:   30E4+            ; xor      ah,ah
  238.           C3               ; ret
  239.  
  240. ;
  241. ; --------------------------------------------------------------------------
  242. ; Fix incorrect interpretation of a hudson time stamp which led to
  243. ; totally wrong display of a hudson message date after 2000.
  244. ;
  245. VER 3E903 0FB745F4+        ; movzx    eax,[ebp-0C]
  246.           8945E0           ; mov      [ebp-20],eax
  247.  
  248. CHA $     E8677EFFFF+      ; call     -00008199 (0003676F)
  249.           90+              ; nop
  250.           90               ; nop
  251. ;
  252. ; This routine is called when reading a message from the Hudson HMB.
  253. ; The date that is in [ebp-0c] is a two digit year number, but we want
  254. ; to have a "tm.tm-year" style year number in eax. Therefore, we check
  255. ; if the value is smaller than 80, and if so, we assume that it is in
  256. ; the 21st century and therefore add 100 to it. This makes HMB save
  257. ; until 31-12-2079.
  258. ;
  259. VER 3676F 00000000000000000000000000000000
  260.           ;
  261. CHA $     0FB745F4+        ; movzx    eax,[ebp-0C]
  262.           83F850+          ; cmp      eax,50
  263.           7703+            ; jnbe     +03 (0003322C)
  264.           83C064+          ; add      eax,64
  265.           8945E0+          ; mov      [ebp-20],eax
  266.           C3               ; ret
  267.  
  268. ;
  269. ; --------------------------------------------------------------------------
  270. ; Fix three digit year in the textual date field in the Hudson HMB
  271. ; ("100" instead of "00"). Previously, a three digit number was pushed
  272. ; to the stack from 2000 on.
  273. ;
  274. VER 3EDF8 FF7014+          ; push     dword ptr [eax+14]
  275.           89C1             ; mov      ecx,eax
  276.           ;
  277. CHA $     E88279FFFF       ; call     -0000867E (0003677F)
  278. ;
  279. ; The routine that has been added for the patch from above (hudson fix).
  280. ; This routine is called when writing a FTSC date stamp into a hudson base.
  281. ; It prevents the 2 digit date field from spilling (without the modulo 100
  282. ; operation, "100" would be written there in the year 2000 instead of 00).
  283. ;
  284. VER 3677F 00000000000000000000000000000+
  285.           0000000000000000000
  286.           ;
  287. CHA $     50+              ; push     eax
  288.           8B4014+          ; mov      eax,[eax+14] ; get year
  289.           52+              ; push     edx
  290.           31C9+            ; xor      ecx,ecx
  291.           B164+            ; mov      cl,64
  292.           99+              ; cwd
  293.           F7F9+            ; idiv     ecx          ; modulo 100
  294.           92+              ; xchg     edx,eax
  295.           5A+              ; pop      edx
  296.           87442404+        ; xchg     [esp+04],eax ; swap year/ret addr
  297.           870424+          ; xchg     [esp],eax    ; swap ret addr/eax
  298.           89C1+            ; mov      ecx,eax
  299.           C3               ; ret
  300.  
  301. ;
  302. ; --------------------------------------------------------------------------
  303. ; Fix incorrect dates in replies generated with a template containing
  304. ; the %year token.  Previously, a three digit year number was pushed to
  305. ; the stack.
  306. ;
  307. VER 254B0 8B45E8+          ; mov      eax,[ebp-18]
  308.           FF7014           ; push     dword ptr [eax+14]
  309.           ;
  310. CHA $     E892120100+      ; call     +00011292 (00036747)
  311.           90               ; nop
  312. ;
  313. ; This routine is called from the patch from above when writing the day number
  314. ; for a %year variable in a message template. We have patched the executable
  315. ; to use %4.4i instead of 19%2.2i as sprintf format string, so we have to
  316. ; push a four digit year number now.
  317. ;
  318. VER 36747 0000000000000000000000000000000000000000+
  319.           0000000000000000000000000000000000000000
  320.           ;
  321. CHA $     8B45E8+          ; mov      eax,[ebp-18]
  322.           50+              ; push     eax
  323.           8B4014+          ; mov      eax,[eax+14] ; get year
  324.           51+              ; push     ecx
  325.           52+              ; push     edx
  326.           31C9+            ; xor      ecx,ecx
  327.           B164+            ; mov      cl,64        ; modulo 100
  328.           99+              ; cwd
  329.           F7F9+            ; idiv     ecx
  330.           81C26C070000+    ; add      edx,0000076C ; add 1900
  331.           09C0+            ; or       eax,eax      ; was year > 99 ?
  332.           7403+            ; jz       +03 (@36764) ; no, done
  333.           83C264+          ; add      edx,64       ; else add 100
  334. @36764:   92+              ; xchg     edx,eax
  335.           5A+              ; pop      edx
  336.           59+              ; pop      ecx
  337.           87442404+        ; xchg     [esp+04],eax ; swap year/ret addr
  338.           870424+          ; xchg     [esp],eax    ; swap ret addr/eax
  339.           C3               ; ret
  340.           ;
  341. VER 5200E 313925322E326900 ; db "19%2.2i",0
  342.           ;
  343. CHA $     25342E3469000000 ; db "%4.4i",0,0,0
  344.  
  345. ;
  346. ; --------------------------------------------------------------------------
  347. ; Patch the Tearline and other places to announce version "1.10.y2k"
  348. ; intead of "1.10".
  349. ;
  350. VER 551DE 00000000         ; db 0,0,0,0
  351.           ;
  352. CHA $     2E79326B         ; db ".y2k"
  353. ;
  354. ; Done!
  355. ;
  356.  
  357.