mirror of
https://github.com/Mr-X-GTA/YimMenu.git
synced 2025-06-22 08:42:44 +08:00
Added script_local implemented by gir489.
Added sanity checks to premake to see if the user did a proper recursive pull, and to warn them if they didn't.
This commit is contained in:
31
BigBaseV2/src/script_local.cpp
Normal file
31
BigBaseV2/src/script_local.cpp
Normal file
@ -0,0 +1,31 @@
|
||||
#include "common.hpp"
|
||||
#include "pointers.hpp"
|
||||
#include "script_local.hpp"
|
||||
#include "gta\script_thread.hpp"
|
||||
|
||||
namespace big
|
||||
{
|
||||
script_local::script_local(rage::scrThread* thread, std::size_t index) :
|
||||
m_index(index), m_stack(thread->m_stack)
|
||||
{
|
||||
}
|
||||
script_local::script_local(PVOID stack, std::size_t index) :
|
||||
m_index(index), m_stack(stack)
|
||||
{
|
||||
}
|
||||
|
||||
script_local script_local::at(std::ptrdiff_t index)
|
||||
{
|
||||
return script_local(m_stack, m_index + index);
|
||||
}
|
||||
|
||||
script_local script_local::at(std::ptrdiff_t index, std::size_t size)
|
||||
{
|
||||
return script_local(m_stack, m_index + 1 + (index * size));
|
||||
}
|
||||
|
||||
void *script_local::get()
|
||||
{
|
||||
return reinterpret_cast<uintptr_t*>((uintptr_t)m_stack + (m_index * sizeof(uintptr_t)));
|
||||
}
|
||||
}
|
31
BigBaseV2/src/script_local.hpp
Normal file
31
BigBaseV2/src/script_local.hpp
Normal file
@ -0,0 +1,31 @@
|
||||
#pragma once
|
||||
#include "common.hpp"
|
||||
|
||||
namespace big
|
||||
{
|
||||
class script_local
|
||||
{
|
||||
public:
|
||||
explicit script_local(rage::scrThread* thread, std::size_t index);
|
||||
explicit script_local(PVOID stack, std::size_t index);
|
||||
|
||||
script_local at(std::ptrdiff_t index);
|
||||
script_local at(std::ptrdiff_t index, std::size_t size);
|
||||
|
||||
template <typename T>
|
||||
std::enable_if_t<std::is_pointer_v<T>, T> as()
|
||||
{
|
||||
return static_cast<T>(get());
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
std::enable_if_t<std::is_lvalue_reference_v<T>, T> as()
|
||||
{
|
||||
return *static_cast<std::add_pointer_t<std::remove_reference_t<T>>>(get());
|
||||
}
|
||||
private:
|
||||
void *get();
|
||||
std::size_t m_index;
|
||||
PVOID m_stack;
|
||||
};
|
||||
}
|
Reference in New Issue
Block a user