home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 14 Text / 14-Text.zip / os2dump.zip / DUMP1011.INF (.txt) next >
OS/2 Help File  |  1995-08-26  |  103KB  |  2,680 lines

  1.  
  2. ΓòÉΓòÉΓòÉ 1. Introduction ΓòÉΓòÉΓòÉ
  3.  
  4. This document was written by 
  5.  
  6. Gary Jarman, 
  7. P O Box 74202, 
  8. Turffontein, 
  9. 2140, 
  10. South Africa. 
  11.  
  12. Welcome to Dump Analysis 101. This document is intended to introduce you to the 
  13. world of 16 bit application dumps. If you use this document please send me a 
  14. postcard with your opinions. There is no catch involved, I would just like to 
  15. know if anyone out there has used this file, and if they have, what they 
  16. thought of it. 
  17.  
  18. I am hoping that this will be a learning experience for both you and I. If you 
  19. see any errors, or can add to what I have written, please let me know. 
  20.  
  21. In the meantime I am starting work on the 32 bit application dump document 
  22. (Dump Analysis 102), to be followed by a document dealing with system hangs and 
  23. application loops (Dump Analysis 103). 
  24.  
  25. Enjoy your reading, Gary, 13 August 1995. 
  26.  
  27.  
  28. ΓòÉΓòÉΓòÉ 2. Changes between versions. ΓòÉΓòÉΓòÉ
  29.  
  30. Rev. 1 
  31.  
  32. The main correction here is that in the original, I had the SP pointing to the 
  33. next available space on the stack. This is incorrect. The SP always points to 
  34. the last parameter pushed onto the stack. I have corrected all diagrams and all 
  35. the references that I could find. 
  36.  
  37.  
  38. ΓòÉΓòÉΓòÉ 3. The 'don't blame me' section. ΓòÉΓòÉΓòÉ
  39.  
  40. All opinions expressed in this document are mine and mine alone. They do not 
  41. necessarily reflect the views of my employers, my parents, or anyone alse that 
  42. I know, and even those people that I don't know. 
  43.  
  44. In addition I accept no responsibility for any damage to anything in your, and 
  45. anyone elses, country/house/surroundings while you are reading, or following 
  46. the advice of, this document. 
  47.  
  48.  
  49. ΓòÉΓòÉΓòÉ 4. The aim of this document. ΓòÉΓòÉΓòÉ
  50.  
  51. I wrote this document because I enjoy looking at dumps and wanted to share some 
  52. of my knowledge with others. Dumps are not as complicated as many people 
  53. believe, and I hope that after reading through this file more people will 
  54. experiment with looking at dumps. 
  55.  
  56. This document will provide you with one approach to looking at dumps. There are 
  57. others that differ slightly from mine and these will work just as well. All I 
  58. am doing here is explaining the method I use. 
  59.  
  60. To help achieve this I am going to go through the method that I use, and at the 
  61. end I will give two sample dumps (only the relevant parts) and pointers on how 
  62. I went through them. 
  63.  
  64.  
  65. ΓòÉΓòÉΓòÉ 5. Limitations of examples in this document. ΓòÉΓòÉΓòÉ
  66.  
  67. The examples used in this document all have the following things in common: 
  68.  
  69.  1. They are all Trap Ds. 
  70.  
  71.  2. They are all  application abends, ie. no hangs etc. 
  72.  
  73.  3. They all occurred on OS/2 2.11. 
  74.  
  75.  4. The applications were all 16 bit. 
  76.  
  77.  
  78. ΓòÉΓòÉΓòÉ 6. Equipment required for dump analysis. ΓòÉΓòÉΓòÉ
  79.  
  80. The most obvious thing that you'll require will be a dump analysis tool. The 
  81. tool that I use is PMDF (Presentation Manager Dump Formatter) from IBM. Contact 
  82. your local IBM representative for information on how to get a copy. I am not 
  83. going to discuss the installation of this product, and I am not going to 
  84. explain all of the commands available (the product comes with a .INF file that 
  85. explains all of the commands available to you). 
  86.  
  87. There are a couple of other utilities that I use, refer to  Getting additional 
  88. information for more information on these. 
  89.  
  90. The only other things that you'll need is a pile of paper and lots of patience. 
  91.  
  92.  
  93. ΓòÉΓòÉΓòÉ 7. What can you achieve with a dump?. ΓòÉΓòÉΓòÉ
  94.  
  95. Dumps will not help you solve EVERY problem. There are those times when, after 
  96. looking at a dump you know the variable that caused the problem, why it caused 
  97. the problem and  how to fix it. But on the other hand, there are also those 
  98. times when you will be left knowing why the trap occurred but not knowing where 
  99. the data corruption originally occurred. 
  100.  
  101.  
  102. ΓòÉΓòÉΓòÉ 8. Taking a dump. ΓòÉΓòÉΓòÉ
  103.  
  104. There are two ways to take a dump. The first method is to use the Alt+Ctrl+(2 x 
  105. (NumLock)) key sequence (manual), and the other way is to put TRAPDUMP=ON in 
  106. your config.sys(automatic). The manual method is useful when you have a system 
  107. hang or an application loop, you can NOT use it for application dumps (refer to 
  108. What happens when the system dumps  to see why). The automatic method will 
  109. cause the system to prompt you to enter dump diskettes whenever a trap occurs, 
  110. you can limit the dump process to certain types of traps, and you can dump to 
  111. another partition instead of diskette.  For more information on how to use the 
  112. TRAPDUMP command, refer to the OS/2 command reference 
  113.  
  114. You might have to go into your system setup and set the interrupt level to 3 to 
  115. allow the dumping to take place. I had to do this before my pc would initiate 
  116. the dump process automatically. 
  117.  
  118.  
  119. ΓòÉΓòÉΓòÉ 9. What happens when the system dumps. ΓòÉΓòÉΓòÉ
  120.  
  121. When you get a trap, OS/2 takes a note of the register contents and other 
  122. information that it will use in the trap information screen. If the application 
  123. had an exitlist linked to it (this is done in the application  using the 
  124. DosExitList command), OS/2 will go through the function specified by the 
  125. DosExitList call. Then OS/2 will clear up all memory that the application was 
  126. using, and only then will the trap information screen be displayed. 
  127.  
  128. It is for this reason that it is pointless to initiate a manual dump when you 
  129. see the trap screen. All the dump will show you is the memory used by every 
  130. other thread still in the system, and there will be no trace of the application 
  131. that abended. 
  132.  
  133. So, if you want to find out why an application is abending you have to have the 
  134. config.sys file set up so that the dump process is kicked off automatically. 
  135.  
  136.  If there is anyone out there who knows any more than this, please let me know. 
  137.  
  138.  
  139. ΓòÉΓòÉΓòÉ 10. Stacks ΓòÉΓòÉΓòÉ
  140.  
  141. The key to reading dumps is the ability to read stacks.  Every slot displayed 
  142. in the dump (use .p to display all slots in your current dump) will have a 
  143. stack. Each slot corresponds to a thread that was running in the system at the 
  144. time the dump was taken. Stacks are used to store local variables and to pass 
  145. parameters when functions are called. They are also used by the system to save 
  146. information on where to return control to when a function is completed. 
  147.  
  148.  
  149. ΓòÉΓòÉΓòÉ 10.1. How is a stack allocated by OS/2?. ΓòÉΓòÉΓòÉ
  150.  
  151. Each thread that is created has a stack. The stack is created in a segment. It 
  152. is created as a sparse object. What this means is that the operating system 
  153. allocates the area of memory, but does not commit the entire area allocated. 
  154. Only the last page (OS/2 handles memory as pages, a page is 4KB in size) is 
  155. committed, while the page above that is committed as a guard page. OS/2 then 
  156. uses the guard page technique to allocate the memory as it is required. When an 
  157. operation occurs that will exceed the boundaries of the committed page and go 
  158. into the guard page, a guard page fault will occur. OS/2 has a default guard 
  159. page fault handler that will commit what was the guard page and make the next 
  160. available page the guard page. This technique helps prevent excessive swapping 
  161. as memory that is not actually being used (even though it has been allocated to 
  162. a process), is not committed and has thus not used up physical memory. This 
  163. method of allocating memory for a stack is used for all stacks except that of 
  164. the first thread created by the process. 
  165.  
  166. The fact that OS/2 commits the LAST page in the segment (the one with the 
  167. highest addresses) first also explains why the earlier functions have higher 
  168. value addresses on the stack than the last accessed functions. 
  169.  
  170. A segment can be a maximum of 64KB and that is the maximum size a stack may be. 
  171. This is the maximum that a 16 bit system can address (in the 32 bit system this 
  172. can be up to 4GB). 
  173.  
  174.  
  175. ΓòÉΓòÉΓòÉ 10.2. How is a stack populated?. ΓòÉΓòÉΓòÉ
  176.  
  177. As mentioned earlier stacks are used to store local variables as well as to 
  178. pass data between functions. This section attempts to explain how this is done. 
  179.  
  180. The example will assume that the first function to be kicked off is 
  181. function_one, it performs some processing and then makes a call to 
  182. function_two, passing it two parameters. The example also shows how the space 
  183. for the local variables of function_two is reserved. For function_one I have 
  184. given the required lines of example C code and their corresponding assembler 
  185. instructions. For each instruction there is a diagram that represents the stack 
  186. after that instruction is executed. 
  187.  
  188. The example assumes that when we enter function_one the SS:BP is 1F:E95E, the 
  189. SP would also be E95E. 
  190.  
  191. Example C source code:
  192.            VOID function_one (MPARAM ....)
  193.              { USHORT usVar1,
  194.                       usVar2,
  195.                       usVar3,
  196.                       usVar4,
  197.                       usVar5;
  198.                  .
  199.                  .
  200.                  .
  201.                function_two(usVar2, usVar4);
  202.                  .
  203.                  .
  204.                  .
  205.              }
  206.  
  207. Example assembler code :
  208.                  bd0f:e318 ....  enter a,0
  209.                  bd0f:e320 ....
  210.                  .
  211.                  .
  212.                  bd0f:e44c ....  push word ptr [bp - 08]
  213.                  bd0f:e44f ....  push word ptr [bp - 04]
  214.                  bd0f:e452 ....  call bd36:0b5c
  215.                  bd0f:e457 ....  add sp,+04
  216.                  .
  217.                  .
  218.                  .
  219.  
  220. To view the stack contents as we enter function_one refer to fig. 1 
  221.  
  222. Function_one has 5 local variables, all of type USHORT, space on the stack must 
  223. be reserved for these variables as the system enters function_one. To do this 
  224. the first instruction is an ENTER instruction. This changes the SP value by the 
  225. value of its first parameter (in this case a (hex) 10) to give us an SP of E954 
  226. (E95E-(5*sizeof(USHORT))). The ENTER command is the equivalent of the following 
  227. instructions : 
  228.  
  229.  1. PUSH BP 
  230.  
  231.  2. MOVE BP,SP 
  232.  
  233.  3. SUB SP,nn. 
  234.  
  235. Compare  Fig. 1  to  Fig 2  to see the changes after executing the enter 
  236. instruction. This is the same method used for entering all functions. 
  237.  
  238. We have done some processing in function_one and now we want to call 
  239. function_two, we are going to pass two variables, also of type USHORT. 
  240.  
  241. Refer to  Fig. 3  to see stack contents after the first parameter is put on the 
  242. stack, and  Fig. 4  for the second parameter being put on the stack. 
  243.  
  244. Take note that in this example I have shown the assembler code as putting 
  245. parameter 2 on the stack and then parameter 1. This will depend on the stack 
  246. conventions used by the compiler the program was compiled with. 
  247.  
  248. This example also assumes that the five variables were loaded to the stack in 
  249. the order that they were defined. This is not always the case, refer to 
  250. Example of compiler generated files. 
  251.  
  252. The parameters are put onto the stack using the PUSH command, data is always 
  253. put onto a stack using the PUSH command (data is removed from the stack using 
  254. the POP command). The PUSH statement will first decrement the SP by two before 
  255. putting the data on the stack. 
  256.  
  257. When the first push was executed the SP would change from E954 to E952. The 
  258. second USHORT would be pushed the same way and the SP would point to E950. The 
  259. next instruction would be a CALL instruction (since we are now going to go to 
  260. function_two). When the call instruction is handled by the hardware, the IP is 
  261. pushed onto the stack and, if it is a far call, the CS is also pushed onto the 
  262. stack. Note that at the stage the CS:IP are pushed onto the stack they are 
  263. pointing to the next instruction (in function_one) to be executed following the 
  264. call. 
  265.  
  266. The fact that the address we are calling is displayed as both a selector and 
  267. offset indicates that we are making a far call.  A far call occurs when control 
  268. is transferred to a piece of code contained in a selector different to that of 
  269. the calling code.  If we were calling a piece of code that was contained in the 
  270. selector bd0f (ie.  the selector we are currently running in) it would be 
  271. referred to as a near call.  A near call would look as follows : bd0f:e457 .... 
  272. call e56a and the address of the entry point for that called function would 
  273. then be bd0f:e56a.  Also with a near call, only the offset of the next 
  274. instruction would be loaded to the stack. 
  275.  
  276. Refer to  Fig. 5  to see the stack contents once we have left function_one but 
  277. have not yet executed any instructions in function_two. 
  278.  
  279. The first instruction that we would encounter in function_two is an ENTER. What 
  280. this does is to push the BP onto the stack and then move the current value of 
  281. SP to BP. Before the ENTER is executed the SS:BP is 1F:E59E, the SP is E58C. 
  282. The enter command will put the value of BP (E59E) on the stack (in so doing the 
  283. value of SP would be decremented by two, giving E58A) and then subtract the 
  284. value of the first parameter (the length of the local variables) from the SP, 
  285. thus giving us E572. 
  286.  
  287.         Example assembler code (at entry of function two):
  288.                         .
  289.                         .
  290.                         .
  291.                        bd36:0b5c ....  enter 16,0
  292.                         .
  293.                         .
  294.                         .
  295.  
  296. Refer to  Fig. 6  to see the stack contents when the enter command has been 
  297. executed. 
  298.  
  299.  
  300. ΓòÉΓòÉΓòÉ 10.3. Stack Registers ΓòÉΓòÉΓòÉ
  301.  
  302. From the above we can see that there are three registers used with the stack: 
  303.  
  304.  1. SS - stack selector, this points to the segment containing the stack. 
  305.  
  306.  2. (E)BP - Base Pointer, points to the current base of the stack. 
  307.  
  308.  3. (E)SP - Stack Pointer, this points to the current position on the stack 
  309.     where data would be moved to in the event of a PUSH statement. 
  310.  
  311.  
  312. ΓòÉΓòÉΓòÉ 10.4. Stack frames. ΓòÉΓòÉΓòÉ
  313.  
  314. The stack is broken down into stack frames.  A stack frame can be thought of as 
  315. a unit containing all of the data required by a function. A frame consists of 
  316. the parameters passed, the return CS:IP, the return BP and the local variables. 
  317.  
  318.                                   ^
  319.         Γöé                     Γöé   Γöé                             ^
  320.         Γöé                     Γöé   Γöé                             Γöé
  321.         Γöé  local data         Γöé   Γöé  <ΓöÇΓöÇΓöÇΓöÇΓöÇ higher value        Γöé
  322.         Γöé                     Γöé   Γöé         addresses           Γöé
  323.         Γöé                     Γöé   Γöé        (eg. 1f:e206)        Γöé
  324.         Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ   Γöé                             Γöé
  325.         Γöé                     Γöé   Γöé                             Γöé
  326.         Γöé  parameters         Γöé   Γöé                             Γöé
  327.         Γöé                     Γöé   Γöé                             Γöé
  328.         Γöé                     Γöé   Γöé                             Γöé
  329.         Γöé                     Γöé   Γöé                             Γöé
  330.         Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ   Γöé                             Γöé
  331.         Γöé  return IP          Γöé   Γöé                             Γöé
  332.         Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ   Γöé                 Unwinding a Γöé
  333.         Γöé  return CS          Γöé   Γöé                 stack takes Γöé
  334.         Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ   Γöé                 you in this Γöé
  335.     ΓöîΓöÇΓöÇ>Γöé  return BP          ΓöéΓöÇΓöÇΓöÇΓöÿ                 direction.  Γöé
  336.     Γöé   Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ                                 Γöé
  337.     Γöé   Γöé                     Γöé                                 Γöé
  338.     Γöé   Γöé                     Γöé                                 Γöé
  339.     Γöé   Γöé                     Γöé                                 Γöé
  340. points  Γöé                     Γöé                                 Γöé
  341. to  Γöé   Γöé  local data         Γöé                                 Γöé
  342. previousΓöé                     Γöé                                 Γöé
  343. stack   Γöé                     Γöé                                 Γöé
  344. frame   Γöé                     Γöé                                 Γöé
  345.     Γöé   Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ ΓöÇΓöÇΓöÇΓöÇΓöÉ                           Γöé
  346.     Γöé   Γöé                     Γöé     Γöé                           Γöé
  347.     Γöé   Γöé  parameters         Γöé     Γöé                           Γöé
  348.     Γöé   Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ     Γöé                           Γöé
  349.     Γöé   Γöé  return IP          Γöé     Γöé                           Γöé
  350.     Γöé   Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ     Γöé                           Γöé
  351.     Γöé   Γöé  return CS          Γöé     Γöé                           Γöé
  352.     Γöé   Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ     Γö£ΓöÇΓöÇ stack frame             Γöé
  353.     ΓööΓöÇΓöÇΓöÇΓöé  return BP          Γöé     Γöé                           Γöé
  354.         Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ     Γöé                           Γöé
  355.         Γöé                     Γöé     Γöé                           Γöé
  356.         Γöé                     Γöé     Γöé                           Γöé
  357.         Γöé                     Γöé     Γöé                           Γöé
  358.         Γöé                     Γöé     Γöé                           Γöé
  359.         Γöé  local data         Γöé     Γöé                           Γöé
  360.         Γöé                     Γöé     Γöé                           Γöé
  361.         Γöé                     Γöé     Γöé                           Γöé
  362.         Γöé                     Γöé     Γöé                           Γöé
  363.         Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ ΓöÇΓöÇΓöÇΓöÇΓöÿ  <ΓöÇΓöÇΓöÇ lower value         Γöé
  364.                                             addresses
  365.                                            (eg. 1f:054a)
  366.  
  367. Be careful of how you picture the growth of a stack.  As mentioned in  How is a 
  368. stack created  OS/2 starts allocating pages from the end of the segment 
  369. allocated for the stack. This means that the stack frame that was allocated 
  370. first, has the highest address (in terms of numerical value) while the last 
  371. allocated frame has the lowest numerical address but is at the top of the 
  372. stack. 
  373.  
  374. From the illustration above there are a few things that can be used as 
  375. guidelines for dump analysis. 
  376.  
  377.  1. When unwinding a stack, the base pointers you are using should always get 
  378.     higher in numerical value (ie. you are working from the lowest value to the 
  379.     highest). If this trend is reversed, the chances are you have a corrupted 
  380.     stack. 
  381.  
  382.  2. If an assembler instruction references BP - ??, 90% of the time it will be 
  383.     referring to local variables of that function. BP + ?? will be referring to 
  384.     parameters passed to that function. 
  385.  
  386.  
  387. ΓòÉΓòÉΓòÉ 10.5. Unwinding a stack. ΓòÉΓòÉΓòÉ
  388.  
  389. This is probably the most important thing you will need to know in order to 
  390. analyse a dump. The stack can tell you the route that the application took to 
  391. get to its sudden, unexpected death. If you have read the section  How is a 
  392. stack used?  and  Stack frames  then you should have a fairly good idea of the 
  393. structure of a stack. If you understand this then it is pretty simple to 
  394. understand how to unwind the stack. 
  395.  
  396. When you first look at the dump, go to SS:BP. This will point you to the middle 
  397. of the stack frame that was active when you trapped. What it will point you to 
  398. is the BP that was used by the function that called the failing function. The 4 
  399. (or 2 depending on whether it was a far or near call (refer to  Near and far 
  400. calls )) bytes after that BP will be address that the function would have 
  401. returned to, if only it had had the chance. 
  402.  
  403. Note the current BP contents and the failing CS:IP. Get the BP, and CS:IP 
  404. pointed to by SS:BP and write those down. Use the BP that you have just got off 
  405. the stack and together with the SS it will point you to the middle of the next 
  406. frame, from where you can get the BP used by the function that called the 
  407. function that called the function that died (and so it carries on). 
  408.  
  409. You have reached the bottom of the stack when the return BP is 0. 
  410.  
  411. Why do you want to do this?. When you are looking at a dump, there are often 
  412. times that it was a parameter that was passed that caused the problem. So you 
  413. need to at least go back to the second last function to see what parameters it 
  414. passed. In some cases you'll have to go back further to get to work out how the 
  415. parameter you suspect actually got to contain the value it did. 
  416.  
  417. Refer to  Fig. 7  for an example of a stack and how the frames link together, 
  418. and Simplified look at unwinding the stack  for more information. 
  419.  
  420. When you are looking through a function other than the one that failed, always 
  421. specify a value rather than a register name. Using the register name will cause 
  422. PMDF to use the value in that register at the time of the abend. This is fine 
  423. for the SS which is the same for all functions, but the BP will change with 
  424. each function. 
  425.  
  426.  
  427. ΓòÉΓòÉΓòÉ 11. Approach to looking at dumps. ΓòÉΓòÉΓòÉ
  428.  
  429. There is no fixed approach to looking at a dump. Each dump has to be looked at 
  430. in its own way. There are however a few guidelines that I can give to help 
  431. track down the problem. 
  432.  
  433.  
  434. ΓòÉΓòÉΓòÉ 12. What PMDF gives us. ΓòÉΓòÉΓòÉ
  435.  
  436. When you first load a dump PMDF gives you a display showing the contents of all 
  437. the registers of the thread that was active at the time of the dump (in the 
  438. case of a trap D this will be the thread that abended). It also gives you the 
  439. assembler instruction that failed, and why it failed. 
  440.  
  441. You can redisplay the register contents, and the assembler instruction using 
  442. the .r command. Refer to  Initial display and output of .r. 
  443.  
  444. Above the register information will be a line that will give you varous handles 
  445. associated with the thread and its process. On the far left hand side is the 
  446. slot number. If you were to do a .p, PMDF would display all the slots that were 
  447. running in the system at the time it trapped (a slot corresponds to a thread). 
  448.  
  449. On the far right of the top line is a name, this is the name of the dll/exe 
  450. that was running the thread. 
  451.  
  452. Make a note of the slot number, it could be used later on. 
  453.  
  454. What have we learnt so far? 
  455.  
  456.  1. The name of the dll/exe that failed. 
  457.  
  458.  2. The assembler instruction that failed. 
  459.  
  460.  3. Why that assembler instruction failed. 
  461.  
  462.  
  463. ΓòÉΓòÉΓòÉ 13. Getting the failing dll/exe. ΓòÉΓòÉΓòÉ
  464.  
  465. The easiest way to do this is to do a .m CS:IP. This will give you some 
  466. information about the thread including the dll/exe that owns it. Refer to 
  467. Output of .m. 
  468.  
  469. If you want the path as well as the dll/exe name then refer to Getting the path 
  470. and dll name the hard way. 
  471.  
  472.  
  473. ΓòÉΓòÉΓòÉ 14. Investigating why the data is corrupt. ΓòÉΓòÉΓòÉ
  474.  
  475. If you perform a u CS:IP - 20 you will display the assembler instructions just 
  476. before the failing address. Here you must be careful. Look at the instructions 
  477. you have just unassembled. Do they look right?. Does the instruction at the 
  478. failing address look like the one displayed when you loaded the dump?. Is there 
  479. an instruction at the address of the CS:IP?. This is important because 
  480. sometimes PMDF will start unassembling instructions from the offset that you 
  481. have given it, and the instructions it gives you are incorrect. If this is the 
  482. case then try - 30, or - 10. Basically experiment until you are getting a list 
  483. of instructions that looks correct. Refer to  Output of u CS:IP - 20. 
  484.  
  485. Look at the way that the data is handled. Look at where the data that caused 
  486. the problem comes from. If the data comes from BP - ?? then we are dealing with 
  487. a local variable, if it comes from BP + ?? we are dealing with a parameter 
  488. passed from another function (refer to Examples of compiler generated files for 
  489. an example of this.). At this stage you have to decide how to proceed. If you 
  490. are dealing with a local variable refer to  Following a local variable.  but if 
  491. you are dealing with a paramater that was passed then refer to  Following a 
  492. parameter. . 
  493.  
  494.  
  495. ΓòÉΓòÉΓòÉ 15. Near and far calls. ΓòÉΓòÉΓòÉ
  496.  
  497. Code is loaded into segments. When a function calls another function or API, it 
  498. does so via a near or far call. 
  499.  
  500. A near call is where the section of code being called is in the same segment as 
  501. the code currently in control. A near call does not have a selector in the 
  502. address. An example CALL 1F24, if we are currently at 10B7:562, would mean that 
  503. we were calling 10B7:1F24. The stack would contain the return BP and IP but not 
  504. the CS. 
  505.  
  506. A far call is when the code being called is in a different segment to the 
  507. currently executing code. For example, if we were at 10B7:562 and wanted to 
  508. make a far call it would look like CALL 10BF:32A. The stack would have the 
  509. return BP, the return IP and the return CS. 
  510.  
  511. How can you decide, from the data on the stack, if a far or near call was 
  512. executed. Look at where the return CS would be, do a  dl return CS, the result 
  513. will tell you that the segment you are enquiring about contains either data, 
  514. code or is invalid. If it is either data or invalid then you know you are 
  515. dealing with a near call. 
  516.  
  517. If it tells you that the segment contains code, you can perform one more check. 
  518. Do a  u return CS:IP - 20 and see if there is a call statement just above the 
  519. return CS:return IP address thet you have used for the unpack. Look at that 
  520. call instruction, is it a far call ?. 
  521.  
  522. This knowledge is needed when you get around to examining data on the stack, 
  523. refer to  Following a parameter  for more information on this. 
  524.  
  525.  
  526. ΓòÉΓòÉΓòÉ 16. Following a local variable. ΓòÉΓòÉΓòÉ
  527.  
  528. What this requires is that you go through the function, looking for all 
  529. references to the area of memory referred to in the failing instruction, taking 
  530. note of what data is moved into and out of that area. By the time you get to 
  531. the failing instruction you will be able to tell where the data came from and 
  532. how it was manipulated to arrive at the current value. There is a possibility 
  533. that the data originally moved into the local variable was moved in from one of 
  534. the paramaters passed and you might have to track down that variable (refer to 
  535. Following a parameter.  for how this is done). 
  536.  
  537. The easiest way to follow the progress of a local variable is to start at the 
  538. beginning of the function and work your way down until you get to the failing 
  539. instruction. To get to the start of the function can be done in one of two 
  540. ways. 
  541.  
  542. The first method is to unpack back up the code, from the failing instruction, 
  543. until you get to the first ENTER instruction (ie. use the u CS:IP - 20 
  544. instruction). With this method you are starting at the failing instruction and 
  545. working back in blocks, it is not the best way to do things as it is messy and 
  546. doesn't give you a nice flow of code to go through. 
  547.  
  548. The second method is to actually get the address of the start of the function 
  549. and then unpack from that point down. Do a dw SS:BP, this will get you to the 
  550. point on the stack where you have the BP of the function that called the 
  551. failing function, the IP that the failing function would have returned to and, 
  552. if it was a far call, the CS. Both the CS and IP mentioned previously are going 
  553. to be referred to as the return CS and return IP from now on. 
  554.  
  555. Do a  u return CS:return IP - 20 This will display the assembler instructions 
  556. before the address to which the failing function would have returned. Just 
  557. above the return CS:return IP will be a call statement. The address in the call 
  558. statement is the address of the entry point to the function that failed. 
  559.  
  560. Take the address that was called and do a  u called CS:called IP l200. This 
  561. will list the assembler instructions from the entry point onwards. The l200 
  562. parameter tells PMDF how many bytes to show (the value is used by PMDF as a hex 
  563. value). You can obviously change the value, if you leave it out the default 
  564. will be displayed (somewhere between 20 to 30 bytes). 
  565.  
  566. If you do a  u CS:IP then the instructions from that address are displayed. If 
  567. you then just enter a u then PMDF will display the assembler instructions 
  568. starting with the instruction following the last displayed instruction. The 
  569. same principle applies when displaying memory. 
  570.  
  571. Refer to Output of u CS:IP - 20.  for some examples to illustrate the above. 
  572.  
  573.  
  574. ΓòÉΓòÉΓòÉ 17. Following a parameter. ΓòÉΓòÉΓòÉ
  575.  
  576. Following the progress of a parameter requires the ability to unwind a stack as 
  577. well as the methods explained in  Following a local variable. 
  578.  
  579. The first thing that you have to do is to go to the function that called the 
  580. failing function. To do this do a dw SS:BP to get to the return BP, return IP 
  581. and, in the event of a far call, the return CS. Do a u return CS:return IP - 20 
  582. to get the instructions that preceded the address to which we would have 
  583. returned. 
  584.  
  585. Typically we would have a CALL instruction directly above the return address, 
  586. and above that would be a number of PUSH statements. The PUSH statements can 
  587. safely be assumed to be parameters being pushed onto the stack. 
  588.  
  589. You need to determine which parameter is the one you are interested in. Take 
  590. the value in the BP register (do a .r if necessary), add 4 to it if you know 
  591. you reached this location via a near call, or 6 if you arrived via a far call 
  592. and you are now pointing to the last parameter pushed onto the stack (ie. the 
  593. value at BP + (4 or 6) will always be the value that was pushed onto the stack 
  594. by the last PUSH statement that you find above the CALL). To carry this example 
  595. further, BP + 8 will be the second last PUSH instruction before the call 
  596. statement. 
  597.  
  598. Since we are working with 16 bit, the values pushed onto the stack will always 
  599. be 2 bytes in length. The reason the first parameter location is at BP + 6 is 
  600. because, BP is pointing to the return BP, BP + 2 points to the return IP, BP + 
  601. 4 will point to the return CS in a far call situation, and the first parameter 
  602. location in a near call situation. 
  603.  
  604.  
  605. ΓòÉΓòÉΓòÉ 18. Looking at the stack. ΓòÉΓòÉΓòÉ
  606.  
  607. I always unwind the stack for about 5 frames (sometimes you have to do a lot 
  608. more) as one of the first steps. This is not always necessary, which is why I 
  609. have left it until here. 
  610.  
  611. Refer to  Unwinding a stack and Simplified look at unwinding the stack  for how 
  612. to unwind the stack. At each frame do a .m return CS:return IP  to get the name 
  613. of the dll/exe that you were called from. I always write this down so that I 
  614. can tell the programmer how the application reached the function that it 
  615. abended in. 
  616.  
  617.  
  618. ΓòÉΓòÉΓòÉ 19. Summary of what we've got. ΓòÉΓòÉΓòÉ
  619.  
  620. By following the above steps, we are able to provide the following information 
  621. to the programmer: 
  622.  
  623.  1. The dll/exe path and name in which the abend occurred (  Getting the 
  624.     dll/exe name.). 
  625.  
  626.  2. Why the trap happened (  What PMDF gives us.). 
  627.  
  628.  3. Was it a parameter or a local variable that was corrupted (or a mixture of 
  629.     the two) (  Investigating why the data is corrupt.). 
  630.  
  631.  4. How the data got to be the way it was ( Following a local variable or 
  632.     Following a parameter). 
  633.  
  634.  5. The exe/dlls that we have been through to get to the failing function ( 
  635.     Looking at the stack). 
  636.  
  637.  6. If it was a corrupt parameter, we can tell tem what number out of all the 
  638.     parameters it was (  Following a parameter  and  How is a stack 
  639.     populated?). 
  640.  
  641. While this may seem impressive to the programmer, it doesn't really help much. 
  642. They will need a bit more information, like what is the function within the dll 
  643. that abended, what was the parameter that was corrupt (to name a few of the 
  644. things they would like). 
  645.  
  646. The following sections explain how to get some extra information for the 
  647. programmer. From this stage on we are not as reliant on PMDF as we have been up 
  648. until now. 
  649.  
  650.  
  651. ΓòÉΓòÉΓòÉ 20. Getting additional information. ΓòÉΓòÉΓòÉ
  652.  
  653. The following couple of screens discuss other tools that I have used to help 
  654. get additional information to solve dumps. 
  655.  
  656.  
  657. ΓòÉΓòÉΓòÉ 20.1. Using the source code. ΓòÉΓòÉΓòÉ
  658.  
  659. If you have the source code available to you, you could recompile it with the 
  660. options set to create both a MAP file and an assembler file. 
  661.  
  662. For the IBM C Set compiler the options are : 
  663.  
  664. /Fa (in your compile step)- will give you an assembler listing. 
  665.  
  666. /MAP (in the link step) - will give you a map file. 
  667.  
  668. At the end of this you will have a .MAP file and a .ASM file. The .ASM file 
  669. will contain the assembler version of your source code (complete with line 
  670. numbers for you to be able to cross match to the source code). 
  671.  
  672. And a .MAP file to give you a list of offsets into the dll/exe file and how 
  673. those offsets correspond to the line numbers of the source code. You could 
  674. combine the output of this and the .ASM file to provide you with useful 
  675. information. 
  676.  
  677. For an example of the source code, map file contents and assembler file 
  678. contents refer to Example of the compiler generated files. 
  679.  
  680. You could now get the IP of the failing instruction, look into the .MAP file, 
  681. find the nearest offset to the value of your IP, take the line number and look 
  682. into the .ASM file. By doing this you can get the exact line of code that 
  683. caused the problem. 
  684.  
  685. The .MAP file may not always have the exact IP value that you have been given 
  686. by PMDF. This is because each line of source code may comprise more than one 
  687. line of assembler code. The value you have could, for example, point to the 
  688. third line of assembler code for that instruction, while the .MAP file will 
  689. have the value that points to the first assembler line for that instruction. 
  690.  
  691. You can, if you are in doubt, unpack the code around the failing instruction 
  692. and compare it to that of the .ASM file. This will settle any doubts you may 
  693. have. Be careful when doing this, the .ASM file will have decimal values, while 
  694. the dump code will have hex values. Thus the dump would for example display BP 
  695. + a, while the .ASM file will display BP + 10. 
  696.  
  697. Always be aware of how values are being displayed in the various files that you 
  698. are using. 
  699.  
  700. Because in  Getting the dll/exe name  you have been able to get the name of the 
  701. dll/exe of all of the functions you have been through, you can if you want, 
  702. recompile all of these to get their .MAP and .ASM files as well. In this way 
  703. you can get the lines of code that set up any parameters passed. 
  704.  
  705. This method is the one that will give you the most information to give to the 
  706. programmer. 
  707.  
  708.  
  709. ΓòÉΓòÉΓòÉ 20.2. ExeInfo - getting a dll using CSLIM. ΓòÉΓòÉΓòÉ
  710.  
  711. There is a useful tool called exeinfo, that is available from Ngb Technologies. 
  712. If you pass this application the CSLIM and a directory to search in, it will 
  713. return you the name of all dll/exe files that meet the requirements. 
  714.  
  715. To get the CSLIM all you have to do is a dl on the CS value. This will give you 
  716. the limit, and that limit is your CSLIM. 
  717.  
  718. Let us suppose that from the following section of the stack, we want to know 
  719. who 5c5f belongs to. 
  720.  
  721. # dw ss:bp
  722.  
  723. 001f:0000e13e  e414 2c1e 5c5f ffc5 5c4f 4a03 017f 5c57
  724. 001f:0000e14e  e48b e44d 3300 61af 0000 0000 0000 ff00
  725. 001f:0000e15e  ff0b 61ba 017f e168 001f 7fff 0001 9ec0
  726. 001f:0000e16e  32d0 000f 98cc 30b0 0000 28c0 b200 ef9a
  727. 001f:0000e17e  fe00 00ff 0000 bd00 00ac 0000 6377 0000
  728. 001f:0000e18e  06d7 2947 bd0f 0001 000f 9ec0 32d0 0043
  729. 001f:0000e19e  98cc 30b0 bd7f 0000 0000 0000 000c bd7f
  730. 001f:0000e1ae  e1c6 281f bd0f 0000 0001 000f 9ec0 4242
  731.  
  732. Do a dl on the CS (5c5f). The lim=???? is the CSLIM for that CS. 
  733.  
  734.  
  735. # dl 5c5f
  736.  
  737. 5c5f  Code    Bas=0b8b0000 Lim=00002ff9 DPL=3 P  RE    A
  738.  
  739. Use the CSLIM as input into EXEINFO, and the path that you want searched. 
  740.  
  741. exeinfo -f -l2ff9 f:\main\dll\*.* 
  742.  
  743. The output will look as follows. 
  744.  
  745.  
  746. ExeInfo, New Exe File Format Info, v2.0f
  747. (C) Copyright Ngb Technologies, 1991-1993, All rights reserved.
  748.  
  749. F:\MAIN\DLL\BDDAS601.DLL
  750.     50518bytes    95-08-09    20:52:06
  751. 001 02ffa  CODE EXECUTEONLY
  752.  
  753. F:\MAIN\DLL\BDYAT003.DLL
  754.     41460bytes    95-08-09    16:10:32
  755. 001 02ffa  CODE EXECUTEONLY
  756.  
  757. Unfortunately, this example returned two dll names to us. The easiest way to 
  758. determine which is the correct one is to do a .m 5c5f:2c1e, which will 
  759. eliminate one of them. 
  760.  
  761.  
  762. ΓòÉΓòÉΓòÉ 20.3. FINDSEG - getting a dll using CSLIM. ΓòÉΓòÉΓòÉ
  763.  
  764. Another tool to get the dll name from the CSLIM is called FINDSEG from IBM. If 
  765. you pass this application the CSLIM and a directory to search in, it will 
  766. return you the name of all dll/exe files that meet the requirements. 
  767.  
  768. To get the CSLIM all you have to do is a dl on the CS value. This will give you 
  769. the limit, and that limit is your CSLIM. 
  770.  
  771. Let us suppose that from the following section of the stack, we want to know 
  772. who 5c5f belongs to. 
  773.  
  774. # dw ss:bp
  775.  
  776. 001f:0000e13e  e414 2c1e 5c5f ffc5 5c4f 4a03 017f 5c57
  777. 001f:0000e14e  e48b e44d 3300 61af 0000 0000 0000 ff00
  778. 001f:0000e15e  ff0b 61ba 017f e168 001f 7fff 0001 9ec0
  779. 001f:0000e16e  32d0 000f 98cc 30b0 0000 28c0 b200 ef9a
  780. 001f:0000e17e  fe00 00ff 0000 bd00 00ac 0000 6377 0000
  781. 001f:0000e18e  06d7 2947 bd0f 0001 000f 9ec0 32d0 0043
  782. 001f:0000e19e  98cc 30b0 bd7f 0000 0000 0000 000c bd7f
  783. 001f:0000e1ae  e1c6 281f bd0f 0000 0001 000f 9ec0 4242
  784.  
  785. Do a dl on the CS (5c5f). The lim=???? is the CSLIM for that CS. 
  786.  
  787. # dl 5c5f
  788.  
  789. 5c5f  Code    Bas=0b8b0000 Lim=00002ff9 DPL=3 P  RE    A
  790.  
  791. Use the CSLIM as input into FINDSEG, and the path that you want searched. 
  792.  
  793. findseg -l0x2ff9 -B -s f:\main\dll 
  794.  
  795. The output will look as follows. 
  796.  
  797. FINDSEG.EXE VER. 1.33 1992/03/18
  798. (C) Copyright IBM Corp, 1990,1991,1992.
  799. Written by Takaaki Nonaka
  800.  
  801. Search path  : F:\main\dll and its sub-directories
  802. Search file  : *.EXE *.COM *.DLL *.IFS *.DRV
  803. Search range : 0x02FF8(12280)-Ox02FFA(12282) bytes
  804. Access rights: not specified
  805.  
  806. F:\main\dll\BDDAS601.DLL
  807.     50518bytes    95-08-09   20:52:06
  808. 001 02FFA CODE FIXED   NONSHARED LOADONCALL E/R RELOC   PL3 NONDISCARDABLE
  809.  
  810. F:\main\dll\BDYAT003.DLL
  811.     41460bytes    95-08-09   16:10:32
  812. 001 02FFA CODE FIXED   NONSHARED LOADONCALL E/R RELOC   PL3 NONDISCARDABLE
  813.  
  814. 2 segments in 2 files
  815.  
  816. Unfortunately, this example returned two dll names to us. The easiest way to 
  817. determine which is the correct one is to do a .m 5c5f:2c1e , which will 
  818. eliminate one of them. 
  819.  
  820.  
  821. ΓòÉΓòÉΓòÉ 20.4. QTRAP - getting a lot more using CS, IP, CSLIM and dll name. ΓòÉΓòÉΓòÉ
  822.  
  823. Using either EXEINFO or FINDSEG you can get the dll name, you have the CSLIM 
  824. either from the registers, or from doing a dl on the CS. From the stack, or the 
  825. registers, you will have the CS and IP. Therefore we have all the information 
  826. needed to use QTRAP. QTRAP is written by Adrian Bonsall (I don't know where he 
  827. works, but I got it in the same package as FINDSEG, so I am assuming (forgive 
  828. me Adrian if I am wrong) that he works for IBM). 
  829.  
  830. Using this application will give you nearest entry point, nearest public 
  831. symbol, and nearest source line. It also gives you the object that has that 
  832. code, this is useful if you have one dll that has many objects linked in. 
  833.  
  834. Let us suppose that from the following section of the stack, we want to know 
  835. what line of source code 5c5f%colon.2c1e belongs to. In the previous two 
  836. sections we have narrowed the choice down to two dlls. Using the .m 5c5f:2c1e I 
  837. have determined that the dll is BDDAS601.DLL, so I am now going to run QTRAP on 
  838. it. 
  839.  
  840. # dw ss:bp
  841.  
  842. 001f:0000e13e  e414 2c1e 5c5f ffc5 5c4f 4a03 017f 5c57
  843. 001f:0000e14e  e48b e44d 3300 61af 0000 0000 0000 ff00
  844. 001f:0000e15e  ff0b 61ba 017f e168 001f 7fff 0001 9ec0
  845. 001f:0000e16e  32d0 000f 98cc 30b0 0000 28c0 b200 ef9a
  846. 001f:0000e17e  fe00 00ff 0000 bd00 00ac 0000 6377 0000
  847. 001f:0000e18e  06d7 2947 bd0f 0001 000f 9ec0 32d0 0043
  848. 001f:0000e19e  98cc 30b0 bd7f 0000 0000 0000 000c bd7f
  849. 001f:0000e1ae  e1c6 281f bd0f 0000 0001 000f 9ec0 4242
  850.  
  851. qtrap 5c5f:2c1e f:\main\dll\bddas601.dll /SIZE=2ffa 
  852.  
  853. Take note that I have added one to the CSLIM of 2ff9 and have passed the new 
  854. value to QTRAP. This is because I discovered that when we switched to OS/2 2.11 
  855. the application would no longer find the information, unless we added one to 
  856. the CSLIM. If you look at the output from FINDSEG you will see that it defines 
  857. its search range as one below and one above the CSLIM that you give to it 
  858. (could it be that if that was not done, it would also not find the 
  859. information?). I have no idea why this is so but if you have any info that 
  860. could be of help, please let me know. 
  861.  
  862. QTRAP v3.03 by Adrian Bonsall - Automated Trap Resolver
  863.  
  864. 5C5F is Entry #2955 in the Local Descriptor Table with a ReqPrivLvl of 3.
  865.  
  866. Selector 5C5F is not assigned to any of the default segments of f:\main\dll\bddas601.dll
  867.  
  868. Checking imported modules for segment of size 2FFA:
  869.                             Searching .... BDDAS601 .... Segment found.
  870.  
  871. Sel.  Off.  Seg.No.  Length  AllocSize  Flags
  872. 5C5F  2C1E   0001    0x2FFA   0x2FFA    CODE RELOC DPL3
  873.  
  874. Nearest Entry Point   : 0001:1116  TPBDDAS601.
  875. Nearest Public Symbol : 0001:1116  TPBDDAS601  (D:\SB\MAIN\OBJ\BDDAS601.OBJ)
  876. Nearest Source Line   : 0001:2BF7  line #1532  (D:\SB\MAIN\OBJ\BDDAS601.OBJ)
  877.  
  878. So now we have the nearest line of source a code in which function and what 
  879. .OBJ file in which dll. You can now refer to the source code if you have it, 
  880. and try to go further from here, or you could pass all of the information that 
  881. you have to the programmer and get him to look at it. 
  882.  
  883.  
  884. ΓòÉΓòÉΓòÉ 21. Dump examples. ΓòÉΓòÉΓòÉ
  885.  
  886. There are two examples contained here. The first is an application dump caused 
  887. by the application trying to access an invalid area of memory. The second is a 
  888. corrupted stack. 
  889.  
  890.  
  891. ΓòÉΓòÉΓòÉ 21.1. Application trap. ΓòÉΓòÉΓòÉ
  892.  
  893. These usually require that you determine how the data that caused the trap, got 
  894. there in the first place. The first step is to unwind the stack to get to the 
  895. function that called the failing function. Remember that the return CS:IP is 
  896. pointing to the instruction following the call instruction. Unassemble the 
  897. instructions just before the return address and in this way you'll get the 
  898. address that was called (ie. the entry point to the function that you have just 
  899. worked back from) as well as the parameters that were put on the stack. 
  900.  
  901. If the data that caused the abend originated from BP + ??, then you are dealing 
  902. with one of the parameters passed. Your next step is to work out why that 
  903. parameter was bad. To do this you need to track the parameters as the functions 
  904. are called. Sometimes this requires that you go back two or three functions. 
  905. Try to see where the parameter was created and then work it out from there. 
  906.  
  907. If the data causing the problem originated from BP - ??, then you are looking 
  908. at a local variable that is causing the trouble. In this case you must 
  909. concentrate on the function in which the trap occurred. 
  910.  
  911. Refer to  Fig. 9 - application dump stack.  for my recommended approach. 
  912.  
  913.  
  914. ΓòÉΓòÉΓòÉ 21.2. Corrupted stacks. ΓòÉΓòÉΓòÉ
  915.  
  916. A corrupted stack is one where data has overwritten areas of the stack that it 
  917. shouldn't have. 
  918.  
  919. There are two types of corruption that can occur. The first is that which 
  920. occurs when data overwites the return BP, CS and IP or when a null terminator 
  921. has corrupted a return BP. This type of corruption shows itself as a trap in 
  922. the return statement. 
  923.  
  924. The other type is when data from one variable, overwrites the values of the 
  925. variable next to it thus giving the overwritten variable invalid data. This 
  926. will manifest itself as a trap d when the application tries to use that invalid 
  927. data. 
  928.  
  929. Corrupted stacks require that you look carefully at the data on the stack, and 
  930. match what should be there with what is there. They are not impossible to fix, 
  931. and are in my opinion the most challenging dumps to get. 
  932.  
  933.  
  934. ΓòÉΓòÉΓòÉ 21.2.1. How do you know that you're dealing with a corrupt stack? ΓòÉΓòÉΓòÉ
  935.  
  936. There are a couple of indications that could point to this. 
  937.  
  938.  1. The CS:IP of the failing instruction does not look right, or the 
  939.     instruction that was being executed doesn't look correct. This could be 
  940.     because the data that has overwritten the return pointers did, by 
  941.     coincidence, make up a valid pointer but is now pointing to the middle of 
  942.     an instruction. 
  943.  
  944.  2. You have been unwinding the stack and suddenly the next return base pointer 
  945.     takes you back up the stack. This is a sure sign that something is wrong. 
  946.  
  947.  3. The next base pointer that you get is pointing to an odd number. The 
  948.     pointers used for return base pointers are always pointing to even offsets 
  949.     (word or doubleword alignment). 
  950.  
  951.  4. Look at the data around where the return base pointer should be. The most 
  952.     obvious would be if you displayed the stack at that area as bytes and 
  953.     discovered that where the return BP should be was right in the middle of a 
  954.     text field. Sometimes though, you aren't that lucky. Try see if the data 
  955.     matches the kind of data you'd expect for the program abended. 
  956.  
  957. Be careful that sometimes the point where you think the corruption has occurred 
  958. is not always the correct point. Sometimes the data that has overwritten your 
  959. return BP is valid in that it will refer you to somewhere else in the stack. 
  960. When you look at the return BP being pointed to you see it isn't valid, and 
  961. assume that that is where the stack has been corrupted. Unless you doublecheck, 
  962. this could lead you on a wild goose chase. For this reason I also keep an eye 
  963. on the return CS and IP, to ensure that they also look reasonably accurate. 
  964.  
  965.  
  966. ΓòÉΓòÉΓòÉ 21.2.2. How does a stack get corrupted ?. ΓòÉΓòÉΓòÉ
  967.  
  968. Because a stack is used for storing local variables, it does sometimes happen 
  969. that the programmer will try to move a string of 57 bytes into a field of 30 
  970. bytes. This will, obviously, overwrite the 27 bytes following the variable 
  971. concerned. Sometimes this will only affect other data fields, and this could 
  972. cause a problem if one of these variables is passed as a parameter to another 
  973. function. But in some cases it could overwrite the return BP, CS and IP. This 
  974. could cause a wild branch when the controlling function tries to hand control 
  975. back to its calling function. 
  976.  
  977. There are times when the programmer has defined a variable for length 10 and 
  978. then tries to move a data of 10 bytes into that field. If the language used was 
  979. C you have to make allowance for a null terminator. The result of the previous 
  980. example is that the lower byte of the return BP is overwritten by a null. 
  981.  
  982.  
  983. ΓòÉΓòÉΓòÉ 21.2.3. Example of a corrupted stack. ΓòÉΓòÉΓòÉ
  984.  
  985. Refer to  Corrupted stack example. for how I go about determining what caused a 
  986. stack to be corrupted. 
  987.  
  988.  
  989. ΓòÉΓòÉΓòÉ 22. Examples and diagrams. ΓòÉΓòÉΓòÉ
  990.  
  991. All of the diagrams displayed below are linked to from the various chapters 
  992. above. 
  993.  
  994.  
  995. ΓòÉΓòÉΓòÉ 22.1. Stack Conventions. ΓòÉΓòÉΓòÉ
  996.  
  997. Parameters are usually put onto the stack using PUSH and removed from the stack 
  998. using CALL. With the C convention, parameters are pushed onto the stack from 
  999. right to left, and they are removed from the stack by adding a constant to SP. 
  1000. The pascal convention pushes parameters on from left to right and removes them 
  1001. by specifying an operand for the RET which is added to SP after the return 
  1002. address has been taken off the stack. 
  1003.  
  1004.  
  1005. ΓòÉΓòÉΓòÉ 22.2. Fig 1 - stack before starting. ΓòÉΓòÉΓòÉ
  1006.  
  1007. The application has just entered function_one. The BP and SP are pointing
  1008. to the same place as no data has yet been moved to the stack.
  1009.  
  1010.           ΓöîΓöÇΓöÇΓöÇ EBP :  0000E95E
  1011.           Γöé    ESP :  0000E95E ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉ
  1012.           Γöé    SS :   001F              Γöé
  1013.           Γöé                             Γöé
  1014.           ΓööΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ
  1015.             Γöé
  1016.             Γöé  E92E 0000 0000 0000 0000 0000 0000 0000 0000
  1017.             Γöé  E93E 0000 0000 0000 0000 0000 0000 0000 0000
  1018.             Γöé  E94E 0000 0000 0000 0000 0000 0000 0000 0000
  1019.             Γöé  E95E 0000 0000 0000 0000 0000 0000 0000 0000
  1020.             Γöé       Γöé
  1021.             ΓööΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ
  1022.  
  1023.  
  1024. ΓòÉΓòÉΓòÉ 22.3. Fig 2 - stack after the enter command is executed. ΓòÉΓòÉΓòÉ
  1025.  
  1026. The value in SP has been decremented by 10 to allow space for the
  1027. local variables. This is all that will be done by the enter command.
  1028. The variables are initialised by other instructions.
  1029.  
  1030.               CS:IP  BD0F:E320
  1031.          ΓöîΓöÇΓöÇΓöÇ EBP :  0000E95E
  1032.          Γöé    ESP :  0000E954 ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉ
  1033.          Γöé    SS  :  001F                                  Γöé
  1034.          Γöé                                                 Γöé
  1035.          ΓööΓöÇΓöÇΓöÉ                                              Γöé
  1036.             Γöé                                              Γöé
  1037.             Γöé E92E 0000 0000 0000 0000 0000 0000 0000 0000 Γöé
  1038.             Γöé E93E 0000 0000 0000 0000 0000 0000 0000 0000 Γöé
  1039.             Γöé E94E 0000 0000 0000 0000 0000 0000 0000 0000 Γöé
  1040.             Γöé                     Γöé                        Γöé
  1041.             Γöé                     ΓööΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ
  1042.             Γöé E95E 0000 0000 0000 0000 0000 0000 0000 0000
  1043.             Γöé      Γöé
  1044.             ΓööΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤
  1045.  
  1046.  
  1047. ΓòÉΓòÉΓòÉ 22.4. Fig. 3 - first parameter pushed onto the stack. ΓòÉΓòÉΓòÉ
  1048.  
  1049. The first parameter has been pushed onto the stack, the SP value
  1050. has been decremented by two to and now points to the last parameter
  1051. pushed onto the stack.
  1052.  
  1053.          ΓöîΓöÇΓöÇΓöÇ EBP :  0000E95E
  1054.          Γöé    ESP :  0000E952 ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉ
  1055.          Γöé    SS  :  001F                                  Γöé
  1056.          Γöé                                                 Γöé
  1057.          ΓööΓöÇΓöÇΓöÉ                                              Γöé
  1058.             Γöé                                              Γöé
  1059.             Γöé E92E 0000 0000 0000 0000 0000 0000 0000 0000 Γöé
  1060.             Γöé E93E 0000 0000 0000 0000 0000 0000 0000 0000 Γöé
  1061.             Γöé E94E 0000 0000 0001 001a 0001 e012 007c 0100 Γöé
  1062.             Γöé                Γöé                             Γöé
  1063.             Γöé                ΓööΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ
  1064.             Γöé E95E 0000 0000 0000 0000 0000 0000 0000 0000
  1065.             Γöé      Γöé
  1066.             ΓööΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ
  1067.  
  1068.  
  1069. ΓòÉΓòÉΓòÉ 22.5. Fig. 4 - second parameter pushed onto the stack. ΓòÉΓòÉΓòÉ
  1070.  
  1071.  
  1072.          ΓöîΓöÇΓöÇΓöÇ EBP :  0000E95E
  1073.          Γöé    ESP :  0000E950 ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉ
  1074.          Γöé    SS  :  001F                                  Γöé
  1075.          Γöé                                                 Γöé
  1076.          ΓööΓöÇΓöÇΓöÉ                                              Γöé
  1077.             Γöé                                              Γöé
  1078.             Γöé E92E 0000 0000 0000 0000 0000 0000 0000 0000 Γöé
  1079.             Γöé E93E 0000 0000 0000 0000 0000 0000 0000 0000 Γöé
  1080.             Γöé E94E 0000 007c 0001 001a 0001 e012 007c 0100 Γöé
  1081.             Γöé           Γöé                                  Γöé
  1082.             Γöé           ΓööΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ
  1083.             Γöé E95E 0000 0000 0000 0000 0000 0000 0000 0000
  1084.             Γöé      Γöé
  1085.             ΓööΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ
  1086.  
  1087.  
  1088. ΓòÉΓòÉΓòÉ 22.6. Fig. 5 - just entered function_two. ΓòÉΓòÉΓòÉ
  1089.  
  1090. If we had executed a near call the SP would be E94C and the stack would not 
  1091. contain the bd0f that it currently has. 
  1092.  
  1093.                 CS:IP      BD36:0B5C
  1094.             ΓöîΓöÇΓöÇ EBP:  0000E95E
  1095.             Γöé   ESP:  0000E94C --ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉ
  1096.             Γöé   SS:   001F                                 Γöé
  1097.             Γöé                                              Γöé
  1098.             Γöé E92E 0000 0000 0000 0000 0000 0000 0000 0000 Γöé
  1099.             Γöé E93E 0000 0000 0000 0000 0000 0000 0000 e457 Γöé
  1100.             Γöé                                         Γöé    Γöé
  1101.             Γöé                                         ΓööΓöÇΓöÇΓöÇΓöÇΓöÿ
  1102.             Γöé E94E bd0f 007c 0001 001a 0001 e012 007c 0100
  1103.             Γöé E95E 0000 0000 0000 0000 0000 0000 0000 0000
  1104.             Γöé      Γöé
  1105.             ΓööΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ
  1106.  
  1107.  
  1108. ΓòÉΓòÉΓòÉ 22.7. Fig. 6 - stack after executing enter in function_two. ΓòÉΓòÉΓòÉ
  1109.  
  1110.                 CS:EIP:  BD36:00000B5E
  1111.             ΓöîΓöÇΓöÇ EBP:  0000E94A
  1112.             Γöé   ESP:  0000E924 -ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉ
  1113.             Γöé   SS:   001F                                 Γöé
  1114.             Γöé                                              Γöé
  1115.             Γöé E92E 0000 0000 0000 0000 0000 0000 0000 0000 Γöé
  1116.             Γöé                     Γöé                        Γöé
  1117.             Γöé                     ΓööΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ
  1118.             Γöé E93E 0000 0000 0000 0000 0000 0000 e95e e457
  1119.             Γöé                                    Γöé
  1120.             ΓööΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ
  1121.               E94E bdof 007c 0001 001a 0001 e012 007c 0100
  1122.               E95E 0000 0000 0000 0000 0000 0000 0000 0000
  1123.  
  1124.  
  1125. ΓòÉΓòÉΓòÉ 22.8. Fig. 7 - unwinding a stack. ΓòÉΓòÉΓòÉ
  1126.  
  1127. The following example will take you through a couple of frames of a stack. 
  1128. Notice how I start of by using the SS:BP to get to the first frame, and 
  1129. thereafter I use the SS and the return BP, to get to the next frame. I have 
  1130. also done a dl on the return CS. The fact that all of the return addresses in 
  1131. this example have a return CS indicates that all of the calls that we did were 
  1132. defined as far calls. The dl tells us that the segments are all code segments 
  1133. (if they showed as data or invalid, then you would assume that you were dealing 
  1134. with a near call, or a corrupt stack). I have also done a .m on all of the 
  1135. return addresses to show you how you can get information on which dlls you have 
  1136. gone through to get to where you abended. 
  1137.  
  1138. The colors used are as follows: 
  1139.  
  1140.  1. return BP 
  1141.  
  1142.  2. return IP 
  1143.  
  1144.  3. return CS 
  1145.  
  1146. (You should refer to Simplified look at unwinding the stack  once you have 
  1147. looked through this.) 
  1148.  
  1149.  
  1150.  
  1151. # dw ss:bp
  1152.  
  1153. 001f:0000e13e  e414 2c1e 5c5fffc5 5c4f 4a03 017f 5c57
  1154. 001f:0000e14e  e48b e44d 3300 61af 0000 0000 0000 ff00
  1155. 001f:0000e15e  ff0b 61ba 017f e168 001f 7fff 0001 9ec0
  1156. 001f:0000e16e  32d0 000f 98cc 30b0 0000 28c0 b200 ef9a
  1157. 001f:0000e17e  fe00 00ff 0000 bd00 00ac 0000 6377 0000
  1158. 001f:0000e18e  06d7 2947 bd0f 0001 000f 9ec0 32d0 0043
  1159. 001f:0000e19e  98cc 30b0 bd7f 0000 0000 0000 000c bd7f
  1160. 001f:0000e1ae  e1c6 281f bd0f 0000 0001 000f 9ec0 4242
  1161.  
  1162. # dl 5c5f
  1163.  
  1164. 5c5f  Code    Bas=0b8b0000 Lim=00002ff9 DPL=3 P  RE    A
  1165.  
  1166. # .m 5c5f:2c1e
  1167.  
  1168.  
  1169. *har     par      cpg        va    flg next prev link hash hob   hal
  1170.  0e57 %fee32b84 00000010 %0b8b0000 3d9 0e56 0e58 0000 0b54 1405 0000  hco=020f4
  1171.  hob   har hobnxt flgs own  hmte  sown,cnt lt st xf
  1172.  1405  0e57 0000  0838 1406 1406  0000 00  00 00 00 shared    c:bddas601.dll
  1173.  hco=20f4 pco=ffe6f4df  hconext=00000 hptda=121b f=1d  pid=004b c:bd.exe
  1174.  
  1175. # dw ss:e414
  1176.  
  1177. 001f:0000e414  e48c 0ff3 5c5f e4e4 001f 0000 0000 0000
  1178. 001f:0000e424  0000 0000 0000 0000 0000 0000 0000 0000
  1179. 001f:0000e434  0000 0000 0000 0000 0000 0000 0000 0000
  1180. 001f:0000e444  0000 0000 0000 0000 0000 001f e528 0068
  1181. 001f:0000e454  0000 0000 0000 0000 0000 0000 0000 0000
  1182. 001f:0000e464  0000 0000 0000 0000 0000 0000 0000 0000
  1183. 001f:0000e474  0000 0000 0000 0000 0000 0000 0000 0000
  1184. 001f:0000e484  0000 0000 0000 6100 e4a2 3204 000f e4e4
  1185.  
  1186. See how the last two frames above have the same return CS, so they have come 
  1187. from the same segment but have done so via a far call. 
  1188.  
  1189. # dw ss:e48c
  1190.  
  1191. 001f:0000e48c  e4a2 3204 000f e4e4 001f 619f e528 0068
  1192. 001f:0000e49c  0000 48a9 017f e4fa 64aa 61a7 e4e4 001f
  1193. 001f:0000e4ac  001f e528 ffff 0000 00b6 636f 0376 00b6
  1194. 001f:0000e4bc  0035 0bff bd7f e4ea 0000 0000 636f e4ea
  1195. 001f:0000e4cc  e076 0068 000a b470 bd0f 9c04 32a0 bd7f
  1196. 001f:0000e4dc  0000 e4f2 b44c bd0f 9c04 32a0 77e4 0020
  1197. 001f:0000e4ec  0000 4856 017f e4e4 001f bd27 0068 e518
  1198. 001f:0000e4fc  e456 bd0f 0001 0001 77e4 0000 0020 9c04
  1199.  
  1200. # dl f
  1201.  
  1202. 000f  Code    Bas=00010000 Lim=00004559 DPL=3 P  RE    A
  1203. # .m f:3204
  1204.  
  1205. *har     par      cpg        va    flg next prev link hash hob   hal
  1206.  0d4c %fee31492 00000010 %00010000 1d9 0d4d 0d4a 0000 0000 1223 0000 hptda=121b
  1207.  hob   har hobnxt flgs own  hmte  sown,cnt lt st xf
  1208.  1223  0d4c 0000  0838 1228 1228  0000 00  00 00 00 shared    c:bd.exe
  1209.  
  1210. # dw ss:e4a2
  1211.  
  1212. 001f:0000e4a2  e4fa 64aa 61a7 e4e4 001f 001f e528 ffff
  1213. 001f:0000e4b2  0000 00b6 636f 0376 00b6 0035 0bff bd7f
  1214. 001f:0000e4c2  e4ea 0000 0000 636f e4ea e076 0068 000a
  1215. 001f:0000e4d2  b470 bd0f 9c04 32a0 bd7f 0000 e4f2 b44c
  1216. 001f:0000e4e2  bd0f 9c04 32a0 77e4 0020 0000 4856 017f
  1217. 001f:0000e4f2  e4e4 001f bd27 0068 e518 e456 bd0f 0001
  1218. 001f:0000e502  0001 77e4 0000 0020 9c04 32a0 0002 0000
  1219. 001f:0000e512  9c04 32a0 bd7f e542 27e0 bd27 e528 001f
  1220.  
  1221. # dl 61a7
  1222.  
  1223. 61a7  Code    Bas=0c340000 Lim=00006d27 DPL=3 P  RE    A
  1224.  
  1225. # .m 61a7:64aa
  1226.  
  1227.  
  1228. *har     par      cpg        va    flg next prev link hash hob   hal
  1229.  0d86 %fee3198e 00000010 %0c340000 3d9 0d85 0d87 0000 0aab 1271 0000  hco=01e23
  1230.  hob   har hobnxt flgs own  hmte  sown,cnt lt st xf
  1231.  1271  0d86 0000  0838 1272 1272  0000 00  00 00 00 shared    c:ga1.dll
  1232.  hco=1e23 pco=ffe6e6ca  hconext=00000 hptda=121b f=1d  pid=004b c:bd.exe
  1233.  
  1234.  
  1235. ΓòÉΓòÉΓòÉ 22.9. Fig. 8 - Corrupted stack example. ΓòÉΓòÉΓòÉ
  1236.  
  1237. This example contains a corrupted stack. The aim here is to show you how to try 
  1238. and find out where it has been corrupted. Remember that as applications use the 
  1239. stack and PUSH and POP data onto and off of it, the data remains there until it 
  1240. is overwritten. A POP merely adjusts the SP value, it doesn't physically remove 
  1241. the data from the stack.  It is for this reason that you must NEVER assume that 
  1242. a local variable will be empty the first time you enter a function. The only 
  1243. time you can be sure that it has been cleared is if you have done it yourself. 
  1244.  
  1245. >
  1246. IBM OS/2 System Dump Formatter for retail kernel
  1247. Formatter is --> Internal revision 6.514, 93/04/12
  1248. Dump file is --> Internal revision 6.661, 95/03/30
  1249. Current slot number: 00a3
  1250. Symbol (c:\os2\pdpsi\pmdf\ga21\os2krnlr.sym) linked
  1251. Symbol (c:\os2\pdpsi\pmdf\ga21\pmshl32.sym) linked
  1252. Symbol (c:\os2\pdpsi\pmdf\ga21\pmviop.sym) linked
  1253. Symbol (c:\os2\pdpsi\pmdf\ga21\pmctls.sym) linked
  1254. Symbol (c:\os2\pdpsi\pmdf\ga21\pmspl.sym) linked
  1255. Symbol (c:\os2\pdpsi\pmdf\ga21\pmshapi.sym) linked
  1256. Symbol (c:\os2\pdpsi\pmdf\ga21\pmgre.sym) linked
  1257. Symbol (c:\os2\pdpsi\pmdf\ga21\pmwin.sym) linked
  1258. Symbol (c:\os2\pdpsi\pmdf\ga21\pmwp.sym) linked
  1259. Symbol (c:\os2\pdpsi\pmdf\ga21\quecalls.sym) linked
  1260. Symbol (c:\os2\pdpsi\pmdf\ga21\sesmgr.sym) linked
  1261. Symbol (c:\os2\pdpsi\pmdf\ga21\os2char.sym) linked
  1262. Symbol (c:\os2\pdpsi\pmdf\ga21\doscall1.sym) linked
  1263.  
  1264.  
  1265.  Slot  Pid  Ppid Csid Ord  Sta Pri  pTSD     pPTDA    pTCB     Disp SG Name
  1266. *00a3# 010e 000c 010e 0001 ___ 1402 7bbfb000 7bc8be74 7bc6a9e0 0970 07 BDREMCMD
  1267.  
  1268. eax=00000230 ebx=00000884 ecx=0000000c edx=00000000 esi=00000442 edi=00008f76
  1269. eip=0000123b esp=00008a74 ebp=0000000a iopl=2 rf -- -- nv up ei ng nz na po nc
  1270. cs=000f ss=0027 ds=0027 es=0027 fs=150b gs=0000  cr2=00000000  cr3=001af000
  1271. 000f:0000123b cb             retf
  1272. #
  1273. Loading version data ... please wait
  1274. Loading structure info for OS/2 2.1 General Availability  ... please wait....Done.
  1275.  
  1276. The data at the area pointed to by SS:BP is : 
  1277.  
  1278. # dw ss:bp
  1279.  
  1280. 0027:0000000a  5220 6e75 542d 6d69 2065 694c 7262 7261
  1281. 0027:0000001a  2079 202d 6f43 7970 6972 6867 2074 6328
  1282. 0027:0000002a  2029 3931 3838 202c 694d 7263 736f 666f
  1283. 0027:0000003a  2074 6f43 7072 0011 4442 4552 434d 444d
  1284. 0027:0000004a  3200 302e 0030 2e32 3030 4700 746f 7920
  1285. 0027:0000005a  756f 2121 2021 6f59 2075 656e 6465 5620
  1286. 0027:0000006a  7325 6f20 2066 4442 4552 4f4d 4554 2121
  1287. 0027:0000007a  5920 756f 6820 7661 2065 2556 0a73 4300
  1288.  
  1289. The data at the area pointed to by SS:SP is : 
  1290.  
  1291. # dw ss:sp
  1292.  
  1293. 0027:00008a74  0230 000a 0027 0000 0000 2e32 3030 0002
  1294. 0027:00008a84  8a9a 0000 0000 0023 0201 0002 0000 1328
  1295. 0027:00008a94  000f 0001 8aa0 0027 8ac0 0027 8aa8 0027
  1296. 0027:00008aa4  0000 0000 3a43 535c 5c42 5845 5c45 4442
  1297. 0027:00008ab4  4552 434d 444d 452e 4558 0300 8b34 0027
  1298. 0027:00008ac4  8b4c 0027 8b69 0027 8b82 0027 8ba2 0027
  1299. 0027:00008ad4  8bb9 0027 8bd4 0027 8bf6 0027 8cc6 0027
  1300. 0027:00008ae4  8d9f 0027 8dad 0027 8df6 0027 8e12 0027
  1301.  The first indicator that we are dealing with a corrupt stack is the fact that 
  1302. the instruction that has trapped is a far return. The next pointer is the 
  1303. difference between the SP and the BP. The difference between the two should 
  1304. NEVER be that great (It would be a truly bad programmer that had a local 
  1305. variable of greater than 30000 bytes.). If we display the data at the BP, and 
  1306. then do a dl on the CS that we should return to (because we are doing a retf we 
  1307. know that the CS and the IP will be on the stack after the base pointer), we 
  1308. get : 
  1309.  
  1310. # DL 542D
  1311.  
  1312. 542d  Invalid Bas=00000000 Lim=00000000 DPL=0 NP
  1313. #
  1314.  If we were not doing a retf and we wanted to make sure, then we could do a dl 
  1315. on the segment that we are currently in (f) and then check that the IP we would 
  1316. return to (according to the stack 6e75) was in the range of that CS. 
  1317.  
  1318. # DL F
  1319.  
  1320. 000f  Code    Bas=00010000 Lim=000043c9 DPL=3 P  RE    A
  1321.  
  1322. # DW F:6E75
  1323.  
  1324. Past end of segment: 000f:00006e75
  1325.  
  1326. #
  1327.  Currently our SP points to 8a74, the BP points to a. We know that the bp is 
  1328. obtained from the stack. When a return is executed, the BP is popped from the 
  1329. stack and the SP is adjusted by two (because we are popping data the value is 
  1330. decremented by two) therefore display the stack from some point above the 
  1331. current SP. Currently, to give substance to the theory that the original return 
  1332. was to 8a72 before the BP was adjusted, is the fact that at 8a72, there is a 
  1333. value a. Now that you have listed the stack from SP - ??, search through it 
  1334. looking for 8a72. You will find one at 8922, and the return address there is 
  1335. f:1233. Do an unpack on f:123b (the address of the return instruction on which 
  1336. we are crashing. You will get : 
  1337.  
  1338. # U CS:IP - 20
  1339.  
  1340. 000f:0000121b 051e00         add     ax,001e
  1341. 000f:0000121e 52             push    dx
  1342. 000f:0000121f 50             push    ax
  1343. 000f:00001220 90             nop
  1344. 000f:00001221 0e             push    cs
  1345. 000f:00001222 e80505         call    172a
  1346. 000f:00001225 83c408         add     sp,+08
  1347. 000f:00001228 ff76c4         push    word ptr [bp-3c]
  1348. 000f:0000122b ff76c2         push    word ptr [bp-3e]
  1349. 000f:0000122e 90             nop
  1350. 000f:0000122f 0e             push    cs
  1351. 000f:00001230 e88502         call    14b8
  1352. # U
  1353.  
  1354. 000f:00001233 83c404         add     sp,+04
  1355. 000f:00001236 8b46fe         mov     ax,word ptr [bp-02]
  1356. 000f:00001239 1f             pop     ds
  1357. 000f:0000123a c9             leave
  1358. 000f:0000123b cb             retf
  1359. 000f:0000123c 680501         push    0105
  1360. 000f:0000123f 8e065e0a       mov     es,word ptr [0a5e]
  1361. 000f:00001243 26a11e01       mov     ax,word ptr es:[011e]
  1362. 000f:00001247 268b162001     mov     dx,word ptr es:[0120]
  1363. 000f:0000124c 051e00         add     ax,001e
  1364. 000f:0000124f 52             push    dx
  1365. 000f:00001250 50             push    ax
  1366. #
  1367.  The address 1233 does point to the next instruction after a call, therefore I 
  1368. am now going to assume that that was the last correct frame. Now that we know 
  1369. we were returning to 8a72, we have to look at the area in the BP - ?? to see if 
  1370. we can find a string that has overwritten the return addresses at 8a72. 
  1371.  
  1372. Stack displayed as bytes. 
  1373.  
  1374. # db ss:sp - 500 l500
  1375.  
  1376. 0027:00008574 00 01 08 86 27 00 12 18-1f a8 00 00 00 00 01 00 ....'....(......
  1377. 0027:00008584 01 00 37 d0 0c 86 95 04-b5 01 b5 01 52 03 00 00 ..7P....5.5.R...
  1378. 0027:00008594 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
  1379. 0027:000085a4 00 00 00 00 00 00 00 00-00 00 00 00 00 00 06 00 ................
  1380. 0027:000085b4 00 00 06 00 01 00 00 00-b5 01 01 00 01 00 ea 85 ........5.....j.
  1381. 0027:000085c4 f1 2a 02 00 00 01 08 86-27 00 12 18 1f a8 00 00 q*......'....(..
  1382. 0027:000085d4 ea 85 95 04 0c 86 00 00-27 00 12 18 1f a8 37 d0 j.......'....(7P
  1383. 0027:000085e4 fa 2a 1f a8 00 00 16 86-a4 27 67 a8 12 18 1f a8 z*.(....$'g(...(
  1384. 0027:000085f4 08 86 27 00 00 01 1f a8-95 04 00 00 01 04 f4 df ..'....(......t_
  1385. 0027:00008604 00 01 86 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
  1386. 0027:00008614 00 00 24 87 f9 2e 67 a8-1f a8 e4 1d 67 a8 1f a8 ..$.y.g(.(d.g(.(
  1387. 0027:00008624 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
  1388. 0027:00008634 00 00 00 00 00 00 37 d0-00 00 6a 01 02 00 02 00 ......7P..j.....
  1389. 0027:00008644 6b 06 37 d0 7a 86 8e 2e-8c 21 ef aa 00 01 ee 01 k.7Pz....!o*..n.
  1390. 0027:00008654 6b 06 6c 01 6b 06 80 00-37 d0 ee 01 6b 06 6c 01 k.l.k...7Pn.k.l.
  1391. 0027:00008664 6b 06 00 00 6b 06 02 00-6b 06 80 00 3a 00 6b 06 k...k...k...:.k.
  1392. 0027:00008674 b5 01 ca 86 da 2c ce 86-da 2c 02 00 00 01 14 87 5.J.Z,N.Z,......
  1393. 0027:00008684 e4 88 27 00 f1 00 de 86-27 00 06 00 f1 00 06 00 d.'.q.^.'...q...
  1394. 0027:00008694 c2 86 cc 09 2f d0 e4 88-27 00 f1 00 de 86 18 0a B.L./Pd.'.q.^...
  1395. 0027:000086a4 c2 86 f1 00 06 00 de 86-f1 00 06 00 27 00 3f d0 B.q...^.q...'.?P
  1396. 0027:000086b4 18 0a 27 00 f7 00 cf 87-00 00 06 00 00 00 f0 88 ..'.w.O.......p.
  1397. 0027:000086c4 c2 39 0f 00 e4 88 27 00-f1 00 de 86 27 00 06 00 B9..d.'.q.^.'...
  1398. 0027:000086d4 8f 00 00 00 de 88 0a 79-7a 39 0d 0a 0d 0a 55 73 ....^..yz9....Us
  1399. 0027:000086e4 65 72 69 64 3a 20 20 79-6f 75 21 21 21 20 59 6f erid:  you!!! Yo
  1400. 0027:000086f4 75 20 6e 65 65 64 20 56-32 2e 30 30 20 6f 66 20 u need V2.00 of
  1401. 0027:00008704 42 44 52 45 4d 4f 54 45-21 21 20 59 6f 75 20 68 BDREMOTE!! You h
  1402. 0027:00008714 61 76 65 20 56 32 2e 30-30 02 0d 0a 20 20 4d 61 ave V2.00...  Ma
  1403. 0027:00008724 63 68 69 6e 65 20 49 44-3a 20 59 6f 75 20 6e 65 chine ID: You ne
  1404. 0027:00008734 65 64 20 56 32 2e 30 30-20 6f 66 20 42 44 52 45 ed V2.00 of BDRE
  1405. 0027:00008744 4d 4f 54 45 21 21 20 59-6f 75 20 68 61 76 65 20 MOTE!! You have
  1406. 0027:00008754 56 32 2e 30 30 02 0d 0a-20 20 44 61 74 65 3a 20 V2.00...  Date:
  1407. 0027:00008764 31 39 39 35 2d 30 37 2d-31 30 20 20 54 69 6d 65 1995-07-10  Time
  1408. 0027:00008774 3a 20 31 34 3a 30 31 3a-32 38 3a 33 39 0d 0a 2d : 14:01:28:39..-
  1409. 0027:00008784 2d 2d 2d 2d 2d 2d 2d 2d-2d 2d 2d 2d 2d 2d 2d 2d ----------------
  1410. 0027:00008794 2d 2d 2d 2d 2d 2d 2d 2d-2d 2d 2d 2d 2d 2d 2d 2d ----------------
  1411. 0027:000087a4 2d 2d 2d 2d 2d 2d 2d 2d-2d 2d 2d 2d 2d 2d 2d 2d ----------------
  1412. 0027:000087b4 2d 2d 2d 2d 2d 2d 2d 2d-2d 2d 2d 2d 2d 2d 2d 2d ----------------
  1413. 0027:000087c4 2d 2d 2d 2d 2d 2d 2d 2d-2d 0d 0a 00 3f d0 85 07 ---------...?P..
  1414. 0027:000087d4 27 00 42 04 76 8f 00 00-8f 00 00 01 1e 88 17 00 '.B.v...........
  1415. 0027:000087e4 30 07 0b 00 97 00 00 00-00 00 22 89 d3 10 0f 00 0.........".S...
  1416. 0027:000087f4 00 00 00 00 01 00 00 00-00 00 c4 02 62 1f 27 00 ..........D.b.'.
  1417. 0027:00008804 62 1f 30 07 57 a9 1e 88-27 00 00 01 57 a9 03 04 b.0.W)..'...W)..
  1418. 0027:00008814 00 00 01 ac f4 df 00 01-ef ac 00 00 00 00 00 00 ...,t_..o,......
  1419. 0027:00008824 00 00 00 00 00 00 00 00-46 88 0b 00 f7 cf 57 a9 ........F...wOW)
  1420. 0027:00008834 58 88 27 00 4a 0c 2f a3-ea 51 8f a3 d1 03 2a 51 X.'.J./#jQ.#Q.*Q
  1421. 0027:00008844 00 00 00 00 86 2e 9e 17-21 52 8f a3 ea 51 8f a3 ........!R.#jQ.#
  1422. 0027:00008854 4a 0c 2f a3 d1 03 00 17-2c 00 9e 17 68 88 04 00 J./#Q...,...h...
  1423. 0027:00008864 53 00 9e 17 00 00 00 00-3c 66 00 00 a0 88 04 00 S.......<f.. ...
  1424. 0027:00008874 a3 2a 9e 17 3c 66 12 17-00 73 0e 17 2a 2b 9e 17 #*..<f...s..*+..
  1425. 0027:00008884 3c 66 12 17 00 73 0e 17-48 88 04 00 09 00 00 00 <f...s..H.......
  1426. 0027:00008894 9a 88 00 00 76 8f 00 00-b6 88 db 2c 0f 00 36 0c ....v...6.[,..6.
  1427. 0027:000088a4 27 00 02 00 37 0c 34 0c-27 00 02 00 00 00 00 00 '...7.4.'.......
  1428. 0027:000088b4 27 00 d4 88 ef 28 0f 00-00 00 42 04 76 8f 27 00 '.T.o(....B.v.'.
  1429. 0027:000088c4 42 04 37 0c 27 00 00 00-13 0c 27 00 00 00 4c 00 B.7.'.....'...L.
  1430. 0027:000088d4 00 00 88 08 e4 88 4a 39-0f 00 8f 00 00 00 76 8f ....d.J9......v.
  1431. 0027:000088e4 f1 00 00 00 e0 88 27 00-06 00 f1 00 04 89 2d 23 q...`.'...q...-#
  1432. 0027:000088f4 0f 00 06 00 0c 00 04 89-07 20 0f 00 0c 00 8f 00 ......... ......
  1433. 0027:00008904 06 00 22 89 1d 15 0f 00-06 00 42 04 84 08 27 00 ..".......B...'.
  1434. 0027:00008914 42 04 76 8f 4c 00 27 00-00 00 72 8a e5 11 72 8a B.v.L.'...r.e.r.
  1435. 0027:00008924 33 12 0f 00 84 08 27 00-27 00 8f a3 ce 0b 1e 0c 3.....'.'..#N...
  1436. 0027:00008934 68 89 04 00 01 00 00 00-1a 00 81 00 66 08 27 a3 h...........f.'#
  1437. 0027:00008944 20 00 03 00 54 89 02 00-56 89 7f 7a 97 5f 00 00  ...T...V..z._..
  1438. 0027:00008954 00 00 04 00 01 00 01 00-6c 9e 97 5f 66 08 27 a3 ........l.._f.'#
  1439. 0027:00008964 20 00 00 00 00 00 82 16-76 89 7f 7a 97 5f 00 00  .......v..z._..
  1440. 0027:00008974 00 00 00 00 00 00 82 16-82 89 0d 76 8f a3 00 00 ...........v.#..
  1441. 0027:00008984 14 00 00 00 97 5f 38 00-37 00 a0 f1 df 9c 00 00 ....._8.7. q_...
  1442. 0027:00008994 00 00 05 00 20 00 2f a3-a6 89 10 0c 8f a3 ce 0b .... ./#-....#N.
  1443. 0027:000089a4 1e 0c 00 00 97 5f 00 f0-ff ef d2 16 ef 9c 00 00 ....._.p.oR.o...
  1444. 0027:000089b4 00 00 06 00 24 00 2f a3-c6 89 10 0c 8f a3 ce 0b ....$./#F....#N.
  1445. 0027:000089c4 1e 0c 00 00 16 01 1f 00-22 8a 27 00 08 00 27 00 ........".'...'.
  1446. 0027:000089d4 d8 89 27 00 16 00 00 00-00 00 00 00 00 00 c2 c4 X.'...........BD
  1447. 0027:000089e4 d9 c5 d4 c3 d4 c4 40 40-40 40 40 40 40 40 40 40 YETCTD@@@@@@@@@@
  1448. 0027:000089f4 40 40 40 40 40 40 40 40-40 40 05 00 fb ff 05 00 @@@@@@@@@@..{...
  1449. 0027:00008a04 24 8a cd a9 88 f1 df 9c-20 00 7f 8f f3 04 76 8f $.M).q_. ...s.v.
  1450. 0027:00008a14 69 8a 00 00 27 00 88 00-00 00 00 00 00 00 00 00 i...'...........
  1451. 0027:00008a24 26 8a 27 00 41 88 6a 8a-1f 00 76 8f 97 5f 00 00 -.'.A.j...v.._..
  1452. 0027:00008a34 84 08 27 00 20 20 44 61-74 65 3a 20 31 39 39 35 ..'.  Date: 1995
  1453. 0027:00008a44 2d 30 37 2d 31 30 20 20-54 69 6d 65 3a 20 31 34 -07-10  Time: 14
  1454. 0027:00008a54 3a 30 31 3a 32 38 3a 33-39 00 54 45 21 21 20 59 :01:28:39.TE!! Y
  1455. 0027:00008a64 6f 75 20 68 61 76 65 20-56 32 2e 30 30 02 0a 00 ou have V2.00...
  1456. 0027:00008a74 30 02 0a 00 27 00 00 00-00 00 32 2e 30 30 02 00 0...'.....2.00..
  1457. 0027:00008a84 9a 8a 00 00 00 00 23 00-01 02 02 00 00 00 28 13 ......#.......(.
  1458. 0027:00008a94 0f 00 01 00 a0 8a 27 00-c0 8a 27 00 a8 8a 27 00 .... .'.@.'.(.'.
  1459. 0027:00008aa4 00 00 00 00 43 3a 5c 53-42 5c 45 58 45 5c 42 44 ....C:\SB\EXE\BD
  1460. 0027:00008ab4 52 45 4d 43 4d 44 2e 45-58 45 00 03 34 8b 27 00 REMCMD.EXE..4.'.
  1461. 0027:00008ac4 4c 8b 27 00 69 8b 27 00-82 8b 27 00 a2 8b 27 00 L.'.i.'...'.".'.
  1462. 0027:00008ad4 b9 8b 27 00 d4 8b 27 00-f6 8b 27 00 c6 8c 27 00 9.'.T.'.v.'.F.'.
  1463. 0027:00008ae4 9f 8d 27 00 ad 8d 27 00-f6 8d 27 00 12 8e 27 00 ..'.-.'.v.'...'.
  1464. 0027:00008af4 20 8e 27 00 30 8e 27 00-4e 8e 27 00 56 8e 27 00  .'.0.'.N.'.V.'.
  1465. 0027:00008b04 a1 8e 27 00 b6 8e 27 00-cc 8e 27 00 ea 8e 27 00 !.'.6.'.L.'.j.'.
  1466. 0027:00008b14 08 8f 27 00 1b 8f 27 00-2a 8f 27 00 32 8f 27 00 ..'...'.*.'.2.'.
  1467. 0027:00008b24 44 8f 27 00 54 8f 27 00-65 8f 27 00 00 00 00 00 D.'.T.'.e.'.....
  1468. 0027:00008b34 55 53 45 52 5f 49 4e 49-3d 43 3a 5c 4f 53 32 5c USER_INI=C:\OS2\
  1469. 0027:00008b44 4f 53 32 2e 49 4e 49 00-53 59 53 54 45 4d 5f 49 OS2.INI.SYSTEM_I
  1470. 0027:00008b54 4e 49 3d 43 3a 5c 4f 53-32 5c 4f 53 32 53 59 53 NI=C:\OS2\OS2SYS
  1471. 0027:00008b64 2e 49 4e 49 00 4f 53 32-5f 53 48 45 4c 4c 3d 43 .INI.OS2_SHELL=C
  1472. 0027:00008b74 3a 5c 4f 53 32 5c 43 4d-44 2e 45 58 45 00 52 55 :\OS2\CMD.EXE.RU
  1473. 0027:00008b84 4e 57 4f 52 4b 50 4c 41-43 45 3d 43 3a 5c 4f 53 NWORKPLACE=C:\OS
  1474. 0027:00008b94 32 5c 50 4d 53 48 45 4c-4c 2e 45 58 45 00 43 4f 2\PMSHELL.EXE.CO
  1475. 0027:00008ba4 4d 53 50 45 43 3d 43 3a-5c 4f 53 32 5c 43 4d 44 MSPEC=C:\OS2\CMD
  1476. 0027:00008bb4 2e 45 58 45 00 41 55 54-4f 53 54 41 52 54 3d 54 .EXE.AUTOSTART=T
  1477. 0027:00008bc4 41 53 4b 4c 49 53 54 2c-46 4f 4c 44 45 52 53 00 ASKLIST,FOLDERS.
  1478. 0027:00008bd4 52 45 53 54 41 52 54 4f-42 4a 45 43 54 53 3d 53 RESTARTOBJECTS=S
  1479. 0027:00008be4 54 41 52 54 55 50 46 4f-4c 44 45 52 53 4f 4e 4c TARTUPFOLDERSONL
  1480.  
  1481. Stack displayed as words. 
  1482.  
  1483. # dw ss:sp - 500 l500
  1484.  
  1485. 0027:00008574  0100 8608 0027 1812 a81f 0000 0000 0001
  1486. 0027:00008584  0001 d037 860c 0495 01b5 01b5 0352 0000
  1487. 0027:00008594  0000 0000 0000 0000 0000 0000 0000 0000
  1488. 0027:000085a4  0000 0000 0000 0000 0000 0000 0000 0006
  1489. 0027:000085b4  0000 0006 0001 0000 01b5 0001 0001 85ea
  1490. 0027:000085c4  2af1 0002 0100 8608 0027 1812 a81f 0000
  1491. 0027:000085d4  85ea 0495 860c 0000 0027 1812 a81f d037
  1492. 0027:000085e4  2afa a81f 0000 8616 27a4 a867 1812 a81f
  1493. 0027:000085f4  8608 0027 0100 a81f 0495 0000 0401 dff4
  1494. 0027:00008604  0100 0086 0000 0000 0000 0000 0000 0000
  1495. 0027:00008614  0000 8724 2ef9 a867 a81f 1de4 a867 a81f
  1496. 0027:00008624  0000 0000 0000 0000 0000 0000 0000 0000
  1497. 0027:00008634  0000 0000 0000 d037 0000 016a 0002 0002
  1498. 0027:00008644  066b d037 867a 2e8e 218c aaef 0100 01ee
  1499. 0027:00008654  066b 016c 066b 0080 d037 01ee 066b 016c
  1500. 0027:00008664  066b 0000 066b 0002 066b 0080 003a 066b
  1501. 0027:00008674  01b5 86ca 2cda 86ce 2cda 0002 0100 8714
  1502. 0027:00008684  88e4 0027 00f1 86de 0027 0006 00f1 0006
  1503. 0027:00008694  86c2 09cc d02f 88e4 0027 00f1 86de 0a18
  1504. 0027:000086a4  86c2 00f1 0006 86de 00f1 0006 0027 d03f
  1505. 0027:000086b4  0a18 0027 00f7 87cf 0000 0006 0000 88f0
  1506. 0027:000086c4  39c2 000f 88e4 0027 00f1 86de 0027 0006
  1507. 0027:000086d4  008f 0000 88de 790a 397a 0a0d 0a0d 7355
  1508. 0027:000086e4  7265 6469 203a 7920 756f 2121 2021 6f59
  1509. 0027:000086f4  2075 656e 6465 5620 2e32 3030 6f20 2066
  1510. 0027:00008704  4442 4552 4f4d 4554 2121 5920 756f 6820
  1511. 0027:00008714  7661 2065 3256 302e 0230 0a0d 2020 614d
  1512. 0027:00008724  6863 6e69 2065 4449 203a 6f59 2075 656e
  1513. 0027:00008734  6465 5620 2e32 3030 6f20 2066 4442 4552
  1514. 0027:00008744  4f4d 4554 2121 5920 756f 6820 7661 2065
  1515. 0027:00008754  3256 302e 0230 0a0d 2020 6144 6574 203a
  1516. 0027:00008764  3931 3539 302d 2d37 3031 2020 6954 656d
  1517. 0027:00008774  203a 3431 303a 3a31 3832 333a 0d39 2d0a
  1518. 0027:00008784  2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d
  1519. 0027:00008794  2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d
  1520. 0027:000087a4  2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d
  1521. 0027:000087b4  2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d
  1522. 0027:000087c4  2d2d 2d2d 2d2d 2d2d 0d2d 000a d03f 0785
  1523. 0027:000087d4  0027 0442 8f76 0000 008f 0100 881e 0017
  1524. 0027:000087e4  0730 000b 0097 0000 0000 8922 10d3 000f
  1525. 0027:000087f4  0000 0000 0001 0000 0000 02c4 1f62 0027
  1526. 0027:00008804  1f62 0730 a957 881e 0027 0100 a957 0403
  1527. 0027:00008814  0000 ac01 dff4 0100 acef 0000 0000 0000
  1528. 0027:00008824  0000 0000 0000 0000 8846 000b cff7 a957
  1529. 0027:00008834  8858 0027 0c4a a32f 51ea a38f 03d1 512a
  1530. 0027:00008844  0000 0000 2e86 179e 5221 a38f 51ea a38f
  1531. 0027:00008854  0c4a a32f 03d1 1700 002c 179e 8868 0004
  1532. 0027:00008864  0053 179e 0000 0000 663c 0000 88a0 0004
  1533. 0027:00008874  2aa3 179e 663c 1712 7300 170e 2b2a 179e
  1534. 0027:00008884  663c 1712 7300 170e 8848 0004 0009 0000
  1535. 0027:00008894  889a 0000 8f76 0000 88b6 2cdb 000f 0c36
  1536. 0027:000088a4  0027 0002 0c37 0c34 0027 0002 0000 0000
  1537. 0027:000088b4  0027 88d4 28ef 000f 0000 0442 8f76 0027
  1538. 0027:000088c4  0442 0c37 0027 0000 0c13 0027 0000 004c
  1539. 0027:000088d4  0000 0888 88e4 394a 000f 008f 0000 8f76
  1540. 0027:000088e4  00f1 0000 88e0 0027 0006 00f1 8904 232d
  1541. 0027:000088f4  000f 0006 000c 8904 2007 000f 000c 008f
  1542. 0027:00008904  0006 8922 151d 000f 0006 0442 0884 0027
  1543. 0027:00008914  0442 8f76 004c 0027 0000 8a72 11e5 8a72
  1544. 0027:00008924  1233 000f 0884 0027 0027 a38f 0bce 0c1e
  1545. 0027:00008934  8968 0004 0001 0000 001a 0081 0866 a327
  1546. 0027:00008944  0020 0003 8954 0002 8956 7a7f 5f97 0000
  1547. 0027:00008954  0000 0004 0001 0001 9e6c 5f97 0866 a327
  1548. 0027:00008964  0020 0000 0000 1682 8976 7a7f 5f97 0000
  1549. 0027:00008974  0000 0000 0000 1682 8982 760d a38f 0000
  1550. 0027:00008984  0014 0000 5f97 0038 0037 f1a0 9cdf 0000
  1551. 0027:00008994  0000 0005 0020 a32f 89a6 0c10 a38f 0bce
  1552. 0027:000089a4  0c1e 0000 5f97 f000 efff 16d2 9cef 0000
  1553. 0027:000089b4  0000 0006 0024 a32f 89c6 0c10 a38f 0bce
  1554. 0027:000089c4  0c1e 0000 0116 001f 8a22 0027 0008 0027
  1555. 0027:000089d4  89d8 0027 0016 0000 0000 0000 0000 c4c2
  1556. 0027:000089e4  c5d9 c3d4 c4d4 4040 4040 4040 4040 4040
  1557. 0027:000089f4  4040 4040 4040 4040 4040 0005 fffb 0005
  1558. 0027:00008a04  8a24 a9cd f188 9cdf 0020 8f7f 04f3 8f76
  1559. 0027:00008a14  8a69 0000 0027 0088 0000 0000 0000 0000
  1560. 0027:00008a24  8a26 0027 8841 8a6a 001f 8f76 5f97 0000
  1561. 0027:00008a34  0884 0027 2020 6144 6574 203a 3931 3539
  1562. 0027:00008a44  302d 2d37 3031 2020 6954 656d 203a 3431
  1563. 0027:00008a54  303a 3a31 3832 333a 0039 4554 2121 5920
  1564. 0027:00008a64  756f 6820 7661 2065 3256 302e 0230 000a
  1565. 0027:00008a74  0230 000a 0027 0000 0000 2e32 3030 0002
  1566. 0027:00008a84  8a9a 0000 0000 0023 0201 0002 0000 1328
  1567. 0027:00008a94  000f 0001 8aa0 0027 8ac0 0027 8aa8 0027
  1568. 0027:00008aa4  0000 0000 3a43 535c 5c42 5845 5c45 4442
  1569. 0027:00008ab4  4552 434d 444d 452e 4558 0300 8b34 0027
  1570. 0027:00008ac4  8b4c 0027 8b69 0027 8b82 0027 8ba2 0027
  1571. 0027:00008ad4  8bb9 0027 8bd4 0027 8bf6 0027 8cc6 0027
  1572. 0027:00008ae4  8d9f 0027 8dad 0027 8df6 0027 8e12 0027
  1573. 0027:00008af4  8e20 0027 8e30 0027 8e4e 0027 8e56 0027
  1574. 0027:00008b04  8ea1 0027 8eb6 0027 8ecc 0027 8eea 0027
  1575. 0027:00008b14  8f08 0027 8f1b 0027 8f2a 0027 8f32 0027
  1576. 0027:00008b24  8f44 0027 8f54 0027 8f65 0027 0000 0000
  1577. 0027:00008b34  5355 5245 495f 494e 433d 5c3a 534f 5c32
  1578. 0027:00008b44  534f 2e32 4e49 0049 5953 5453 4d45 495f
  1579. 0027:00008b54  494e 433d 5c3a 534f 5c32 534f 5332 5359
  1580. 0027:00008b64  492e 494e 4f00 3253 535f 4548 4c4c 433d
  1581. 0027:00008b74  5c3a 534f 5c32 4d43 2e44 5845 0045 5552
  1582. 0027:00008b84  574e 524f 504b 414c 4543 433d 5c3a 534f
  1583. 0027:00008b94  5c32 4d50 4853 4c45 2e4c 5845 0045 4f43
  1584. 0027:00008ba4  534d 4550 3d43 3a43 4f5c 3253 435c 444d
  1585. 0027:00008bb4  452e 4558 4100 5455 534f 4154 5452 543d
  1586. 0027:00008bc4  5341 4c4b 5349 2c54 4f46 444c 5245 0053
  1587. 0027:00008bd4  4552 5453 5241 4f54 4a42 4345 5354 533d
  1588. 0027:00008be4  4154 5452 5055 4f46 444c 5245 4f53 4c4e
  1589. 0027:00008bf4  0059 4150 4854 433d 5c3a 4253 455c 4558
  1590. 0027:00008c04  433b 5c3a 4344 4641 3231 433b 5c3a 5153
  1591. 0027:00008c14  4c4c 4249 433b 5c3a 4249 4c4d 4e41 4e5c
  1592. 0027:00008c24  5445 5250 474f 433b 5c3a 554d 4c47 4249
  1593. 0027:00008c34  433b 5c3a 534f 3b32 3a43 435c 4c4d 4249
  1594. 0027:00008c44  433b 5c3a 534f 5c32 5953 5453 4d45 433b
  1595. 0027:00008c54  5c3a 534f 5c32 444d 534f 575c 4e49 534f
  1596. 0027:00008c64  3b32 3a43 4f5c 3253 495c 534e 4154 4c4c
  1597. 0027:00008c74  433b 5c3a 433b 5c3a 534f 5c32 444d 534f
  1598. 0027:00008c84  433b 5c3a 534f 5c32 5041 5350 433b 5c3a
  1599. 0027:00008c94  444e 5c4d 4942 3b4e 3a43 4c5c 554d 3b32
  1600. 0027:00008ca4  3a43 535c 5059 554c 3b53 3a43 545c 534d
  1601. 0027:00008cb4  433b 5c3a 4f52 4f42 4153 4556 573b 5c3a
  1602. 0027:00008cc4  003b 5044 5441 3d48 3a43 535c 5c42 4144
  1603. 0027:00008cd4  4154 433b 5c3a 4253 435c 4746 433b 5c3a
  1604. 0027:00008ce4  4344 4641 3231 433b 5c3a 5153 4c4c 4249
  1605. 0027:00008cf4  433b 5c3a 4249 4c4d 4e41 4e5c 5445 5250
  1606. 0027:00008d04  474f 433b 5c3a 4249 4c4d 4e41 433b 5c3a
  1607. 0027:00008d14  554d 4c47 4249 433b 5c3a 4249 434d 4d4f
  1608. 0027:00008d24  433b 5c3a 534f 3b32 3a43 435c 4c4d 4249
  1609. 0027:00008d34  433b 5c3a 534f 5c32 5953 5453 4d45 433b
  1610. 0027:00008d44  5c3a 534f 5c32 444d 534f 575c 4e49 534f
  1611. 0027:00008d54  3b32 3a43 4f5c 3253 495c 534e 4154 4c4c
  1612. 0027:00008d64  433b 5c3a 433b 5c3a 534f 5c32 4942 4d54
  1613. 0027:00008d74  5041 433b 5c3a 534f 5c32 444d 534f 433b
  1614. 0027:00008d84  5c3a 534f 5c32 5041 5350 433b 5c3a 444e
  1615. 0027:00008d94  3b4d 3a43 4c5c 554d 3b32 5000 4f52 504d
  1616. 0027:00008da4  3d54 6924 245b 5d70 4800 4c45 3d50 3a43
  1617. 0027:00008db4  535c 4c51 494c 3b42 3a43 4f5c 3253 485c
  1618. 0027:00008dc4  4c45 3b50 3a43 4f5c 3253 485c 4c45 5c50
  1619. 0027:00008dd4  5554 4f54 4952 4c41 433b 5c3a 4d43 494c
  1620. 0027:00008de4  3b42 3a43 4c5c 554d 3b32 3a43 4e5c 4d44
  1621. 0027:00008df4  003b 4c47 534f 4153 5952 433d 5c3a 534f
  1622. 0027:00008e04  5c32 4548 504c 475c 4f4c 5353 003b 5049
  1623. 0027:00008e14  5f46 454b 5359 533d 4342 0053 414b 454c
  1624. 0027:00008e24  444e 5245 433d 5c3a 4253 005c 4442 4844
  1625. 0027:00008e34  4c45 3d50 3a43 535c 5c42 5049 5c46 4442
  1626. 0027:00008e44  4844 4c45 2e50 4c48 0050 454b 5359 4f3d
  1627. 0027:00008e54  004e 4f42 4b4f 4853 4c45 3d46 3a43 535c
  1628. 0027:00008e64  4c51 494c 5c42 4f42 4b4f 433b 5c3a 4249
  1629. 0027:00008e74  4c4d 4e41 425c 4f4f 3b4b 3a43 4f5c 3253
  1630. 0027:00008e84  425c 4f4f 3b4b 3a43 435c 4c4d 4249 425c
  1631. 0027:00008e94  4f4f 3b4b 3a43 4c5c 554d 3b32 4500 4d50
  1632. 0027:00008ea4  4150 4854 433d 5c3a 534f 5c32 5041 5350
  1633. 0027:00008eb4  003b 4956 4544 5f4f 4544 4956 4543 3d53
  1634. 0027:00008ec4  4956 5f4f 4758 0041 4956 5f4f 4758 3d41
  1635. 0027:00008ed4  4544 4956 4543 4228 4856 4756 2c41 5642
  1636. 0027:00008ee4  5848 4147 0029 4956 5f4f 5653 4147 443d
  1637. 0027:00008ef4  5645 4349 2845 5642 5648 4147 422c 4856
  1638. 0027:00008f04  4758 0041 4e49 4c43 4455 3d45 3a43 535c
  1639. 0027:00008f14  4c51 494c 3b42 4c00 4249 433d 5c3a 5153
  1640. 0027:00008f24  4c4c 4249 003b 5251 4457 3d52 0043 5251
  1641. 0027:00008f34  4957 534e 3d54 3a43 535c 4c51 494c 0042
  1642. 0027:00008f44  4d43 4150 4854 433d 5c3a 4d43 494c 0042
  1643. 0027:00008f54  4f42 4b4f 474d 3d52 3a43 4c5c 554d 3b32
  1644. 0027:00008f64  4100 5050 5443 4e50 423d 5244 4d45 4d43
  1645. #
  1646.  
  1647. Looking at the stack we now find that there is a string that overwrites the 
  1648. return addresses (see below).  A good starting point now would be to look at 
  1649. the last correct stack frame we could find and look at that program. You could 
  1650. also try to see below the overwritten stack area to see if you can get another 
  1651. correct frame. If you can then you will have two functions to work from. 
  1652. Corrupted stacks require lots of investigation. As long as you understand how 
  1653. stacks work and how data is stored on them, you should be able to sort it out. 
  1654.  
  1655. 0027:00008a54 3a 30 31 3a 32 38 3a 33-39 00 54 45 21 21 20 59 :01:28:39.TE!! Y
  1656. 0027:00008a64 6f 75 20 68 61 76 65 20-56 32 2e 30 30 02 0a 00 ou have V2.00...
  1657. 0027:00008a74 30 02 0a 00 27 00 00 00-00 00 32 2e 30 30 02 00 0...'.....2.00..
  1658.  
  1659. Another form of stack corruption that you will come across is when the one half 
  1660. of the return BP has been overwritten. This is because a local variable has 
  1661. been defined as a certain length, and the program has moved a value of exactly 
  1662. that length into it and the null terminator has overwritten the one byte of the 
  1663. BP. These are a bit easier to solve as you still have the return address to 
  1664. work with. 
  1665.  
  1666.  
  1667. ΓòÉΓòÉΓòÉ 22.10. Fig. 9 - application dump stack. ΓòÉΓòÉΓòÉ
  1668.  
  1669.  
  1670. #
  1671. OS/2 2.x Dump Formatter for retail kernel
  1672. Formatter is --> Internal revision 6.651, 94/10/19
  1673. Dump file is --> Internal revision 6.651, 94/10/19
  1674. Current slot number: 008f
  1675. Symbol (c:\os2\pdpsi\pmdf\std9501\os2krnlr.sym) linked
  1676.  
  1677.  
  1678.  Slot  Pid  Ppid Csid Ord  Sta Pri  pTSD     pPTDA    pTCB     Disp SG Name
  1679. *008f# 004b 000b 004b 0001 run 0500 7bbf7000 7bc9a608 7bc786e0 0f04 10 BD
  1680.  
  1681. eax=0000ffc5 ebx=0000e48b ecx=00000011 edx=50f8e44d esi=00004a03 edi=0000ffc5
  1682. eip=00001899 esp=0000e13c ebp=0000e13e iopl=2 rf -- -- nv up ei pl nz na po nc
  1683. cs=68e7 ss=001f ds=017f es=5c4f fs=150b gs=0000  cr2=00000000  cr3=00000000
  1684. 68e7:00001899 a4             movsb                   es:ffc5=invalid ds:4a03=30
  1685. #
  1686. Loading version data ... please wait
  1687. Loading structure info for OS/2 2.11 as per 9501 version ... please wait..
  1688.  
  1689. # .
  1690.  
  1691. # .
  1692.  
  1693. #
  1694.  
  1695. # Done.
  1696.  
  1697.  Now that we have loaded the dump we can see that the instruction that failed 
  1698. was movsb and it failed because the value es:ffc5 was invalid. The ES is valid 
  1699. but the ffc5 is not. If you investigated you would find that the movsb 
  1700. instruction moves the value at ds:si to es:di. Lets look at what details we can 
  1701. about the segment allocated to ES. 
  1702.  
  1703.  
  1704. # dl 5c4f
  1705.  
  1706. 5c4f  Data    Bas=0b890000 Lim=00000226 DPL=3 P  RW    A
  1707.  
  1708.  We are trying to access offset ffc5 in a segment that has got a limit of 226. 
  1709. Not surprising we trapped. The next question is where and why. Look at the dll 
  1710. we are in. 
  1711.  
  1712. # .M CS:IP
  1713.  
  1714.  
  1715. *har     par      cpg        va    flg next prev link hash hob   hal
  1716.  0bb6 %fee2f1ae 00000010 %0d1c0000 3d9 0bb5 0bb7 0000 09c3 0f03 0000  hco=017e9
  1717.  hob   har hobnxt flgs own  hmte  sown,cnt lt st xf
  1718.  0f03  0bb6 0000  0838 0f02 0f02  0000 00  00 00 00 shared    c:crtlib.dll
  1719.  hco=17e9 pco=ffe6c7a8  hconext=018ad hptda=13b8 f=1c  pid=006a c:loop.exe
  1720.  
  1721.  We are in crtlib.dll. Since this dll is a system dll we can make an assumption 
  1722. that it was a faulty parameter that was passed.  I am not saying that system 
  1723. dlls are perfect, but if you are dealing with an abend in one, then rather make 
  1724. the assumption that it was a bad parameter first. If you prove all the 
  1725. parameters were okay, then start looking at the system dll itself. 
  1726.  
  1727. Now we have to look at the stack to see where crtlib was called from. 
  1728.  
  1729. # dw ss:bp
  1730.  
  1731. 001f:0000e13e  e414 2c1e 5c5f ffc5 5c4f 4a03 017f 5c57
  1732. 001f:0000e14e  e48b e44d 3300 61af 0000 0000 0000 ff00
  1733. 001f:0000e15e  ff0b 61ba 017f e168 001f 7fff 0001 9ec0
  1734. 001f:0000e16e  32d0 000f 98cc 30b0 0000 28c0 b200 ef9a
  1735. 001f:0000e17e  fe00 00ff 0000 bd00 00ac 0000 6377 0000
  1736. 001f:0000e18e  06d7 2947 bd0f 0001 000f 9ec0 32d0 0043
  1737. 001f:0000e19e  98cc 30b0 bd7f 0000 0000 0000 000c bd7f
  1738. 001f:0000e1ae  e1c6 281f bd0f 0000 0001 000f 9ec0 4242
  1739.  
  1740.  The address that we were to return to is 5c5f:2c1e. What can we tell about the 
  1741. segment?. 
  1742.  
  1743. # dl 5c5f
  1744.  
  1745. 5c5f  Code    Bas=0b8b0000 Lim=00002ff9 DPL=3 P  RE    A
  1746.  
  1747.  PMDF is telling us that is a code segment running at descriptor privilege 
  1748. level of 3. Who owns that segment ?. 
  1749.  
  1750. # .m 5c5f:2c1e
  1751.  
  1752.  
  1753. *har     par      cpg        va    flg next prev link hash hob   hal
  1754.  0e57 %fee32b84 00000010 %0b8b0000 3d9 0e56 0e58 0000 0b54 1405 0000  hco=020f4
  1755.  hob   har hobnxt flgs own  hmte  sown,cnt lt st xf
  1756.  1405  0e57 0000  0838 1406 1406  0000 00  00 00 00 shared    c:bddas601.dll
  1757.  hco=20f4 pco=ffe6f4df  hconext=00000 hptda=121b f=1d  pid=004b c:bd.exe
  1758.  The segment is owned by BDDAS601.DLL. Refer to  Getting the path and dll name 
  1759. the hard way. and ExeInfo - getting a dll using CSLIM. or FINDSEG - getting a 
  1760. dll using CSLIM. and QTRAP - getting a lot more using CS, IP, CSLIM and dll 
  1761. name.  for information on how to get the source code line number of that return 
  1762. address. 
  1763.  
  1764. Let us have a look at he parameters that were passed to crtlib. 
  1765.  
  1766.  
  1767. # U 5C5F:2C1E - 30
  1768.  
  1769. 5c5f:00002bee 50             push    ax
  1770. 5c5f:00002bef 9a7618e768     call    68e7:1876
  1771. 5c5f:00002bf4 83c408         add     sp,+08
  1772. 5c5f:00002bf7 c45e06         les     bx,dword ptr [bp+06]
  1773. 5c5f:00002bfa 26c45f0a       les     bx,dword ptr es:[bx+0a]
  1774. 5c5f:00002bfe 268b4710       mov     ax,word ptr es:[bx+10]
  1775. 5c5f:00002c02 268b5712       mov     dx,word ptr es:[bx+12]
  1776. 5c5f:00002c06 051100         add     ax,0011
  1777. 5c5f:00002c09 52             push    dx
  1778. 5c5f:00002c0a 50             push    ax
  1779. 5c5f:00002c0b 6b9ec6fe3d     imul    bx,word ptr [bp+fec6],3d ;'='
  1780. 5c5f:00002c10 8d87c5ff       lea     ax,[bx+ffc5]
  1781. 5c5f:00002c14 ba4f5c         mov     dx,5c4f
  1782. 5c5f:00002c17 52             push    dx
  1783. 5c5f:00002c18 50             push    ax
  1784. 5c5f:00002c19 9a7618e768     call    68e7:1876   <--- call to crtlib
  1785. 5c5f:00002c1e 83c408         add     sp,+08      <--- address to return to
  1786. 5c5f:00002c21 c45e06         les     bx,dword ptr [bp+06]
  1787. 5c5f:00002c24 26c45f0a       les     bx,dword ptr es:[bx+0a]
  1788. 5c5f:00002c28 268b4710       mov     ax,word ptr es:[bx+10]
  1789. 5c5f:00002c2c 268b5712       mov     dx,word ptr es:[bx+12]
  1790. 5c5f:00002c30 052700         add     ax,0027
  1791. 5c5f:00002c33 52             push    dx
  1792. 5c5f:00002c34 50             push    ax
  1793. #
  1794.  
  1795.  At 5c5f:2c0b above PMDF has told us to add fec6 to the BP. Doing this would 
  1796. give us an out of range address. Subtract that value from (hex)10000 and then 
  1797. subtract the result from BP to get the correct pointer. I have no idea why this 
  1798. sometimes happens. 
  1799.  
  1800. # ?10000 - FEC6
  1801.  
  1802. 013aH 314T 472Q 0000000100111010Y ':' TRUE
  1803.  
  1804.  Test the parameters passed. From the above unassembled code we know that we 
  1805. pushed 4 paramaters onto the stack. Therefore the last four values just before 
  1806. the return CS will be the parameters passed. 
  1807.  
  1808. # DW SS:BP - 10
  1809.  
  1810. 001f:0000e12e  e168 001f e408 001f 5c57 e48b e44d 5c57
  1811. 001f:0000e13e  e414 2c1e 5c5f ffc5 5c4f 4a03 017f 5c57
  1812. 001f:0000e14e  e48b e44d 3300 61af 0000 0000 0000 ff00
  1813. 001f:0000e15e  ff0b 61ba 017f e168 001f 7fff 0001 9ec0
  1814. 001f:0000e16e  32d0 000f 98cc 30b0 0000 28c0 b200 ef9a
  1815. 001f:0000e17e  fe00 00ff 0000 bd00 00ac 0000 6377 0000
  1816. 001f:0000e18e  06d7 2947 bd0f 0001 000f 9ec0 32d0 0043
  1817. 001f:0000e19e  98cc 30b0 bd7f 0000 0000 0000 000c bd7f
  1818.  
  1819. # DW 17F:4A03
  1820.  
  1821. 017f:00004a03  3030 3030 3130 3231 3030 3431 3036 3030
  1822. 017f:00004a13  3000 3438 0035 3030 3130 3839 0032 0000
  1823. 017f:00004a23  0000 1200 d100 7f48 0001 0005 0bff 01ff
  1824. 017f:00004a33  0f06 43e0 bd5f 1200 0000 7f49 0001 0005
  1825. 017f:00004a43  0bff 01ff 0f06 43e0 bd5f 2200 5e00 7f49
  1826. 017f:00004a53  0001 0000 0000 0000 0000 7400 0061 0500
  1827. 017f:00004a63  0500 0500 0601 540f 5f37 00bd 0000 2800
  1828. 017f:00004a73  8d00 7f49 0001 0000 0000 0000 0000 0000
  1829.  
  1830. # DW 5C4F:FFC5
  1831.  
  1832. Past end of segment: 5c4f:0000ffc5
  1833.  
  1834. # .R
  1835.  
  1836. eax=0000ffc5 ebx=0000e48b ecx=00000011 edx=50f8e44d esi=00004a03 edi=0000ffc5
  1837. eip=00001899 esp=0000e13c ebp=0000e13e iopl=2 rf -- -- nv up ei pl nz na po nc
  1838. cs=68e7 ss=001f ds=017f es=5c4f fs=150b gs=0000  cr2=00000000  cr3=00000000
  1839. 68e7:00001899 a4             movsb                   es:ffc5=invalid ds:4a03=30
  1840.  
  1841.  Looking at the two parameters passed, and testing each of them we see that the 
  1842. second parameter to be put on the stack (in C convention, the first parameter 
  1843. to be passed) is invalid. 
  1844.  
  1845.  At this stage we go to the source code, because I know that am in BDDAS601.DLL 
  1846. I don't have to run findseg. I get the CSLIM from the dl that I did earlier 
  1847. (2ff9) and I have the CS:IP from the stack (5c5f:2c1e). So now I perform a 
  1848. qtrap and get the following: 
  1849.  
  1850. QTRAP v3.03 by Adrian Bonsall - Automated Trap Resolver
  1851.  
  1852. 5C5F is Entry #2955 in the Local Descriptor Table with a ReqPrivLvl of 3.
  1853.  
  1854. Selector 5C5F is not assigned to any of the default segments of f:\main\dll\bddas601.dll
  1855.  
  1856. Checking imported modules for segment of size 2FFA:
  1857.                             Searching .... BDDAS601 .... Segment found.
  1858.  
  1859. Sel.  Off.  Seg.No.  Length  AllocSize  Flags
  1860. 5C5F  2C1E   0001    0x2FFA   0x2FFA    CODE RELOC DPL3
  1861.  
  1862. Nearest Entry Point   : 0001:1116  TPBDDAS601.
  1863. Nearest Public Symbol : 0001:1116  TPBDDAS601  (D:\SB\MAIN\OBJ\BDDAS601.OBJ)
  1864. Nearest Source Line   : 0001:2BF7  line #1532  (D:\SB\MAIN\OBJ\BDDAS601.OBJ)
  1865.  
  1866. We can double check this by referring to the MAP file. 
  1867.  
  1868.                                   .
  1869.                                   .
  1870.                                   .
  1871.  
  1872. Line numbers for C:\SB\OBJ\BDDAS601.OBJ(F:\MAIN\SRC\REF\BDDAS601.C) segment BDDAS601_TEXT
  1873.  
  1874.                                   .
  1875.                                   .
  1876.                                   .
  1877.   1523 0001:2BB3  1526 0001:2BBE  1528 0001:2BD1  1530 0001:2BE4
  1878.   1532 0001:2BF7  1534 0001:2C21  1536 0001:2C4B  1538 0001:2C65
  1879.                                   .
  1880.                                   .
  1881.                                   .
  1882.  
  1883. Here we have a good example of where you have to look for the nearest number 
  1884. matching the offset in map file, and not the exact offset, as discussed in 
  1885. Using the source code. 
  1886.  
  1887.                 .
  1888.                 .
  1889.  
  1890. ; Line 1532
  1891.         les     bx,DWORD PTR [bp+6]     ;pDlgDat
  1892.         les     bx,DWORD PTR es:[bx+10]
  1893.         mov     ax,WORD PTR es:[bx+16]
  1894.         mov     dx,WORD PTR es:[bx+18]
  1895.         add     ax,17
  1896.         push    dx
  1897.         push    ax
  1898.         imul    bx,WORD PTR [bp-314],61 ;sNamesdeleted
  1899.         lea     ax,WORD PTR _NamDetails[bx-61]
  1900.         mov     dx,SEG _NamDetails
  1901.         push    dx
  1902.         push    ax
  1903.         call    FAR PTR _strcpy
  1904.         add     sp,8                   <-- pointed to by 5c5f:2c31
  1905. ; Line 1533
  1906.                  .
  1907.                  .
  1908.  
  1909.  Having got the line, I look at the source code for that line. 
  1910.  
  1911.                             .
  1912.                             .
  1913.  strcpy(DeleteDetails.szCardNumber,
  1914.      CardDetails.szCardNumber);
  1915.  strcpy(NamDetails[sNamesdeleted - 1].szNameNumber,   <-- line 1532
  1916.      BDDAS601REC(szNameNumber));
  1917.                             .
  1918.                             .
  1919.  
  1920. From looking at the unpacked assembler code in PMDF I know that parameter the 
  1921. parameter passed as NamDetails[sNamesdeleted - 1].szNameNumber had an invalid 
  1922. pointer of 5c4f:ffc5. At this stage it is up to the programmer to investigate 
  1923. the logic of his code to see why this would be invalid. You can do some more 
  1924. investigation at this stage. What is required is that you use the source code 
  1925. and the assembler, and work through the function that called crtlib with an 
  1926. invalid parameter. You might be able to determine why it was invalid. But that 
  1927. is beyond the scope of this document. 
  1928.  
  1929. As a matter of interest, the reason that this particular trap occurred was 
  1930. because the sNamesdeleted was 0, therefore doing the -1 gave us garbage. 
  1931.  
  1932.  
  1933. ΓòÉΓòÉΓòÉ 22.11. Initial display and output of .r. ΓòÉΓòÉΓòÉ
  1934.  
  1935. The display that you are presented with when you first load the dump. 
  1936.  
  1937. OS/2 2.x Dump Formatter for retail kernel
  1938. Formatter is --> Internal revision 6.651, 94/10/19
  1939. Dump file is --> Internal revision 6.651, 94/10/19
  1940. Current slot number: 008f
  1941. Symbol (c:\os2\pdpsi\pmdf\std9501\os2krnlr.sym)
  1942. linked
  1943.  
  1944.  
  1945.  Slot  Pid  Ppid Csid Ord  Sta Pri  pTSD     pPTDA    pTCB     Disp SG Name
  1946. *008f# 004b 000b 004b 0001 run 0500 7bbf7000 7bc9a608 7bc786e0 0f04 10
  1947. BD
  1948.  
  1949. eax=0000ffc5 ebx=0000e48b ecx=00000011 edx=50f8e44d esi=00004a03 edi=0000ffc5
  1950. eip=00001899 esp=0000e13c ebp=0000e13e iopl=2 rf-- -- nv up ei pl nz na po nc
  1951. cs=68e7 ss=001f ds=017f es=5c4f fs=150b gs=0000  cr2=00000000  cr3=00000000
  1952. 68e7:00001899 a4  movsb  es:ffc5=invalid
  1953. ds:4a03=30
  1954.  
  1955. Loading version data ... please wait
  1956. Loading structure info for OS/2 2.11 as per 9501 version ... please wait..
  1957.  
  1958. # .
  1959.  
  1960. # .
  1961.  
  1962. #
  1963.  
  1964. # Done.
  1965.  
  1966. From this we have been given the name of the exe/dll that abended, the  address 
  1967. of the abending instruction (we could also get that from looking at the values 
  1968. of the CS and IP registers). We were also given the  actual instruction that 
  1969. abended and we were even given the values that the instruction was using with 
  1970. the invalid value pointed out to us. 
  1971.  
  1972. You can easily get this information all over again by using .r which will cause 
  1973. the following to be displayed : 
  1974.  
  1975. # .r
  1976.  
  1977. eax=0000ffc5 ebx=0000e48b ecx=00000011 edx=50f8e44d esi=00004a03 edi=0000ffc5
  1978. eip=00001899 esp=0000e13c ebp=0000e13e iopl=2 rf-- -- nv up ei pl nz na po nc
  1979. cs=68e7 ss=001f ds=017f es=5c4f fs=150b gs=0000  cr2=00000000  cr3=00000000
  1980. 68e7:00001899 a4        movsb    es:ffc5=invalid
  1981. ds:4a03=30
  1982.  
  1983.  
  1984. ΓòÉΓòÉΓòÉ 22.12. Output of .m. ΓòÉΓòÉΓòÉ
  1985.  
  1986. Another way to get the name of the dll that you are working from. Do a .m on 
  1987. the address that you want to enquire about. This will display the following 
  1988. information : 
  1989.  
  1990. # .M CS:IP
  1991.  
  1992. *har     par      cpg        va    flg next prev link hash hob   hal
  1993.  0bb6 %fee2f1ae 00000010 %0d1c0000 3d9 0bb5 0bb7 0000 09c3
  1994. 0f03 0000 hco=017e9 hob   har hobnxt flgs own  hmte  sown,cnt lt st xf
  1995.  0f03  0bb6 0000  0838 0f02 0f02  0000 00  00 00 00 shared   c:crtlib.dll
  1996.  hco=17e9 pco=ffe6c7a8  hconext=018ad hptda=13b8 f=1c  pid=006a c:loop.exe
  1997.  
  1998.  
  1999. # .m 5c5f:2c1e
  2000.  
  2001. *har     par      cpg        va    flg next prev link hash hob   hal
  2002.  0e57 %fee32b84 00000010 %0b8b0000 3d9 0e56 0e58 0000 0b54
  2003. 1405 0000 hco=020f4 hob   har hobnxt flgs own  hmte  sown,cnt lt st xf
  2004.  1405  0e57 0000  0838 1406 1406  0000 00  00 00 00 shared
  2005.  c:bddas601.dll
  2006.  hco=20f4 pco=ffe6f4df  hconext=00000 hptda=121b f=1d  pid=004b c:bd.exe
  2007.  
  2008. The  actual dll that we were in and the  executable file that called it. 
  2009.  
  2010. Be warned, just when things are going so well, you'll get a result that looks 
  2011. like this. In a case like this I just try to work out what is the most likely 
  2012. one that I will be dealing with. 
  2013.  
  2014.  
  2015.  
  2016. # .m f:3204
  2017.  
  2018.  
  2019. *har     par      cpg        va    flg next prev link hash hob   hal
  2020.  0225 %fee21f38 00000010 %00010000 1d9 0224 0220 0000 0000 0270 0000 hptda=026b
  2021.  hob   har hobnxt flgs own  hmte  sown,cnt lt st xf
  2022.  0270  0225 0000  0838 026f 026f  0000 00  00 00 00 shared    c:eqnrckb.exe
  2023.  
  2024. *har     par      cpg        va    flg next prev link hash hob   hal
  2025.  0241 %fee221a0 00000010 %00010000 1d9 020f 0c96 0000 0000 13bd 0000 hptda=13b8
  2026.  hob   har hobnxt flgs own  hmte  sown,cnt lt st xf
  2027.  13bd  0241 0000  0838 13be 13be  0000 00  00 00 00 shared    c:loop.exe
  2028.  
  2029. *har     par      cpg        va    flg next prev link hash hob   hal
  2030.  024a %fee22266 00000010 %00010000 179 024b 0248 0000 0000 029e 0000 hptda=029a
  2031.  hob   har hobnxt flgs own  hmte  sown,cnt lt st xf
  2032.  029e  024a 0000  002c 029a 029f  0000 00  00 00 00 priv 0006 c:lanmsgex.exe
  2033.  
  2034. *har     par      cpg        va    flg next prev link hash hob   hal
  2035.  0257 %fee22384 00000010 %00010000 1d9 0258 0255 0000 0000 02b0 0000 hptda=02ac
  2036.  hob   har hobnxt flgs own  hmte  sown,cnt lt st xf
  2037.  02b0  0257 0000  0838 02b1 02b1  0000 00  00 00 00 shared    c:landll.exe
  2038.  
  2039. *har     par      cpg        va    flg next prev link hash hob   hal
  2040.  0263 %fee2248c 00000010 %00010000 1d9 0265 0261 0000 0000 02c2 0000 hptda=02be
  2041.  hob   har hobnxt flgs own  hmte  sown,cnt lt st xf
  2042.  02c2  0263 0000  0838 02c4 02c4  0000 00  00 00 00 shared    c:lsdaemon.exe
  2043.  
  2044. *har     par      cpg        va    flg next prev link hash hob   hal
  2045.  026e %fee2257e 00000010 %00010000 1d9 026f 026c 0000 0000 02d0 0000 hptda=02cc
  2046.  hob   har hobnxt flgs own  hmte  sown,cnt lt st xf
  2047.  02d0  026e 0000  0838 02d1 02d1  0000 00  00 00 00 shared    c:logdaem.exe
  2048.  
  2049. *har     par      cpg        va    flg next prev link hash hob   hal
  2050.  0276 %fee2262e 00000010 %00010000 1d9 0277 0274 0000 0000 02dd 0000 hptda=02d9
  2051.  hob   har hobnxt flgs own  hmte  sown,cnt lt st xf
  2052.  02dd  0276 0000  0838 02de 02de  0000 00  00 00 00 shared    c:epwrout.exe
  2053.  
  2054. *har     par      cpg        va    flg next prev link hash hob   hal
  2055.  040a %fee248e6 00000010 %00010000 1c9 040b 0408 02b7 0000 032b 0000 hptda=04e3
  2056.  02b7 %fee22bc4 00000010 %00010000 1d9 02b8 0090 0000 0000 032b 0000 hptda=0093
  2057.  hob   har hobnxt flgs own  hmte  sown,cnt lt st xf
  2058.  032b  040a 0000  0838 032c 032c  0000 00  00 00 00 shared    c:pmshell.exe
  2059.  
  2060. *har     par      cpg        va    flg next prev link hash hob   hal
  2061.  02fc %fee231b2 00000010 %00010000 179 02fd 02fa 0000 0000 0392 0000 hptda=038e
  2062.  hob   har hobnxt flgs own  hmte  sown,cnt lt st xf
  2063.  0392  02fc 0000  002c 038e 0393  0000 00  00 00 00 priv 000c c:harderr.exe
  2064.  
  2065. *har     par      cpg        va    flg next prev link hash hob   hal
  2066.  0d3e %fee3135e 00000010 %00010000 1c9 0d3f 0d3c 031b 0000 03ae 0000 hptda=1205
  2067.  031b %fee2345c 00000010 %00010000 1d9 031c 0319 0000 0000 03ae 0000 hptda=000e
  2068.  hob   har hobnxt flgs own  hmte  sown,cnt lt st xf
  2069.  03ae  0d3e 0000  0838 03af 03af  0000 00  00 00 00 shared    c:epwmux.exe
  2070.  
  2071. *har     par      cpg        va    flg next prev link hash hob   hal
  2072.  0377 %fee23c44 00000010 %00010000 1d9 0378 0375 0000 0000 0418 0000 hptda=0414
  2073.  hob   har hobnxt flgs own  hmte  sown,cnt lt st xf
  2074.  0418  0377 0000  0838 0419 0419  0000 00  00 00 00 shared    c:stoplan.exe
  2075.  
  2076. *har     par      cpg        va    flg next prev link hash hob   hal
  2077.  040a %fee248e6 00000010 %00010000 1c9 040b 0408 02b7 0000 032b 0000 hptda=04e3
  2078.  02b7 %fee22bc4 00000010 %00010000 1d9 02b8 0090 0000 0000 032b 0000 hptda=0093
  2079.  hob   har hobnxt flgs own  hmte  sown,cnt lt st xf
  2080.  032b  040a 0000  0838 032c 032c  0000 00  00 00 00 shared    c:pmshell.exe
  2081.  
  2082. *har     par      cpg        va    flg next prev link hash hob   hal
  2083.  0446 %fee24e0e 00000010 %00010000 1d9 0447 0443 0000 0000 0585 0000 hptda=0581
  2084.  hob   har hobnxt flgs own  hmte  sown,cnt lt st xf
  2085.  0585  0446 0000  0838 0586 0586  0000 00  00 00 00 shared    c:muglrqst.exe
  2086.  
  2087. *har     par      cpg        va    flg next prev link hash hob   hal
  2088.  048a %fee253e6 00000010 %00010000 1d9 0465 048c 0000 0000 0565 0000 hptda=0535
  2089.  hob   har hobnxt flgs own  hmte  sown,cnt lt st xf
  2090.  0565  048a 0000  0838 0601 0601  0000 00  00 00 00 shared    c:cmstart.exe
  2091.  
  2092. *har     par      cpg        va    flg next prev link hash hob   hal
  2093.  04af %fee25714 00000010 %00010000 1d9 04b0 04ad 0000 0000 061e 0000 hptda=061a
  2094.  hob   har hobnxt flgs own  hmte  sown,cnt lt st xf
  2095.  061e  04af 0000  0838 061f 061f  0000 00  00 00 00 shared    c:wksta.exe
  2096.  
  2097. *har     par      cpg        va    flg next prev link hash hob   hal
  2098.  04c5 %fee258f8 00000010 %00010000 1d9 04c6 0490 0000 0000 0658 0000 hptda=05d4
  2099.  hob   har hobnxt flgs own  hmte  sown,cnt lt st xf
  2100.  0658  04c5 0000  0838 0659 0659  0000 00  00 00 00 shared    c:wkstahlp.exe
  2101.  
  2102. *har     par      cpg        va    flg next prev link hash hob   hal
  2103.  04e3 %fee25b8c 00000010 %00010000 1d9 04e4 04e1 0000 0000 069f 0000 hptda=069b
  2104.  hob   har hobnxt flgs own  hmte  sown,cnt lt st xf
  2105.  069f  04e3 0000  0838 06a0 06a0  0000 00  00 00 00 shared    c:lsclient.exe
  2106.  
  2107. *har     par      cpg        va    flg next prev link hash hob   hal
  2108.  04f0 %fee25caa 00000010 %00010000 1d9 04f1 04ee 0000 0000 06e6 0000 hptda=06cd
  2109.  hob   har hobnxt flgs own  hmte  sown,cnt lt st xf
  2110.  06e6  04f0 0000  0838 06e7 06e7  0000 00  00 00 00 shared    c:netpopup.exe
  2111.  
  2112. *har     par      cpg        va    flg next prev link hash hob   hal
  2113.  04f5 %fee25d18 00000010 %00010000 1d9 04f6 04aa 0000 0000 06f6 0000 hptda=064c
  2114.  hob   har hobnxt flgs own  hmte  sown,cnt lt st xf
  2115.  06f6  04f5 0000  0838 06f7 06f7  0000 00  00 00 00 shared    c:msrv.exe
  2116.  
  2117. *har     par      cpg        va    flg next prev link hash hob   hal
  2118.  055a %fee265c6 00000010 %00010000 1d9 055b 0558 0000 0000 0798 0000 hptda=0794
  2119.  hob   har hobnxt flgs own  hmte  sown,cnt lt st xf
  2120.  0798  055a 0000  0838 0799 0799  0000 00  00 00 00 shared    c:remmain.exe
  2121.  
  2122. *har     par      cpg        va    flg next prev link hash hob   hal
  2123.  057a %fee26886 00000010 %00010000 1d9 057b 0579 0000 0000 07d2 0000 hptda=07cf
  2124.  hob   har hobnxt flgs own  hmte  sown,cnt lt st xf
  2125.  07d2  057a 0000  0838 07d3 07d3  0000 00  00 00 00 shared    c:acsrasp.exe
  2126.  
  2127. *har     par      cpg        va    flg next prev link hash hob   hal
  2128.  05cc %fee26f92 00000010 %00010000 199 05cd 05ca 0000 0000 0893 0000 hptda=088f
  2129.  hob   har hobnxt flgs own  hmte  sown,cnt lt st xf
  2130.  0893  05cc 0000  0830 0894 0894  0000 00  00 00 00 shared    c:acs3eini.exe
  2131.  
  2132. *har     par      cpg        va    flg next prev link hash hob   hal
  2133.  06a7 %fee28264 00000020 %00010000 1c9 06a8 06a5 0000 0000 098f 0000 hptda=098b
  2134.  hob   har hobnxt flgs own  hmte  sown,cnt lt st xf
  2135.  098f  06a7 0000  0838 0990 0990  0000 00  00 00 00 shared    c:anxcmclc.exe
  2136.  
  2137. *har     par      cpg        va    flg next prev link hash hob   hal
  2138.  0e83 %fee32f4c 00000010 %00010000 1c9 0e85 0e80 0b91 0000 04d9 0000 hptda=1444
  2139.  0b91 %fee2ee80 00000010 %00010000 1c9 0b92 0b8f 0b80 0000 04d9 0000 hptda=0ece
  2140.  0b80 %fee2ed0a 00000010 %00010000 1c9 0b81 0b7e 0733 0000 04d9 0000 hptda=0eb0
  2141.  0733 %fee28e6c 00000010 %00010000 1c9 0731 0732 06fa 0000 04d9 0000 hptda=0a1f
  2142.  06fa %fee28986 00000010 %00010000 1c9 06fc 072a 0000 0000 04d9 0000 hptda=0976
  2143.  hob   har hobnxt flgs own  hmte  sown,cnt lt st xf
  2144.  04d9  0e83 0000  0838 04da 04da  0000 00  00 00 00 shared    c:cmd.exe
  2145.  
  2146. *har     par      cpg        va    flg next prev link hash hob   hal
  2147.  0e83 %fee32f4c 00000010 %00010000 1c9 0e85 0e80 0b91 0000 04d9 0000 hptda=1444
  2148.  0b91 %fee2ee80 00000010 %00010000 1c9 0b92 0b8f 0b80 0000 04d9 0000 hptda=0ece
  2149.  0b80 %fee2ed0a 00000010 %00010000 1c9 0b81 0b7e 0733 0000 04d9 0000 hptda=0eb0
  2150.  0733 %fee28e6c 00000010 %00010000 1c9 0731 0732 06fa 0000 04d9 0000 hptda=0a1f
  2151.  06fa %fee28986 00000010 %00010000 1c9 06fc 072a 0000 0000 04d9 0000 hptda=0976
  2152.  hob   har hobnxt flgs own  hmte  sown,cnt lt st xf
  2153.  04d9  0e83 0000  0838 04da 04da  0000 00  00 00 00 shared    c:cmd.exe
  2154.  
  2155. *har     par      cpg        va    flg next prev link hash hob   hal
  2156.  073f %fee28f74 00000010 %00010000 1d9 0740 073d 0000 0000 0a42 0000 hptda=0a3e
  2157.  hob   har hobnxt flgs own  hmte  sown,cnt lt st xf
  2158.  0a42  073f 0000  0838 0a43 0a43  0000 00  00 00 00 shared    c:sqlesta0.exe
  2159.  
  2160. *har     par      cpg        va    flg next prev link hash hob   hal
  2161.  0b73 %fee2ebec 00000010 %00010000 1d9 0b74 0b70 0000 0000 0eb2 0000 hptda=074a
  2162.  hob   har hobnxt flgs own  hmte  sown,cnt lt st xf
  2163.  0eb2  0b73 0000  0838 0ea7 0ea7  0000 00  00 00 00 shared    c:pmpc0.exe
  2164.  
  2165. *har     par      cpg        va    flg next prev link hash hob   hal
  2166.  0e83 %fee32f4c 00000010 %00010000 1c9 0e85 0e80 0b91 0000 04d9 0000 hptda=1444
  2167.  0b91 %fee2ee80 00000010 %00010000 1c9 0b92 0b8f 0b80 0000 04d9 0000 hptda=0ece
  2168.  0b80 %fee2ed0a 00000010 %00010000 1c9 0b81 0b7e 0733 0000 04d9 0000 hptda=0eb0
  2169.  0733 %fee28e6c 00000010 %00010000 1c9 0731 0732 06fa 0000 04d9 0000 hptda=0a1f
  2170.  06fa %fee28986 00000010 %00010000 1c9 06fc 072a 0000 0000 04d9 0000 hptda=0976
  2171.  hob   har hobnxt flgs own  hmte  sown,cnt lt st xf
  2172.  04d9  0e83 0000  0838 04da 04da  0000 00  00 00 00 shared    c:cmd.exe
  2173.  
  2174. *har     par      cpg        va    flg next prev link hash hob   hal
  2175.  0e83 %fee32f4c 00000010 %00010000 1c9 0e85 0e80 0b91 0000 04d9 0000 hptda=1444
  2176.  0b91 %fee2ee80 00000010 %00010000 1c9 0b92 0b8f 0b80 0000 04d9 0000 hptda=0ece
  2177.  0b80 %fee2ed0a 00000010 %00010000 1c9 0b81 0b7e 0733 0000 04d9 0000 hptda=0eb0
  2178.  0733 %fee28e6c 00000010 %00010000 1c9 0731 0732 06fa 0000 04d9 0000 hptda=0a1f
  2179.  06fa %fee28986 00000010 %00010000 1c9 06fc 072a 0000 0000 04d9 0000 hptda=0976
  2180.  hob   har hobnxt flgs own  hmte  sown,cnt lt st xf
  2181.  04d9  0e83 0000  0838 04da 04da  0000 00  00 00 00 shared    c:cmd.exe
  2182.  
  2183. *har     par      cpg        va    flg next prev link hash hob   hal
  2184.  0b9d %fee2ef88 00000010 %00010000 1d9 0b9e 0b9b 0000 0000 0ee3 0000 hptda=0edf
  2185.  hob   har hobnxt flgs own  hmte  sown,cnt lt st xf
  2186.  0ee3  0b9d 0000  0838 0ee4 0ee4  0000 00  00 00 00 shared    c:pc0.exe
  2187.  
  2188. *har     par      cpg        va    flg next prev link hash hob   hal
  2189.  0bd1 %fee2f400 00000010 %00010000 1d9 0bd2 0bcf 0000 0000 0f4d 0000 hptda=0f49
  2190.  hob   har hobnxt flgs own  hmte  sown,cnt lt st xf
  2191.  0f4d  0bd1 0000  0838 0f4e 0f4e  0000 00  00 00 00 shared    c:ulg.exe
  2192.  
  2193. *har     par      cpg        va    flg next prev link hash hob   hal
  2194.  0be1 %fee2f560 00000010 %00010000 1d9 0be2 0bdf 0000 0000 0f91 0000 hptda=0f8d
  2195.  hob   har hobnxt flgs own  hmte  sown,cnt lt st xf
  2196.  0f91  0be1 0000  0838 0f92 0f92  0000 00  00 00 00 shared    c:pc3.exe
  2197.  
  2198. *har     par      cpg        va    flg next prev link hash hob   hal
  2199.  0bf0 %fee2f6aa 00000010 %00010000 1d9 0c12 0c36 0000 0000 1038 0000 hptda=1056
  2200.  hob   har hobnxt flgs own  hmte  sown,cnt lt st xf
  2201.  1038  0bf0 0000  0838 0525 0525  0000 00  00 00 00 shared    c:pr.exe
  2202.  
  2203. *har     par      cpg        va    flg next prev link hash hob   hal
  2204.  0c3f %fee2fd74 00000010 %00010000 1d9 0c40 0c3b 0000 0000 106b 0000 hptda=1065
  2205.  hob   har hobnxt flgs own  hmte  sown,cnt lt st xf
  2206.  106b  0c3f 0000  0838 106c 106c  0000 00  00 00 00 shared    c:netprt.exe
  2207.  
  2208. *har     par      cpg        va    flg next prev link hash hob   hal
  2209.  0c62 %fee30076 00000010 %00010000 1d9 0c63 0c60 0000 0000 10c6 0000 hptda=10c2
  2210.  hob   har hobnxt flgs own  hmte  sown,cnt lt st xf
  2211.  10c6  0c62 0000  0838 10c7 10c7  0000 00  00 00 00 shared    c:eqntgui.exe
  2212.  
  2213. *har     par      cpg        va    flg next prev link hash hob   hal
  2214.  0d0f %fee30f54 00000010 %00010000 1d9 0d10 0d0d 0000 0000 11b7 0000 hptda=11b3
  2215.  hob   har hobnxt flgs own  hmte  sown,cnt lt st xf
  2216.  11b7  0d0f 0000  0838 11b8 11b8  0000 00  00 00 00 shared    c:epwmp.exe
  2217.  
  2218. *har     par      cpg        va    flg next prev link hash hob   hal
  2219.  0d1e %fee3109e 00000010 %00010000 1d9 0d1f 0d1b 0000 0000 11d9 0000 hptda=11d4
  2220.  hob   har hobnxt flgs own  hmte  sown,cnt lt st xf
  2221.  11d9  0d1e 0000  0838 11da 11da  0000 00  00 00 00 shared    c:epwpsi.exe
  2222.  
  2223. *har     par      cpg        va    flg next prev link hash hob   hal
  2224.  0d3e %fee3135e 00000010 %00010000 1c9 0d3f 0d3c 031b 0000 03ae 0000 hptda=1205
  2225.  031b %fee2345c 00000010 %00010000 1d9 031c 0319 0000 0000 03ae 0000 hptda=000e
  2226.  hob   har hobnxt flgs own  hmte  sown,cnt lt st xf
  2227.  03ae  0d3e 0000  0838 03af 03af  0000 00  00 00 00 shared    c:epwmux.exe
  2228.  
  2229. *har     par      cpg        va    flg next prev link hash hob   hal
  2230.  0d4c %fee31492 00000010 %00010000 1d9 0d4d 0d4a 0000 0000 1223 0000 hptda=121b
  2231.  hob   har hobnxt flgs own  hmte  sown,cnt lt st xf
  2232.  1223  0d4c 0000  0838 1228 1228  0000 00  00 00 00 shared    c:bd.exe
  2233.  
  2234. *har     par      cpg        va    flg next prev link hash hob   hal
  2235.  0e83 %fee32f4c 00000010 %00010000 1c9 0e85 0e80 0b91 0000 04d9 0000 hptda=1444
  2236.  0b91 %fee2ee80 00000010 %00010000 1c9 0b92 0b8f 0b80 0000 04d9 0000 hptda=0ece
  2237.  0b80 %fee2ed0a 00000010 %00010000 1c9 0b81 0b7e 0733 0000 04d9 0000 hptda=0eb0
  2238.  0733 %fee28e6c 00000010 %00010000 1c9 0731 0732 06fa 0000 04d9 0000 hptda=0a1f
  2239.  06fa %fee28986 00000010 %00010000 1c9 06fc 072a 0000 0000 04d9 0000 hptda=0976
  2240.  hob   har hobnxt flgs own  hmte  sown,cnt lt st xf
  2241.  04d9  0e83 0000  0838 04da 04da  0000 00  00 00 00 shared    c:cmd.exe
  2242.  
  2243.  
  2244.  
  2245.  
  2246.  
  2247. ΓòÉΓòÉΓòÉ 22.13. Getting the path and dll name the hard way. ΓòÉΓòÉΓòÉ
  2248.  
  2249. Load the dump. 
  2250.  
  2251.  
  2252. OS/2 2.x Dump Formatter for retail kernel
  2253. Formatter is --> Internal revision 6.651, 94/10/19
  2254. Dump file is --> Internal revision 6.651, 94/10/19
  2255. Current slot number: 008f
  2256. Symbol (c:\os2\pdpsi\pmdf\std9501\os2krnlr.sym) linked
  2257.  
  2258.  
  2259.  Slot  Pid  Ppid Csid Ord  Sta Pri  pTSD     pPTDA    pTCB     Disp SG Name
  2260. *008f# 004b 000b 004b 0001 run 0500 7bbf7000 7bc9a608 7bc786e0 0f04 10 BD
  2261.  
  2262. eax=0000ffc5 ebx=0000e48b ecx=00000011 edx=50f8e44d esi=00004a03 edi=0000ffc5
  2263. eip=00001899 esp=0000e13c ebp=0000e13e iopl=2 rf -- -- nv up ei pl nz na po nc
  2264. cs=68e7 ss=001f ds=017f es=5c4f fs=150b gs=0000  cr2=00000000  cr3=00000000
  2265. 68e7:00001899 a4             movsb                   es:ffc5=invalid ds:4a03=30
  2266. #
  2267. Loading version data ... please wait
  2268. Loading structure info for OS/2 2.11 as per 9501 version ... please wait..
  2269.  
  2270. # .
  2271.  
  2272. # .
  2273.  
  2274. #
  2275.  
  2276. # Done.
  2277.  
  2278. Do a .m on the CS:IP. 
  2279.  
  2280. # .m cs:ip
  2281.  
  2282.  
  2283. *har     par      cpg        va    flg next prev link hash hob   hal
  2284.  0bb6 %fee2f1ae 00000010 %0d1c0000 3d9 0bb5 0bb7 0000 09c3 0f03 0000  hco=017e9
  2285.  hob   har hobnxt flgs own  hmte  sown,cnt lt st xf
  2286.  0f03  0bb6 0000  0838 0f02 0f02  0000 00  00 00 00 shared    c:crtlib.dll
  2287.  hco=17e9 pco=ffe6c7a8  hconext=018ad hptda=13b8 f=1c  pid=006a c:loop.exe
  2288.  
  2289. Do a .mo on the handle to the MTE. 
  2290.  
  2291. # .mo f02
  2292.  
  2293.  hob       va     flgs own  hmte  sown,cnt lt st xf
  2294.  0f02  %fdea2bf0  8000 ffa6 0000  0000 00  00 00 00 mte       c:crtlib.dll
  2295.  
  2296. Display the memory (as double word) at the address pointed to by the va. Use 
  2297. the % when using 32 bit addresses to tell the dump formatter that you are 
  2298. passing it a 32 bit linear address. 
  2299.  
  2300.  
  2301. # dd %fdea2bf0
  2302.  
  2303. %fdea2bf0  0f020001 fca85c98 fdea2c1c fdea2cec
  2304. %fdea2c00  0508b18a 00000004 000000ef fde3af6c
  2305. %fdea2c10  fde33f24 fde33d84 fde29f44 54524306
  2306. %fdea2c20  fd42494c ff9e0048 00000201 00000000
  2307. %fdea2c30  00000000 72a80000 00000420 02010000
  2308. %fdea2c40  00000000 00000000 00000000 0000078d
  2309. %fdea2c50  3a430012 5c42535c 5c4c4c44 5f505450
  2310. %fdea2c60  504d4f43 4c4c442e fdea2000 ff9e0048
  2311.  
  2312. Display the memory pointed to at offset 4 in the data that you displayed in the 
  2313. above step. 
  2314.  
  2315.  
  2316. # dd %fca85c98
  2317.  
  2318. %fca85c98  00000000 00000000 00000000 00000000
  2319. %fca85ca8  00000000 00000000 00001706 fca85d2f
  2320. %fca85cb8  00000007 00000000 00000000 fca85d9f
  2321. %fca85cc8  00000000 fca85d9f fca86e9e fca85c98
  2322. %fca85cd8  00000000 fca86e76 fca86e7e 00000000
  2323. %fca85ce8  000016f7 00000036 00000007 00000000
  2324. %fca85cf8  00000000 00000000 fca85d1a 00000000
  2325. %fca85d08  00000000 00000000 00000009 00010014
  2326.  
  2327. Display the memory at offset (hex)68 in the information you displayed in the 
  2328. above step. This time you must display it in byte format. Look at the ASCII 
  2329. translation on the left and you will have the path and file name. 
  2330.  
  2331.  
  2332. # db %fca85d1a
  2333.  
  2334. %fca85d1a 43 3a 5c 53 42 5c 44 4c-4c 5c 43 52 54 4c 49 42 C:\SB\DLL\CRTLIB
  2335. %fca85d2a 2e 44 4c 4c 00 0c 00 06-00 20 28 06 00 01 0f ee .DLL..... (....n
  2336. %fca85d3a 68 00 00 00 00 0d 00 dd-fd 20 2d dd fd 03 0f e7 h......]} -]}..g
  2337. %fca85d4a 68 a0 d3 a8 fc 8d 00 4b-24 20 2d 4b 24 04 0f df h S(|..K$ -K$.._
  2338. %fca85d5a 68 b8 78 a8 fc 00 00 00-00 01 0c 34 08 00 00 d7 h8x(|......4...W
  2339. %fca85d6a 68 00 00 00 00 a0 00 14-00 01 0c 99 02 00 00 cf h.... .........O
  2340. %fca85d7a 68 00 00 00 00 00 00 00-00 01 0c 00 02 00 00 c7 h..............G
  2341. %fca85d8a 68 00 00 00 00 a1 00 c8-2e 01 0d 40 38 00 00 bf h....!.H...@8..?
  2342. #
  2343.  
  2344.  
  2345. ΓòÉΓòÉΓòÉ 22.14. Output of u CS:IP - 20. ΓòÉΓòÉΓòÉ
  2346.  
  2347. I have included the .r output so that you can see the values of CS and IP. You 
  2348. can enter your own address and your own value that you want to go back by. 
  2349.  
  2350. # .r
  2351.  
  2352. eax=0000ffc5 ebx=0000e48b ecx=00000011 edx=50f8e44d esi=00004a03 edi=0000ffc5
  2353. eip=00001899 esp=0000e13c ebp=0000e13e iopl=2 rf -- -- nv up ei pl nz na po nc
  2354. cs=68e7 ss=001f ds=017f es=5c4f fs=150b gs=0000  cr2=00000000  cr3=00000000
  2355. 68e7:00001899 a4             movsb              es:ffc5=invalid ds:4a03=30
  2356.  
  2357. # u cs:ip - 20
  2358.  
  2359. 68e7:00001879 8bd7           mov     dx,di
  2360. 68e7:0000187b 8bde           mov     bx,si
  2361. 68e7:0000187d 1e             push    ds
  2362. 68e7:0000187e c5760a         lds     si,dword ptr [bp+0a]
  2363. 68e7:00001881 8bfe           mov     di,si
  2364. 68e7:00001883 8cd8           mov     ax,ds
  2365. 68e7:00001885 8ec0           mov     es,ax
  2366. 68e7:00001887 33c0           xor     ax,ax
  2367. 68e7:00001889 b9ffff         mov     cx,ffff
  2368. 68e7:0000188c f2ae           repne scasb
  2369. 68e7:0000188e f7d1           not     cx
  2370. 68e7:00001890 c47e06         les     di,dword ptr [bp+06]
  2371.  
  2372. See how if you just do a u now, PMDF will display the unassembled instructions 
  2373. starting at the next instruction following the last one that was displayed. 
  2374.  
  2375. # u
  2376.  
  2377. 68e7:00001893 8bc7           mov     ax,di
  2378. 68e7:00001895 a801           test    al,01
  2379. 68e7:00001897 7402           jz      189b
  2380. 68e7:00001899 a4             movsb
  2381. 68e7:0000189a 49             dec     cx
  2382. 68e7:0000189b d1e9           shr     cx,1
  2383. 68e7:0000189d f3a5           repe movsw
  2384. 68e7:0000189f 13c9           adc     cx,cx
  2385. 68e7:000018a1 f3a4           repe movsb
  2386. 68e7:000018a3 8bf3           mov     si,bx
  2387. 68e7:000018a5 8bfa           mov     di,dx
  2388. 68e7:000018a7 1f             pop     ds
  2389.  
  2390.  
  2391. ΓòÉΓòÉΓòÉ 22.15. Example of compiler generated files. ΓòÉΓòÉΓòÉ
  2392.  
  2393. Things to note in the following examples: 
  2394.  
  2395.  1. Notice how the assembler code has dealt with the variables of 
  2396.     PFAvoidDuplic. The local variables are all defined as - ??? and the two 
  2397.     paramaters are + ???. The - and + are relative to the BP for that function. 
  2398.  
  2399.  2. The variables are not positioned according to the way that they were 
  2400.     defined in the source code. 
  2401.  
  2402.  3. The assembler code for the call instruction starts at ????:0cf7 ( look at 
  2403.     the map file for line 816) but there are 7 lines of assembler code for that 
  2404.     line of source code. So if we were, for example, to abend in the 
  2405.  
  2406.           lea   ax,WORD PTR [bp-52]   ;szUserID 
  2407.  
  2408.     instruction the IP would be somewhere between 0cf7 abd 0d0a. Remember this 
  2409.     when you are looking for the IP in the MAP file and you can't find it. Just 
  2410.     look the nearest number that is lower than the IP you are looking for. 
  2411.  
  2412.  4. You can ignore the CS in the MAP file. To the best of my knowledge this 
  2413.     refers to the segment that the code will be loaded into if the entire code 
  2414.     is going to be loaded into more than one segment. 
  2415.  
  2416.  5. Using these files you can match any selector:offset to the actual line in 
  2417.     the source code file. 
  2418.  
  2419.  6. Remember to ensure that the version of code you re-compiled is the same as 
  2420.     that which is in the dump. Otherwise you could lead yourself on a wild 
  2421.     goose chase. 
  2422.  
  2423.  
  2424. Source code (line 816) :
  2425.  
  2426.      sProceed = PFAvoidDuplic(pDlgDat,        /* ensure they are not adding */
  2427.                               szUserID);      /* a duplicate.               */
  2428.  
  2429.  
  2430. Source code (line 1133) :
  2431.  
  2432.     _SHORT EXPENTRY         PFAvoidDuplic
  2433.         (
  2434.         PDIAM               pDlgDat,
  2435.         PCHAR               szUserid
  2436.         )
  2437.       {
  2438.        UCHAR                uchAccess;        /* database access mode       */
  2439.  
  2440.        _SHORT               sReturn;          /* return to caller           */
  2441.        _CHAR                szTest[10];       /* test recovery field        */
  2442.  
  2443.        PDBFIELD             pDfi;             /* number of cols from db2    */
  2444.        _CHAR                szCommand[400];   /* sql command line buffer    */
  2445.        _LONG                lDbRet;           /* return from sql cmd        */
  2446.        _CHAR                szQueryHandle[4]; /*                            */
  2447.  
  2448.        uchAccess = LOCAL;                     /* access local database      */
  2449.        sReturn = 0;                           /* set return to zero         */
  2450.  
  2451. Assembler code : 
  2452.  
  2453.  
  2454.     ; Line 816
  2455.             push    WORD PTR [bp+8]
  2456.             push    WORD PTR [bp+6] ;pDlgDat
  2457.             lea     ax,WORD PTR [bp-52]     ;szUserID
  2458.             push    ss
  2459.             push    ax
  2460.             call    FAR PTR PFAVOIDDUPLIC
  2461.             mov     WORD PTR [bp-8],ax      ;sProceed
  2462.  
  2463.  
  2464.     ; Line 1133
  2465.             PUBLIC  PFAVOIDDUPLIC
  2466.     PFAVOIDDUPLIC   PROC FAR
  2467.             enter   WORD PTR 426,0
  2468.             push    di
  2469.             push    si
  2470.             push    ds
  2471.             mov     ax,DGROUP
  2472.             mov     ds,ax
  2473.             ASSUME DS: DGROUP
  2474.     ;       pDlgDat = 10
  2475.     ;       szUserid = 6
  2476.     ;       uchAccess = -2
  2477.     ;       sReturn = -8
  2478.     ;       szTest = -422
  2479.     ;       pDfi = -6
  2480.     ;       szCommand = -408
  2481.     ;       lDbRet = -412
  2482.     ;       szQueryHandle = -426
  2483.     ; Line 1134
  2484.     ; Line 1136
  2485.     ; Line 1137
  2486.     ; Line 1139
  2487.     ; Line 1140
  2488.     ; Line 1141
  2489.     ; Line 1142
  2490.     ; Line 1144
  2491.             mov     BYTE PTR [bp-2],1       ;uchAccess
  2492.     ; Line 1145
  2493.             mov     WORD PTR [bp-8],0       ;sReturn
  2494.  
  2495. Example of the map file output : 
  2496.  
  2497.  
  2498.      BDYAA001
  2499.  
  2500.      Start     Length     Name                   Class
  2501.      0001:0000 0243AH     BDDAA001_TEXT          CODE
  2502.      0002:0000 00954H     _DATA                  DATA
  2503.      0002:0954 00000H     CONST                  CONST
  2504.      0002:0954 00000H     _BSS                   BSS
  2505.      0002:0960 00000H     c_common               BSS
  2506.      0003:0000 00005H     FAR_BSS                FAR_BSS
  2507.  
  2508.      Origin   Group
  2509.      0002:0   DGROUP
  2510.  
  2511.      Address   Export                  Alias
  2512.  
  2513.      0001:00B1 CPBDDAA001              CPBDDAA001
  2514.      0001:034A EPBDDAA001              EPBDDAA001
  2515.      0001:0000 IPBDDAA001              IPBDDAA001
  2516.      0001:040C TPBDDAA001              TPBDDAA001
  2517.  
  2518.       Address         Publics by Name
  2519.  
  2520.                                           .
  2521.                                           .
  2522.                                           .
  2523.                                           .
  2524.      0000:0000  Imp  _itoa                (CRTLIB._itoa)
  2525.      0000:0000  Imp  _ltoa                (CRTLIB._ltoa)
  2526.  
  2527.       Address         Publics by Value
  2528.  
  2529.                           .
  2530.                           .
  2531.                           .
  2532.                           .
  2533.      0000:0000  Imp  _strlen              (CRTLIB._strlen)
  2534.      0000:0000  Imp  DISABITEM            (GA2.DISABITEM)
  2535.      0000:0000  Imp  DDFREEDBF            (DDDM.DDFREEDBF)
  2536.      0001:0000       IPBDDAA001
  2537.      0001:00B1       CPBDDAA001
  2538.      0001:034A       EPBDDAA001
  2539.      0001:040C       TPBDDAA001
  2540.      0001:0425       PFINITIALISESCREEN
  2541.      0001:09EE       PFVALIDATEDATA
  2542.      0001:0B75       PFSAVEBPDRDATA
  2543.      0001:0FFC       PFLOADCHECKPOPUP
  2544.      0001:108D       PFCHECKLEVEL
  2545.      0001:1223       PFVALIDATECHANGE
  2546.      0001:12AC       PFAVOIDDUPLIC
  2547.      0001:13F6       PFALLOWEXIT
  2548.      0001:178E       PFCONTROLUNSUSPEND
  2549.      0001:182D       PFPROMPTFORPASSWORD
  2550.      0001:18BE       PFAMENDSTAFF
  2551.      0001:1B98       PFHOSTFLOW
  2552.      0001:239D       PFCHECKSTRING
  2553.      0003:0000       _dummy
  2554.  
  2555.     Line numbers for C:\SB\OBJ\BDDAA001.OBJ(F:\MAIN\SRC\REF\BDDAA001.C) segment
  2556.     BDDAA001_TEXT
  2557.                            .
  2558.                            .
  2559.                            .
  2560.        813 0001:0CE5   816 0001:0CF7   818 0001:0D0A   819 0001:0D13
  2561.        826 0001:0D40   831 0001:0D51   834 0001:0D66   836 0001:0D7D
  2562.                            .
  2563.                            .
  2564.                            .
  2565.       1133 0001:12AC  1144 0001:12B8  1145 0001:12BC  1147 0001:12C1
  2566.       1154 0001:12CE  1157 0001:12E9  1160 0001:12FB  1165 0001:130E
  2567.                            .
  2568.                            .
  2569.  
  2570.  
  2571. ΓòÉΓòÉΓòÉ 22.16. Simplified look at unwinding the stack. ΓòÉΓòÉΓòÉ
  2572.  
  2573.  
  2574.       EXAMPLE FUNCTIONS                       EXAMPLE STACK
  2575. ΓöîΓöÇMAINΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉ
  2576. Γöé                                           Γöé
  2577. Γöé 1007:0010   CALL 1007:0340                Γöé
  2578. Γöé                                           Γöé
  2579. Γöé                                           Γöé
  2580. Γöé                                           Γöé
  2581. ΓööΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ
  2582. ΓöîΓöÇFUNCTION AΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉ
  2583. Γöé                                           Γöé
  2584. Γöé 1007:0340   ENTER....                     Γöé           Γöé                   Γöé
  2585. Γöé                                           Γöé   1f:a73e Γöé0000               Γöé
  2586. Γöé                                           Γöé           Γöé                   Γöé
  2587. Γöé                                           Γöé           Γöé                   Γöé
  2588. Γöé                                           Γöé           Γöé                   Γöé
  2589. Γöé                                           Γöé           Γöé                   Γöé
  2590. Γöé 1007:0356   CALL   1207:12d4              Γöé           Γöé                   Γöé
  2591. Γöé 1007:035c   ......                        Γöé           Γöé                   Γöé
  2592. Γöé                                           Γöé           Γöé                   Γöé
  2593. Γöé                                           Γöé           Γöé                   Γöé
  2594. Γöé                                           Γöé   1f:a6bc Γöéa73e 035c 1007     Γöé
  2595. Γöé                                           Γöé           Γöé                   Γöé
  2596. Γöé                                           Γöé           Γöé                   Γöé
  2597. Γöé 1007:0402   RETF                          Γöé           Γöé                   Γöé
  2598. ΓööΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ           Γöé                   Γöé
  2599.                                                         Γöé                   Γöé
  2600. ΓöîΓöÇFUNCTION BΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉ            Γöé                   Γöé
  2601. Γöé                                          Γöé            Γöé                   Γöé
  2602. Γöé 1207:12d4   ENTER....                    Γöé            Γöé                   Γöé
  2603. Γöé                                          Γöé            Γöé                   Γöé
  2604. Γöé                                          Γöé            Γöé                   Γöé
  2605. Γöé                                          Γöé            Γöé                   Γöé
  2606. Γöé                                          Γöé            Γöé                   Γöé
  2607. Γöé                                          Γöé            Γöé                   Γöé
  2608. Γöé 1207:12e0   CALL   120f:01da             Γöé            Γöé                   Γöé
  2609. Γöé 1207:12e8   .......                      Γöé            Γöé                   Γöé
  2610. Γöé                                          Γöé            Γöé                   Γöé
  2611. Γöé                                          Γöé            Γöé                   Γöé
  2612. Γöé                                          Γöé            Γöé                   Γöé
  2613. Γöé                                          Γöé            Γöé                   Γöé
  2614. Γöé                                          Γöé            Γöé                   Γöé
  2615. Γöé 1207:1312   RETF                         Γöé            Γöé                   Γöé
  2616. Γöé                                          Γöé            Γöé                   Γöé
  2617. ΓööΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ            Γöé                   Γöé
  2618.                                                         Γöé                   Γöé
  2619. ΓöîΓöÇFUNCTION CΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉ           Γöé                   Γöé
  2620. Γöé                                           Γöé           Γöé                   Γöé
  2621. Γöé 120f:01da   ENTER....                     Γöé   1f:a69c Γöéa6bc 12e8 1207     Γöé
  2622. Γöé                                           Γöé           Γöé                   Γöé
  2623. Γöé                                           Γöé           Γöé                   Γöé
  2624. Γöé                                           Γöé           Γöé                   Γöé
  2625. Γöé                                           Γöé           Γöé                   Γöé
  2626. Γöé                                           Γöé           Γöé                   Γöé
  2627. Γöé 120f:02d0   CALL   120f:10da              Γöé           Γöé                   Γöé
  2628. Γöé 120f:02da   .......                       Γöé           Γöé                   Γöé
  2629. Γöé                                           Γöé           Γöé                   Γöé
  2630. Γöé                                           Γöé           Γöé                   Γöé
  2631. Γöé                                           Γöé           Γöé                   Γöé
  2632. Γöé                                           Γöé           Γöé                   Γöé
  2633. Γöé                                           Γöé           Γöé                   Γöé
  2634. Γöé                                           Γöé           Γöé                   Γöé
  2635. Γöé 120f:02fc   RETF                          Γöé           Γöé                   Γöé
  2636. Γöé                                           Γöé           Γöé                   Γöé
  2637. ΓööΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ           Γöé                   Γöé
  2638.                                                         Γöé                   Γöé
  2639. ΓöîΓöÇFUNCTION DΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉ                       Γöé                   Γöé
  2640. Γöé                               Γöé               1f:a640 Γöéa69c 02da 120f     Γöé
  2641. Γöé 120f:10da   ENTER.....        Γöé                       Γöé                   Γöé
  2642. Γöé                               Γöé                       Γöé                   Γöé
  2643. Γöé                               Γöé    REGISTERS          Γöé                   Γöé
  2644. Γöé                               Γöé    BP - a640          Γöé                   Γöé
  2645. Γöé                               Γöé    SS - 1f            Γöé                   Γöé
  2646. Γöé                               Γöé    CS - 120f          Γöé                   Γöé
  2647. Γöé 120f:11a0   crash             Γöé    IP - 11a0          Γöé                   Γöé
  2648. Γöé                               Γöé
  2649. Γöé This function has no values   Γöé
  2650. Γöé on the stack. Its values are  Γöé
  2651. Γöé still on the registers.       Γöé
  2652. Γöé                               Γöé
  2653. Γöé                               Γöé
  2654. Γöé                               Γöé
  2655. Γöé                               Γöé
  2656. Γöé                               Γöé
  2657. Γöé                               Γöé
  2658. Γöé                               Γöé
  2659. Γöé                               Γöé
  2660. Γöé 120f:120d   RETF              Γöé
  2661. ΓööΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ
  2662.  
  2663. Note how the BP always points to the BP that points to the next BP etc..This is 
  2664. how the stack frames are linked. Next to each BP you have a return CS and IP. 
  2665. These are your entry point into the the calling function. Use the three values 
  2666. as a group. 
  2667.  
  2668. Suppose you are trying to follow the values in a variable in FUNCTION A. The BP 
  2669. you would use would be a73e, for FUNCTION B it would be a6bc. Remember that 
  2670. when the CS and IP are put onto the stack, the BP active at that time is also 
  2671. saved. 
  2672.  
  2673. From this example you can also see how to get the start address of a function. 
  2674. Suppose you want to debug FUNCTION D from its entry point to the failing 
  2675. instruction. Go to the frame pointed to by SS:BP, take the return address and 
  2676. unpack from that address back 20 bytes. IE. you go to 1f:a640 and do a u 
  2677. 120f:2da - 20. In the unpacked code, just above 120f:2da you will get the CALL 
  2678. 120f:10da. In this way you have got the start address of FUNCTION D. 
  2679.  
  2680.