04-27-2018, 01:39 PM | #1 |
Wizard
Posts: 2,731
Karma: 6681393
Join Date: May 2016
Location: Ontario, Canada
Device: Kobo Mini, Aura Edition 2 v1, Clara HD
|
kobopatch - A new (WIP) patching system
Continued from https://www.mobileread.com/forums/sh...77#post3686505
--- I'm working on a new patching system written in Go as a replacement for patch32lsb. The code is on GitHub here. It will have many more advantages for example:
So far, I've finished a drop-in replacement for patch32lsb (with the old format) here which can be downloaded here. Please use this to test my patching system to make sure it produces the exact same results as the original patch32lsb. On Linux, this can be automated with the testallnickel and testalllibnickel scripts in the root of the repository. As far as I have tested, it seems to work well. The reason why it can be tested this way is because my patching system is modular, and the format is separated from the patching system itself. I've also almost finished a working POC for the new all-in-one patcher. Here (minus README.md and oldpatches) is a sample of the layout, and here is a sample (which is subject to change) of the features of the new patch format. This thread is old. See https://www.mobileread.com/forums/sh....php?p=3697837 Last edited by geek1011; 05-27-2018 at 03:08 PM. |
04-27-2018, 01:39 PM | #2 |
Wizard
Posts: 2,731
Karma: 6681393
Join Date: May 2016
Location: Ontario, Canada
Device: Kobo Mini, Aura Edition 2 v1, Clara HD
|
Here are some regexps I'm working on to convert the patches to my (WIP) new format (the output needs to be checked, as these don't cover edge cases):
Note: These need to be applied without case sensitivity. replace_bytes: Spoiler:
replace_int: Spoiler:
replace_float: Spoiler:
base_address: Spoiler:
patch_name: Spoiler:
patch_enable: Spoiler:
find_base_address: Spoiler:
replace_string: Spoiler:
patch_group: Spoiler:
patch: Spoiler:
The description and cleanup needs to be done manually, and the output needs to be checked. Last edited by geek1011; 04-27-2018 at 09:58 PM. |
Advert | |
|
04-27-2018, 01:40 PM | #3 |
Wizard
Posts: 2,731
Karma: 6681393
Join Date: May 2016
Location: Ontario, Canada
Device: Kobo Mini, Aura Edition 2 v1, Clara HD
|
reserved 1
|
04-27-2018, 01:40 PM | #4 |
Wizard
Posts: 2,731
Karma: 6681393
Join Date: May 2016
Location: Ontario, Canada
Device: Kobo Mini, Aura Edition 2 v1, Clara HD
|
reserved 2
|
04-27-2018, 01:50 PM | #5 | ||||||
Wizard
Posts: 2,731
Karma: 6681393
Join Date: May 2016
Location: Ontario, Canada
Device: Kobo Mini, Aura Edition 2 v1, Clara HD
|
Anything in bold is something I want more opinions about.
Quote:
Quote:
Quote:
Quote:
Quote:
Quote:
|
||||||
Advert | |
|
04-27-2018, 01:58 PM | #6 |
Wizard
Posts: 2,731
Karma: 6681393
Join Date: May 2016
Location: Ontario, Canada
Device: Kobo Mini, Aura Edition 2 v1, Clara HD
|
I've implemented a new instruction for the new patch format: FindReplaceString.
An example: Instead of: Code:
- FindBaseAddress: "ReadingFooter {\n qproperty-footerMargin: 105;\n}\n" - ReplaceString: {Offset: 0x0, Find: "ReadingFooter {\n qproperty-footerMargin: 105;\n}\n", Replace: "ReadingFooter {min-height:15px;max-height:15px;}\n"} Code:
- FindReplaceString: {Find: "ReadingFooter {\n qproperty-footerMargin: 105;\n}\n", Replace: "ReadingFooter {min-height:15px;max-height:15px;}\n"} |
04-27-2018, 02:13 PM | #7 |
Wizard
Posts: 2,731
Karma: 6681393
Join Date: May 2016
Location: Ontario, Canada
Device: Kobo Mini, Aura Edition 2 v1, Clara HD
|
I've now implemented PatchGroup checking in the new patch format. kobopatch will give an error if more than 1 enabled patch has the same PatchGroup.
|
04-27-2018, 02:17 PM | #8 | ||
Grand Sorcerer
Posts: 6,208
Karma: 16534692
Join Date: Sep 2009
Location: UK
Device: Kobo: KA1, ClaraHD, Forma, Libra2, Clara2E. PocketBook: TouchHD3
|
Quote:
Quote:
I'm not sure CSS Id (e.g /* found: 116 (zlib) pos: 45e7e8 */) is any help because the id number (116 in my example) changes with every firmware, even if the CSS content itself hasn't changed. I believe it's always possible to define a unique string to identify the required CSS stream, (e.g. #N3TableOfContentsWidget[qApp_deviceIsTrilogy=true]), but you can't rely on being able to find a unique string which starts at the first character in the stream. |
||
04-27-2018, 02:21 PM | #9 |
Grand Sorcerer
Posts: 6,208
Karma: 16534692
Join Date: Sep 2009
Location: UK
Device: Kobo: KA1, ClaraHD, Forma, Libra2, Clara2E. PocketBook: TouchHD3
|
Can you also consider creating a physical output log .txt file. When users have problems, it might be helpful if it's easy for them to attach their error log when they ask for help. Or are you planning to make the new system so easy no-one ever makes silly mistakes
|
04-27-2018, 02:24 PM | #10 |
Wizard
Posts: 2,731
Karma: 6681393
Join Date: May 2016
Location: Ontario, Canada
Device: Kobo Mini, Aura Edition 2 v1, Clara HD
|
I've now implemented a Description option in the new patch format. This makes it look a lot cleaner.
Here is an example patch using Description, FindReplaceString, and PatchGroup: Code:
# Versions: 4.6.9960 - 4.8.10956+ Disable Reading Footer: - Enabled: true - PatchGroup: Test Patch Group - Description: | Removes the reading footer for both ePub and KePub books, leaving a 15px bottom margin which matches the 15px built-in top margin of ePub books. - FindReplaceString: {Find: "ReadingFooter {\n qproperty-footerMargin: 105;\n}\n", Replace: "ReadingFooter {min-height:15px;max-height:15px;}\n"} - FindReplaceString: {Find: "#caption[qApp_deviceIsTrilogy=true] {\n font-size: 19px;\n}\n", Replace: "#caption {font-size:1px;color:transparent;}\n\0"} |
04-27-2018, 02:27 PM | #11 |
Grand Sorcerer
Posts: 6,229
Karma: 11768331
Join Date: Jun 2009
Location: Madrid, Spain
Device: Kobo Clara/Aura One/Forma,XiaoMI 5, iPad, Huawei MediaPad, YotaPhone 2
|
A converter would be nice... for Geoff and oren_64. The rest of us copy and paste text at best. I think, in the long term, it will be simpler to maintain only a format for the patches.
|
04-27-2018, 02:29 PM | #12 | ||
Wizard
Posts: 2,731
Karma: 6681393
Join Date: May 2016
Location: Ontario, Canada
Device: Kobo Mini, Aura Edition 2 v1, Clara HD
|
Quote:
Also, should I make an option to dump the CSS? Quote:
|
||
04-27-2018, 02:34 PM | #13 | |
Wizard
Posts: 2,731
Karma: 6681393
Join Date: May 2016
Location: Ontario, Canada
Device: Kobo Mini, Aura Edition 2 v1, Clara HD
|
Quote:
For copying and pasting, an advantage of my format is long patches (such as zlib ones) can be made into 1 line if needed. Here is an example: Short: Code:
{'Disable Reading Footer': [{Enabled: true}, {Description: "Removes the reading footer for both ePub and KePub books, leaving a 15px\nbottom margin which matches the 15px built-in top margin of ePub books.\n"}, {FindReplaceString: {Find: "ReadingFooter {\n qproperty-footerMargin: 105;\n}\n", Replace: "ReadingFooter {min-height:15px;max-height:15px;}\n"}}, {FindReplaceString: {Find: "#caption[qApp_deviceIsTrilogy=true] {\n font-size: 19px;\n}\n", Replace: "#caption {font-size:1px;color:transparent;}\n\0"}}]}
Code:
# Versions: 4.6.9960 - 4.8.10956+
Disable Reading Footer:
- Enabled: true
- Description: |
Removes the reading footer for both ePub and KePub books, leaving a 15px
bottom margin which matches the 15px built-in top margin of ePub books.
- FindReplaceString: {Find: "ReadingFooter {\n qproperty-footerMargin: 105;\n}\n", Replace: "ReadingFooter {min-height:15px;max-height:15px;}\n"}
- FindReplaceString: {Find: "#caption[qApp_deviceIsTrilogy=true] {\n font-size: 19px;\n}\n", Replace: "#caption {font-size:1px;color:transparent;}\n\0"}
Long: Code:
# Versions: 4.6.9960 - 4.8.10956+
Disable Reading Footer:
- Enabled: true
- Description: |
Removes the reading footer for both ePub and KePub books, leaving a 15px
bottom margin which matches the 15px built-in top margin of ePub books.
- FindReplaceString:
Find: "ReadingFooter {\n qproperty-footerMargin: 105;\n}\n"
Replace: "ReadingFooter {min-height:15px;max-height:15px;}\n"
- FindReplaceString:
Find: "#caption[qApp_deviceIsTrilogy=true] {\n font-size: 19px;\n}\n"
Replace: "#caption {font-size:1px;color:transparent;}\n\0"
Last edited by geek1011; 04-27-2018 at 02:37 PM. |
|
04-27-2018, 02:41 PM | #14 | |
Grand Sorcerer
Posts: 6,208
Karma: 16534692
Join Date: Sep 2009
Location: UK
Device: Kobo: KA1, ClaraHD, Forma, Libra2, Clara2E. PocketBook: TouchHD3
|
Quote:
Yes - for those who create/maintain patches. Not necessary for the average user, though. |
|
04-27-2018, 02:48 PM | #15 | |
Wizard
Posts: 2,731
Karma: 6681393
Join Date: May 2016
Location: Ontario, Canada
Device: Kobo Mini, Aura Edition 2 v1, Clara HD
|
Quote:
Also, can someone who knows about the internals of the CSS patches like @oren64 or @GeoffR tell me a bit about how to extract it? I've been getting stuck on properly finding the right Zlib streams. |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Glo [WIP] Port of Kindle Paperwhite OS | giorgio130 | Kobo Developer's Corner | 59 | 04-26-2016 08:25 AM |
Android [WIP] Overclocking the PE | plasticarmyman | enTourage eDGe | 16 | 06-11-2012 07:08 PM |
Seriously thoughtful I always knew Windows was a WIP | GeoffC | Lounge | 4 | 02-06-2010 02:20 AM |
Thirty - WIP - comments wanted | ravenlife | Writers' Corner | 20 | 08-16-2009 12:10 PM |
Opinions needed on a WIP ebook | Nate the great | Workshop | 5 | 07-15-2009 11:38 AM |