Source code of Windows XP (NT5)
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.

99 lines
2.9 KiB

  1. /****************************** Module Header ******************************\
  2. * Module Name: clinit.c
  3. *
  4. * Copyright (c) 1985-1992 Microsoft Corporation
  5. *
  6. * This module contains all the client/server init code for MMSNDSRVL.
  7. *
  8. * History:
  9. * 1 May 92 SteveDav Pinched from USER
  10. \***************************************************************************/
  11. #ifndef DOSWIN32
  12. #include <nt.h>
  13. #include <ntrtl.h>
  14. #include <nturtl.h>
  15. #include <ntcsrdll.h>
  16. #include "winmmi.h"
  17. #include "mci.h"
  18. #include <mmsndcs.h>
  19. #include <winss.h>
  20. #include <ntcsrmsg.h>
  21. #endif
  22. /***************************************************************************\
  23. * ServerInit
  24. *
  25. * When WINMM is loaded by an EXE (either at EXE load or at LoadModule
  26. * time) this routine is called by the loader. Its purpose is to initialize
  27. * everything that will be needed for future API calls by the app.
  28. *
  29. * History:
  30. * 1 May 92 SteveDav Pinched from USER
  31. \***************************************************************************/
  32. UINT fServer; // Server Process id
  33. BOOL ServerInit(VOID)
  34. {
  35. #ifndef DOSWIN32
  36. NTSTATUS status = 0;
  37. MMSNDCONNECT sndconnect;
  38. CSR_CALLBACK_INFO cbiCallBack;
  39. ULONG ulConnect = sizeof(MMSNDCONNECT);
  40. sndconnect.ulVersion = MMSNDCURRENTVERSION;
  41. sndconnect.hFileMapping = 0;
  42. cbiCallBack.ApiNumberBase = 0;
  43. cbiCallBack.MaxApiNumber = 0;
  44. cbiCallBack.CallbackDispatchTable = 0;
  45. dprintf3((" BEFORE %8x >> hFileMapping",sndconnect.hFileMapping));
  46. dprintf4((" %8x >> hEvent",sndconnect.hEvent));
  47. dprintf4((" %8x >> hMutex",sndconnect.hMutex));
  48. status = CsrClientConnectToServer(WINSS_OBJECT_DIRECTORY_NAME,
  49. MMSNDSRV_SERVERDLL_INDEX, &cbiCallBack, &sndconnect,
  50. &ulConnect, (PBOOLEAN)&fServer);
  51. if (!NT_SUCCESS(status)) {
  52. dprintf2(("could not connect to sound server, status is %8x", status));
  53. return FALSE;
  54. }
  55. dprintf3(("AFTER %8x = version, status is %x",sndconnect.ulCurrentVersion, status));
  56. dprintf3((" %8x >> hFileMapping",sndconnect.hFileMapping));
  57. dprintf4((" %8x >> hEvent",sndconnect.hEvent));
  58. dprintf4((" %8x >> hMutex",sndconnect.hMutex));
  59. if (sndconnect.hFileMapping) {
  60. base = MapViewOfFile( sndconnect.hFileMapping, FILE_MAP_ALL_ACCESS,
  61. 0, 0, 0); // from beginning for total length
  62. if (!base) {
  63. DWORD n;
  64. n = GetLastError();
  65. dprintf1(("Error %d mapping file view with server handle %x", n, sndconnect.hFileMapping));
  66. } else {
  67. dprintf2(("Address %x mapping file view with server handle", base));
  68. hEvent = sndconnect.hEvent;
  69. hMutex = sndconnect.hMutex;
  70. hFileMapping = sndconnect.hFileMapping;
  71. tidNotify = base->dwGlobalThreadId;
  72. }
  73. } else {
  74. dprintf1(("Server did not return a valid file mapping handle"));
  75. }
  76. #endif
  77. return TRUE;
  78. }