annotate Allocator.cpp @ 463:f7b91ef98ab2

shopgenerators done, except config tables
author Gloval
date Mon, 25 Feb 2013 08:30:49 +0400
parents 2bc1c8d68f41
children 2dfb67633b01
rev   line source
0
Ritor1
parents:
diff changeset
1 #include <string.h>
Ritor1
parents:
diff changeset
2 #include <stdio.h>
Ritor1
parents:
diff changeset
3 #include "OSAPI.h"
Ritor1
parents:
diff changeset
4
Ritor1
parents:
diff changeset
5 #include "Allocator.h"
Ritor1
parents:
diff changeset
6
Ritor1
parents:
diff changeset
7 #include "mm7_data.h"
Ritor1
parents:
diff changeset
8
Ritor1
parents:
diff changeset
9
Ritor1
parents:
diff changeset
10
Ritor1
parents:
diff changeset
11 Allocator *pAllocator; // idb
Ritor1
parents:
diff changeset
12
Ritor1
parents:
diff changeset
13
Ritor1
parents:
diff changeset
14
Ritor1
parents:
diff changeset
15
Ritor1
parents:
diff changeset
16
Ritor1
parents:
diff changeset
17 void __fastcall CheckMemoryAccessibility(void *pBase, DWORD uSize);
Ritor1
parents:
diff changeset
18
Ritor1
parents:
diff changeset
19
Ritor1
parents:
diff changeset
20
Ritor1
parents:
diff changeset
21 //----- (00426755) --------------------------------------------------------
Ritor1
parents:
diff changeset
22 void *Allocator::AllocNamedChunk(const void *pPrevPtrValue, unsigned int uSize, const char *pName)
Ritor1
parents:
diff changeset
23 {
Ritor1
parents:
diff changeset
24 //Allocator *v4; // esi@1
Ritor1
parents:
diff changeset
25 unsigned int v5; // eax@7
Ritor1
parents:
diff changeset
26 void *result; // eax@8
363
2bc1c8d68f41 Allocator and SpellCost Tip
Gloval
parents: 0
diff changeset
27 // unsigned int *pNumBuffersUsed; // ebx@12
0
Ritor1
parents:
diff changeset
28 unsigned int v8; // edi@15
Ritor1
parents:
diff changeset
29 char v9; // zf@15
Ritor1
parents:
diff changeset
30 int v10; // eax@16
Ritor1
parents:
diff changeset
31 void **v11; // ebx@19
Ritor1
parents:
diff changeset
32 void *v12; // eax@22
Ritor1
parents:
diff changeset
33 unsigned int Size; // [sp+14h] [bp+Ch]@16
Ritor1
parents:
diff changeset
34
363
2bc1c8d68f41 Allocator and SpellCost Tip
Gloval
parents: 0
diff changeset
35 int aligned_size;
2bc1c8d68f41 Allocator and SpellCost Tip
Gloval
parents: 0
diff changeset
36
2bc1c8d68f41 Allocator and SpellCost Tip
Gloval
parents: 0
diff changeset
37
2bc1c8d68f41 Allocator and SpellCost Tip
Gloval
parents: 0
diff changeset
38 if ( pPrevPtrValue && !aborting_app )
2bc1c8d68f41 Allocator and SpellCost Tip
Gloval
parents: 0
diff changeset
39 AbortWithError();
2bc1c8d68f41 Allocator and SpellCost Tip
Gloval
parents: 0
diff changeset
40 if ( !bBigBufferAllocated && !aborting_app )
2bc1c8d68f41 Allocator and SpellCost Tip
Gloval
parents: 0
diff changeset
41 AbortWithError();
2bc1c8d68f41 Allocator and SpellCost Tip
Gloval
parents: 0
diff changeset
42
2bc1c8d68f41 Allocator and SpellCost Tip
Gloval
parents: 0
diff changeset
43 if (!uSize)
2bc1c8d68f41 Allocator and SpellCost Tip
Gloval
parents: 0
diff changeset
44 return 0;
2bc1c8d68f41 Allocator and SpellCost Tip
Gloval
parents: 0
diff changeset
45
2bc1c8d68f41 Allocator and SpellCost Tip
Gloval
parents: 0
diff changeset
46 if (((uSize & 0x80000000u) != 0) && !aborting_app)
2bc1c8d68f41 Allocator and SpellCost Tip
Gloval
parents: 0
diff changeset
47 AbortWithError();
2bc1c8d68f41 Allocator and SpellCost Tip
Gloval
parents: 0
diff changeset
48
2bc1c8d68f41 Allocator and SpellCost Tip
Gloval
parents: 0
diff changeset
49 if (uNumBuffersUsed == 6000 && !aborting_app)
2bc1c8d68f41 Allocator and SpellCost Tip
Gloval
parents: 0
diff changeset
50 AbortWithError();
2bc1c8d68f41 Allocator and SpellCost Tip
Gloval
parents: 0
diff changeset
51
2bc1c8d68f41 Allocator and SpellCost Tip
Gloval
parents: 0
diff changeset
52 ++uNumBuffersUsed;
2bc1c8d68f41 Allocator and SpellCost Tip
Gloval
parents: 0
diff changeset
53
2bc1c8d68f41 Allocator and SpellCost Tip
Gloval
parents: 0
diff changeset
54 if (!bUseBigBuffer)
2bc1c8d68f41 Allocator and SpellCost Tip
Gloval
parents: 0
diff changeset
55 {
2bc1c8d68f41 Allocator and SpellCost Tip
Gloval
parents: 0
diff changeset
56 pMemoryBuffers[uNumBuffersUsed] = malloc(uSize);
2bc1c8d68f41 Allocator and SpellCost Tip
Gloval
parents: 0
diff changeset
57 if (pMemoryBuffers[uNumBuffersUsed])
2bc1c8d68f41 Allocator and SpellCost Tip
Gloval
parents: 0
diff changeset
58 uMemoryBuffersSizes[uNumBuffersUsed] = uSize;
2bc1c8d68f41 Allocator and SpellCost Tip
Gloval
parents: 0
diff changeset
59 else
2bc1c8d68f41 Allocator and SpellCost Tip
Gloval
parents: 0
diff changeset
60 {
2bc1c8d68f41 Allocator and SpellCost Tip
Gloval
parents: 0
diff changeset
61 if ( !aborting_app )
2bc1c8d68f41 Allocator and SpellCost Tip
Gloval
parents: 0
diff changeset
62 AbortWithError();
2bc1c8d68f41 Allocator and SpellCost Tip
Gloval
parents: 0
diff changeset
63 }
2bc1c8d68f41 Allocator and SpellCost Tip
Gloval
parents: 0
diff changeset
64 }
2bc1c8d68f41 Allocator and SpellCost Tip
Gloval
parents: 0
diff changeset
65 else
2bc1c8d68f41 Allocator and SpellCost Tip
Gloval
parents: 0
diff changeset
66 {
2bc1c8d68f41 Allocator and SpellCost Tip
Gloval
parents: 0
diff changeset
67
2bc1c8d68f41 Allocator and SpellCost Tip
Gloval
parents: 0
diff changeset
68 aligned_size =(uSize&0xFFFFFFFC) + 4;
2bc1c8d68f41 Allocator and SpellCost Tip
Gloval
parents: 0
diff changeset
69
2bc1c8d68f41 Allocator and SpellCost Tip
Gloval
parents: 0
diff changeset
70 if ((uNextFreeOffsetInBigBuffer +aligned_size) > uBigBufferSizeAligned)
2bc1c8d68f41 Allocator and SpellCost Tip
Gloval
parents: 0
diff changeset
71 {
2bc1c8d68f41 Allocator and SpellCost Tip
Gloval
parents: 0
diff changeset
72 printf("Id: %s Size: %i", pName, aligned_size);
2bc1c8d68f41 Allocator and SpellCost Tip
Gloval
parents: 0
diff changeset
73 CreateFileDump( "Memory");
2bc1c8d68f41 Allocator and SpellCost Tip
Gloval
parents: 0
diff changeset
74 if ( !aborting_app )
2bc1c8d68f41 Allocator and SpellCost Tip
Gloval
parents: 0
diff changeset
75 AbortWithError();
2bc1c8d68f41 Allocator and SpellCost Tip
Gloval
parents: 0
diff changeset
76 }
2bc1c8d68f41 Allocator and SpellCost Tip
Gloval
parents: 0
diff changeset
77
2bc1c8d68f41 Allocator and SpellCost Tip
Gloval
parents: 0
diff changeset
78 pMemoryBuffers[uNumBuffersUsed] = (char *)(pBigBufferAligned) + uNextFreeOffsetInBigBuffer;
2bc1c8d68f41 Allocator and SpellCost Tip
Gloval
parents: 0
diff changeset
79 uMemoryBuffersSizes[uNumBuffersUsed] =aligned_size;
2bc1c8d68f41 Allocator and SpellCost Tip
Gloval
parents: 0
diff changeset
80
2bc1c8d68f41 Allocator and SpellCost Tip
Gloval
parents: 0
diff changeset
81 if (pName)
2bc1c8d68f41 Allocator and SpellCost Tip
Gloval
parents: 0
diff changeset
82 strncpy(pMemoryBuffersNames[uNumBuffersUsed], pName, 11);
2bc1c8d68f41 Allocator and SpellCost Tip
Gloval
parents: 0
diff changeset
83 uNextFreeOffsetInBigBuffer += aligned_size;
2bc1c8d68f41 Allocator and SpellCost Tip
Gloval
parents: 0
diff changeset
84 }
2bc1c8d68f41 Allocator and SpellCost Tip
Gloval
parents: 0
diff changeset
85 return pMemoryBuffers[uNumBuffersUsed];
2bc1c8d68f41 Allocator and SpellCost Tip
Gloval
parents: 0
diff changeset
86
2bc1c8d68f41 Allocator and SpellCost Tip
Gloval
parents: 0
diff changeset
87 /*
0
Ritor1
parents:
diff changeset
88 //v4 = this;
Ritor1
parents:
diff changeset
89 if ( pPrevPtrValue && !aborting_app )
Ritor1
parents:
diff changeset
90 AbortWithError();
Ritor1
parents:
diff changeset
91 if ( !bBigBufferAllocated && !aborting_app )
Ritor1
parents:
diff changeset
92 AbortWithError();
Ritor1
parents:
diff changeset
93 v5 = uSize;
Ritor1
parents:
diff changeset
94 if ( uSize )
Ritor1
parents:
diff changeset
95 {
Ritor1
parents:
diff changeset
96 if ( (uSize & 0x80000000u) != 0 && !aborting_app )
Ritor1
parents:
diff changeset
97 {
Ritor1
parents:
diff changeset
98 AbortWithError();
Ritor1
parents:
diff changeset
99 v5 = uSize;
Ritor1
parents:
diff changeset
100 }
Ritor1
parents:
diff changeset
101 pNumBuffersUsed = &uNumBuffersUsed;
Ritor1
parents:
diff changeset
102 if (uNumBuffersUsed == 6000 && !aborting_app)
Ritor1
parents:
diff changeset
103 {
Ritor1
parents:
diff changeset
104 AbortWithError();
Ritor1
parents:
diff changeset
105 v5 = uSize;
Ritor1
parents:
diff changeset
106 }
Ritor1
parents:
diff changeset
107 v8 = *pNumBuffersUsed;
Ritor1
parents:
diff changeset
108 v9 = bUseBigBuffer == 0;
Ritor1
parents:
diff changeset
109 ++*pNumBuffersUsed;
Ritor1
parents:
diff changeset
110 if ( v9 )
Ritor1
parents:
diff changeset
111 {
Ritor1
parents:
diff changeset
112 v12 = malloc(v5);
Ritor1
parents:
diff changeset
113 v11 = &pMemoryBuffers[v8];
Ritor1
parents:
diff changeset
114 *v11 = v12;
Ritor1
parents:
diff changeset
115 if ( v12 )
Ritor1
parents:
diff changeset
116 {
Ritor1
parents:
diff changeset
117 uMemoryBuffersSizes[v8] = uSize;
Ritor1
parents:
diff changeset
118 }
Ritor1
parents:
diff changeset
119 else
Ritor1
parents:
diff changeset
120 {
Ritor1
parents:
diff changeset
121 if ( !aborting_app )
Ritor1
parents:
diff changeset
122 AbortWithError();
Ritor1
parents:
diff changeset
123 }
Ritor1
parents:
diff changeset
124 }
Ritor1
parents:
diff changeset
125 else
Ritor1
parents:
diff changeset
126 {
Ritor1
parents:
diff changeset
127 LOBYTE(v5) = v5 & 0xFC;
Ritor1
parents:
diff changeset
128 v10 = v5 + 4;
Ritor1
parents:
diff changeset
129 Size = v10;
Ritor1
parents:
diff changeset
130 if ( v10 + uNextFreeOffsetInBigBuffer > uBigBufferSizeAligned )
Ritor1
parents:
diff changeset
131 {
Ritor1
parents:
diff changeset
132 printf("Id: %s Size: %i\n", pName, v10);
Ritor1
parents:
diff changeset
133 CreateFileDump("Memory");
Ritor1
parents:
diff changeset
134 if ( !aborting_app )
Ritor1
parents:
diff changeset
135 AbortWithError();
Ritor1
parents:
diff changeset
136 }
Ritor1
parents:
diff changeset
137 v11 = &pMemoryBuffers[v8];
Ritor1
parents:
diff changeset
138 *v11 = (char *)pBigMemoryBuffer + uNextFreeOffsetInBigBuffer;
Ritor1
parents:
diff changeset
139 uMemoryBuffersSizes[v8] = Size;
Ritor1
parents:
diff changeset
140 if (pName)
Ritor1
parents:
diff changeset
141 strncpy(pMemoryBuffersNames[v8], pName, 11);
Ritor1
parents:
diff changeset
142 uNextFreeOffsetInBigBuffer += Size;
Ritor1
parents:
diff changeset
143 }
Ritor1
parents:
diff changeset
144 result = *v11;
Ritor1
parents:
diff changeset
145 }
Ritor1
parents:
diff changeset
146 else
Ritor1
parents:
diff changeset
147 {
Ritor1
parents:
diff changeset
148 result = 0;
Ritor1
parents:
diff changeset
149 }
363
2bc1c8d68f41 Allocator and SpellCost Tip
Gloval
parents: 0
diff changeset
150 return result;*/
0
Ritor1
parents:
diff changeset
151 }
Ritor1
parents:
diff changeset
152 // 720018: using guessed type int aborting_app;
Ritor1
parents:
diff changeset
153
Ritor1
parents:
diff changeset
154
Ritor1
parents:
diff changeset
155
Ritor1
parents:
diff changeset
156 //----- (004266CD) --------------------------------------------------------
Ritor1
parents:
diff changeset
157 bool Allocator::Initialize(unsigned int uNumKBytes)
Ritor1
parents:
diff changeset
158 {
Ritor1
parents:
diff changeset
159 if (bBigBufferAllocated)
Ritor1
parents:
diff changeset
160 return false;
Ritor1
parents:
diff changeset
161
Ritor1
parents:
diff changeset
162 if (!uNumKBytes)
Ritor1
parents:
diff changeset
163 return false;
Ritor1
parents:
diff changeset
164
Ritor1
parents:
diff changeset
165 pBigMemoryBuffer = malloc(uNumKBytes * 1024);
Ritor1
parents:
diff changeset
166 if (!pBigMemoryBuffer)
Ritor1
parents:
diff changeset
167 return false;
Ritor1
parents:
diff changeset
168
363
2bc1c8d68f41 Allocator and SpellCost Tip
Gloval
parents: 0
diff changeset
169 pBigBufferAligned = (void *)((unsigned int)(pBigMemoryBuffer) & 0xFFFF0000 + 4096);
2bc1c8d68f41 Allocator and SpellCost Tip
Gloval
parents: 0
diff changeset
170 //(char *)pBigMemoryBuffer + -((unsigned __int16)pBigMemoryBuffer & 0xFFF) + 4096;
0
Ritor1
parents:
diff changeset
171 uBigBufferSizeAligned = (uNumKBytes * 1024) - 4096;
Ritor1
parents:
diff changeset
172
Ritor1
parents:
diff changeset
173 uNumBuffersUsed = 0;
Ritor1
parents:
diff changeset
174 uNextFreeOffsetInBigBuffer = 0;
Ritor1
parents:
diff changeset
175
Ritor1
parents:
diff changeset
176 bUseBigBuffer = true;
Ritor1
parents:
diff changeset
177 return bBigBufferAllocated = true;
Ritor1
parents:
diff changeset
178 }
Ritor1
parents:
diff changeset
179
Ritor1
parents:
diff changeset
180
Ritor1
parents:
diff changeset
181 //----- (00426474) --------------------------------------------------------
Ritor1
parents:
diff changeset
182 void Allocator::FreeChunk(void *ptr)
Ritor1
parents:
diff changeset
183 {
Ritor1
parents:
diff changeset
184 Allocator *v2; // esi@1
Ritor1
parents:
diff changeset
185 unsigned int v3; // eax@5
Ritor1
parents:
diff changeset
186 signed int i; // edi@5
Ritor1
parents:
diff changeset
187 unsigned int v5; // eax@13
Ritor1
parents:
diff changeset
188 signed int v6; // ecx@16
Ritor1
parents:
diff changeset
189 signed int j; // edx@16
Ritor1
parents:
diff changeset
190 char v8; // zf@20
Ritor1
parents:
diff changeset
191
363
2bc1c8d68f41 Allocator and SpellCost Tip
Gloval
parents: 0
diff changeset
192
2bc1c8d68f41 Allocator and SpellCost Tip
Gloval
parents: 0
diff changeset
193
2bc1c8d68f41 Allocator and SpellCost Tip
Gloval
parents: 0
diff changeset
194 unsigned int uBuffindx;
2bc1c8d68f41 Allocator and SpellCost Tip
Gloval
parents: 0
diff changeset
195 unsigned int indx;
2bc1c8d68f41 Allocator and SpellCost Tip
Gloval
parents: 0
diff changeset
196
2bc1c8d68f41 Allocator and SpellCost Tip
Gloval
parents: 0
diff changeset
197 if (ptr)
2bc1c8d68f41 Allocator and SpellCost Tip
Gloval
parents: 0
diff changeset
198 {
2bc1c8d68f41 Allocator and SpellCost Tip
Gloval
parents: 0
diff changeset
199 if ((!bBigBufferAllocated)&& (!aborting_app ))
2bc1c8d68f41 Allocator and SpellCost Tip
Gloval
parents: 0
diff changeset
200 AbortWithError();
2bc1c8d68f41 Allocator and SpellCost Tip
Gloval
parents: 0
diff changeset
201 for (indx = 0; indx <=uNumBuffersUsed; ++indx)
2bc1c8d68f41 Allocator and SpellCost Tip
Gloval
parents: 0
diff changeset
202 if (pMemoryBuffers[indx] == ptr)
2bc1c8d68f41 Allocator and SpellCost Tip
Gloval
parents: 0
diff changeset
203 break;
2bc1c8d68f41 Allocator and SpellCost Tip
Gloval
parents: 0
diff changeset
204 // if ((indx>uNumBuffersUsed)&& !aborting_app )
2bc1c8d68f41 Allocator and SpellCost Tip
Gloval
parents: 0
diff changeset
205 // AbortWithError(); to detect memory problems - uncomment
2bc1c8d68f41 Allocator and SpellCost Tip
Gloval
parents: 0
diff changeset
206 if (!bUseBigBuffer)
2bc1c8d68f41 Allocator and SpellCost Tip
Gloval
parents: 0
diff changeset
207 free(pMemoryBuffers[indx]);
2bc1c8d68f41 Allocator and SpellCost Tip
Gloval
parents: 0
diff changeset
208 pMemoryBuffers[indx] = NULL;
2bc1c8d68f41 Allocator and SpellCost Tip
Gloval
parents: 0
diff changeset
209 uMemoryBuffersSizes[indx] = 0;
2bc1c8d68f41 Allocator and SpellCost Tip
Gloval
parents: 0
diff changeset
210 pMemoryBuffersNames[indx][0] = 0;
2bc1c8d68f41 Allocator and SpellCost Tip
Gloval
parents: 0
diff changeset
211 if (indx == (uNumBuffersUsed-1))
2bc1c8d68f41 Allocator and SpellCost Tip
Gloval
parents: 0
diff changeset
212 {
2bc1c8d68f41 Allocator and SpellCost Tip
Gloval
parents: 0
diff changeset
213 if (indx>0)
2bc1c8d68f41 Allocator and SpellCost Tip
Gloval
parents: 0
diff changeset
214 {
2bc1c8d68f41 Allocator and SpellCost Tip
Gloval
parents: 0
diff changeset
215 uBuffindx = 0;
2bc1c8d68f41 Allocator and SpellCost Tip
Gloval
parents: 0
diff changeset
216 for (j = 0; j < uNumBuffersUsed-1; ++j)
2bc1c8d68f41 Allocator and SpellCost Tip
Gloval
parents: 0
diff changeset
217 {
2bc1c8d68f41 Allocator and SpellCost Tip
Gloval
parents: 0
diff changeset
218 if (pMemoryBuffers[j])
2bc1c8d68f41 Allocator and SpellCost Tip
Gloval
parents: 0
diff changeset
219 uBuffindx = j;
2bc1c8d68f41 Allocator and SpellCost Tip
Gloval
parents: 0
diff changeset
220 }
2bc1c8d68f41 Allocator and SpellCost Tip
Gloval
parents: 0
diff changeset
221 uNumBuffersUsed = uBuffindx + 1;
2bc1c8d68f41 Allocator and SpellCost Tip
Gloval
parents: 0
diff changeset
222 if (bUseBigBuffer)
2bc1c8d68f41 Allocator and SpellCost Tip
Gloval
parents: 0
diff changeset
223 uNextFreeOffsetInBigBuffer =
2bc1c8d68f41 Allocator and SpellCost Tip
Gloval
parents: 0
diff changeset
224 ((long)((char*)pMemoryBuffers[uBuffindx] -(char*)pBigBufferAligned)+ uMemoryBuffersSizes[uBuffindx]);
2bc1c8d68f41 Allocator and SpellCost Tip
Gloval
parents: 0
diff changeset
225 }
2bc1c8d68f41 Allocator and SpellCost Tip
Gloval
parents: 0
diff changeset
226 else
2bc1c8d68f41 Allocator and SpellCost Tip
Gloval
parents: 0
diff changeset
227 {
2bc1c8d68f41 Allocator and SpellCost Tip
Gloval
parents: 0
diff changeset
228 uNumBuffersUsed = 0;
2bc1c8d68f41 Allocator and SpellCost Tip
Gloval
parents: 0
diff changeset
229 uNextFreeOffsetInBigBuffer = 0;
2bc1c8d68f41 Allocator and SpellCost Tip
Gloval
parents: 0
diff changeset
230 }
2bc1c8d68f41 Allocator and SpellCost Tip
Gloval
parents: 0
diff changeset
231 }
2bc1c8d68f41 Allocator and SpellCost Tip
Gloval
parents: 0
diff changeset
232 }
2bc1c8d68f41 Allocator and SpellCost Tip
Gloval
parents: 0
diff changeset
233
2bc1c8d68f41 Allocator and SpellCost Tip
Gloval
parents: 0
diff changeset
234 /*
0
Ritor1
parents:
diff changeset
235 v2 = this;
Ritor1
parents:
diff changeset
236 if ( ptr )
Ritor1
parents:
diff changeset
237 {
Ritor1
parents:
diff changeset
238 if ( !this->bBigBufferAllocated && !aborting_app )
Ritor1
parents:
diff changeset
239 AbortWithError();
Ritor1
parents:
diff changeset
240 v3 = v2->uNumBuffersUsed;
Ritor1
parents:
diff changeset
241 for ( i = 0; i < (signed int)v3; ++i )
Ritor1
parents:
diff changeset
242 {
Ritor1
parents:
diff changeset
243 if ( v2->pMemoryBuffers[i] == ptr )
Ritor1
parents:
diff changeset
244 break;
Ritor1
parents:
diff changeset
245 }
Ritor1
parents:
diff changeset
246 if ( i >= (signed int)v3 && !aborting_app )
Ritor1
parents:
diff changeset
247 AbortWithError();
Ritor1
parents:
diff changeset
248 if ( !v2->bUseBigBuffer )
Ritor1
parents:
diff changeset
249 free(v2->pMemoryBuffers[i]);
Ritor1
parents:
diff changeset
250 v2->pMemoryBuffers[i] = 0;
Ritor1
parents:
diff changeset
251 v2->uMemoryBuffersSizes[i] = 0;
Ritor1
parents:
diff changeset
252 LOBYTE(v2->pMemoryBuffers[3 * i + 12000]) = 0;
Ritor1
parents:
diff changeset
253 v5 = v2->uNumBuffersUsed;
Ritor1
parents:
diff changeset
254 if ( i == v5 - 1 )
Ritor1
parents:
diff changeset
255 {
Ritor1
parents:
diff changeset
256 if ( i )
Ritor1
parents:
diff changeset
257 {
Ritor1
parents:
diff changeset
258 v6 = 0;
Ritor1
parents:
diff changeset
259 for ( j = 0; j < (signed int)v5; ++j )
Ritor1
parents:
diff changeset
260 {
Ritor1
parents:
diff changeset
261 if ( v2->pMemoryBuffers[j] )
Ritor1
parents:
diff changeset
262 v6 = j;
Ritor1
parents:
diff changeset
263 }
Ritor1
parents:
diff changeset
264 v8 = v2->bUseBigBuffer == 0;
Ritor1
parents:
diff changeset
265 v2->uNumBuffersUsed = v6 + 1;
Ritor1
parents:
diff changeset
266 if ( !v8 )
Ritor1
parents:
diff changeset
267 v2->uNextFreeOffsetInBigBuffer = (char *)v2->pMemoryBuffers[v6]
Ritor1
parents:
diff changeset
268 + v2->uMemoryBuffersSizes[v6]
Ritor1
parents:
diff changeset
269 - v2->pBigMemoryBuffer;
Ritor1
parents:
diff changeset
270 }
Ritor1
parents:
diff changeset
271 else
Ritor1
parents:
diff changeset
272 {
Ritor1
parents:
diff changeset
273 v2->uNextFreeOffsetInBigBuffer = 0;
Ritor1
parents:
diff changeset
274 v2->uNumBuffersUsed = 0;
Ritor1
parents:
diff changeset
275 }
Ritor1
parents:
diff changeset
276 }
363
2bc1c8d68f41 Allocator and SpellCost Tip
Gloval
parents: 0
diff changeset
277 }*/
0
Ritor1
parents:
diff changeset
278 }
Ritor1
parents:
diff changeset
279 // 720018: using guessed type int aborting_app;
Ritor1
parents:
diff changeset
280
Ritor1
parents:
diff changeset
281
Ritor1
parents:
diff changeset
282
Ritor1
parents:
diff changeset
283 //----- (00426429) --------------------------------------------------------
Ritor1
parents:
diff changeset
284 Allocator::Allocator()
Ritor1
parents:
diff changeset
285 {
Ritor1
parents:
diff changeset
286 Allocator *v1; // eax@1
Ritor1
parents:
diff changeset
287 signed int v2; // ecx@1
Ritor1
parents:
diff changeset
288 int v3; // edx@1
Ritor1
parents:
diff changeset
289
Ritor1
parents:
diff changeset
290 v1 = this;
Ritor1
parents:
diff changeset
291 v2 = 0;
Ritor1
parents:
diff changeset
292 v1->uBigBufferSizeAligned = 0;
Ritor1
parents:
diff changeset
293 v1->bBigBufferAllocated = 0;
Ritor1
parents:
diff changeset
294 v3 = (int)v1->pMemoryBuffersNames;
Ritor1
parents:
diff changeset
295 do
Ritor1
parents:
diff changeset
296 {
Ritor1
parents:
diff changeset
297 v1->pMemoryBuffers[v2] = 0;
Ritor1
parents:
diff changeset
298 v1->uMemoryBuffersSizes[v2] = 0;
Ritor1
parents:
diff changeset
299 *(char *)v3 = 0;
Ritor1
parents:
diff changeset
300 ++v2;
Ritor1
parents:
diff changeset
301 v3 += 12;
Ritor1
parents:
diff changeset
302 }
Ritor1
parents:
diff changeset
303 while ( v2 < 6000 );
Ritor1
parents:
diff changeset
304 v1->uDumpsCount = 0;
Ritor1
parents:
diff changeset
305 }
Ritor1
parents:
diff changeset
306
Ritor1
parents:
diff changeset
307
Ritor1
parents:
diff changeset
308 //----- (0042654C) --------------------------------------------------------
Ritor1
parents:
diff changeset
309 bool Allocator::CreateFileDump(const char *a1)
Ritor1
parents:
diff changeset
310 {
Ritor1
parents:
diff changeset
311 Allocator *v2; // esi@1
Ritor1
parents:
diff changeset
312 unsigned int v3; // ST44_4@1
Ritor1
parents:
diff changeset
313 FILE *v4; // eax@1
Ritor1
parents:
diff changeset
314 FILE *v5; // edi@1
Ritor1
parents:
diff changeset
315 bool result; // eax@2
Ritor1
parents:
diff changeset
316 unsigned int v7; // ecx@5
Ritor1
parents:
diff changeset
317 int v8; // edx@5
Ritor1
parents:
diff changeset
318 int v9; // eax@6
Ritor1
parents:
diff changeset
319 int v10; // eax@8
Ritor1
parents:
diff changeset
320 int v11; // ecx@8
Ritor1
parents:
diff changeset
321 signed int v12; // ebx@8
Ritor1
parents:
diff changeset
322 signed int v13; // ebx@10
Ritor1
parents:
diff changeset
323 struct _MEMORYSTATUS memstat; // [sp+8h] [bp-38h]@5
Ritor1
parents:
diff changeset
324 char Filename[20]; // [sp+28h] [bp-18h]@1
Ritor1
parents:
diff changeset
325 unsigned int *v16; // [sp+3Ch] [bp-4h]@11
Ritor1
parents:
diff changeset
326 int a1a; // [sp+48h] [bp+8h]@11
Ritor1
parents:
diff changeset
327
Ritor1
parents:
diff changeset
328 v2 = this;
Ritor1
parents:
diff changeset
329 v3 = this->uDumpsCount;
Ritor1
parents:
diff changeset
330 this->uDumpsCount = v3 + 1;
Ritor1
parents:
diff changeset
331 sprintf(Filename, "Mem%03i.txt", v3);
Ritor1
parents:
diff changeset
332 v4 = fopen(Filename, "w");
Ritor1
parents:
diff changeset
333 v5 = v4;
Ritor1
parents:
diff changeset
334 if ( v4 )
Ritor1
parents:
diff changeset
335 {
Ritor1
parents:
diff changeset
336 if ( a1 )
Ritor1
parents:
diff changeset
337 fprintf(v4, "%s\n\n", a1);
Ritor1
parents:
diff changeset
338 fprintf(v5, "Windows Memory Status");
Ritor1
parents:
diff changeset
339 GlobalMemoryStatus(&memstat);
Ritor1
parents:
diff changeset
340 fprintf(v5, "dwLength: %d\n\n", memstat.dwLength);
Ritor1
parents:
diff changeset
341 fprintf(v5, "dwMemoryLoad: %d\n", memstat.dwMemoryLoad);
Ritor1
parents:
diff changeset
342 fprintf(v5, "dwTotalPhys: %d\n", memstat.dwTotalPhys);
Ritor1
parents:
diff changeset
343 fprintf(v5, "dwAvailPhys: %d\n", memstat.dwAvailPhys);
Ritor1
parents:
diff changeset
344 fprintf(v5, "dwTotalPageFile: %d\n", memstat.dwTotalPageFile);
Ritor1
parents:
diff changeset
345 fprintf(v5, "dwAvailPageFile: %d\n", memstat.dwAvailPageFile);
Ritor1
parents:
diff changeset
346 fprintf(v5, "dwTotalVirtual: %d\n", memstat.dwTotalVirtual);
Ritor1
parents:
diff changeset
347 fprintf(v5, "dwAvailVirtual: %d\n\n\n", memstat.dwAvailVirtual);
Ritor1
parents:
diff changeset
348 v7 = v2->uNumBuffersUsed;
Ritor1
parents:
diff changeset
349 v8 = 0;
Ritor1
parents:
diff changeset
350 if ( (signed int)v7 > 0 )
Ritor1
parents:
diff changeset
351 {
Ritor1
parents:
diff changeset
352 v9 = (int)v2->uMemoryBuffersSizes;
Ritor1
parents:
diff changeset
353 do
Ritor1
parents:
diff changeset
354 {
Ritor1
parents:
diff changeset
355 v8 += *(int *)v9;
Ritor1
parents:
diff changeset
356 v9 += 4;
Ritor1
parents:
diff changeset
357 --v7;
Ritor1
parents:
diff changeset
358 }
Ritor1
parents:
diff changeset
359 while ( v7 );
Ritor1
parents:
diff changeset
360 }
Ritor1
parents:
diff changeset
361 v10 = 0;
Ritor1
parents:
diff changeset
362 v11 = (int)v2->uMemoryBuffersSizes;
Ritor1
parents:
diff changeset
363 v12 = 6000;
Ritor1
parents:
diff changeset
364 do
Ritor1
parents:
diff changeset
365 {
Ritor1
parents:
diff changeset
366 v10 += *(int *)v11;
Ritor1
parents:
diff changeset
367 v11 += 4;
Ritor1
parents:
diff changeset
368 --v12;
Ritor1
parents:
diff changeset
369 }
Ritor1
parents:
diff changeset
370 while ( v12 );
Ritor1
parents:
diff changeset
371 fprintf(v5, "Size: %i %i %i\n\n", v2->uNumBuffersUsed, v8, v10);
Ritor1
parents:
diff changeset
372 v13 = 0;
Ritor1
parents:
diff changeset
373 if ( (signed int)v2->uNumBuffersUsed > 0 )
Ritor1
parents:
diff changeset
374 {
Ritor1
parents:
diff changeset
375 v16 = v2->uMemoryBuffersSizes;
Ritor1
parents:
diff changeset
376 a1a = (int)v2->pMemoryBuffersNames;
Ritor1
parents:
diff changeset
377 do
Ritor1
parents:
diff changeset
378 {
Ritor1
parents:
diff changeset
379 fprintf(v5, "%10i %10i %s\n", v13, *v16, a1a);
Ritor1
parents:
diff changeset
380 a1a += 12;
Ritor1
parents:
diff changeset
381 ++v16;
Ritor1
parents:
diff changeset
382 ++v13;
Ritor1
parents:
diff changeset
383 }
Ritor1
parents:
diff changeset
384 while ( v13 < (signed int)v2->uNumBuffersUsed );
Ritor1
parents:
diff changeset
385 }
Ritor1
parents:
diff changeset
386 fclose(v5);
Ritor1
parents:
diff changeset
387 result = 0;
Ritor1
parents:
diff changeset
388 }
Ritor1
parents:
diff changeset
389 else
Ritor1
parents:
diff changeset
390 {
Ritor1
parents:
diff changeset
391 result = 1;
Ritor1
parents:
diff changeset
392 }
Ritor1
parents:
diff changeset
393 return result;
Ritor1
parents:
diff changeset
394 }
Ritor1
parents:
diff changeset
395
Ritor1
parents:
diff changeset
396
Ritor1
parents:
diff changeset
397
Ritor1
parents:
diff changeset
398
Ritor1
parents:
diff changeset
399
Ritor1
parents:
diff changeset
400
Ritor1
parents:
diff changeset
401
Ritor1
parents:
diff changeset
402
Ritor1
parents:
diff changeset
403 //----- (00426892) --------------------------------------------------------
Ritor1
parents:
diff changeset
404 static void __fastcall CheckMemoryAccessibility(void *pBase, DWORD uSize)
Ritor1
parents:
diff changeset
405 {
Ritor1
parents:
diff changeset
406 DWORD v2; // edi@1
Ritor1
parents:
diff changeset
407 DWORD i; // eax@1
Ritor1
parents:
diff changeset
408 struct _SYSTEM_INFO SystemInfo; // [sp+8h] [bp-24h]@1
Ritor1
parents:
diff changeset
409
Ritor1
parents:
diff changeset
410 v2 = uSize;
Ritor1
parents:
diff changeset
411 GetSystemInfo(&SystemInfo);
Ritor1
parents:
diff changeset
412 for ( i = 16 * SystemInfo.dwPageSize; i < v2; i += SystemInfo.dwPageSize )
Ritor1
parents:
diff changeset
413 ;
Ritor1
parents:
diff changeset
414 }