Chameleon

Chameleon Commit Details

Date:2012-05-30 14:25:59 (7 years 2 months ago)
Author:armel cadet-petit
Commit:1986
Parents: 1985
Message:updated __doprnt, strings format are now normalized
Changes:
M/branches/cparm/i386/libsaio/device_tree.c
M/branches/cparm/i386/libsaio/load.c
M/branches/cparm/i386/libsaio/hfs.c
M/branches/cparm/i386/modules/Keymapper/Keymapper.c
M/branches/cparm/i386/modules/SMBiosGetters/mysmbios.c
M/branches/cparm/Chameleon.xcodeproj/project.pbxproj
M/branches/cparm/i386/libsaio/hfs_compare.c
M/branches/cparm/i386/libsaio/fake_efi.c
M/branches/cparm/i386/libsaio/disk.c
M/branches/cparm/i386/modules/SMBiosPatcher/smbios_patcher.c
M/branches/cparm/i386/libsaio/device_inject.c
M/branches/cparm/i386/libsaio/ufs.c
M/branches/cparm/i386/boot2/options.c
M/branches/cparm/i386/boot2/Makefile
M/branches/cparm/i386/libsaio/console.c
M/branches/cparm/i386/libsaio/bootXnu.h
M/branches/cparm/i386/boot2/boot.c
M/branches/cparm/TODO
M/branches/cparm/i386/libsa/printf.c
M/branches/cparm/CHANGES

File differences

