Source code of Windows XP (NT5)
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.

477 lines
12 KiB

  1. /*++
  2. Copyright (c) 1995-1997 Microsoft Corporation
  3. Module Name :
  4. dbgthunk.cxx
  5. Abstract:
  6. This module defines all thunks for inlined functions, so that the
  7. debugger extension DLL can be peacefully linked.
  8. Author:
  9. Murali R. Krishnan ( MuraliK ) 24-Aug-1997
  10. Environment:
  11. Debugging Mode - NTSD Debugger Extension DLL
  12. Project:
  13. IIS Debugger Extensions DLL
  14. Functions Exported:
  15. Revision History:
  16. --*/
  17. /************************************************************
  18. * Include Headers
  19. ************************************************************/
  20. # include "inetdbgp.h"
  21. # undef DBG_ASSERT
  22. # define minSize(a, b) (((a) < (b)) ? (a) : (b))
  23. #ifdef _NO_TRACING_
  24. DECLARE_DEBUG_VARIABLE();
  25. #endif
  26. DECLARE_DEBUG_PRINTS_OBJECT();
  27. /************************************************************
  28. * Utility Functions
  29. ************************************************************/
  30. VOID
  31. dstring( CHAR * pszName, PVOID pvString, DWORD cbLen)
  32. /*++
  33. Description:
  34. This function reads the data from the debuggee process at
  35. address [pvString] for specified length [cbLen] and echoes
  36. the string back on the debugger window.
  37. Arguments:
  38. pszName - pointer to string containing the name of the string read
  39. pvString - pointer to VOID specifying the location of the string
  40. in the debugee process
  41. cbLen - count of bytes to be read at [pvString]
  42. Returns:
  43. None
  44. --*/
  45. {
  46. CHAR rgchString[10240];
  47. DWORD cLength = minSize( cbLen, sizeof(rgchString) -1);
  48. //
  49. // Read the data block from the debuggee process into local buffer
  50. //
  51. moveBlock( rgchString, pvString, cLength);
  52. rgchString[cLength] = '\0'; // terminate the string buffer
  53. dprintf( "%s = %s\n", pszName, rgchString);
  54. return;
  55. } // dstring()
  56. VOID
  57. PrintLargeInteger( CHAR * pszName, LARGE_INTEGER * pli)
  58. {
  59. CHAR szLargeInt[100];
  60. RtlLargeIntegerToChar( pli, // large integer location
  61. 10, // base for conversion
  62. sizeof(szLargeInt),
  63. szLargeInt );
  64. dprintf( " %30s = %s\n", pszName, szLargeInt);
  65. return;
  66. } // PrintLargeInteger()
  67. VOID
  68. Print2Dwords( CHAR * pszN1, DWORD d1,
  69. CHAR * pszN2, DWORD d2
  70. )
  71. {
  72. dprintf(" %25s =%8d %25s =%8d\n",
  73. pszN1, d1,
  74. pszN2, d2
  75. );
  76. return;
  77. } // Print2Dwords()
  78. BOOL
  79. EnumLinkedList(
  80. IN LIST_ENTRY * pListHead,
  81. IN PFN_LIST_ENUMERATOR pfnListEnumerator,
  82. IN CHAR chVerbosity,
  83. IN DWORD cbSizeOfStructure,
  84. IN DWORD cbListEntryOffset
  85. )
  86. /*++
  87. Description:
  88. This function iterates over the NT's standard LIST_ENTRY structure
  89. (doubly linked circular list with header) and makes callbacks for
  90. objects found on the list.
  91. Arguments:
  92. pListHead - pointer to List head in the debugee process
  93. pfnListEnumerator - pointer to callback function for the object on the list
  94. chVerbosity - character indicating the verbosity level desired
  95. cbSizeOfStructure - count of bytes of object's size
  96. cbListEntryOffset - count of bytes of offset of the List entry structure
  97. inside the containing object
  98. Returns:
  99. TRUE on successful enumeration
  100. FALSE on failure
  101. --*/
  102. {
  103. # define MAX_STRUCTURE_SIZE (10240)
  104. CHAR rgch[MAX_STRUCTURE_SIZE];
  105. PVOID pvDebuggee = NULL;
  106. PVOID pvDebugger = (PVOID ) rgch;
  107. LIST_ENTRY leListHead;
  108. LIST_ENTRY * pListEntry;
  109. DWORD cItems = 0;
  110. if ( NULL == pListHead) {
  111. dprintf( "Invalid List given \n");
  112. return (FALSE);
  113. }
  114. if ( MAX_STRUCTURE_SIZE < cbSizeOfStructure) {
  115. dprintf( "Given size for structure %d exceeds default max %d bytes\n",
  116. cbSizeOfStructure, MAX_STRUCTURE_SIZE);
  117. return (FALSE);
  118. }
  119. // make a local copy of the list head for navigation purposes
  120. MoveWithRet( leListHead, pListHead, FALSE);
  121. for ( pListEntry = leListHead.Flink;
  122. pListEntry != pListHead;
  123. )
  124. {
  125. if ( CheckControlC() )
  126. {
  127. return (FALSE);
  128. }
  129. pvDebuggee = (PVOID ) ((PCHAR ) pListEntry - cbListEntryOffset);
  130. // make a local copy of the debuggee structure
  131. MoveBlockWithRet( rgch, pvDebuggee, cbSizeOfStructure, FALSE);
  132. cItems++;
  133. if( pfnListEnumerator ) {
  134. (*pfnListEnumerator)( pvDebuggee, pvDebugger, chVerbosity, cItems);
  135. dprintf( "\n");
  136. }
  137. MoveWithRet( pListEntry, &pListEntry->Flink, FALSE );
  138. } // for all linked list entries
  139. dprintf( "%d entries traversed\n", cItems );
  140. return (TRUE);
  141. } // EnumLinkedList()
  142. /*++
  143. Description:
  144. COM objects registered as LocalServer result in running in a separate
  145. process. The base process communicates with these COM objects using RPC.
  146. It is often required to find the process id of destination process.
  147. The function cracks the process id of the target process given the first
  148. parameter to the function
  149. ole32!CRpcChannelBuffer__SendReceive()
  150. Argument:
  151. arg1 - pointer to string containing the parameter that is the hex-value
  152. of the RPC structure's location (which is the first param of
  153. function ole32!CRpcChannelBuffer__SendReceive())
  154. Standard NTSD parameters:
  155. hCurrentProcess - Supplies a handle to the current process (at the
  156. time the extension was called).
  157. hCurrentThread - Supplies a handle to the current thread (at the
  158. time the extension was called).
  159. CurrentPc - Supplies the current pc at the time the extension is
  160. called.
  161. lpExtensionApis - Supplies the address of the functions callable
  162. by this extension.
  163. lpArgumentString - Supplies the asciiz string that describes the
  164. ansi string to be dumped.
  165. Returns:
  166. None
  167. --*/
  168. DECLARE_API( rpcoop )
  169. {
  170. DWORD * pRpcParam1;
  171. DWORD dwContent;
  172. INIT_API();
  173. #if _WIN64
  174. dprintf("inetdbg.rpcoop: Not functional for 64bit as of yet");
  175. #else
  176. while (*lpArgumentString == ' ')
  177. lpArgumentString++;
  178. if ( !*lpArgumentString )
  179. {
  180. PrintUsage( "rpcoop" );
  181. return;
  182. }
  183. if ( *lpArgumentString == '-' )
  184. {
  185. lpArgumentString++;
  186. if ( *lpArgumentString == 'h' )
  187. {
  188. PrintUsage( "rpcoop" );
  189. return;
  190. }
  191. } // while
  192. //
  193. // Treat the argument as the param1 of the RPC function
  194. //
  195. pRpcParam1 = (DWORD * ) GetExpression( lpArgumentString );
  196. if ( !pRpcParam1 )
  197. {
  198. dprintf( "inetdbg.rpcoop: Unable to evaluate \"%s\"\n",
  199. lpArgumentString );
  200. return;
  201. }
  202. //
  203. // get the contents of the memory at seventh DWORD to pRpcParam1
  204. // ie. get [pRpcParam1 + 0x6]
  205. // - this is valid based on NT 4.0 SP3 code base :(
  206. //
  207. move( dwContent, pRpcParam1 + 0x6 );
  208. //
  209. // dwContent now contains the address of another structure
  210. // that carries the remote process Id
  211. // get the contents of the memory at seventh DWORD to dwContent
  212. // ie. get [dwContent + 9]
  213. // - this is valid based on NT 4.0 SP3 code base :(
  214. //
  215. DWORD dwProcessId;
  216. move( dwProcessId, ((LPDWORD ) dwContent) + 9);
  217. //
  218. // dump the process id to debugger screen
  219. //
  220. dprintf("\tRPC process ID = %d (0x%x)\n", dwProcessId, dwProcessId);
  221. #endif
  222. return;
  223. } // DECLARE_API( rpcoop )
  224. DECLARE_API( llc )
  225. /*++
  226. Routine Description:
  227. This function is called as an NTSD extension to count the LIST_ENTRYs
  228. on a linked list.
  229. Arguments:
  230. hCurrentProcess - Supplies a handle to the current process (at the
  231. time the extension was called).
  232. hCurrentThread - Supplies a handle to the current thread (at the
  233. time the extension was called).
  234. CurrentPc - Supplies the current pc at the time the extension is
  235. called.
  236. lpExtensionApis - Supplies the address of the functions callable
  237. by this extension.
  238. lpArgumentString - Supplies the asciiz string that describes the
  239. ansi string to be dumped.
  240. Return Value:
  241. None.
  242. --*/
  243. {
  244. PLIST_ENTRY remoteListHead;
  245. INIT_API();
  246. //
  247. // Skip leading blanks.
  248. //
  249. while( *lpArgumentString == ' ' ||
  250. *lpArgumentString == '\t' ) {
  251. lpArgumentString++;
  252. }
  253. if( *lpArgumentString == '\0' ) {
  254. PrintUsage( "llc" );
  255. return;
  256. }
  257. //
  258. // Get the list head.
  259. //
  260. remoteListHead = (PLIST_ENTRY)GetExpression( lpArgumentString );
  261. if( remoteListHead == NULL ) {
  262. dprintf( "!llc: cannot evaluate %s\n", lpArgumentString );
  263. return;
  264. }
  265. //
  266. // Let the enumerator do the dirty work.
  267. //
  268. EnumLinkedList(
  269. remoteListHead,
  270. NULL,
  271. 0,
  272. sizeof(LIST_ENTRY),
  273. 0
  274. );
  275. } // DECLARE_API( llc )
  276. /************************************************************
  277. * FAKE Functions
  278. *
  279. * Fake the definitions of certain functions that belong only
  280. * in the local compilation of w3svc & infocomm dlls
  281. *
  282. ************************************************************/
  283. extern "C" {
  284. //
  285. // NTSD Extensions & CRTDLL likes to have the main() function
  286. // Let us throw this in as well, while we are in the business
  287. // of faking several other functions :)
  288. //
  289. void _cdecl main( void )
  290. {
  291. ;
  292. }
  293. }
  294. __int64
  295. GetCurrentTimeInMilliseconds(
  296. VOID
  297. )
  298. { return (0); }
  299. BOOL BUFFER::GetNewStorage( UINT cbRequested ) { return (TRUE);}
  300. BOOL BUFFER::ReallocStorage( UINT cbRequested ) { return (TRUE);}
  301. VOID STR::AuxInit( const BYTE * pInit ) {}
  302. BOOL STR::AuxAppend( const BYTE * pInit,
  303. UINT cbStr, BOOL fAddSlop )
  304. { return (TRUE);}
  305. VOID MULTISZ::AuxInit( const BYTE * pInit ) {}
  306. BOOL MULTISZ::AuxAppend( const BYTE * pInit,
  307. UINT cbStr, BOOL fAddSlop )
  308. { return (TRUE);}
  309. DWORD HASH_TABLE::CalculateHash( IN LPCSTR pszKey, IN DWORD cchKey) const
  310. { return ( 0); }
  311. VOID HASH_TABLE::Cleanup( VOID) {}
  312. HT_ELEMENT * HASH_TABLE::Lookup( IN LPCSTR pszKey, IN DWORD cchKey)
  313. { return ( NULL); }
  314. DWORD
  315. IIS_SERVER_INSTANCE::UpdateBindingsHelper(
  316. IN BOOL IsSecure
  317. )
  318. { return (NO_ERROR); }
  319. DWORD
  320. IIS_SERVER_INSTANCE::UnbindHelper(
  321. IN PLIST_ENTRY BindingListHead
  322. )
  323. { return ( NO_ERROR); }
  324. BOOL IIS_SERVICE::LoadStr( OUT STR & str, IN DWORD dwResId, IN BOOL fForceEnglish ) const
  325. { return ( TRUE); }
  326. DWORD
  327. IIS_SERVICE::UpdateServiceStatus(IN DWORD State,
  328. IN DWORD Win32ExitCode,
  329. IN DWORD CheckPoint,
  330. IN DWORD WaitHint )
  331. { return ( NO_ERROR); }
  332. BOOL IIS_SERVICE::RemoveServerInstance(
  333. IN IIS_SERVER_INSTANCE * pInstance
  334. )
  335. { return ( FALSE); }
  336. INET_PARSER::INET_PARSER( char * pszStart) {}
  337. INET_PARSER::~INET_PARSER(VOID) {}
  338. CHAR * INET_PARSER::AuxEatWhite(VOID) { return ( NULL); }
  339. CHAR * INET_PARSER::AuxEatNonWhite(CHAR ch) { return ( NULL); }
  340. CHAR * INET_PARSER::AuxSkipTo(CHAR ch) { return ( NULL); }
  341. VOID INET_PARSER::TerminateToken( CHAR ch) {}
  342. VOID INET_PARSER::RestoreToken( VOID ) {}
  343. VOID INET_PARSER::TerminateLine( VOID ) {}
  344. VOID INET_PARSER::RestoreLine( VOID ) {}
  345. CHAR * INET_PARSER::NextToken( CHAR ) { return (NULL); }
  346. AC_RESULT ADDRESS_CHECK::CheckName( LPSTR pName ) { return ( AC_NO_LIST); }
  347. VOID TS_DIRECTORY_INFO::CleanupThis(VOID) {};
  348. VOID * TCP_AUTHENT::QueryPrimaryToken(VOID) { return (NULL); }
  349. /************************ End of File ***********************/