jwaiphlpapi.pas 38 KB

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