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.

93 lines
4.4 KiB

  1. var EXCEPTION_ACCESS_VIOLATION = 0xc0000005;
  2. var EXCEPTION_STACK_OVERFLOW = 0xc00000fd;
  3. var EXCEPTION_INT_DIVIDE_BY_ZERO = 0xc0000094;
  4. var EXCEPTION_ILLEGAL_INSTRUCTION = 0xc000001d;
  5. // from resources.h
  6. var TYPE_LPWSTR = 0;
  7. var TYPE_LPLPWSTR = 1;
  8. var TYPE_LPSTR = 2;
  9. var TYPE_LPLPSTR = 3;
  10. var TYPE_DWORD = 4;
  11. var TYPE_LPDWORD = 5;
  12. // pointer value flags
  13. var NULL_PTR = 0;
  14. var BAD_PTR = 1;
  15. var FREE_PTR = 2;
  16. var UNINIT_PTR = 3;
  17. // data init flags
  18. var INIT_NULL = 0;
  19. var INIT_SMILEY = 1;
  20. var INIT_HEXFF = 2;
  21. var INIT_GARBAGE = 3;
  22. // from winhttp.h
  23. var WINHTTP_ACCESS_TYPE_DEFAULT_PROXY = 0;
  24. var WINHTTP_ACCESS_TYPE_NO_PROXY = 1;
  25. var WINHTTP_ACCESS_TYPE_NAMED_PROXY = 3;
  26. var WINHTTP_FLAG_SYNC = 0x00000000;
  27. var WINHTTP_FLAG_ASYNC = 0x10000000;
  28. var WINHTTP_CALLBACK_STATUS_RESOLVING_NAME = 0x00000001;
  29. var WINHTTP_CALLBACK_STATUS_NAME_RESOLVED = 0x00000002;
  30. var WINHTTP_CALLBACK_STATUS_CONNECTING_TO_SERVER = 0x00000004;
  31. var WINHTTP_CALLBACK_STATUS_CONNECTED_TO_SERVER = 0x00000008;
  32. var WINHTTP_CALLBACK_STATUS_SENDING_REQUEST = 0x00000010;
  33. var WINHTTP_CALLBACK_STATUS_REQUEST_SENT = 0x00000020;
  34. var WINHTTP_CALLBACK_STATUS_RECEIVING_RESPONSE = 0x00000040;
  35. var WINHTTP_CALLBACK_STATUS_RESPONSE_RECEIVED = 0x00000080;
  36. var WINHTTP_CALLBACK_STATUS_CLOSING_CONNECTION = 0x00000100;
  37. var WINHTTP_CALLBACK_STATUS_CONNECTION_CLOSED = 0x00000200;
  38. var WINHTTP_CALLBACK_STATUS_HANDLE_CREATED = 0x00000400;
  39. var WINHTTP_CALLBACK_STATUS_HANDLE_CLOSING = 0x00000800;
  40. var WINHTTP_CALLBACK_STATUS_DETECTING_PROXY = 0x00001000;
  41. var WINHTTP_CALLBACK_STATUS_REQUEST_COMPLETE = 0x00002000;
  42. var WINHTTP_CALLBACK_STATUS_REDIRECT = 0x00004000;
  43. var WINHTTP_CALLBACK_STATUS_INTERMEDIATE_RESPONSE = 0x00008000;
  44. var WINHTTP_CALLBACK_STATUS_SECURE_FAILURE = 0x00010000;
  45. var WINHTTP_CALLBACK_FLAG_RESOLVE_NAME = (WINHTTP_CALLBACK_STATUS_RESOLVING_NAME | WINHTTP_CALLBACK_STATUS_NAME_RESOLVED);
  46. var WINHTTP_CALLBACK_FLAG_CONNECT_TO_SERVER = (WINHTTP_CALLBACK_STATUS_CONNECTING_TO_SERVER | WINHTTP_CALLBACK_STATUS_CONNECTED_TO_SERVER);
  47. var WINHTTP_CALLBACK_FLAG_SEND_REQUEST = (WINHTTP_CALLBACK_STATUS_SENDING_REQUEST | WINHTTP_CALLBACK_STATUS_REQUEST_SENT);
  48. var WINHTTP_CALLBACK_FLAG_RECEIVE_RESPONSE = (WINHTTP_CALLBACK_STATUS_RECEIVING_RESPONSE | WINHTTP_CALLBACK_STATUS_RESPONSE_RECEIVED);
  49. var WINHTTP_CALLBACK_FLAG_CLOSE_CONNECTION = (WINHTTP_CALLBACK_STATUS_CLOSING_CONNECTION | WINHTTP_CALLBACK_STATUS_CONNECTION_CLOSED);
  50. var WINHTTP_CALLBACK_FLAG_HANDLES = (WINHTTP_CALLBACK_STATUS_HANDLE_CREATED | WINHTTP_CALLBACK_STATUS_HANDLE_CLOSING);
  51. var WINHTTP_CALLBACK_FLAG_DETECTING_PROXY = WINHTTP_CALLBACK_STATUS_DETECTING_PROXY;
  52. var WINHTTP_CALLBACK_FLAG_REQUEST_COMPLETE = WINHTTP_CALLBACK_STATUS_REQUEST_COMPLETE;
  53. var WINHTTP_CALLBACK_FLAG_REDIRECT = WINHTTP_CALLBACK_STATUS_REDIRECT;
  54. var WINHTTP_CALLBACK_FLAG_INTERMEDIATE_RESPONSE = WINHTTP_CALLBACK_STATUS_INTERMEDIATE_RESPONSE;
  55. var WINHTTP_CALLBACK_FLAG_SECURE_FAILURE = WINHTTP_CALLBACK_STATUS_SECURE_FAILURE;
  56. var WINHTTP_CALLBACK_FLAG_ALL_NOTIFICATIONS = 0x0000000a; // not the same as the header file, but script doesn't like 0xffffffff
  57. var whr = new ActiveXObject("WinHttpTest");
  58. if( whr )
  59. {
  60. var hOpen = null;
  61. var hConnect = null;
  62. var hRequest = null;
  63. var AcceptHeaders = new Array("text/plain", "image/*", "*/*");
  64. var bRequestSend = false;
  65. hOpen = whr.winhttpopen("test", WINHTTP_ACCESS_TYPE_NAMED_PROXY, "itgproxy", "", WINHTTP_FLAG_SYNC);
  66. whr.winhttpsetstatuscallback(hOpen, callback1, WINHTTP_CALLBACK_FLAG_ALL_NOTIFICATIONS, 0);
  67. hConnect = whr.winhttpconnect(hOpen, "winhttp", 80, 0);
  68. hRequest = whr.winhttpopenrequest(hConnect, "GET", "/", NULL_PTR, NULL_PTR, AcceptHeaders.join(";"), 0);
  69. if( whr.winhttpsendrequest(hRequest, NULL_PTR, 0, NULL_PTR, 0, 0, 0) )
  70. {
  71. WScript.Echo("request was sent");
  72. }
  73. whr.winhttpclosehandle(hRequest);
  74. whr.winhttpclosehandle(hConnect);
  75. whr.winhttpclosehandle(hOpen);
  76. }
  77. function callback1(handle, context, status, info, infolen)
  78. {
  79. WScript.Echo("in callback1: " + handle + ", " + context + ", " + status + ", " + info + ", " + infolen);
  80. }