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.

116 lines
3.4 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. //
  5. // Copyright (C) Microsoft Corporation, 2002
  6. //
  7. // File: skeleton.cxx
  8. //
  9. // History:
  10. // March 19th, 2002 mauricf Created
  11. //
  12. //
  13. // This file defines the boiler plate implementation. We define:
  14. // - our top level commands and command groups
  15. // - implement our context functions (start,stop commit etc)
  16. // - implement InitHelperDll (the one function we export directly)
  17. //--------------------------------------------------------------------------
  18. #include <windows.h>
  19. #include <guiddef.h>
  20. #include <stdlib.h>
  21. #include <netsh.h>
  22. #include <skeleton.h>
  23. #include <handlers.hxx>
  24. //Define all our top level commands (commands with no options)
  25. static CMD_ENTRY g_TopLevelCmdTable[] =
  26. {
  27. CREATE_CMD_ENTRY_EX_VER(ADD, HandleAdd, (CMD_FLAG_LOCAL|CMD_FLAG_ONLINE|CMD_FLAG_PRIVATE),CheckServerOrGreater),
  28. CREATE_CMD_ENTRY_EX_VER(DELETE, HandleDelete, (CMD_FLAG_LOCAL|CMD_FLAG_ONLINE|CMD_FLAG_PRIVATE),CheckServerOrGreater),
  29. CREATE_CMD_ENTRY_EX_VER(RESET, HandleReset, (CMD_FLAG_LOCAL|CMD_FLAG_ONLINE|CMD_FLAG_PRIVATE),CheckServerOrGreater),
  30. CREATE_CMD_ENTRY_EX_VER(SHOW, HandleShow, (CMD_FLAG_LOCAL|CMD_FLAG_ONLINE|CMD_FLAG_PRIVATE),CheckServerOrGreater)
  31. };
  32. const ULONG g_TopLevelCmdCount = 4;
  33. HANDLE g_hModule = NULL; //Need this to print error messages and get
  34. //string table strings
  35. DWORD WINAPI
  36. InitHelperDll(
  37. IN DWORD dwNetshVersion
  38. )
  39. /*++
  40. Routine Description:
  41. The InitHelperDll function is called by NetShell to perform an initial
  42. loading of a helper.
  43. Arguments:
  44. Return Value:
  45. --*/
  46. {
  47. DWORD dwErr;
  48. NS_HELPER_ATTRIBUTES attMyAttributes;
  49. // Attributes of this helper
  50. ZeroMemory(&attMyAttributes, sizeof(attMyAttributes));
  51. attMyAttributes.guidHelper = g_RPCNSHGuid; // GUID of this helper
  52. attMyAttributes.dwVersion = RPCNSH_VERSION;
  53. attMyAttributes.pfnStart = StartHelpers;
  54. attMyAttributes.pfnStop = NULL;
  55. dwErr = RegisterHelper(NULL,
  56. &attMyAttributes);
  57. g_hModule = GetModuleHandle("rpcnsh.dll");
  58. return dwErr;
  59. }
  60. DWORD WINAPI
  61. StartHelpers(
  62. IN CONST GUID * pguidParent,
  63. IN DWORD dwVersion
  64. )
  65. /*++
  66. Routine Description:
  67. The NS_HELPER_START_FN command is the start function for helpers. The start
  68. function provides an opportunity for helpers to register contexts, and is
  69. registered in the RegisterContext function.
  70. Arguments:
  71. Return Value:
  72. --*/
  73. {
  74. DWORD dwErr;
  75. NS_CONTEXT_ATTRIBUTES attMyAttributes;
  76. ZeroMemory(&attMyAttributes, sizeof(attMyAttributes));
  77. attMyAttributes.pwszContext = L"rpc";
  78. attMyAttributes.guidHelper = g_RPCNSHGuid;
  79. attMyAttributes.dwVersion = RPCNSH_VERSION;
  80. attMyAttributes.dwFlags = CMD_FLAG_LOCAL;
  81. attMyAttributes.ulNumTopCmds = g_TopLevelCmdCount;
  82. attMyAttributes.pTopCmds = (CMD_ENTRY (*)[])&g_TopLevelCmdTable;
  83. attMyAttributes.ulNumGroups = 0;
  84. attMyAttributes.pCmdGroups = NULL;
  85. attMyAttributes.pfnCommitFn = NULL;
  86. attMyAttributes.pfnDumpFn = NULL;
  87. attMyAttributes.pfnConnectFn = NULL;
  88. dwErr = RegisterContext( &attMyAttributes );
  89. return dwErr;
  90. }