Jump to content
Tuts 4 You

How to open chm file (winapi) ?


Alzri2

Recommended Posts

Hi,


 


Is there a way to open a chm file in the index tab and write something there ?


 


Well, OllyDBG 2.01 does that ... I tried to debug it but couldn't figure out how it does that


bp on 0049A8F1 and use "Help on API function" from the R click menu to break on it.


 


This is the code I tried in ASM:



.data
libN db "HHCTRL.OCX", 0
funcN db "HtmlHelpA", 0 ;unicode HtmlHelpW
path db "D:\WinApi.chm", 0
val db 20h, 0
DeskHWND dd ? .code
start:
invoke GetDesktopWindow
mov DeskHWND, eax invoke LoadLibrary, addr libN
invoke GetProcAddress, eax, addr funcN push offset val
push 0Dh
push offset path
push DeskHWND ; could be NULL
call eax invoke ExitProcess, 0
end start

Link to comment

dont know what "open chm in index tab & write something there means" but to display a .chm in the "html browser" this works for me.


 


 
push 0
push 0 ; HH_DISPLAY_TOPIC
push offset path
push DeskHWND
call eax
 

  • Like 1
Link to comment

Thanks ... works like a charm :)


only ExitProcess invoke needs to be omitted


 


Still, I want to write something in the index after opening the file cuz I'm writing a plugin for x64dbg, OllyDBG, and (maybe) IDA pro :)


This is how Olly works as u know :


http://postimg.org/image/4q8fits3p/


Do u have any idea on how to do so ?


Edited by Alzri2
Link to comment

use HTML Help Workshop. just briefly tried & looks like to create custom index (w/tab view in left pane) u just create an index file & compile in ur project. tons of info on this.


 


https://msdn.microsoft.com/en-us/library/windows/desktop/ms644604%28v=vs.85%29.aspx


 


edit - u can also use htmlhelp.lib from the html help SDK instead of dynamically loading it


Edited by simple
  • Like 1
Link to comment

Ollydbg 2.01 can simply open the chm and write the function name in the index tab without all of that (it doesn't create any index or smth cuz the chm browser creates this file automatically)


Is there a simple way ?


Link to comment

thanks Dreamer, but what u've posted is an independent chm viewer ... I'm looking for a way to launch a chm file using the windows html viewer


Link to comment

simple:


I didn't import htmlhelp.lib cuz I don't like to import a whole library to get only one var !


 


@atom0s:


ShellExecute would only open the file as the user normally does, which means there won't be anything written in the index tab.


I can then wait for the chm viewer window and add smth using SendMessage. But, it would be hyper ugliness code :D


 


kao:


Do u really think I would pass an argument randomly ?!!


As I said, I ripped the code above from Olly 2.01, but it doesn't work properly as it does in Olly.


 


 


whenever I have the time, I'll try another way


Edited by Alzri2
Link to comment

Did you actually read my suggestion and look at that MSDN topic? You ripped some data but that was not enough.


Link to comment

Sure I did. But, I haven't tried it yet ...

Btw it looks like it will show the search tab instead of showing the index tab if I passed that arg.

Anyway, as I said, I'll try it once i have the time.

Link to comment

As I said, I did it in an another way ...


I wrote it in C++ cuz I couldn't pass a dword value in ASM :D


 


Here is a working code:



int CALLBACK WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow){ typedef INT (CALLBACK* LPFNDLLFUNC1)(HWND, LPCTSTR, UINT, DWORD);
HINSTANCE hDLL; // Handle to DLL
LPFNDLLFUNC1 lpfnDllFunc1; // Function pointer
UINT valS = 32; hDLL = LoadLibrary("HHCTRL.OCX");
if (hDLL != NULL)
{
lpfnDllFunc1 = (LPFNDLLFUNC1)GetProcAddress(hDLL, "HtmlHelpA");
if (!lpfnDllFunc1)
{
FreeLibrary(hDLL);
return 0;
}else{
lpfnDllFunc1(GetDesktopWindow(),
"D:\\WinApi.chm",
0x0002, //HH_DISPLAY_INDEX
(DWORD)"MessageBox");
while (true){} // just don't exit
}
}
return 0;
};

Edited by Alzri2
Link to comment

Not all the time, but in that case a dword cast means the address in binary


 


db MBString "MessageBox", 0
 
...
 
push offset MbString
push 2
push offset path
push DeskHWND
call eax

  • Like 1
Link to comment

Hi guys,


 


I have a little question.Can anybody tell me where to find API references files (offline versions to use without internet access) about almost all APIs?Normaly I just use win32.hlp (24 MB) but I also wanna know whether there are also others to download like documentations about VB & Msvcrt API's etc (also in hlp or chm).If you know some then it would be nice if you could post some links where I can download them.


 


PS: Sorry for asking on your topic Alzri2 but on your picture I have seen you do use any other MSDN Lite reference (I don't know this one).


 


Thank you


Link to comment

No problem to ask here at all :)

Well, u don't how much time I spent on compiling this help :D

I have converted help files of win7 sdk into a chm file just for the purpose mentioned in this topic (make plugins).

Sure, I will upload it with the plugins once I have the time.

  • Like 1
Link to comment

Hi Alzri2,


 


thanks first.


Sounds good if you could upload all files for us. :)


I also like hlp files a bit more than chm files but anyway so its just important to have some extern offline documentation. :) Oh and if you also know or have any (extern / offline) VB & Msvcrt API documentation then upload them too if possible.No idea why I can't find anything about these on the internet to download.


 


PS: Good luck with your plugin.


 


Thank you


Link to comment

Chm files are much better than hlp files ... one of many advantages is supporting Win vista/7/8/8.1 (without any updates from MS)


 


Don't know about VB. But, is there information about it in the online MSDN ? If so, you might find info about it in the chm file as well.


Edited by Alzri2
Link to comment
  • 3 months later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...