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.

117 lines
2.9 KiB

  1. #include "SymCommon.h"
  2. #include <strsafe.h>
  3. BOOL SymCommonPDBLinesStripped(PDB *ppdb, DBI *pdbi) {
  4. // Return values:
  5. // FALSE - Private Information has NOT been stripped
  6. // TRUE - Private Information has been stripped
  7. Mod *pmod;
  8. Mod *prevmod;
  9. long cb;
  10. pmod = NULL;
  11. prevmod=NULL;
  12. while (DBIQueryNextMod(pdbi, pmod, &pmod) && pmod) {
  13. if (prevmod != NULL) ModClose(prevmod);
  14. // Check that Source line info is removed
  15. ModQueryLines(pmod, NULL, &cb);
  16. if (cb != 0) {
  17. ModClose(pmod);
  18. return FALSE;
  19. }
  20. // Check that local symbols are removed
  21. ModQuerySymbols(pmod, NULL, &cb);
  22. if (cb != 0) {
  23. ModClose(pmod);
  24. return FALSE;
  25. }
  26. prevmod=pmod;
  27. }
  28. if (pmod != NULL) ModClose(pmod);
  29. if (prevmod != NULL) ModClose(prevmod);
  30. return (TRUE);
  31. }
  32. BOOL SymCommonPDBPrivateStripped(PDB *ppdb, DBI *pdbi) {
  33. AGE age;
  34. BOOL PrivateStripped;
  35. GSI *pgsi;
  36. BOOL valid;
  37. age = pdbi->QueryAge();
  38. if (age == 0) {
  39. // If the age is 0, then check for types to determine if this is
  40. // a private pdb or not. PDB 5.0 and earlier may have types and no
  41. // globals if the age is 0.
  42. PrivateStripped= SymCommonPDBTypesStripped(ppdb, pdbi) &&
  43. SymCommonPDBLinesStripped(ppdb, pdbi);
  44. } else {
  45. // Otherwise, use globals to determine if the private info is
  46. // stripped or not. No globals means that private is stripped.
  47. __try {
  48. valid = pdbi->OpenGlobals(&pgsi);
  49. } __except( EXCEPTION_EXECUTE_HANDLER ) {
  50. valid= FALSE;
  51. }
  52. if ( !valid ) {
  53. return FALSE;
  54. }
  55. // Now, see if there are any globals in the pdb.
  56. valid=TRUE;
  57. __try {
  58. PrivateStripped= ((pgsi->NextSym(NULL)) == NULL);
  59. } __except( EXCEPTION_EXECUTE_HANDLER ) {
  60. valid= FALSE;
  61. }
  62. GSIClose(pgsi);
  63. if ( !valid ) {
  64. return FALSE;
  65. }
  66. }
  67. return (PrivateStripped);
  68. }
  69. BOOL SymCommonPDBTypesStripped(PDB *ppdb, DBI *pdbi) {
  70. // Return values:
  71. // FALSE - Private Information has NOT been stripped
  72. // TRUE - Private Information has been stripped
  73. unsigned itsm;
  74. TPI *ptpi;
  75. TI tiMin;
  76. TI tiMac;
  77. // Check that types are removed
  78. for ( itsm = 0; itsm < 256; itsm++) {
  79. ptpi = 0;
  80. if (DBIQueryTypeServer(pdbi, (ITSM) itsm, &ptpi)) {
  81. continue;
  82. }
  83. if (!ptpi) {
  84. PDBOpenTpi(ppdb, pdbRead, &ptpi);
  85. tiMin = TypesQueryTiMinEx(ptpi);
  86. tiMac = TypesQueryTiMacEx(ptpi);
  87. if (tiMin < tiMac) {
  88. TypesClose(ptpi);
  89. return FALSE;
  90. }
  91. }
  92. }
  93. TypesClose(ptpi);
  94. return (TRUE);
  95. }