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.

135 lines
4.6 KiB

  1. // --------------------------------------------------------------------------
  2. // Module Name: BadApplicationServerExports.cpp
  3. //
  4. // Copyright (c) 2000, Microsoft Corporation
  5. //
  6. // This file contains functions exported by name from the BAM service dll.
  7. //
  8. // History: 2000-12-04 vtan created
  9. // --------------------------------------------------------------------------
  10. #ifdef _X86_
  11. #include "StandardHeader.h"
  12. #include "BadApplicationAPIServer.h"
  13. #include "GracefulTerminateApplication.h"
  14. extern HINSTANCE g_hInstance;
  15. // --------------------------------------------------------------------------
  16. // ::FUSCompatibilityEntryTerminate
  17. //
  18. // Arguments: pszCommand = Command line from rundll32.
  19. //
  20. // Returns: <none>
  21. //
  22. // Purpose: Internal entry point to execute termination of a specified
  23. // process on behalf of the BAM server. The server starts the
  24. // rundll32 process on the correct session so that it can find
  25. // the window belonging to that session.
  26. //
  27. // History: 2000-10-27 vtan created
  28. // --------------------------------------------------------------------------
  29. EXTERN_C void WINAPI FUSCompatibilityEntryTerminate (const WCHAR *pszCommand)
  30. {
  31. CGracefulTerminateApplication terminateApplication;
  32. terminateApplication.Terminate(CBadApplicationAPIServer::StrToInt(pszCommand));
  33. DISPLAYMSG("Where was the call to kernel32!ExitProcess in CGracefulTerminateApplication::Terminate");
  34. }
  35. // --------------------------------------------------------------------------
  36. // ::FUSCompatibilityEntryPrompt
  37. //
  38. // Arguments: pszCommand = Command line from rundll32.
  39. //
  40. // Returns: <none>
  41. //
  42. // Purpose: Internal entry point to execute a prompt for termination of
  43. // the parent process of this one. This is used by the BAM shim
  44. // for type 1. Instead of bringing up UI in the application it
  45. // creates a rundll32 process to call this entry point which
  46. // brings up UI and returns a result to the parent in the exit
  47. // code.
  48. //
  49. // History: 2000-11-03 vtan created
  50. // --------------------------------------------------------------------------
  51. EXTERN_C void WINAPI FUSCompatibilityEntryPrompt (const WCHAR *pszCommand)
  52. {
  53. CGracefulTerminateApplication::Prompt(g_hInstance, reinterpret_cast<HANDLE>(CBadApplicationAPIServer::StrToInt(pszCommand)));
  54. DISPLAYMSG("Where was the call to kernel32!ExitProcess in CGracefulTerminateApplication::Prompt");
  55. }
  56. // --------------------------------------------------------------------------
  57. // ::FUSCompatibilityEntryW
  58. //
  59. // Arguments: hwndStub = ?
  60. // hInstance = ?
  61. // pszCmdLine = ?
  62. // nCmdShow = ?
  63. //
  64. // Returns: <none>
  65. //
  66. // Purpose: External named entry point for rundll32.exe in case of
  67. // external process hosting.
  68. //
  69. // History: 2000-10-10 vtan created
  70. // --------------------------------------------------------------------------
  71. EXTERN_C void WINAPI FUSCompatibilityEntryW (HWND hwndStub, HINSTANCE hInstance, LPWSTR pszCmdLine, int nCmdShow)
  72. {
  73. UNREFERENCED_PARAMETER(hwndStub);
  74. UNREFERENCED_PARAMETER(hInstance);
  75. UNREFERENCED_PARAMETER(nCmdShow);
  76. typedef void (WINAPI * PFNCOMMANDPROC) (const WCHAR *pszCommand);
  77. typedef struct
  78. {
  79. const WCHAR* szCommand;
  80. PFNCOMMANDPROC pfnCommandProc;
  81. } COMMAND_ENTRY, *PCOMMAND_ENTRY;
  82. static const COMMAND_ENTRY s_commands[] =
  83. {
  84. { L"terminate", FUSCompatibilityEntryTerminate },
  85. { L"prompt", FUSCompatibilityEntryPrompt }
  86. };
  87. int i, iLength;
  88. WCHAR szCommand[32];
  89. i = 0;
  90. iLength = lstrlenW(pszCmdLine);
  91. while ((i < iLength) && (pszCmdLine[i] != L' '))
  92. {
  93. ++i;
  94. }
  95. iLength = i;
  96. ASSERTMSG((i + sizeof('\0')) < ARRAYSIZE(szCommand), "Impending string overflow in ::BadApplicationEntryW");
  97. lstrcpy(szCommand, pszCmdLine);
  98. szCommand[iLength] = L'\0';
  99. for (i = 0; i < ARRAYSIZE(s_commands); ++i)
  100. {
  101. if (lstrcmpiW(s_commands[i].szCommand, szCommand) == 0)
  102. {
  103. const WCHAR *pszParameter;
  104. pszParameter = pszCmdLine + iLength;
  105. if (pszCmdLine[iLength] == L' ')
  106. {
  107. ++pszParameter;
  108. }
  109. s_commands[i].pfnCommandProc(pszParameter);
  110. }
  111. }
  112. }
  113. #endif /* _X86_ */