rizinorg / ideas

Features that would be nice to have but they are not in the roadmap
3 stars 0 forks source link

Persistent state/buffer module #51

Open Rot127 opened 11 months ago

Rot127 commented 11 months ago

It would be nice if we would have a module, which allows other modules (RzArch for example) to persists its internal state for a certain lifetime.

I think it would be useful to implement this without any connection to an existing module.

Feature could be:

Practical example where it would be useful are token patterns. Those can be compiled once on the asm module init. And then used every time something is disassembled. But currently those compiled patterns can not be easily stored somewhere.

Rot127 commented 5 months ago

@XVilka suggested a one time writable hash-table as basic data-structure for this. Alternatively, though more complex, leveraging [incremental computing](Wikipedia Main Image Incremental computing like anchors

ret2libc commented 5 months ago

I'm not sure I understand the original idea. Can't we store stuff in the main module? For example, in RzArch->cache or whatever.

Rot127 commented 5 months ago

We could. But this would invalidate the whole cache if RzArch is reset. And some computations just have to be done once globally.

But yes, for module specific caches we could do RzArch->cache. But even for those it would be nice to a have a unified cache module IMHO.

ret2libc commented 5 months ago

Can we have the cache "injected" into the various RzArch? Like, if we need to instantiate several RzArch, we could store the needed "global" caches in RzCore and pass them in the rz_arch_new constructor.

Rot127 commented 5 months ago

Sounds good to me. This would not break our hierarchy core->arch->plugin. Was this your intention?

It would be nice though to control what cached data survives an inject and what not. E.g. arch specific cached values can be dropped, if a new RzArch with a different architecture is initialized. But pre-compiled regex patterns to match function names, should stay in the cache, no matter for what archictecture RzArch is initialized (because we might want to match malloc function names for every architecture).