How can I get a list of help context IDs used in a CHM help file? - chm

I have a C++ program that calls AfxMessageBox, passing in a help file context ID. When I click Help on the resulting message box, I get a litte error box that says "Failed to launch help." I need to verify that I'm using a valid help ID. Is there a way to examine a CHM file to find out what context IDs are valid for it? Either a commercial tool or a way to write a C# or C++ or even Python program to do it.
Edit: This is an old CHM file, and I do not have the files that were used to create it. I used 7-zip to extract its contents into a folder, but I see nothing there that tells me what context IDs the file has. When the error occurs, the C++ code assigns a value of 135 to the error, and then it adds 0x30000 (196,608) to that for no reason I know. Then, when the message box gets generated, 0x30000 is subtracted and the result, 135, is passed in to AfxMessageBox() as the help ID. I've tried both 135 and 196743 (0x30000 + 135) in the AfxMessageBox() call but neither has worked. The files extracted from the help file by 7-Zip include a set of .htm file with numbers for names, but the numbers have no relation to the context IDs that I can find.
There is another execution path in my code that uses the same help file. As near as I can tell, it uses low-level functions to create a dialog box that resembles the output of AfxMessageBox(). When I force that code path use context ID 196743, I get the expected help page. Unfortunately, it's not easy to get from the code that doesn't work to the code that does.

Edit:
Your additional Edit in the question take me back many years. Not related to your original question but some links to read:
Starting with HTML Help
Adding HTML Help to Existing Dialog-Based Application
Extracting help contextID by code you must have deep knowledge of the CHM internals.
For a single value e.g. 10000 you may want to test the contextID using PowerShell or a DOS prompt. This opens the requested .chm in the Help viewer, and uses a context ID to request a URL to display.
hh.exe -mapid 10000 ms-its:CHM-example.chm
Sometimes you only have the CHM output file and nobody can locate the source files. It’s not always possible to recover all files and data you need.
Decompiling loses the alias.h and map.h files and their information for F1-Help (context sensitive help).
You may know a CHM is something like a zipped web (HTML archive) with some additional system files of metadata. Context ID's are mostly integrated by compiling a alias.h and map.h file. The purpose of the two files is to ease the coordination between developer and help author. The mapping file links an ID to the map number - typically this can be easily created by the developer and passed to the help author. Then the help author creates an alias file linking the IDs to the topic names (See: Creating Context-Sensitive Help for Applications.
I'm using FAR HTML as a toolbox full of various authoring, file and HTML utilities (Disclaimer: It is freeware now!).
Please note there is a download link (for required Microsoft HTMLHelp Workshop) because the Microsoft download links are broken.
The CHM can be opened using FAR HTML and by copy and paste you have all ID and topic information (ALIAS section). In Help File Explorer you need to open Internal Files > #IVB.

Related

Is there any way to fill in Sharepoint entries via parsing text file?

My workplace has a whole bunch of unannotated .zip files that need to be uploaded to the new file server (Windows). I've used perl to parse through through the excel files within the .zip files to create an annotation.txt file for each .zip file that contains information about the .zip file. I have 1000's of zip files and do not want to manually enter in information for each entry if there's a way to automate it. I am proficient in perl and mysql, and wondering if there is any way to utilize my skillsets to port this information into the Microsoft Sharepoint website.
Thank you in advance for any advice or suggestions.
There a many, many ways to meet your requirement.
You could write a event receiver to parse the files once uploaded and set metadata.
A better approach for your use case might be to write a .NET based console application and reference Microsoft.SharePoint.Client and then upload your files using the Client side object model (CSOM) and set the metadata during that process as outlined here: Upload a document to a SharePoint list from Client Side Object Model
There are also REST and ASMX webservices that you could call from a non .NET runtime process.
Plenty of options, pick the one that fits your needs and skills best.

CHM file unreadble if saved to hdd

