@shitiandmw/node-pty 1.1.0-agent.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (288) hide show
  1. package/LICENSE +69 -0
  2. package/README.md +170 -0
  3. package/binding.gyp +111 -0
  4. package/deps/.editorconfig +2 -0
  5. package/deps/winpty/.drone.yml +17 -0
  6. package/deps/winpty/.gitattributes +19 -0
  7. package/deps/winpty/LICENSE +21 -0
  8. package/deps/winpty/Makefile +166 -0
  9. package/deps/winpty/README.md +151 -0
  10. package/deps/winpty/RELEASES.md +280 -0
  11. package/deps/winpty/VERSION.txt +1 -0
  12. package/deps/winpty/configure +167 -0
  13. package/deps/winpty/misc/BufferResizeTests.cc +90 -0
  14. package/deps/winpty/misc/ChangeScreenBuffer.cc +53 -0
  15. package/deps/winpty/misc/ClearConsole.cc +72 -0
  16. package/deps/winpty/misc/ConinMode.cc +117 -0
  17. package/deps/winpty/misc/ConinMode.ps1 +116 -0
  18. package/deps/winpty/misc/ConoutMode.cc +113 -0
  19. package/deps/winpty/misc/DebugClient.py +42 -0
  20. package/deps/winpty/misc/DebugServer.py +63 -0
  21. package/deps/winpty/misc/DumpLines.py +5 -0
  22. package/deps/winpty/misc/EnableExtendedFlags.txt +46 -0
  23. package/deps/winpty/misc/Font-Report-June2016/CP437-Consolas.txt +528 -0
  24. package/deps/winpty/misc/Font-Report-June2016/CP437-Lucida.txt +633 -0
  25. package/deps/winpty/misc/Font-Report-June2016/CP932.txt +630 -0
  26. package/deps/winpty/misc/Font-Report-June2016/CP936.txt +630 -0
  27. package/deps/winpty/misc/Font-Report-June2016/CP949.txt +630 -0
  28. package/deps/winpty/misc/Font-Report-June2016/CP950.txt +630 -0
  29. package/deps/winpty/misc/Font-Report-June2016/MinimumWindowWidths.txt +16 -0
  30. package/deps/winpty/misc/Font-Report-June2016/Results.txt +4 -0
  31. package/deps/winpty/misc/Font-Report-June2016/Windows10SetFontBugginess.txt +144 -0
  32. package/deps/winpty/misc/FontSurvey.cc +100 -0
  33. package/deps/winpty/misc/FormatChar.h +21 -0
  34. package/deps/winpty/misc/FreezePerfTest.cc +62 -0
  35. package/deps/winpty/misc/GetCh.cc +20 -0
  36. package/deps/winpty/misc/GetConsolePos.cc +41 -0
  37. package/deps/winpty/misc/GetFont.cc +261 -0
  38. package/deps/winpty/misc/IdentifyConsoleWindow.ps1 +51 -0
  39. package/deps/winpty/misc/IsNewConsole.cc +87 -0
  40. package/deps/winpty/misc/MouseInputNotes.txt +90 -0
  41. package/deps/winpty/misc/MoveConsoleWindow.cc +34 -0
  42. package/deps/winpty/misc/Notes.txt +219 -0
  43. package/deps/winpty/misc/OSVersion.cc +27 -0
  44. package/deps/winpty/misc/ScreenBufferFreezeInactive.cc +101 -0
  45. package/deps/winpty/misc/ScreenBufferTest.cc +671 -0
  46. package/deps/winpty/misc/ScreenBufferTest2.cc +151 -0
  47. package/deps/winpty/misc/SelectAllTest.cc +45 -0
  48. package/deps/winpty/misc/SetBufferSize.cc +32 -0
  49. package/deps/winpty/misc/SetCursorPos.cc +10 -0
  50. package/deps/winpty/misc/SetFont.cc +145 -0
  51. package/deps/winpty/misc/SetWindowRect.cc +36 -0
  52. package/deps/winpty/misc/ShowArgv.cc +12 -0
  53. package/deps/winpty/misc/ShowConsoleInput.cc +40 -0
  54. package/deps/winpty/misc/Spew.py +5 -0
  55. package/deps/winpty/misc/TestUtil.cc +172 -0
  56. package/deps/winpty/misc/UnicodeDoubleWidthTest.cc +102 -0
  57. package/deps/winpty/misc/UnicodeWideTest1.cc +246 -0
  58. package/deps/winpty/misc/UnicodeWideTest2.cc +130 -0
  59. package/deps/winpty/misc/UnixEcho.cc +89 -0
  60. package/deps/winpty/misc/Utf16Echo.cc +46 -0
  61. package/deps/winpty/misc/VeryLargeRead.cc +122 -0
  62. package/deps/winpty/misc/VkEscapeTest.cc +56 -0
  63. package/deps/winpty/misc/Win10ResizeWhileFrozen.cc +52 -0
  64. package/deps/winpty/misc/Win10WrapTest1.cc +57 -0
  65. package/deps/winpty/misc/Win10WrapTest2.cc +30 -0
  66. package/deps/winpty/misc/Win32Echo1.cc +26 -0
  67. package/deps/winpty/misc/Win32Echo2.cc +19 -0
  68. package/deps/winpty/misc/Win32Test1.cc +46 -0
  69. package/deps/winpty/misc/Win32Test2.cc +70 -0
  70. package/deps/winpty/misc/Win32Test3.cc +78 -0
  71. package/deps/winpty/misc/Win32Write1.cc +44 -0
  72. package/deps/winpty/misc/WindowsBugCrashReader.cc +27 -0
  73. package/deps/winpty/misc/WriteConsole.cc +106 -0
  74. package/deps/winpty/misc/build32.sh +9 -0
  75. package/deps/winpty/misc/build64.sh +9 -0
  76. package/deps/winpty/misc/color-test.sh +212 -0
  77. package/deps/winpty/misc/font-notes.txt +300 -0
  78. package/deps/winpty/misc/winbug-15048.cc +201 -0
  79. package/deps/winpty/ship/build-pty4j-libpty.bat +36 -0
  80. package/deps/winpty/ship/common_ship.py +53 -0
  81. package/deps/winpty/ship/make_msvc_package.py +165 -0
  82. package/deps/winpty/ship/ship.py +108 -0
  83. package/deps/winpty/src/agent/Agent.cc +613 -0
  84. package/deps/winpty/src/agent/Agent.h +103 -0
  85. package/deps/winpty/src/agent/AgentCreateDesktop.cc +84 -0
  86. package/deps/winpty/src/agent/AgentCreateDesktop.h +28 -0
  87. package/deps/winpty/src/agent/ConsoleFont.cc +632 -0
  88. package/deps/winpty/src/agent/ConsoleFont.h +28 -0
  89. package/deps/winpty/src/agent/ConsoleInput.cc +852 -0
  90. package/deps/winpty/src/agent/ConsoleInput.h +109 -0
  91. package/deps/winpty/src/agent/ConsoleInputReencoding.cc +121 -0
  92. package/deps/winpty/src/agent/ConsoleInputReencoding.h +36 -0
  93. package/deps/winpty/src/agent/ConsoleLine.cc +152 -0
  94. package/deps/winpty/src/agent/ConsoleLine.h +41 -0
  95. package/deps/winpty/src/agent/Coord.h +87 -0
  96. package/deps/winpty/src/agent/DebugShowInput.cc +239 -0
  97. package/deps/winpty/src/agent/DebugShowInput.h +32 -0
  98. package/deps/winpty/src/agent/DefaultInputMap.cc +422 -0
  99. package/deps/winpty/src/agent/DefaultInputMap.h +28 -0
  100. package/deps/winpty/src/agent/DsrSender.h +30 -0
  101. package/deps/winpty/src/agent/EventLoop.cc +99 -0
  102. package/deps/winpty/src/agent/EventLoop.h +47 -0
  103. package/deps/winpty/src/agent/InputMap.cc +246 -0
  104. package/deps/winpty/src/agent/InputMap.h +114 -0
  105. package/deps/winpty/src/agent/LargeConsoleRead.cc +71 -0
  106. package/deps/winpty/src/agent/LargeConsoleRead.h +68 -0
  107. package/deps/winpty/src/agent/NamedPipe.cc +378 -0
  108. package/deps/winpty/src/agent/NamedPipe.h +125 -0
  109. package/deps/winpty/src/agent/Scraper.cc +699 -0
  110. package/deps/winpty/src/agent/Scraper.h +103 -0
  111. package/deps/winpty/src/agent/SimplePool.h +75 -0
  112. package/deps/winpty/src/agent/SmallRect.h +143 -0
  113. package/deps/winpty/src/agent/Terminal.cc +535 -0
  114. package/deps/winpty/src/agent/Terminal.h +69 -0
  115. package/deps/winpty/src/agent/UnicodeEncoding.h +157 -0
  116. package/deps/winpty/src/agent/UnicodeEncodingTest.cc +189 -0
  117. package/deps/winpty/src/agent/Win32Console.cc +107 -0
  118. package/deps/winpty/src/agent/Win32Console.h +67 -0
  119. package/deps/winpty/src/agent/Win32ConsoleBuffer.cc +193 -0
  120. package/deps/winpty/src/agent/Win32ConsoleBuffer.h +99 -0
  121. package/deps/winpty/src/agent/main.cc +114 -0
  122. package/deps/winpty/src/agent/subdir.mk +61 -0
  123. package/deps/winpty/src/configurations.gypi +60 -0
  124. package/deps/winpty/src/debugserver/DebugServer.cc +117 -0
  125. package/deps/winpty/src/debugserver/subdir.mk +41 -0
  126. package/deps/winpty/src/include/winpty.h +242 -0
  127. package/deps/winpty/src/include/winpty_constants.h +131 -0
  128. package/deps/winpty/src/libwinpty/AgentLocation.cc +75 -0
  129. package/deps/winpty/src/libwinpty/AgentLocation.h +28 -0
  130. package/deps/winpty/src/libwinpty/LibWinptyException.h +54 -0
  131. package/deps/winpty/src/libwinpty/WinptyInternal.h +72 -0
  132. package/deps/winpty/src/libwinpty/subdir.mk +46 -0
  133. package/deps/winpty/src/libwinpty/winpty.cc +970 -0
  134. package/deps/winpty/src/shared/AgentMsg.h +38 -0
  135. package/deps/winpty/src/shared/BackgroundDesktop.cc +122 -0
  136. package/deps/winpty/src/shared/BackgroundDesktop.h +73 -0
  137. package/deps/winpty/src/shared/Buffer.cc +103 -0
  138. package/deps/winpty/src/shared/Buffer.h +102 -0
  139. package/deps/winpty/src/shared/DebugClient.cc +187 -0
  140. package/deps/winpty/src/shared/DebugClient.h +38 -0
  141. package/deps/winpty/src/shared/GenRandom.cc +138 -0
  142. package/deps/winpty/src/shared/GenRandom.h +55 -0
  143. package/deps/winpty/src/shared/GetCommitHash.bat +13 -0
  144. package/deps/winpty/src/shared/Mutex.h +54 -0
  145. package/deps/winpty/src/shared/OsModule.h +63 -0
  146. package/deps/winpty/src/shared/OwnedHandle.cc +36 -0
  147. package/deps/winpty/src/shared/OwnedHandle.h +45 -0
  148. package/deps/winpty/src/shared/PrecompiledHeader.h +43 -0
  149. package/deps/winpty/src/shared/StringBuilder.h +227 -0
  150. package/deps/winpty/src/shared/StringBuilderTest.cc +114 -0
  151. package/deps/winpty/src/shared/StringUtil.cc +55 -0
  152. package/deps/winpty/src/shared/StringUtil.h +80 -0
  153. package/deps/winpty/src/shared/TimeMeasurement.h +63 -0
  154. package/deps/winpty/src/shared/UnixCtrlChars.h +45 -0
  155. package/deps/winpty/src/shared/UpdateGenVersion.bat +20 -0
  156. package/deps/winpty/src/shared/WindowsSecurity.cc +460 -0
  157. package/deps/winpty/src/shared/WindowsSecurity.h +104 -0
  158. package/deps/winpty/src/shared/WindowsVersion.cc +252 -0
  159. package/deps/winpty/src/shared/WindowsVersion.h +29 -0
  160. package/deps/winpty/src/shared/WinptyAssert.cc +55 -0
  161. package/deps/winpty/src/shared/WinptyAssert.h +64 -0
  162. package/deps/winpty/src/shared/WinptyException.cc +57 -0
  163. package/deps/winpty/src/shared/WinptyException.h +43 -0
  164. package/deps/winpty/src/shared/WinptyVersion.cc +42 -0
  165. package/deps/winpty/src/shared/WinptyVersion.h +27 -0
  166. package/deps/winpty/src/shared/winpty_snprintf.h +99 -0
  167. package/deps/winpty/src/subdir.mk +5 -0
  168. package/deps/winpty/src/tests/subdir.mk +28 -0
  169. package/deps/winpty/src/tests/trivial_test.cc +158 -0
  170. package/deps/winpty/src/unix-adapter/InputHandler.cc +114 -0
  171. package/deps/winpty/src/unix-adapter/InputHandler.h +56 -0
  172. package/deps/winpty/src/unix-adapter/OutputHandler.cc +80 -0
  173. package/deps/winpty/src/unix-adapter/OutputHandler.h +53 -0
  174. package/deps/winpty/src/unix-adapter/Util.cc +86 -0
  175. package/deps/winpty/src/unix-adapter/Util.h +31 -0
  176. package/deps/winpty/src/unix-adapter/WakeupFd.cc +70 -0
  177. package/deps/winpty/src/unix-adapter/WakeupFd.h +42 -0
  178. package/deps/winpty/src/unix-adapter/main.cc +729 -0
  179. package/deps/winpty/src/unix-adapter/subdir.mk +41 -0
  180. package/deps/winpty/src/winpty.gyp +234 -0
  181. package/deps/winpty/vcbuild.bat +83 -0
  182. package/lib/conpty_console_list_agent.js +16 -0
  183. package/lib/conpty_console_list_agent.js.map +1 -0
  184. package/lib/eventEmitter2.js +47 -0
  185. package/lib/eventEmitter2.js.map +1 -0
  186. package/lib/eventEmitter2.test.js +30 -0
  187. package/lib/eventEmitter2.test.js.map +1 -0
  188. package/lib/index.js +52 -0
  189. package/lib/index.js.map +1 -0
  190. package/lib/interfaces.js +7 -0
  191. package/lib/interfaces.js.map +1 -0
  192. package/lib/shared/conout.js +11 -0
  193. package/lib/shared/conout.js.map +1 -0
  194. package/lib/terminal.js +190 -0
  195. package/lib/terminal.js.map +1 -0
  196. package/lib/terminal.test.js +139 -0
  197. package/lib/terminal.test.js.map +1 -0
  198. package/lib/testUtils.test.js +28 -0
  199. package/lib/testUtils.test.js.map +1 -0
  200. package/lib/types.js +7 -0
  201. package/lib/types.js.map +1 -0
  202. package/lib/unixTerminal.js +346 -0
  203. package/lib/unixTerminal.js.map +1 -0
  204. package/lib/unixTerminal.test.js +351 -0
  205. package/lib/unixTerminal.test.js.map +1 -0
  206. package/lib/utils.js +39 -0
  207. package/lib/utils.js.map +1 -0
  208. package/lib/windowsConoutConnection.js +125 -0
  209. package/lib/windowsConoutConnection.js.map +1 -0
  210. package/lib/windowsPtyAgent.js +320 -0
  211. package/lib/windowsPtyAgent.js.map +1 -0
  212. package/lib/windowsPtyAgent.test.js +90 -0
  213. package/lib/windowsPtyAgent.test.js.map +1 -0
  214. package/lib/windowsTerminal.js +199 -0
  215. package/lib/windowsTerminal.js.map +1 -0
  216. package/lib/windowsTerminal.test.js +219 -0
  217. package/lib/windowsTerminal.test.js.map +1 -0
  218. package/lib/worker/conoutSocketWorker.js +22 -0
  219. package/lib/worker/conoutSocketWorker.js.map +1 -0
  220. package/package.json +68 -0
  221. package/prebuilds/darwin-arm64/pty.node +0 -0
  222. package/prebuilds/darwin-arm64/spawn-helper +0 -0
  223. package/prebuilds/darwin-x64/pty.node +0 -0
  224. package/prebuilds/darwin-x64/spawn-helper +0 -0
  225. package/prebuilds/win32-arm64/conpty/OpenConsole.exe +0 -0
  226. package/prebuilds/win32-arm64/conpty/conpty.dll +0 -0
  227. package/prebuilds/win32-arm64/conpty.node +0 -0
  228. package/prebuilds/win32-arm64/conpty.pdb +0 -0
  229. package/prebuilds/win32-arm64/conpty_console_list.node +0 -0
  230. package/prebuilds/win32-arm64/conpty_console_list.pdb +0 -0
  231. package/prebuilds/win32-arm64/pty.node +0 -0
  232. package/prebuilds/win32-arm64/pty.pdb +0 -0
  233. package/prebuilds/win32-arm64/winpty-agent.exe +0 -0
  234. package/prebuilds/win32-arm64/winpty-agent.pdb +0 -0
  235. package/prebuilds/win32-arm64/winpty.dll +0 -0
  236. package/prebuilds/win32-arm64/winpty.pdb +0 -0
  237. package/prebuilds/win32-x64/conpty/OpenConsole.exe +0 -0
  238. package/prebuilds/win32-x64/conpty/conpty.dll +0 -0
  239. package/prebuilds/win32-x64/conpty.node +0 -0
  240. package/prebuilds/win32-x64/conpty.pdb +0 -0
  241. package/prebuilds/win32-x64/conpty_console_list.node +0 -0
  242. package/prebuilds/win32-x64/conpty_console_list.pdb +0 -0
  243. package/prebuilds/win32-x64/pty.node +0 -0
  244. package/prebuilds/win32-x64/pty.pdb +0 -0
  245. package/prebuilds/win32-x64/winpty-agent.exe +0 -0
  246. package/prebuilds/win32-x64/winpty-agent.pdb +0 -0
  247. package/prebuilds/win32-x64/winpty.dll +0 -0
  248. package/prebuilds/win32-x64/winpty.pdb +0 -0
  249. package/scripts/gen-compile-commands.js +8 -0
  250. package/scripts/increment-version.js +54 -0
  251. package/scripts/post-install.js +99 -0
  252. package/scripts/prebuild.js +39 -0
  253. package/scripts/sync-prebuild.js +31 -0
  254. package/scripts/verify-darwin-fd-leak.js +63 -0
  255. package/src/conpty_console_list_agent.ts +15 -0
  256. package/src/eventEmitter2.test.ts +30 -0
  257. package/src/eventEmitter2.ts +48 -0
  258. package/src/index.ts +52 -0
  259. package/src/interfaces.ts +130 -0
  260. package/src/native.d.ts +54 -0
  261. package/src/shared/conout.ts +15 -0
  262. package/src/terminal.test.ts +119 -0
  263. package/src/terminal.ts +211 -0
  264. package/src/testUtils.test.ts +23 -0
  265. package/src/tsconfig.json +22 -0
  266. package/src/types.ts +15 -0
  267. package/src/unix/pty.cc +808 -0
  268. package/src/unix/spawn-helper.cc +23 -0
  269. package/src/unixTerminal.test.ts +367 -0
  270. package/src/unixTerminal.ts +388 -0
  271. package/src/utils.ts +29 -0
  272. package/src/win/conpty.cc +583 -0
  273. package/src/win/conpty.h +41 -0
  274. package/src/win/conpty_console_list.cc +44 -0
  275. package/src/win/path_util.cc +95 -0
  276. package/src/win/path_util.h +26 -0
  277. package/src/win/winpty.cc +333 -0
  278. package/src/windowsConoutConnection.ts +82 -0
  279. package/src/windowsPtyAgent.test.ts +94 -0
  280. package/src/windowsPtyAgent.ts +321 -0
  281. package/src/windowsTerminal.test.ts +229 -0
  282. package/src/windowsTerminal.ts +203 -0
  283. package/src/worker/conoutSocketWorker.ts +22 -0
  284. package/third_party/conpty/1.23.251008001/win10-arm64/OpenConsole.exe +0 -0
  285. package/third_party/conpty/1.23.251008001/win10-arm64/conpty.dll +0 -0
  286. package/third_party/conpty/1.23.251008001/win10-x64/OpenConsole.exe +0 -0
  287. package/third_party/conpty/1.23.251008001/win10-x64/conpty.dll +0 -0
  288. package/typings/node-pty.d.ts +211 -0
