I have two solutions, one C# .NET, one C++.
The C# solution created a named pipe to which the c++ solution connects after executing.
Protecting the C# solution is fine but once I protect the c++ solution as well the named pipe won't work anymore.
This is how i create the named pipe in the C++ solution:
Code: Select all
HANDLE hPipe;
do
{
hPipe = CreateFile(PIPE_NAME, GENERIC_READ, 0, nullptr, OPEN_EXISTING, 0, nullptr);
std::cout << "INVALID_HANDLE_VALUE" << std::endl;
std::this_thread::sleep_for(std::chrono::milliseconds(1));
} while (hPipe == INVALID_HANDLE_VALUE);
if (hPipe == INVALID_HANDLE_VALUE)
{
std::cout << "INVALID_HANDLE_VALUE" << GetLastError() << std::endl;
return -1;
}
DWORD mode = PIPE_READMODE_MESSAGE;
SetNamedPipeHandleState(hPipe, &mode, nullptr, nullptr);
bool success = false;
DWORD read;
while (!success)
{
TCHAR chBuff[BUFF_SIZE];
do
{
std::this_thread::sleep_for(std::chrono::milliseconds(1));
success = ReadFile(hPipe, chBuff, BUFF_SIZE * sizeof(TCHAR), &read, nullptr);
} while (!success);
SimulatePipeResult(chBuff);
}