Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

41 lines
2.4 KiB

  1. For each service pack, we will create a new subdirectory. The first service pack to use
  2. this method is sp1, so the first directory created is sp1.
  3. When you build the resourcedll\sp1 directory, a couple of things happen:
  4. The first thing is that it creates a dll called sp1res.dll. This dll doesn't
  5. contain any code or entry points; it just has resources in it. Adding new
  6. string resources is simply a matter of editing the sp1res.mc file in this
  7. directory and recompiling.
  8. The second thing that happens is that it creates sp1res.h, and copies it to the
  9. \nt\private\inc directory. This header file contains the resource IDs for all
  10. the resources in sp1res.dll.
  11. Now, how does this get used? There are two different scenarios:
  12. (1) a binary wants to add a resource string to be used in logging
  13. event log messages.
  14. (2) a binary wants to use an resource string for some other reason, such as
  15. displaying in a message box.
  16. In both scenarios, the programmer will include the sp1res.h file in his source
  17. code, so that he has access to the correct resource IDs.
  18. In scenario (1), you simply add the path and name of sp1res.dll to the appropriate
  19. registry key for the component that logs the error message; for example in W2K
  20. bug 12918, dmboot.sys is the component that logs the error message, so under
  21. the key HKLM,"SYSTEM\CurrentControlSet\Services\EventLog\System\dmboot", you would
  22. change EventFileLog from its current value of %SystemRoot%\System32\Drivers\dmboot.sys
  23. to a new value of %SystemRoot%\System32\Drivers\dmboot.sys; %SystemRoot%\System32\sp2res.dll.
  24. When event viewer encounters an error message logged with a source of dmboot, it
  25. will look for the resource string first in dmboot.sys, and then in sp2res.dll.
  26. In scenario (2), the coder needs to manually do a LoadLibraryEx() on sp1res.dll,
  27. and a LoadString() for whatever resource he is looking for. You should use the
  28. LOAD_LIBRARY_AS_DATAFILE flag when using LoadLibraryEx(). This will be completely
  29. straightforward in the cases where the existing code already requires a LoadLibrary
  30. and LoadString to get at its resources; you'll just need to load an additional
  31. library. It will be slightly less straightforward in those cases where the
  32. existing binary is just getting resources out of its own resource section, since
  33. this will involve adding new code to load a library that was not necessary
  34. before; however, even in those cases, it's not exactly rocket science.