home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / comp / os / mswindo / programm / win32 / 3131 < prev    next >
Encoding:
Internet Message Format  |  1993-01-28  |  2.0 KB

  1. 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
  2. From: dale@mkseast.uucp (Dale Gass)
  3. Newsgroups: comp.os.ms-windows.programmer.win32
  4. Subject: Finding message strings for error numbers...
  5. Message-ID: <1993Jan27.024020.8420@mkseast.uucp>
  6. Date: 27 Jan 93 02:40:20 GMT
  7. Organization: Mortice Kern Systems, Atlantic Canada Branch
  8. Lines: 49
  9.  
  10. (Yet another complaint on my part about having to use undocumented calls
  11. to achieve a basic function...)
  12.  
  13. NT has (well, to use a nice word) a "wealth" of error codes, about 550
  14. listed in winerror.h.
  15.  
  16. There doesn't appear to be any documented way to convert such an error 
  17. code from GetLastError() into an informative string.
  18.  
  19. I tried compiling up a quick "main{perror()};" program to see if it had
  20. any clues.  Not.  It just had a sys_errlist table in CRTDLL for the first
  21. 37 error messages (which are the same ones as on DOS).
  22.  
  23. I noticed that cmd.exe appeared to print full error message strings:
  24. ("type [" generates a nice, verbose string).
  25.  
  26. Hunting around with the debugger, I find Yet Another Undocumented Call, 
  27. which I guess goes something like this:
  28.  
  29.     BOOL RtlFindMessage(void *dll, 
  30.                 DWORD a, 
  31.                 DWORD b, 
  32.                 DWORD status, 
  33.                 struct msg m)
  34.  
  35.     "dll" appears to be a pointer into the address space of the appropriate
  36.     dll.  If you point it into KERNEL32.DLL, the messages you get are
  37.     the kernel error messages.  CMD.EXE also uses this call, with dll 
  38.     pointing into itself to retrieve other strings of its own.
  39.  
  40.     "a" always appears to be 0xb
  41.     "b" always appears to be 0
  42.     Status is the error code we want to look up.
  43.  
  44.     struct msg {
  45.         DWORD num;    Some number
  46.         char str[1];    Start of the error message string.
  47.     }
  48.  
  49. Now this looks like a genuinely useful call, and the only way to print out
  50. an aribtrary but meaningful error string based upon a value returned by
  51. GetLastError().
  52.  
  53. Is there any "official" way to do the same thing?
  54.  
  55. -dale
  56. -- 
  57.  Dale Gass, Mortice Kern Systems, Atlantic Canada Branch
  58. Business: dale@east.mks.com, Pleasure: dale@mkseast.uucp
  59.