关于“IDA Pro 5.4 中文帮助手册.chm”在IDA打开文件时按F1出现错误的解决方法
 
首先感谢“看雪”提供的中文翻译版帮助文件,同时也感谢各位翻译人员的辛勤劳动。
中文版的帮助有助于迅速普及国人学习IDA的使用。一个小遗憾就是在IDA打开数据文件
时按快捷键F1出现“HH_HELPCONTEXT called without a [MAP] section”错误信息。
现在提供该错误的解决办法。
 
所用的工具是Far Helpware。其实问题很简单,就是在用FAR的项目编辑器(HH Project Editor)打开项目
文件时的“Other Sections”选项下定义[MAP]和[ALIAS]两个节。我们首先要学习一下[MAP]和[ALIAS]的
语法,在Far的帮助文件(Help)内搜索“[MAP]”, 可找到如下信息:
 
===============================================================================================================================
[MAP] [ALIAS]
The Map and Alias sections must be set if you want to create a Context ID to URL mapping. Used when the application opens help using the HH_HELP_CONTEXT help command. ie. For opening help using an HelpContext / integer ID.
 
EG. HtmlHelp(0, "c:\app\help\Help.chm", HH_HELP_CONTEXT, 1001);
 
The [MAP] section defines the IDs. 
The [ALIAS] section defines the mapping between ID and help topic.
 
Example MAP and ALIAS section
[ALIAS]
IDH_HomePage=default.htm
IDH_TestTopic1=htmlfiles\testtopic1.htm
IDH_TestTopic2=mychm::htmlfiles\testtopic2.htm
 
[MAP]
#define IDH_HomePage 1000 ;comment
#define IDH_TestTopic1 1001
#define IDH_TestTopic2 1002
 
Example MAP and ALIAS section using #include statements;Use the #include statement to include an external header file at compile time.
 
[ALIAS]
#include myhelp.ali
 
[MAP]
#include myhelp.h
 
where myhelp.ali is a text file containing
 
IDH_HomePage=default.htm
IDH_TestTopic1=htmlfiles\testtopic1.htm
IDH_TestTopic2=mychm::htmlfiles\testtopic2.htm
 
and myhelp.h is a text file containing
 
#define IDH_HomePage 1000
#define IDH_TestTopic1 1001
#define IDH_TestTopic2 1002
===============================================================================================================================
 
内容翻译如下:
===============================================================================================================================
要想创建上下文ID与URL关联信息,就必须设置Map和Alias节,这两个节用与应用程序在打开帮助文件时使用"HH_HELP_CONTEXT"帮助命令的情况。也就是说使用一个
"帮助上下文"与"ID号"关联对(ID号为一个整数类型的数值)来打开帮助信息。
 
例如命令:
HtmlHelp(0, "c:\app\help\Help.chm", HH_HELP_CONTEXT, 1001); // 帮助上下文为“HH_HELP_CONTEXT”,“ID”为1001。
[MAP]节定义ID值。
[ALIAS]节定义ID与帮助主题的映射关系。
 
直接定义MAP与ALIAS节的例子:
[ALIAS]
IDH_HomePage=default.htm
IDH_TestTopic1=htmlfiles\testtopic1.htm
IDH_TestTopic2=mychm::htmlfiles\testtopic2.htm
 
[MAP]
#define IDH_HomePage 1000 ;comment
#define IDH_TestTopic1 1001
#define IDH_TestTopic2 1002
 
此外还可以用类似C语言的#include语句在编译帮助文件时包含外部定义的头文件来定义[MAP]和[ALIAS]节,相应的例子如下:
[ALIAS]
#include myhelp.ali
 
[MAP]
#include myhelp.h
 
其中myhelp.ali为一个纯文本文件,其内容如下:
IDH_HomePage=default.htm
IDH_TestTopic1=htmlfiles\testtopic1.htm
IDH_TestTopic2=mychm::htmlfiles\testtopic2.htm
 
而myhelp.h也是一个纯文本文件,其内容如下:
#define IDH_HomePage 1000
#define IDH_TestTopic1 1001
#define IDH_TestTopic2 1002
===============================================================================================================================
 
下面的问题就简单了, 只要在Other Sections的"[ALISAS]"和"[MAP]"填入相应信息即可。因为涉及的文件有756个之多,所以我们采用包含头文件的方法,
即用#include语句来定义相关信息。
 
idahelp.ali文件的内容如下(因篇幅省略表示):
--------------------------------------
IDH_1=IDA Pro 中文帮助手册说明.htm
IDH_2=index.htm
IDH_4=4.htm
IDH_5=5.htm
IDH_6=6.htm
IDH_7=7.htm
IDH_8=8.htm
......
......
IDH_1523=1523.htm
--------------------------------------
 
idahelp.h文件的内容如下(因篇幅省略表示):
--------------------------------------
#define IDH_1 2
#define IDH_2 2
#define IDH_4 4
#define IDH_5 5
#define IDH_6 6
#define IDH_7 7
#define IDH_8 8
......
......
#define IDH_1523 1523
--------------------------------------
 
按如下步骤操作:
1) 将idahelp.ali和idahelp.h文件放在与idahelp.hpp(帮助项目助文件)相同的文件夹下;
2) 在FAR项目编辑器(HH Project Editor)主界面下Other Options选项向的中间栏内选中“[ALIAS]”,
在右侧单击“Include File...”并选中idahelp.ali文件;
3) 在FAR项目编辑器(HH Project Editor)主界面下Other Options选项向的中间栏内选中“[MAP]”,
在右侧单击“Include File...”并选中idahelp.h文件;
4) 保存帮助项目助文件idahelp.hpp,然后编译帮助文件;
5) 将编译好的文件复制到IDA的安装位置(注意一定要先备份英文的idahelp.chm文件,或先将其更名为idahelp_en.chm),
  再将中文版的帮助文件更名为idahelp.chm,此时大功告成。
 
另外发现一个小窍门:.chm文件中的“#IVB”就是编译结果,因此也可以将“#IVB”文件直接放入.chm文件中。
我使用的是Total Commander的chm插件将其直接放入chm内的。请大家在试验之前一定要做好备份工作。但这个方法
不是十分可靠,有时可能会显示空页(“无法显示网页”),但可以点击其它主题。
 
还有一个问题,用IDA 5.2的F1打开帮助文件时,显示的是“WindowOpen”主题,可能IDA5.2调用的命令是
HtmlHelp(0, "IdaHelp.chm", HH_HELP_CONTEXT, 585); 
经查585.htm正是该主题。如果要想显示index.htm的话,应将其更名为585.htm。但原来的585.htm可能与其他文件有关联,
因此,要把所有的关联修正好后才行。当然还可以分析idag.exe将那个585改为2(我这里将index.htm的ID定义为2)。
 
 
附件内含“idahelp.ali”、“idahelp.h”、“idahelp.hpp”、“#IVB”和搞定的中文版帮助文件idahelp_cn.chm共5个文件。

更正后的附件见14楼,对此造成的不便表示歉意。