OLD | NEW |
1 #include <Windows.h> | 1 #include <Windows.h> |
2 #include <Lmcons.h> | 2 #include <Lmcons.h> |
3 #include <Sddl.h> | 3 #include <Sddl.h> |
4 | 4 |
5 #include "Communication.h" | 5 #include "Communication.h" |
6 #include "Utils.h" | 6 #include "Utils.h" |
7 | 7 |
8 namespace | 8 namespace |
9 { | 9 { |
10 const int bufferSize = 1024; | 10 const int bufferSize = 1024; |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 if (IsWindowsVistaOrLater() && securitydescriptor) | 79 if (IsWindowsVistaOrLater() && securitydescriptor) |
80 { | 80 { |
81 LocalFree(securitydescriptor); | 81 LocalFree(securitydescriptor); |
82 } | 82 } |
83 } | 83 } |
84 else | 84 else |
85 { | 85 { |
86 pipe = CreateFileW(pipeName.c_str(), GENERIC_READ | GENERIC_WRITE, 0, 0, OPE
N_EXISTING, 0, 0); | 86 pipe = CreateFileW(pipeName.c_str(), GENERIC_READ | GENERIC_WRITE, 0, 0, OPE
N_EXISTING, 0, 0); |
87 if (pipe == INVALID_HANDLE_VALUE && GetLastError() == ERROR_PIPE_BUSY) | 87 if (pipe == INVALID_HANDLE_VALUE && GetLastError() == ERROR_PIPE_BUSY) |
88 { | 88 { |
89 if (!WaitNamedPipeW(pipeName.c_str(), 5000)) | 89 if (!WaitNamedPipeW(pipeName.c_str(), 10000)) |
90 throw PipeBusyError(); | 90 throw PipeBusyError(); |
91 | 91 |
92 pipe = CreateFileW(pipeName.c_str(), GENERIC_READ | GENERIC_WRITE, 0, 0, O
PEN_EXISTING, 0, 0); | 92 pipe = CreateFileW(pipeName.c_str(), GENERIC_READ | GENERIC_WRITE, 0, 0, O
PEN_EXISTING, 0, 0); |
93 } | 93 } |
94 } | 94 } |
95 | 95 |
96 if (pipe == INVALID_HANDLE_VALUE) | 96 if (pipe == INVALID_HANDLE_VALUE) |
97 throw PipeConnectionError(); | 97 throw PipeConnectionError(); |
98 | 98 |
99 DWORD pipeMode = PIPE_READMODE_MESSAGE | PIPE_WAIT; | 99 DWORD pipeMode = PIPE_READMODE_MESSAGE | PIPE_WAIT; |
(...skipping 30 matching lines...) Expand all Loading... |
130 return Communication::InputBuffer(stream.str()); | 130 return Communication::InputBuffer(stream.str()); |
131 } | 131 } |
132 | 132 |
133 void Communication::Pipe::WriteMessage(Communication::OutputBuffer& message) | 133 void Communication::Pipe::WriteMessage(Communication::OutputBuffer& message) |
134 { | 134 { |
135 DWORD bytesWritten; | 135 DWORD bytesWritten; |
136 std::string data = message.Get(); | 136 std::string data = message.Get(); |
137 if (!WriteFile(pipe, data.c_str(), data.length(), &bytesWritten, 0)) | 137 if (!WriteFile(pipe, data.c_str(), data.length(), &bytesWritten, 0)) |
138 throw std::runtime_error("Failed to write to pipe"); | 138 throw std::runtime_error("Failed to write to pipe"); |
139 } | 139 } |
OLD | NEW |