I would like to prevent loading of malicious DLLs that may be possible through access of the current working directory as described in http://msdn.microsoft.com/en-us/library/ff919712(VS.85).aspx
The solution implemented in our C++ apps was to make a WinAPI call to SetDllDirectory(""), which would effectively remove the current working directory from the Windows DLL loading search path. However, it seems this solution is not available for our Delphi apps because the SetDllDirectory() function doesn't exist.
Is there an equivalent call in Delphi that does the same thing as SetDllDirectory("")? Thanks!
Windows.pas
, it is generally really easy to declare it yourself. All you need is the information at the MSDN, where the data types of the argument and result are specified, as is the DLL to look in. In most cases, the types used there can be used even in Delphi as well (such as HBRUSH, HWND, etc.), or you can use an equivalent type (such ascardinal
, orTHWND
). Just don't forget to set the calling convention tostdcall
. – Andreas Rejbrand Oct 28 '10 at 21:58