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.

54 lines
1.8 KiB

  1. /*
  2. *
  3. * signatr.h
  4. *
  5. * This file defines the signatures of various T.120 objects. These
  6. * signatures are used mainly for debugging debug and retail versions
  7. * of T.120.
  8. *
  9. * T.120 used to have many many dictionaries where pointers to objects were put using
  10. * 16-bit values as keys to search the dictionary and get the pointer to
  11. * the appropriate object. These lookups were inefficient for three
  12. * reasons:
  13. *
  14. * 1. The lookup takes time
  15. * 2. The dictionaries take space
  16. * 3. A 16-bit value passed around requires masking to extract in a
  17. * 32-bit machine, that is, extra instructions.
  18. *
  19. * To eliminate these efficiency problems, the pointers to the objects are
  20. * used as handles to them (unique values identifying the objects).
  21. * But, to catch bugs caused by modifications of these handles as they are
  22. * passed around, we need to put a signature in each object that lets us
  23. * verify whether an object of type X is really an object of type X. The way
  24. * we do this is by specifying a unique signature for type X and putting this
  25. * signature into every object of type X.
  26. *
  27. * Each signature contains only 8 significant bytes.
  28. */
  29. #ifndef _T120_SIGNATURES
  30. #define _T120_SIGNATURES
  31. // Signature length
  32. #define SIGNATURE_LENGTH 8
  33. #ifdef _DEBUG
  34. // The macro to compare signatures
  35. #define SIGNATURE_MATCH(p, s) (memcmp ((p)->mSignature, (s), SIGNATURE_LENGTH) == 0)
  36. // The macro to copy signatures
  37. #define SIGNATURE_COPY(s) (memcpy (mSignature, (s), SIGNATURE_LENGTH))
  38. #else // _DEBUG
  39. #define SIGNATURE_MATCH(p, s) (TRUE)
  40. # ifndef SHIP_BUILD
  41. # define SIGNATURE_COPY(s) (memcpy (mSignature, (s), SIGNATURE_LENGTH))
  42. # else // SHIP_BUILD
  43. # define SIGNATURE_COPY(s)
  44. # endif // SHIP_BUILD
  45. #endif // _DEBUG
  46. extern const char *MemorySignature;
  47. #endif // _T120_SIGNATURES