1#include <grpcpp/grpcpp.h>
2#include "panoptes.grpc.pb.h"
3#include "scanner_ipc.hpp"
6using grpc::ClientContext;
9std::unique_ptr<PanoptesService::Stub>
stub_;
16 DWORD dwType = REG_DWORD;
20 LONG lResult = RegOpenKeyExA(
28 if (lResult != ERROR_SUCCESS) {
29 std::cerr <<
"Error opening registry key. Error code: " << lResult << std::endl;
34 lResult = RegQueryValueExA(
39 reinterpret_cast<LPBYTE
>(&portValue),
45 if (lResult != ERROR_SUCCESS) {
46 std::cerr <<
"Error reading registry value. Error code: " << lResult << std::endl;
50 if (dwType != REG_DWORD) {
51 std::cerr <<
"Unexpected value type in registry." << std::endl;
62 std::string server_url =
"localhost:0" + std::to_string(
SERVICE_PORT);
63 std::shared_ptr<grpc::Channel> channel = grpc::CreateChannel(server_url, grpc::InsecureChannelCredentials());
64 stub_ = PanoptesService::NewStub(channel);
74 ClientContext context;
75 std::chrono::system_clock::time_point deadline = std::chrono::system_clock::now() + std::chrono::milliseconds(8000);
76 context.set_deadline(deadline);
78 request.set_file_hash(FileHash);
79 request.set_portable_executable_path(PePath);
81 Status status =
stub_->QueuePeScan(&context, request, &reply);
83 if (status.error_code() != grpc::StatusCode::UNKNOWN || status.error_code() != grpc::StatusCode::DEADLINE_EXCEEDED) {
84 message = status.error_message();
PanoptesServiceClient()
The PanoptesServiceClient class is a class that implements the PanoptesServiceClient class.
bool QueuePeScan(std::string PePath, std::string FileHash, std::string &message)
Send a request to the Panoptes Service to scan a PE file.
bool GetRegistryPortValue(DWORD &portValue)
Get the gRPC port value from the registry.
std::unique_ptr< PanoptesService::Stub > stub_
std::unique_ptr< PanoptesService::Stub > stub_
bool GetRegistryPortValue(DWORD &portValue)
Get the Panoptes Service port value from the registry.