jwaiphlpapi.pas 38 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184
  1. {******************************************************************************}
  2. { }
  3. { Internet Protocol Helper API interface Unit for Object Pascal }
  4. { }
  5. { Portions created by Microsoft are Copyright (C) 1995-2001 Microsoft }
  6. { Corporation. All Rights Reserved. }
  7. { }
  8. { The original file is: iphlpapi.h, released August 2000. The original Pascal }
  9. { code is: IpHlpApi.pas, released September 2000. The initial developer of the }
  10. { Pascal code is Marcel van Brakel (brakelm att chello dott nl). }
  11. { }
  12. { Portions created by Marcel van Brakel are Copyright (C) 1999-2001 }
  13. { Marcel van Brakel. All Rights Reserved. }
  14. { }
  15. { Contributor(s): John C. Penman (jcp att craiglockhart dott com) }
  16. { Vladimir Vassiliev (voldemarv att hotpop dott com) }
  17. { }
  18. { Obtained through: Joint Endeavour of Delphi Innovators (Project JEDI) }
  19. { }
  20. { You may retrieve the latest version of this file at the Project JEDI }
  21. { APILIB home page, located at http://jedi-apilib.sourceforge.net }
  22. { }
  23. { The contents of this file are used with permission, subject to the Mozilla }
  24. { Public License Version 1.1 (the "License"); you may not use this file except }
  25. { in compliance with the License. You may obtain a copy of the License at }
  26. { http://www.mozilla.org/MPL/MPL-1.1.html }
  27. { }
  28. { Software distributed under the License is distributed on an "AS IS" basis, }
  29. { WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for }
  30. { the specific language governing rights and limitations under the License. }
  31. { }
  32. { Alternatively, the contents of this file may be used under the terms of the }
  33. { GNU Lesser General Public License (the "LGPL License"), in which case the }
  34. { provisions of the LGPL License are applicable instead of those above. }
  35. { If you wish to allow use of your version of this file only under the terms }
  36. { of the LGPL License and not to allow others to use your version of this file }
  37. { under the MPL, indicate your decision by deleting the provisions above and }
  38. { replace them with the notice and other provisions required by the LGPL }
  39. { License. If you do not delete the provisions above, a recipient may use }
  40. { your version of this file under either the MPL or the LGPL License. }
  41. { }
  42. { For more information about the LGPL: http://www.gnu.org/copyleft/lesser.html }
  43. { }
  44. {******************************************************************************}
  45. unit JwaIpHlpApi;
  46. {$WEAKPACKAGEUNIT}
  47. {$HPPEMIT ''}
  48. {$HPPEMIT '#include "iphlpapi.h"'}
  49. {$HPPEMIT ''}
  50. {$I jediapilib.inc}
  51. interface
  52. uses
  53. JwaIpExport, JwaIpRtrMib, JwaIpTypes, JwaWinType, JwaWinBase, JwaWinSock;
  54. //////////////////////////////////////////////////////////////////////////////
  55. // //
  56. // IPRTRMIB.H has the definitions of the strcutures used to set and get //
  57. // information //
  58. // //
  59. //////////////////////////////////////////////////////////////////////////////
  60. // #include <iprtrmib.h>
  61. // #include <ipexport.h>
  62. // #include <iptypes.h>
  63. //////////////////////////////////////////////////////////////////////////////
  64. // //
  65. // The GetXXXTable APIs take a buffer and a size of buffer. If the buffer //
  66. // is not large enough, the APIs return ERROR_INSUFFICIENT_BUFFER and //
  67. // *pdwSize is the required buffer size //
  68. // The bOrder is a BOOLEAN, which if TRUE sorts the table according to //
  69. // MIB-II (RFC XXXX) //
  70. // //
  71. //////////////////////////////////////////////////////////////////////////////
  72. //////////////////////////////////////////////////////////////////////////////
  73. // //
  74. // Retrieves the number of interfaces in the system. These include LAN and //
  75. // WAN interfaces //
  76. // //
  77. //////////////////////////////////////////////////////////////////////////////
  78. function GetNumberOfInterfaces(var pdwNumIf: DWORD): DWORD; stdcall;
  79. {$EXTERNALSYM GetNumberOfInterfaces}
  80. //////////////////////////////////////////////////////////////////////////////
  81. // //
  82. // Gets the MIB-II ifEntry //
  83. // The dwIndex field of the MIB_IFROW should be set to the index of the //
  84. // interface being queried //
  85. // //
  86. //////////////////////////////////////////////////////////////////////////////
  87. function GetIfEntry(pIfRow: PMIB_IFROW): DWORD; stdcall;
  88. {$EXTERNALSYM GetIfEntry}
  89. //////////////////////////////////////////////////////////////////////////////
  90. // //
  91. // Gets the MIB-II IfTable //
  92. // //
  93. //////////////////////////////////////////////////////////////////////////////
  94. function GetIfTable(pIfTable: PMIB_IFTABLE; var pdwSize: ULONG; bOrder: BOOL): DWORD; stdcall;
  95. {$EXTERNALSYM GetIfTable}
  96. //////////////////////////////////////////////////////////////////////////////
  97. // //
  98. // Gets the Interface to IP Address mapping //
  99. // //
  100. //////////////////////////////////////////////////////////////////////////////
  101. function GetIpAddrTable(pIpAddrTable: PMIB_IPADDRTABLE; var pdwSize: ULONG; bOrder: BOOL): DWORD; stdcall;
  102. {$EXTERNALSYM GetIpAddrTable}
  103. //////////////////////////////////////////////////////////////////////////////
  104. // //
  105. // Gets the current IP Address to Physical Address (ARP) mapping //
  106. // //
  107. //////////////////////////////////////////////////////////////////////////////
  108. function GetIpNetTable(pIpNetTable: PMIB_IPNETTABLE; var pdwSize: ULONG; bOrder: BOOL): DWORD; stdcall;
  109. {$EXTERNALSYM GetIpNetTable}
  110. //////////////////////////////////////////////////////////////////////////////
  111. // //
  112. // Gets the IP Routing Table (RFX XXXX) //
  113. // //
  114. //////////////////////////////////////////////////////////////////////////////
  115. function GetIpForwardTable(pIpForwardTable: PMIB_IPFORWARDTABLE; var pdwSize: ULONG;
  116. bOrder: BOOL): DWORD; stdcall;
  117. {$EXTERNALSYM GetIpForwardTable}
  118. //////////////////////////////////////////////////////////////////////////////
  119. // //
  120. // Gets TCP Connection/UDP Listener Table //
  121. // //
  122. //////////////////////////////////////////////////////////////////////////////
  123. function GetTcpTable(pTcpTable: PMIB_TCPTABLE; var pdwSize: DWORD; bOrder: BOOL): DWORD; stdcall;
  124. {$EXTERNALSYM GetTcpTable}
  125. function GetUdpTable(pUdpTable: PMIB_UDPTABLE; var pdwSize: DWORD; bOrder: BOOL): DWORD; stdcall;
  126. {$EXTERNALSYM GetUdpTable}
  127. //////////////////////////////////////////////////////////////////////////////
  128. // //
  129. // Gets IP/ICMP/TCP/UDP Statistics //
  130. // //
  131. //////////////////////////////////////////////////////////////////////////////
  132. function GetIpStatistics(var pStats: MIB_IPSTATS): DWORD; stdcall;
  133. {$EXTERNALSYM GetIpStatistics}
  134. function GetIpStatisticsEx(pStats: PMIB_IPSTATS; dwFamily: DWORD): DWORD; stdcall;
  135. {$EXTERNALSYM GetIpStatisticsEx}
  136. function GetIcmpStatistics(var pStats: MIB_ICMP): DWORD; stdcall;
  137. {$EXTERNALSYM GetIcmpStatistics}
  138. function GetIcmpStatisticsEx(pStats: PMIB_ICMP_EX; dwFamily: DWORD): DWORD; stdcall;
  139. {$EXTERNALSYM GetIcmpStatisticsEx}
  140. function GetTcpStatistics(var pStats: MIB_TCPSTATS): DWORD; stdcall;
  141. {$EXTERNALSYM GetTcpStatistics}
  142. function GetTcpStatisticsEx(pStats: PMIB_TCPSTATS; dwFamily: DWORD): DWORD; stdcall;
  143. {$EXTERNALSYM GetTcpStatisticsEx}
  144. function GetUdpStatistics(var pStats: MIB_UDPSTATS): DWORD; stdcall;
  145. {$EXTERNALSYM GetUdpStatistics}
  146. function GetUdpStatisticsEx(pStats: PMIB_UDPSTATS; dwFamily: DWORD): DWORD; stdcall;
  147. {$EXTERNALSYM GetUdpStatisticsEx}
  148. //////////////////////////////////////////////////////////////////////////////
  149. // //
  150. // Used to set the ifAdminStatus on an interface. The only fields of the //
  151. // MIB_IFROW that are relevant are the dwIndex (index of the interface //
  152. // whose status needs to be set) and the dwAdminStatus which can be either //
  153. // MIB_IF_ADMIN_STATUS_UP or MIB_IF_ADMIN_STATUS_DOWN //
  154. // //
  155. //////////////////////////////////////////////////////////////////////////////
  156. function SetIfEntry(const pIfRow: MIB_IFROW): DWORD; stdcall;
  157. {$EXTERNALSYM SetIfEntry}
  158. //////////////////////////////////////////////////////////////////////////////
  159. // //
  160. // Used to create, modify or delete a route. In all cases the //
  161. // dwForwardIfIndex, dwForwardDest, dwForwardMask, dwForwardNextHop and //
  162. // dwForwardPolicy MUST BE SPECIFIED. Currently dwForwardPolicy is unused //
  163. // and MUST BE 0. //
  164. // For a set, the complete MIB_IPFORWARDROW structure must be specified //
  165. // //
  166. //////////////////////////////////////////////////////////////////////////////
  167. function CreateIpForwardEntry(const pRoute: MIB_IPFORWARDROW): DWORD; stdcall;
  168. {$EXTERNALSYM CreateIpForwardEntry}
  169. function SetIpForwardEntry(const pRoute: MIB_IPFORWARDROW): DWORD; stdcall;
  170. {$EXTERNALSYM SetIpForwardEntry}
  171. function DeleteIpForwardEntry(const pRoute: MIB_IPFORWARDROW): DWORD; stdcall;
  172. {$EXTERNALSYM DeleteIpForwardEntry}
  173. //////////////////////////////////////////////////////////////////////////////
  174. // //
  175. // Used to set the ipForwarding to ON or OFF (currently only ON->OFF is //
  176. // allowed) and to set the defaultTTL. If only one of the fields needs to //
  177. // be modified and the other needs to be the same as before the other field //
  178. // needs to be set to MIB_USE_CURRENT_TTL or MIB_USE_CURRENT_FORWARDING as //
  179. // the case may be //
  180. // //
  181. //////////////////////////////////////////////////////////////////////////////
  182. function SetIpStatistics(const pIpStats: MIB_IPSTATS): DWORD; stdcall;
  183. {$EXTERNALSYM SetIpStatistics}
  184. //////////////////////////////////////////////////////////////////////////////
  185. // //
  186. // Used to set the defaultTTL. //
  187. // //
  188. //////////////////////////////////////////////////////////////////////////////
  189. function SetIpTTL(nTTL: UINT): DWORD; stdcall;
  190. {$EXTERNALSYM SetIpTTL}
  191. //////////////////////////////////////////////////////////////////////////////
  192. // //
  193. // Used to create, modify or delete an ARP entry. In all cases the dwIndex //
  194. // dwAddr field MUST BE SPECIFIED. //
  195. // For a set, the complete MIB_IPNETROW structure must be specified //
  196. // //
  197. //////////////////////////////////////////////////////////////////////////////
  198. function CreateIpNetEntry(const pArpEntry: MIB_IPNETROW): DWORD; stdcall;
  199. {$EXTERNALSYM CreateIpNetEntry}
  200. function SetIpNetEntry(const pArpEntry: MIB_IPNETROW): DWORD; stdcall;
  201. {$EXTERNALSYM SetIpNetEntry}
  202. function DeleteIpNetEntry(const pArpEntry: MIB_IPNETROW): DWORD; stdcall;
  203. {$EXTERNALSYM DeleteIpNetEntry}
  204. function FlushIpNetTable(dwIfIndex: DWORD): DWORD; stdcall;
  205. {$EXTERNALSYM FlushIpNetTable}
  206. //////////////////////////////////////////////////////////////////////////////
  207. // //
  208. // Used to create or delete a Proxy ARP entry. The dwIndex is the index of //
  209. // the interface on which to PARP for the dwAddress. If the interface is //
  210. // of a type that doesnt support ARP, e.g. PPP, then the call will fail //
  211. // //
  212. //////////////////////////////////////////////////////////////////////////////
  213. function CreateProxyArpEntry(dwAddress, dwMask, dwIfIndex: DWORD): DWORD; stdcall;
  214. {$EXTERNALSYM CreateProxyArpEntry}
  215. function DeleteProxyArpEntry(dwAddress, dwMask, dwIfIndex: DWORD): DWORD; stdcall;
  216. {$EXTERNALSYM DeleteProxyArpEntry}
  217. //////////////////////////////////////////////////////////////////////////////
  218. // //
  219. // Used to set the state of a TCP Connection. The only state that it can be //
  220. // set to is MIB_TCP_STATE_DELETE_TCB. The complete MIB_TCPROW structure //
  221. // MUST BE SPECIFIED //
  222. // //
  223. //////////////////////////////////////////////////////////////////////////////
  224. function SetTcpEntry(const pTcpRow: MIB_TCPROW): DWORD; stdcall;
  225. {$EXTERNALSYM SetTcpEntry}
  226. function GetInterfaceInfo(pIfTable: PIP_INTERFACE_INFO; var dwOutBufLen: ULONG): DWORD; stdcall;
  227. {$EXTERNALSYM GetInterfaceInfo}
  228. function GetUniDirectionalAdapterInfo(pIPIfInfo: PIP_UNIDIRECTIONAL_ADAPTER_ADDRESS;
  229. var dwOutBufLen: ULONG): DWORD; stdcall;
  230. {$EXTERNALSYM GetUniDirectionalAdapterInfo(OUT PIP_UNIDIRECTIONAL_ADAPTER_ADDRESS pIPIfInfo}
  231. function NhpAllocateAndGetInterfaceInfoFromStack(out ppTable: PIP_INTERFACE_NAME_INFO;
  232. pdwCount: PDWORD; bOrder: BOOL; hHeap: HANDLE; dwFlags: DWORD): DWORD; stdcall;
  233. {$EXTERNALSYM NhpAllocateAndGetInterfaceInfoFromStack}
  234. //////////////////////////////////////////////////////////////////////////////
  235. // //
  236. // Gets the "best" outgoing interface for the specified destination address //
  237. // //
  238. //////////////////////////////////////////////////////////////////////////////
  239. function GetBestInterface(dwDestAddr: IPAddr; var pdwBestIfIndex: DWORD): DWORD; stdcall;
  240. {$EXTERNALSYM GetBestInterface}
  241. function GetBestInterfaceEx(pDestAddr: PSockAddr; var pdwBestIfIndex: DWORD): DWORD; stdcall;
  242. {$EXTERNALSYM GetBestInterfaceEx}
  243. //////////////////////////////////////////////////////////////////////////////
  244. // //
  245. // Gets the best (longest matching prefix) route for the given destination //
  246. // If the source address is also specified (i.e. is not 0x00000000), and //
  247. // there are multiple "best" routes to the given destination, the returned //
  248. // route will be one that goes out over the interface which has an address //
  249. // that matches the source address //
  250. // //
  251. //////////////////////////////////////////////////////////////////////////////
  252. function GetBestRoute(dwDestAddr, dwSourceAddr: DWORD; pBestRoute: PMIB_IPFORWARDROW): DWORD; stdcall;
  253. {$EXTERNALSYM GetBestRoute}
  254. function NotifyAddrChange(var Handle: THandle; overlapped: POVERLAPPED): DWORD; stdcall;
  255. {$EXTERNALSYM NotifyAddrChange}
  256. function NotifyRouteChange(var Handle: THandle; overlapped: POVERLAPPED): DWORD; stdcall;
  257. {$EXTERNALSYM NotifyRouteChange}
  258. function CancelIPChangeNotify(notifyOverlapped: LPOVERLAPPED): BOOL; stdcall;
  259. {$EXTERNALSYM CancelIPChangeNotify}
  260. function GetAdapterIndex(AdapterName: LPWSTR; var IfIndex: ULONG): DWORD; stdcall;
  261. {$EXTERNALSYM GetAdapterIndex}
  262. function AddIPAddress(Address: IPAddr; IpMask: IPMask; IfIndex: DWORD;
  263. var NTEContext, NTEInstance: ULONG): DWORD; stdcall;
  264. {$EXTERNALSYM AddIPAddress}
  265. function DeleteIPAddress(NTEContext: ULONG): DWORD; stdcall;
  266. {$EXTERNALSYM DeleteIPAddress}
  267. function GetNetworkParams(pFixedInfo: PFIXED_INFO; var pOutBufLen: ULONG): DWORD; stdcall;
  268. {$EXTERNALSYM GetNetworkParams}
  269. function GetAdaptersInfo(pAdapterInfo: PIP_ADAPTER_INFO; var pOutBufLen: ULONG): DWORD; stdcall;
  270. {$EXTERNALSYM GetAdaptersInfo}
  271. function GetAdapterOrderMap: PIP_ADAPTER_ORDER_MAP; stdcall;
  272. {$EXTERNALSYM GetAdapterOrderMap}
  273. //
  274. // The following functions require Winsock2.
  275. //
  276. function GetAdaptersAddresses(Family: ULONG; Flags: DWORD; Reserved: PVOID;
  277. pAdapterAddresses: PIP_ADAPTER_ADDRESSES; pOutBufLen: PULONG): DWORD; stdcall;
  278. {$EXTERNALSYM GetAdaptersAddresses}
  279. function GetPerAdapterInfo(IfIndex: ULONG; pPerAdapterInfo: PIP_PER_ADAPTER_INFO;
  280. var pOutBufLen: ULONG): DWORD; stdcall;
  281. {$EXTERNALSYM GetPerAdapterInfo}
  282. function IpReleaseAddress(const AdapterInfo: IP_ADAPTER_INDEX_MAP): DWORD; stdcall;
  283. {$EXTERNALSYM IpReleaseAddress}
  284. function IpRenewAddress(const AdapterInfo: IP_ADAPTER_INDEX_MAP): DWORD; stdcall;
  285. {$EXTERNALSYM IpRenewAddress}
  286. function SendARP(const DestIP, SrcIP: IPAddr; pMacAddr: PULONG; var PhyAddrLen: ULONG): DWORD; stdcall;
  287. {$EXTERNALSYM SendARP}
  288. function GetRTTAndHopCount(DestIpAddress: IPAddr; var HopCount: ULONG;
  289. MaxHops: ULONG; var RTT: ULONG): BOOL; stdcall;
  290. {$EXTERNALSYM GetRTTAndHopCount}
  291. function GetFriendlyIfIndex(IfIndex: DWORD): DWORD; stdcall;
  292. {$EXTERNALSYM GetFriendlyIfIndex}
  293. function EnableRouter(var pHandle: THandle; pOverlapped: POVERLAPPED): DWORD; stdcall;
  294. {$EXTERNALSYM EnableRouter}
  295. function UnenableRouter(pOverlapped: POVERLAPPED; lpdwEnableCount: LPDWORD): DWORD; stdcall;
  296. {$EXTERNALSYM UnenableRouter}
  297. function DisableMediaSense(var pHandle: HANDLE; pOverLapped: POVERLAPPED): DWORD; stdcall;
  298. {$EXTERNALSYM DisableMediaSense}
  299. function RestoreMediaSense(pOverlapped: POVERLAPPED; lpdwEnableCount: LPDWORD): DWORD; stdcall;
  300. {$EXTERNALSYM RestoreMediaSense}
  301. function GetIpErrorString(ErrorCode: IP_STATUS; Buffer: PWCHAR; var Size: DWORD): DWORD; stdcall;
  302. {$EXTERNALSYM GetIpErrorString}
  303. implementation
  304. const
  305. iphlpapilib = 'iphlpapi.dll';
  306. {$IFDEF DYNAMIC_LINK}
  307. var
  308. _GetNumberOfInterfaces: Pointer;
  309. function GetNumberOfInterfaces;
  310. begin
  311. GetProcedureAddress(_GetNumberOfInterfaces, iphlpapilib, 'GetNumberOfInterfaces');
  312. asm
  313. MOV ESP, EBP
  314. POP EBP
  315. JMP [_GetNumberOfInterfaces]
  316. end;
  317. end;
  318. var
  319. _GetIfEntry: Pointer;
  320. function GetIfEntry;
  321. begin
  322. GetProcedureAddress(_GetIfEntry, iphlpapilib, 'GetIfEntry');
  323. asm
  324. MOV ESP, EBP
  325. POP EBP
  326. JMP [_GetIfEntry]
  327. end;
  328. end;
  329. var
  330. _GetIfTable: Pointer;
  331. function GetIfTable;
  332. begin
  333. GetProcedureAddress(_GetIfTable, iphlpapilib, 'GetIfTable');
  334. asm
  335. MOV ESP, EBP
  336. POP EBP
  337. JMP [_GetIfTable]
  338. end;
  339. end;
  340. var
  341. _GetIpAddrTable: Pointer;
  342. function GetIpAddrTable;
  343. begin
  344. GetProcedureAddress(_GetIpAddrTable, iphlpapilib, 'GetIpAddrTable');
  345. asm
  346. MOV ESP, EBP
  347. POP EBP
  348. JMP [_GetIpAddrTable]
  349. end;
  350. end;
  351. var
  352. _GetIpNetTable: Pointer;
  353. function GetIpNetTable;
  354. begin
  355. GetProcedureAddress(_GetIpNetTable, iphlpapilib, 'GetIpNetTable');
  356. asm
  357. MOV ESP, EBP
  358. POP EBP
  359. JMP [_GetIpNetTable]
  360. end;
  361. end;
  362. var
  363. _GetIpForwardTable: Pointer;
  364. function GetIpForwardTable;
  365. begin
  366. GetProcedureAddress(_GetIpForwardTable, iphlpapilib, 'GetIpForwardTable');
  367. asm
  368. MOV ESP, EBP
  369. POP EBP
  370. JMP [_GetIpForwardTable]
  371. end;
  372. end;
  373. var
  374. _GetTcpTable: Pointer;
  375. function GetTcpTable;
  376. begin
  377. GetProcedureAddress(_GetTcpTable, iphlpapilib, 'GetTcpTable');
  378. asm
  379. MOV ESP, EBP
  380. POP EBP
  381. JMP [_GetTcpTable]
  382. end;
  383. end;
  384. var
  385. _GetUdpTable: Pointer;
  386. function GetUdpTable;
  387. begin
  388. GetProcedureAddress(_GetUdpTable, iphlpapilib, 'GetUdpTable');
  389. asm
  390. MOV ESP, EBP
  391. POP EBP
  392. JMP [_GetUdpTable]
  393. end;
  394. end;
  395. var
  396. _GetIpStatistics: Pointer;
  397. function GetIpStatistics;
  398. begin
  399. GetProcedureAddress(_GetIpStatistics, iphlpapilib, 'GetIpStatistics');
  400. asm
  401. MOV ESP, EBP
  402. POP EBP
  403. JMP [_GetIpStatistics]
  404. end;
  405. end;
  406. var
  407. _GetIpStatisticsEx: Pointer;
  408. function GetIpStatisticsEx;
  409. begin
  410. GetProcedureAddress(_GetIpStatisticsEx, iphlpapilib, 'GetIpStatisticsEx');
  411. asm
  412. MOV ESP, EBP
  413. POP EBP
  414. JMP [_GetIpStatisticsEx]
  415. end;
  416. end;
  417. var
  418. _GetIcmpStatistics: Pointer;
  419. function GetIcmpStatistics;
  420. begin
  421. GetProcedureAddress(_GetIcmpStatistics, iphlpapilib, 'GetIcmpStatistics');
  422. asm
  423. MOV ESP, EBP
  424. POP EBP
  425. JMP [_GetIcmpStatistics]
  426. end;
  427. end;
  428. var
  429. _GetIcmpStatisticsEx: Pointer;
  430. function GetIcmpStatisticsEx;
  431. begin
  432. GetProcedureAddress(_GetIcmpStatisticsEx, iphlpapilib, 'GetIcmpStatisticsEx');
  433. asm
  434. MOV ESP, EBP
  435. POP EBP
  436. JMP [_GetIcmpStatisticsEx]
  437. end;
  438. end;
  439. var
  440. _GetTcpStatistics: Pointer;
  441. function GetTcpStatistics;
  442. begin
  443. GetProcedureAddress(_GetTcpStatistics, iphlpapilib, 'GetTcpStatistics');
  444. asm
  445. MOV ESP, EBP
  446. POP EBP
  447. JMP [_GetTcpStatistics]
  448. end;
  449. end;
  450. var
  451. _GetTcpStatisticsEx: Pointer;
  452. function GetTcpStatisticsEx;
  453. begin
  454. GetProcedureAddress(_GetTcpStatisticsEx, iphlpapilib, 'GetTcpStatisticsEx');
  455. asm
  456. MOV ESP, EBP
  457. POP EBP
  458. JMP [_GetTcpStatisticsEx]
  459. end;
  460. end;
  461. var
  462. _GetUdpStatistics: Pointer;
  463. function GetUdpStatistics;
  464. begin
  465. GetProcedureAddress(_GetUdpStatistics, iphlpapilib, 'GetUdpStatistics');
  466. asm
  467. MOV ESP, EBP
  468. POP EBP
  469. JMP [_GetUdpStatistics]
  470. end;
  471. end;
  472. var
  473. _GetUdpStatisticsEx: Pointer;
  474. function GetUdpStatisticsEx;
  475. begin
  476. GetProcedureAddress(_GetUdpStatisticsEx, iphlpapilib, 'GetUdpStatisticsEx');
  477. asm
  478. MOV ESP, EBP
  479. POP EBP
  480. JMP [_GetUdpStatisticsEx]
  481. end;
  482. end;
  483. var
  484. _SetIfEntry: Pointer;
  485. function SetIfEntry;
  486. begin
  487. GetProcedureAddress(_SetIfEntry, iphlpapilib, 'SetIfEntry');
  488. asm
  489. MOV ESP, EBP
  490. POP EBP
  491. JMP [_SetIfEntry]
  492. end;
  493. end;
  494. var
  495. _CreateIpForwardEntry: Pointer;
  496. function CreateIpForwardEntry;
  497. begin
  498. GetProcedureAddress(_CreateIpForwardEntry, iphlpapilib, 'CreateIpForwardEntry');
  499. asm
  500. MOV ESP, EBP
  501. POP EBP
  502. JMP [_CreateIpForwardEntry]
  503. end;
  504. end;
  505. var
  506. _SetIpForwardEntry: Pointer;
  507. function SetIpForwardEntry;
  508. begin
  509. GetProcedureAddress(_SetIpForwardEntry, iphlpapilib, 'SetIpForwardEntry');
  510. asm
  511. MOV ESP, EBP
  512. POP EBP
  513. JMP [_SetIpForwardEntry]
  514. end;
  515. end;
  516. var
  517. _DeleteIpForwardEntry: Pointer;
  518. function DeleteIpForwardEntry;
  519. begin
  520. GetProcedureAddress(_DeleteIpForwardEntry, iphlpapilib, 'DeleteIpForwardEntry');
  521. asm
  522. MOV ESP, EBP
  523. POP EBP
  524. JMP [_DeleteIpForwardEntry]
  525. end;
  526. end;
  527. var
  528. _SetIpStatistics: Pointer;
  529. function SetIpStatistics;
  530. begin
  531. GetProcedureAddress(_SetIpStatistics, iphlpapilib, 'SetIpStatistics');
  532. asm
  533. MOV ESP, EBP
  534. POP EBP
  535. JMP [_SetIpStatistics]
  536. end;
  537. end;
  538. var
  539. _SetIpTTL: Pointer;
  540. function SetIpTTL;
  541. begin
  542. GetProcedureAddress(_SetIpTTL, iphlpapilib, 'SetIpTTL');
  543. asm
  544. MOV ESP, EBP
  545. POP EBP
  546. JMP [_SetIpTTL]
  547. end;
  548. end;
  549. var
  550. _CreateIpNetEntry: Pointer;
  551. function CreateIpNetEntry;
  552. begin
  553. GetProcedureAddress(_CreateIpNetEntry, iphlpapilib, 'CreateIpNetEntry');
  554. asm
  555. MOV ESP, EBP
  556. POP EBP
  557. JMP [_CreateIpNetEntry]
  558. end;
  559. end;
  560. var
  561. _SetIpNetEntry: Pointer;
  562. function SetIpNetEntry;
  563. begin
  564. GetProcedureAddress(_SetIpNetEntry, iphlpapilib, 'SetIpNetEntry');
  565. asm
  566. MOV ESP, EBP
  567. POP EBP
  568. JMP [_SetIpNetEntry]
  569. end;
  570. end;
  571. var
  572. _DeleteIpNetEntry: Pointer;
  573. function DeleteIpNetEntry;
  574. begin
  575. GetProcedureAddress(_DeleteIpNetEntry, iphlpapilib, 'DeleteIpNetEntry');
  576. asm
  577. MOV ESP, EBP
  578. POP EBP
  579. JMP [_DeleteIpNetEntry]
  580. end;
  581. end;
  582. var
  583. _FlushIpNetTable: Pointer;
  584. function FlushIpNetTable;
  585. begin
  586. GetProcedureAddress(_FlushIpNetTable, iphlpapilib, 'FlushIpNetTable');
  587. asm
  588. MOV ESP, EBP
  589. POP EBP
  590. JMP [_FlushIpNetTable]
  591. end;
  592. end;
  593. var
  594. _CreateProxyArpEntry: Pointer;
  595. function CreateProxyArpEntry;
  596. begin
  597. GetProcedureAddress(_CreateProxyArpEntry, iphlpapilib, 'CreateProxyArpEntry');
  598. asm
  599. MOV ESP, EBP
  600. POP EBP
  601. JMP [_CreateProxyArpEntry]
  602. end;
  603. end;
  604. var
  605. _DeleteProxyArpEntry: Pointer;
  606. function DeleteProxyArpEntry;
  607. begin
  608. GetProcedureAddress(_DeleteProxyArpEntry, iphlpapilib, 'DeleteProxyArpEntry');
  609. asm
  610. MOV ESP, EBP
  611. POP EBP
  612. JMP [_DeleteProxyArpEntry]
  613. end;
  614. end;
  615. var
  616. _SetTcpEntry: Pointer;
  617. function SetTcpEntry;
  618. begin
  619. GetProcedureAddress(_SetTcpEntry, iphlpapilib, 'SetTcpEntry');
  620. asm
  621. MOV ESP, EBP
  622. POP EBP
  623. JMP [_SetTcpEntry]
  624. end;
  625. end;
  626. var
  627. _GetInterfaceInfo: Pointer;
  628. function GetInterfaceInfo;
  629. begin
  630. GetProcedureAddress(_GetInterfaceInfo, iphlpapilib, 'GetInterfaceInfo');
  631. asm
  632. MOV ESP, EBP
  633. POP EBP
  634. JMP [_GetInterfaceInfo]
  635. end;
  636. end;
  637. var
  638. _GetUniDirectionalAdapterInfo: Pointer;
  639. function GetUniDirectionalAdapterInfo;
  640. begin
  641. GetProcedureAddress(_GetUniDirectionalAdapterInfo, iphlpapilib, 'GetUniDirectionalAdapterInfo');
  642. asm
  643. MOV ESP, EBP
  644. POP EBP
  645. JMP [_GetUniDirectionalAdapterInfo]
  646. end;
  647. end;
  648. var
  649. _NhpAllocateAndGetInterfaceInfoFromStack: Pointer;
  650. function NhpAllocateAndGetInterfaceInfoFromStack;
  651. begin
  652. GetProcedureAddress(_NhpAllocateAndGetInterfaceInfoFromStack, iphlpapilib, 'NhpAllocateAndGetInterfaceInfoFromStack');
  653. asm
  654. MOV ESP, EBP
  655. POP EBP
  656. JMP [_NhpAllocateAndGetInterfaceInfoFromStack]
  657. end;
  658. end;
  659. var
  660. _GetBestInterface: Pointer;
  661. function GetBestInterface;
  662. begin
  663. GetProcedureAddress(_GetBestInterface, iphlpapilib, 'GetBestInterface');
  664. asm
  665. MOV ESP, EBP
  666. POP EBP
  667. JMP [_GetBestInterface]
  668. end;
  669. end;
  670. var
  671. _GetBestInterfaceEx: Pointer;
  672. function GetBestInterfaceEx;
  673. begin
  674. GetProcedureAddress(_GetBestInterfaceEx, iphlpapilib, 'GetBestInterfaceEx');
  675. asm
  676. MOV ESP, EBP
  677. POP EBP
  678. JMP [_GetBestInterfaceEx]
  679. end;
  680. end;
  681. var
  682. _GetBestRoute: Pointer;
  683. function GetBestRoute;
  684. begin
  685. GetProcedureAddress(_GetBestRoute, iphlpapilib, 'GetBestRoute');
  686. asm
  687. MOV ESP, EBP
  688. POP EBP
  689. JMP [_GetBestRoute]
  690. end;
  691. end;
  692. var
  693. _NotifyAddrChange: Pointer;
  694. function NotifyAddrChange;
  695. begin
  696. GetProcedureAddress(_NotifyAddrChange, iphlpapilib, 'NotifyAddrChange');
  697. asm
  698. MOV ESP, EBP
  699. POP EBP
  700. JMP [_NotifyAddrChange]
  701. end;
  702. end;
  703. var
  704. _NotifyRouteChange: Pointer;
  705. function NotifyRouteChange;
  706. begin
  707. GetProcedureAddress(_NotifyRouteChange, iphlpapilib, 'NotifyRouteChange');
  708. asm
  709. MOV ESP, EBP
  710. POP EBP
  711. JMP [_NotifyRouteChange]
  712. end;
  713. end;
  714. var
  715. _CancelIPChangeNotify: Pointer;
  716. function CancelIPChangeNotify;
  717. begin
  718. GetProcedureAddress(_CancelIPChangeNotify, iphlpapilib, 'CancelIPChangeNotify');
  719. asm
  720. MOV ESP, EBP
  721. POP EBP
  722. JMP [_CancelIPChangeNotify]
  723. end;
  724. end;
  725. var
  726. _GetAdapterIndex: Pointer;
  727. function GetAdapterIndex;
  728. begin
  729. GetProcedureAddress(_GetAdapterIndex, iphlpapilib, 'GetAdapterIndex');
  730. asm
  731. MOV ESP, EBP
  732. POP EBP
  733. JMP [_GetAdapterIndex]
  734. end;
  735. end;
  736. var
  737. _AddIPAddress: Pointer;
  738. function AddIPAddress;
  739. begin
  740. GetProcedureAddress(_AddIPAddress, iphlpapilib, 'AddIPAddress');
  741. asm
  742. MOV ESP, EBP
  743. POP EBP
  744. JMP [_AddIPAddress]
  745. end;
  746. end;
  747. var
  748. _DeleteIPAddress: Pointer;
  749. function DeleteIPAddress;
  750. begin
  751. GetProcedureAddress(_DeleteIPAddress, iphlpapilib, 'DeleteIPAddress');
  752. asm
  753. MOV ESP, EBP
  754. POP EBP
  755. JMP [_DeleteIPAddress]
  756. end;
  757. end;
  758. var
  759. _GetNetworkParams: Pointer;
  760. function GetNetworkParams;
  761. begin
  762. GetProcedureAddress(_GetNetworkParams, iphlpapilib, 'GetNetworkParams');
  763. asm
  764. MOV ESP, EBP
  765. POP EBP
  766. JMP [_GetNetworkParams]
  767. end;
  768. end;
  769. var
  770. _GetAdaptersInfo: Pointer;
  771. function GetAdaptersInfo;
  772. begin
  773. GetProcedureAddress(_GetAdaptersInfo, iphlpapilib, 'GetAdaptersInfo');
  774. asm
  775. MOV ESP, EBP
  776. POP EBP
  777. JMP [_GetAdaptersInfo]
  778. end;
  779. end;
  780. var
  781. _GetAdapterOrderMap: Pointer;
  782. function GetAdapterOrderMap;
  783. begin
  784. GetProcedureAddress(_GetAdapterOrderMap, iphlpapilib, 'GetAdapterOrderMap');
  785. asm
  786. MOV ESP, EBP
  787. POP EBP
  788. JMP [_GetAdapterOrderMap]
  789. end;
  790. end;
  791. var
  792. _GetAdaptersAddresses: Pointer;
  793. function GetAdaptersAddresses;
  794. begin
  795. GetProcedureAddress(_GetAdaptersAddresses, iphlpapilib, 'GetAdaptersAddresses');
  796. asm
  797. MOV ESP, EBP
  798. POP EBP
  799. JMP [_GetAdaptersAddresses]
  800. end;
  801. end;
  802. var
  803. _GetPerAdapterInfo: Pointer;
  804. function GetPerAdapterInfo;
  805. begin
  806. GetProcedureAddress(_GetPerAdapterInfo, iphlpapilib, 'GetPerAdapterInfo');
  807. asm
  808. MOV ESP, EBP
  809. POP EBP
  810. JMP [_GetPerAdapterInfo]
  811. end;
  812. end;
  813. var
  814. _IpReleaseAddress: Pointer;
  815. function IpReleaseAddress;
  816. begin
  817. GetProcedureAddress(_IpReleaseAddress, iphlpapilib, 'IpReleaseAddress');
  818. asm
  819. MOV ESP, EBP
  820. POP EBP
  821. JMP [_IpReleaseAddress]
  822. end;
  823. end;
  824. var
  825. _IpRenewAddress: Pointer;
  826. function IpRenewAddress;
  827. begin
  828. GetProcedureAddress(_IpRenewAddress, iphlpapilib, 'IpRenewAddress');
  829. asm
  830. MOV ESP, EBP
  831. POP EBP
  832. JMP [_IpRenewAddress]
  833. end;
  834. end;
  835. var
  836. _SendARP: Pointer;
  837. function SendARP;
  838. begin
  839. GetProcedureAddress(_SendARP, iphlpapilib, 'SendARP');
  840. asm
  841. MOV ESP, EBP
  842. POP EBP
  843. JMP [_SendARP]
  844. end;
  845. end;
  846. var
  847. _GetRTTAndHopCount: Pointer;
  848. function GetRTTAndHopCount;
  849. begin
  850. GetProcedureAddress(_GetRTTAndHopCount, iphlpapilib, 'GetRTTAndHopCount');
  851. asm
  852. MOV ESP, EBP
  853. POP EBP
  854. JMP [_GetRTTAndHopCount]
  855. end;
  856. end;
  857. var
  858. _GetFriendlyIfIndex: Pointer;
  859. function GetFriendlyIfIndex;
  860. begin
  861. GetProcedureAddress(_GetFriendlyIfIndex, iphlpapilib, 'GetFriendlyIfIndex');
  862. asm
  863. MOV ESP, EBP
  864. POP EBP
  865. JMP [_GetFriendlyIfIndex]
  866. end;
  867. end;
  868. var
  869. _EnableRouter: Pointer;
  870. function EnableRouter;
  871. begin
  872. GetProcedureAddress(_EnableRouter, iphlpapilib, 'EnableRouter');
  873. asm
  874. MOV ESP, EBP
  875. POP EBP
  876. JMP [_EnableRouter]
  877. end;
  878. end;
  879. var
  880. _UnenableRouter: Pointer;
  881. function UnenableRouter;
  882. begin
  883. GetProcedureAddress(_UnenableRouter, iphlpapilib, 'UnenableRouter');
  884. asm
  885. MOV ESP, EBP
  886. POP EBP
  887. JMP [_UnenableRouter]
  888. end;
  889. end;
  890. var
  891. _DisableMediaSense: Pointer;
  892. function DisableMediaSense;
  893. begin
  894. GetProcedureAddress(_DisableMediaSense, iphlpapilib, 'DisableMediaSense');
  895. asm
  896. MOV ESP, EBP
  897. POP EBP
  898. JMP [_DisableMediaSense]
  899. end;
  900. end;
  901. var
  902. _RestoreMediaSense: Pointer;
  903. function RestoreMediaSense;
  904. begin
  905. GetProcedureAddress(_RestoreMediaSense, iphlpapilib, 'RestoreMediaSense');
  906. asm
  907. MOV ESP, EBP
  908. POP EBP
  909. JMP [_RestoreMediaSense]
  910. end;
  911. end;
  912. var
  913. _GetIpErrorString: Pointer;
  914. function GetIpErrorString;
  915. begin
  916. GetProcedureAddress(_GetIpErrorString, iphlpapilib, 'GetIpErrorString');
  917. asm
  918. MOV ESP, EBP
  919. POP EBP
  920. JMP [_GetIpErrorString]
  921. end;
  922. end;
  923. {$ELSE}
  924. function GetNumberOfInterfaces; external iphlpapilib name 'GetNumberOfInterfaces';
  925. function GetIfEntry; external iphlpapilib name 'GetIfEntry';
  926. function GetIfTable; external iphlpapilib name 'GetIfTable';
  927. function GetIpAddrTable; external iphlpapilib name 'GetIpAddrTable';
  928. function GetIpNetTable; external iphlpapilib name 'GetIpNetTable';
  929. function GetIpForwardTable; external iphlpapilib name 'GetIpForwardTable';
  930. function GetTcpTable; external iphlpapilib name 'GetTcpTable';
  931. function GetUdpTable; external iphlpapilib name 'GetUdpTable';
  932. function GetIpStatistics; external iphlpapilib name 'GetIpStatistics';
  933. function GetIpStatisticsEx; external iphlpapilib name 'GetIpStatisticsEx';
  934. function GetIcmpStatistics; external iphlpapilib name 'GetIcmpStatistics';
  935. function GetIcmpStatisticsEx; external iphlpapilib name 'GetIcmpStatisticsEx';
  936. function GetTcpStatistics; external iphlpapilib name 'GetTcpStatistics';
  937. function GetTcpStatisticsEx; external iphlpapilib name 'GetTcpStatisticsEx';
  938. function GetUdpStatistics; external iphlpapilib name 'GetUdpStatistics';
  939. function GetUdpStatisticsEx; external iphlpapilib name 'GetUdpStatisticsEx';
  940. function SetIfEntry; external iphlpapilib name 'SetIfEntry';
  941. function CreateIpForwardEntry; external iphlpapilib name 'CreateIpForwardEntry';
  942. function SetIpForwardEntry; external iphlpapilib name 'SetIpForwardEntry';
  943. function DeleteIpForwardEntry; external iphlpapilib name 'DeleteIpForwardEntry';
  944. function SetIpStatistics; external iphlpapilib name 'SetIpStatistics';
  945. function SetIpTTL; external iphlpapilib name 'SetIpTTL';
  946. function CreateIpNetEntry; external iphlpapilib name 'CreateIpNetEntry';
  947. function SetIpNetEntry; external iphlpapilib name 'SetIpNetEntry';
  948. function DeleteIpNetEntry; external iphlpapilib name 'DeleteIpNetEntry';
  949. function FlushIpNetTable; external iphlpapilib name 'FlushIpNetTable';
  950. function CreateProxyArpEntry; external iphlpapilib name 'CreateProxyArpEntry';
  951. function DeleteProxyArpEntry; external iphlpapilib name 'DeleteProxyArpEntry';
  952. function SetTcpEntry; external iphlpapilib name 'SetTcpEntry';
  953. function GetInterfaceInfo; external iphlpapilib name 'GetInterfaceInfo';
  954. function GetUniDirectionalAdapterInfo; external iphlpapilib name 'GetUniDirectionalAdapterInfo';
  955. function NhpAllocateAndGetInterfaceInfoFromStack; external iphlpapilib name 'NhpAllocateAndGetInterfaceInfoFromStack';
  956. function GetBestInterface; external iphlpapilib name 'GetBestInterface';
  957. function GetBestInterfaceEx; external iphlpapilib name 'GetBestInterfaceEx';
  958. function GetBestRoute; external iphlpapilib name 'GetBestRoute';
  959. function NotifyAddrChange; external iphlpapilib name 'NotifyAddrChange';
  960. function NotifyRouteChange; external iphlpapilib name 'NotifyRouteChange';
  961. function CancelIPChangeNotify; external iphlpapilib name 'CancelIPChangeNotify';
  962. function GetAdapterIndex; external iphlpapilib name 'GetAdapterIndex';
  963. function AddIPAddress; external iphlpapilib name 'AddIPAddress';
  964. function DeleteIPAddress; external iphlpapilib name 'DeleteIPAddress';
  965. function GetNetworkParams; external iphlpapilib name 'GetNetworkParams';
  966. function GetAdaptersInfo; external iphlpapilib name 'GetAdaptersInfo';
  967. function GetAdapterOrderMap; external iphlpapilib name 'GetAdapterOrderMap';
  968. function GetAdaptersAddresses; external iphlpapilib name 'GetAdaptersAddresses';
  969. function GetPerAdapterInfo; external iphlpapilib name 'GetPerAdapterInfo';
  970. function IpReleaseAddress; external iphlpapilib name 'IpReleaseAddress';
  971. function IpRenewAddress; external iphlpapilib name 'IpRenewAddress';
  972. function SendARP; external iphlpapilib name 'SendARP';
  973. function GetRTTAndHopCount; external iphlpapilib name 'GetRTTAndHopCount';
  974. function GetFriendlyIfIndex; external iphlpapilib name 'GetFriendlyIfIndex';
  975. function EnableRouter; external iphlpapilib name 'EnableRouter';
  976. function UnenableRouter; external iphlpapilib name 'UnenableRouter';
  977. function DisableMediaSense; external iphlpapilib name 'DisableMediaSense';
  978. function RestoreMediaSense; external iphlpapilib name 'RestoreMediaSense';
  979. function GetIpErrorString; external iphlpapilib name 'GetIpErrorString';
  980. {$ENDIF DYNAMIC_LINK}
  981. end.