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.

109 lines
3.0 KiB

  1. #include <nt.h>
  2. #include <ntrtl.h>
  3. #include <nturtl.h>
  4. #include <windows.h>
  5. #include <stdio.h>
  6. #include <stdlib.h>
  7. #include <dnsapi.h>
  8. #include "..\dnslib.h"
  9. VOID
  10. PrintIpAddress (
  11. IN DWORD dwIpAddress )
  12. {
  13. printf( "%d.%d.%d.%d\n",
  14. ((BYTE *) &dwIpAddress)[0],
  15. ((BYTE *) &dwIpAddress)[1],
  16. ((BYTE *) &dwIpAddress)[2],
  17. ((BYTE *) &dwIpAddress)[3] );
  18. }
  19. VOID
  20. PrintServerInfo (
  21. IN DNS_NAME_SERVER_INFO ServerInfo )
  22. {
  23. printf( " ipAddress : " );
  24. PrintIpAddress( ServerInfo.ipAddress );
  25. printf( " Priority : %d\n", ServerInfo.Priority );
  26. printf( " Status : %d\n\n", ServerInfo.Status );
  27. }
  28. VOID
  29. PrintAdapterInfo (
  30. IN PDNS_ADAPTER_INFO pAdapterInfo )
  31. {
  32. DWORD iter;
  33. printf( " pszAdapterDomain : %s\n", pAdapterInfo->pszAdapterDomain );
  34. printf( " Status : 0x%x\n", pAdapterInfo->Status );
  35. printf( " ReturnFlags : 0x%x\n", pAdapterInfo->ReturnFlags );
  36. printf( " ipLastSend : " );
  37. PrintIpAddress( pAdapterInfo->ipLastSend );
  38. printf( " cServerCount : %d\n", pAdapterInfo->cServerCount );
  39. printf( " cTotalListSize : %d\n\n", pAdapterInfo->cTotalListSize );
  40. for ( iter = 0; iter < pAdapterInfo->cServerCount; iter++ )
  41. {
  42. printf( " Server Info (%d)\n", iter + 1 );
  43. printf( " ___________________\n" );
  44. PrintServerInfo( pAdapterInfo->aipServers[iter] );
  45. }
  46. printf( "\n" );
  47. }
  48. _cdecl
  49. main(int argc, char **argv)
  50. {
  51. PDNS_NETWORK_INFO pNetworkInfo = NULL;
  52. DWORD sysVersion;
  53. DWORD iter;
  54. Dns_InitNetworkInfo();
  55. sysVersion = GetVersion();
  56. printf( "System version is : 0x%x\n", sysVersion );
  57. pNetworkInfo = Dns_GetDnsNetworkInfo( TRUE, TRUE );
  58. if ( !pNetworkInfo )
  59. {
  60. printf( "Dns_GetDnsNetworkInfo call failed\n" );
  61. return(0);
  62. }
  63. printf( "Dns_GetDnsNetworkInfo returned ...\n\n" );
  64. printf( " pNetworkInfo->ReturnFlags : 0x%x\n", pNetworkInfo->ReturnFlags );
  65. printf( " pNetworkInfo->pszName : %s\n", pNetworkInfo->pszName );
  66. printf( " pNetworkInfo->cAdapterCount : %d\n", pNetworkInfo->cAdapterCount );
  67. printf( " pNetworkInfo->cTotalListSize : %d\n", pNetworkInfo->cTotalListSize );
  68. for ( iter = 0; iter < pNetworkInfo->cAdapterCount; iter++ )
  69. {
  70. printf( " Adapter Info (%d)\n", iter + 1 );
  71. printf( " ____________________________________\n" );
  72. PrintAdapterInfo( pNetworkInfo->aAdapterInfoList[iter] );
  73. }
  74. system( "pause" );
  75. for ( iter = 0; iter < 100000; iter++ )
  76. {
  77. PDNS_NETWORK_INFO pTempNetworkInfo = pNetworkInfo;
  78. pNetworkInfo = Dns_CreateNetworkInfoCopy( pTempNetworkInfo );
  79. Dns_FreeNetworkInfo( pTempNetworkInfo );
  80. }
  81. system( "pause" );
  82. Dns_FreeNetworkInfo( pNetworkInfo );
  83. system( "pause" );
  84. return(0);
  85. }