《精通Windows API-函数、接口、编程实例》——第3章开发工具配置与使用

    技术2024-11-04  27


    SDK platform sdk xp-sp2 官方下载地址

    Platform SDK XP-SP2:http://www.microsoft.com/msdownload/platformsdk/sdkupdate/XPSP2FULLInstall.htmhttp://download.microsoft.com/download/platformsdk/sdk/update/WIN98MeXP/EN-US/2600.2180/FULL/PSDK-FULL.1.cabhttp://download.microsoft.com/download/platformsdk/sdk/update/WIN98MeXP/EN-US/2600.2180/FULL/PSDK-FULL.2.cabhttp://download.microsoft.com/download/platformsdk/sdk/update/WIN98MeXP/EN-US/2600.2180/FULL/PSDK-FULL.3.cabhttp://download.microsoft.com/download/platformsdk/sdk/update/WIN98MeXP/EN-US/2600.2180/FULL/PSDK-FULL.4.cabhttp://download.microsoft.com/download/platformsdk/sdk/update/WIN98MeXP/EN-US/2600.2180/FULL/PSDK-FULL.5.cabhttp://download.microsoft.com/download/platformsdk/sdk/update/WIN98MeXP/EN-US/2600.2180/FULL/PSDK-FULL.6.cabhttp://download.microsoft.com/download/platformsdk/sdk/update/WIN98MeXP/EN-US/2600.2180/FULL/PSDK-FULL.7.cabhttp://download.microsoft.com/download/platformsdk/sdk/update/WIN98MeXP/EN-US/2600.2180/FULL/PSDK-FULL.8.cabhttp://download.microsoft.com/download/platformsdk/sdk/update/WIN98MeXP/EN-US/2600.2180/FULL/PSDK-FULL.9.cabhttp://download.microsoft.com/download/platformsdk/sdk/update/WIN98MeXP/EN-US/2600.2180/FULL/PSDK-FULL.10.cabhttp://download.microsoft.com/download/platformsdk/sdk/update/WIN98MeXP/EN-US/2600.2180/FULL/Extract.exehttp://download.microsoft.com/download/platformsdk/sdk/update/WIN98MeXP/EN-US/2600.2180/FULL/PSDK-FULL.bat

    Platform SDK February 2003:

    http://www.microsoft.com/msdownload/platformsdk/sdkupdate/psdk-full.htm

    http://download.microsoft.com/download/platformsdk/sdk/update/win98mexp/en-us/3790.0/FULL/PSDK-FULL.1.cabhttp://download.microsoft.com/download/platformsdk/sdk/update/win98mexp/en-us/3790.0/FULL/PSDK-FULL.2.cabhttp://download.microsoft.com/download/platformsdk/sdk/update/win98mexp/en-us/3790.0/FULL/PSDK-FULL.3.cabhttp://download.microsoft.com/download/platformsdk/sdk/update/win98mexp/en-us/3790.0/FULL/PSDK-FULL.4.cabhttp://download.microsoft.com/download/platformsdk/sdk/update/win98mexp/en-us/3790.0/FULL/PSDK-FULL.5.cabhttp://download.microsoft.com/download/platformsdk/sdk/update/win98mexp/en-us/3790.0/FULL/PSDK-FULL.6.cabhttp://download.microsoft.com/download/platformsdk/sdk/update/win98mexp/en-us/3790.0/FULL/PSDK-FULL.7.cabhttp://download.microsoft.com/download/platformsdk/sdk/update/win98mexp/en-us/3790.0/FULL/PSDK-FULL.8.cabhttp://download.microsoft.com/download/platformsdk/sdk/update/win98mexp/en-us/3790.0/FULL/PSDK-FULL.9.cabhttp://download.microsoft.com/download/platformsdk/sdk/update/win98mexp/en-us/3790.0/FULL/PSDK-FULL.10.cabhttp://download.microsoft.com/download/platformsdk/sdk/update/win98mexp/en-us/3790.0/FULL/PSDK-FULL.11.cabhttp://download.microsoft.com/download/platformsdk/sdk/update/win98mexp/en-us/3790.0/FULL/PSDK-FULL.12.cabhttp://download.microsoft.com/download/platformsdk/sdk/update/win98mexp/en-us/3790.0/FULL/PSDK-FULL.13.cabhttp://download.microsoft.com/download/platformsdk/sdk/update/win98mexp/en-us/3790.0/FULL/PSDK-FULL.bathttp://download.microsoft.com/download/platformsdk/sdk/update/win98mexp/en-us/3790.0/FULL/Extract.exe 执行BAT文件(PSDK-FULL.bat)示例:c:/psdktemp> psdk-full c:/psdk

     

    1.设置IDE环境在“选项”对话框中选择“项目和解决方案”→“VC++目录”。在“显示以下内容的目录”中选择列表中选择“包含文件”,单击下方的“新建”按钮选择Platform SDK安装目录下的“Include”文件夹。如:C:/Program Files/Microsoft Platform SDK /Include.在选择列表中选择“库文件”,单击下方的“新建”按钮。选择Platform SDK安装目录下的“Lib”文件夹,如:C:/Program Files/Microsoft Platform SDK YLib.在选择列表中选择“可执行”,单击下方的“新建”按钮。选择Platform SDK安装目录下的“Bin”文件夹,如:C:/Program FilesYMicrosofi Platform SDK /Bin。



    VC6设置

     

    WinDbg调试的程序

    #include "stdafx.h" #include <windows.h> //连接时使用User32.lib #pragma comment (lib, "User32.lib") int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { // TODO: Place code here. MessageBox(NULL, TEXT("开始学习Windows编程"), TEXT("消息对话框"), MB_OK); return 0; }

     

     

     

     

    WinDbg命令由于WinDbg命令条目众多、功能丰富,因此使用方法比较复杂。这里只介绍最简单的几个命令,使读者有初步的了解。在实际使用时可以查阅WinDbg文档。. d:查看内存数据。. l:列出进程信息。. Im:查看已经加载的模块。. g:运行。. p:单步运行。. ld:加载符号文件。. r:查看寄存器。. bp、bu、bm:下载断点,bp为执行断点,bu为未解析断点,bm为符号断点。.bl:列出断点。. bc:清除断点

     

    调试过程演示

     

    运行WinDbg。◇加载start.exe的符号文件:菜单“file/symbol file path”,在对话框中选择“browse”,找到编译生成的“START DEBUG”目录,单击“确定”按钮,加入符号文件。(就是。PDB文件就是符号文件 目录要和路径一致)◇将WinDbg设置为源代码模式:在菜单“Debg”中将“Source Mode”勾选上。◇打开供调试的可执行文件start.exe:选择菜单“file”一“executable file path”,在对话框中找到之前生成的start.exe,单击“打开”按钮,如图3-8所示。

     

    (1)bp WinMain                 (调试 在WinMain下断点) F9查看断点

    (2) g或F5运行 

    (3)lm                       (显示出当前已经加载的模块)

    (4)d  MessageBoxA   显示结果是MessageBoxA函数的机器码,使用d命令可以通过指针查看内存,也可以在“Memory”窗口查看。(5) u   WinMain                 WinMain 函数的反汇编程序,同样的功能也可以通过"Disassembly”窗口查看。

    (6)a 命令 改程序

    F10 :步过F8,F11:步入shift+F11:跳出,返回到上层CALL执行(OD里的CTRL+F9)F5:运行bp:下断点 int 3 ,CC断点  F9查看断点bl 显示断点列表bc 清除指定断点bd 禁用指定断点be 启用指定断点

     

    可以通过菜单“View”打开。常用的窗口包括:命令窗口(Command)局部变量(Locals)、寄存器(Register)、内存(Memory)、反汇编(Disassembly)、监视(Watch)、进程和线程( Process and thread)等

     

     


    最新回复(0)