1 | //␊ |
2 | // binaryPatcher.h␊ |
3 | // ␊ |
4 | // binary patcher of any kinds (kexts, kernel, ACPI tables etc..)␊ |
5 | //␊ |
6 | //␊ |
7 | ␊ |
8 | #ifndef binaryPatcher_h␊ |
9 | #define binaryPatcher_h␊ |
10 | ␊ |
11 | #include <string.h>␊ |
12 | #include <stdbool.h>␊ |
13 | #include <libkern/OSTypes.h>␊ |
14 | #include "saio_types.h"␊ |
15 | #include "libsaio.h"␊ |
16 | #include "xml.h"␊ |
17 | ␊ |
18 | #include "bootargs.h"␊ |
19 | #include "saio_types.h"␊ |
20 | #include "bios.h"␊ |
21 | #include "device_tree.h"␊ |
22 | ␊ |
23 | // Micky1979: Next five functions (+ needed struct) are to split a string like "10.10.5,10.7,10.11.6,10.8.x"␊ |
24 | // in their components separated by comma (in this case)␊ |
25 | struct MatchOSes {␊ |
26 | int count;␊ |
27 | char* array[100];␊ |
28 | };␊ |
29 | ␊ |
30 | /** Returns a boolean and then enable disable the patch if MachOSEntry have a match for the booted OS. */␊ |
31 | bool IsPatchEnabled(char *MatchOSEntry, char *CurrOS);␊ |
32 | ␊ |
33 | /** return true if a given os contains '.' as separator,␊ |
34 | and then match components of the current booted OS. Also allow 10.10.x format meaning all revisions␊ |
35 | of the 10.10 OS */␊ |
36 | bool IsOSValid(char *MatchOS, char *CurrOS);␊ |
37 | ␊ |
38 | /** return MatchOSes struct (count+array) with the components of str that contains the given char sep as separator. */␊ |
39 | struct MatchOSes *GetStrArraySeparatedByChar(char *str, char sep);␊ |
40 | ␊ |
41 | /** free MatchOSes struct and its array. */␊ |
42 | void deallocMatchOSes(struct MatchOSes *s);␊ |
43 | ␊ |
44 | /** count occurrences of a given char in a char* string. */␊ |
45 | int countOccurrences( char *s, char c );␊ |
46 | ␊ |
47 | ␊ |
48 | unsigned int FindAndReplace(void *sourceData,␊ |
49 | UInt32 SourceSize,␊ |
50 | UInt32 StartLocation,␊ |
51 | UInt8 *Search,␊ |
52 | unsigned int SearchSize,␊ |
53 | UInt8 *Replace,␊ |
54 | int MaxReplaces);␊ |
55 | ␊ |
56 | unsigned int FindAndCount(void *sourceData,␊ |
57 | UInt32 SourceSize,␊ |
58 | UInt32 StartLocation,␊ |
59 | UInt8 *Search,␊ |
60 | unsigned int SearchSize);␊ |
61 | ␊ |
62 | void pach_binaryUsingDictionary(void *data,␊ |
63 | UInt32 dataLen,␊ |
64 | UInt32 StartLocation,␊ |
65 | char *reason,␊ |
66 | TagPtr config);␊ |
67 | ␊ |
68 | #endif /* binaryPatcher_h */␊ |
69 | |