OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include <windows.h> | 5 #include <windows.h> |
6 #include <stdlib.h> | 6 #include <stdlib.h> |
7 | 7 |
8 #include "base/at_exit.h" | 8 #include "base/at_exit.h" |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/win/scoped_handle.h" | 10 #include "base/win/scoped_handle.h" |
(...skipping 16 matching lines...) Expand all Loading... |
27 const int kUsageExitCode = 1; | 27 const int kUsageExitCode = 1; |
28 const int kErrorExitCode = 2; | 28 const int kErrorExitCode = 2; |
29 | 29 |
30 void usage(const char* program_name) { | 30 void usage(const char* program_name) { |
31 fprintf(stderr, kUsageMessage, program_name); | 31 fprintf(stderr, kUsageMessage, program_name); |
32 } | 32 } |
33 | 33 |
34 } // namespace | 34 } // namespace |
35 | 35 |
36 int main(int argc, char** argv) { | 36 int main(int argc, char** argv) { |
37 CommandLine::Init(argc, argv); | 37 base::CommandLine::Init(argc, argv); |
38 | 38 |
39 base::AtExitManager exit_manager; | 39 base::AtExitManager exit_manager; |
40 | 40 |
41 remoting::InitHostLogging(); | 41 remoting::InitHostLogging(); |
42 | 42 |
43 const CommandLine* command_line = CommandLine::ForCurrentProcess(); | 43 const base::CommandLine* command_line = |
| 44 base::CommandLine::ForCurrentProcess(); |
44 if (command_line->HasSwitch(kHelpSwitchName) || | 45 if (command_line->HasSwitch(kHelpSwitchName) || |
45 command_line->HasSwitch(kQuestionSwitchName)) { | 46 command_line->HasSwitch(kQuestionSwitchName)) { |
46 usage(argv[0]); | 47 usage(argv[0]); |
47 return kSuccessExitCode; | 48 return kSuccessExitCode; |
48 } | 49 } |
49 | 50 |
50 CommandLine::StringVector args = command_line->GetArgs(); | 51 base::CommandLine::StringVector args = command_line->GetArgs(); |
51 if (args.size() != 1) { | 52 if (args.size() != 1) { |
52 usage(argv[0]); | 53 usage(argv[0]); |
53 return kUsageExitCode; | 54 return kUsageExitCode; |
54 } | 55 } |
55 | 56 |
56 int pid = _wtoi(args[0].c_str()); | 57 int pid = _wtoi(args[0].c_str()); |
57 if (pid == 0) { | 58 if (pid == 0) { |
58 LOG(ERROR) << "Invalid process PID: " << args[0]; | 59 LOG(ERROR) << "Invalid process PID: " << args[0]; |
59 return kErrorExitCode; | 60 return kErrorExitCode; |
60 } | 61 } |
(...skipping 11 matching lines...) Expand all Loading... |
72 base::win::ScopedHandle thread; | 73 base::win::ScopedHandle thread; |
73 thread.Set(CreateRemoteThread(process.Get(), NULL, 0, NULL, NULL, 0, | 74 thread.Set(CreateRemoteThread(process.Get(), NULL, 0, NULL, NULL, 0, |
74 &thread_id)); | 75 &thread_id)); |
75 if (!thread.IsValid()) { | 76 if (!thread.IsValid()) { |
76 PLOG(ERROR) << "Failed to create a remote thread in " << pid; | 77 PLOG(ERROR) << "Failed to create a remote thread in " << pid; |
77 return kErrorExitCode; | 78 return kErrorExitCode; |
78 } | 79 } |
79 | 80 |
80 return kSuccessExitCode; | 81 return kSuccessExitCode; |
81 } | 82 } |
OLD | NEW |