1
1
#include <windows.h>
2
+ #define USING_NAMESPACE_BCB6_STD
2
3
#include "bcb6_operator.h"
3
4
#include "TSSGCtrl.h"
4
5
5
6
EXTERN_C BOOL ExtensionTSSDir ;
6
- EXTERN_C void __cdecl TSSGAttributeSelector_AddElement_MakeOnlyOneAtteribute (void * , void * );
7
- EXTERN_C void __cdecl TSSGAttributeSelector_MakeNowAttributeVec_push_back (void * , void * );
8
7
EXTERN_C void * __cdecl TSSGCtrl_ReadSSG_PushElement (void * , void * );
9
8
10
- static __declspec(naked ) void __cdecl TSSGAttributeSelector_StartElementCheck_new_attributeSetMap ()
9
+ static unsigned seqElement = MAXDWORD ;
10
+
11
+ static __declspec(naked ) uint64_t __cdecl TSSGAttributeSelector_StartElementCheck_new_attributeSetMap (size_t __n )
12
+ {
13
+ __asm {
14
+ xor eax , eax
15
+ mov seqElement , eax
16
+ mov edx , dword ptr [esi + TSSGAttributeSelector .attributeSetMap ]
17
+ test edx , edx
18
+ jnz PASS
19
+
20
+ mov ecx , dword ptr [esp + 4 ]
21
+ #if OPTIMIZE_ALLOCATOR
22
+ call bcb6_operator_new
23
+ #else
24
+ push ecx
25
+ call bcb6_operator_new
26
+ pop ecx
27
+ #endif
28
+ xor edx , edx
29
+
30
+ PASS :
31
+ ret
32
+ }
33
+ }
34
+
35
+ void * __cdecl TSSGAttributeSelector_AddElement_MakeOnlyOneAtteribute (TSSGAttributeSelector * const this , TAdjustmentAttribute * AElem )
36
+ {
37
+ static void * (__cdecl * const TSSGAttributeSelector_MakeOnlyOneAtteribute )(TSSGAttributeSelector * , void * ) = (void * )0x004D5764 ;
38
+
39
+ AElem = TSSGAttributeSelector_MakeOnlyOneAtteribute (this , AElem );
40
+ AElem -> seqElement = TSSGAttributeElement_GetType (AElem ) == atDEFINE
41
+ ? string_length (& ((TDefineAttribute * )AElem )-> inputCode )
42
+ : seqElement ++ // renumbering when redeclared too
43
+ ;// store into allocator_type[1], except atSCOPE
44
+ return AElem ;
45
+ }
46
+
47
+ static int __cdecl cmpElement (LPCVOID const A , LPCVOID const B )
48
+ {
49
+ const TAdjustmentAttribute * const a = * (TAdjustmentAttribute * * )A ;
50
+ const TAdjustmentAttribute * const b = * (TAdjustmentAttribute * * )B ;
51
+ signed diff = a -> type - b -> type ;
52
+ return diff ? diff : TSSGAttributeElement_GetType (a ) == atDEFINE ?
53
+ strcmp (a -> c_str , b -> c_str ) : a -> seqElement - b -> seqElement ;
54
+ }
55
+
56
+ #pragma intrinsic(_BitScanForward)
57
+ void __cdecl TSSGAttributeSelector_MakeNowAttributeVec_push_back (list * const allAtteributeVecList , vector * const * const __x )
58
+ {
59
+ static void (__cdecl * const list_vector_push_back )(list * , const vector * const * ) = (void * )0x004D5FBC ;
60
+
61
+ COORD coords [0x20 ] = { { 0 , 0 } };
62
+ vector const index = { coords , coords + _countof (coords ) - 1 , NULL , NULL , coords , MAXDWORD };
63
+
64
+ vector * const NewVec = * __x ;
65
+ qsort (vector_begin (NewVec ), vector_size_by_type (NewVec , void * ), sizeof (void * ), cmpElement );
66
+
67
+ for (TSSGAttributeElement * * VIt = vector_begin (NewVec );
68
+ VIt < (TSSGAttributeElement * * )vector_end (NewVec );
69
+ VIt ++ )
70
+ {
71
+ DWORD Index ;
72
+ _BitScanForward (& Index , TSSGAttributeElement_GetType (* VIt ));
73
+ if (coords [Index ].X ++ == 0 )
74
+ coords [Index ].Y = VIt - (TSSGAttributeElement * * )vector_begin (NewVec );
75
+ }
76
+
77
+ NewVec -> allocator_type [0 ] = NULL ;
78
+ NewVec -> allocator_type [1 ] = NULL ;
79
+ NewVec -> tblIndex = SubjectStringTable_insert ((string * )& index );
80
+ list_vector_push_back (allAtteributeVecList , __x );
81
+ }
82
+
83
+ CONSOLE_FONT_INFO __fastcall TSSGAttributeElement_GetViaCoord (AtType const Type , const vector * const AttrV )
84
+ {
85
+ DWORD Index ;
86
+ _BitScanForward (& Index , Type );
87
+ COORD coord = vector_type_at (& vector_at (& SubjectStringTable_array , AttrV -> tblIndex ), COORD , Index );
88
+ return (CONSOLE_FONT_INFO ) { coord .X ? vector_type_at (AttrV , DWORD , coord .Y ) : 0 , coord };
89
+ }
90
+
91
+ static BOOL __fastcall TSSGCtrl_AddressAttributeFilter_GetAddress_replace (TReplaceAttribute * tmpAE , TSSGSubject * * SSGS )
11
92
{
93
+ if (tmpAE -> context )
94
+ * SSGS = tmpAE -> context ;
95
+ return !!tmpAE -> context ;
96
+ }
97
+
98
+ static __declspec(naked ) void __cdecl TSSGCtrl_AddressAttributeFilter_GetAddress ()
99
+ {
12
100
__asm {
13
- #define attributeSetMap (esi + 0x20)
14
- mov eax , ExtensionTSSDir
15
- neg eax
16
- and eax , dword ptr [attributeSetMap ]
17
- jz NEW
18
- mov dword ptr [esp ], 0x004D2E28
19
- ret 4 // goto nowAttributeList = new list<TSSGAttributeElement *>;
20
-
21
- align 16
22
- NEW :
23
- mov ecx , dword ptr [esp + 4 ]
24
- jmp bcb6_operator_new
25
- #undef attributeSetMap
101
+ lea edx , [esp + 8 ]
102
+ mov ecx , [ebx ]
103
+ call TSSGCtrl_AddressAttributeFilter_GetAddress_replace
104
+ test eax , eax
105
+ jz GET
106
+ mov ecx , [ebp - 0x48 ]
107
+ mov [edi ], ecx // restore initial address
108
+ GET :
109
+ jmp TSSGCtrl_GetAddress
110
+ ud2
26
111
}
27
112
}
28
113
29
- static __declspec(naked ) BOOLEAN __cdecl THeapAdjustmentAttribute_IsEqual_adaptScope () {
114
+ static __declspec(naked ) void __fastcall THeapAdjustmentAttribute_dtor_heapMap (THeapAdjustmentAttribute * this , struct _Rb_tree_node * root )
115
+ {
116
+ static void (__cdecl * const tree_ulong_pair_uu_erase )() = (void * )0x004D0A80 ;
117
+ static void (__cdecl * const tree_string_double_erase )() = (void * )0x0051C168 ;
118
+
30
119
__asm {
31
- cmp dword ptr [ebx + 4 ], atSCOPE
32
- jne CONTINUE
33
- mov dword ptr [esp ], 0x00523643
34
- CONTINUE :
35
- mov eax , 1
36
- ret
120
+ mov eax , tree_ulong_pair_uu_erase
121
+ cmp dword ptr [ecx + TSSGAttributeElement .type ], atSCOPE
122
+ cmove eax , tree_string_double_erase
123
+ jmp eax
124
+ ud2
37
125
}
38
126
}
39
127
40
128
#define CALL_REL (BYTE )0xE8
41
129
#define JMP_REL32 (BYTE )0xE9
130
+ #define JMP_REL8 (BYTE )0xEB
131
+ #define JZ_SHORT (BYTE )0x74
132
+ #define JNZ_SHORT (BYTE )0x75
42
133
#define NOP (BYTE )0x90
43
- #define NOP_X4 (DWORD )0x90909090
134
+ #define NOP_X4 (DWORD )0x00401F0F
44
135
45
136
EXTERN_C void __cdecl Attach_EnumReadSSG ()
46
137
{
47
138
// TSSGAttributeSelector::StartElementCheck
48
139
// attributeSetMap!=NULL => nowAttributeList!=NULL
49
140
* (LPBYTE )(0x004D2D6D + 2 ) = offsetof(TSSGAttributeSelector , nowAttributeList );
50
141
* (LPDWORD )(0x004D2D85 + 1 ) = (DWORD )TSSGAttributeSelector_StartElementCheck_new_attributeSetMap - (0x004D2D85 + 1 + sizeof (DWORD ));
142
+ * (LPDWORD )(0x004D2D90 + 2 ) = 0x004D2E25 - (0x004D2D90 + 2 + sizeof (DWORD ));// EAX is NULL then use EDX
51
143
52
144
// TSSGAttributeSelector::EndElementCheck
53
145
// retain attributeSetMap if caller isn't TSSGAttributeSelector::Clear
54
- * (LPWORD )0x004D3686 = BSWAP16 (0x6690 );
55
- * (LPDWORD )0x004D3688 = BSWAP32 (0x33C08943 );
56
- * (LPDWORD )0x004D368C = BSWAP32 (0x28817D04 );
57
- * (LPDWORD )0x004D3690 = 0x004D2D15 ;
58
- * (LPBYTE )0x004D3694 = 0x74 ;
59
- * (LPBYTE )0x004D3695 = 0x004D36A2 - (0x004D3695 + sizeof (BYTE ));
60
- * (LPWORD )0x004D3696 = BSWAP16 (0x3905 );
61
- * (LPDWORD )0x004D3698 = (DWORD )& ExtensionTSSDir ;
62
- * (LPWORD )0x004D369C = BSWAP16 (0x0F85 );
63
- * (LPDWORD )0x004D369E = 0x004D3722 - (0x004D369E + sizeof (DWORD ));
146
+ * (LPWORD )0x004D3686 = BSWAP16 (0x33C9 );// xor ecx, ecx
147
+ * (LPDWORD )0x004D3688 = BSWAP32 (0x8B45042D );// mov eax, dword ptr [_AddressOfReturnAddress]
148
+ * (LPDWORD )0x004D368C = 0x004D2D15 ;// sub eax, ...
149
+ * (LPDWORD )0x004D3690 = BSWAP32 (0xF7D81BD2 );// neg eax; sbb edx, edx
150
+ * (LPDWORD )0x004D3694 = BSWAP32 (0x8B432089 );// mov eax, dword ptr [attributeSetMap]
151
+ * (LPDWORD )0x004D3698 = BSWAP32 (0x4B288515 );// mov dword ptr [nowAttributeVec], ecx
152
+ * (LPDWORD )0x004D369C = (DWORD )& ExtensionTSSDir ;// test edx, ds:
153
+ * (LPBYTE )0x004D36A0 = JZ_SHORT ;
154
+ * (LPBYTE )0x004D36A1 = 0x004D36A5 - (0x004D36A1 + sizeof (BYTE ));
155
+ * (LPBYTE )0x004D36A2 = JMP_REL8 ;
156
+ * (LPBYTE )0x004D36A3 = 0x004D3722 - (0x004D36A3 + sizeof (BYTE ));
157
+ * (LPBYTE )0x004D36A4 = NOP ;
64
158
65
159
// TSSGAttributeSelector::AddElement
66
160
* (LPDWORD )0x004D3DCA = (DWORD )TSSGAttributeSelector_AddElement_MakeOnlyOneAtteribute - (0x004D3DCA + sizeof (DWORD ));
@@ -69,7 +163,21 @@ EXTERN_C void __cdecl Attach_EnumReadSSG()
69
163
* (LPDWORD )0x004D5C88 = (DWORD )TSSGAttributeSelector_MakeNowAttributeVec_push_back - (0x004D5C88 + sizeof (DWORD ));
70
164
71
165
// TSSGCtrl::ReadSSG
72
- * (LPDWORD )0x004E462A = (DWORD )TSSGCtrl_ReadSSG_PushElement - (0x004E462A + sizeof (DWORD ));
166
+ * (LPBYTE )(0x004E45C8 + 1 ) = sizeof (TDirAttribute );
167
+
168
+ * (LPBYTE )(0x004E45F7 + 0 ) = 0x89 ;// mov [eax]
169
+ * (LPBYTE )(0x004E45F7 + 1 ) = 0x08 ;// ecx
170
+ * (LPBYTE )(0x004E45F9 + 0 ) = 0x8B ;// mov edx,
171
+ * (LPBYTE )(0x004E45F9 + 1 ) = 0x93 ;// [ebx + ...
172
+ * (LPDWORD )(0x004E45F9 + 2 ) = offsetof(TSSGCtrl , rootSubject );
173
+ * (LPBYTE )(0x004E4601 + 1 ) = 0x48 ;// edx => eax
174
+ * (LPWORD )(0x004E4604 + 0 ) = BSWAP16 (0x8948 );// mov [eax + ...], ecx
175
+ * (LPBYTE )(0x004E4604 + 2 ) = offsetof(TDirAttribute , identity );
176
+ * (LPBYTE )(0x004E4617 + 0 ) = 0x89 ;// mov [eax + ...]
177
+ * (LPBYTE )(0x004E4617 + 1 ) = 0x50 ;// edx
178
+ * (LPBYTE )(0x004E4617 + 2 ) = offsetof(TDirAttribute , ref );
179
+
180
+ * (LPDWORD )(0x004E4629 + 1 ) = (DWORD )TSSGCtrl_ReadSSG_PushElement - (0x004E4629 + 1 + sizeof (DWORD ));
73
181
74
182
// TSSGCtrl::EnumReadSSG
75
183
* (LPBYTE )0x004E5090 = JMP_REL32 ;
@@ -83,9 +191,70 @@ EXTERN_C void __cdecl Attach_EnumReadSSG()
83
191
// attributeSelector.IsElementCheckMode()
84
192
* (LPBYTE )(0x004FD49A + 2 ) = offsetof(TSSGCtrl , attributeSelector .nowAttributeList );
85
193
194
+ * (LPBYTE )(0x004FD549 + 1 ) = sizeof (TDirAttribute );
195
+ * (LPWORD )(0x004FD594 + 0 ) = BSWAP16 (0x894A );// mov [edx + ...], ecx
196
+ * (LPBYTE )(0x004FD594 + 2 ) = offsetof(TDirAttribute , identity );
197
+ * (LPBYTE )(0x004FD597 + 0 ) = 0x89 ;// mov [edx + ...]
198
+ * (LPBYTE )(0x004FD597 + 1 ) = 0x4A ;// ecx
199
+ * (LPBYTE )(0x004FD597 + 2 ) = offsetof(TDirAttribute , ref );
200
+ * (LPBYTE )(0x004FD59A + 1 ) = 0x42 ;// edx => eax
201
+
202
+ // TSSGCtrl::GetAttribute
203
+ * (LPWORD )0x005038FE = BSWAP16 (0x8BCB );// mov ecx, ebx
204
+ * (LPWORD )0x00503900 = BSWAP16 (0x5B5D );// pop ebx
205
+ * (LPBYTE )0x00503902 = JMP_REL32 ;// pop ebp
206
+ * (LPDWORD )0x00503903 = (DWORD )TSSGAttributeElement_GetViaCoord - (0x00503903 + sizeof (DWORD ));
207
+
208
+ // TSSGCtrl::AddressAttributeFilter
209
+ // keeping Address initial value.
210
+ * (LPWORD )(0x00504133 + 1 ) = BSWAP16 (0xEC48 );// sub esp, 0x48
211
+ * (LPDWORD ) 0x0050414C = BSWAP16 (0x8B0F );// mov ecx, dword ptr [Address]
212
+ * (LPWORD ) 0x0050414E = BSWAP16 (0x85C0 );// test eax, eax
213
+ * (LPBYTE ) 0x00504150 = JNZ_SHORT ;
214
+ * (LPBYTE )(0x00504150 + 1 ) = 0x00504161 - (0x00504150 + 1 + sizeof (BYTE ));
215
+ * (LPBYTE )(0x00504169 + 0 ) = 0x89 ;// mov dword ptr
216
+ * (LPWORD )(0x00504169 + 1 ) = BSWAP16 (0x4DB8 );// [ebp - 0x48], ecx
217
+ * (LPBYTE )(0x0050416C + 0 ) = JMP_REL32 ;
218
+ * (LPDWORD )(0x0050416C + 1 ) = 0x00504266 - (0x0050416C + 1 + sizeof (DWORD ));
219
+ * (LPBYTE )(0x0050416C + 5 ) = NOP ;
220
+ // GetAddress(SSGS, tmpAE->GetOffsetCode(), 0)
221
+ * (LPDWORD )(0x005041CF + 1 ) = (DWORD )TSSGCtrl_AddressAttributeFilter_GetAddress - (0x005041CF + 1 + sizeof (DWORD ));
222
+
223
+ // THeapAdjustmentAttribute::~THeapAdjustmentAttribute
224
+ #ifdef SCOPE_USE_STRING_KEY
225
+ * (LPDWORD )(0x00523531 + 1 ) = (DWORD )THeapAdjustmentAttribute_dtor_heapMap - (0x00523531 + 1 + sizeof (DWORD ));
226
+ #endif
227
+
86
228
// THeapAdjustmentAttribute::IsEqual
87
- * (LPBYTE )0x005235C8 = 0xC0 ;
88
- * (LPBYTE )0x005235CB = CALL_REL ;
89
- * (LPDWORD )0x005235CC = (DWORD )THeapAdjustmentAttribute_IsEqual_adaptScope - (0x005235CC + sizeof (DWORD ));
90
- * (LPBYTE )0x005235D1 = 0xC0 ;
229
+ // if (type == atSCOPE) return TRUE;
230
+ * (LPBYTE )0x005235CA = 0x0052363A - (0x005235CA + sizeof (BYTE ));
231
+ * (LPBYTE )0x005235CB = 0x81 ;// cmp dword ptr
232
+ * (LPBYTE )0x005235CC = 0x7B ;// [ebx + ...
233
+ * (LPBYTE )0x005235CD = offsetof(THeapAdjustmentAttribute , type );
234
+ * (LPDWORD )0x005235CE = atSCOPE ;
235
+ * (LPBYTE )0x005235D3 = 0x0052363E - (0x005235D3 + sizeof (BYTE ));
236
+
237
+ // TReplaceAttribute::IsEqual
238
+ // if (context != X->context) return FALSE;
239
+ * (LPBYTE )0x00527250 = JNZ_SHORT ;
240
+ * (LPWORD )0x00527251 = 0x0052726A - (0x00527251 + sizeof (BYTE ));
241
+ * (LPWORD )0x00527252 = BSWAP16 (0x8B47 );// mov eax, dword ptr [edi + ...
242
+ * (LPBYTE )0x00527254 = offsetof(TReplaceAttribute , context );
243
+ * (LPBYTE )0x00527255 = 0x8B ;// mov ecx, dword ptr [ebp +
244
+ * (LPWORD )0x00527256 = BSWAP16 (0x4D0C );// 0x0C]
245
+ * (LPWORD )0x00527258 = BSWAP16 (0x8B51 );// mov edx, dword ptr [ecx + ...
246
+ * (LPBYTE )0x0052725A = offsetof(TReplaceAttribute , context );
247
+ * (LPBYTE )0x0052725B = 0x3B ;// cmp eax, edx
248
+ * (LPWORD )0x0052725C = BSWAP16 (0xC2 << 8 | JNZ_SHORT );
249
+
250
+ // TDirAttribute::IsEqual
251
+ // if (identity != X->identity) return FALSE;
252
+ * (LPBYTE )0x00527403 = JNZ_SHORT ;
253
+ * (LPBYTE )0x00527404 = 0x00527415 - (0x00527404 + sizeof (BYTE ));
254
+ * (LPBYTE )0x00527405 = 0x8B ;// mov ecx,
255
+ * (LPBYTE )0x00527406 = 0x48 ;// [eax + ...
256
+ * (LPBYTE )0x00527407 = offsetof(TDirAttribute , identity );
257
+ * (LPWORD )0x00527408 = BSWAP16 (0x3B4A );// cmp ecx, [edx + ..
258
+ * (LPBYTE )0x0052740A = offsetof(TDirAttribute , identity );
259
+ * (LPBYTE )0x0052740B = JNZ_SHORT ;
91
260
}
0 commit comments