AuroraRuntime/Include/Aurora/Process/Process.hpp
Jamie Reece Wilson 33f77cf011 [+] Aurora::Process::GetBinaryClassPath
[+] Aurora::Process::SetBinaryClassPath
[+] Aurora::Process::AddBinaryClassPath
[+] Aurora::Process::LoadModuleEx
[+] Aurora::Process::GetProcHandle
[+] Aurora::Process::GetProcAddressEx
[+] Aurora::ProcessConfig
[*] Cleanup a bit
2023-10-11 01:11:57 +01:00

97 lines
4.3 KiB
C++

/***
Copyright (C) 2021 J Reece Wilson (a/k/a "Reece"). All rights reserved.
File: Process.hpp
Date: 2021-6-10
Author: Reece
***/
#pragma once
#include "Paths.hpp"
#include "ProcessMap.hpp"
#include "IProcessSectionMapView.hpp"
#include "IProcessSectionView.hpp"
#include "ProcessEnvironment.hpp"
#include "ProcessStartTime.hpp"
namespace Aurora::Process
{
/**
* @brief Aborts the current process with the provided exitcode
* @param exitcode
* @return
*/
AUKN_SYM AU_NORETURN void Exit(AuUInt32 exitcode);
AUE_DEFINE(EModulePath,
(
eModulePathCWD,
eModulePathSystemDir, /// /usr/lib/, windir/system32
eModulePathUserDir, /// /usr/local/lib
eProcessDirectory, ///
eClassPath,
//eOSSpecified, /// LD_LIBRARY_PATH + /etc/ld.so.conf, AddDllDirectory
eSpecified
));
// eModulePathSystemDir -> why /usr/lib and not /lib?
// https://www.freedesktop.org/wiki/Software/systemd/TheCaseForTheUsrMerge/
// Arch 2012: https://archlinux.org/news/the-lib-directory-becomes-a-symlink/
// Ubuntu 2018 (mandatory 2021+): https://lists.ubuntu.com/archives/ubuntu-devel-announce/2018-November/001253.html https://wiki.debian.org/UsrMerge
// Fedora (2011?): https://fedoraproject.org/wiki/Features/UsrMove
static AuList<EModulePath> kUserOverloadableSearchPath = { EModulePath::eSpecified, EModulePath::eModulePathCWD, EModulePath::eClassPath, EModulePath::eProcessDirectory, EModulePath::eModulePathUserDir, EModulePath::eModulePathSystemDir };
static AuList<EModulePath> kAdminOverloadableSearchPath = { EModulePath::eSpecified, EModulePath::eModulePathSystemDir, EModulePath::eProcessDirectory, EModulePath::eClassPath, EModulePath::eModulePathCWD, EModulePath::eModulePathUserDir };
static AuList<EModulePath> kSpecifiedPath = { EModulePath::eSpecified, EModulePath::eClassPath };
static AuList<EModulePath> kSpecifiedPathStrict = { EModulePath::eSpecified };
static AuList<EModulePath> kCWDPath = { EModulePath::eModulePathCWD };
static AuList<EModulePath> kProcPath = { EModulePath::eProcessDirectory };
struct ModuleLoadRequest
{
inline ModuleLoadRequest(const AuList<AuString> &directories, const AuString &mod) : mod(mod), specifiedSearchPaths(&directories), searchPath(&kSpecifiedPathStrict)
{}
inline ModuleLoadRequest(const AuList<AuString> &directories, const AuString &mod, const AuString &version) : mod(mod), version(version), specifiedSearchPaths(&directories), searchPath(&kSpecifiedPathStrict)
{}
inline ModuleLoadRequest(const AuString &mod) : mod(mod), searchPath(&kAdminOverloadableSearchPath)
{}
inline ModuleLoadRequest(const AuString &mod, const AuString &version) : mod(mod), version(version), searchPath(&kAdminOverloadableSearchPath)
{}
AuString mod;
AuString version;
AuList<AuString> const * specifiedSearchPaths {};
AuList<EModulePath> const * searchPath {};
bool verify {}; // always effectively true if the executable is signed and enableMitigations is true
bool unixCheckPlusX { true };
bool enableMitigations { true };
bool forceMitigations { false };
};
/**
* @brief Loads a dynamic link module into cache, by the name of 'mod', somewhere in the directories specified by 'searchPath'.
* You should not provide a suffix, platform extension, or the full aurora dll string. Path resolution will take care of
* resolving the Aurora ABI, falling back to mod.platformext.
* @param request
* @return
*/
AUKN_SYM bool LoadModule(const ModuleLoadRequest &request);
AUKN_SYM void *LoadModuleEx(const ModuleLoadRequest &request);
AUKN_SYM void *GetProcHandle(const AuString &name);
AUKN_SYM AuMach GetProcAddress(const AuString &mod, const AuString &symbol);
AUKN_SYM AuMach GetProcAddressEx(void *pHandle, const AuString &symbol);
AUKN_SYM AuList<AuString> GetBinaryClassPath();
AUKN_SYM bool SetBinaryClassPath(const AuList<AuString> &list, bool preloadAll = false);
AUKN_SYM bool AddBinaryClassPath(const AuString &dir, bool preloadAll = false);
}