@@ -183,7 +183,7 @@ class SoInfoPatch
183183 bool check1 = (it.is_rw && it.startAddress >= nb_impl_elf.bss () && it.endAddress <= (nb_impl_elf.bss ()+nb_impl_elf.bssSize ()));
184184
185185 // search in "[anon:Mem_x]" read-only regions
186- bool check2 = (it.is_ro && KittyUtils::string_startswith (it.pathname , " [anon:Mem_" ));
186+ bool check2 = (it.is_ro && KittyUtils::String::StartsWith (it.pathname , " [anon:Mem_" ));
187187
188188 // search in "[anon:linker_alloc]" read-only regions
189189 bool check3 = (it.is_ro && it.pathname == " [anon:linker_alloc]" );
@@ -227,13 +227,10 @@ class SoInfoPatch
227227 return results;
228228 }
229229
230- for (auto & it : maps)
230+ // search in nb implementation rw regions
231+ for (auto & it : nb_impl_elf.segments ())
231232 {
232- if (!it.is_private || it.length < 0xFFFF )
233- continue ;
234-
235- // search in nb implementation rw regions
236- if (!(it.is_rw && it.startAddress >= nb_impl_elf.base () && it.endAddress <= nb_impl_elf.end ()))
233+ if (!it.is_private || !it.is_rw )
237234 continue ;
238235
239236 auto results = _kMgr->memScanner .findDataAll (it.startAddress , it.endAddress , &si, sizeof (si));
@@ -286,14 +283,14 @@ class SoInfoPatch
286283 if (sohead_elf.isValid () && it.startAddress >= sohead_elf.base ())
287284 continue ;
288285
289- if (!KittyUtils::string_contains (it.pathname , arch))
286+ if (!KittyUtils::String::Contains (it.pathname , arch))
290287 continue ;
291288
292289 auto fileName = KittyUtils::fileNameFromPath (it.pathname );
293290 auto fileExtension = KittyUtils::fileExtension (it.pathname );
294291
295292 bool is_libc = fileName == " libc.so" ;
296- bool is_app_process = fileExtension.empty () && KittyUtils::string_startswith (fileName, " app_process" );
293+ bool is_app_process = fileExtension.empty () && KittyUtils::String::StartsWith (fileName, " app_process" );
297294
298295 if (!is_libc && !is_app_process)
299296 continue ;
@@ -307,11 +304,11 @@ class SoInfoPatch
307304 sohead_elf = tmp;
308305 }
309306
310- // our injected elf is loaded before libc / app_process ?
311- if (!sohead_elf.isValid () || sohead_elf. base () > elf. base () )
307+ // nb libc / app_process not loaded yet.
308+ if (!sohead_elf.isValid ())
312309 {
313310 // don't have solution for this yet, increase injection delay for now
314- KITTY_LOGE (" SoInfoPatch: Failed to remove elf(%p) (first in solist). " , ( void *)elf. base () );
311+ KITTY_LOGE (" SoInfoPatch: Failed to find sohead ELF. " );
315312 return false ;
316313 }
317314
@@ -363,7 +360,7 @@ class SoInfoPatch
363360
364361 if (!trav)
365362 {
366- KITTY_LOGE (" SoInfoPatch: elf(%p) is not in solist." , (void *)elf.base ());
363+ KITTY_LOGE (" SoInfoPatch: elf(%p) is not in solist or was loaded before sohead ." , (void *)elf.base ());
367364 return false ;
368365 }
369366
0 commit comments