proc_info.hpp 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. // Copyright (c) 2022 Klemens D. Morgenstern
  2. // Copyright (c) 2022 Samuel Venable
  3. //
  4. // Distributed under the Boost Software License, Version 1.0. (See accompanying
  5. // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  6. #ifndef BOOST_PROCESS_V2_DETAIL_PROC_INFO_HPP
  7. #define BOOST_PROCESS_V2_DETAIL_PROC_INFO_HPP
  8. #include <boost/process/v2/detail/config.hpp>
  9. #include <boost/process/v2/detail/throw_error.hpp>
  10. #include <boost/process/v2/pid.hpp>
  11. #include <string>
  12. #include <vector>
  13. #if defined(BOOST_PROCESS_V2_WINDOWS)
  14. #include <iterator>
  15. #include <algorithm>
  16. #include <windows.h>
  17. #include <winternl.h>
  18. extern "C" ULONG NTAPI RtlNtStatusToDosError(NTSTATUS Status);
  19. #endif
  20. BOOST_PROCESS_V2_BEGIN_NAMESPACE
  21. namespace detail
  22. {
  23. namespace ext
  24. {
  25. #if defined(BOOST_PROCESS_V2_WINDOWS)
  26. #if !defined(_MSC_VER)
  27. #pragma pack(push, 8)
  28. #else
  29. #include <pshpack8.h>
  30. #endif
  31. /* CURDIR struct from:
  32. https://github.com/processhacker/phnt/
  33. CC BY 4.0 licence */
  34. typedef struct {
  35. UNICODE_STRING DosPath;
  36. HANDLE Handle;
  37. } CURDIR;
  38. /* RTL_DRIVE_LETTER_CURDIR struct from:
  39. https://github.com/processhacker/phnt/
  40. CC BY 4.0 licence */
  41. typedef struct {
  42. USHORT Flags;
  43. USHORT Length;
  44. ULONG TimeStamp;
  45. STRING DosPath;
  46. } RTL_DRIVE_LETTER_CURDIR;
  47. /* RTL_USER_PROCESS_PARAMETERS struct from:
  48. https://github.com/processhacker/phnt/
  49. CC BY 4.0 licence */
  50. typedef struct {
  51. ULONG MaximumLength;
  52. ULONG Length;
  53. ULONG Flags;
  54. ULONG DebugFlags;
  55. HANDLE ConsoleHandle;
  56. ULONG ConsoleFlags;
  57. HANDLE StandardInput;
  58. HANDLE StandardOutput;
  59. HANDLE StandardError;
  60. CURDIR CurrentDirectory;
  61. UNICODE_STRING DllPath;
  62. UNICODE_STRING ImagePathName;
  63. UNICODE_STRING CommandLine;
  64. PVOID Environment;
  65. ULONG StartingX;
  66. ULONG StartingY;
  67. ULONG CountX;
  68. ULONG CountY;
  69. ULONG CountCharsX;
  70. ULONG CountCharsY;
  71. ULONG FillAttribute;
  72. ULONG WindowFlags;
  73. ULONG ShowWindowFlags;
  74. UNICODE_STRING WindowTitle;
  75. UNICODE_STRING DesktopInfo;
  76. UNICODE_STRING ShellInfo;
  77. UNICODE_STRING RuntimeData;
  78. RTL_DRIVE_LETTER_CURDIR CurrentDirectories[32];
  79. ULONG_PTR EnvironmentSize;
  80. ULONG_PTR EnvironmentVersion;
  81. PVOID PackageDependencyData;
  82. ULONG ProcessGroupId;
  83. ULONG LoaderThreads;
  84. UNICODE_STRING RedirectionDllName;
  85. UNICODE_STRING HeapPartitionName;
  86. ULONG_PTR DefaultThreadpoolCpuSetMasks;
  87. ULONG DefaultThreadpoolCpuSetMaskCount;
  88. } RTL_USER_PROCESS_PARAMETERS_EXTENDED;
  89. #if !defined(_MSC_VER)
  90. #pragma pack(pop)
  91. #else
  92. #include <poppack.h>
  93. #endif
  94. BOOST_PROCESS_V2_DECL std::wstring cwd_cmd_from_proc(HANDLE proc, int type, boost::system::error_code & ec);
  95. BOOST_PROCESS_V2_DECL HANDLE open_process_with_debug_privilege(boost::process::v2::pid_type pid, boost::system::error_code & ec);
  96. #endif
  97. } // namespace ext
  98. } // namespace detail
  99. BOOST_PROCESS_V2_END_NAMESPACE
  100. #endif // BOOST_PROCESS_V2_DETAIL_PROC_INFO_HPP