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 think I have found the way to get a default page from a Help2 namespace however I need someone to test it on something other than MS.VSCC.v90 and MS.MSDNQTR.v90.en, I have uploaded the program to my website, link at the top of this thread. A test on the PSDK would be great.
"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

Rob Chandler, author of FAR and H2Viewer and Microsoft Help MVP has helped me out with the home page issue, I was not getting a home page for MSDN Express edition. He emailed me how he accomplished it in FAR and it solved the problem nicely, version 0.4.0.0 has the GetHomePage function that is my attempt at implementing what he told me he did in H2Viewer. Essentially he first tries for the HomePage entry, if that's not found then the DefaultPage entry if that fails then he scans the table of contents to find the topmost url. I did not fully implement the scan of the TOC, I simply look at the first slot and if it contains a valid URL I use that, if not then I show a blank page.

Again, I would appreciate feedback on whether everything is working.
"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

ToutEnMasm

Hello,
It's work with XP sp3,but .... the search box disappear too much quickly.
Better would be a button to close it

akane

Donkey, I'm providing a set of answers/bugs:

line 1268 // Should I Release the iHxTopic here ???
Yes, you know its index. The index identifies single IHxTopic until the session is valid, and the selected filter does not change.

BUG line 1304 InitializeNamespace ... CoInvoke Release.
You need to zero global pointers after releasing any instance. If SetHxCollection fails (or something later), next time you execute InitializeNamespace, Release will be called again on the released pointer. Change the namespace two or three times to see what happens.

BUG line 1435 EndHxSession
Release method is allowed to return any value, not only the reference count, so you should not rely on it, and always set *ppSession to NULL after calling Release.

Memory leaks in function GetURL, GetName, GetCollectionTitle...
pbszName = SysAllocString{Len}
CoInvoke methodname, [pbszName]

The methodname method always calls SysAllocString and returns the new string in the last parameter. If you do so, the first 4 bytes in pbszName are a BSTR pointing to new string. Use this instead:
// do not call invoke SysAllocString{Len}
CoInvoke(pInterface,IWebBrowser2.get_LocationName,offset pbszName)

This is how a method returns BSTR:
HRESULT __stdcall IMyInterface::get_title(BSTR* ppv)
{
*ppv = SysAllocString(L"whatever");
return *ppv ? S_OK : E_OUTOFMEMORY;
}
or
invoke SysAllocString, L"whatever"
mov edx,[ppv]
mov [edx],eax

donkey

#19
Hi akane,

Thanks very much, I wasn't comfortable with the way the BSTR returns seemed to end up working, I am actually glad I had it wrong, at least now it makes sense. Just not used to having to free someone else's memory so it never dawned on me that I might have to. I have combed through the application as much as I could and hopefully I've taken care of the leaks and the necessary releases. I hope to finish up the unicode version in the next couple of days, that way I can get rid of the back and forth conversion that dogs the program. I still have one leak that I haven't tracked down, when I dbl click an item in the index memory usage shoots up about 200 or so K and doesn't drop back down after 20 or so pages it adds up, I am trying to find the cause.

I have uploaded an interim version (0.4.1.0) while I continue work on the unicode release.

Hi ToutEnMasm

Good idea, the Search dialog now works the way you suggested, it remains active until you close it.

Edgar
"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

You have to love GoAsm,

Nearly 2000 lines of code and the ANSI to UNICODE transition took less than half an hour and everything was working, I am so happy I picked this assembler !!!

The UNICODE version has been uploaded (0.5.0.0) there was an issue with the commctrl header file under UNICODE that has been dealt with, headers version 0x013002 is required to build the application because of the error, that has been uploaded as well. There is very little code changed since the change over from ANSI to UNICODE apis is automatically handled in the headers. The most significant difference is the lack of conversion back and forth, there were places where the lstrcpyn function was used when moving data from bstr return values to memory buffers. I decided on lstrcpyn because since I have no control over the length of string returned from the COM calls it protects the buffers from overruns. Any inline quoted text has the L modifier to indicate UNICODE, declared text uses DUS. The only real issue I ran into was the registry, you will have to delete the registry key created by the ANSI version and run the program to reselect it, it is found under

HKCU\Software\Donkey\HelpViewer\

Just delete the whole thing, the namespace is the only thing saved there for now anyway.
"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

Donkey, could you please include the object file in your zip file? On a crash, it would be easier to find the bug. It is crashing if you change the namespace (no visible change) and close the viewer or click a topic.

donkey

