如何调试ISAPI程序?(50分)

  • 主题发起人 主题发起人 tsp
  • 开始时间 开始时间
T

tsp

Unregistered / Unconfirmed
GUEST, unregistred user!
按Delphi4的帮助文件以及某些书上的说法,调试ISAPI程序对于PWin95
(我是PWin98)的PWS来说,Host Application为"Inetsw95.exe",Run
Parameters是"-w3svc",但是,我的PWS是从PWin98源盘安装的,不存在上述
执行文件,只有"Pws.exe"和类似于IIS Server的"Inetinfo.exe",采用这两
个作为Host都不行,改参数为"-e w3svc"也不行,那么如何调试呢?
 
今天是回郑州后第一次连上大富翁,就撞见这个问题,哈哈,这样:
1. PWS中的Inetinfo.exe为主调用程序,即Inetinfo.exe应该为HOST.
2. 参数用-e w3svc没有问题。
3. ——这可能是最重要的一点:你必须先将PWS和Inetinfo.exe从系统中移出去。如
果不这样,Delphi根本控制不到HOST!!!
4. 移除方法:修改注册表,将
HKEY_LOCAL_MACHINE/Software/Microsoft/Windows/CurrentVersion/Run 和
HKEY_LOCAL_MACHINE/Software/Microsoft/Windows/CurrentVersion/RunServices
中涉及到PWS和Inetinfo.exe的两个键值删去,再重启机器。这时,PWS和Inetinfo就已经不在系统中了。再启动Delphi,调试吧。 :)
 
