News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Help2 revisited

Started by donkey, February 22, 2009, 12:51:01 AM

Previous topic - Next topic

donkey

I have worked a bit on the MSDN/Help2 viewer ToutEnAsm and I discussed in another thread and thought I would post the progress. It has evolved into almost a complete viewer application. You are now allowed to choose the Namespace (actually you're required to at first run). The index is an HxIndexView control and it loads the keyword index very quickly. The Web browser is the MFC WebBrowser control which is basically IE. I have kept much of he junk like IE toolbars and url boxes out of the program in order to maintain a bit of control over the GUI. Both ATL controls have event sinks so they can be used interactively, the Keyword HxIndexList was challenging as it only sent click and select and it took a bit of puzzling to extract the data, see the IHxIndexViewEvents_Invoke for how it was done. The biggest obstacle to my last attempt at a raw HX interface program was looking up partial names, unless you know the full name of the keyword most methods returned an error. After experimenting for a couple of days I found that IHxIndex.GetSlotFromString would do exactly what I needed it to do and return an item number in the index, from there its simple, see the DisplayKeyword function for how I implemented it. I have added a few more comments and it was not as painful as I thought, I am notoriously lax in commenting my code. There are still a few things that need to be done before it can be built into a full blown application, better exception handling and a splitter bar between the index and webbrowser to name two.

As usual, the code in the program was written by me and is free for any use, however I would ask that you respect my wishes and it is not used in any work published under the GPL.



Download Help2 Viewer
"Ahhh, what an awful dream. Ones and zeroes everywhere...[shudder] and I thought I saw a two." -- Bender
"It was just a dream, Bender. There's no such thing as two". -- Fry
-- Futurama

Donkey's Stable

donkey

Sorry guys I accidentally uploaded an earlier version, the one I first uploaded didn't have a fully functional options dialog. The correct version is now up top, the options dialog now works and provides a brief description of the Namespace object that you select. There were 5 downloads.

"Ahhh, what an awful dream. Ones and zeroes everywhere...[shudder] and I thought I saw a two." -- Bender
"It was just a dream, Bender. There's no such thing as two". -- Fry
-- Futurama

Donkey's Stable

GregL

Donkey,

I wanted to check out your Help2 Viewer, but it's crashing on me. I'm running Vista Ultimate.

Here is the debugger listing, see comment:


_RtlInitLargeAnsiString@12:
757B90F5  mov         edi,edi
757B90F7  push        ebp 
757B90F8  mov         ebp,esp
757B90FA  mov         eax,dword ptr [ebp+8]
757B90FD  mov         ecx,dword ptr [ebp+0Ch]
757B9100  mov         edx,80000000h
757B9105  or          dword ptr [eax+4],edx
757B9108  test        ecx,ecx
757B910A  push        esi 
757B910B  mov         esi,dword ptr [eax+4]
757B910E  mov         dword ptr [eax+8],ecx
757B9111  je          _RtlInitLargeAnsiString@12+51h (757B914Dh)
757B9113  push        edi 
757B9114  lea         edi,[ecx+1]
757B9117  mov         dl,byte ptr [ecx]    <<<<<<<<<<<<<<<<<< access violation (0c0000005h) here, ecx = 0ffffffffh
757B9119  inc         ecx 
757B911A  test        dl,dl
757B911C  jne         _RtlInitLargeAnsiString@12+22h (757B9117h)
757B911E  sub         ecx,edi
757B9120  mov         edi,dword ptr [ebp+10h]
757B9123  cmp         ecx,edi
757B9125  mov         edx,ecx
757B9127  jae         _RtlInitLargeAnsiString@12+34h (757F2F7Ch)


donkey

Well, first off let me say that I am thoroughly disappointed in the disassembly you posted, I mean what a bonehead way to scan for the NULL terminator. Also whats with mov edi,edi, it doesn't set any flags or help with register stalls (might cause one though) so its just garbage from a compiler. Besides that I have no idea whats happening, if you could try to trace the exception back to the SysAllocString or MultibyteToWideChar that most likely made the call I would appreciate it, I am not running any Vista machines here at the moment (or in the foreseeable future). Beyond knowing what the applications call is, there's not much I can do since the exception is in what appears to be NTDLL.
"Ahhh, what an awful dream. Ones and zeroes everywhere...[shudder] and I thought I saw a two." -- Bender
"It was just a dream, Bender. There's no such thing as two". -- Fry
-- Futurama

Donkey's Stable

donkey

Hi Greg,

Are you running it with the MSDN library ?
"Ahhh, what an awful dream. Ones and zeroes everywhere...[shudder] and I thought I saw a two." -- Bender
"It was just a dream, Bender. There's no such thing as two". -- Fry
-- Futurama

Donkey's Stable

japheth


I tried on WinXP SP 2 and it crashes as well:


77d2236f 56              push    esi
77d22370 8b7004          mov     esi,dword ptr [eax+4]
77d22373 894808          mov     dword ptr [eax+8],ecx
77d22376 743a            je      USER32!RegisterClassA+0x9c (77d223b2)
77d22378 57              push    edi
77d22379 8d7901          lea     edi,[ecx+1]
77d2237c 8a11            mov     dl,byte ptr [ecx]          ds:0023:ffffffff=??  ;<<<<<<<<<<<<<
77d2237e 41              inc     ecx
77d2237f 84d2            test    dl,dl
77d22381 75f9            jne     USER32!RegisterClassA+0x66 (77d2237c)
77d22383 2bcf            sub     ecx,edi
77d22385 8b7d10          mov     edi,dword ptr [ebp+10h]
77d22388 3bcf            cmp     ecx,edi
77d2238a 8bd1            mov     edx,ecx
77d2238c 0f831bf20100    jae     USER32!GetClipboardFormatNameA+0x1268 (77d415ad)


However, it's in USER32, and the call stack is

USER32!RegisterClassA+0x66
USER32!PaintMenuBar+0x57
USER32!AppendMenuA+0x12a
USER32!UnhookWindowsHook+0x28
USER32!SetWindowTextA+0x2d
USER32!SetDlgItemTextA+0x1d
Help2_Viewer+0x1b51
USER32!GetDC+0x72


the location in the binary (0x401b51) looks like this:


00401b2d 6850010000      push    150h
00401b32 68ea030000      push    3EAh
00401b37 ff750c          push    dword ptr [ebp+0Ch]
0:000> u
Help2_Viewer+0x1b3a:
00401b3a e8b1f50000      call    Help2_Viewer+0x110f0 (004110f0)
00401b3f 85c0            test    eax,eax
00401b41 740e            je      Help2_Viewer+0x1b51 (00401b51)
00401b43 50              push    eax
00401b44 68ee030000      push    3EEh
00401b49 ff750c          push    dword ptr [ebp+0Ch]
00401b4c e8a5f50000      call    Help2_Viewer+0x110f6 (004110f6)
00401b51 ff7518          push    dword ptr [ebp+18h]


akane

It is crashing at SetDlgItemText, control id=0x3EE, text* = -1.

donkey

Quote from: akane on February 22, 2009, 10:28:14 AM
It is crashing at SetDlgItemText, control id=0x3EE, text* = -1.

Weird, the only way I can see there being an error ther is if no Help2 namespaces were found on the system. Try the version I just uploaded, I will work on a more fault tolerant namespace enumeration that will fail the whole program if no usable namespaces are found.
"Ahhh, what an awful dream. Ones and zeroes everywhere...[shudder] and I thought I saw a two." -- Bender
"It was just a dream, Bender. There's no such thing as two". -- Fry
-- Futurama

Donkey's Stable

donkey

Stupid error, Took a line out because it was interfering with somethign else and tested the program,eveything worked, Didn't think to test it without an initial namespace selected, the first run routine failed because it was trying to display text in a memory buffer with an address of -1. The upload at the top should solve the problem.
"Ahhh, what an awful dream. Ones and zeroes everywhere...[shudder] and I thought I saw a two." -- Bender
"It was just a dream, Bender. There's no such thing as two". -- Fry
-- Futurama

Donkey's Stable

akane

This attachmet is unaccessible now, I see You are not allowed to access this section.
I have 45 namespaces installed on my primary host so this should be no problem. By the way, the first attachment had missing vertical scrollbar in namespace selector.

donkey

#10
Just tried the download, it seems to work fine.

QuoteI have 45 namespaces installed on my primary host so this should be no problem

Yes, lack of namespaces was not the problem but would have had the same symptoms,it was an oversight on first run,I didn't take into account a -1 return from CB_GETITEMDATA. It has been dealt with.
"Ahhh, what an awful dream. Ones and zeroes everywhere...[shudder] and I thought I saw a two." -- Bender
"It was just a dream, Bender. There's no such thing as two". -- Fry
-- Futurama

Donkey's Stable

GregL

Donkey,

It's working fine now. I should have posted the call stack. Nice tool and nice example. I have always liked H2Viewer because it has more command line options than Dexplore, making integrating into editors and IDEs easier.


donkey

Hi Greg,

Thanks. the hard part was working through undocumented COM interfaces using OleView and guessing what might or might not work. I am thinking about making it into a full blown integrated help application, adding command line support would be trivial but right now I am looking for docs on the underlying HTMLHelp format, specifically how I can integrate it into the program using the same GUI. I am looking for a way to get an index listing from a chm help file without opening a chm help window, once I find that I should be able to make CHM content available as well. I will definitely look at the command line interface, I really liked that about H2Viewer as well, they had one long before it was available on DExplore and I rewrote part of RadASM's RadHelp plugin to support it. Right now I am converting my app to Unicode in order to save some time doing conversions, after that I will be working on the GUI, adding a few features I think are important (TOC, menu, Splitter bar etc..). SInce I am pretty much stalled on my main project, it is my new "de jour"
"Ahhh, what an awful dream. Ones and zeroes everywhere...[shudder] and I thought I saw a two." -- Bender
"It was just a dream, Bender. There's no such thing as two". -- Fry
-- Futurama

Donkey's Stable

donkey

Added a Find Topic dialog, it will find the first 50 matches for a string entered. I am running out of button images so the index search has been changed to the image with the little pencil and Find Topic is the magnifying glass. I will get around to tooltips as soon as I finish figuring out the rest of the interface issues (still no luck finding the default start page programatically). The upload is in the top post, there were about 20 downloads.



Double-click a topic in the listbox to display it
"Ahhh, what an awful dream. Ones and zeroes everywhere...[shudder] and I thought I saw a two." -- Bender
"It was just a dream, Bender. There's no such thing as two". -- Fry
-- Futurama

Donkey's Stable

donkey

Had a chance to work on the GUI a bit today, fixed the Rebar band problem so the windows resize properly when the bands are moved. Added tooltips for the toolbar and an about box. I was considering adding a menu but couldn't really think of anything to put in it so I let it go. I also added version information to the file, the current version is 0.2.0.0, it can be checked in the normal way (right click the executable - select Properties).
"Ahhh, what an awful dream. Ones and zeroes everywhere...[shudder] and I thought I saw a two." -- Bender
"It was just a dream, Bender. There's no such thing as two". -- Fry
-- Futurama

Donkey's Stable