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.

91 lines
2.0 KiB

  1. #include "pch.h"
  2. extern "C" int __cdecl wmain(const UINT argc,const WCHAR* argv[]);
  3. typedef HRESULT (WINAPI * PFNDNSETUP)(LPCWSTR lpszFwdZoneName,
  4. LPCWSTR lpszFwdZoneFileName,
  5. LPCWSTR lpszRevZoneName,
  6. LPCWSTR lpszRevZoneFileName,
  7. DWORD dwFlags);
  8. HRESULT DnsSetup(LPCWSTR lpszFwdZoneName,
  9. LPCWSTR lpszFwdZoneFileName,
  10. LPCWSTR lpszRevZoneName,
  11. LPCWSTR lpszRevZoneFileName,
  12. DWORD dwFlags)
  13. {
  14. HMODULE hLibrary = ::LoadLibrary(L"dnsmgr.dll");
  15. if (NULL == hLibrary)
  16. {
  17. // The library is not present
  18. wprintf(L"LoadLibrary() failed\n");
  19. return E_INVALIDARG;
  20. }
  21. FARPROC pfFunction = ::GetProcAddress(hLibrary, "DnsSetup" );
  22. if ( NULL == pfFunction )
  23. {
  24. // The library is present but does not have the entry point
  25. wprintf(L"GetProcAddress() failed\n");
  26. ::FreeLibrary( hLibrary );
  27. return E_INVALIDARG;
  28. }
  29. wprintf(L"calling function\n");
  30. HRESULT hr = ((PFNDNSETUP)pfFunction)
  31. (lpszFwdZoneName ,lpszFwdZoneFileName, lpszRevZoneName, lpszRevZoneFileName, dwFlags);
  32. wprintf(L"function returned hr = 0x%x\n", hr);
  33. ::FreeLibrary( hLibrary );
  34. return hr;
  35. }
  36. int __cdecl wmain(const UINT argc,const WCHAR* argv[])
  37. {
  38. LPCWSTR lpszFwdZoneName = NULL;
  39. LPCWSTR lpszFwdZoneFileName = NULL;
  40. LPCWSTR lpszRevZoneName = NULL;
  41. LPCWSTR lpszRevZoneFileName = NULL;
  42. if ((argc != 3) && (argc != 5))
  43. {
  44. wprintf(L"usage:\n");
  45. wprintf(L"dnssetup fdwzonename fwzzonefilename [revzonename revzonefilename]\n");
  46. return -1;
  47. }
  48. lpszFwdZoneName = argv[1];
  49. lpszFwdZoneFileName = argv[2];
  50. if (argc == 5)
  51. {
  52. LPCWSTR lpszRevZoneName = argv[3];
  53. LPCWSTR lpszRevZoneFileName = argv[4];
  54. }
  55. wprintf(L"Starting\n");
  56. HRESULT hr = DnsSetup(lpszFwdZoneName, lpszFwdZoneFileName, lpszRevZoneName, lpszRevZoneFileName, 0x0);
  57. wprintf(L"\nDone\n");
  58. return 0;
  59. }