Test.js 3.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. // Create the SymGuard.Application object
  2. // (this is designed to be safely cached in an ASP Application object variable)
  3. var app = new ActiveXObject("SymGuard.Application");
  4. // Declare input values
  5. var strSymbolPath = "C:\\temp";
  6. var strModuleName = "Allegiance.exe"; // Get from XML
  7. var strImageBase = "00400000"; // Get from XML
  8. var strImageSize = "001D8000"; // Get from XML
  9. // Create a SymGuard.Module object
  10. var timeBegin = new Date();
  11. var module1 = app.LoadModule(strSymbolPath, strModuleName, strImageBase, strImageSize);
  12. var timeEnd = new Date();
  13. DisplaySymModule(module1);
  14. WScript.Echo("First LoadModule: " + (timeEnd - timeBegin) + " ms\n");
  15. function DisplaySymModule(module)
  16. {
  17. // Display the properties of the module or symbol file
  18. WScript.Echo("SymbolPath = " + module.SymbolPath );
  19. WScript.Echo("ModuleName = " + module.ModuleName );
  20. WScript.Echo("ImageBase = 0x" + Hex(module.ImageBase) );
  21. WScript.Echo("ImageSize = 0x" + Hex(module.ImageSize) );
  22. WScript.Echo("TimeDateStamp = " + module.TimeDateStamp );
  23. WScript.Echo("CheckSum = 0x" + Hex(module.CheckSum) );
  24. WScript.Echo("SymbolCount = 0x" + Hex(module.SymbolCount) );
  25. WScript.Echo("SymbolType = " + module.SymbolType );
  26. WScript.Echo("ImageName = " + module.ImageName );
  27. WScript.Echo("LoadedImageName = " + module.LoadedImageName);
  28. // Set the path-formatting options
  29. module.BuildPathBase = "D:\\fedsrc"; // Gets stripped from beginning
  30. module.SourcePathBase = "\\\\oblivion0\\builds\\2006\\CD2\\Src"; // Gets prepended to beginning
  31. // Display the symbol information for several addresses
  32. DisplaySymAddress(module, "00426297"); // Get from XML
  33. DisplaySymAddress(module, "0042117B"); // Get from XML
  34. DisplaySymAddress(module, "0041F271"); // Get from XML
  35. DisplaySymAddress(module, "004C9CC1"); // Get from XML
  36. DisplaySymAddress(module, "004C9F50"); // Get from XML
  37. DisplaySymAddress(module, "004A6610"); // Get from XML
  38. DisplaySymAddress(module, "004A680A"); // Get from XML
  39. DisplaySymAddress(module, "004AB998"); // Get from XML
  40. DisplaySymAddress(module, "004757DF"); // Get from XML
  41. DisplaySymAddress(module, "004A2DF8"); // Get from XML
  42. }
  43. /////////////////////////////////////////////////////////////////////////////
  44. // Displays all the known symbol information for the symbol at the specified
  45. // address within the specified module.
  46. //
  47. function DisplaySymAddress(module, addr)
  48. {
  49. // Find the symbol information for the specified address
  50. var sym = module.GetSymbolFromAddress(addr);
  51. // Display the properties of the symbol information object
  52. WScript.Echo(" " + module.ModuleName + "!" + Hex(sym.Address) + " " + sym.Name + " " + sym.DecoratedName);
  53. if (sym.SourceFileName.length && sym.LineNumber)
  54. {
  55. WScript.Echo(" " + sym.SourceFileName + "(" + sym.LineNumber + ")");
  56. WScript.Echo(" BytesFromSymbol = " + sym.BytesFromSymbol);
  57. WScript.Echo(" BytesFromLine = " + sym.BytesFromLine);
  58. }
  59. }
  60. /////////////////////////////////////////////////////////////////////////////
  61. // Converts the specified value to an 8-character hex string.
  62. //
  63. function Hex(val)
  64. {
  65. var str = "0000000" + new Number(val).toString(16);
  66. return str.substr(str.length - 8);
  67. }