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

  1. ;
  2. ; ==========================================================================
  3. ;               Patch script for timEd/2 v1.10 (OS/2 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. ;       timedp.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 326162                ; filesize timedp.exe
  18. ;
  19. COPY UNPATCH\TIMEDP.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 into 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 35555 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.           E8BEAFFFFF       ; call     -00005042 (00030522)
  51. ;
  52. VER 3556C 99+              ; cwd
  53.           F7F9             ; idiv     ecx
  54. CHA $     90+              ; nop                   ; call unsigned division
  55.           FFD6             ; call     esi          ; (addr in esi)
  56. ;
  57. VER 35571 99+              ; cwd
  58.           F7F9             ; idiv     ecx
  59. CHA $     90+              ; nop
  60.           FFD6             ; call     esi
  61. ;
  62. VER 3557C 99+              ; cwd
  63.           F7F9             ; idiv     ecx
  64. CHA $     90+              ; nop
  65.           FFD6             ; call     esi
  66. ;
  67. VER 35586 99+              ; cwd
  68.           F7F9             ; idiv     ecx
  69. CHA $     90+              ; nop
  70.           FFD6             ; call     esi
  71. ;
  72. VER 35591 99+              ; cwd
  73.           F7F9             ; idiv     ecx
  74. CHA $     90+              ; nop
  75.           FFD6             ; call     esi
  76. ;
  77. VER 3559E 99+              ; cwd
  78.           F7F9             ; idiv     ecx
  79. CHA $     90+              ; nop
  80.           FFD6             ; call     esi
  81. ;
  82. VER 355AE 99+              ; cwd
  83.           F7F9             ; idiv     ecx
  84. CHA $     90+              ; nop
  85.           FFD6             ; call     esi
  86. ;
  87. VER 35682 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 service will return 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 30522 00000000000000000000000000000000+
  100.           0000000000000000000000
  101.           ;
  102.           ; local call to get the entry address in esi
  103.           ;
  104. CHA $     E80D000000+      ; call     +0000000D (@30534)
  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. @30534:   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 2B2E3 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 $     E859E80000+      ; call     +0000E859 (00039B41)
  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 393D1 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.           E86A070000+      ; call     +0000076A (00039B41)
  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 3DC5A 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.           E8E1BEFFFF+      ; call     -0000411F (00039B41)
  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 routine that has been added for the three patches from above
  188. ; (info screenn, squish, *.msg).
  189. ; This routine is called when writing a FTSC date stamp into a *.squish or
  190. ; *.msg base and writing the info screen. It prevents the 2 digit date field
  191. ; from spilling (without the modulo 100 operation, "100" would be written
  192. ; there in the year 2000 instead of 00).
  193. ;
  194. VER 39B41 0000000000000000000000000000000000000000000+
  195.           00000000000000000000000000000
  196.           ;
  197. CHA $     FF7104+          ; push     dword ptr [ecx+04]
  198.           FF7108+          ; push     dword ptr [ecx+08]
  199.           50+              ; push     eax          ; room for two values
  200.           50+              ; push     eax
  201.           51+              ; push     ecx
  202.           52+              ; push     edx
  203.           8B4114+          ; mov      eax,[ecx+14] ; get year
  204.           31C9+            ; xor      ecx,ecx
  205.           B164+            ; mov      cl,64
  206.           99+              ; cwd
  207.           F7F9+            ; idiv     ecx          ; modulo 100
  208.           8954240C+        ; mov      [esp+0C],edx ; save year on stack
  209.           5A+              ; pop      edx
  210.           59+              ; pop      ecx
  211.           8B01+            ; mov      eax,[ecx]    ; get value to push
  212.           87442410+        ; xchg     [esp+10],eax ; swap ret addr/eax
  213.           870424+          ; xchg     [esp],eax    ; swap eax/ret addr
  214.           C3               ; ret
  215.  
  216. ;
  217. ; ---------------------------------------------------------------------------
  218. ; Fix interpretation of a two digit year number when reading Squish and
  219. ; *.MSG style message bases. Previously, it was always interpreted as 19xx,
  220. ; Now, we use the following logic: 19xx if xx>=80, 20xx if xx<80
  221. ;
  222. VER 44F44 83E850+          ; sub      eax,50
  223.           30E4             ; xor      ah,ah
  224.           ;
  225. CHA $     E81C4CFFFF       ; call     -0000B3E4 (00039B65)
  226. ;
  227. ; Convert a two digit year number that has is stored in eax into a DOS time
  228. ; compliant year number (which gives the number of years that have been passed
  229. ; since 1980). The method we use is save until 2080. Prevent wrong binary t
  230. ; imestamps (TimEd derives them from the two digit FTSC date) in Squish and
  231. ; MSG areas.
  232. ;
  233. VER 39B65 0000000000000000000000
  234.           ;
  235. CHA $     83E850+          ; sub      eax,50       ; sub 80
  236.           7703+            ; jnbe     +03 (@39B6D) ; no overflow, done
  237.           83C064+          ; add      eax,64       ; else add 100
  238. @39B6D:   30E4+            ; xor      ah,ah
  239.           C3               ; ret
  240.  
  241. ;
  242. ; --------------------------------------------------------------------------
  243. ; Fix incorrect interpretation of a hudson time stamp which led to
  244. ; totally wrong display of a hudson message date after 2000.
  245. ;
  246. VER 3B0BD 0FB745F4+        ; movzx    eax,[ebp-0C]
  247.           8945E0           ; mov      [ebp-20],eax
  248.  
  249. CHA $     E85E81FFFF+      ; call     -00007EA2 (00033220)
  250.           90+              ; nop
  251.           90               ; nop
  252. ;
  253. ; This routine is called when reading a message from the Hudson HMB.
  254. ; The date that is in [ebp-0c] is a two digit year number, but we want
  255. ; to have a "tm.tm-year" style year number in eax. Therefore, we check
  256. ; if the value is smaller than 80, and if so, we assume that it is in
  257. ; the 21st century and therefore add 100 to it. This makes HMB save
  258. ; until 31-12-2079.
  259. ;
  260. VER 33220 00000000000000000000000000000000
  261.           ;
  262. CHA $     0FB745F4+        ; movzx    eax,[ebp-0C]
  263.           83F850+          ; cmp      eax,50
  264.           7703+            ; jnbe     +03 (0003322C)
  265.           83C064+          ; add      eax,64
  266.           8945E0+          ; mov      [ebp-20],eax
  267.           C3               ; ret
  268.  
  269. ;
  270. ; --------------------------------------------------------------------------
  271. ; Fix three digit year in the textual date field in the Hudson HMB
  272. ; ("100" instead of "00"). Previously, a three digit number was pushed
  273. ; to the stack from 2000 on.
  274. ;
  275. VER 3B5B2 FF7014+          ; push     dword ptr [eax+14]
  276.           89C1             ; mov      ecx,eax
  277.           ;
  278. CHA $     E8797CFFFF       ; call     -00008387 (00033230)
  279. ;
  280. ; The routine that has been added for the patch from above (hudson fix).
  281. ; This routine is called when writing a FTSC date stamp into a hudson base.
  282. ; It prevents the 2 digit date field from spilling (without the modulo 100
  283. ; operation, "100" would be written there in the year 2000 instead of 00).
  284. ;
  285. VER 33230 00000000000000000000000000000+
  286.           0000000000000000000
  287.           ;
  288. CHA $     50+              ; push     eax
  289.           8B4014+          ; mov      eax,[eax+14] ; get year
  290.           52+              ; push     edx
  291.           31C9+            ; xor      ecx,ecx
  292.           B164+            ; mov      cl,64
  293.           99+              ; cwd
  294.           F7F9+            ; idiv     ecx          ; modulo 100
  295.           92+              ; xchg     edx,eax
  296.           5A+              ; pop      edx
  297.           87442404+        ; xchg     [esp+04],eax ; swap year/ret addr
  298.           870424+          ; xchg     [esp],eax    ; swap ret addr/eax
  299.           89C1+            ; mov      ecx,eax
  300.           C3               ; ret
  301.  
  302. ;
  303. ; --------------------------------------------------------------------------
  304. ; Fix incorrect dates in replies generated with a template containing
  305. ; the %year token.  Previously, a three digit year number was pushed to
  306. ; the stack.
  307. ;
  308. VER 21CC3 8B45E8+          ; mov      eax,[ebp-18]
  309.           FF7014           ; push     dword ptr [eax+14]
  310.           ;
  311. CHA $     E830150100+      ; call     +00011530 (000331F8)
  312.           90               ; nop
  313. ;
  314. ; This routine is called from the patch from above when writing the day number
  315. ; for a %year variable in a message template. We have patched the executable
  316. ; to use %4.4i instead of 19%2.2i as sprintf format string, so we have to
  317. ; push a four digit year number now.
  318. ;
  319. VER 331F8 0000000000000000000000000000000000000000+
  320.           0000000000000000000000000000000000000000
  321.           ;
  322. CHA $     8B45E8+          ; mov      eax,[ebp-18]
  323.           50+              ; push     eax
  324.           8B4014+          ; mov      eax,[eax+14] ; get year
  325.           51+              ; push     ecx
  326.           52+              ; push     edx
  327.           31C9+            ; xor      ecx,ecx
  328.           B164+            ; mov      cl,64        ; modulo 100
  329.           99+              ; cwd
  330.           F7F9+            ; idiv     ecx
  331.           81C26C070000+    ; add      edx,0000076C ; add 1900
  332.           09C0+            ; or       eax,eax      ; was year > 99 ?
  333.           7403+            ; jz       +03 (@33215) ; no, done
  334.           83C264+          ; add      edx,64       ; else add 100
  335. @33215:   92+              ; xchg     edx,eax
  336.           5A+              ; pop      edx
  337.           59+              ; pop      ecx
  338.           87442404+        ; xchg     [esp+04],eax ; swap year/ret addr
  339.           870424+          ; xchg     [esp],eax    ; swap ret addr/eax
  340.           C3               ; ret
  341.           ;
  342. VER 4AA24 313925322E326900 ; db "19%2.2i",0
  343.           ;
  344. CHA $     25342E3469000000 ; db "%4.4i",0,0,0
  345.  
  346. ;
  347. ; --------------------------------------------------------------------------
  348. ; Patch the Tearline and other places to announce version "1.10.y2k"
  349. ; intead of "1.10".
  350. ;
  351. VER 4DBBE 00000000         ; db 0,0,0,0
  352.           ;
  353. CHA $     2E79326B         ; db ".y2k"
  354. ;
  355. ; Done!
  356. ;
  357.  
  358.