厉害,学到东西了:)
DELPHI FAN 2 :(
 
aimingoo不愧是搞网络的!
 
高手!!!
我一直使用黑箱操作 :(
 
我剃头的!
对不起,是五体投地.
 
mayday, 什么黑箱?不调试?
 
回到当年使用 Microsoft C 时的场景,狂加上一段调试信息
回头看log文件 苦 :-(
 
服气,服气!
吃饭?^o^
 
Establishing a Debugging Environment


There are several ways to establish an environment for debugging your server components and ISAPI extensions. If you are using a debugging tool capable of attaching to a Windows NT process, you can use this functionality to debug your component or extension. For example, if you are debugging an ISAPI extension with Microsoft Visual Studio™ you should take the following steps.

Start the iisadmin process. This can be done from the command line with the command net start iisadmin. You can also use the Services dialog box from the Control Panel to start the IIS Admin Service, which will start iisadmin.


Launch Visual Studio and select the Attach to Process command from the Start Debug sub-menu of the Build menu.


Click the Show System Process check box.


Select the inetinfo process from the list and click OK.


Start the w3svc service. This can be done from the command line with the command net start w3svc. You may also use the Services dialog box in the Control Panel to start the World Wide Web Publishing Service.
If the debugging tool you are using is not capable of attaching to a Windows NT process, you should take the following steps to establish an appropriate debugging environment.

Open the Services dialog box in the Control Panel.


Select the IIS Admin service and click the Startup button.


Select the Allow Service to Interact with Desktop check box and click OK.


Repeat steps 2 and 3 for all processes that run under the IIS Admin process, for example World Wide Web Publishing Service, and FTP Publishing Service.


Use the Registry Editor (REGEDIT) to add a subkey named Inetinfo.Exe to the HKEY_LOCAL_MACHINE/Software/Microsoft/WindowsNT/CurrentVersion/Image File Execution Options key.


Add the following entry to this new key:
Debugger = <DebuggerExeName> where DebuggerExeName is the full path to the debugger you are using.
When the World Wide Web Publishing Service is started, your debugger will also be launched. You can now set appropriate break points in your ISAPI extension.

You won't be able to set breakpoints in a component's source code until the component has been loaded into memory. First, you will need to start Internet Explorer and view the .ASP page containing the object. As soon as the page is loaded, you should be able to set breakpoints in your component. Select Refresh to view the page again, and trigger the breakpoints you selected. If the component cannot be loaded even once (for instance, if the fault occurs in component startup code) you will need to load the component DLL prior to starting the debugging session. (See step 11 below.)

In some cases, you may not be able to use either of the two procedures outlined above. If you have difficulty using either of these strategies, there is a third approach, which has been described in previous releases of IIS. This third approach requires the establishing of NT security privileges as well as making changes to the registry. It will also disable your ability to run IIS as a service. This approach should only be attempted if the previous two strategies have failed.

Use the User Manager for Domains administration tool (USRMGR) to add the Log on as Service, Act as part of the operating system and Generate security audits rights on the local computer to the NT account you will use when debugging the ISAPI extension.


Use the Distributed COM Configuration utility (DCOMCNFG) to change the identity of the IIS Admin Service to the user account you will use for debugging.


Use the Registry Editor (REGEDIT) to remove the LocalService keyword from all IISADMIN-related subkeys under HKEY_CLASSES_ROOT/AppID. This keyword may be found in the following subkeys:
{61738644-F196-11D0-9953-00C04FD919C1} // IIS WAMREG admin Service
{9F0BD3A0-EC01-11D0-A6A0-00A0C922E752} // IIS Admin Crypto Extension
{A9E69610-B80D-11D0-B9B9-00A0C922E750} // IISADMIN Service
The LocalService keyword may be found in additional subkeys of AppID.


Add LocalServer32 subkeys to all IISADMIN related subkeys under the CLSID node of the registry. This will include subkeys corresponding to all of the subkeys you removed in the previous step. Set the default value of these new keys to <path>/inetinfo.exe -e w3svc. (<path> is normally "c:/winnt/system32/inetsrv".)


Stop the WWW and FTP services from the Microsoft Management Console, or from the Services dialog box in the Control Panel.


Start Visual Studio and select the Debug tab in Project Settings window.


Enter C:/WINNT/System32/Inetsrv/inetinfo.exe in the Executable for debug session field.


Enter "-e w3svc" in the Program Arguments field.


Select the Link tab in the Visual Studio Project Settings Window.


Enter the name and path of the ISAPI extension you are debugging in the Output file name field.


Optionally, add your component DLL to the list of Additional DLLs that are loaded before the application starts. This will allow you to set breakpoints in component startup code.


Click the Go button to start the debugging session.
Note After you have completed the debugging session, you must reverse steps five through one to restore the previous settings and allow IIS to be run as a service.
 
我有一个WebServer支持ISAPI,只有一个EXE,很适合调试ISAPI.
我是从DSP下载的.
 
TO lhz,
有这样的好东东给我一个好吗?或者到哪去当?
谢谢。
 
to Jao:
<a href="http://sunsite.icm.edu.pl/delphi/">DSP</a>上,用其搜索引擎查找
"webweav",就可以找到.深度历险上也有,但比较难找.

作者号称要公布源码,但他的<a href="http://members.xoom.com/_XOOM/BSoutham/index.html">站点</a>我连不上:(

如果要给个足够大的e-mail.有近500KB,编码后有750KB.

下面是他的说明:
******************* IMPORTANT *******************
* Version 0.40 uses a different INI file format *
* Make sure that you delete your existing INI *
* file before running the new version. *
*************************************************


Author: Blaine R Southam
Description: This application is the foundation of a multi-threaded
Web Server. It uses thread pooling for the listener threads.
I decided to use Francois Piette TWSocket as socket component
for the web server. You must install TWSocket before you can
compile this, but the EXE will run without it. TWSocket is
availible at http://www.rtfm.be/fpiette/

To use the web server, make sure that the HTTP server is
started, then load your browser, and use either
127.0.0.1 or localhost as the URL. This should bring up
the test page.

This web server SHOULD currently server up any HTML page.
The ISAPI support stuff should now work. I have not done
lots of testing on it, but it seems OK.


Thanks to Carlo Kok (ckok.1@hccnet.nl) for helping with the
ISAPI support.

Creation: March 14, 1999
Version: 0.40
EMail: bsoutham@poboxes.com


Support: I might respond if you e-mail me... No promises...
Legal issues: Copyright (C) 1999 by Blaine R Southam

This software is provided 'as-is', without any express or
implied warranty. In no event will the author be held liable
for any damages arising from the use of this software.

You may use this program for any non-commercial use. If you
wish to re-distribute or use it in a commercial application
e-mail me for approval. Approval will be granted in most
cases, I just want to know what it is being used for. I'll
send anyone the source code to the .01a version if they
would like it. Just send me an e-mail. bsoutham@poboxes.com


By using this software you are also subject to the following
restrictions:

1. The origin of this software must not be misrepresented,
you must not claim that you wrote the original software.
If you use this software in a product, an acknowledgment
in the product documentation would be appreciated but is
not required.

2. Altered source versions must be plainly marked as such, and
must not be misrepresented as being the original software.

3. This notice may not be removed or altered from any
distribution.

** Most of these restrictions were taken from the license
for Francios's TWSocket.


Future: - Add security restrictions
- Add CGI support

History:
Mar 13, 1999 V0.1 - First public release
Mar 15, 1999 V0.1a - Added Options page
- Added the ability to modify the default doc
- Added the ability to modify the virtual root
- Added the ability to modify the thead cache pool size
Mar 16, 1999 V0.1b - Added directory browsing
Mar 22, 1999 V0.2 - Added configurable MIME types
- Added configurable IP address security
- Fixed a problem with thread cache
- Fixed resource leak with file handles
- Created seperate server thread for listening for
connections so that UI wouldn't slow it down.
- Updated configuration options
- Added configurable thread priority
- Update table output for directory browsing
- Added icons in table directory browsing
- Added configurable maximum number of threads
- Added ability to auto-start
Mar 30, 1999 V0.21 - Added configurable window logging
- Added delay window logging option
- Added configurable refresh for window logging
- Added redirection ability for 404 errors
- Added conditional GET for if-modified-since
- Added HEAD request
- Added ability to log to file in addition to window
- Updated logging to Common Log Format (CLF) output
Apr 12, 1999 V0.22 - Added Trayicon
- Removed task button
- Added HtmlEdit.Exe
- Added basic ISAPI support.
- Addded basic FTP Server capabilities
Apr 13, 1999 V0.30 - Added start & stop server from trayicon
- Added about screen
- Fixed problems with Conditional GET
- Fixed table listing (did not list first file)
- Added Directory Caching to FTP Server
- Fixed problem with ISAPI demo
Apr 21, 1999 V0.31 - Complete re-write of client request handling
- Fixed problems (again!) with Conditional GET
- Complete re-write of ISAPI handler
- Fixed CLF format problem
- Added FTP window logging
- Enabled Anonymous Logins
- Added Home Directories for FTP users
- Disable Thread cache pool (wierd problems)
- Added ISAPI config page
- Added ISAPI directory alias ability
- Added Alias config page
- Added ability to create alias for directories
Apr 27, 1999 V0.40 - Added remote Admin functions
- Added configurable Remote Admin Port
- Added 403 Access Denied response to security violation
- Fixed bug in directory browsing code
- Enabled IP Address security
- Fixed bug in IP Address security
- Added Basic user authentication
- Added configurable users page
- Modifed FTP User and HTTP User to use new user page
- Added Realm based security
 

我在用NT下的IIS,可在注册表中没有与inetinfo.exe或PWS相关的键值,不过
我的IIS运行起来可是很正常。只是在调试的时候,一按load按钮就出来一个CPU
的窗口,尽是些汇编代码,根本不知道是什么意思,也没办法调。这个问题可该
如何是好?
 
多人接受答案了。
 
后退
顶部