winoldap.c 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. /*
  2. * WINOLDAP implementation
  3. *
  4. * Copyright 2000 Alexandre Julliard
  5. *
  6. * This library is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU Lesser General Public
  8. * License as published by the Free Software Foundation; either
  9. * version 2.1 of the License, or (at your option) any later version.
  10. *
  11. * This library is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * Lesser General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Lesser General Public
  17. * License along with this library; if not, write to the Free Software
  18. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
  19. */
  20. #include <stdarg.h>
  21. #include <stdio.h>
  22. #include "windef.h"
  23. #include "winbase.h"
  24. #include "wownt32.h"
  25. #include "wine/winbase16.h"
  26. #include "wine/server.h"
  27. #include "wine/debug.h"
  28. WINE_DEFAULT_DEBUG_CHANNEL(module);
  29. /***********************************************************************
  30. * wait_input_idle
  31. *
  32. * user32.WaitForInputIdle releases the win16 lock, so here is a replacement.
  33. */
  34. static DWORD wait_input_idle( HANDLE process, DWORD timeout )
  35. {
  36. DWORD ret;
  37. HANDLE handles[2];
  38. handles[0] = process;
  39. SERVER_START_REQ( get_process_idle_event )
  40. {
  41. req->handle = wine_server_obj_handle(process);
  42. if (!(ret = wine_server_call_err( req ))) handles[1] = wine_server_ptr_handle( reply->event );
  43. }
  44. SERVER_END_REQ;
  45. if (ret) return WAIT_FAILED; /* error */
  46. if (!handles[1]) return 0; /* no event to wait on */
  47. return WaitForMultipleObjects( 2, handles, FALSE, timeout );
  48. }
  49. /**************************************************************************
  50. * WINOLDAP entry point
  51. */
  52. WORD WINAPI WinMain16( HINSTANCE16 inst, HINSTANCE16 prev, LPSTR cmdline, WORD show )
  53. {
  54. PROCESS_INFORMATION info;
  55. STARTUPINFOA startup;
  56. DWORD count, exit_code = 1;
  57. WINE_TRACE( "%x %x %s %u\n", inst, prev, wine_dbgstr_a(cmdline), show );
  58. memset( &startup, 0, sizeof(startup) );
  59. startup.cb = sizeof(startup);
  60. if (CreateProcessA( NULL, cmdline, NULL, NULL, FALSE,
  61. 0, NULL, NULL, &startup, &info ))
  62. {
  63. /* Give 10 seconds to the app to come up */
  64. if (wait_input_idle( info.hProcess, 10000 ) == WAIT_FAILED)
  65. WINE_WARN("WaitForInputIdle failed: Error %ld\n", GetLastError() );
  66. ReleaseThunkLock( &count );
  67. WaitForSingleObject( info.hProcess, INFINITE );
  68. RestoreThunkLock( count );
  69. GetExitCodeProcess( info.hProcess, &exit_code );
  70. CloseHandle( info.hThread );
  71. CloseHandle( info.hProcess );
  72. }
  73. HeapFree( GetProcessHeap(), 0, cmdline );
  74. ExitThread( exit_code );
  75. }