IceReaper
IceReaper
CC#
Created by IceReaper on 12/21/2023 in #help
Safe Plugin Loader - Forbid specific namespaces (and reflection usage)?
Im trying to wire a plugin loader where people can extend the application with custom plugins. To ensure people cannot do evil things in their plugin, i want to explicitly whitelist namespaces people can use. If anything forbidden is used in a plugin .dll, i want to reject loading it. The loading and unloading part is the easiest thing, but what about the namespace restrictions? Anyone has any idea how i can do that? Also i need to forbid the usage of .GetType or typeof() to get around reflection usage. My idea would be by either hand-parse the .dll, somehow find all namespace or function references, and evaluate this manualy as im unaware of any other method. But maybe there is?
33 replies
CC#
Created by IceReaper on 1/18/2023 in #help
❔ How to calculate with numbers which are typed as object?
I have a function which gets a List<object> parameter. Several different sources are actually adding a value to the list, which might be anything from byte to decimal. Basicaly any buildin number type. Im trying to calculate using the values in the list, one after another. However its not possible to simply to "a + b" if both are only known as "object". I could ofcourse do 15 * 15 type checks (possible number types) for a and b, just to be able to sum them and get the appropriete result (int + int = int, int + float = float, ...). Is there any better solution to this at all? Help would be very appreciated!
9 replies