branches/cparm/TODO
11
22
33
4
5
64
75
86
TODO List for Chameleon Boot Loader
====================================
- Try to sync our prf() with the apple/mach __doprnt() (in Xnu/osfmk/kern/printf.c) to normalize the formating in our printf, sprintf, etc ..., and facilitate bug fixes (almost done !!)
- split nvidia, gma and ati code into separate modules
- move device_inject, MBR (OSX works better on Guid partition theme anyway), winfs, bsdfs, ext2fs, befs, and the command lspci, memory, more and video into modules
- Implement a pool allocator, so each module will run and allocate memory in there own pool, de-alloc all allocated memory by the module,
branches/cparm/Chameleon.xcodeproj/project.pbxproj
210210
211211
212212
213
214213
215214
216215
......
953952
954953
955954
956
957955
958956
959957
AB43B2E214C37E520018D529 /* libsa.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = libsa.h; sourceTree = "<group>"; };
AB43B2E314C37E520018D529 /* Makefile */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.make; path = Makefile; sourceTree = "<group>"; };
AB43B2E414C37E520018D529 /* memory.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = memory.h; sourceTree = "<group>"; };
AB43B2E514C37E520018D529 /* prf.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = prf.c; sourceTree = "<group>"; };
AB43B2E614C37E520018D529 /* printf.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = printf.c; sourceTree = "<group>"; };
AB43B2E714C37E520018D529 /* qsort.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = qsort.c; sourceTree = "<group>"; };
AB43B2E914C37E520018D529 /* setjmp.s */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.asm; path = setjmp.s; sourceTree = "<group>"; };
AB43B2E214C37E520018D529 /* libsa.h */,
AB43B2E314C37E520018D529 /* Makefile */,
AB43B2E414C37E520018D529 /* memory.h */,
AB43B2E514C37E520018D529 /* prf.c */,
AB43B2E614C37E520018D529 /* printf.c */,
AB43B2E714C37E520018D529 /* qsort.c */,
AB43B2E914C37E520018D529 /* setjmp.s */,
branches/cparm/CHANGES
1
2
3
14
25
36
- security, stability, bugs fixes
- moved __doprnt to the xnu version
- security and stability fixes
- Fixed a bug where prf may return a wrong string len (for ex : in the previous versions newStringWithformat("%02x%02x%02x%02x%02x%02x",101,117,104,113,103,100) may not return the entire string)
- Fixed a bug in xml.c
branches/cparm/i386/libsaio/console.c
103103
104104
105105
106
106107
107108
108109
......
113114
114115
115116
116
117
117118
118119
119120
*/
void putchar(char c)
{
if ( c == '\t' )
{
for (c = 0; c < 8; c++) putc(' ');
{
putc('\r');
}
putc(c);
}
branches/cparm/i386/libsaio/device_tree.c
7474
7575
7676
77
77
7878
7979
8080
......
110110
111111
112112
113
113
114114
115115
116116
......
142142
143143
144144
145
145
146146
147147
148
149
148
149
150150
151151
152152
......
205205
206206
207207
208
208
209209
210210
211211
......
269269
270270
271271
272
272
273273
274274
275275
......
331331
332332
333333
334
334
335335
336336
337337
......
347347
348348
349349
350
350
351351
352352
353353
{
Property *prop;
DPRINTF("DT__AddProperty([Node '%s'], '%s', %d, 0x%x)\n", DT__GetName(node), name, length, value);
DPRINTF("DT__AddProperty([Node '%s'], '%s', %d, %p)\n", DT__GetName(node), name, length, value);
if (freeProperties == NULL) {
void *buf = malloc(kAllocSize);
if (buf == 0) return 0;
node->last_prop = prop;
prop->next = 0;
DPRINTF("Done [0x%x]\n", prop);
DPRINTF("Done [%p]\n", prop);
DTInfo.numProperties++;
DTInfo.totalPropertySize += RoundToLong(length);
node++;
}
}
DPRINTF("DT__AddChild(0x%x, '%s')\n", parent, name);
DPRINTF("DT__AddChild(%p, '%s')\n", parent, name);
node = freeNodes;
freeNodes = node->next;
DPRINTF("Got free node 0x%x\n", node);
DPRINTF("prop = 0x%x, children = 0x%x, next = 0x%x\n", node->properties, node->children, node->next);
DPRINTF("Got free node %p\n", node);
DPRINTF("prop = %p, children = %p, next = %p\n", node->properties, node->children, node->next);
if (parent == NULL) {
rootNode = node;
for (prop = allocedProperties; prop != NULL; prop = prop->next) {
if (prop->value) free(prop->value);
if (prop->name) free(prop->name);
}
allocedProperties = NULL;
freeProperties = NULL;
uint32_t totalSize;
void *buf;
DPRINTF("DT__FlattenDeviceTree(0x%x, 0x%x)\n", buffer_p, length);
DPRINTF("DT__FlattenDeviceTree(%p, %u)\n", buffer_p, *length);
#if DEBUG
if (buffer_p) DT__PrintTree(rootNode);
#endif
// Start at root
node = rootNode;
DPRINTF("root = 0x%x\n", rootNode);
DPRINTF("root = %p\n", rootNode);
while (node) {
// Skip leading slash
DPRINTF("Node '%s'\n", nameBuf);
for (child = node->children; child != 0; child = child->next) {
DPRINTF("Child 0x%x\n", child);
DPRINTF("Child %p\n", child);
if (strcmp(DT__GetName(child), nameBuf) == 0) {
break;
}
branches/cparm/i386/libsaio/hfs.c
2727
2828
2929
30
30
3131
3232
3333
......
418418
419419
420420
421
422
423
421
422
423
424424
425425
426426
* DRI: Josh de Cesare
*/
#include <sl.h>
#include "sl.h"
#include <hfs/hfs_format.h>
#include "hfs.h"
}
#if DEBUG
printf("extent start 0x%x\n", (unsigned long)GetExtentStart(extents, 0));
printf("block size 0x%x\n", (unsigned long)gBlockSize);
printf("Allocation offset 0x%x\n", (unsigned long)gAllocationOffset);
printf("extent start 0x%lx\n", (unsigned long)GetExtentStart(extents, 0));
printf("block size 0x%lx\n", (unsigned long)gBlockSize);
printf("Allocation offset 0x%lx\n", (unsigned long)gAllocationOffset);
#endif
*firstBlock = ((unsigned long long)GetExtentStart(extents, 0) * (unsigned long long) gBlockSize + gAllocationOffset) / 512ULL;
return 0;
branches/cparm/i386/libsaio/hfs_compare.c
2727
2828
2929
30
30
3131
3232
3333
* DRI: Josh de Cesare
*/
#include <sl.h>
#include "sl.h"
#include "hfs_CaseTables.h"
#if ! UNCOMPRESSED
branches/cparm/i386/libsaio/ufs.c
2626
2727
2828
29
29
3030
3131
3232
*
* DRI: Josh de Cesare
*/
#include <sl.h>
#include "sl.h"
#include "ufs.h"
#include "ufs_byteorder.h"
branches/cparm/i386/libsaio/bootXnu.h
9191
9292
9393
94
95
96
97
98
99
100
101
102
103
104
94105
95106
96107
......
146157
147158
148159
149
160
150161
151162
152163
153
164
154165
155
166
156167
157168
158169
159170
160
171
161172
162
173
163174
164175
165
176
166177
167178
168
179
169180
170181
171182
172
183
173184
174185
175
186
176187
177188
178
189
179190
180191
181192
182193
183194
184195
185
186
196
197
198
199
200
187201
188202
189203
......
225239
226240
227241
242
243
244
245
228246
229
230
231
232
247
233248
234249
235250
......
275290
276291
277292
278
293
294
295
279296
280297
281298
typedef struct Boot_VideoBoot_Video;
/* Struct describing an image passed in by the booter */
struct boot_icon_element {
unsigned int width;
unsigned int height;
int y_offset_from_center;
unsigned int data_size;
unsigned int __reserved1[4];
unsigned char data[0];
};
typedef struct boot_icon_element boot_icon_element;
/* Values for v_display */
#define GRAPHICS_MODE 1
typedef struct boot_args_107 {
uint16_t Revision;/* Revision of boot_args structure */
uint16_t Version;/* Version of boot_args structure */
uint8_t efiMode; /* 32 = 32-bit, 64 = 64-bit */
uint8_t debugMode; /* Bit field with behavior changes */
uint8_t __reserved1[2];
char CommandLine[BOOT_LINE_LENGTH];/* Passed in command line */
uint32_t MemoryMap; /* Physical address of memory map */
uint32_t MemoryMapSize;
uint32_t MemoryMapDescriptorSize;
uint32_t MemoryMapDescriptorVersion;
Boot_VideoVideo;/* Video Information */
uint32_t deviceTreeP; /* Physical address of flattened device tree */
uint32_t deviceTreeLength; /* Length of flattened tree */
uint32_t kaddr; /* Physical address of beginning of kernel text */
uint32_t ksize; /* Size of combined kernel text+data+efi */
uint32_t efiRuntimeServicesPageStart; /* physical address of defragmented runtime pages */
uint32_t efiRuntimeServicesPageCount;
uint64_t efiRuntimeServicesVirtualPageStart; /* virtual address of defragmented runtime pages */
uint32_t efiSystemTable; /* physical address of system table in runtime area */
uint32_t __reserved2;
uint32_t performanceDataStart; /* physical address of log */
uint32_t performanceDataSize;
uint32_t keyStoreDataStart; /* physical address of key store data */
uint32_t keyStoreDataSize;
uint64_tbootMemStart;
uint64_tbootMemSize;
uint64_t PhysicalMemorySize;
uint64_t FSBFrequency;
uint32_t __reserved4[734];
uint64_t pciConfigSpaceBaseAddress;
uint32_t pciConfigSpaceStartBusNumber;
uint32_t pciConfigSpaceEndBusNumber;
uint32_t __reserved4[730];
} boot_args_107;
typedef struct boot_args_108 {
uint64_tbootMemSize;
uint64_t PhysicalMemorySize;
uint64_t FSBFrequency;
uint64_t pciConfigSpaceBaseAddress;
uint32_t pciConfigSpaceStartBusNumber;
uint32_t pciConfigSpaceEndBusNumber;
uint32_t __reserved4[730];
uint32_t __reserved3[4];
uint32_t __reserved4[730];
} boot_args_108;
} boot_args_108; // for now apparently the same package for 10.8 and 10.7
typedef struct boot_args_header {
uint16_t Revision;/* Revision of boot_args structure */
uint64_tbootMemSize;
uint64_t PhysicalMemorySize;
uint32_t __reserved[4];
uint64_t pciConfigSpaceBaseAddress;
uint32_t pciConfigSpaceStartBusNumber;
uint32_t pciConfigSpaceEndBusNumber;
} boot_args_10x;
typedef struct boot_args_10x boot_args_common;
branches/cparm/i386/libsaio/device_inject.c
182182
183183
184184
185
185
186
187
188
189
190
191
192
193
194
195
186196
187197
188198
......
305315
306316
307317
308
318
319
320
321
322
323
324
325
326
327
328
309329
310330
311331
......
407427
408428
409429
430
431
432
433
410434
411435
412436
......
454478
455479
456480
457
481
458482
459483
484
485
486
487
460488
461489
462490
......
464492
465493
466494
467
468
469495
470496
471
497
498
499
500
472501
473502
474503
}
struct DevPropDevice **string_entries_arrey = (struct DevPropDevice **) string->entries;
string->numentries++;
if ((string->numentries+1) < MAX_STRING_NUM_ENTRIES)
{
string->numentries++;
}
else
{
free(string->entries);
free(device);
return NULL;
}
string_entries_arrey[string->numentries-1] = device;
}
struct DevPropDevice **string_entries_arrey = (struct DevPropDevice **) string->entries;
string->numentries++;
if ((string->numentries+1) < MAX_STRING_NUM_ENTRIES)
{
string->numentries++;
}
else
{
free(string->entries);
free(device);
return NULL;
}
string_entries_arrey[string->numentries-1] = device;
while(i < string->numentries)
{
if (!(i<MAX_STRING_NUM_ENTRIES))
{
continue;
}
sprintf(buffer, "%08x%04x%04x", dp_swap32(string_entries_arrey[i]->length),
dp_swap16(string_entries_arrey[i]->numentries), string_entries_arrey[i]->WHAT2);
int i;
struct DevPropDevice **string_entries_arrey = (struct DevPropDevice **) string->entries;
for(i = 0; i < string->numentries; i++)
{
if (!(i<MAX_STRING_NUM_ENTRIES))
{
continue;
}
if(string_entries_arrey[i])
{
if(string_entries_arrey[i]->data)
free(string_entries_arrey[i]->data);
string_entries_arrey[i]->data = NULL;
}
free(string_entries_arrey[i]);
string_entries_arrey[i] = NULL;
}
}
free(string->entries);
string->entries = NULL;
free(string);
string = NULL;
}
branches/cparm/i386/libsaio/load.c
257257
258258
259259
260
260
261261
262262
263263
return 0;
}
#if DEBUG
#if 0
printf("segname: %s, vmaddr: %x, vmsize: %x, fileoff: %x, filesize: %x, nsects: %d, flags: %x.\n",
segCmd->segname, (unsigned)vmaddr, (unsigned)vmsize, (unsigned)fileaddr, (unsigned)filesize,
(unsigned) segCmd->nsects, (unsigned)segCmd->flags);
branches/cparm/i386/libsaio/disk.c
310310
311311
312312
313
313
314314
315315
316316
......
338338
339339
340340
341
342
341
342
343343
344344
345345
......
380380
381381
382382
383
384
383
384
385385
386386
387387
......
431431
432432
433433
434
434
435435
436436
437437
......
19551955
19561956
19571957
1958
1958
19591959
19601960
19611961
}
divisor = bps / BPS;
DEBUG_DISK(("Biosread dev %x sec %d bps %d\n", biosdev, secno, bps));
DEBUG_DISK(("Biosread dev %x sec %llu bps %d\n", biosdev, secno, bps));
// To read the disk sectors, use EBIOS if we can. Otherwise,
// revert to the standard BIOS calls.
rc = 0;
break;
}
printf(" EBIOS read error: %s\n", bios_error(rc), rc);
printf(" Block 0x%x Sectors %d\n", secno, xnsecs);
printf(" EBIOS read error (%d): %s\n", rc, bios_error(rc) );
printf(" Block 0x%llx Sectors %d\n", secno, xnsecs);
sleep(1);
}
}
rc = 0;
break;
}
printf(" BIOS read error: %s\n", bios_error(rc), rc);
printf(" Block %d, Cyl %d Head %d Sector %d\n",
printf(" BIOS read error(%d): %s\n", rc, bios_error(rc));
printf(" Block %llu, Cyl %d Head %d Sector %d\n",
secno, cyl, head, sec);
sleep(1);
}
int error;
int copy_len;
DEBUG_DISK(("%s: dev %x block %x [%d] -> 0x%x...", __FUNCTION__,
DEBUG_DISK(("%s: dev %x block %llu [%d] -> 0x%x...", __FUNCTION__,
biosdev, blkno, byteCount, (unsigned)cbuf));
for ( ; byteCount; cbuf += copy_len, blkno++ )
if (!bvr) {
break;
}
printf(" bvr: %d, dev: %d, part: %d, flags: %d, vis: %d\n", bvr, bvr->biosdev, bvr->part_no, bvr->flags, bvr->visible);
printf(" bvr: %p, dev: %d, part: %d, flags: %d, vis: %d\n", bvr, bvr->biosdev, bvr->part_no, bvr->flags, bvr->visible);
}
printf("count: %d\n", bvCount);
getc();
branches/cparm/i386/libsaio/fake_efi.c
696696
697697
698698
699
700
701
702
703
704
705
706
707
708
699
709700
710701
711702
......
748739
749740
750741
751
742
752743
753744
754745
kType = get_env(envType);
DT__AddProperty(node, SYSTEM_TYPE_PROP, sizeof(uint8_t), &kType);
}
#ifdef NO_BOOT_IMG
struct boot_progress_element {
unsigned intwidth;
unsigned intheight;
intyOffset;
unsigned intres[5];
unsigned chardata[0];
};
typedef struct boot_progress_element boot_progress_element;
#endif
static VOID setupEfiDeviceTree(void)
{
Node*node;
((boot_progress_element *)bootPict)->yOffset = kFailedBootOffset;
if (((BVRef)(uint32_t)get_env(envgBootVolume))->OSVersion[3] == '8')
{
((boot_progress_element *)bootPict)->res[0] = size - 32;
((boot_progress_element *)bootPict)->data_size = size - 32;
}
bcopy((char *)gFailedBootPict, (char *)(bootPict + 32), size - 32);
}
branches/cparm/i386/boot2/boot.c
528528
529529
530530
531
532
531
532
533533
534534
535535
}
#if DEBUG
printf(" Default: %d, ->biosdev: %d, ->part_no: %d ->flags: %d\n", ((BVRef)(uint32_t)get_env(envgBootVolume)), ((BVRef)(uint32_t)get_env(envgBootVolume))->biosdev, ((BVRef)(uint32_t)get_env(envgBootVolume))->part_no, ((BVRef)(uint32_t)get_env(envgBootVolume))->flags);
printf(" bt(0,0): %d, ->biosdev: %d, ->part_no: %d ->flags: %d\n", ((BVRef)(uint32_t)get_env(envgBIOSBootVolume)), ((BVRef)(uint32_t)get_env(envgBIOSBootVolume))->biosdev, ((BVRef)(uint32_t)get_env(envgBIOSBootVolume))->part_no, ((BVRef)(uint32_t)get_env(envgBIOSBootVolume))->flags);
printf(" Default: %p, ->biosdev: %d, ->part_no: %d ->flags: %d\n", ((BVRef)(uint32_t)get_env(envgBootVolume)), ((BVRef)(uint32_t)get_env(envgBootVolume))->biosdev, ((BVRef)(uint32_t)get_env(envgBootVolume))->part_no, ((BVRef)(uint32_t)get_env(envgBootVolume))->flags);
printf(" bt(0,0): %p, ->biosdev: %d, ->part_no: %d ->flags: %d\n", ((BVRef)(uint32_t)get_env(envgBIOSBootVolume)), ((BVRef)(uint32_t)get_env(envgBIOSBootVolume))->biosdev, ((BVRef)(uint32_t)get_env(envgBIOSBootVolume))->part_no, ((BVRef)(uint32_t)get_env(envgBIOSBootVolume))->flags);
getc();
#endif
branches/cparm/i386/boot2/options.c
268268
269269
270270
271
271
272
273
272274
273275
274276
else
putca(' ', 0x07, 40);
printf(" %40s\n", item->name);
char Item[40];
snprintf(Item, sizeof(Item), item->name);
printf(" %s\n", Item);
}
//==========================================================================
branches/cparm/i386/boot2/Makefile
7171
7272
7373
74
75
74
75
7676
7777
7878
CFLAGS += -DSAFE_MALLOC
GFLAGS += -DNO_MULTIBOOT_SUPPORT
#OBJS += mboot.o
#GFLAGS += -DNO_MULTIBOOT_SUPPORT
OBJS += mboot.o
# CFLAGS += -DBOOT_HELPER_SUPPORT # +992 bytes
branches/cparm/i386/modules/SMBiosGetters/mysmbios.c
543543
544544
545545
546
547
546
547
548548
549
549
550550
551551
552
552
553553
554554
555555
......
566566
567567
568568
569
569
570570
571571
572572
573573
574574
575
576
575
576
577577
578
579
578
579
580580
581581
582582
......
600600
601601
602602
603
604
603
604
605605
606606
607607
// Append all charaters to the string
char tmp[2];
bzero(tmp,sizeof(tmp));
sprintf(tmp,"%c",sn_gen_pn_str[rand_sn1]);
strlcpy (str, tmp, sizeof(tmp)+1);
snprintf(tmp, sizeof(tmp),"%c",sn_gen_pn_str[rand_sn1]);
strlcpy (str, tmp, sizeof(str));
sprintf(tmp,"%c",sn_gen_pn_str[rand_sn2]);
snprintf(tmp, sizeof(tmp),"%c",sn_gen_pn_str[rand_sn2]);
strcat (str, tmp);
sprintf(tmp,"%c",sn_gen_pn_str[rand_sn3]);
snprintf(tmp, sizeof(tmp),"%c",sn_gen_pn_str[rand_sn3]);
strcat (str, tmp);
DBG ("fake_productNumber: %s\n",str);
// Get randomized characters
int rand_week ;
rand_week = arc4random_unirange(0,47);
// Append all charaters to the string
char tmp[3];
bzero(tmp,sizeof(tmp));
if (rand_week < 10) {
sprintf(tmp,"0%d",rand_week);
strlcpy (str, tmp, sizeof(tmp)+1);
snprintf(tmp, sizeof(tmp),"0%d",rand_week);
strlcpy (str, tmp, sizeof(str));
} else if (rand_week < 100) { // avoid overflow in case random return a number >= 100
sprintf(tmp,"%d",rand_week);
strlcpy (str, tmp, sizeof(tmp)+1);
snprintf(tmp, sizeof(tmp),"%d",rand_week);
strlcpy (str, tmp, sizeof(str));
}
DBG ("fake_week: %s\n",str);
bzero(tmp,sizeof(tmp));
if (rand_year < 10) {
sprintf(tmp,"%d",rand_year);
strlcpy (str, tmp, sizeof(tmp)+1);
snprintf(tmp, sizeof(tmp),"%d",rand_year);
strlcpy (str, tmp, sizeof(str));
}
DBG ("fake_year: %s\n",str);
branches/cparm/i386/modules/Keymapper/Keymapper.c
199199
200200
201201
202
202
203
203204
204205
205206
206207
207208
208209
209
210
210
211
212
213
211214
212215
213216
......
227230
228231
229232
230
233
231234
232235
233236
234237
235238
236
239
237240
238241
239242
{
int *ret = (int *)arg1;
int c = *(int *)ret;
char *kMatchkey = NULL;
// Check for xml map in the config file
if (match_map == NULL)
match_map = XMLGetProperty(DEFAULT_BOOT_CONFIG_DICT, (const char*)"KeyboardMap");
if (match_map)
{
char *kMatchkey = 0;
sprintf(kMatchkey, "%d",c);
kMatchkey = newStringWithFormat("%d",c);
if (!kMatchkey) {
return;
}
TagPtr match_key;
if ((match_key = XMLGetProperty(match_map, (const char*)kMatchkey)))
{
map_kb_type = "NONE"; // Default to QWERTY
}
if (strcmp(map_kb_type, "AZERTY") == 0)
if (map_kb_type && (strcmp(map_kb_type, "AZERTY") == 0))
c = AZERTY_switch(c);
out:
*ret = c;
if (kMatchkey) free(kMatchkey);
}
void Keymapper_start(void);
branches/cparm/i386/modules/SMBiosPatcher/smbios_patcher.c
313313
314314
315315
316
317
316
317
318318
319
319
320320
321321
322
322
323323
324324
325325
......
336336
337337
338338
339
339
340340
341341
342342
343343
344344
345
346
345
346
347347
348
349
348
349
350350
351351
352352
......
370370
371371
372372
373
374
373
374
375375
376376
377377
// Append all charaters to the string
char tmp[2];
bzero(tmp,sizeof(tmp));
sprintf(tmp,"%c",sn_gen_pn_str[rand_sn1]);
strlcpy (str, tmp, sizeof(tmp)+1);
snprintf(tmp,sizeof(tmp),"%c",sn_gen_pn_str[rand_sn1]);
strlcpy (str, tmp, sizeof(str));
sprintf(tmp,"%c",sn_gen_pn_str[rand_sn2]);
snprintf(tmp,sizeof(tmp),"%c",sn_gen_pn_str[rand_sn2]);
strcat (str, tmp);
sprintf(tmp,"%c",sn_gen_pn_str[rand_sn3]);
snprintf(tmp,sizeof(tmp),"%c",sn_gen_pn_str[rand_sn3]);
strcat (str, tmp);
DBG ("fake_productNumber: %s\n",str);
// Get randomized characters
int rand_week ;
rand_week = arc4random_unirange(0,47);
// Append all charaters to the string
char tmp[3];
bzero(tmp,sizeof(tmp));
if (rand_week < 10) {
sprintf(tmp,"0%d",rand_week);
strlcpy (str, tmp, sizeof(tmp)+1);
snprintf(tmp,sizeof(tmp),"0%d",rand_week);
strlcpy (str, tmp, sizeof(str));
} else if (rand_week < 100) { // avoid overflow in case random return a number >= 100
sprintf(tmp,"%d",rand_week);
strlcpy (str, tmp, sizeof(tmp)+1);
snprintf(tmp,sizeof(tmp),"%d",rand_week);
strlcpy (str, tmp, sizeof(str));
}
DBG ("fake_week: %s\n",str);
bzero(tmp,sizeof(tmp));
if (rand_year < 10) {
sprintf(tmp,"%d",rand_year);
strlcpy (str, tmp, sizeof(tmp)+1);
snprintf(tmp,sizeof(tmp),"%d",rand_year);
strlcpy (str, tmp, sizeof(str));
}
DBG ("fake_year: %s\n",str);
branches/cparm/i386/libsa/printf.c
119119
120120
121121
122
123
122124
123125
124126
......
651653
652654
653655
654
656
655657
656658
657659
{
__doprnt(fmt, argp, dummy_putc, putc, radix);
}
#endif
#if 1
#define Ctod(c) ((c) - '0')
#define MAXBUF (sizeof(long long int) * 8)/* enough for binary */
return(retval);
}
#if 1
#if 0
/*
* Copyright (c) 1999-2003 Apple Computer, Inc. All rights reserved.
*

Archive Download the corresponding diff file

Revision: 1986