@@ -0,0 +1,242 @@
1
+ /*
2
+ * Copyright (c) 2011-2016 Ryan Prichard
3
+ *
4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ * of this software and associated documentation files (the "Software"), to
6
+ * deal in the Software without restriction, including without limitation the
7
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
8
+ * sell copies of the Software, and to permit persons to whom the Software is
9
+ * furnished to do so, subject to the following conditions:
10
+ *
11
+ * The above copyright notice and this permission notice shall be included in
12
+ * all copies or substantial portions of the Software.
13
+ *
14
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
20
+ * IN THE SOFTWARE.
21
+ */
22
+
23
+ #ifndef WINPTY_H
24
+ #define WINPTY_H
25
+
26
+ #include <windows.h>
27
+
28
+ #include "winpty_constants.h"
29
+
30
+ /* On 32-bit Windows, winpty functions have the default __cdecl (not __stdcall)
31
+ * calling convention. (64-bit Windows has only a single calling convention.)
32
+ * When compiled with __declspec(dllexport), with either MinGW or MSVC, the
33
+ * winpty functions are unadorned--no underscore prefix or '@nn' suffix--so
34
+ * GetProcAddress can be used easily. */
35
+ #ifdef COMPILING_WINPTY_DLL
36
+ #define WINPTY_API __declspec(dllexport)
37
+ #else
38
+ #define WINPTY_API __declspec(dllimport)
39
+ #endif
40
+
41
+ #ifdef __cplusplus
42
+ extern "C" {
43
+ #endif
44
+
45
+ /* The winpty API uses wide characters, instead of UTF-8, to avoid conversion
46
+ * complications related to surrogates. Windows generally tolerates unpaired
47
+ * surrogates in text, which makes conversion to and from UTF-8 ambiguous and
48
+ * complicated. (There are different UTF-8 variants that deal with UTF-16
49
+ * surrogates differently.) */
50
+
51
+
52
+
53
+ /*****************************************************************************
54
+ * Error handling. */
55
+
56
+ /* All the APIs have an optional winpty_error_t output parameter. If a
57
+ * non-NULL argument is specified, then either the API writes NULL to the
58
+ * value (on success) or writes a newly allocated winpty_error_t object. The
59
+ * object must be freed using winpty_error_free. */
60
+
61
+ /* An error object. */
62
+ typedef struct winpty_error_s winpty_error_t;
63
+ typedef winpty_error_t *winpty_error_ptr_t;
64
+
65
+ /* An error code -- one of WINPTY_ERROR_xxx. */
66
+ typedef DWORD winpty_result_t;
67
+
68
+ /* Gets the error code from the error object. */
69
+ WINPTY_API winpty_result_t winpty_error_code(winpty_error_ptr_t err);
70
+
71
+ /* Returns a textual representation of the error. The string is freed when
72
+ * the error is freed. */
73
+ WINPTY_API LPCWSTR winpty_error_msg(winpty_error_ptr_t err);
74
+
75
+ /* Free the error object. Every error returned from the winpty API must be
76
+ * freed. */
77
+ WINPTY_API void winpty_error_free(winpty_error_ptr_t err);
78
+
79
+
80
+
81
+ /*****************************************************************************
82
+ * Configuration of a new agent. */
83
+
84
+ /* The winpty_config_t object is not thread-safe. */
85
+ typedef struct winpty_config_s winpty_config_t;
86
+
87
+ /* Allocate a winpty_config_t value. Returns NULL on error. There are no
88
+ * required settings -- the object may immediately be used. agentFlags is a
89
+ * set of zero or more WINPTY_FLAG_xxx values. An unrecognized flag results
90
+ * in an assertion failure. */
91
+ WINPTY_API winpty_config_t *
92
+ winpty_config_new(UINT64 agentFlags, winpty_error_ptr_t *err /*OPTIONAL*/);
93
+
94
+ /* Free the cfg object after passing it to winpty_open. */
95
+ WINPTY_API void winpty_config_free(winpty_config_t *cfg);
96
+
97
+ WINPTY_API void
98
+ winpty_config_set_initial_size(winpty_config_t *cfg, int cols, int rows);
99
+
100
+ /* Set the mouse mode to one of the WINPTY_MOUSE_MODE_xxx constants. */
101
+ WINPTY_API void
102
+ winpty_config_set_mouse_mode(winpty_config_t *cfg, int mouseMode);
103
+
104
+ /* Amount of time to wait for the agent to startup and to wait for any given
105
+ * agent RPC request. Must be greater than 0. Can be INFINITE. */
106
+ WINPTY_API void
107
+ winpty_config_set_agent_timeout(winpty_config_t *cfg, DWORD timeoutMs);
108
+
109
+
110
+
111
+ /*****************************************************************************
112
+ * Start the agent. */
113
+
114
+ /* The winpty_t object is thread-safe. */
115
+ typedef struct winpty_s winpty_t;
116
+
117
+ /* Starts the agent. Returns NULL on error. This process will connect to the
118
+ * agent over a control pipe, and the agent will open data pipes (e.g. CONIN
119
+ * and CONOUT). */
120
+ WINPTY_API winpty_t *
121
+ winpty_open(const winpty_config_t *cfg,
122
+ winpty_error_ptr_t *err /*OPTIONAL*/);
123
+
124
+ /* A handle to the agent process. This value is valid for the lifetime of the
125
+ * winpty_t object. Do not close it. */
126
+ WINPTY_API HANDLE winpty_agent_process(winpty_t *wp);
127
+
128
+
129
+
130
+ /*****************************************************************************
131
+ * I/O pipes. */
132
+
133
+ /* Returns the names of named pipes used for terminal I/O. Each input or
134
+ * output direction uses a different half-duplex pipe. The agent creates
135
+ * these pipes, and the client can connect to them using ordinary I/O methods.
136
+ * The strings are freed when the winpty_t object is freed.
137
+ *
138
+ * winpty_conerr_name returns NULL unless WINPTY_FLAG_CONERR is specified.
139
+ *
140
+ * N.B.: CreateFile does not block when connecting to a local server pipe. If
141
+ * the server pipe does not exist or is already connected, then it fails
142
+ * instantly. */
143
+ WINPTY_API LPCWSTR winpty_conin_name(winpty_t *wp);
144
+ WINPTY_API LPCWSTR winpty_conout_name(winpty_t *wp);
145
+ WINPTY_API LPCWSTR winpty_conerr_name(winpty_t *wp);
146
+
147
+
148
+
149
+ /*****************************************************************************
150
+ * winpty agent RPC call: process creation. */
151
+
152
+ /* The winpty_spawn_config_t object is not thread-safe. */
153
+ typedef struct winpty_spawn_config_s winpty_spawn_config_t;
154
+
155
+ /* winpty_spawn_config strings do not need to live as long as the config
156
+ * object. They are copied. Returns NULL on error. spawnFlags is a set of
157
+ * zero or more WINPTY_SPAWN_FLAG_xxx values. An unrecognized flag results in
158
+ * an assertion failure.
159
+ *
160
+ * env is a a pointer to an environment block like that passed to
161
+ * CreateProcess--a contiguous array of NUL-terminated "VAR=VAL" strings
162
+ * followed by a final NUL terminator.
163
+ *
164
+ * N.B.: If you want to gather all of the child's output, you may want the
165
+ * WINPTY_SPAWN_FLAG_AUTO_SHUTDOWN flag.
166
+ */
167
+ WINPTY_API winpty_spawn_config_t *
168
+ winpty_spawn_config_new(UINT64 spawnFlags,
169
+ LPCWSTR appname /*OPTIONAL*/,
170
+ LPCWSTR cmdline /*OPTIONAL*/,
171
+ LPCWSTR cwd /*OPTIONAL*/,
172
+ LPCWSTR env /*OPTIONAL*/,
173
+ winpty_error_ptr_t *err /*OPTIONAL*/);
174
+
175
+ /* Free the cfg object after passing it to winpty_spawn. */
176
+ WINPTY_API void winpty_spawn_config_free(winpty_spawn_config_t *cfg);
177
+
178
+ /*
179
+ * Spawns the new process.
180
+ *
181
+ * The function initializes all output parameters to zero or NULL.
182
+ *
183
+ * On success, the function returns TRUE. For each of process_handle and
184
+ * thread_handle that is non-NULL, the HANDLE returned from CreateProcess is
185
+ * duplicated from the agent and returned to the winpty client. The client is
186
+ * responsible for closing these HANDLES.
187
+ *
188
+ * On failure, the function returns FALSE, and if err is non-NULL, then *err
189
+ * is set to an error object.
190
+ *
191
+ * If the agent's CreateProcess call failed, then *create_process_error is set
192
+ * to GetLastError(), and the WINPTY_ERROR_SPAWN_CREATE_PROCESS_FAILED error
193
+ * is returned.
194
+ *
195
+ * winpty_spawn can only be called once per winpty_t object. If it is called
196
+ * before the output data pipe(s) is/are connected, then collected output is
197
+ * buffered until the pipes are connected, rather than being discarded.
198
+ *
199
+ * N.B.: GetProcessId works even if the process has exited. The PID is not
200
+ * recycled until the NT process object is freed.
201
+ * (https://blogs.msdn.microsoft.com/oldnewthing/20110107-00/?p=11803)
202
+ */
203
+ WINPTY_API BOOL
204
+ winpty_spawn(winpty_t *wp,
205
+ const winpty_spawn_config_t *cfg,
206
+ HANDLE *process_handle /*OPTIONAL*/,
207
+ HANDLE *thread_handle /*OPTIONAL*/,
208
+ DWORD *create_process_error /*OPTIONAL*/,
209
+ winpty_error_ptr_t *err /*OPTIONAL*/);
210
+
211
+
212
+
213
+ /*****************************************************************************
214
+ * winpty agent RPC calls: everything else */
215
+
216
+ /* Change the size of the Windows console window. */
217
+ WINPTY_API BOOL
218
+ winpty_set_size(winpty_t *wp, int cols, int rows,
219
+ winpty_error_ptr_t *err /*OPTIONAL*/);
220
+
221
+ /* Gets a list of processes attached to the console. */
222
+ WINPTY_API int
223
+ winpty_get_console_process_list(winpty_t *wp, int *processList, const int processCount,
224
+ winpty_error_ptr_t *err /*OPTIONAL*/);
225
+
226
+ /* Frees the winpty_t object and the OS resources contained in it. This
227
+ * call breaks the connection with the agent, which should then close its
228
+ * console, terminating the processes attached to it.
229
+ *
230
+ * This function must not be called if any other threads are using the
231
+ * winpty_t object. Undefined behavior results. */
232
+ WINPTY_API void winpty_free(winpty_t *wp);
233
+
234
+
235
+
236
+ /****************************************************************************/
237
+
238
+ #ifdef __cplusplus
239
+ }
240
+ #endif
241
+
242
+ #endif /* WINPTY_H */
@@ -0,0 +1,131 @@
1
+ /*
2
+ * Copyright (c) 2016 Ryan Prichard
3
+ *
4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ * of this software and associated documentation files (the "Software"), to
6
+ * deal in the Software without restriction, including without limitation the
7
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
8
+ * sell copies of the Software, and to permit persons to whom the Software is
9
+ * furnished to do so, subject to the following conditions:
10
+ *
11
+ * The above copyright notice and this permission notice shall be included in
12
+ * all copies or substantial portions of the Software.
13
+ *
14
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
20
+ * IN THE SOFTWARE.
21
+ */
22
+
23
+ #ifndef WINPTY_CONSTANTS_H
24
+ #define WINPTY_CONSTANTS_H
25
+
26
+ /*
27
+ * You may want to include winpty.h instead, which includes this header.
28
+ *
29
+ * This file is split out from winpty.h so that the agent can access the
30
+ * winpty flags without also declaring the libwinpty APIs.
31
+ */
32
+
33
+ /*****************************************************************************
34
+ * Error codes. */
35
+
36
+ #define WINPTY_ERROR_SUCCESS 0
37
+ #define WINPTY_ERROR_OUT_OF_MEMORY 1
38
+ #define WINPTY_ERROR_SPAWN_CREATE_PROCESS_FAILED 2
39
+ #define WINPTY_ERROR_LOST_CONNECTION 3
40
+ #define WINPTY_ERROR_AGENT_EXE_MISSING 4
41
+ #define WINPTY_ERROR_UNSPECIFIED 5
42
+ #define WINPTY_ERROR_AGENT_DIED 6
43
+ #define WINPTY_ERROR_AGENT_TIMEOUT 7
44
+ #define WINPTY_ERROR_AGENT_CREATION_FAILED 8
45
+
46
+
47
+
48
+ /*****************************************************************************
49
+ * Configuration of a new agent. */
50
+
51
+ /* Create a new screen buffer (connected to the "conerr" terminal pipe) and
52
+ * pass it to child processes as the STDERR handle. This flag also prevents
53
+ * the agent from reopening CONOUT$ when it polls -- regardless of whether the
54
+ * active screen buffer changes, winpty continues to monitor the original
55
+ * primary screen buffer. */
56
+ #define WINPTY_FLAG_CONERR 0x1ull
57
+
58
+ /* Don't output escape sequences. */
59
+ #define WINPTY_FLAG_PLAIN_OUTPUT 0x2ull
60
+
61
+ /* Do output color escape sequences. These escapes are output by default, but
62
+ * are suppressed with WINPTY_FLAG_PLAIN_OUTPUT. Use this flag to reenable
63
+ * them. */
64
+ #define WINPTY_FLAG_COLOR_ESCAPES 0x4ull
65
+
66
+ /* On XP and Vista, winpty needs to put the hidden console on a desktop in a
67
+ * service window station so that its polling does not interfere with other
68
+ * (visible) console windows. To create this desktop, it must change the
69
+ * process' window station (i.e. SetProcessWindowStation) for the duration of
70
+ * the winpty_open call. In theory, this change could interfere with the
71
+ * winpty client (e.g. other threads, spawning children), so winpty by default
72
+ * spawns a special agent process to create the hidden desktop. Spawning
73
+ * processes on Windows is slow, though, so if
74
+ * WINPTY_FLAG_ALLOW_CURPROC_DESKTOP_CREATION is set, winpty changes this
75
+ * process' window station instead.
76
+ * See https://github.com/rprichard/winpty/issues/58. */
77
+ #define WINPTY_FLAG_ALLOW_CURPROC_DESKTOP_CREATION 0x8ull
78
+
79
+ #define WINPTY_FLAG_MASK (0ull \
80
+ | WINPTY_FLAG_CONERR \
81
+ | WINPTY_FLAG_PLAIN_OUTPUT \
82
+ | WINPTY_FLAG_COLOR_ESCAPES \
83
+ | WINPTY_FLAG_ALLOW_CURPROC_DESKTOP_CREATION \
84
+ )
85
+
86
+ /* QuickEdit mode is initially disabled, and the agent does not send mouse
87
+ * mode sequences to the terminal. If it receives mouse input, though, it
88
+ * still writes MOUSE_EVENT_RECORD values into CONIN. */
89
+ #define WINPTY_MOUSE_MODE_NONE 0
90
+
91
+ /* QuickEdit mode is initially enabled. As CONIN enters or leaves mouse
92
+ * input mode (i.e. where ENABLE_MOUSE_INPUT is on and ENABLE_QUICK_EDIT_MODE
93
+ * is off), the agent enables or disables mouse input on the terminal.
94
+ *
95
+ * This is the default mode. */
96
+ #define WINPTY_MOUSE_MODE_AUTO 1
97
+
98
+ /* QuickEdit mode is initially disabled, and the agent enables the terminal's
99
+ * mouse input mode. It does not disable terminal mouse mode (until exit). */
100
+ #define WINPTY_MOUSE_MODE_FORCE 2
101
+
102
+
103
+
104
+ /*****************************************************************************
105
+ * winpty agent RPC call: process creation. */
106
+
107
+ /* If the spawn is marked "auto-shutdown", then the agent shuts down console
108
+ * output once the process exits. The agent stops polling for new console
109
+ * output, and once all pending data has been written to the output pipe, the
110
+ * agent closes the pipe. (At that point, the pipe may still have data in it,
111
+ * which the client may read. Once all the data has been read, further reads
112
+ * return EOF.) */
113
+ #define WINPTY_SPAWN_FLAG_AUTO_SHUTDOWN 1ull
114
+
115
+ /* After the agent shuts down output, and after all output has been written
116
+ * into the pipe(s), exit the agent by closing the console. If there any
117
+ * surviving processes still attached to the console, they are killed.
118
+ *
119
+ * Note: With this flag, an RPC call (e.g. winpty_set_size) issued after the
120
+ * agent exits will fail with an I/O or dead-agent error. */
121
+ #define WINPTY_SPAWN_FLAG_EXIT_AFTER_SHUTDOWN 2ull
122
+
123
+ /* All the spawn flags. */
124
+ #define WINPTY_SPAWN_FLAG_MASK (0ull \
125
+ | WINPTY_SPAWN_FLAG_AUTO_SHUTDOWN \
126
+ | WINPTY_SPAWN_FLAG_EXIT_AFTER_SHUTDOWN \
127
+ )
128
+
129
+
130
+
131
+ #endif /* WINPTY_CONSTANTS_H */
@@ -0,0 +1,75 @@
1
+ // Copyright (c) 2011-2016 Ryan Prichard
2
+ //
3
+ // Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ // of this software and associated documentation files (the "Software"), to
5
+ // deal in the Software without restriction, including without limitation the
6
+ // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
7
+ // sell copies of the Software, and to permit persons to whom the Software is
8
+ // furnished to do so, subject to the following conditions:
9
+ //
10
+ // The above copyright notice and this permission notice shall be included in
11
+ // all copies or substantial portions of the Software.
12
+ //
13
+ // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
18
+ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
19
+ // IN THE SOFTWARE.
20
+
21
+ #include "AgentLocation.h"
22
+
23
+ #include <windows.h>
24
+
25
+ #include <string>
26
+
27
+ #include "../shared/WinptyAssert.h"
28
+
29
+ #include "LibWinptyException.h"
30
+
31
+ #define AGENT_EXE L"winpty-agent.exe"
32
+
33
+ static HMODULE getCurrentModule() {
34
+ HMODULE module;
35
+ if (!GetModuleHandleExW(
36
+ GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS |
37
+ GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT,
38
+ reinterpret_cast<LPCWSTR>(getCurrentModule),
39
+ &module)) {
40
+ ASSERT(false && "GetModuleHandleEx failed");
41
+ }
42
+ return module;
43
+ }
44
+
45
+ static std::wstring getModuleFileName(HMODULE module) {
46
+ const int bufsize = 4096;
47
+ wchar_t path[bufsize];
48
+ int size = GetModuleFileNameW(module, path, bufsize);
49
+ ASSERT(size != 0 && size != bufsize);
50
+ return std::wstring(path);
51
+ }
52
+
53
+ static std::wstring dirname(const std::wstring &path) {
54
+ std::wstring::size_type pos = path.find_last_of(L"\\/");
55
+ if (pos == std::wstring::npos) {
56
+ return L"";
57
+ } else {
58
+ return path.substr(0, pos);
59
+ }
60
+ }
61
+
62
+ static bool pathExists(const std::wstring &path) {
63
+ return GetFileAttributesW(path.c_str()) != 0xFFFFFFFF;
64
+ }
65
+
66
+ std::wstring findAgentProgram() {
67
+ std::wstring progDir = dirname(getModuleFileName(getCurrentModule()));
68
+ std::wstring ret = progDir + (L"\\" AGENT_EXE);
69
+ if (!pathExists(ret)) {
70
+ throw LibWinptyException(
71
+ WINPTY_ERROR_AGENT_EXE_MISSING,
72
+ (L"agent executable does not exist: '" + ret + L"'").c_str());
73
+ }
74
+ return ret;
75
+ }
@@ -0,0 +1,28 @@
1
+ // Copyright (c) 2011-2016 Ryan Prichard
2
+ //
3
+ // Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ // of this software and associated documentation files (the "Software"), to
5
+ // deal in the Software without restriction, including without limitation the
6
+ // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
7
+ // sell copies of the Software, and to permit persons to whom the Software is
8
+ // furnished to do so, subject to the following conditions:
9
+ //
10
+ // The above copyright notice and this permission notice shall be included in
11
+ // all copies or substantial portions of the Software.
12
+ //
13
+ // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
18
+ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
19
+ // IN THE SOFTWARE.
20
+
21
+ #ifndef LIBWINPTY_AGENT_LOCATION_H
22
+ #define LIBWINPTY_AGENT_LOCATION_H
23
+
24
+ #include <string>
25
+
26
+ std::wstring findAgentProgram();
27
+
28
+ #endif // LIBWINPTY_AGENT_LOCATION_H
@@ -0,0 +1,54 @@
1
+ // Copyright (c) 2016 Ryan Prichard
2
+ //
3
+ // Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ // of this software and associated documentation files (the "Software"), to
5
+ // deal in the Software without restriction, including without limitation the
6
+ // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
7
+ // sell copies of the Software, and to permit persons to whom the Software is
8
+ // furnished to do so, subject to the following conditions:
9
+ //
10
+ // The above copyright notice and this permission notice shall be included in
11
+ // all copies or substantial portions of the Software.
12
+ //
13
+ // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
18
+ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
19
+ // IN THE SOFTWARE.
20
+
21
+ #ifndef LIB_WINPTY_EXCEPTION_H
22
+ #define LIB_WINPTY_EXCEPTION_H
23
+
24
+ #include "../include/winpty.h"
25
+
26
+ #include "../shared/WinptyException.h"
27
+
28
+ #include <memory>
29
+ #include <string>
30
+
31
+ class LibWinptyException : public WinptyException {
32
+ public:
33
+ LibWinptyException(winpty_result_t code, const wchar_t *what) :
34
+ m_code(code), m_what(std::make_shared<std::wstring>(what)) {}
35
+
36
+ winpty_result_t code() const WINPTY_NOEXCEPT {
37
+ return m_code;
38
+ }
39
+
40
+ const wchar_t *what() const WINPTY_NOEXCEPT override {
41
+ return m_what->c_str();
42
+ }
43
+
44
+ std::shared_ptr<std::wstring> whatSharedStr() const WINPTY_NOEXCEPT {
45
+ return m_what;
46
+ }
47
+
48
+ private:
49
+ winpty_result_t m_code;
50
+ // Using a shared_ptr ensures that copying the object raises no exception.
51
+ std::shared_ptr<std::wstring> m_what;
52
+ };
53
+
54
+ #endif // LIB_WINPTY_EXCEPTION_H
@@ -0,0 +1,72 @@
1
+ // Copyright (c) 2016 Ryan Prichard
2
+ //
3
+ // Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ // of this software and associated documentation files (the "Software"), to
5
+ // deal in the Software without restriction, including without limitation the
6
+ // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
7
+ // sell copies of the Software, and to permit persons to whom the Software is
8
+ // furnished to do so, subject to the following conditions:
9
+ //
10
+ // The above copyright notice and this permission notice shall be included in
11
+ // all copies or substantial portions of the Software.
12
+ //
13
+ // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
18
+ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
19
+ // IN THE SOFTWARE.
20
+
21
+ #ifndef LIBWINPTY_WINPTY_INTERNAL_H
22
+ #define LIBWINPTY_WINPTY_INTERNAL_H
23
+
24
+ #include <memory>
25
+ #include <string>
26
+
27
+ #include "../include/winpty.h"
28
+
29
+ #include "../shared/Mutex.h"
30
+ #include "../shared/OwnedHandle.h"
31
+
32
+ // The structures in this header are not intended to be accessed directly by
33
+ // client programs.
34
+
35
+ struct winpty_error_s {
36
+ winpty_result_t code;
37
+ const wchar_t *msgStatic;
38
+ // Use a pointer to a std::shared_ptr so that the struct remains simple
39
+ // enough to statically initialize, for the benefit of static error
40
+ // objects like kOutOfMemory.
41
+ std::shared_ptr<std::wstring> *msgDynamic;
42
+ };
43
+
44
+ struct winpty_config_s {
45
+ uint64_t flags = 0;
46
+ int cols = 80;
47
+ int rows = 25;
48
+ int mouseMode = WINPTY_MOUSE_MODE_AUTO;
49
+ DWORD timeoutMs = 30000;
50
+ };
51
+
52
+ struct winpty_s {
53
+ Mutex mutex;
54
+ OwnedHandle agentProcess;
55
+ OwnedHandle controlPipe;
56
+ DWORD agentTimeoutMs = 0;
57
+ OwnedHandle ioEvent;
58
+ std::wstring spawnDesktopName;
59
+ std::wstring coninPipeName;
60
+ std::wstring conoutPipeName;
61
+ std::wstring conerrPipeName;
62
+ };
63
+
64
+ struct winpty_spawn_config_s {
65
+ uint64_t winptyFlags = 0;
66
+ std::wstring appname;
67
+ std::wstring cmdline;
68
+ std::wstring cwd;
69
+ std::wstring env;
70
+ };
71
+
72
+ #endif // LIBWINPTY_WINPTY_INTERNAL_H
@@ -0,0 +1,46 @@
1
+ # Copyright (c) 2011-2015 Ryan Prichard
2
+ #
3
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ # of this software and associated documentation files (the "Software"), to
5
+ # deal in the Software without restriction, including without limitation the
6
+ # rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
7
+ # sell copies of the Software, and to permit persons to whom the Software is
8
+ # furnished to do so, subject to the following conditions:
9
+ #
10
+ # The above copyright notice and this permission notice shall be included in
11
+ # all copies or substantial portions of the Software.
12
+ #
13
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
18
+ # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
19
+ # IN THE SOFTWARE.
20
+
21
+ ALL_TARGETS += build/winpty.dll
22
+
23
+ $(eval $(call def_mingw_target,libwinpty,-DCOMPILING_WINPTY_DLL))
24
+
25
+ LIBWINPTY_OBJECTS = \
26
+ build/libwinpty/libwinpty/AgentLocation.o \
27
+ build/libwinpty/libwinpty/winpty.o \
28
+ build/libwinpty/shared/BackgroundDesktop.o \
29
+ build/libwinpty/shared/Buffer.o \
30
+ build/libwinpty/shared/DebugClient.o \
31
+ build/libwinpty/shared/GenRandom.o \
32
+ build/libwinpty/shared/OwnedHandle.o \
33
+ build/libwinpty/shared/StringUtil.o \
34
+ build/libwinpty/shared/WindowsSecurity.o \
35
+ build/libwinpty/shared/WindowsVersion.o \
36
+ build/libwinpty/shared/WinptyAssert.o \
37
+ build/libwinpty/shared/WinptyException.o \
38
+ build/libwinpty/shared/WinptyVersion.o
39
+
40
+ build/libwinpty/shared/WinptyVersion.o : build/gen/GenVersion.h
41
+
42
+ build/winpty.dll : $(LIBWINPTY_OBJECTS)
43
+ $(info Linking $@)
44
+ @$(MINGW_CXX) $(MINGW_LDFLAGS) -shared -o $@ $^ -Wl,--out-implib,build/winpty.lib
45
+
46
+ -include $(LIBWINPTY_OBJECTS:.o=.d)