Chameleon

Chameleon Commit Details

Date:2011-10-23 21:15:27 (8 years 7 months ago)
Author:armel cadet-petit
Commit:1654
Parents: 1653
Message:added SMBIOS serial number randomization for SMBIOSPatcher
Changes:
D/branches/cparm/i386/modules/GUI/rand.c
D/branches/cparm/i386/modules/GUI/rand.h
A/branches/cparm/i386/libsa/rand.c
M/branches/cparm/i386/libsa/string.c
M/branches/cparm/i386/libsaio/saio_types.h
M/branches/cparm/i386/libsaio/md5c.c
M/branches/cparm/i386/libsaio/misc.c
M/branches/cparm/i386/libsa/zalloc.c
M/branches/cparm/i386/libsaio/saio_internal.h
M/branches/cparm/i386/modules/SMBiosGetters/README
M/branches/cparm/i386/boot2/options.c
M/branches/cparm/i386/modules/GUI/gui.c
M/branches/cparm/i386/modules/SMBiosPatcher/smbios_patcher.h
M/branches/cparm/i386/modules/SMBiosPatcher/README
M/branches/cparm/i386/boot2/boot.c
M/branches/cparm/i386/modules/GUI/Makefile
M/branches/cparm/i386/libsa/libsa.h
M/branches/cparm/i386/boot2/modules.c
M/branches/cparm/CHANGES

File differences

