| 127 | |
| 128 | |
| 129 | BOOL ShutdownPplService() { |
| 130 | LOG_A(LOG_INFO, "ETW-TI: ShutdownPplService()"); |
| 131 | char buffer[PPL_CONFIG_LEN] = { 0 }; |
| 132 | |
| 133 | try { |
| 134 | // Create JSON object for shutdown command |
| 135 | nlohmann::json j; |
| 136 | j["command"] = "shutdown"; |
| 137 | |
| 138 | std::string json_str = j.dump(); |
| 139 | |
| 140 | // Validate JSON string length |
| 141 | if (json_str.length() >= (PPL_CONFIG_LEN - 1)) { |
| 142 | LOG_A(LOG_ERROR, "ETW-TI: Shutdown JSON payload too long: %zu characters", json_str.length()); |
| 143 | return FALSE; |
| 144 | } |
| 145 | |
| 146 | // Copy JSON string to buffer |
| 147 | strncpy_s(buffer, PPL_CONFIG_LEN, json_str.c_str(), _TRUNCATE); |
| 148 | |
| 149 | if (!pipeClient.Send(buffer)) { |
| 150 | LOG_A(LOG_ERROR, "ETW-TI: Error writing shutdown JSON to named pipe: %ld", GetLastError()); |
| 151 | return FALSE; |
| 152 | } |
| 153 | pipeClient.Disconnect(); |
| 154 | return TRUE; |
| 155 | } |
| 156 | catch (const std::exception& ex) { |
| 157 | LOG_A(LOG_ERROR, "ETW-TI: JSON serialization error for shutdown: %s", ex.what()); |
| 158 | return FALSE; |
| 159 | } |
| 160 | } |
| 161 | |
| 162 | |
| 163 | BOOL InstallElamCertPpl() |