| 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 #include <aclapi.h> | 4 #include <aclapi.h> | 
| 5 #include <strsafe.h> | 5 #include <strsafe.h> | 
| 6 | 6 | 
| 7 #include "AutoHandle.h" | 7 #include "AutoHandle.h" | 
| 8 #include "Communication.h" | 8 #include "Communication.h" | 
| 9 #include "Utils.h" | 9 #include "Utils.h" | 
| 10 | 10 | 
| (...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 204   } | 204   } | 
| 205   free(securityDescriptor); | 205   free(securityDescriptor); | 
| 206 } | 206 } | 
| 207 | 207 | 
| 208 Communication::Pipe::Pipe(const std::wstring& pipeName, Communication::Pipe::Mod
     e mode) | 208 Communication::Pipe::Pipe(const std::wstring& pipeName, Communication::Pipe::Mod
     e mode) | 
| 209 { | 209 { | 
| 210   pipe = INVALID_HANDLE_VALUE; | 210   pipe = INVALID_HANDLE_VALUE; | 
| 211   if (mode == MODE_CREATE) | 211   if (mode == MODE_CREATE) | 
| 212   { | 212   { | 
| 213     SECURITY_ATTRIBUTES securityAttributes = {}; | 213     SECURITY_ATTRIBUTES securityAttributes = {}; | 
| 214     securityAttributes.nLength = sizeof(securityAttributes); | 214     securityAttributes.nLength = sizeof(SECURITY_ATTRIBUTES); | 
| 215     securityAttributes.bInheritHandle = TRUE; | 215     securityAttributes.bInheritHandle = TRUE; | 
| 216 | 216 | 
| 217     std::tr1::shared_ptr<SECURITY_DESCRIPTOR> sharedSecurityDescriptor; // Just 
     to simplify cleanup | 217     std::tr1::shared_ptr<SECURITY_DESCRIPTOR> sharedSecurityDescriptor; // Just 
     to simplify cleanup | 
| 218     AutoHandle token; | 218     AutoHandle token; | 
| 219     OpenProcessToken(GetCurrentProcess(), TOKEN_READ, token); | 219     OpenProcessToken(GetCurrentProcess(), TOKEN_READ, token); | 
| 220 | 220 | 
| 221     if (IsWindowsVistaOrLater()) | 221     if (IsWindowsVistaOrLater()) | 
| 222     { | 222     { | 
| 223       std::auto_ptr<SID> logonSid = GetLogonSid(token); | 223       std::auto_ptr<SID> logonSid = GetLogonSid(token); | 
| 224       // Create a SECURITY_DESCRIPTOR that has both Low Integrity and allows acc
     ess to all AppContainers | 224       // Create a SECURITY_DESCRIPTOR that has both Low Integrity and allows acc
     ess to all AppContainers | 
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 258 } | 258 } | 
| 259 | 259 | 
| 260 Communication::Pipe::~Pipe() | 260 Communication::Pipe::~Pipe() | 
| 261 { | 261 { | 
| 262   CloseHandle(pipe); | 262   CloseHandle(pipe); | 
| 263 } | 263 } | 
| 264 | 264 | 
| 265 Communication::InputBuffer Communication::Pipe::ReadMessage() | 265 Communication::InputBuffer Communication::Pipe::ReadMessage() | 
| 266 { | 266 { | 
| 267   std::stringstream stream; | 267   std::stringstream stream; | 
| 268   std::unique_ptr<char[]> buffer(new char[bufferSize]); | 268   std::auto_ptr<char> buffer(new char[bufferSize]); | 
| 269   bool doneReading = false; | 269   bool doneReading = false; | 
| 270   while (!doneReading) | 270   while (!doneReading) | 
| 271   { | 271   { | 
| 272     DWORD bytesRead; | 272     DWORD bytesRead; | 
| 273     if (ReadFile(pipe, buffer.get(), bufferSize * sizeof(char), &bytesRead, 0)) | 273     if (ReadFile(pipe, buffer.get(), bufferSize * sizeof(char), &bytesRead, 0)) | 
| 274       doneReading = true; | 274       doneReading = true; | 
| 275     else | 275     else | 
| 276     { | 276     { | 
| 277       DWORD lastError = GetLastError(); | 277       DWORD lastError = GetLastError(); | 
| 278       switch (lastError) | 278       switch (lastError) | 
| (...skipping 13 matching lines...) Expand all  Loading... | 
| 292   return Communication::InputBuffer(stream.str()); | 292   return Communication::InputBuffer(stream.str()); | 
| 293 } | 293 } | 
| 294 | 294 | 
| 295 void Communication::Pipe::WriteMessage(Communication::OutputBuffer& message) | 295 void Communication::Pipe::WriteMessage(Communication::OutputBuffer& message) | 
| 296 { | 296 { | 
| 297   DWORD bytesWritten; | 297   DWORD bytesWritten; | 
| 298   std::string data = message.Get(); | 298   std::string data = message.Get(); | 
| 299   if (!WriteFile(pipe, data.c_str(), static_cast<DWORD>(data.length()), &bytesWr
     itten, 0)) | 299   if (!WriteFile(pipe, data.c_str(), static_cast<DWORD>(data.length()), &bytesWr
     itten, 0)) | 
| 300     throw std::runtime_error("Failed to write to pipe"); | 300     throw std::runtime_error("Failed to write to pipe"); | 
| 301 } | 301 } | 
| OLD | NEW | 
|---|