1#include <grpcpp/grpcpp.h>
2#include "panoptes.pb.h"
3#include "panoptes.grpc.pb.h"
14 InitializeCriticalSection(&cs_);
15 InitializeConditionVariable(&cv_);
22 EnterCriticalSection(&cs_);
24 std::cout <<
"Enqueued item. Queue size: " << queue_.size() << std::endl;
25 LeaveCriticalSection(&cs_);
26 WakeConditionVariable(&cv_);
32 EnterCriticalSection(&cs_);
33 while (queue_.empty()) {
34 std::cout <<
"Queue empty, waiting..." << std::endl;
35 SleepConditionVariableCS(&cv_, &cs_, INFINITE);
37 PeScan message = queue_.front();
40 LeaveCriticalSection(&cs_);
48 std::unique_lock<std::mutex> lock(mutex_);
56 std::unique_lock<std::mutex> lock(mutex_);
57 cv_.wait(lock, [
this] {
return !queue_.empty(); });
58 MemScan message = queue_.front();
72 ::grpc::Status PEScan(::grpc::ServerContext* context, const ::PeScanInfo* request, ::AckMessage* response)
override {
74 scanInfo.
PePath = request->portable_executable_path();
75 scanInfo.
FileHash = request->file_hash();
81 response->set_ack_type(AckType::SUCCESS);
82 return ::grpc::Status::OK;
90 ::grpc::Status MemoryScan(::grpc::ServerContext* context, const ::MemoryScanInfo* request, ::AckMessage* response)
override {
92 scanInfo.
ProcessId = request->process_id();
98 response->set_ack_type(AckType::SUCCESS);
99 return ::grpc::Status::OK;
107 int* ContainerPort = (
int*)(lpParam);
110 grpc::ServerBuilder builder;
111 std::string server_url =
"localhost:" + std::to_string(*ContainerPort);
112 builder.AddListeningPort(server_url, grpc::InsecureServerCredentials(), ContainerPort);
113 builder.RegisterService(&service);
114 std::unique_ptr<grpc::Server> server(builder.BuildAndStart());
void enqueue(const MemScan &message)
The enqueue function enqueues a MemScan message to the queue.
MemScan dequeue()
The dequeue function dequeues a MemScan messages from the queue.
The PanoptesImpl class is a class that implements the PanoptesExtensibility::Service interface from t...
PeMessageQueue()
The PeMessageQueue class is a thread-safe queue for PeScan messages.
PeScan dequeue()
The dequeue function dequeues a PeScan messages from the queue.
void enqueue(const PeScan &message)
The enqueue function is a function that enqueues a PeScan message to the queue.
MemoryMessageQueue * message_queue_mem_
PeMessageQueue * message_queue_pe_
void RunContainerServer(LPVOID lpParam)
The RunContainerServer function is a function that runs the container server.
The information about the memory to be scanned that passed between the container, extensibility and t...
The information about the file to be scanned that passed between the container, extensibility and the...