Quote from: akane on February 25, 2009, 10:01:11 PM
Donkey, could you please include the object file in your zip file? On a crash, it would be easier to find the bug. It is crashing if you change the namespace (no visible change) and close the viewer or click a topic.

Hi akane,

Had to work so I didn't get to this till I got home (my boss actually wants me to show up in order to get paid nazi bast*rd), I should have also been releasing the whole session when changing collections, as well I needed to call AtlUnAdvise for the index view. It seems to be working fine now, actually better than before, I am not sure why this problem didn't appear in the ANSI version as it has nothing to do with the conversion. I have included the OBJ and RES files in the zip.
"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

I have added a table of contents to the viewer along with a synchronize button on the toolbar. In order to add the TOC I also had to add a tab control which should allow for better expandability in the future as I can now add new windows easily. I have yet to code the splitter bar, too many things going on with other parts of the program right now. I am currently working on adding the ability to open CHM files in the viewer and making the UI transparent to the difference. This will allow for a fully integrated help system for both HTML Help 1.x and 2.0 with complete transparency to the user.

The progress with HTMLHelp 1.x is slow, I have implemented the IStorage interface and can extract a Keyword index in XML format from any CHM file, the major outstanding issue is to parse the XML file. The TOC should be straight forward enough once I finish the parser. Once this is finished and implemented I will begin to scratch my head over the splitter bar and a few other UI issues.

You can download the source and executable at my website.

The new version number is 0.6.0.0
"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

I've got my frst exception, thanks for the object file! I managed to find the cause in StartHxSession:
StartHxSession FRAME ppSession
LOCAL pSession:D

mov eax,[ppSession]
mov ecx,[eax]
test ecx,ecx
jz >
CoInvoke(eax,IHxSession.IUnknown.Release)
:

Should not ecx be passed to coinvoke?

donkey

Hi akane,

Actually that whole bit was supposed to be removed, it is unnecessary I missed it when I rewrote the namespace loader. Odd that I don't get the exception here though. Yes, it should be ECX but that will not help as the interface is released immediately prior to the call by the InitializeNamespace function so it is redundant. The first call to StartHxSession at startup was also redundant and has been removed since the session is started in InitializeNamespace instead. I have uploaded version 0.6.1.1 which should correct the problem, it also has the search dialog moved to the tab, it makes more sense having it there.

Edgar
"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

Version 0.6.1.4:

A few minor changes to the UI, the DISPID_COMMANDSTATECHANGE event is processed allowing the back and forward buttons to be disabled when there are no pages for them to navigate to. The top of the web browser has been aligned to the tab control and the search window resizing issue has been dealt with.

The initialization of the application had a bug where I assumed that any one running the app would have Help2 installed, that may not be the case so it will exit gracefully if the required class is not found. The OLE error code is reported in the termination dialog if the program cannot load Help2.

Edgar
"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

#27
Version 0.6.2.1

Added a command line option to do an index search, this is primarily for integration into an IDE. The command line is very simple...

Help2 Viewer.exe /Keyword /Namespace

The keyword cannot contain spaces, nor can there be a space after the /. In order to make the program workable I also added a SingleInstance function, it enforces only one instance of the program to be running at a time. If another is started the command line is parsed and through some fancy interprocess communication it passes the keyword to the running instance. However, I am not entirely sure that Vista allows this type of thing so I need someone to test on Vista. Also the program needs to be run in Admin mode as far as I know, if someone can test that as well I would greatly appreciate it.

EDIT> I thought about the command line and added the /Namespace as well. The program will check to see if one was specified and initialize it if it is. The arguments are location specific, in other words the first argument must be the keyword. The namespace is as it appears in the select namespace dialog, that is :

MS.MSDNQTR.v90.en

Do not add the "ms-help://" prefix, it is added by the program.

Since this feature is aimed at IDE plugin authors I have decided the strictness is not a limitation so I will most likely not be changing it to a more robust method. It is up to the IDE to determine the fitness of the data passed.
"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

Version 0.6.2.4

Had to redo the command line parser to parse it completely from within the application as there were issues with instances started through CreateProcess when lpApplicationName was non-NULL. It should now catch the problem and deal with it appropriately, I also added the option to change collections from an IDE, the command line syntax remains the same.
"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

Version 0.6.2.5

Incredibly small update, I was trying resource based urls and added a resource based page to display a custom page when a navigation error occurs.

BTW I really need to know if interprocess communication works under Vista, just run the prog and double click the "Find ExitProcess" link.
"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