pdk 1.9.0 → 3.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/CHANGELOG.md +744 -711
- data/README.md +23 -21
- data/lib/pdk/answer_file.rb +3 -112
- data/lib/pdk/bolt.rb +20 -0
- data/lib/pdk/cli/build.rb +51 -54
- data/lib/pdk/cli/bundle.rb +33 -29
- data/lib/pdk/cli/console.rb +148 -0
- data/lib/pdk/cli/convert.rb +46 -37
- data/lib/pdk/cli/env.rb +51 -0
- data/lib/pdk/cli/errors.rb +4 -3
- data/lib/pdk/cli/exec/command.rb +285 -0
- data/lib/pdk/cli/exec/interactive_command.rb +109 -0
- data/lib/pdk/cli/exec.rb +32 -201
- data/lib/pdk/cli/exec_group.rb +79 -43
- data/lib/pdk/cli/get/config.rb +26 -0
- data/lib/pdk/cli/get.rb +22 -0
- data/lib/pdk/cli/new/class.rb +20 -22
- data/lib/pdk/cli/new/defined_type.rb +21 -21
- data/lib/pdk/cli/new/fact.rb +27 -0
- data/lib/pdk/cli/new/function.rb +27 -0
- data/lib/pdk/cli/new/module.rb +40 -29
- data/lib/pdk/cli/new/provider.rb +18 -18
- data/lib/pdk/cli/new/task.rb +23 -22
- data/lib/pdk/cli/new/test.rb +52 -0
- data/lib/pdk/cli/new/transport.rb +27 -0
- data/lib/pdk/cli/new.rb +15 -9
- data/lib/pdk/cli/release/prep.rb +39 -0
- data/lib/pdk/cli/release/publish.rb +46 -0
- data/lib/pdk/cli/release.rb +185 -0
- data/lib/pdk/cli/remove/config.rb +83 -0
- data/lib/pdk/cli/remove.rb +22 -0
- data/lib/pdk/cli/set/config.rb +121 -0
- data/lib/pdk/cli/set.rb +22 -0
- data/lib/pdk/cli/test/unit.rb +71 -69
- data/lib/pdk/cli/test.rb +9 -8
- data/lib/pdk/cli/update.rb +38 -21
- data/lib/pdk/cli/util/command_redirector.rb +13 -3
- data/lib/pdk/cli/util/interview.rb +25 -9
- data/lib/pdk/cli/util/option_normalizer.rb +6 -6
- data/lib/pdk/cli/util/option_validator.rb +19 -9
- data/lib/pdk/cli/util/spinner.rb +13 -0
- data/lib/pdk/cli/util/update_manager_printer.rb +82 -0
- data/lib/pdk/cli/util.rb +105 -48
- data/lib/pdk/cli/validate.rb +96 -111
- data/lib/pdk/cli.rb +134 -87
- data/lib/pdk/config/errors.rb +5 -0
- data/lib/pdk/config/ini_file.rb +184 -0
- data/lib/pdk/config/ini_file_setting.rb +35 -0
- data/lib/pdk/config/json.rb +35 -0
- data/lib/pdk/config/json_schema_namespace.rb +137 -0
- data/lib/pdk/config/json_schema_setting.rb +51 -0
- data/lib/pdk/config/json_with_schema.rb +47 -0
- data/lib/pdk/config/namespace.rb +362 -0
- data/lib/pdk/config/setting.rb +134 -0
- data/lib/pdk/config/task_schema.json +116 -0
- data/lib/pdk/config/validator.rb +31 -0
- data/lib/pdk/config/yaml.rb +41 -0
- data/lib/pdk/config/yaml_with_schema.rb +51 -0
- data/lib/pdk/config.rb +304 -0
- data/lib/pdk/context/control_repo.rb +61 -0
- data/lib/pdk/context/module.rb +28 -0
- data/lib/pdk/context/none.rb +22 -0
- data/lib/pdk/context.rb +98 -0
- data/lib/pdk/control_repo.rb +89 -0
- data/lib/pdk/generate/defined_type.rb +27 -33
- data/lib/pdk/generate/fact.rb +26 -0
- data/lib/pdk/generate/function.rb +49 -0
- data/lib/pdk/generate/module.rb +160 -153
- data/lib/pdk/generate/provider.rb +16 -69
- data/lib/pdk/generate/puppet_class.rb +27 -32
- data/lib/pdk/generate/puppet_object.rb +100 -159
- data/lib/pdk/generate/task.rb +34 -51
- data/lib/pdk/generate/transport.rb +34 -0
- data/lib/pdk/generate.rb +21 -8
- data/lib/pdk/logger.rb +24 -6
- data/lib/pdk/module/build.rb +125 -37
- data/lib/pdk/module/convert.rb +146 -65
- data/lib/pdk/module/metadata.rb +72 -71
- data/lib/pdk/module/release.rb +255 -0
- data/lib/pdk/module/update.rb +48 -37
- data/lib/pdk/module/update_manager.rb +75 -39
- data/lib/pdk/module.rb +10 -2
- data/lib/pdk/monkey_patches.rb +268 -0
- data/lib/pdk/report/event.rb +36 -48
- data/lib/pdk/report.rb +35 -22
- data/lib/pdk/template/fetcher/git.rb +84 -0
- data/lib/pdk/template/fetcher/local.rb +29 -0
- data/lib/pdk/template/fetcher.rb +100 -0
- data/lib/pdk/template/renderer/v1/legacy_template_dir.rb +108 -0
- data/lib/pdk/template/renderer/v1/renderer.rb +131 -0
- data/lib/pdk/template/renderer/v1/template_file.rb +100 -0
- data/lib/pdk/template/renderer/v1.rb +25 -0
- data/lib/pdk/template/renderer.rb +97 -0
- data/lib/pdk/template/template_dir.rb +67 -0
- data/lib/pdk/template.rb +52 -0
- data/lib/pdk/tests/unit.rb +101 -51
- data/lib/pdk/util/bundler.rb +44 -42
- data/lib/pdk/util/changelog_generator.rb +138 -0
- data/lib/pdk/util/env.rb +48 -0
- data/lib/pdk/util/filesystem.rb +139 -2
- data/lib/pdk/util/git.rb +108 -8
- data/lib/pdk/util/json_finder.rb +86 -0
- data/lib/pdk/util/puppet_strings.rb +125 -0
- data/lib/pdk/util/puppet_version.rb +71 -87
- data/lib/pdk/util/ruby_version.rb +49 -25
- data/lib/pdk/util/template_uri.rb +283 -0
- data/lib/pdk/util/vendored_file.rb +34 -42
- data/lib/pdk/util/version.rb +11 -10
- data/lib/pdk/util/windows/api_types.rb +74 -44
- data/lib/pdk/util/windows/file.rb +31 -27
- data/lib/pdk/util/windows/process.rb +74 -0
- data/lib/pdk/util/windows/string.rb +19 -12
- data/lib/pdk/util/windows.rb +2 -0
- data/lib/pdk/util.rb +111 -124
- data/lib/pdk/validate/control_repo/control_repo_validator_group.rb +23 -0
- data/lib/pdk/validate/control_repo/environment_conf_validator.rb +98 -0
- data/lib/pdk/validate/external_command_validator.rb +213 -0
- data/lib/pdk/validate/internal_ruby_validator.rb +101 -0
- data/lib/pdk/validate/invokable_validator.rb +238 -0
- data/lib/pdk/validate/metadata/metadata_json_lint_validator.rb +84 -0
- data/lib/pdk/validate/metadata/metadata_syntax_validator.rb +76 -0
- data/lib/pdk/validate/metadata/metadata_validator_group.rb +20 -0
- data/lib/pdk/validate/puppet/puppet_epp_validator.rb +131 -0
- data/lib/pdk/validate/puppet/puppet_lint_validator.rb +66 -0
- data/lib/pdk/validate/puppet/puppet_plan_syntax_validator.rb +38 -0
- data/lib/pdk/validate/puppet/puppet_syntax_validator.rb +135 -0
- data/lib/pdk/validate/puppet/puppet_validator_group.rb +22 -0
- data/lib/pdk/validate/ruby/ruby_rubocop_validator.rb +79 -0
- data/lib/pdk/validate/ruby/ruby_validator_group.rb +19 -0
- data/lib/pdk/validate/tasks/tasks_metadata_lint_validator.rb +83 -0
- data/lib/pdk/validate/tasks/tasks_name_validator.rb +45 -0
- data/lib/pdk/validate/tasks/tasks_validator_group.rb +20 -0
- data/lib/pdk/validate/validator.rb +120 -0
- data/lib/pdk/validate/validator_group.rb +107 -0
- data/lib/pdk/validate/yaml/yaml_syntax_validator.rb +86 -0
- data/lib/pdk/validate/yaml/yaml_validator_group.rb +19 -0
- data/lib/pdk/validate.rb +86 -12
- data/lib/pdk/version.rb +2 -2
- data/lib/pdk.rb +60 -10
- metadata +138 -100
- data/lib/pdk/cli/module/build.rb +0 -14
- data/lib/pdk/cli/module/generate.rb +0 -45
- data/lib/pdk/cli/module.rb +0 -14
- data/lib/pdk/i18n.rb +0 -4
- data/lib/pdk/module/templatedir.rb +0 -321
- data/lib/pdk/template_file.rb +0 -95
- data/lib/pdk/validate/base_validator.rb +0 -215
- data/lib/pdk/validate/metadata/metadata_json_lint.rb +0 -86
- data/lib/pdk/validate/metadata/metadata_syntax.rb +0 -109
- data/lib/pdk/validate/metadata_validator.rb +0 -30
- data/lib/pdk/validate/puppet/puppet_lint.rb +0 -67
- data/lib/pdk/validate/puppet/puppet_syntax.rb +0 -112
- data/lib/pdk/validate/puppet_validator.rb +0 -30
- data/lib/pdk/validate/ruby/rubocop.rb +0 -77
- data/lib/pdk/validate/ruby_validator.rb +0 -29
- data/lib/pdk/validate/tasks/metadata_lint.rb +0 -126
- data/lib/pdk/validate/tasks/name.rb +0 -88
- data/lib/pdk/validate/tasks_validator.rb +0 -33
- data/lib/pdk/validate/yaml/syntax.rb +0 -109
- data/lib/pdk/validate/yaml_validator.rb +0 -31
- data/locales/config.yaml +0 -21
- data/locales/pdk.pot +0 -1291
@@ -1,9 +1,4 @@
|
|
1
|
-
require '
|
2
|
-
require 'diff/lcs/hunk'
|
3
|
-
require 'English'
|
4
|
-
require 'fileutils'
|
5
|
-
require 'set'
|
6
|
-
require 'pdk/util/filesystem'
|
1
|
+
require 'pdk'
|
7
2
|
|
8
3
|
module PDK
|
9
4
|
module Module
|
@@ -11,9 +6,12 @@ module PDK
|
|
11
6
|
# Initialises a blank UpdateManager object, which is used to store and
|
12
7
|
# process file additions/removals/modifications.
|
13
8
|
def initialize
|
9
|
+
require 'set'
|
10
|
+
|
14
11
|
@modified_files = Set.new
|
15
12
|
@added_files = Set.new
|
16
13
|
@removed_files = Set.new
|
14
|
+
@executable_files = Set.new
|
17
15
|
@diff_cache = {}
|
18
16
|
end
|
19
17
|
|
@@ -40,17 +38,27 @@ module PDK
|
|
40
38
|
@removed_files << path
|
41
39
|
end
|
42
40
|
|
41
|
+
# Store a pending file execute mode change.
|
42
|
+
#
|
43
|
+
# @param path [String] The path to the file to be made executable.
|
44
|
+
def make_file_executable(path)
|
45
|
+
@executable_files << path
|
46
|
+
end
|
47
|
+
|
43
48
|
# Generate a summary of the changes that will be applied to the module.
|
44
49
|
#
|
45
50
|
# @raise (see #calculate_diffs)
|
46
51
|
# @return [Hash{Symbol => Set,Hash}] the summary of the pending changes.
|
47
52
|
def changes
|
53
|
+
require 'pdk/util/filesystem'
|
54
|
+
|
48
55
|
calculate_diffs
|
49
56
|
|
50
57
|
{
|
51
|
-
added:
|
52
|
-
removed:
|
53
|
-
modified: @diff_cache.
|
58
|
+
added: @added_files,
|
59
|
+
removed: @removed_files.select { |f| PDK::Util::Filesystem.exist?(f) },
|
60
|
+
modified: @diff_cache.compact,
|
61
|
+
'made executable': @executable_files
|
54
62
|
}
|
55
63
|
end
|
56
64
|
|
@@ -61,7 +69,8 @@ module PDK
|
|
61
69
|
def changes?
|
62
70
|
!changes[:added].empty? ||
|
63
71
|
!changes[:removed].empty? ||
|
64
|
-
changes[:modified].any? { |_, value| !value.nil? }
|
72
|
+
changes[:modified].any? { |_, value| !value.nil? } ||
|
73
|
+
!changes[:'made executable'].empty?
|
65
74
|
end
|
66
75
|
|
67
76
|
# Check if the update manager will change the specified file upon sync.
|
@@ -73,7 +82,16 @@ module PDK
|
|
73
82
|
def changed?(path)
|
74
83
|
changes[:added].any? { |add| add[:path] == path } ||
|
75
84
|
changes[:removed].include?(path) ||
|
76
|
-
changes[:modified].
|
85
|
+
changes[:modified].key?(path) ||
|
86
|
+
changes[:'made executable'].include?(path)
|
87
|
+
end
|
88
|
+
|
89
|
+
def clear!
|
90
|
+
@modified_files.clear
|
91
|
+
@added_files.clear
|
92
|
+
@removed_files.clear
|
93
|
+
@executable_files.clear
|
94
|
+
nil
|
77
95
|
end
|
78
96
|
|
79
97
|
# Apply any pending changes stored in the UpdateManager to the module.
|
@@ -94,6 +112,10 @@ module PDK
|
|
94
112
|
files_to_write.each do |file|
|
95
113
|
write_file(file[:path], file[:content])
|
96
114
|
end
|
115
|
+
|
116
|
+
@executable_files.each do |file|
|
117
|
+
update_execute_bits(file)
|
118
|
+
end
|
97
119
|
end
|
98
120
|
|
99
121
|
# Remove a file from disk.
|
@@ -106,17 +128,16 @@ module PDK
|
|
106
128
|
#
|
107
129
|
# @raise [PDK::CLI::ExitWithError] if the file could not be removed.
|
108
130
|
def unlink_file(path)
|
109
|
-
|
110
|
-
|
111
|
-
|
131
|
+
require 'pdk/util/filesystem'
|
132
|
+
|
133
|
+
if PDK::Util::Filesystem.file?(path)
|
134
|
+
PDK.logger.debug(format("unlinking '%{path}'", path: path))
|
135
|
+
PDK::Util::Filesystem.rm(path)
|
112
136
|
else
|
113
|
-
PDK.logger.debug(
|
137
|
+
PDK.logger.debug(format("'%{path}': already gone", path: path))
|
114
138
|
end
|
115
|
-
rescue => e
|
116
|
-
raise PDK::CLI::ExitWithError,
|
117
|
-
path: path,
|
118
|
-
message: e.message,
|
119
|
-
}
|
139
|
+
rescue StandardError => e
|
140
|
+
raise PDK::CLI::ExitWithError, format("Unable to remove '%{path}': %{message}", path: path, message: e.message)
|
120
141
|
end
|
121
142
|
|
122
143
|
private
|
@@ -127,14 +148,14 @@ module PDK
|
|
127
148
|
# @raise [PDK::CLI::ExitWithError] if a file being modified isn't
|
128
149
|
# readable.
|
129
150
|
def calculate_diffs
|
151
|
+
require 'pdk/util/filesystem'
|
152
|
+
|
130
153
|
@modified_files.each do |file|
|
131
154
|
next if @diff_cache.key?(file[:path])
|
132
155
|
|
133
|
-
unless
|
134
|
-
raise PDK::CLI::ExitWithError, _("Unable to open '%{path}' for reading") % { path: file[:path] }
|
135
|
-
end
|
156
|
+
raise PDK::CLI::ExitWithError, format("Unable to open '%{path}' for reading", path: file[:path]) unless PDK::Util::Filesystem.readable?(file[:path])
|
136
157
|
|
137
|
-
old_content =
|
158
|
+
old_content = PDK::Util::Filesystem.read_file(file[:path])
|
138
159
|
file_diff = unified_diff(file[:path], old_content, file[:content])
|
139
160
|
@diff_cache[file[:path]] = file_diff
|
140
161
|
end
|
@@ -147,11 +168,13 @@ module PDK
|
|
147
168
|
#
|
148
169
|
# @raise [PDK::CLI::ExitWithError] if the file is not writeable.
|
149
170
|
def write_file(path, content)
|
150
|
-
|
151
|
-
|
171
|
+
require 'pdk/util/filesystem'
|
172
|
+
|
173
|
+
PDK::Util::Filesystem.mkdir_p(File.dirname(path))
|
174
|
+
PDK.logger.debug(format("writing '%{path}'", path: path))
|
152
175
|
PDK::Util::Filesystem.write_file(path, content)
|
153
176
|
rescue Errno::EACCES
|
154
|
-
raise PDK::CLI::ExitWithError,
|
177
|
+
raise PDK::CLI::ExitWithError, format("You do not have permission to write to '%{path}'", path: path)
|
155
178
|
end
|
156
179
|
|
157
180
|
# Generate a unified diff of the changes to be made to a file.
|
@@ -167,6 +190,9 @@ module PDK
|
|
167
190
|
#
|
168
191
|
# @return [String] The unified diff of the pending changes to the file.
|
169
192
|
def unified_diff(path, old_content, new_content, lines_of_context = 3)
|
193
|
+
require 'diff/lcs'
|
194
|
+
require 'English'
|
195
|
+
|
170
196
|
output = []
|
171
197
|
|
172
198
|
old_lines = old_content.split($INPUT_RECORD_SEPARATOR).map(&:chomp)
|
@@ -174,9 +200,11 @@ module PDK
|
|
174
200
|
|
175
201
|
diffs = Diff::LCS.diff(old_lines, new_lines)
|
176
202
|
|
177
|
-
return
|
203
|
+
return if diffs.empty?
|
204
|
+
|
205
|
+
require 'diff/lcs/hunk'
|
178
206
|
|
179
|
-
file_mtime =
|
207
|
+
file_mtime = PDK::Util::Filesystem.stat(path).mtime.localtime.strftime('%Y-%m-%d %H:%M:%S.%N %z')
|
180
208
|
now = Time.now.localtime.strftime('%Y-%m-%d %H:%M:%S.%N %z')
|
181
209
|
|
182
210
|
output << "--- #{path}\t#{file_mtime}"
|
@@ -186,25 +214,33 @@ module PDK
|
|
186
214
|
file_length_difference = 0
|
187
215
|
|
188
216
|
diffs.each do |piece|
|
189
|
-
|
190
|
-
|
191
|
-
file_length_difference = hunk.file_length_difference
|
217
|
+
hunk = Diff::LCS::Hunk.new(old_lines, new_lines, piece, lines_of_context, file_length_difference)
|
218
|
+
file_length_difference = hunk.file_length_difference
|
192
219
|
|
193
|
-
|
220
|
+
next unless oldhunk
|
194
221
|
|
195
|
-
|
196
|
-
|
222
|
+
# If the hunk overlaps with the oldhunk, merge them.
|
223
|
+
next if lines_of_context.positive? && hunk.merge(oldhunk)
|
197
224
|
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
end
|
225
|
+
output << oldhunk.diff(:unified)
|
226
|
+
ensure
|
227
|
+
oldhunk = hunk
|
202
228
|
end
|
203
229
|
|
204
230
|
output << oldhunk.diff(:unified)
|
205
231
|
|
206
232
|
output.join($INPUT_RECORD_SEPARATOR)
|
207
233
|
end
|
234
|
+
|
235
|
+
# Set the execute bits on a file
|
236
|
+
def update_execute_bits(path)
|
237
|
+
require 'pdk/util/filesystem'
|
238
|
+
|
239
|
+
PDK.logger.debug(format("making '%{path}' executable", path: path))
|
240
|
+
PDK::Util::Filesystem.make_executable(path)
|
241
|
+
rescue Errno::EACCES
|
242
|
+
raise PDK::CLI::ExitWithError, format("You do not have permission to make '%{path}' executable", path: path)
|
243
|
+
end
|
208
244
|
end
|
209
245
|
end
|
210
246
|
end
|
data/lib/pdk/module.rb
CHANGED
@@ -1,7 +1,12 @@
|
|
1
|
-
require 'pathspec'
|
2
|
-
|
3
1
|
module PDK
|
4
2
|
module Module
|
3
|
+
autoload :Build, 'pdk/module/build'
|
4
|
+
autoload :Convert, 'pdk/module/convert'
|
5
|
+
autoload :Metadata, 'pdk/module/metadata'
|
6
|
+
autoload :Release, 'pdk/module/release'
|
7
|
+
autoload :UpdateManager, 'pdk/module/update_manager'
|
8
|
+
autoload :Update, 'pdk/module/update'
|
9
|
+
|
5
10
|
DEFAULT_IGNORED = [
|
6
11
|
'/pkg/',
|
7
12
|
'~*',
|
@@ -10,9 +15,12 @@ module PDK
|
|
10
15
|
'/REVISION',
|
11
16
|
'/spec/fixtures/modules/',
|
12
17
|
'/vendor/',
|
18
|
+
'.DS_Store'
|
13
19
|
].freeze
|
14
20
|
|
15
21
|
def default_ignored_pathspec(ignore_dotfiles = true)
|
22
|
+
require 'pathspec'
|
23
|
+
|
16
24
|
PathSpec.new(DEFAULT_IGNORED).tap do |ps|
|
17
25
|
ps.add('.*') if ignore_dotfiles
|
18
26
|
end
|
@@ -0,0 +1,268 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module OS
|
4
|
+
# Os detection: Are we on Windows?
|
5
|
+
def self.windows?
|
6
|
+
(/cygwin|mswin|mingw|bccwin|wince|emx/ =~ RUBY_PLATFORM) != nil
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
# Patch childprocess so that it is Ruby 3 compliant.
|
11
|
+
# This could be removed if the following PR is ever merged
|
12
|
+
# and released:
|
13
|
+
# https://github.com/enkessler/childprocess/pull/185
|
14
|
+
module ChildProcess
|
15
|
+
class << self
|
16
|
+
def build(*args)
|
17
|
+
case os
|
18
|
+
when :macosx, :linux, :solaris, :bsd, :cygwin, :aix
|
19
|
+
if posix_spawn?
|
20
|
+
Unix::PosixSpawnProcess.new(*args)
|
21
|
+
elsif jruby?
|
22
|
+
JRuby::Process.new(*args)
|
23
|
+
else
|
24
|
+
Unix::ForkExecProcess.new(*args)
|
25
|
+
end
|
26
|
+
when :windows
|
27
|
+
Windows::Process.new(*args)
|
28
|
+
else
|
29
|
+
raise Error, "unsupported platform #{platform_name.inspect}"
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
class AbstractProcess
|
35
|
+
def initialize(*args)
|
36
|
+
raise ArgumentError, "all arguments must be String: #{args.inspect}" unless args.all?(String)
|
37
|
+
|
38
|
+
@args = args
|
39
|
+
@started = false
|
40
|
+
@exit_code = nil
|
41
|
+
@io = nil
|
42
|
+
@cwd = nil
|
43
|
+
@detach = false
|
44
|
+
@duplex = false
|
45
|
+
@leader = false
|
46
|
+
@environment = {}
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
if OS.windows?
|
51
|
+
module Windows
|
52
|
+
module Lib
|
53
|
+
extend FFI::Library
|
54
|
+
def self.msvcrt_name
|
55
|
+
RbConfig::CONFIG['RUBY_SO_NAME'][/msvc\w+/] || 'ucrtbase'
|
56
|
+
end
|
57
|
+
|
58
|
+
ffi_lib 'kernel32', msvcrt_name
|
59
|
+
ffi_convention :stdcall
|
60
|
+
|
61
|
+
# We have to redefine the function declarations so that they are available
|
62
|
+
# with the patched ffi_lib.
|
63
|
+
enum :wait_status, [
|
64
|
+
:wait_object_0, 0, # rubocop:disable Naming/VariableNumber
|
65
|
+
:wait_timeout, 0x102,
|
66
|
+
:wait_abandoned, 0x80,
|
67
|
+
:wait_failed, 0xFFFFFFFF
|
68
|
+
]
|
69
|
+
|
70
|
+
#
|
71
|
+
# BOOL WINAPI CreateProcess(
|
72
|
+
# __in_opt LPCTSTR lpApplicationName,
|
73
|
+
# __inout_opt LPTSTR lpCommandLine,
|
74
|
+
# __in_opt LPSECURITY_ATTRIBUTES lpProcessAttributes,
|
75
|
+
# __in_opt LPSECURITY_ATTRIBUTES lpThreadAttributes,
|
76
|
+
# __in BOOL bInheritHandles,
|
77
|
+
# __in DWORD dwCreationFlags,
|
78
|
+
# __in_opt LPVOID lpEnvironment,
|
79
|
+
# __in_opt LPCTSTR lpCurrentDirectory,
|
80
|
+
# __in LPSTARTUPINFO lpStartupInfo,
|
81
|
+
# __out LPPROCESS_INFORMATION lpProcessInformation
|
82
|
+
# );
|
83
|
+
#
|
84
|
+
|
85
|
+
attach_function :create_process, :CreateProcessW, [
|
86
|
+
:pointer,
|
87
|
+
:buffer_inout,
|
88
|
+
:pointer,
|
89
|
+
:pointer,
|
90
|
+
:bool,
|
91
|
+
:ulong,
|
92
|
+
:pointer,
|
93
|
+
:pointer,
|
94
|
+
:pointer,
|
95
|
+
:pointer
|
96
|
+
], :bool
|
97
|
+
|
98
|
+
#
|
99
|
+
# DWORD WINAPI FormatMessage(
|
100
|
+
# __in DWORD dwFlags,
|
101
|
+
# __in_opt LPCVOID lpSource,
|
102
|
+
# __in DWORD dwMessageId,
|
103
|
+
# __in DWORD dwLanguageId,
|
104
|
+
# __out LPTSTR lpBuffer,
|
105
|
+
# __in DWORD nSize,
|
106
|
+
# __in_opt va_list *Arguments
|
107
|
+
# );
|
108
|
+
#
|
109
|
+
|
110
|
+
attach_function :format_message, :FormatMessageA, [
|
111
|
+
:ulong,
|
112
|
+
:pointer,
|
113
|
+
:ulong,
|
114
|
+
:ulong,
|
115
|
+
:pointer,
|
116
|
+
:ulong,
|
117
|
+
:pointer
|
118
|
+
], :ulong
|
119
|
+
|
120
|
+
attach_function :close_handle, :CloseHandle, [:pointer], :bool
|
121
|
+
|
122
|
+
#
|
123
|
+
# HANDLE WINAPI OpenProcess(
|
124
|
+
# __in DWORD dwDesiredAccess,
|
125
|
+
# __in BOOL bInheritHandle,
|
126
|
+
# __in DWORD dwProcessId
|
127
|
+
# );
|
128
|
+
#
|
129
|
+
|
130
|
+
attach_function :open_process, :OpenProcess, [:ulong, :bool, :ulong], :pointer
|
131
|
+
|
132
|
+
#
|
133
|
+
# HANDLE WINAPI CreateJobObject(
|
134
|
+
# _In_opt_ LPSECURITY_ATTRIBUTES lpJobAttributes,
|
135
|
+
# _In_opt_ LPCTSTR lpName
|
136
|
+
# );
|
137
|
+
#
|
138
|
+
|
139
|
+
attach_function :create_job_object, :CreateJobObjectA, [:pointer, :pointer], :pointer
|
140
|
+
|
141
|
+
#
|
142
|
+
# BOOL WINAPI AssignProcessToJobObject(
|
143
|
+
# _In_ HANDLE hJob,
|
144
|
+
# _In_ HANDLE hProcess
|
145
|
+
# );
|
146
|
+
|
147
|
+
attach_function :assign_process_to_job_object, :AssignProcessToJobObject, [:pointer, :pointer], :bool
|
148
|
+
|
149
|
+
#
|
150
|
+
# BOOL WINAPI SetInformationJobObject(
|
151
|
+
# _In_ HANDLE hJob,
|
152
|
+
# _In_ JOBOBJECTINFOCLASS JobObjectInfoClass,
|
153
|
+
# _In_ LPVOID lpJobObjectInfo,
|
154
|
+
# _In_ DWORD cbJobObjectInfoLength
|
155
|
+
# );
|
156
|
+
#
|
157
|
+
|
158
|
+
attach_function :set_information_job_object, :SetInformationJobObject, [:pointer, :int, :pointer, :ulong], :bool
|
159
|
+
|
160
|
+
#
|
161
|
+
#
|
162
|
+
# DWORD WINAPI WaitForSingleObject(
|
163
|
+
# __in HANDLE hHandle,
|
164
|
+
# __in DWORD dwMilliseconds
|
165
|
+
# );
|
166
|
+
#
|
167
|
+
|
168
|
+
attach_function :wait_for_single_object, :WaitForSingleObject, [:pointer, :ulong], :wait_status, blocking: true
|
169
|
+
|
170
|
+
#
|
171
|
+
# BOOL WINAPI GetExitCodeProcess(
|
172
|
+
# __in HANDLE hProcess,
|
173
|
+
# __out LPDWORD lpExitCode
|
174
|
+
# );
|
175
|
+
#
|
176
|
+
|
177
|
+
attach_function :get_exit_code, :GetExitCodeProcess, [:pointer, :pointer], :bool
|
178
|
+
|
179
|
+
#
|
180
|
+
# BOOL WINAPI GenerateConsoleCtrlEvent(
|
181
|
+
# __in DWORD dwCtrlEvent,
|
182
|
+
# __in DWORD dwProcessGroupId
|
183
|
+
# );
|
184
|
+
#
|
185
|
+
|
186
|
+
attach_function :generate_console_ctrl_event, :GenerateConsoleCtrlEvent, [:ulong, :ulong], :bool
|
187
|
+
|
188
|
+
#
|
189
|
+
# BOOL WINAPI TerminateProcess(
|
190
|
+
# __in HANDLE hProcess,
|
191
|
+
# __in UINT uExitCode
|
192
|
+
# );
|
193
|
+
#
|
194
|
+
|
195
|
+
attach_function :terminate_process, :TerminateProcess, [:pointer, :uint], :bool
|
196
|
+
|
197
|
+
#
|
198
|
+
# intptr_t _get_osfhandle(
|
199
|
+
# int fd
|
200
|
+
# );
|
201
|
+
#
|
202
|
+
|
203
|
+
attach_function :get_osfhandle, :_get_osfhandle, [:int], :intptr_t
|
204
|
+
|
205
|
+
#
|
206
|
+
# int _open_osfhandle (
|
207
|
+
# intptr_t osfhandle,
|
208
|
+
# int flags
|
209
|
+
# );
|
210
|
+
#
|
211
|
+
|
212
|
+
attach_function :open_osfhandle, :_open_osfhandle, [:pointer, :int], :int
|
213
|
+
|
214
|
+
# BOOL WINAPI SetHandleInformation(
|
215
|
+
# __in HANDLE hObject,
|
216
|
+
# __in DWORD dwMask,
|
217
|
+
# __in DWORD dwFlags
|
218
|
+
# );
|
219
|
+
|
220
|
+
attach_function :set_handle_information, :SetHandleInformation, [:pointer, :ulong, :ulong], :bool
|
221
|
+
|
222
|
+
# BOOL WINAPI GetHandleInformation(
|
223
|
+
# __in HANDLE hObject,
|
224
|
+
# __out LPDWORD lpdwFlags
|
225
|
+
# );
|
226
|
+
|
227
|
+
attach_function :get_handle_information, :GetHandleInformation, [:pointer, :pointer], :bool
|
228
|
+
|
229
|
+
# BOOL WINAPI CreatePipe(
|
230
|
+
# __out PHANDLE hReadPipe,
|
231
|
+
# __out PHANDLE hWritePipe,
|
232
|
+
# __in_opt LPSECURITY_ATTRIBUTES lpPipeAttributes,
|
233
|
+
# __in DWORD nSize
|
234
|
+
# );
|
235
|
+
|
236
|
+
attach_function :create_pipe, :CreatePipe, [:pointer, :pointer, :pointer, :ulong], :bool
|
237
|
+
|
238
|
+
#
|
239
|
+
# HANDLE WINAPI GetCurrentProcess(void);
|
240
|
+
#
|
241
|
+
|
242
|
+
attach_function :current_process, :GetCurrentProcess, [], :pointer
|
243
|
+
|
244
|
+
#
|
245
|
+
# BOOL WINAPI DuplicateHandle(
|
246
|
+
# __in HANDLE hSourceProcessHandle,
|
247
|
+
# __in HANDLE hSourceHandle,
|
248
|
+
# __in HANDLE hTargetProcessHandle,
|
249
|
+
# __out LPHANDLE lpTargetHandle,
|
250
|
+
# __in DWORD dwDesiredAccess,
|
251
|
+
# __in BOOL bInheritHandle,
|
252
|
+
# __in DWORD dwOptions
|
253
|
+
# );
|
254
|
+
#
|
255
|
+
|
256
|
+
attach_function :_duplicate_handle, :DuplicateHandle, [
|
257
|
+
:pointer,
|
258
|
+
:pointer,
|
259
|
+
:pointer,
|
260
|
+
:pointer,
|
261
|
+
:ulong,
|
262
|
+
:bool,
|
263
|
+
:ulong
|
264
|
+
], :bool
|
265
|
+
end
|
266
|
+
end
|
267
|
+
end
|
268
|
+
end
|