home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!munnari.oz.au!sgiblab!spool.mu.edu!olivea!charnel!sifon!newsflash.concordia.ca!nstn.ns.ca!cs.dal.ca!iisat!mkseast!dale
- From: dale@mkseast.uucp (Dale Gass)
- Newsgroups: comp.os.ms-windows.programmer.win32
- Subject: Finding message strings for error numbers...
- Message-ID: <1993Jan27.024020.8420@mkseast.uucp>
- Date: 27 Jan 93 02:40:20 GMT
- Organization: Mortice Kern Systems, Atlantic Canada Branch
- Lines: 49
-
- (Yet another complaint on my part about having to use undocumented calls
- to achieve a basic function...)
-
- NT has (well, to use a nice word) a "wealth" of error codes, about 550
- listed in winerror.h.
-
- There doesn't appear to be any documented way to convert such an error
- code from GetLastError() into an informative string.
-
- I tried compiling up a quick "main{perror()};" program to see if it had
- any clues. Not. It just had a sys_errlist table in CRTDLL for the first
- 37 error messages (which are the same ones as on DOS).
-
- I noticed that cmd.exe appeared to print full error message strings:
- ("type [" generates a nice, verbose string).
-
- Hunting around with the debugger, I find Yet Another Undocumented Call,
- which I guess goes something like this:
-
- BOOL RtlFindMessage(void *dll,
- DWORD a,
- DWORD b,
- DWORD status,
- struct msg m)
-
- "dll" appears to be a pointer into the address space of the appropriate
- dll. If you point it into KERNEL32.DLL, the messages you get are
- the kernel error messages. CMD.EXE also uses this call, with dll
- pointing into itself to retrieve other strings of its own.
-
- "a" always appears to be 0xb
- "b" always appears to be 0
- Status is the error code we want to look up.
-
- struct msg {
- DWORD num; Some number
- char str[1]; Start of the error message string.
- }
-
- Now this looks like a genuinely useful call, and the only way to print out
- an aribtrary but meaningful error string based upon a value returned by
- GetLastError().
-
- Is there any "official" way to do the same thing?
-
- -dale
- --
- Dale Gass, Mortice Kern Systems, Atlantic Canada Branch
- Business: dale@east.mks.com, Pleasure: dale@mkseast.uucp
-