forked from NasiRawon/AlternateConversationCamera
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathUtils.cpp
110 lines (82 loc) · 3.55 KB
/
Utils.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
#include "ObjectRef.h"
#include "Utils.h"
#include "PatternScanner.h"
namespace Tralala
{
uintptr_t g_MenuTopicManagerAddr = 0;
uintptr_t g_TESCameraControllerAddr = 0;
uintptr_t g_bsfixedstringCtorAddr = 0;
uintptr_t g_bsfixedstringDtorAddr = 0;
uintptr_t g_iSizeWDisplayAddr = 0;
uintptr_t g_iSizeHDisplayAddr = 0;
uintptr_t g_deltaTimeAddr = 0;
uintptr_t g_sneakHeightMultAddr = 0;
uintptr_t g_isDialogueMenuCloseAddr = 0;
uintptr_t g_containerHandle = 0;
uintptr_t g_barterHandle = 0;
void UtilsGetAddresses()
{
const std::array<BYTE, 13> Topicpattern = { 0x48, 0x85, 0xC0, 0x41, 0xB1, 0x01, 0x48, 0x8B, 0xD7, 0x4C, 0x0F, 0x45, 0xC0 };
g_MenuTopicManagerAddr = (uintptr_t)scan_memory_data(Topicpattern, 0x55, true, 0x3, 0x7);
const std::array<BYTE, 10> Controllerpattern = { 0xF3, 0x0F, 0x5C, 0xF0, 0x48, 0x8B, 0xCF, 0x0F, 0x28, 0xCE };
g_TESCameraControllerAddr = (uintptr_t)scan_memory_data(Controllerpattern, 0x99, false, 0x3, 0x7);
const std::array<BYTE, 6> ctorpattern = { 0x45, 0x33, 0xDB, 0x48, 0x8B, 0xD9 };
g_bsfixedstringCtorAddr = (uintptr_t)scan_memory(ctorpattern, 0x6, false);
const std::array<BYTE, 7> dtorpattern = { 0x44, 0x8D, 0x42, 0x38, 0x48, 0x8B, 0xCB };
g_bsfixedstringDtorAddr = (uintptr_t)scan_memory_data(dtorpattern, 0x18, false, 0x3, 0x7);
const std::array<BYTE, 6> wdispattern = { 0x89, 0x44, 0x24, 0x5C, 0x33, 0xC0 };
g_iSizeWDisplayAddr = (uintptr_t)scan_memory_data(wdispattern, 0x36, false, 0x2, 0x6);
const std::array<BYTE, 6> hdispattern = { 0x89, 0x44, 0x24, 0x5C, 0x33, 0xC0 };
g_iSizeHDisplayAddr = (uintptr_t)scan_memory_data(hdispattern, 0x2C, false, 0x2, 0x6);
const std::array<BYTE, 6> deltaTimepattern = { 0x0F, 0x28, 0xCB, 0x0F, 0x54, 0xCD };
g_deltaTimeAddr = (uintptr_t)scan_memory_data(deltaTimepattern, 0xC, false, 0x4, 0x8);
const std::array<BYTE, 6> sneakpattern = { 0x48, 0x8B, 0xC3, 0x89, 0x4B, 0x04 };
g_sneakHeightMultAddr = (uintptr_t)scan_memory_data(sneakpattern, 0x25, true, 0x4, 0x8);
const std::array<BYTE, 5> dialpattern = { 0x32, 0xC9, 0x45, 0x84, 0xF6 };
g_isDialogueMenuCloseAddr = (uintptr_t)scan_memory_data(dialpattern, 0x1E, true, 0x2, 0x7);
const std::array<BYTE, 6> contpattern = { 0x48, 0x3B, 0xD0, 0x0F, 0x94, 0xC2 };
g_containerHandle = (uintptr_t)scan_memory_data(contpattern, 0x3B, true, 0x2, 0x6);
const std::array<BYTE, 7> bartpattern = { 0x4C, 0x8B, 0xEF, 0x48, 0x8B, 0x43, 0x28 };
g_barterHandle = (uintptr_t)scan_memory_data(bartpattern, 0x33, false, 0x3, 0x7);
}
TESCameraController* TESCameraController::GetSingleton()
{
return (TESCameraController*)g_TESCameraControllerAddr;
}
MenuTopicManager * MenuTopicManager::GetSingleton()
{
return *(MenuTopicManager**)g_MenuTopicManagerAddr;
}
NiPointer<TESObjectREFR> MenuTopicManager::GetDialogueTarget()
{
NiPointer<TESObjectREFR> refr;
if (talkingHandle != Tralala::InvalidRefHandle()) LookupRefByHandle(talkingHandle, refr);
if (!refr)
{
if (handle2 != Tralala::InvalidRefHandle()) LookupRefByHandle(handle2, refr);
}
return refr;
}
StringCache::Ref::Ref()
{
typedef StringCache::Ref*(*ctor_t)(StringCache::Ref *, const char *);
ctor_t ctor = (ctor_t)g_bsfixedstringCtorAddr;
ctor(this, "");
}
StringCache::Ref::Ref(const char * buf)
{
typedef StringCache::Ref*(*ctor_t)(StringCache::Ref *, const char *);
ctor_t ctor = (ctor_t)g_bsfixedstringCtorAddr;
ctor(this, buf);
}
StringCache::Ref::~Ref()
{
Release();
}
void StringCache::Ref::Release()
{
typedef void(*dtor_t)(StringCache::Ref*);
dtor_t dtor = (dtor_t)g_bsfixedstringDtorAddr;
dtor(this);
}
}