Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add VirtualMachine, GameVM, a shitton of other stuff #220

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
14369a8
fix: rename IFunction::TranslateIPToLineNumber
nikitalita Apr 9, 2024
032c390
feat: add IRemoteDebugger, RemoteDebugger
nikitalita Apr 9, 2024
642f67e
feat: add MemoryManager::GetThreadScrapHeap()
nikitalita Apr 9, 2024
390ff22
feat: Add ScrapHeap and associated interfaces
nikitalita Apr 9, 2024
4883c68
feat: add funcs to BSScrapArrayAllocator
nikitalita Apr 9, 2024
ee2878b
feat: add BSTObjectArena
nikitalita Apr 9, 2024
28fb956
feat: add IObjectProcessor, LinkerProcessor
nikitalita Apr 9, 2024
c1f7092
feat: add ReadableStringTable
nikitalita Apr 9, 2024
bdad88f
feat: Add CompiledScriptLoader, ILoader
nikitalita Apr 9, 2024
a0829b3
feat: add AutoScrapBuffer
nikitalita Apr 9, 2024
7eb02a5
feat: add BSStorage
nikitalita Apr 9, 2024
ed496a3
fix: add scrapheap ids
nikitalita Apr 9, 2024
979d1d1
fix: Fix BSStorage
nikitalita Apr 9, 2024
0362849
feat: add Stream, StreamBase
nikitalita Apr 9, 2024
52eae71
feat: add IStore, Store
nikitalita Apr 9, 2024
cc740dd
fix: Fix BSStorage
nikitalita Apr 9, 2024
21e99bb
feat: add BSResourceEnums
nikitalita Apr 9, 2024
ea9b33e
fix: Fix CompiledScriptLoader
nikitalita Apr 9, 2024
456a999
fix: add BSResourceEnums to starfield.h
nikitalita Apr 9, 2024
2776bc3
feat: add HandleReaderWriters
nikitalita Apr 9, 2024
12ae96f
feat: add ReadbleTypeTable, WritableStringTable, WritableTypeTable
nikitalita Apr 9, 2024
3af60fc
feat: add SuspendedStack
nikitalita Apr 9, 2024
be66396
feat: Add VirtualMachine
nikitalita Apr 9, 2024
f7cb46f
feat: add IClientVM
nikitalita Apr 9, 2024
a9a224c
fix: fix VirtualMachine IClient
nikitalita Apr 9, 2024
6f5bb91
feat: add IStackCallbackSaveInterface
nikitalita Apr 9, 2024
0e729b3
fix: Fix IFuncCallQuery namespace
nikitalita Apr 9, 2024
eeccc11
fix: fix pragma once in handlepolicy.h
nikitalita Apr 9, 2024
185ce40
feat: add BSTimer
nikitalita Apr 9, 2024
9f50a6a
feat: add BSTFreeList
nikitalita Apr 9, 2024
170feb5
feat: add MemoryPagePolicies
nikitalita Apr 9, 2024
9022aab
feat: add Profiler, IProfilePolicy
nikitalita Apr 9, 2024
4bf4d6e
feat: add GameVM
nikitalita Apr 9, 2024
9b2bc01
feat: fix Logger members
nikitalita Apr 9, 2024
813d5a0
fix: change TESFormDeleteEvent to struct
nikitalita Apr 9, 2024
638c4b2
fix: fix missing includes in IVirtualMachine
nikitalita Apr 9, 2024
2726c38
feat: Implement VirtualMachine::GetSingleton()
nikitalita Apr 9, 2024
3d1f4c3
fix: fix access in RemoteDebugger
nikitalita Apr 9, 2024
356ba9c
fix: add boost-stl-interfaces for BSTObjectArena
nikitalita Apr 9, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 56 additions & 0 deletions CommonLibSF/include/RE/B/BSResourceEnums.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#pragma once

namespace RE::BSResource
{
enum class ErrorCode : std::uint32_t
{
kNone = 0,
kNotExist = 1,
kInvalidPath = 2,
kFileError = 3,
kInvalidType = 4,
kMemoryError = 5,
kBusy = 6,
kInvalidParam = 7,
kUnsupported = 8
};

enum class SeekMode
{
kSet = 0,
kCurrent = 1,
kEnd = 2
};

struct FileID
{
public:
[[nodiscard]] bool operator==(const FileID&) const noexcept = default;

// members
std::uint32_t file = 0; // 0
std::uint32_t ext = 0; // 4
};
static_assert(sizeof(FileID) == 0x8);

struct ID :
public FileID // 0
{
public:
[[nodiscard]] bool operator==(const ID&) const noexcept = default;

// members
std::uint32_t dir = 0; // 8
};
static_assert(sizeof(BSResource::ID) == 0xC);

struct Info
{
public:
// members
WinAPI::FILETIME modifyTime; // 00
WinAPI::FILETIME createTime; // 08
std::uint64_t fileSize; // 10
};
static_assert(sizeof(Info) == 0x18);
}
104 changes: 104 additions & 0 deletions CommonLibSF/include/RE/B/BSStorage.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
#pragma once

#include "RE/B/BSIntrusiveRefCounted.h"
#include "RE/B/BSTSmartPointer.h"

