Leaked source code of windows server 2003
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.

139 lines
4.8 KiB

  1. Copyright (c) 1997-2001 Microsoft Corporation
  2. BURNSLIB: Basic Utility Resource 'N String Library ;->
  3. ==================================================
  4. There are two flavors of this library: the "core" and the "rest."
  5. The core library is the most stable, and most easily used in just about any
  6. application. It consists of the following:
  7. - class String, which is a Windows-aware, enhancement of std::wstring.
  8. - Replacement versions of ::operator new and ::operator delete,
  9. which, among other things allow each allocation to be accompanied
  10. with file, line number and stack trace at the point of allocation.
  11. - class Log, which provides thread-safe diagnostic logging with
  12. output directable to debugger, file, a named pipe.
  13. - A very small set of lightweight COM helpers which do not exhibit
  14. the elephantine nature of MFC and ATL constructs of similar
  15. purpose.
  16. The rest is really meant for my own use, but has since garnered enough
  17. dependent projects that we have to take version control serviously (the
  18. bane of the shared code author).
  19. IMPORTANT:
  20. If you use the core or the rest, please update the dependents.txt file so
  21. that I can make sure changes I make don't break your build.
  22. To use the core library in your code:
  23. ====================================
  24. In your razzle environment (for chk builds, this causes the linker to use
  25. the debug CRT .lib files and passes -D_DEBUG to the compiler. This is
  26. necessary to use the heap debugging functionality)
  27. set DEBUG_CRTS=1
  28. In your headers.hxx file
  29. Add #include <blcore.hpp> before any headers for code that you want to
  30. use the replacement operator new and delete. (Generally, I only put
  31. include headers from outside my project in headers.hxx. So, I include
  32. blcore.hpp last in my headers.hxx.)
  33. Note that blcore.hpp #includes syscore.hpp, which in turn #includes
  34. several sdk header files. You may want to remove redundant inclusion
  35. of those files.
  36. In your sources file:
  37. Add admin\burnslib\inc to the INCLUDES macro
  38. Add the following to your UNLIBS or TARGETLIBS macro
  39. $(SDXROOT)\admin\burnslib\lib\*\blcore.lib
  40. Add the following lines:
  41. # enable logging for chk builds
  42. !if !$(FREEBUILD)
  43. !MESSAGE defining LOGGING_BUILD
  44. C_DEFINES=$(C_DEFINES) -DLOGGING_BUILD
  45. !ENDIF
  46. # enable Unicode support
  47. C_DEFINES=$(C_DEFINES) -DUNICODE -D_UNICODE
  48. # enable C++ Standard Template Library
  49. USE_STL=1
  50. # enable C++ Exceptions
  51. USE_NATIVE_EH=1
  52. # use msvcrt (C runtimes)
  53. USE_MSVCRT=1
  54. Somewhere in your source code, you need to define the following symbols.
  55. See blcore.hpp for explanations of each.
  56. HINSTANCE hResourceModuleHandle
  57. const wchar_t* RUNTIME_NAME
  58. DWORD DEFAULT_LOGGING_OPTIONS
  59. In your project's resource script (rc) file, #include blcore.rc. These are
  60. the resources for the out-of-memory dialog.
  61. Notes:
  62. =========================
  63. Since you are using the debug CRTs, you will need to have available on your
  64. search path msvcrtd.dll and possibly also msvcp50d.dll (depending on which
  65. STL templates your code uses). This means that you will may need to
  66. include those dlls with any private chk binaries you distribute.
  67. All of BURNSLIB compiles clean with warning level 4, so you can include
  68. MSC_WARNING_LEVEL=/W4 in your sources if you wish.
  69. BURNSLIB is statically linked to your binary. There is no associated dll.
  70. It replaces the global operator new, operator new[], operator delete, and
  71. operator delete[] with private versions. This isolates the behavior of
  72. those operators to your binary. To understand why this is a Good Thing,
  73. see new.doc. If you use STL template classes, then remember to use the
  74. Burnslib::Heap::Allocator classes to keep the STL from falling back to the
  75. CRT allocator.
  76. If you plan to use any functions that load resources (strings, icons,
  77. etc.), you need to make sure you set the hResourceModuleHandle to the
  78. HINSTANCE of the binary containing the resource. The best place to do this
  79. is the first line of code in WinMain/DllMain. The design of the library
  80. assumes that all resources are in the same binary; a tradeoff between
  81. simplicity and flexibility. In your code, you can retrieve this handle by
  82. calling Burnslib::GetResourceModuleHandle().
  83. Most of the symbols are in the Burnslib namespace. blcore.hpp specifies
  84. "using namespace Burnslib;" so you don't have to.
  85. To use the "rest" of the library in your code:
  86. =============================================
  87. Cut and paste. Don't link directly to it. I tweak the rest with reckless
  88. abandon and will offer no apologies for breaking your code.
  89. Well, that was then. I will try to be a good citizen here.
  90. <eof>