Jump to content
Tuts 4 You
Sign in to follow this  
Alzri2

How to open chm file (winapi) ?

Recommended Posts

Alzri2

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

Share this post


Link to post
simple

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

Share this post


Link to post
Alzri2

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 (see edit history)

Share this post


Link to post
simple

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 (see edit history)
  • Like 1

Share this post


Link to post
Alzri2

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 ?


Share this post


Link to post
Alzri2

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


Share this post


Link to post
atom0s

If the file type is known to the system you should just be able to use ShellExecute to open it.


  • Like 1

Share this post


Link to post
kao

0Dh is HH_KEYWORD_LOOKUP command. So, study the MSDN topic and pass a correct structure to HtmlHelp, not just a dummy value of 20h.

As simple as that.

  • Like 1

Share this post


Link to post
Alzri2

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 (see edit history)

Share this post


Link to post
kao

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


Share this post


Link to post
Alzri2

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.

Share this post


Link to post
Alzri2

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 (see edit history)

Share this post


Link to post
simple

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

Share this post


Link to post
LCF-AT

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


Share this post


Link to post
Alzri2

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

Share this post


Link to post
LCF-AT

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


Share this post


Link to post
Alzri2

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 (see edit history)

Share this post


Link to post

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
Sign in to follow this  
×
×
  • Create New...