branches/cparm/CHANGES
1
2
3
4
5
6
7
8
9
110
211
312
- Implemented a serial number randomizer in smbiospatcher
(can be useful for icloud registration problems, especially when the serial number is already used by another machine,
DISCLAIMER: Please read the iCloud License (http://www.apple.com/legal/icloud/ww/) carefully before using this option.
By using this option, you are agreeing to be bound by
the terms of the iCloud License (http://www.apple.com/legal/icloud/ww/). If you do not or cannot agree to the terms
of the icloud License (http://www.apple.com/legal/icloud/ww/), please do not use this option.
THE CHAMELEON ( OR VOODOO ) TEAM CAN NOT BE HELD RESPONSIBLE FOR ANY ABUSE.)
- Chameleon (or at least this branch) can now boot OSX on Parallels Desktop 7, with full acpi and smbios support
(note: you will need to embed at least acpicodec and smbiosgetters since virtual machines don't like our module system),
see this vid ;-) : http://www.youtube.com/watch?v=kvSgwIE6D4o&feature=channel_video_title
branches/cparm/i386/libsaio/saio_types.h
4747
4848
4949
50
51
52
53
54
55
56
57
5058
5159
5260
*/
#define IO_CONFIG_DATA_SIZE4096 // was 163840
#define rand_tab_len 100
struct ran_obj {
int tab[rand_tab_len];
int rmin;
int n;
};
typedef unsigned long entry_t;
typedef struct {
branches/cparm/i386/libsaio/md5c.c
2828
2929
3030
31
32
33
34
35
36
37
38
39
31
4032
41
42
43
4433
4534
46
47
48
49
50
51
5235
5336
54
55
56
57
58
59
60
61
6237
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
9938
100
101
102
39
40
41
10342
10443
10544
......
11655
11756
11857
119
120
121
122
58
59
60
61
12362
124
125
126
127
63
64
65
66
12867
129
130
131
132
68
69
70
71
13372
134
135
136
137
73
74
75
76
13877
13978
14079
......
14281
14382
14483
145
84
14685
147
86
14887
149
88
15089
15190
15291
......
162101
163102
164103
165
104
166105
167
106
168107
169
108
170109
171
110
172111
173112
174
113
175114
176115
177
116
178117
179118
180119
181120
182121
183
122
184123
185
124
186125
187126
188127
189
128
190129
191
130
192131
193132
194
133
195134
196135
197136
198137
199
138
200139
201140
202
141
203142
204143
205144
......
208147
209148
210149
211
150
212151
213152
214153
215
154
216155
217156
218
157
219158
220159
221160
222161
223
162
224163
225164
226165
......
232171
233172
234173
235
236
174
175
237176
238177
239178
240
179
241180
242181
243
182
244183
245184
246185
......
249188
250189
251190
252
253
191
192
254193
255194
256
195
257196
258
197
259198
260199
261200
......
277216
278217
279218
280
219
281220
282221
283222
......
299238
300239
301240
302
241
303242
304243
305244
......
321260
322261
323262
324
263
325264
326265
327266
......
343282
344283
345284
346
285
347286
348287
349288
350289
351
290
352291
353292
354293
* edited for clarity and style only.
*/
#include <sys/types.h>
#ifdef KERNEL
#include <sys/systm.h>
#else
#include <string.h>
#endif
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5
#include "libsaio.h"
# include <Kernel/libkern/crypto/md5.h>
#else
# include <sys/md5.h>
#endif
#ifdef KERNEL
#define memset(x,y,z)bzero(x,z);
#define memcpy(x,y,z)bcopy(y, x, z)
#endif
#if defined(__i386__) || defined(__alpha__)
#define Encode memcpy
#define Decode memcpy
#else /* __i386__ */
static void Encode (output, input, len);
static void Decode (output, input, len);
static void MD5Transform (state, block);
/*
* Encodes input (u_int32_t) into output (unsigned char). Assumes len is
* a multiple of 4.
*/
/* XXX not prototyped, and not compatible with memcpy(). */
static void
Encode (output, input, len)
unsigned char *output;
u_int32_t *input;
unsigned int len;
{
unsigned int i, j;
for (i = 0, j = 0; j < len; i++, j += 4) {
output[j] = (unsigned char)(input[i] & 0xff);
output[j+1] = (unsigned char)((input[i] >> 8) & 0xff);
output[j+2] = (unsigned char)((input[i] >> 16) & 0xff);
output[j+3] = (unsigned char)((input[i] >> 24) & 0xff);
}
}
/*
* Decodes input (unsigned char) into output (u_int32_t). Assumes len is
* a multiple of 4.
*/
static void
Decode (output, input, len)
u_int32_t *output;
const unsigned char *input;
unsigned int len;
{
unsigned int i, j;
for (i = 0, j = 0; j < len; i++, j += 4)
output[i] = ((u_int32_t)input[j]) | (((u_int32_t)input[j+1]) << 8) |
(((u_int32_t)input[j+2]) << 16) | (((u_int32_t)input[j+3]) << 24);
}
#endif /* i386 */
static unsigned char PADDING[64] = {
0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
};
/* F, G, H and I are basic MD5 functions. */
* Rotation is separate from addition to prevent recomputation.
*/
#define FF(a, b, c, d, x, s, ac) { \
(a) += F ((b), (c), (d)) + (x) + (u_int32_t)(ac); \
(a) = ROTATE_LEFT ((a), (s)); \
(a) += (b); \
}
(a) += F ((b), (c), (d)) + (x) + (u_int32_t)(ac); \
(a) = ROTATE_LEFT ((a), (s)); \
(a) += (b); \
}
#define GG(a, b, c, d, x, s, ac) { \
(a) += G ((b), (c), (d)) + (x) + (u_int32_t)(ac); \
(a) = ROTATE_LEFT ((a), (s)); \
(a) += (b); \
}
(a) += G ((b), (c), (d)) + (x) + (u_int32_t)(ac); \
(a) = ROTATE_LEFT ((a), (s)); \
(a) += (b); \
}
#define HH(a, b, c, d, x, s, ac) { \
(a) += H ((b), (c), (d)) + (x) + (u_int32_t)(ac); \
(a) = ROTATE_LEFT ((a), (s)); \
(a) += (b); \
}
(a) += H ((b), (c), (d)) + (x) + (u_int32_t)(ac); \
(a) = ROTATE_LEFT ((a), (s)); \
(a) += (b); \
}
#define II(a, b, c, d, x, s, ac) { \
(a) += I ((b), (c), (d)) + (x) + (u_int32_t)(ac); \
(a) = ROTATE_LEFT ((a), (s)); \
(a) += (b); \
}
(a) += I ((b), (c), (d)) + (x) + (u_int32_t)(ac); \
(a) = ROTATE_LEFT ((a), (s)); \
(a) += (b); \
}
static void MD5Transform (u_int32_t state[4], const unsigned char block[64]);
void
MD5Init (context)
MD5_CTX *context;
MD5_CTX *context;
{
context->count[0] = context->count[1] = 0;
/* Load magic initialization constants. */
context->state[0] = 0x67452301;
context->state[1] = 0xefcdab89;
void
MD5Update (context, input, inputLen)
MD5_CTX *context;
MD5_CTX *context;
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5
const void *input;
const void *input;
#else
const unsigned char *input;
const unsigned char *input;
#endif
unsigned int inputLen;
unsigned int inputLen;
{
unsigned int i, index, partLen;
/* Compute number of bytes mod 64 */
index = (unsigned int)((context->count[0] >> 3) & 0x3F);
/* Update number of bits */
if ((context->count[0] += ((u_int32_t)inputLen << 3))
< ((u_int32_t)inputLen << 3))
context->count[1]++;
context->count[1] += ((u_int32_t)inputLen >> 29);
partLen = 64 - index;
/* Transform as many times as possible. */
if (inputLen >= partLen) {
memcpy((void *)&context->buffer[index], (const void *)input,
partLen);
partLen);
MD5Transform (context->state, context->buffer);
for (i = partLen; i + 63 < inputLen; i += 64)
MD5Transform (context->state, &((const unsigned char *)input)[i]);
index = 0;
}
else
i = 0;
/* Buffer remaining input */
memcpy ((void *)&context->buffer[index], (const void *)&((const unsigned char*)input)[i],
inputLen-i);
inputLen-i);
}
/*
void
MD5Pad (context)
MD5_CTX *context;
MD5_CTX *context;
{
unsigned char bits[8];
unsigned int index, padLen;
/* Save number of bits */
Encode (bits, context->count, 8);
/* Pad out to 56 mod 64. */
index = (unsigned int)((context->count[0] >> 3) & 0x3f);
padLen = (index < 56) ? (56 - index) : (120 - index);
MD5Update (context, PADDING, padLen);
/* Append length (before padding) */
MD5Update (context, bits, 8);
}
void
MD5Final (digest, context)
unsigned char digest[16];
MD5_CTX *context;
unsigned char digest[16];
MD5_CTX *context;
{
/* Do padding. */
MD5Pad (context);
/* Store state in digest */
Encode (digest, context->state, 16);
/* Zeroize sensitive information. */
memset ((void *)context, 0, sizeof (*context));
}
static void
MD5Transform (state, block)
u_int32_t state[4];
const unsigned char block[64];
u_int32_t state[4];
const unsigned char block[64];
{
u_int32_t a = state[0], b = state[1], c = state[2], d = state[3], x[16];
Decode (x, block, 64);
/* Round 1 */
#define S11 7
#define S12 12
FF (d, a, b, c, x[13], S12, 0xfd987193); /* 14 */
FF (c, d, a, b, x[14], S13, 0xa679438e); /* 15 */
FF (b, c, d, a, x[15], S14, 0x49b40821); /* 16 */
/* Round 2 */
#define S21 5
#define S22 9
GG (d, a, b, c, x[ 2], S22, 0xfcefa3f8); /* 30 */
GG (c, d, a, b, x[ 7], S23, 0x676f02d9); /* 31 */
GG (b, c, d, a, x[12], S24, 0x8d2a4c8a); /* 32 */
/* Round 3 */
#define S31 4
#define S32 11
HH (d, a, b, c, x[12], S32, 0xe6db99e5); /* 46 */
HH (c, d, a, b, x[15], S33, 0x1fa27cf8); /* 47 */
HH (b, c, d, a, x[ 2], S34, 0xc4ac5665); /* 48 */
/* Round 4 */
#define S41 6
#define S42 10
II (d, a, b, c, x[11], S42, 0xbd3af235); /* 62 */
II (c, d, a, b, x[ 2], S43, 0x2ad7d2bb); /* 63 */
II (b, c, d, a, x[ 9], S44, 0xeb86d391); /* 64 */
state[0] += a;
state[1] += b;
state[2] += c;
state[3] += d;
/* Zeroize sensitive information. */
memset ((void *)x, 0, sizeof (x));
}
branches/cparm/i386/libsaio/misc.c
120120
121121
122122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
123251
124252
125253
}
#endif
static bool fix_random=true;
struct ran_obj* random_init (int rmin, int rmax)
{
if (rmin > rmax)
return false;
int n = (rmax+1) - rmin;
int tab[rand_tab_len];
struct ran_obj * self = (struct ran_obj * )malloc(sizeof(struct ran_obj));
bzero(self,sizeof(struct ran_obj));
self->rmin= rmin;
self->n= n;
int i;
srand(time18());
int limit1= 0, limit2= 0, gate1 = 0, gate2 = 0;
if (fix_random) {
limit1 = (rand() % 20) ;
limit2 = (rand() % 20) ;
}
for (i = 0; i < rand_tab_len; i++){
tab[i] = (rand() % n) + rmin;
if (fix_random) {
if (i > 1 && gate1 < limit1 && tab[i]==tab[i-2]) {
i--;
gate1++;
continue;
}
if (i > 7 && gate2 < limit2 && tab[i]==tab[i-((rand() % 4)+5)]) {
i--;
gate2++;
continue;
}
}
self->tab[i]= tab[i];
}
return self;
}
int random (struct ran_obj* self)
{
//struct ran_opt * ret = (struct ran_opt * )malloc(sizeof(struct ran_opt));
//ret = rt ;
struct ran_obj * ret = self ;
static int wheel = 0;
int gate3 = 0;
int limit3 = 0;
static int retlst[rand_tab_len];
int index;
int rn;
if (!ret) {
return -1;// TODO: fix this
}
if (fix_random) {
gate3 = rand() % 2;
}
retry:
index = rand() % rand_tab_len;
rn = ret->tab[index];
ret->tab[index] = (rand() % ret->n) + ret->rmin;
if (fix_random) {
if ((gate3 && limit3 < 5) && (ret->tab[index] == rn)) {
limit3++;
goto retry;
}
retlst[wheel] = rn;
if (wheel > 0 && limit3 < 5) {
if (gate3 && (rn == retlst[wheel-1])) {
limit3++;
goto retry;
}
if (gate3 && (wheel > 3 && rn==retlst[wheel-((rand() % 3)+1)]) && (limit3 < 5)) {
limit3++;
goto retry;
}
}
wheel++;
}
self = ret;
return rn;
}
void random_free (struct ran_obj* self)
{
if (self /* && self->sgn == random_obj_sgn */) {
free(self);
}
}
void usefixedrandom (bool opt)
{
fix_random = opt;
}
//==========================================================================
// Return the platform name for this hardware.
//
branches/cparm/i386/libsaio/saio_internal.h
146146
147147
148148
149
150
151
152
153
149154
150155
151156
......
154159
155160
156161
162
163
164
157165
158166
159167
extern void enableA20(void);
extern void turnOffFloppy(void);
extern void random_free (struct ran_obj* self);
extern int random (struct ran_obj* self);
extern struct ran_obj* random_init (int rmin, int rmax);
extern void usefixedrandom (bool opt);
extern void getPlatformName(char *nameBuf);
#ifdef NBP_SUPPORT
extern BVRef nbpScanBootVolumes(int biosdev, int *count);
#endif
/* stringTable.c */
extern char * newStringFromList(char **list, int *size);
extern int stringLength(const char *table, int compress);
branches/cparm/i386/boot2/boot.c
439439
440440
441441
442
443
444
442445
443446
444447
{
firstRun = false;
}
#if virtualM
firstRun = false;
#endif
}
#ifndef OPTION_ROM
branches/cparm/i386/boot2/modules.c
908908
909909
910910
911
911912
912913
913914
else if(strcmp(symbolName, SYMBOL_DYLD_STUB_BINDER) != 0)
{
printf("Unable to bind symbol %s\n", symbolName);
getc();
}
segmentAddress += sizeof(void*);
branches/cparm/i386/boot2/options.c
111111
112112
113113
114
115
116
117
118
119
114
120115
121116
122
123
124
125
126
127
128
129
117
130118
131119
132120
moveCursor( 0, row );
printf(msg);
/*
int multi_buff = 18 * (timeout);
int multi = ++multi_buff;
*/
//unsigned int lasttime=0;
for ( time = time18(), timeout++; timeout > 0; )
{
/*
if( time18() > lasttime)
{
multi--;
lasttime=time18();
}
*/
if ((ch = readKeyboardStatus()))
if ((ch = readKeyboardStatus()))
break;
// Count can be interrupted by holding down shift,
branches/cparm/i386/modules/GUI/rand.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
/*
* Cadet-petit Armel <armelcadetpetit@gmail.com>
*
*rand & srand implementation
*/
#include "rand.h"
static long holdrand = 1L;
#defineRAND_MAX0x7fffffff
void srand (unsigned int seed)
{
holdrand = (long)seed;
}
int rand (void)
{
holdrand = holdrand * 214013L + 2531011L;
return ((holdrand >> 16) & RAND_MAX);
}
branches/cparm/i386/modules/GUI/rand.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
/*
* Cadet-petit Armel <armelcadetpetit@gmail.com>
*
* rand & srand implementation
*/
#ifndef __RAND_H
#define __RAND_H
#include "libsa.h"
extern int rand (void);
extern void srand (unsigned int seed);
#endif /* !__RAND_H */
branches/cparm/i386/modules/GUI/gui.c
1616
1717
1818
19
2019
2120
2221
#include "GUI_appleboot.h"
#include "vers.h"
#include "modules.h"
#include "rand.h"
#include "sl.h"
branches/cparm/i386/modules/GUI/Makefile
4949
5050
5151
52
52
5353
5454
5555
......
8282
8383
8484
85
8685
8786
8887
......
102101
103102
104103
105
106
107
108104
109105
110106
VPATH = $(OBJROOT):$(SYMROOT)
GUI_OBJS = rand.o GUI_module.o gui.o picopng.o graphic_utils.o
GUI_OBJS = GUI_module.o gui.o picopng.o graphic_utils.o
SFILES =
-current_version $(MODULE_VERSION) -compatibility_version $(MODULE_COMPAT_VERSION) \
-final_output $(MODULE_NAME) \
-macosx_version_min 10.6 \
$(OBJROOT)/rand.o \
$(OBJROOT)/GUI_module.o \
$(OBJROOT)/gui.o \
$(OBJROOT)/picopng.o \
graphic_utils.o:
gcc-4.2 $(CPPFLAGS) $(CFLAGS) $(DEFINES) -c "graphic_utils.c" $(INC) -o "$(OBJROOT)/graphic_utils.o"
rand.o:
gcc-4.2 $(CPPFLAGS) $(CFLAGS) $(DEFINES) -c "rand.c" $(INC) -o "$(OBJROOT)/rand.o"
art.h:
@if [ "$(PNGCRUSH)" ]; then\
echo "optimizing art files ...\n$(PNGCRUSH) $(PNGOPTIONS) artwork/$(THEME)"; \
branches/cparm/i386/modules/SMBiosGetters/README
1
1
please do not use SMBiosGetters and SMBiosPatcher together, you have to chose one of them (SMBiosGetters is recommended), this issue will be fixed in the next versions
please do not use SMBiosGetters and SMBiosPatcher together, you have to chose one of them, this issue will be fixed in the next versions
branches/cparm/i386/modules/SMBiosPatcher/smbios_patcher.c
2828
2929
3030
31
32
33
34
3135
3236
3337
......
3539
3640
3741
38
39
40
41
42
43
44
45
46
47
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
4857
4958
5059
5160
5261
53
54
55
56
57
58
59
60
61
62
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
6377
6478
6579
6680
6781
68
69
70
71
72
73
74
75
76
77
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
7897
7998
8099
81100
82101
83
84
85
86
87
88
89
90
91
92
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
93117
94118
95119
96120
97121
98
99
100
101
102
103
104
105
106
107
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
108137
109138
110139
111140
112141
113
114
115
116
117
118
119
120
121
122
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
123157
124158
125159
126160
127161
128
129
130
131
132
133
134
135
136
137
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
138177
139178
140179
141180
142181
143
144
145
146
147
148
149
150
151
152
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
153197
154198
155199
156200
157201
158
159
160
161
162
163
164
165
166
167
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
168217
169218
170219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
171383
172384
173
174385
175
386
387
388
176389
177390
178
391
179392
180393
181394
......
199412
200413
201414
202
203
204
205
415
416
417
418
206419
207420
208421
......
231444
232445
233446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
234499
235
236
237
238
239
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
240534
241
242
243
244
535
536
537
538
539
540
541
542
245543
246544
247545
......
583881
584882
585883
884
885
886
586887
587888
588
889
589890
590891
591892
......
604905
605906
606907
607
608
908
909
910
911
912
913
914
915
609916
610917
611918
......
651958
652959
653960
654
961
962
963
964
965
966
967
655968
656969
657970
......
6971010
6981011
6991012
1013
1014
1015
7001016
7011017
7021018
......
7611077
7621078
7631079
764
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
7651090
7661091
7671092
......
8781203
8791204
8801205
881
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
8821216
8831217
8841218
char* gSMBIOSBoardModel;
static char fake_serial[11];
static char const sn_gen_pn_str[36] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
typedef struct {
const char* key;
const char* value;
// defaults for a MacBook
static const SMStrEntryPair const sm_macbook_defaults[]={
{"SMbiosvendor","Apple Inc."},
{"SMbiosversion","MB41.88Z.00C1.B00.0802091535"},
{"SMbiosdate","02/09/2008"},
{"SMmanufacter","Apple Inc."},
{"SMproductname","MacBook4,1"},
{"SMsystemversion","1.0"},
{"SMserial","RM83064H0P1"},
{"SMfamily","MacBook"},
{"SMboardmanufacter","Apple Inc."},
{"SMboardproduct","Mac-F22788A9"},
{"SMbiosvendor", "Apple Inc." },
{"SMbiosversion", "MB41.88Z.00C1.B00.0802091535"},
{"SMbiosdate", "02/09/2008" },
{"SMmanufacter", "Apple Inc." },
{"SMproductname", "MacBook4,1" },
{"SMsystemversion", "1.0" },
{"SMserial", "RM83064H0P1" },
{"SMserialProductCountry","RM" },
{"SMserialYear", "8" },
{"SMserialWeek", "30" },
{"SMserialProductNumber","64H" },
{"SMserialModel","0P1" },
{"SMfamily", "MacBook" },
{"SMboardmanufacter", "Apple Inc." },
{"SMboardproduct", "Mac-F22788A9" },
{ "",""}
};
// defaults for a MacBook Pro
static const SMStrEntryPair const sm_macbookpro_defaults[]={
{"SMbiosvendor","Apple Inc."},
{"SMbiosversion","MBP41.88Z.00C1.B03.0802271651"},
{"SMbiosdate","02/27/2008"},
{"SMmanufacter","Apple Inc."},
{"SMproductname","MacBookPro4,1"},
{"SMsystemversion","1.0"},
{"SMserial","W88198N6YJX"},
{"SMfamily","MacBookPro"},
{"SMboardmanufacter","Apple Inc."},
{"SMboardproduct","Mac-F42C89C8"},
{"SMbiosvendor", "Apple Inc." },
{"SMbiosversion", "MBP41.88Z.00C1.B03.0802271651"},
{"SMbiosdate", "02/27/2008" },
{"SMmanufacter", "Apple Inc." },
{"SMproductname", "MacBookPro4,1" },
{"SMsystemversion", "1.0" },
{"SMserial", "W88198N6YJX" },
{"SMserialProductCountry","W8" },
{"SMserialYear", "8" },
{"SMserialWeek", "19" },
{"SMserialProductNumber","8N6" },
{"SMserialModel","YJX" },
{"SMfamily", "MacBookPro" },
{"SMboardmanufacter", "Apple Inc." },
{"SMboardproduct", "Mac-F42C89C8" },
{ "",""}
};
// defaults for a Mac mini
static const SMStrEntryPair const sm_macmini_defaults[]={
{"SMbiosvendor","Apple Inc."},
{"SMbiosversion","MM21.88Z.009A.B00.0706281359"},
{"SMbiosdate","06/28/2007"},
{"SMmanufacter","Apple Inc."},
{"SMproductname","Macmini2,1"},
{"SMsystemversion","1.0"},
{"SMserial","YM8054BYYL2"},
{"SMfamily","Napa Mac"},
{"SMboardmanufacter","Apple Inc."},
{"SMboardproduct","Mac-F4208EAA"},
{"SMbiosvendor", "Apple Inc." },
{"SMbiosversion", "MM21.88Z.009A.B00.0706281359"},
{"SMbiosdate", "06/28/2007" },
{"SMmanufacter", "Apple Inc." },
{"SMproductname", "Macmini2,1" },
{"SMsystemversion", "1.0" },
{"SMserial", "YM8054BYYL2" },
{"SMserialProductCountry","YM" },
{"SMserialYear", "8" },
{"SMserialWeek", "05" },
{"SMserialProductNumber","4BY" },
{"SMserialModel","YL2" },
{"SMfamily", "Napa Mac" },
{"SMboardmanufacter", "Apple Inc." },
{"SMboardproduct", "Mac-F4208EAA" },
{ "",""}
};
// defaults for an iMac
static const SMStrEntryPair const sm_imac_defaults[]={
{"SMbiosvendor","Apple Inc."},
{"SMbiosversion","IM71.88Z.007A.B03.0803051705"},
{"SMbiosdate","03/05/2008"},
{"SMmanufacter","Apple Inc."},
{"SMproductname","iMac7,1"},
{"SMsystemversion","1.0"},
{"SMserial","W87410PWX87"},
{"SMfamily","Mac"},
{"SMboardmanufacter","Apple Inc."},
{"SMboardproduct","Mac-F4238CC8"},
{"SMbiosvendor", "Apple Inc." },
{"SMbiosversion", "IM71.88Z.007A.B03.0803051705"},
{"SMbiosdate", "03/05/2008" },
{"SMmanufacter", "Apple Inc." },
{"SMproductname", "iMac7,1" },
{"SMsystemversion", "1.0" },
{"SMserial", "W87410PWX87" },
{"SMserialProductCountry","W8" },
{"SMserialYear", "7" },
{"SMserialWeek", "41" },
{"SMserialProductNumber","0PW" },
{"SMserialModel","X87" },
{"SMfamily", "Mac" },
{"SMboardmanufacter", "Apple Inc." },
{"SMboardproduct", "Mac-F4238CC8" },
{ "",""}
};
// defaults for a Mac Pro
static const SMStrEntryPair const sm_macpro_defaults[]={
{"SMbiosvendor","Apple Computer, Inc."},
{"SMbiosversion","MP31.88Z.006C.B02.0801021250"},
{"SMbiosdate","01/02/2008"},
{"SMmanufacter","Apple Computer, Inc."},
{"SMproductname","MacPro3,1"},
{"SMsystemversion","1.0"},
{"SMserial","G88014V4XYK"},
{"SMfamily","MacPro"},
{"SMboardmanufacter","Apple Computer, Inc."},
{"SMboardproduct","Mac-F42C88C8"},
{"SMbiosvendor", "Apple Computer, Inc."},
{"SMbiosversion", "MP31.88Z.006C.B02.0801021250"},
{"SMbiosdate", "01/02/2008"},
{"SMmanufacter", "Apple Computer, Inc."},
{"SMproductname", "MacPro3,1"},
{"SMsystemversion", "1.0"},
{"SMserial", "G88014V4XYK"},
{"SMserialProductCountry","G8" },
{"SMserialYear", "8" },
{"SMserialWeek", "01" },
{"SMserialProductNumber","4V4" },
{"SMserialModel","XYK" },
{"SMfamily", "MacPro"},
{"SMboardmanufacter", "Apple Computer, Inc."},
{"SMboardproduct", "Mac-F42C88C8"},
{ "",""}
};
// defaults for an iMac11,1 core i3/i5/i7
static const SMStrEntryPair const sm_imac_core_defaults[]={
{"SMbiosvendor","Apple Inc."},
{"SMbiosversion","IM111.88Z.0034.B00.0910301727"},
{"SMbiosdate","10/30/2009"},
{"SMmanufacter","Apple Inc."},
{"SMproductname","iMac11,1"},
{"SMsystemversion","1.0"},
{"SMserial","W89470DZ5RU"},
{"SMfamily","iMac"},
{"SMboardmanufacter","Apple Inc." },
{"SMboardproduct","Mac-F2268DAE"},
{"SMbiosvendor", "Apple Inc."},
{"SMbiosversion", "IM111.88Z.0034.B00.0910301727"},
{"SMbiosdate", "10/30/2009"},
{"SMmanufacter", "Apple Inc."},
{"SMproductname", "iMac11,1"},
{"SMsystemversion", "1.0"},
{"SMserial", "W89470DZ5RU"},
{"SMserialProductCountry", "W8" },
{"SMserialYear", "9" },
{"SMserialWeek", "47" },
{"SMserialProductNumber", "0DZ" },
{"SMserialModel", "5RU" },
{"SMfamily", "iMac"},
{"SMboardmanufacter", "Apple Inc." },
{"SMboardproduct", "Mac-F2268DAE"},
{ "",""}
};
// defaults for an iMac12,1 : todo: populate correctly
static const SMStrEntryPair const sm_imac_sandy_defaults[]={
{"SMbiosvendor","Apple Inc."},
{"SMbiosversion","IM121.88Z.0047.B00.1102091756"},
{"SMbiosdate","10/30/2011"},
{"SMmanufacter","Apple Inc."},
{"SMproductname","iMac12,1"},
{"SMsystemversion","1.0"},
{"SMserial","W89470DZ5RU"},
{"SMfamily","iMac"},
{"SMboardmanufacter","Apple Inc." },
{"SMboardproduct","Mac-F2268DAE"},
{"SMbiosvendor", "Apple Inc."},
{"SMbiosversion", "IM121.88Z.0047.B00.1102091756"},
{"SMbiosdate", "10/30/2011"},
{"SMmanufacter", "Apple Inc."},
{"SMproductname", "iMac12,1"},
{"SMsystemversion", "1.0"},
{"SMserial", "W89470DZ5RU"},
{"SMserialProductCountry", "W8" },
{"SMserialYear", "9" },
{"SMserialWeek", "47" },
{"SMserialProductNumber", "0DZ" },
{"SMserialModel", "5RU" },
{"SMfamily", "iMac"},
{"SMboardmanufacter", "Apple Inc." },
{"SMboardproduct", "Mac-F2268DAE"},
{ "",""}
};
// defaults for a Mac Pro 4,1 core i7/Xeon
static const SMStrEntryPair const sm_macpro_core_defaults[]={
{"SMbiosvendor","Apple Computer, Inc."},
{"SMbiosversion","MP41.88Z.0081.B03.0902231259"},
{"SMbiosdate","02/23/2009"},
{"SMmanufacter","Apple Inc." },
{"SMproductname","MacPro4,1"},
{"SMsystemversion","1.0"},
{"SMserial","CK91601V8Q0"},
{"SMfamily","MacPro"},
{"SMboardmanufacter","Apple Computer, Inc."},
{"SMboardproduct","Mac-F221BEC8"},
{"SMbiosvendor", "Apple Computer, Inc."},
{"SMbiosversion", "MP41.88Z.0081.B03.0902231259"},
{"SMbiosdate", "02/23/2009"},
{"SMmanufacter", "Apple Inc." },
{"SMproductname", "MacPro4,1"},
{"SMsystemversion", "1.0"},
{"SMserial", "CK91601V8Q0"},
{"SMserialProductCountry","CK" },
{"SMserialYear", "9" },
{"SMserialWeek", "16" },
{"SMserialProductNumber","01V" },
{"SMserialModel","8Q0" },
{"SMfamily", "MacPro"},
{"SMboardmanufacter", "Apple Computer, Inc."},
{"SMboardproduct", "Mac-F221BEC8"},
{ "",""}
};
// default for a Xserve
static const SMStrEntryPair const sm_xserve_defaults[]={
{"SMbiosvendor","Apple Inc."},
{"SMbiosversion","XS21.88Z.006C.B06.0804011317"},
{"SMbiosdate","04/01/2008"},
{"SMmanufacter","Apple Inc."},
{"SMproductname","Xserve2,1"},
{"SMsystemversion","1.0"},
{"SMserial","CK816033X8S"},
{"SMfamily","Xserve"},
{"SMboardmanufacter","Apple Inc."},
{"SMboardproduct","Mac-F42289C8"},
{"SMbiosvendor", "Apple Inc."},
{"SMbiosversion", "XS21.88Z.006C.B06.0804011317"},
{"SMbiosdate", "04/01/2008"},
{"SMmanufacter", "Apple Inc."},
{"SMproductname", "Xserve2,1"},
{"SMsystemversion", "1.0"},
{"SMserial", "CK816033X8S"},
{"SMserialProductCountry","CK" },
{"SMserialYear", "8" },
{"SMserialWeek", "16" },
{"SMserialProductNumber","033" },
{"SMserialModel","X8S" },
{"SMfamily", "Xserve"},
{"SMboardmanufacter", "Apple Inc."},
{"SMboardproduct", "Mac-F42289C8"},
{ "",""}
};
typedef struct {
const char* code;
const char* info;
} SMProductCountry;
static const SMProductCountry const sm_country_list[]={
{"1C","China" },
{"2Z","Refurbished" },
{"4H","China" },
{"5K","China" },
{"8H","China" },
{"5D","China" },
{"7J","China " },
{"CK","Cork " },
/*{"E","Singapur" },*/
{"EE","Taiwan" },
/*{"F","Fremont " },*/
{"FC","Fountain " },
{"G8","USA" },
{"GQ","Refurbished" },
{"PT","Korea" },
{"CY","Korea" },
{"QT","Taiwan" },
{"QP","China" },
{"RN","Mexico" },
{"RM","Refurbished/Remanufactured"},
{"SG","Singapore" },
{"UV","Taiwan" },
{"U2","Taiwan" },
{"V7","Taiwan" },
{"VM","China" },
{"W8","Shanghai" },
{"WQ","China" },
{"XA","Elk Grove Sacramento"},
{"XB","Elk Grove Sacramento"},
{"YM","China /Konfiguriert"}
};
const char* sm_search_str(const SMStrEntryPair*sm_defaults, const char * key)
{
int i;
for (i=0; sm_defaults[i].key[0]; i++) {
if (!strcmp (sm_defaults[i].key, key)) {
return sm_defaults[i].value;
}
}
// Shouldn't happen
printf ("Error: no default for %s known\n", key);
sleep (2);
return "";
}
const char* sm_get_random_productNumber()
{
static char str[4] = {0x00,0x00,0x00,0x00};
if(str[0] == 0)
{
// Get randomized characters
int rand_sn1 ;
int rand_sn2 ;
int rand_sn3 ;
struct ran_obj* random_serial_obj = random_init(0,35);
rand_sn1 = random(random_serial_obj);
rand_sn2 = random(random_serial_obj);
rand_sn3 = random(random_serial_obj);
random_free(random_serial_obj);
// Append all charaters to the string
char tmp[2];
bzero(tmp,sizeof(tmp));
sprintf(tmp,"%c",sn_gen_pn_str[rand_sn1]);
strcpy (str, tmp);
sprintf(tmp,"%c",sn_gen_pn_str[rand_sn2]);
strcat (str, tmp);
sprintf(tmp,"%c",sn_gen_pn_str[rand_sn3]);
strcat (str, tmp);
DBG ("fake_productNumber: %s\n",str);
}
return str;
}
const char* sm_get_random_week()
{
static char str[4] = {0x00,0x00,0x00,0x00};
if(str[0] == 0)
{
// Get randomized characters
int rand_week ;
struct ran_obj* random_week_obj = random_init(0,47)/* random_init(1,48) */;
rand_week = random(random_week_obj);
random_free(random_week_obj);
// Append all charaters to the string
char tmp[3];
bzero(tmp,sizeof(tmp));
if (rand_week < 10) {
sprintf(tmp,"0%d",rand_week);
strcpy (str, tmp);
} else if (rand_week < 100) { // avoid overflow in case random return a number >= 100
sprintf(tmp,"%d",rand_week);
strcpy (str, tmp);
}
DBG ("fake_week: %s\n",str);
}
return str;
}
const char* sm_get_random_year()
{
static char str[2] = {0x00,0x00};
if(str[0] == 0)
{
// Get randomized characters
int rand_year ;
struct ran_obj* random_year_obj = random_init(0,9);
rand_year = random(random_year_obj);
random_free(random_year_obj);
// Append all charaters to the string
char tmp[2];
bzero(tmp,sizeof(tmp));
if (rand_year < 10) {
sprintf(tmp,"%d",rand_year);
strcpy (str, tmp);
}
DBG ("fake_year: %s\n",str);
}
return str;
}
const char* sm_get_random_country()
{
static char str[3] = {0x00,0x00,0x00};
if(str[0] == 0)
{
// Get randomized characters
int rand_country ;
struct ran_obj* random_country_obj = random_init(0,(sizeof(sm_country_list) / sizeof(sm_country_list[0]))-1);
rand_country = random(random_country_obj);
random_free(random_country_obj);
strcpy (str, sm_country_list[rand_country].code);
DBG ("fake_country: %s (%s)\n",str,sm_country_list[rand_country].info);
}
return str;
}
const char* sm_get_defstr(const char * key, int table_num)
{
inti;
const SMStrEntryPair*sm_defaults;
const SMStrEntryPair*sm_chosen;
static bool serial_done = false;
if (Platform->CPU.isServer == true)
{
sm_defaults=sm_xserve_defaults;
sm_defaults=sm_xserve_defaults;
} else if (Platform->CPU.isMobile == true) {
if (Platform->CPU.NoCores > 1) {
sm_defaults=sm_macbookpro_defaults;
{
switch (Platform->CPU.Model)
{
case CPUID_MODEL_FIELDS: // Intel Core i5, i7 LGA1156 (45nm)
case CPUID_MODEL_DALES: // Intel Core i5, i7 LGA1156 (45nm) ???
case CPUID_MODEL_DALES_32NM: // Intel Core i3, i5, i7 LGA1156 (32nm) (Clarkdale, Arrandale)
case 0x19: // Intel Core i5 650 @3.20 Ghz
case CPUID_MODEL_FIELDS: // Intel Core i5, i7 LGA1156 (45nm)
case CPUID_MODEL_DALES: // Intel Core i5, i7 LGA1156 (45nm) ???
case CPUID_MODEL_DALES_32NM: // Intel Core i3, i5, i7 LGA1156 (32nm) (Clarkdale, Arrandale)
case 0x19: // Intel Core i5 650 @3.20 Ghz
sm_defaults=sm_imac_core_defaults;
break;
}
}
}
{
const char*str;
intsize;
if (getValueForKey("SMproductname", &str, &size, &bootInfo->smbiosConfig))
{
if (strstr (str, "MacPro4"))
{
sm_chosen = sm_macpro_core_defaults ;
}
else if (strstr (str, "MacPro"))
{
sm_chosen = sm_macpro_defaults ;
}
else if (strstr (str,"MacBookPro"))
{
sm_chosen = sm_macbookpro_defaults ;
}
else if (strstr (str, "MacBook"))
{
sm_chosen = sm_macbook_defaults ;
}
else if (!strcmp ("iMac12,1", str))
{
sm_chosen = sm_imac_sandy_defaults ;
}
else if (!strcmp ("iMac11,1", str))
{
sm_chosen = sm_imac_core_defaults ;
}
else if (strstr (str, "iMac"))
{
sm_chosen = sm_imac_defaults ;
}
else if (strstr (str, "Macmini"))
{
sm_chosen = sm_macmini_defaults ;
}
else if (strstr (str, "Xserve"))
{
sm_chosen = sm_xserve_defaults ;
}
else
{
sm_chosen = sm_defaults ;
}
}
else
sm_chosen = sm_defaults;
}
for (i=0; sm_defaults[i].key[0]; i++) {
if (!strcmp (sm_defaults[i].key, key)) {
return sm_defaults[i].value;
}
}
if (!strcmp ("SMserial", key)) {
if (!serial_done) {
bzero (fake_serial,sizeof(fake_serial));
bool randomSerial = false;
getBoolForKey(kSMBIOSRandomSerial, &randomSerial, &bootInfo->bootConfig) ;
if ( randomSerial ) // useless
strcat (fake_serial,sm_get_random_country());
else
strcpy (fake_serial,sm_search_str(sm_chosen, "SMserialProductCountry"));
if ( randomSerial ) // useless
strcat (fake_serial,sm_get_random_year());
else
strcat (fake_serial,sm_search_str(sm_chosen, "SMserialYear"));
if ( randomSerial ) // useless
strcat (fake_serial,sm_get_random_week());
else
strcat (fake_serial,sm_search_str(sm_chosen, "SMserialWeek"));
if ( randomSerial )
strcat (fake_serial,sm_get_random_productNumber());
else
strcat (fake_serial,sm_search_str(sm_chosen, "SMserialProductNumber"));
strcat (fake_serial,sm_search_str(sm_chosen, "SMserialModel"));
serial_done = true;
if ( randomSerial )
msglog ("fake_serial: %s\n",fake_serial);
// Shouldn't happen
printf ("Error: no default for '%s' known\n", key);
sleep (2);
return "";
}
return fake_serial;
}
return sm_search_str(sm_chosen, key);
}
static int sm_get_fsb(const char *name, int table_num)
ret->dmi.bcdRevision = 0x21;
tablesptr = smbiostables;
bool randomSerial = false;
getBoolForKey(kSMBIOSRandomSerial, &randomSerial, &bootInfo->bootConfig);
// add stringlen of overrides to original stringlen, update maxStructure size adequately,
// update structure count and tablepresent[type] with count of type.
if (smbiostables) {
if (smbiostables) {
for (i=0; i<origsmbiosnum; i++) {
struct smbios_table_header*cur = (struct smbios_table_header *)tablesptr;
char*stringsptr;
intsize;
charaltname[40];
sprintf(altname, "%s_%d",smbios_properties[j].name, tablespresent[cur->type] + 1);
if (smbios_properties[j].table_type == cur->type &&
sprintf(altname, "%s_%d",smbios_properties[j].name, tablespresent[cur->type] + 1);
if (smbios_properties[j].table_type == cur->type &&
smbios_properties[j].value_type == SMSTRING &&
smbios_properties[j].auto_str && randomSerial && (!strcmp ("SMserial", smbios_properties[j].name))) {
stringlen += strlen(smbios_properties[j].auto_str(smbios_properties[j].name, tablespresent[cur->type])) + 1;
} else if (smbios_properties[j].table_type == cur->type &&
smbios_properties[j].value_type == SMSTRING &&
(getValueForKey(smbios_properties[j].name, &str, &size, &bootInfo->smbiosConfig) ||
getValueForKey(altname,&str, &size, &bootInfo->smbiosConfig)))
charaltname[40];
sprintf(altname, "%s_%d",smbios_properties[j].name, tablespresent[smbios_table_descriptions[i].type] + 1);
if (smbios_properties[j].table_type == smbios_table_descriptions[i].type &&
if (smbios_properties[j].table_type == smbios_table_descriptions[i].type &&
smbios_properties[j].value_type==SMSTRING &&
smbios_properties[j].auto_str && randomSerial && (!strcmp ("SMserial", smbios_properties[j].name))) {
stringlen += strlen(smbios_properties[j].auto_str(smbios_properties[j].name, tablespresent[smbios_table_descriptions[i].type])) + 1;
} else if (smbios_properties[j].table_type == smbios_table_descriptions[i].type &&
smbios_properties[j].value_type == SMSTRING &&
(getValueForKey(altname, &str, &size, &bootInfo->smbiosConfig) ||
getValueForKey(smbios_properties[j].name, &str, &size, &bootInfo->smbiosConfig)))
static bool done = false; // IMPROVEME: called twice via getSmbios(), but only the second call can get all necessary info !
bool randomSerial = false;
getBoolForKey(kSMBIOSRandomSerial, &randomSerial, &bootInfo->bootConfig);
bzero(tablespresent, sizeof(tablespresent));
bzero(handles, sizeof(handles));
if (smbios_properties[j].table_type == newcur->type) {
switch (smbios_properties[j].value_type) {
case SMSTRING:
if (getValueForKey(altname, &str, &size, &bootInfo->smbiosConfig) ||
if (smbios_properties[j].auto_str && randomSerial && (!strcmp ("SMserial", smbios_properties[j].name)))
{
str = smbios_properties[j].auto_str(smbios_properties[j].name, tablespresent[newcur->type]);
size = strlen(str);
memcpy(newtablesptr, str, size);
newtablesptr[size] = 0;
newtablesptr += size + 1;
*((uint8_t*)(((char*)newcur) + smbios_properties[j].offset)) = ++nstrings;
} else if (getValueForKey(altname, &str, &size, &bootInfo->smbiosConfig) ||
getValueForKey(smbios_properties[j].name, &str, &size, &bootInfo->smbiosConfig))
{
memcpy(newtablesptr, str, size);
if (smbios_properties[j].table_type == newcur->type) {
switch (smbios_properties[j].value_type) {
case SMSTRING:
if (getValueForKey(altname, &str, &size, &bootInfo->smbiosConfig) ||
if (smbios_properties[j].auto_str && randomSerial && (!strcmp ("SMserial", smbios_properties[j].name)))
{
str = smbios_properties[j].auto_str(smbios_properties[j].name, tablespresent[newcur->type]);
size = strlen(str);
memcpy(newtablesptr, str, size);
newtablesptr[size] = 0;
newtablesptr += size + 1;
*((uint8_t*)(((char*)newcur) + smbios_properties[j].offset)) = ++nstrings;
} else if (getValueForKey(altname, &str, &size, &bootInfo->smbiosConfig) ||
getValueForKey(smbios_properties[j].name, &str, &size, &bootInfo->smbiosConfig))
{
memcpy(newtablesptr, str, size);
branches/cparm/i386/modules/SMBiosPatcher/smbios_patcher.h
1414
1515
1616
17
18
1719
1820
1921
#define kSMBIOSdefaults"SMBIOSdefaults"/* smbios_patcher.c */
#define kSMBIOSRandomSerial"randomSerial"
extern uint64_t smbios_p;
struct smbios_table_header
branches/cparm/i386/modules/SMBiosPatcher/README
1
1
please do not use SMBiosGetters and SMBiosPatcher together, you have to chose one of them (SMBiosGetters is recommended), this issue will be fixed in the next versions
please do not use SMBiosGetters and SMBiosPatcher together, you have to chose one of them , this issue will be fixed in the next versions
branches/cparm/i386/libsa/libsa.h
148148
149149
150150
151
152
153
154151
155
152
153
156154
157155
158
159156
160157
158
159
160
161
162
163
164
165
166
167
168
169
161170
162171
163
164
172
173
165174
166175
extern void * realloc(void * ptr, size_t size);
//#if SAFE_MALLOC
//#define malloc(size) safe_malloc(size, __FILE__, __LINE__)
//extern void malloc_init(char * start, int size, int nodes, void (*malloc_error)(char *, size_t, const char *, int));
//extern void * safe_malloc(size_t size, const char *file, int line);
//extern size_t zalloced_size;
//#else
//#endif
extern void malloc_init(char * start, int size, int nodes, void (*malloc_error)(char *, size_t));
extern void * malloc(size_t size);
//#endif
/*
* rand.c
*
* rand & srand implementation for chameleon by Cadet-petit Armel <armelcadetpetit@gmail.com>
*/
extern int rand (void);
extern void srand (unsigned int seed);
/*
* getsegbyname.c
*/
extern struct segment_command *
getsegbynamefromheader(struct mach_header * mhp, char * segname);
//extern struct segment_command *
// getsegbynamefromheader(struct mach_header * mhp, char * segname);
#endif /* !__BOOT_LIBSA_H */
branches/cparm/i386/libsa/rand.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
/*
*
* rand & srand implementation for chameleon by Cadet-petit Armel <armelcadetpetit@gmail.com>
*/
#include "libsa.h"
static long holdrand = 1L;
#defineRAND_MAX0x7fffffff
void srand (unsigned int seed)
{
holdrand = (long)seed;
}
int rand (void)
{
holdrand = holdrand * 214013L + 2531011L;
return ((holdrand >> 16) & RAND_MAX);
}
branches/cparm/i386/libsa/zalloc.c
6464
6565
6666
67
68
69
70
71
72
6773
6874
6975
......
104110
105111
106112
107
113
108114
109
115
110116
111117
112118
......
180186
181187
182188
183
184
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
185205
186
206
187207
188
208
189209
190
191
210
211
192212
193
213
194214
195215
196216
197
198
199
200
217
201218
202219
203220
static void malloc_error(char *addr, size_t size);
#endif
#ifdef SAFE_MALLOC
static void * Safe_Malloc(size_t size, const char *file, int line);
#else
static void * Malloc(size_t size);
#endif
#if ZDEBUG
size_t zalloced_size;
#endif
#define BEST_FIT 1
#ifdef SAFE_MALLOC
void * safe_malloc(size_t size, const char *file, int line)
static void * Safe_Malloc(size_t size, const char *file, int line)
#else
void * malloc(size_t size)
static void * Malloc(size_t size)
#endif
{
int i;
}
#endif
done:
if ((ret == 0) || (ret + size >= zalloc_end))
done:
#if ZDEBUG
zalloced_size += size;
#endif
return (void *) ret;
}
void *
malloc (size_t size)
{
#ifdef SAFE_MALLOC
register void *ret = Safe_Malloc( size, __FILE__, __LINE__);
#else
register void *ret = Malloc (size);
#endif
if (ret == 0 || ((char *)ret + size >= zalloc_end))
{
if (zerror)
if (zerror)
#ifdef SAFE_MALLOC
(*zerror)(ret, size, file, line);
(*zerror)(ret, size, __FILE__, __LINE__);
#else
(*zerror)(ret, size);
#endif
(*zerror)(ret, size);
#endif
}
if (ret != 0)
else if (ret != 0)
{
bzero(ret, size);
}
#if ZDEBUG
zalloced_size += size;
#endif
return (void *) ret;
return ret;
}
void free(void * pointer)
branches/cparm/i386/libsa/string.c
5555
5656
5757
58
58
5959
6060
6161
6262
63
63
6464
6565
6666
......
106106
107107
108108
109
109
110110
111111
112112
......
120120
121121
122122
123
123
124124
125125
126126
......
371371
372372
373373
374
375
376
377
378
379
380
381
382
383
384
385
386
{
memset(dst, 0, len);
}
/*
void __bzero(void * dst, size_t len)
{
memset(dst, 0, len);
}
*/
#else
void * memcpy(void * dst, const void * src, size_t len)
{
: "c" (len), "D" (dst)
: "memory", "%eax" );
}
/*
void __bzero(void * dst, size_t len)
{
asm volatile ( "xorl %%eax, %%eax \n\t"
:
: "c" (len), "D" (dst)
: "memory", "%eax" );
}
}*/
#endif
/* #if DONT_USE_GCC_BUILT_IN_STRLEN */
return result;
}
static long holdrand = 1L;
#defineRAND_MAX0x7fffffff
void srand (unsigned int seed)
{
holdrand = (long)seed;
}
int rand (void)
{
holdrand = holdrand * 214013L + 2531011L;
return ((holdrand >> 16) & RAND_MAX);
}

Archive Download the corresponding diff file

Revision: 1654