Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

207 lines
4.9 KiB

  1. /*
  2. * module.c - Module functions of DBG DLL.
  3. *
  4. *
  5. */
  6. #include <precomp.h>
  7. #pragma hdrstop
  8. VOID
  9. WINAPI
  10. xxxDbgDosAppStart(
  11. WORD wCS,
  12. WORD wIP
  13. )
  14. {
  15. if ( fDebugged ) {
  16. if (VdmDbgTraceFlags & VDMDBG_BREAK_DOSTASK) {
  17. DbgSetTemporaryBP(wCS, wIP, FALSE);
  18. }
  19. }
  20. }
  21. BOOL
  22. DbgDllStart(
  23. PNDFRAME16 pNDFrame
  24. ) {
  25. BOOL fResult;
  26. fResult = FALSE; // Default to Event not handled
  27. if ( fDebugged ) {
  28. LPSTR lpModuleName;
  29. LPSTR lpModulePath;
  30. UINT length;
  31. UCHAR fPE;
  32. IMAGE_NOTE im;
  33. DbgGetContext();
  34. EventParams[2] = (DWORD)&im;
  35. // Get the module's path and name
  36. fPE = ISPESET;
  37. lpModuleName = (LPSTR)Sim32GetVDMPointer(
  38. (ULONG)pNDFrame->dwModuleName,
  39. MAX_MODULE,
  40. fPE );
  41. lpModulePath = (LPSTR)Sim32GetVDMPointer(
  42. (ULONG)pNDFrame->dwModulePath,
  43. MAX_PATH,
  44. fPE );
  45. length = (UINT)((UCHAR)*lpModuleName++);
  46. strncpy( im.Module, lpModuleName, length );
  47. im.Module[length] = '\0';
  48. length = (UINT)((UCHAR)*lpModulePath);
  49. lpModulePath += 8;
  50. length -= 8;
  51. strncpy( im.FileName, lpModulePath, length );
  52. im.FileName[length] = '\0';
  53. im.hModule = pNDFrame->hModule;
  54. im.hTask = pNDFrame->hTask;
  55. fResult = SendVDMEvent(DBG_DLLSTART);
  56. if (VdmDbgTraceFlags & VDMDBG_BREAK_LOADDLL) {
  57. DbgSetTemporaryBP(pNDFrame->wCS, pNDFrame->wIP, (BOOL)(getMSW() & MSW_PE));
  58. }
  59. }
  60. return( fResult );
  61. }
  62. BOOL
  63. DbgTaskStop(
  64. PSTFRAME16 pSTFrame
  65. ) {
  66. BOOL fResult;
  67. fResult = FALSE; // Default to Event not handled
  68. if ( fDebugged ) {
  69. LPSTR lpModuleName;
  70. LPSTR lpModulePath;
  71. UINT length;
  72. UCHAR fPE;
  73. IMAGE_NOTE im;
  74. DbgGetContext();
  75. EventParams[2] = (DWORD)&im;
  76. // The code in TASK.ASM pops the frame off the stack before it IRETs
  77. vcContext.Esp += sizeof(STFRAME16);
  78. // Get the module's path and name
  79. fPE = ISPESET;
  80. lpModuleName = (LPSTR)Sim32GetVDMPointer(
  81. (ULONG)pSTFrame->dwModuleName,
  82. MAX_MODULE,
  83. fPE );
  84. lpModulePath = (LPSTR)Sim32GetVDMPointer(
  85. (ULONG)pSTFrame->dwModulePath,
  86. MAX_PATH,
  87. fPE );
  88. length = (UINT)((UCHAR)*lpModuleName++);
  89. strncpy( im.Module, lpModuleName, length );
  90. im.Module[length] = '\0';
  91. length = (UINT)((UCHAR)*lpModulePath);
  92. lpModulePath += 8;
  93. length -= 8;
  94. strncpy( im.FileName, lpModulePath, length );
  95. im.FileName[length] = '\0';
  96. im.hModule = pSTFrame->hModule;
  97. im.hTask = pSTFrame->hTask;
  98. fResult = SendVDMEvent(DBG_TASKSTOP);
  99. // See comment about what the code does above
  100. vcContext.Esp -= sizeof(STFRAME16);
  101. }
  102. return( fResult );
  103. }
  104. VOID
  105. xxxDbgNotifyNewTask(
  106. LPVOID lpvNTFrame,
  107. UINT uFrameSize
  108. ) {
  109. BOOL fResult;
  110. PNTFRAME16 pNTFrame;
  111. pNTFrame = (PNTFRAME16)lpvNTFrame;
  112. if ( fDebugged ) {
  113. LPSTR lpModuleName;
  114. LPSTR lpModulePath;
  115. UINT length;
  116. UCHAR fPE;
  117. IMAGE_NOTE im;
  118. DbgGetContext();
  119. EventParams[2] = (DWORD)&im;
  120. // Get the module's path and name
  121. fPE = ISPESET;
  122. lpModuleName = (LPSTR)Sim32GetVDMPointer(
  123. (ULONG)pNTFrame->dwModuleName,
  124. MAX_MODULE,
  125. fPE );
  126. lpModulePath = (LPSTR)Sim32GetVDMPointer(
  127. (ULONG)pNTFrame->dwModulePath,
  128. MAX_PATH,
  129. fPE );
  130. length = (UINT)((UCHAR)*lpModuleName++);
  131. strncpy( im.Module, lpModuleName, length );
  132. im.Module[length] = '\0';
  133. length = (UINT)((UCHAR)*lpModulePath);
  134. lpModulePath += 8;
  135. length -= 8;
  136. strncpy( im.FileName, lpModulePath, length );
  137. im.FileName[length] = '\0';
  138. im.hModule = pNTFrame->hModule;
  139. im.hTask = pNTFrame->hTask;
  140. fResult = SendVDMEvent(DBG_TASKSTART);
  141. if (VdmDbgTraceFlags & VDMDBG_BREAK_WOWTASK) {
  142. DbgSetTemporaryBP(pNTFrame->wCS, pNTFrame->wIP, (BOOL)(getMSW() & MSW_PE));
  143. }
  144. }
  145. }