Windows NT 4.0 source code leak
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.

139 lines
2.2 KiB

4 years ago
  1. /*++
  2. Copyright (c) 1992 Microsoft Corporation
  3. Module Name:
  4. addr.c
  5. Abstract:
  6. Implements the addr command.
  7. Author:
  8. Keith Moore (keithmo) 19-Apr-1995
  9. Environment:
  10. User Mode.
  11. Revision History:
  12. --*/
  13. #include "afdkdp.h"
  14. #pragma hdrstop
  15. //
  16. // Public functions.
  17. //
  18. DECLARE_API( addr )
  19. /*++
  20. Routine Description:
  21. Dumps the TRANSPORT_ADDRESS structure at the specified address.
  22. Arguments:
  23. None.
  24. Return Value:
  25. None.
  26. --*/
  27. {
  28. DWORD address = 0;
  29. ULONG result;
  30. UCHAR transportAddress[MAX_TRANSPORT_ADDR];
  31. PTA_IP_ADDRESS ipAddress = (PTA_IP_ADDRESS)transportAddress;
  32. //
  33. // Snag the address from the command line.
  34. //
  35. sscanf( args, "%lx", &address );
  36. if( address == 0 ) {
  37. dprintf( "use: addr address\n" );
  38. return;
  39. }
  40. //
  41. // Assume the address is 22 bytes long (the same size as
  42. // a TA_IP_ADDRESS structure). After we perform this initial
  43. // read, we can examine the structure to determine its actual
  44. // size. If it's really larger than 22 bytes, we'll reread
  45. // the entire address structure.
  46. //
  47. if( !ReadMemory(
  48. address,
  49. transportAddress,
  50. sizeof(TA_IP_ADDRESS),
  51. &result
  52. ) ) {
  53. dprintf(
  54. "addr: cannot read TRANSPORT_ADDRESS @ %08lx\n",
  55. address
  56. );
  57. return;
  58. }
  59. if( ipAddress->TAAddressCount != 1 ) {
  60. dprintf(
  61. "addr: invalid TRANSPORT_ADDRESS @ %08lx\n",
  62. address
  63. );
  64. return;
  65. }
  66. if( ipAddress->Address[0].AddressLength > sizeof(TDI_ADDRESS_IP) ) {
  67. //
  68. // It's a big one.
  69. //
  70. if( !ReadMemory(
  71. address,
  72. transportAddress,
  73. ipAddress->Address[0].AddressLength +
  74. ( sizeof(TA_IP_ADDRESS) - sizeof(TDI_ADDRESS_IP) ),
  75. &result
  76. ) ) {
  77. dprintf(
  78. "addr: cannot read TRANSPORT_ADDRESS @ %08lx\n",
  79. address
  80. );
  81. return;
  82. }
  83. }
  84. DumpTransportAddress(
  85. "",
  86. (PTRANSPORT_ADDRESS)transportAddress,
  87. address
  88. );
  89. } // addr