namespace RE
{
namespace BSStorageDefs
{
enum class ErrorCode
{
kOK = 0,
kError = 1,
kNotImplemented = 2,
};
enum class SeekMode;
struct StreamBuffer
{
void Reset()
{
ptrCur = buffer.GetPtr();
}

StreamBuffer() = delete;
StreamBuffer(std::size_t a_size) :
size(a_size),
buffer(a_size, 8),
ptrCur(buffer.GetPtr())
{
}

std::size_t size;
MemoryManager::AutoScrapBuffer buffer;
void* ptrCur;
};
}

class __declspec(novtable) BSStorage :
public BSIntrusiveRefCounted
{
public:
inline static constexpr auto RTTI = { RTTI::BSStorage };
inline static constexpr auto VTABLE = { VTABLE::BSStorage };

virtual ~BSStorage() = default; // 00

virtual std::size_t GetSize() const = 0; // 01
virtual std::size_t GetPosition() const = 0; // 02
virtual BSStorageDefs::ErrorCode Seek(std::size_t a_offset, BSStorageDefs::SeekMode a_seekMode) const = 0; // 03
virtual BSStorageDefs::ErrorCode Read(std::size_t a_numBytes, std::byte* a_bytes) const = 0; // 04
virtual BSStorageDefs::ErrorCode Write(std::size_t a_numBytes, const std::byte* a_bytes) = 0; // 05

template <typename T>
BSStorageDefs::ErrorCode Write(T a_value)
requires(std::is_arithmetic_v<T>)
{
if (usingStreambuffer && buf && PrepareStreamBuffer(sizeof(T)) == BSStorageDefs::ErrorCode::kOK) {
*reinterpret_cast<T*>(buf->ptrCur) = a_value;
buf->ptrCur = reinterpret_cast<std::byte*>(buf->ptrCur) + sizeof(T);
return BSStorageDefs::ErrorCode::kOK;
}
return Write(sizeof(T), reinterpret_cast<const std::byte*>(&a_value));
}

template <typename T>
BSStorageDefs::ErrorCode Write(const T& a_value)
requires(!std::is_arithmetic_v<T>)
{
return Write(sizeof(T), reinterpret_cast<const std::byte*>(&a_value));
}

template <typename T>
BSStorageDefs::ErrorCode Read(T& a_value)
{
return Read(sizeof(T), reinterpret_cast<std::byte*>(&a_value));
}

BSStorageDefs::ErrorCode WriteString(const char* a_string, bool use32bitLength)
{
using func_t = decltype(&BSStorage::WriteString);
REL::Relocation<func_t> func{ ID::BSStorage::WriteString };
return func(this, a_string, use32bitLength);
}

BSStorageDefs::ErrorCode PrepareStreamBuffer(std::size_t a_size)
{
using func_t = decltype(&BSStorage::PrepareStreamBuffer);
REL::Relocation<func_t> func{ ID::BSStorage::PrepareStreamBuffer };
return func(this, a_size);
}

BSStorageDefs::ErrorCode FlushStreamBuffer()
{
using func_t = decltype(&BSStorage::FlushStreamBuffer);
REL::Relocation<func_t> func{ ID::BSStorage::FlushStreamBuffer };
return func(this);
}

// members
msvc::unique_ptr<BSStorageDefs::StreamBuffer> buf{ nullptr }; // 10
bool usingStreambuffer{ 0 }; // 18
};
static_assert(sizeof(BSStorage) == 0x20);
}
13 changes: 13 additions & 0 deletions CommonLibSF/include/RE/B/BSTArray.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,18 @@ namespace RE

class BSScrapArrayAllocator
{
public:
void* allocate(std::size_t a_size)
{
const auto mem = _allocator->Allocate(a_size, 0);
if (!mem) {
stl::report_and_fail("out of memory"sv);
}
std::memset(mem, 0, a_size);
return mem;
}
void deallocate(void* a_ptr) { _allocator->Deallocate(a_ptr, 0); }

protected:
// members
ScrapHeap* _allocator{ nullptr }; // 00
Expand Down Expand Up @@ -301,4 +313,5 @@ namespace RE

template <class T>
using BSScrapArray = BSTArray<T, BSScrapArrayAllocator>;
static_assert(sizeof(BSScrapArray<void*>) == 0x18);
}
34 changes: 34 additions & 0 deletions CommonLibSF/include/RE/B/BSTFreeList.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#pragma once

namespace RE
{
template <class T>
struct BSTFreeListElem
{
public:
// members
std::byte rawElem[sizeof(T)]; // 00
BSTFreeListElem<T>* next; // ??
};

template <class T>
class __declspec(novtable) BSTFreeList
{
public:
virtual ~BSTFreeList(); // 00

// members
std::uint32_t lock; // 08
BSTFreeListElem<T>* free; // 10
};
//static_assert(sizeof(BSTFreeList<void*>) == 0x18);

template <class T, std::uint32_t N>
class __declspec(novtable) BSTStaticFreeList :
public BSTFreeList<T> // 00
{
public:
// members
BSTFreeListElem<T> elems[N]; // ??
};
}
Loading
Loading