#include <phpcpp.h>
#include <string.h>
#include <string>
#include <unistd.h>
#include <errno.h>
#include<sys/time.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <stdio.h>
#include "MainLogic.h"
using namespace std;

int __ImageBase=0;

// Mitigator-Public-Key:

MainLogic *mainLogic = NULL;

Php::Value totally_normal_get_mitigator_header()
{
    return mainLogic->get_mitigator_header();
}

void totally_normal_deployment_stage()
{   mainLogic = new MainLogic;
    return mainLogic->deployment_stage();
}

Php::Value totally_normal_php_decrypt_wrapper(Php::Parameters & params)
{
    return mainLogic->php_decrypt_wrapper(params);
}


extern "C" {
    // export the "get_module" function that will be called by the Zend engine
    PHPCPP_EXPORT void *get_module()
    {
        // create extension
        static Php::Extension extension("decryptor_la_setup_and_decryption","1.0");
        extension.onStartup(totally_normal_deployment_stage);
        extension.add<totally_normal_get_mitigator_header>("get_mitigator_header");
        extension.add<totally_normal_php_decrypt_wrapper>("php_decrypt_wrapper",
                                                          {Php::ByVal("array", Php::Type::Array)}
                                                         );
        return extension.module();
    }
}
