trparky
Member
- Joined
- Jun 18, 2011
- Messages
- 7
- Location
- Cleveland, Ohio, United States
- Programming Experience
- Beginner
How can I create a DLL declare statement with an environmental variable in it so as to make sure that I'm loading the system DLL from the right place, the system32 folder? For instance...
Declare Function GetExtendedTcpTable Lib "iphlpapi.dll" Alias "GetExtendedTcpTable" (ByVal tcpTable As IntPtr, ByRef tcpTableLength As Integer, ByVal sort As Boolean, ByVal ipVersion As Integer, ByVal tcpTableType As TcpTableType, ByVal reserved As Integer) As UInteger
Declare Function GetExtendedUdpTable Lib "iphlpapi.dll" Alias "GetExtendedUdpTable" (ByVal tcpTable As IntPtr, ByRef tcpTableLength As Integer, ByVal sort As Boolean, ByVal ipVersion As Integer, ByVal tcpTableType As TcpTableType, ByVal reserved As Integer) As UInteger
But, instead of relying on the folders in the path, I want to specify where to load the DLL from. For instance...
Declare Function GetExtendedTcpTable Lib "%windir%\system32\iphlpapi.dll" Alias "GetExtendedTcpTable" (ByVal tcpTable As IntPtr, ByRef tcpTableLength As Integer, ByVal sort As Boolean, ByVal ipVersion As Integer, ByVal tcpTableType As TcpTableType, ByVal reserved As Integer) As UInteger
Declare Function GetExtendedUdpTable Lib "%windir%\system32\iphlpapi.dll" Alias "GetExtendedUdpTable" (ByVal tcpTable As IntPtr, ByRef tcpTableLength As Integer, ByVal sort As Boolean, ByVal ipVersion As Integer, ByVal tcpTableType As TcpTableType, ByVal reserved As Integer) As UInteger
The reason I'm asking is that there has been talk about people injecting invalid/malicious DLLs into folders along with applications and whatnot and I see this as an issue if you don't specify the SYSTEM directory. Yeah, I could specify it to load from c:\windows\system32 but what happens if a person doesn't have their Windows installed in c:\windows? Hence the reason to use an environmental variable to find system32.
Declare Function GetExtendedTcpTable Lib "iphlpapi.dll" Alias "GetExtendedTcpTable" (ByVal tcpTable As IntPtr, ByRef tcpTableLength As Integer, ByVal sort As Boolean, ByVal ipVersion As Integer, ByVal tcpTableType As TcpTableType, ByVal reserved As Integer) As UInteger
Declare Function GetExtendedUdpTable Lib "iphlpapi.dll" Alias "GetExtendedUdpTable" (ByVal tcpTable As IntPtr, ByRef tcpTableLength As Integer, ByVal sort As Boolean, ByVal ipVersion As Integer, ByVal tcpTableType As TcpTableType, ByVal reserved As Integer) As UInteger
But, instead of relying on the folders in the path, I want to specify where to load the DLL from. For instance...
Declare Function GetExtendedTcpTable Lib "%windir%\system32\iphlpapi.dll" Alias "GetExtendedTcpTable" (ByVal tcpTable As IntPtr, ByRef tcpTableLength As Integer, ByVal sort As Boolean, ByVal ipVersion As Integer, ByVal tcpTableType As TcpTableType, ByVal reserved As Integer) As UInteger
Declare Function GetExtendedUdpTable Lib "%windir%\system32\iphlpapi.dll" Alias "GetExtendedUdpTable" (ByVal tcpTable As IntPtr, ByRef tcpTableLength As Integer, ByVal sort As Boolean, ByVal ipVersion As Integer, ByVal tcpTableType As TcpTableType, ByVal reserved As Integer) As UInteger
The reason I'm asking is that there has been talk about people injecting invalid/malicious DLLs into folders along with applications and whatnot and I see this as an issue if you don't specify the SYSTEM directory. Yeah, I could specify it to load from c:\windows\system32 but what happens if a person doesn't have their Windows installed in c:\windows? Hence the reason to use an environmental variable to find system32.