I've just downloaded JSon.Net for framework 4.0 as a zip file.
Opening zip (using WinRar) I'm able to open Documentation.chm file by double-clicking over the name listed and the help file is well done.
Anyway if I extract this file to hdd and I open it, help is unreadable.
Sounds silly, but it's happening.
Thanks for your help!!!
EDITED:
Another tip: unreadble chm file is located in D:\.... (second NTFS partition of first hdd); if I save it on my desktop, chm file becomes readable !!! Crazy...
------------------------------------
---------- SOLUTION ----------
------------------------------------
I answer my question to close it and to help someone who finds in my same trouble.
Using tip suggested by #Marco van de Voort I searched Google for "chm unblock" and found this link:
Your CHM files are stored in the folder with '#' (hash) character in
the path Many C# developers discovered that their documentation
and e-books in CHM format cannot be read because they were storing
their CHM files in the directories like 'C:\E-books\C#\'. The hash
character signifies an anchor in HTML so the CHM viewer fails to
resolve the path properly and to retrieve the content.
That was my problem: I had path with a #... and I'd never thought this could be a great mess for CHM files!!!
Thanks to SO mates for the help given !!
Windows keeps track of downloaded files on NTFS systems, and puts certain restrictions on them. If you extract with windows explorer, this status propagates from archive to file. Using a third party tool (winrar in your case, I use INFO zip) can circumvent this.
Some descriptions and other links can be found
http://wiki.lazarus.freepascal.org/chm_backend_for_fpdoc#Troubleshooting
Free Pascal (2.4.4) has some tool to unlock them. (chmls unblock). It is done by truncating an alternate filestream (therefore it only works with NTFS). I found this info somewhere on stackoverflow, but can't quickly find the link.
It might be that virtual folders like desktop don't fully support this.
maybe the references to some content is to web or no chm file. maybe if you can disassamble in CHM editor and change paths can fix it.
maybe this can help you
There are security permissions applied to this file type by a recent patch.
you need to unblock the file:
http://www.helpscribble.com/chmnetwork.html
instead of thinking many possibilities of "windows security permission", get a CHM reader or wrap your CHM using winrar, and doubleclick to view it like you did.
It's save your time a lot!!
So, two simple solutions are:
have a CHM reader: https://blog.kowalczyk.info/articles/chm-reader-viewer-for-windows.html
OR right click CHM file/s, > Add to RAR Archive.
If you want to read it, double click RAR file > double click CHM file. BINGO!!

A web-page that would provide a user to download a certain file from it, but would not disclose the location of that file - is it possible at all?

(I am sorry if my question is not in the right place. (I've been thinking for awhile and came up to the conclusion that this one is the best place for my question)
Is it possible to create such an HTML web-page that would provide a user to download a certain file from it, but would not disclose the location of that file (i.e. the user would not know the URL of the file that he is downloading).
If yes, would you, please, give me some directions as to which HTML code I should use to create such a page.
The HTML page would provide a link to a server side script passing a filename or other unique moniker:
Download Now
The script would read the identifier, derive a full path from it, load the file and write it back with the appropriate headers/mime type causing the browser to prompt the user with the normal download dialog.
The only location data available to the user would be the link to the script - which would - unless you add some security - serve back the file just as if it were a standard url pointing to a file.
(PHP Example)
With pure html, no. But with a serverside script (php, c#, vb, perl, or other) yes. You would stream the file to user. In that case just the serverside script has access to the origin files

How to extract hhp file from a chm file

I have an A.chm file for my windows application which runs as expected.
When I decompile it using HTML workshop I get set of html files, .hhc file, .hhk file. When I compile another file B.chm from these extracted files without changing any of the files.((I want to add more html contents to this file but looks like I am losing some information after decompiling)) The output file I get is 72K where as the original file was 75K. B.chm's contents look all file when viewed in the chm viewer but the behavior is lost when when used with the application.
After reading around I found that if .hhp can be extracted from a .chm file then it can be re-constructed as it is without losing any mapping or aliases. Is that true?
How can I extract .hhp file from a .chm file?
Thanks,
Sam
No, Yes , and no.
The original hhp can't be guaranteed extracted
however since chm is an archive type, the project could have added all project files to the archive. I assume you already would have found them if that were the case.
If the decompile process does its administration, it can regenerate the .hhp to a certain degree.
Comments and #define names will probably be lost though, maybe more, but that should not result in problems when recompiling.
But of course it could be that the decompiler is limited. You could try some other (search for something from "keytools").
If not, then take "chmlib" and start drilling down into the format.

Packing a file into an ELF executable

I'm currently looking for a way to add data to an already compiled ELF executable, i.e. embedding a file into the executable without recompiling it.
I could easily do that by using cat myexe mydata > myexe_with_mydata, but I couldn't access the data from the executable because I don't know the size of the original executable.
Does anyone have an idea of how I could implement this ? I thought of adding a section to the executable or using a special marker (0xBADBEEFC0FFEE for example) to detect the beginning of the data in the executable, but I do not know if there is a more beautiful way to do it.
Thanks in advance.
You could add the file to the elf file as a special section with objcopy(1):
objcopy --add-section sname=file oldelf newelf
will add the file to oldelf and write the results to newelf (oldelf won't be modified)
You can then use libbfd to read the elf file and extract the section by name, or just roll your own code that reads the section table and finds you section. Make sure to use a section name that doesn't collide with anything the system is expecting -- as long as your name doesn't start with a ., you should be fine.
I've created a small library called elfdataembed which provides a simple interface for extracting/referencing sections embedded using objcopy. This allows you to pass the offset/size to another tool, or reference it directly from the runtime using file descriptors. Hopefully this will help someone in the future.
It's worth mentioning this approach is more efficient than compiling to a symbol, as it allows external tools to reference the data without needing to be extracted, and it also doesn't require the entire binary to be loaded into memory in order to extract/reference it.