⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 wscontrol.html

📁 SDK FAQ集
💻 HTML
📖 第 1 页 / 共 5 页
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"><html lang="en"><head><title>Winsock Programmer's FAQ: Articles</title><link rel="Stylesheet" type="text/css" href="../faq.css"></head><body bgcolor="#ffffee" text="#000000" link="#491e00" vlink="#7d2e01" alink="#da7417"><!--  ---- Header Bar ----  --><table border="0" width="95%" bgcolor="#006000" cellpadding="5" cellspacing="3" align="center">	<tr>		<td align="left" bgcolor="#e0e0c0">			<font size="2" face=Verdana,Arial,Helvetica>				<b><a href="../articles/bsd-compatibility.html">&lt;&lt;</a></b>			</font>		</td>		<td align="center">			<font face=Verdana,Arial,Helvetica color="#ffffee">				<p align=center class=bigger3><b>				Winsock Programmer's FAQ<br>				Section 7: Articles<br>				</b></p>			</font>			</td>		<td align="right" bgcolor="#e0e0c0">			<font size="2" face=Verdana,Arial,Helvetica>				<b><a href="../reviews/index.html">&gt;&gt;</a></b>			</font>		</td>	</tr></table><!--  ---- Body Table ----  --><table width="95%" border="0" cellpadding="10">	<tr valign="top">		<td><H3>WsControl() Revealed</H3><p>	<I>by <a href="mailto:tsanfilippo@earthlink.net"> Tom Sanfilippo</a></i></p><h4>Description</h4><p><code>WsControl()</code> is used to get interface info in the Windows95 program winipcfg.exe. Apparently it can also be used to set IP configinformation as well. I have not tested setting, but with the info below,you should be able to do a lot of query-only calls. In theory you canalso trace the "set" calls made by winipcfg.exe and deduce some of theinput parameters for those calls. This is left as an exercise for thereader.</p><p>In the mode used in winipcfg.exe, <code>WsControl()</code>basically gives you access to SNMP query info, such as route tableentries, interface list entries, adapter description entries, etc.(Pretty exciting!!) However, like others, I needed it for a Windows95 application that cannot require Winsock 2. If you have Windows 98,Windows NT, Windows 2000, or can require Winsock 2, you are probablybetter off using <code>WSIoctl()</code> or <code>GetInterfaceInfo()</code>to get the info provided by <code>WsControl()</code> (at least as muchas is exposed by its use in winipcfg.exe).</p><h5>How It Was Done</h5><p>I used a hook DLL to hook and dump all the parameters, then Ilooked for patterns in the input and output. Then I wrote a testprogram to test out the theoretical signatures. I showed this to<a href="mailto:tdivine@pcausa.com"> Thomas Divine</a>, and he recognizedthat the parameters I came up with were similar to parameters in aWSHelper sample in the NT4 DDK. I then took that sample and was ableto deduce even more parameters. See the section entitled "ParameterDeduction Notes" for more info.</p><h5>Why Was It Done</h5><p>Well, the official line from Microsoft is that if you need thisinformation programmatically from a Windows 95 application without Winsock2, then you should have your application run winipcfg.exe in batch mode(yes there is a batch mode), and pipe the output to a file, then readthe file into your application. Being that this would be almost as muchfun as embedding a Tcl interpreter, I though it would be more interestingto see how they did it.</p><h4>Getting the DDK</h4><p>You will need a copy of the most recent version of the NT4 DDK toget the necessary header files (even though the code is designed forWindows 95/98). The relevant headers are:</p><pre>                \ddk\src\network\inc\tdiinfo.h                \ddk\src\network\wshsmple\smpletcp.h</pre><p>I'm not sure they are redistributable. However, as of this writing,you can <a href="http://www.microsoft.com/ddk/ddk40.htm">download theNT4 DDK</a> from Microsoft.</p><p>The headers in the downloadable version should work. Copy the aboveheaders to the project directory if you don't want to pull in the entireNT4 DDK.</p><h4>The WsControl() Call</h4><p>The <code>WsControl()</code> function looks something like this:</p><pre>                int WsControl(                    DWORD protocol,                    DWORD action,                    LPVOID pRequestInfo,

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -