annotate Allocator.cpp @ 114:8e802a11b20d

Merge
author Nomad
date Wed, 07 Nov 2012 20:26:28 +0200
parents a84fb3752681
children
rev   line source
0
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
1 #include <string.h>
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
2 #include <stdio.h>
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
3 #include "OSAPI.h"
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
4
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
5 #include "Allocator.h"
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
6
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
7 #include "mm7_data.h"
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
8
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
9
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
10
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
11 Allocator *pAllocator; // idb
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
12
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
13
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
14
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
15
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
16
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
17 void __fastcall CheckMemoryAccessibility(void *pBase, DWORD uSize);
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
18
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
19
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
20
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
21 //----- (00426755) --------------------------------------------------------
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
22 void *Allocator::AllocNamedChunk(const void *pPrevPtrValue, unsigned int uSize, const char *pName)
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
23 {
26
93bf1d5f6a6d Game loading.
Nomad
parents: 0
diff changeset
24 //Allocator *v4; // esi@1
0
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
25 unsigned int v5; // eax@7
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
26 void *result; // eax@8
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
27 unsigned int *pNumBuffersUsed; // ebx@12
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
28 unsigned int v8; // edi@15
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
29 char v9; // zf@15
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
30 int v10; // eax@16
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
31 void **v11; // ebx@19
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
32 void *v12; // eax@22
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
33 unsigned int Size; // [sp+14h] [bp+Ch]@16
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
34
26
93bf1d5f6a6d Game loading.
Nomad
parents: 0
diff changeset
35 //v4 = this;
0
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
36 if ( pPrevPtrValue && !aborting_app )
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
37 AbortWithError();
26
93bf1d5f6a6d Game loading.
Nomad
parents: 0
diff changeset
38 if ( !bBigBufferAllocated && !aborting_app )
0
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
39 AbortWithError();
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
40 v5 = uSize;
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
41 if ( uSize )
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
42 {
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
43 if ( (uSize & 0x80000000u) != 0 && !aborting_app )
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
44 {
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
45 AbortWithError();
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
46 v5 = uSize;
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
47 }
26
93bf1d5f6a6d Game loading.
Nomad
parents: 0
diff changeset
48 pNumBuffersUsed = &uNumBuffersUsed;
93bf1d5f6a6d Game loading.
Nomad
parents: 0
diff changeset
49 if (uNumBuffersUsed == 6000 && !aborting_app)
0
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
50 {
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
51 AbortWithError();
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
52 v5 = uSize;
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
53 }
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
54 v8 = *pNumBuffersUsed;
26
93bf1d5f6a6d Game loading.
Nomad
parents: 0
diff changeset
55 v9 = bUseBigBuffer == 0;
0
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
56 ++*pNumBuffersUsed;
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
57 if ( v9 )
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
58 {
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
59 v12 = malloc(v5);
26
93bf1d5f6a6d Game loading.
Nomad
parents: 0
diff changeset
60 v11 = &pMemoryBuffers[v8];
0
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
61 *v11 = v12;
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
62 if ( v12 )
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
63 {
26
93bf1d5f6a6d Game loading.
Nomad
parents: 0
diff changeset
64 uMemoryBuffersSizes[v8] = uSize;
0
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
65 }
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
66 else
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
67 {
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
68 if ( !aborting_app )
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
69 AbortWithError();
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
70 }
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
71 }
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
72 else
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
73 {
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
74 LOBYTE(v5) = v5 & 0xFC;
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
75 v10 = v5 + 4;
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
76 Size = v10;
26
93bf1d5f6a6d Game loading.
Nomad
parents: 0
diff changeset
77 if ( v10 + uNextFreeOffsetInBigBuffer > uBigBufferSizeAligned )
0
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
78 {
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
79 printf("Id: %s Size: %i\n", pName, v10);
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
80 CreateFileDump("Memory");
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
81 if ( !aborting_app )
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
82 AbortWithError();
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
83 }
26
93bf1d5f6a6d Game loading.
Nomad
parents: 0
diff changeset
84 v11 = &pMemoryBuffers[v8];
93bf1d5f6a6d Game loading.
Nomad
parents: 0
diff changeset
85 *v11 = (char *)pBigMemoryBuffer + uNextFreeOffsetInBigBuffer;
93bf1d5f6a6d Game loading.
Nomad
parents: 0
diff changeset
86 uMemoryBuffersSizes[v8] = Size;
93bf1d5f6a6d Game loading.
Nomad
parents: 0
diff changeset
87 if (pName)
93bf1d5f6a6d Game loading.
Nomad
parents: 0
diff changeset
88 strncpy(pMemoryBuffersNames[v8], pName, 11);
93bf1d5f6a6d Game loading.
Nomad
parents: 0
diff changeset
89 uNextFreeOffsetInBigBuffer += Size;
0
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
90 }
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
91 result = *v11;
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
92 }
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
93 else
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
94 {
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
95 result = 0;
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
96 }
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
97 return result;
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
98 }
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
99 // 720018: using guessed type int aborting_app;
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
100
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
101
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
102
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
103 //----- (004266CD) --------------------------------------------------------
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
104 bool Allocator::Initialize(unsigned int uNumKBytes)
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
105 {
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
106 if (bBigBufferAllocated)
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
107 return false;
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
108
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
109 if (!uNumKBytes)
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
110 return false;
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
111
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
112 pBigMemoryBuffer = malloc(uNumKBytes * 1024);
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
113 if (!pBigMemoryBuffer)
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
114 return false;
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
115
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
116 pBigBufferAligned = (char *)pBigMemoryBuffer + -((unsigned __int16)pBigMemoryBuffer & 0xFFF) + 4096;
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
117 uBigBufferSizeAligned = (uNumKBytes * 1024) - 4096;
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
118
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
119 uNumBuffersUsed = 0;
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
120 uNextFreeOffsetInBigBuffer = 0;
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
121
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
122 bUseBigBuffer = true;
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
123 return bBigBufferAllocated = true;
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
124 }
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
125
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
126
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
127 //----- (00426474) --------------------------------------------------------
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
128 void Allocator::FreeChunk(void *ptr)
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
129 {
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
130 Allocator *v2; // esi@1
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
131 unsigned int v3; // eax@5
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
132 signed int i; // edi@5
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
133 unsigned int v5; // eax@13
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
134 signed int v6; // ecx@16
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
135 signed int j; // edx@16
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
136 char v8; // zf@20
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
137
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
138 v2 = this;
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
139 if ( ptr )
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
140 {
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
141 if ( !this->bBigBufferAllocated && !aborting_app )
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
142 AbortWithError();
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
143 v3 = v2->uNumBuffersUsed;
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
144 for ( i = 0; i < (signed int)v3; ++i )
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
145 {
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
146 if ( v2->pMemoryBuffers[i] == ptr )
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
147 break;
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
148 }
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
149 if ( i >= (signed int)v3 && !aborting_app )
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
150 AbortWithError();
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
151 if ( !v2->bUseBigBuffer )
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
152 free(v2->pMemoryBuffers[i]);
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
153 v2->pMemoryBuffers[i] = 0;
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
154 v2->uMemoryBuffersSizes[i] = 0;
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
155 LOBYTE(v2->pMemoryBuffers[3 * i + 12000]) = 0;
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
156 v5 = v2->uNumBuffersUsed;
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
157 if ( i == v5 - 1 )
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
158 {
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
159 if ( i )
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
160 {
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
161 v6 = 0;
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
162 for ( j = 0; j < (signed int)v5; ++j )
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
163 {
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
164 if ( v2->pMemoryBuffers[j] )
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
165 v6 = j;
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
166 }
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
167 v8 = v2->bUseBigBuffer == 0;
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
168 v2->uNumBuffersUsed = v6 + 1;
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
169 if ( !v8 )
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
170 v2->uNextFreeOffsetInBigBuffer = (char *)v2->pMemoryBuffers[v6]
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
171 + v2->uMemoryBuffersSizes[v6]
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
172 - v2->pBigMemoryBuffer;
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
173 }
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
174 else
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
175 {
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
176 v2->uNextFreeOffsetInBigBuffer = 0;
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
177 v2->uNumBuffersUsed = 0;
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
178 }
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
179 }
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
180 }
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
181 }
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
182 // 720018: using guessed type int aborting_app;
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
183
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
184
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
185
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
186 //----- (00426429) --------------------------------------------------------
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
187 Allocator::Allocator()
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
188 {
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
189 Allocator *v1; // eax@1
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
190 signed int v2; // ecx@1
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
191 int v3; // edx@1
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
192
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
193 v1 = this;
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
194 v2 = 0;
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
195 v1->uBigBufferSizeAligned = 0;
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
196 v1->bBigBufferAllocated = 0;
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
197 v3 = (int)v1->pMemoryBuffersNames;
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
198 do
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
199 {
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
200 v1->pMemoryBuffers[v2] = 0;
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
201 v1->uMemoryBuffersSizes[v2] = 0;
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
202 *(char *)v3 = 0;
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
203 ++v2;
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
204 v3 += 12;
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
205 }
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
206 while ( v2 < 6000 );
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
207 v1->uDumpsCount = 0;
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
208 }
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
209
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
210
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
211 //----- (0042654C) --------------------------------------------------------
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
212 bool Allocator::CreateFileDump(const char *a1)
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
213 {
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
214 Allocator *v2; // esi@1
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
215 unsigned int v3; // ST44_4@1
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
216 FILE *v4; // eax@1
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
217 FILE *v5; // edi@1
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
218 bool result; // eax@2
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
219 unsigned int v7; // ecx@5
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
220 int v8; // edx@5
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
221 int v9; // eax@6
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
222 int v10; // eax@8
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
223 int v11; // ecx@8
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
224 signed int v12; // ebx@8
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
225 signed int v13; // ebx@10
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
226 struct _MEMORYSTATUS memstat; // [sp+8h] [bp-38h]@5
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
227 char Filename[20]; // [sp+28h] [bp-18h]@1
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
228 unsigned int *v16; // [sp+3Ch] [bp-4h]@11
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
229 int a1a; // [sp+48h] [bp+8h]@11
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
230
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
231 v2 = this;
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
232 v3 = this->uDumpsCount;
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
233 this->uDumpsCount = v3 + 1;
80
a84fb3752681 28.10.12
Ritor1
parents: 26
diff changeset
234 sprintf(Filename, "Mem%03i.txt", v3);
0
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
235 v4 = fopen(Filename, "w");
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
236 v5 = v4;
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
237 if ( v4 )
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
238 {
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
239 if ( a1 )
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
240 fprintf(v4, "%s\n\n", a1);
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
241 fprintf(v5, "Windows Memory Status");
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
242 GlobalMemoryStatus(&memstat);
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
243 fprintf(v5, "dwLength: %d\n\n", memstat.dwLength);
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
244 fprintf(v5, "dwMemoryLoad: %d\n", memstat.dwMemoryLoad);
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
245 fprintf(v5, "dwTotalPhys: %d\n", memstat.dwTotalPhys);
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
246 fprintf(v5, "dwAvailPhys: %d\n", memstat.dwAvailPhys);
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
247 fprintf(v5, "dwTotalPageFile: %d\n", memstat.dwTotalPageFile);
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
248 fprintf(v5, "dwAvailPageFile: %d\n", memstat.dwAvailPageFile);
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
249 fprintf(v5, "dwTotalVirtual: %d\n", memstat.dwTotalVirtual);
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
250 fprintf(v5, "dwAvailVirtual: %d\n\n\n", memstat.dwAvailVirtual);
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
251 v7 = v2->uNumBuffersUsed;
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
252 v8 = 0;
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
253 if ( (signed int)v7 > 0 )
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
254 {
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
255 v9 = (int)v2->uMemoryBuffersSizes;
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
256 do
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
257 {
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
258 v8 += *(int *)v9;
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
259 v9 += 4;
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
260 --v7;
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
261 }
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
262 while ( v7 );
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
263 }
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
264 v10 = 0;
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
265 v11 = (int)v2->uMemoryBuffersSizes;
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
266 v12 = 6000;
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
267 do
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
268 {
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
269 v10 += *(int *)v11;
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
270 v11 += 4;
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
271 --v12;
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
272 }
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
273 while ( v12 );
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
274 fprintf(v5, "Size: %i %i %i\n\n", v2->uNumBuffersUsed, v8, v10);
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
275 v13 = 0;
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
276 if ( (signed int)v2->uNumBuffersUsed > 0 )
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
277 {
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
278 v16 = v2->uMemoryBuffersSizes;
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
279 a1a = (int)v2->pMemoryBuffersNames;
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
280 do
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
281 {
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
282 fprintf(v5, "%10i %10i %s\n", v13, *v16, a1a);
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
283 a1a += 12;
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
284 ++v16;
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
285 ++v13;
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
286 }
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
287 while ( v13 < (signed int)v2->uNumBuffersUsed );
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
288 }
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
289 fclose(v5);
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
290 result = 0;
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
291 }
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
292 else
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
293 {
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
294 result = 1;
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
295 }
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
296 return result;
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
297 }
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
298
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
299
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
300
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
301
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
302
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
303
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
304
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
305
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
306 //----- (00426892) --------------------------------------------------------
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
307 static void __fastcall CheckMemoryAccessibility(void *pBase, DWORD uSize)
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
308 {
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
309 DWORD v2; // edi@1
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
310 DWORD i; // eax@1
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
311 struct _SYSTEM_INFO SystemInfo; // [sp+8h] [bp-24h]@1
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
312
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
313 v2 = uSize;
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
314 GetSystemInfo(&SystemInfo);
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
315 for ( i = 16 * SystemInfo.dwPageSize; i < v2; i += SystemInfo.dwPageSize )
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
316 ;
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
317 }