Sometimes we read that malware infections start thanks to .dll files code injection. But what is a DLL? A DLL (Dynamic Link Library) is a library which can contains methods (pieces of source code that could return a result for example an integer, a string, boolean, etc.), but obviously methods could also return nothing (but instead this type of methods do stuff in the body of the method but without a result, this is called void method).
The power of DLL files is that they can be used by software by importing them and use library source code without rewrite all the source code of the library, but instead use simply and fastly the DLL source code. To stay a bit safer against DLL injection it is possible to do not permit processes to get high privileges, so privilege escalation.
Example of DLL:
Ok guys, now to use a method of a DLL we can use this:
The power of DLL files is that they can be used by software by importing them and use library source code without rewrite all the source code of the library, but instead use simply and fastly the DLL source code. To stay a bit safer against DLL injection it is possible to do not permit processes to get high privileges, so privilege escalation.
Example of DLL:
C#:
namespace DLL1
{
public class DLL1Class
{
public static int algorithm(int n)
{
n++; //do a simple increment here
return n;
}
}
}
Ok guys, now to use a method of a DLL we can use this:
C#:
DLL1.DLL1Class.algorithm(6);