aboutsummaryrefslogtreecommitdiff
path: root/src/shared
diff options
context:
space:
mode:
authorNeo2003 <none@none>2008-10-11 14:16:25 -0500
committerNeo2003 <none@none>2008-10-11 14:16:25 -0500
commit95b91afbab455d917a2800d8936e1f29e4d9604d (patch)
tree85e9e642d493123cd8cbafbf8d88ce9cafa32ddf /src/shared
parentf84ae3af9e9ab10bf43243187e5b458698e9a39a (diff)
[svn] * svn:eol-style native set on all files that need it
--HG-- branch : trunk
Diffstat (limited to 'src/shared')
-rw-r--r--src/shared/Database/DBCStructure.h1876
-rw-r--r--src/shared/Database/DBCfmt.cpp156
-rw-r--r--src/shared/Database/DatabaseEnv.h108
-rw-r--r--src/shared/WheatyExceptionReport.cpp2028
-rw-r--r--src/shared/WheatyExceptionReport.h234
5 files changed, 2201 insertions, 2201 deletions
diff --git a/src/shared/Database/DBCStructure.h b/src/shared/Database/DBCStructure.h
index 307dcb0655b..bca75923394 100644
--- a/src/shared/Database/DBCStructure.h
+++ b/src/shared/Database/DBCStructure.h
@@ -1,938 +1,938 @@
-/*
- * Copyright (C) 2005-2008 MaNGOS <http://www.mangosproject.org/>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#ifndef DBCSTRUCTURE_H
-#define DBCSTRUCTURE_H
-
-#include "Platform/Define.h"
-
-#include <map>
-#include <set>
-#include <vector>
-
-// Structures using to access raw DBC data and required packing to portability
-
-// GCC have alternative #pragma pack(N) syntax and old gcc version not support pack(push,N), also any gcc version not support it at some platform
-#if defined( __GNUC__ )
-#pragma pack(1)
-#else
-#pragma pack(push,1)
-#endif
-
-enum AreaTeams
-{
- AREATEAM_NONE = 0,
- AREATEAM_ALLY = 2,
- AREATEAM_HORDE = 4
-};
-
-enum AreaFlags
-{
- AREA_FLAG_SNOW = 0x00000001, // snow (only Dun Morogh, Naxxramas, Razorfen Downs and Winterspring)
- AREA_FLAG_UNK1 = 0x00000002, // unknown, (only Naxxramas and Razorfen Downs)
- AREA_FLAG_UNK2 = 0x00000004, // Only used on development map
- AREA_FLAG_SLAVE_CAPITAL = 0x00000008, // slave capital city flag?
- AREA_FLAG_UNK3 = 0x00000010, // unknown
- AREA_FLAG_SLAVE_CAPITAL2 = 0x00000020, // slave capital city flag?
- AREA_FLAG_UNK4 = 0x00000040, // many zones have this flag
- AREA_FLAG_ARENA = 0x00000080, // arena, both instanced and world arenas
- AREA_FLAG_CAPITAL = 0x00000100, // main capital city flag
- AREA_FLAG_CITY = 0x00000200, // only for one zone named "City" (where it located?)
- AREA_FLAG_OUTLAND = 0x00000400, // outland zones? (only Eye of the Storm not have this flag, but have 0x00004000 flag)
- AREA_FLAG_SANCTUARY = 0x00000800, // sanctuary area (PvP disabled)
- AREA_FLAG_NEED_FLY = 0x00001000, // only Netherwing Ledge, Socrethar's Seat, Tempest Keep, The Arcatraz, The Botanica, The Mechanar, Sorrow Wing Point, Dragonspine Ridge, Netherwing Mines, Dragonmaw Base Camp, Dragonmaw Skyway
- AREA_FLAG_UNUSED1 = 0x00002000, // not used now (no area/zones with this flag set in 2.4.2)
- AREA_FLAG_OUTLAND2 = 0x00004000, // outland zones? (only Circle of Blood Arena not have this flag, but have 0x00000400 flag)
- AREA_FLAG_PVP = 0x00008000, // pvp objective area? (Death's Door also has this flag although it's no pvp object area)
- AREA_FLAG_ARENA_INSTANCE = 0x00010000, // used by instanced arenas only
- AREA_FLAG_UNUSED2 = 0x00020000, // not used now (no area/zones with this flag set in 2.4.2)
- AREA_FLAG_UNK5 = 0x00040000, // just used for Amani Pass, Hatchet Hills
- AREA_FLAG_LOWLEVEL = 0x00100000 // used for some starting areas with area_level <=15
-};
-
-enum FactionTemplateFlags
-{
- FACTION_TEMPLATE_FLAG_CONTESTED_GUARD = 0x00001000, // faction will attack players that were involved in PvP combats
-};
-
-struct AreaTableEntry
-{
- uint32 ID; // 0
- uint32 mapid; // 1
- uint32 zone; // 2 if 0 then it's zone, else it's zone id of this area
- uint32 exploreFlag; // 3, main index
- uint32 flags; // 4, unknown value but 312 for all cities
- // 5-9 unused
- int32 area_level; // 10
- char* area_name[16]; // 11-26
- // 27, string flags, unused
- uint32 team; // 28
-};
-
-struct AreaTriggerEntry
-{
- uint32 id; // 0
- uint32 mapid; // 1
- float x; // 2
- float y; // 3
- float z; // 4
- float radius; // 5
- float box_x; // 6 extent x edge
- float box_y; // 7 extent y edge
- float box_z; // 8 extent z edge
- float box_orientation; // 9 extent rotation by about z axis
-};
-
-struct BankBagSlotPricesEntry
-{
- uint32 ID;
- uint32 price;
-};
-
-struct BattlemasterListEntry
-{
- uint32 id; // 0
- uint32 mapid[3]; // 1-3 mapid
- // 4-8 unused
- uint32 type; // 9 (3 - BG, 4 - arena)
- uint32 minlvl; // 10
- uint32 maxlvl; // 11
- uint32 maxplayersperteam; // 12
- // 13-14 unused
- char* name[16]; // 15-30
- // 31 string flag, unused
- // 32 unused
-};
-
-struct CharTitlesEntry
-{
- uint32 ID; // 0, title ids, for example in Quest::GetCharTitleId()
- //uint32 unk1; // 1 flags?
- //char* name[16]; // 2-17, unused
- // 18 string flag, unused
- //char* name2[16]; // 19-34, unused
- // 35 string flag, unused
- uint32 bit_index; // 36 used in PLAYER_CHOSEN_TITLE and 1<<index in PLAYER__FIELD_KNOWN_TITLES
-};
-
-struct ChatChannelsEntry
-{
- uint32 ChannelID; // 0
- uint32 flags; // 1
- char* pattern[16]; // 3-18
- // 19 string flags, unused
- //char* name[16]; // 20-35 unused
- // 36 string flag, unused
-};
-
-struct ChrClassesEntry
-{
- uint32 ClassID; // 0
- // 1-2, unused
- uint32 powerType; // 3
- // 4, unused
- //char* name[16]; // 5-20 unused
- // 21 string flag, unused
- //char* string1[16]; // 21-36 unused
- // 37 string flag, unused
- //char* string2[16]; // 38-53 unused
- // 54 string flag, unused
- // 55, unused
- uint32 spellfamily; // 56
- // 57, unused
-};
-
-struct ChrRacesEntry
-{
- uint32 RaceID; // 0
- // 1 unused
- uint32 FactionID; // 2 facton template id
- // 3 unused
- uint32 model_m; // 4
- uint32 model_f; // 5
- // 6-7 unused
- uint32 TeamID; // 8 (7-Alliance 1-Horde)
- // 9-12 unused
- uint32 startmovie; // 13 id from CinematicCamera.dbc
- char* name[16]; // 14-29 used for DBC language detection/selection
- // 30 string flags, unused
- //char* string1[16]; // 31-46 used for DBC language detection/selection
- // 47 string flags, unused
- //char* string2[16]; // 48-63 used for DBC language detection/selection
- // 64 string flags, unused
- // 65-67 unused
- //uint32 addon // 68 (0 - original race, 1 - tbc addon, ...) unused
-};
-
-struct CreatureDisplayInfoEntry
-{
- uint32 Displayid; // 0
- // 1-3,unused
- float scale; // 4
- // 5-13,unused
-};
-
-struct CreatureFamilyEntry
-{
- uint32 ID; // 0
- float minScale; // 1
- uint32 minScaleLevel; // 2 0/1
- float maxScale; // 3
- uint32 maxScaleLevel; // 4 0/60
- uint32 skillLine; // 5
- uint32 skillLine2; // 6
- uint32 petFoodMask; // 7
- char* Name[16]; // 8-23
- // 24 string flags, unused
- // 25 icon, unused
-};
-
-struct CreatureSpellDataEntry
-{
- uint32 ID; // 0
- //uint32 spellId[4]; // 1-4 hunter pet learned spell (for later use)
-};
-
-struct DurabilityCostsEntry
-{
- uint32 Itemlvl; // 0
- uint32 multiplier[29]; // 1-29
-};
-
-struct DurabilityQualityEntry
-{
- uint32 Id; // 0
- float quality_mod; // 1
-};
-
-struct EmotesTextEntry
-{
- uint32 Id;
- uint32 textid;
-};
-
-struct FactionEntry
-{
- uint32 ID; // 0
- int32 reputationListID; // 1
- uint32 BaseRepRaceMask[4]; // 2-5 Base reputation race masks (see enum Races)
- uint32 BaseRepClassMask[4]; // 6-9 Base reputation class masks (see enum Classes)
- int32 BaseRepValue[4]; // 10-13 Base reputation values
- uint32 ReputationFlags[4]; // 14-17 Default flags to apply
- uint32 team; // 18 enum Team
- char* name[16]; // 19-34
- // 35 string flags, unused
- //char* description[16]; // 36-51 unused
- // 52 string flags, unused
-};
-
-enum FactionMasks
-{
- FACTION_MASK_PLAYER = 1, // any player
- FACTION_MASK_ALLIANCE = 2, // player or creature from alliance team
- FACTION_MASK_HORDE = 4, // player or creature from horde team
- FACTION_MASK_MONSTER = 8 // aggressive creature from monster team
- // if none flags set then non-aggressive creature
-};
-
-struct FactionTemplateEntry
-{
- uint32 ID; // 0
- uint32 faction; // 1
- uint32 factionFlags; // 2 specific flags for that faction
- uint32 ourMask; // 3 if mask set (see FactionMasks) then faction included in masked team
- uint32 friendlyMask; // 4 if mask set (see FactionMasks) then faction friendly to masked team
- uint32 hostileMask; // 5 if mask set (see FactionMasks) then faction hostile to masked team
- uint32 enemyFaction1; // 6
- uint32 enemyFaction2; // 7
- uint32 enemyFaction3; // 8
- uint32 enemyFaction4; // 9
- uint32 friendFaction1; // 10
- uint32 friendFaction2; // 11
- uint32 friendFaction3; // 12
- uint32 friendFaction4; // 13
- //------------------------------------------------------- end structure
-
- // helpers
- bool IsFriendlyTo(FactionTemplateEntry const& entry) const
- {
- if(enemyFaction1 == entry.faction || enemyFaction2 == entry.faction || enemyFaction3 == entry.faction || enemyFaction4 == entry.faction )
- return false;
- if(friendFaction1 == entry.faction || friendFaction2 == entry.faction || friendFaction3 == entry.faction || friendFaction4 == entry.faction )
- return true;
- return (friendlyMask & entry.ourMask) || (ourMask & entry.friendlyMask);
- }
- bool IsHostileTo(FactionTemplateEntry const& entry) const
- {
- if(enemyFaction1 == entry.faction || enemyFaction2 == entry.faction || enemyFaction3 == entry.faction || enemyFaction4 == entry.faction )
- return true;
- if(friendFaction1 == entry.faction || friendFaction2 == entry.faction || friendFaction3 == entry.faction || friendFaction4 == entry.faction )
- return false;
- return (hostileMask & entry.ourMask) != 0;
- }
- bool IsHostileToPlayers() const { return (hostileMask & FACTION_MASK_PLAYER) !=0; }
- bool IsNeutralToAll() const { return hostileMask == 0 && friendlyMask == 0 && enemyFaction1==0 && enemyFaction2==0 && enemyFaction3==0 && enemyFaction4==0; }
- bool IsContestedGuardFaction() const { return (factionFlags & FACTION_TEMPLATE_FLAG_CONTESTED_GUARD)!=0; }
-};
-
-struct GemPropertiesEntry
-{
- uint32 ID;
- uint32 spellitemenchantement;
- uint32 color;
-};
-
-#define GT_MAX_LEVEL 100
-struct GtCombatRatingsEntry
-{
- float ratio;
-};
-
-struct GtChanceToMeleeCritBaseEntry
-{
- float base;
-};
-
-struct GtChanceToMeleeCritEntry
-{
- float ratio;
-};
-
-struct GtChanceToSpellCritBaseEntry
-{
- float base;
-};
-
-struct GtChanceToSpellCritEntry
-{
- float ratio;
-};
-
-struct GtOCTRegenHPEntry
-{
- float ratio;
-};
-
-//struct GtOCTRegenMPEntry
-//{
-// float ratio;
-//};
-
-struct GtRegenHPPerSptEntry
-{
- float ratio;
-};
-
-struct GtRegenMPPerSptEntry
-{
- float ratio;
-};
-
-struct ItemEntry
-{
- uint32 ID;
- uint32 DisplayId;
- uint32 InventoryType;
- uint32 Sheath;
-};
-
-struct ItemDisplayInfoEntry
-{
- uint32 ID;
- uint32 randomPropertyChance;
-};
-
-//struct ItemCondExtCostsEntry
-//{
-// uint32 ID;
-// uint32 condExtendedCost; // ItemPrototype::CondExtendedCost
-// uint32 itemextendedcostentry; // ItemPrototype::ExtendedCost
-// uint32 arenaseason; // arena season number(1-4)
-//};
-
-struct ItemExtendedCostEntry
-{
- uint32 ID; // 0 extended-cost entry id
- uint32 reqhonorpoints; // 1 required honor points
- uint32 reqarenapoints; // 2 required arena points
- uint32 reqitem[5]; // 3-7 required item id
- uint32 reqitemcount[5]; // 8-12 required count of 1st item
- uint32 reqpersonalarenarating; // 13 required personal arena rating
-};
-
-struct ItemRandomPropertiesEntry
-{
- uint32 ID; // 0
- //char* internalName // 1 unused
- uint32 enchant_id[3]; // 2-4
- // 5-6 unused, 0 only values, reserved for additional enchantments?
- //char* nameSuffix[16] // 7-22, unused
- // 23 nameSufix flags, unused
-};
-
-struct ItemRandomSuffixEntry
-{
- uint32 ID; // 0
- //char* name[16] // 1-16 unused
- // 17, name flags, unused
- // 18 unused
- uint32 enchant_id[3]; // 19-21
- uint32 prefix[3]; // 22-24
-};
-
-struct ItemSetEntry
-{
- //uint32 id // 0 item set ID
- char* name[16]; // 1-16
- // 17 string flags, unused
- // 18-28 items from set, but not have all items listed, use ItemPrototype::ItemSet instead
- // 29-34 unused
- uint32 spells[8]; // 35-42
- uint32 items_to_triggerspell[8]; // 43-50
- uint32 required_skill_id; // 51
- uint32 required_skill_value; // 52
-};
-
-struct LockEntry
-{
- uint32 ID; // 0
- uint32 keytype[5]; // 1-5
- // 6-8, not used
- uint32 key[5]; // 9-13
- // 14-16, not used
- uint32 requiredminingskill; // 17
- uint32 requiredlockskill; // 18
- // 19-32, not used
-};
-
-struct MailTemplateEntry
-{
- uint32 ID; // 0
- //char* subject[16]; // 1-16
- // 17 name flags, unused
- //char* content[16]; // 18-33
-};
-
-enum MapTypes
-{
- MAP_COMMON = 0,
- MAP_INSTANCE = 1,
- MAP_RAID = 2,
- MAP_BATTLEGROUND = 3,
- MAP_ARENA = 4
-};
-
-struct MapEntry
-{
- uint32 MapID; // 0
- //char* internalname; // 1 unused
- uint32 map_type; // 2
- // 3 unused
- char* name[16]; // 4-19
- // 20 name flags, unused
- // 21-23 unused (something PvPZone related - levels?)
- // 24-26
- uint32 linked_zone; // 27 common zone for instance and continent map
- //char* hordeIntro // 28-43 text for PvP Zones
- // 44 intro text flags
- //char* allianceIntro // 45-60 text for PvP Zones
- // 46 intro text flags
- // 47-61 not used
- uint32 multimap_id; // 62
- // 63-65 not used
- //chat* unknownText1 // 66-81 unknown empty text fields, possible normal Intro text.
- // 82 text flags
- //chat* heroicIntroText // 83-98 heroic mode requirement text
- // 99 text flags
- //chat* unknownText2 // 100-115 unknown empty text fields
- // 116 text flags
- int32 parent_map; // 117 map_id of parent map
- //float start_x // 118 enter x coordinate (if exist single entry)
- //float start_y // 119 enter y coordinate (if exist single entry)
- uint32 resetTimeRaid; // 120
- uint32 resetTimeHeroic; // 121
- // 122-123
- uint32 addon; // 124 (0-original maps,1-tbc addon)
-
- // Helpers
- bool IsExpansionMap() const { return addon != 0; }
-
-
- bool IsDungeon() const { return map_type == MAP_INSTANCE || map_type == MAP_RAID; }
- bool Instanceable() const { return map_type == MAP_INSTANCE || map_type == MAP_RAID || map_type == MAP_BATTLEGROUND || map_type == MAP_ARENA; }
- bool IsRaid() const { return map_type == MAP_RAID; }
- bool IsBattleGround() const { return map_type == MAP_BATTLEGROUND; }
- bool IsBattleArena() const { return map_type == MAP_ARENA; }
- bool IsBattleGroundOrArena() const { return map_type == MAP_BATTLEGROUND || map_type == MAP_ARENA; }
- bool SupportsHeroicMode() const { return resetTimeHeroic && !resetTimeRaid; }
- bool HasResetTime() const { return resetTimeHeroic || resetTimeRaid; }
-
- bool IsMountAllowed() const
- {
- return !IsDungeon() ||
- MapID==568 || MapID==309 || MapID==209 || MapID==534 ||
- MapID==560 || MapID==509 || MapID==269;
- }
-};
-
-struct QuestSortEntry
-{
- uint32 id; // 0, sort id
- //char* name[16]; // 1-16, unused
- // 17 name flags, unused
-};
-
-struct RandomPropertiesPointsEntry
-{
- //uint32 Id; // 0 hidden key
- uint32 itemLevel; // 1
- uint32 EpicPropertiesPoints[5]; // 2-6
- uint32 RarePropertiesPoints[5]; // 7-11
- uint32 UncommonPropertiesPoints[5]; // 12-16
-};
-
-//struct SkillLineCategoryEntry{
-// uint32 id; // 0 hidden key
-// char* name[16]; // 1 - 17 Category name
-// // 18 string flag
-// uint32 displayOrder; // Display order in character tab
-//};
-
-//struct SkillRaceClassInfoEntry{
-// uint32 id; // 0
-// uint32 skillId; // 1 present some refrences to unknown skill
-// uint32 raceMask; // 2
-// uint32 classMask; // 3
-// uint32 flags; // 4 mask for some thing
-// uint32 reqLevel; // 5
-// uint32 skillTierId; // 6
-// uint32 skillCostID; // 7
-//};
-
-//struct SkillTiersEntry{
-// uint32 id; // 0
-// uint32 skillValue[16]; // 1-17 unknown possibly add value on learn?
-// uint32 maxSkillValue[16]; // Max value for rank
-//};
-
-struct SkillLineEntry
-{
- uint32 id; // 0
- uint32 categoryId; // 1 (index from SkillLineCategory.dbc)
- //uint32 skillCostID; // 2 not used
- char* name[16]; // 3-18
- // 19 string flags, not used
- //char* description[16]; // 20-35, not used
- // 36 string flags, not used
- uint32 spellIcon; // 37
-};
-
-enum AbilytyLearnType
-{
- ABILITY_LEARNED_ON_GET_PROFESSION_SKILL = 1,
- ABILITY_LEARNED_ON_GET_RACE_OR_CLASS_SKILL = 2
-};
-
-struct SkillLineAbilityEntry
-{
- uint32 id; // 0, INDEX
- uint32 skillId; // 1
- uint32 spellId; // 2
- uint32 racemask; // 3
- uint32 classmask; // 4
- //uint32 racemaskNot; // 5 always 0 in 2.4.2
- //uint32 classmaskNot; // 6 always 0 in 2.4.2
- uint32 req_skill_value; // 7 for trade skill.not for training.
- uint32 forward_spellid; // 8
- uint32 learnOnGetSkill; // 9 can be 1 or 2 for spells learned on get skill
- uint32 max_value; // 10
- uint32 min_value; // 11
- // 12-13, unknown, always 0
- uint32 reqtrainpoints; // 14
-};
-
-struct SoundEntriesEntry
-{
- uint32 Id; // 0, sound id
- //uint32 Type; // 1, sound type (10 generally for creature, etc)
- //char* InternalName; // 2, internal name, for use in lookup command for example
- //char* FileName[10]; // 3-12, file names
- //uint32 Unk13[10]; // 13-22, linked with file names?
- //char* Path; // 23
- // 24-28, unknown
-};
-
-struct SpellEntry
-{
- uint32 Id; // 0 normally counted from 0 field (but some tools start counting from 1, check this before tool use for data view!)
- uint32 Category; // 1
- //uint32 castUI // 2 not used
- uint32 Dispel; // 3
- uint32 Mechanic; // 4
- uint32 Attributes; // 5
- uint32 AttributesEx; // 6
- uint32 AttributesEx2; // 7
- uint32 AttributesEx3; // 8
- uint32 AttributesEx4; // 9
- uint32 AttributesEx5; // 10
- //uint32 AttributesEx6; // 11 not used
- uint32 Stances; // 12
- uint32 StancesNot; // 13
- uint32 Targets; // 14
- uint32 TargetCreatureType; // 15
- uint32 RequiresSpellFocus; // 16
- uint32 FacingCasterFlags; // 17
- uint32 CasterAuraState; // 18
- uint32 TargetAuraState; // 19
- uint32 CasterAuraStateNot; // 20
- uint32 TargetAuraStateNot; // 21
- uint32 CastingTimeIndex; // 22
- uint32 RecoveryTime; // 23
- uint32 CategoryRecoveryTime; // 24
- uint32 InterruptFlags; // 25
- uint32 AuraInterruptFlags; // 26
- uint32 ChannelInterruptFlags; // 27
- uint32 procFlags; // 28
- uint32 procChance; // 29
- uint32 procCharges; // 30
- uint32 maxLevel; // 31
- uint32 baseLevel; // 32
- uint32 spellLevel; // 33
- uint32 DurationIndex; // 34
- uint32 powerType; // 35
- uint32 manaCost; // 36
- uint32 manaCostPerlevel; // 37
- uint32 manaPerSecond; // 38
- uint32 manaPerSecondPerLevel; // 39
- uint32 rangeIndex; // 40
- float speed; // 41
- //uint32 modalNextSpell; // 42
- uint32 StackAmount; // 43
- uint32 Totem[2]; // 44-45
- int32 Reagent[8]; // 46-53
- uint32 ReagentCount[8]; // 54-61
- int32 EquippedItemClass; // 62 (value)
- int32 EquippedItemSubClassMask; // 63 (mask)
- int32 EquippedItemInventoryTypeMask; // 64 (mask)
- uint32 Effect[3]; // 65-67
- int32 EffectDieSides[3]; // 68-70
- uint32 EffectBaseDice[3]; // 71-73
- float EffectDicePerLevel[3]; // 74-76
- float EffectRealPointsPerLevel[3]; // 77-79
- int32 EffectBasePoints[3]; // 80-82 (don't must be used in spell/auras explicitly, must be used cached Spell::m_currentBasePoints)
- uint32 EffectMechanic[3]; // 83-85
- uint32 EffectImplicitTargetA[3]; // 86-88
- uint32 EffectImplicitTargetB[3]; // 89-91
- uint32 EffectRadiusIndex[3]; // 92-94 - spellradius.dbc
- uint32 EffectApplyAuraName[3]; // 95-97
- uint32 EffectAmplitude[3]; // 98-100
- float EffectMultipleValue[3]; // 101-103
- uint32 EffectChainTarget[3]; // 104-106
- uint32 EffectItemType[3]; // 107-109
- int32 EffectMiscValue[3]; // 110-112
- int32 EffectMiscValueB[3]; // 113-115
- uint32 EffectTriggerSpell[3]; // 116-118
- float EffectPointsPerComboPoint[3]; // 119-121
- uint32 SpellVisual; // 122
- // 123 not used
- uint32 SpellIconID; // 124
- uint32 activeIconID; // 125
- //uint32 spellPriority; // 126
- char* SpellName[16]; // 127-142
- //uint32 SpellNameFlag; // 143
- char* Rank[16]; // 144-159
- //uint32 RankFlags; // 160
- //char* Description[16]; // 161-176 not used
- //uint32 DescriptionFlags; // 177 not used
- //char* ToolTip[16]; // 178-193 not used
- //uint32 ToolTipFlags; // 194 not used
- uint32 ManaCostPercentage; // 195
- uint32 StartRecoveryCategory; // 196
- uint32 StartRecoveryTime; // 197
- uint32 MaxTargetLevel; // 198
- uint32 SpellFamilyName; // 199
- uint64 SpellFamilyFlags; // 200+201
- uint32 MaxAffectedTargets; // 202
- uint32 DmgClass; // 203 defenseType
- uint32 PreventionType; // 204
- //uint32 StanceBarOrder; // 205 not used
- float DmgMultiplier[3]; // 206-208
- //uint32 MinFactionId; // 209 not used, and 0 in 2.4.2
- //uint32 MinReputation; // 210 not used, and 0 in 2.4.2
- //uint32 RequiredAuraVision; // 211 not used
- uint32 TotemCategory[2]; // 212-213
- uint32 AreaId; // 214
- uint32 SchoolMask; // 215 school mask
-
- private:
- // prevent creating custom entries (copy data from original in fact)
- SpellEntry(SpellEntry const&); // DON'T must have implementation
-};
-
-typedef std::set<uint32> SpellCategorySet;
-typedef std::map<uint32,SpellCategorySet > SpellCategoryStore;
-typedef std::set<uint32> PetFamilySpellsSet;
-typedef std::map<uint32,PetFamilySpellsSet > PetFamilySpellsStore;
-
-struct SpellCastTimesEntry
-{
- uint32 ID; // 0
- int32 CastTime; // 1
- //float CastTimePerLevel; // 2 unsure / per skill?
- //int32 MinCastTime; // 3 unsure
-};
-
-struct SpellFocusObjectEntry
-{
- uint32 ID; // 0
- //char* Name[16]; // 1-15 unused
- // 16 string flags, unused
-};
-
-// stored in SQL table
-struct SpellThreatEntry
-{
- uint32 spellId;
- int32 threat;
-};
-
-struct SpellRadiusEntry
-{
- uint32 ID;
- float Radius;
- float Radius2;
-};
-
-struct SpellRangeEntry
-{
- uint32 ID;
- float minRange;
- float maxRange;
-};
-
-struct SpellShapeshiftEntry
-{
- uint32 ID; // 0
- //uint32 buttonPosition; // 1 unused
- //char* Name[16]; // 2-17 unused
- //uint32 NameFlags; // 18 unused
- uint32 flags1; // 19
- int32 creatureType; // 20 <=0 humanoid, other normal creature types
- //uint32 unk1; // 21 unused
- uint32 attackSpeed; // 22
- //uint32 modelID; // 23 unused, alliance modelid (where horde case?)
- //uint32 unk2; // 24 unused
- //uint32 unk3; // 25 unused
- //uint32 unk4; // 26 unused
- //uint32 unk5; // 27 unused
- //uint32 unk6; // 28 unused
- //uint32 unk7; // 29 unused
- //uint32 unk8; // 30 unused
- //uint32 unk9; // 31 unused
- //uint32 unk10; // 32 unused
- //uint32 unk11; // 33 unused
- //uint32 unk12; // 34 unused
-};
-
-struct SpellDurationEntry
-{
- uint32 ID;
- int32 Duration[3];
-};
-
-enum ItemEnchantmentType
-{
- ITEM_ENCHANTMENT_TYPE_NONE = 0,
- ITEM_ENCHANTMENT_TYPE_COMBAT_SPELL = 1,
- ITEM_ENCHANTMENT_TYPE_DAMAGE = 2,
- ITEM_ENCHANTMENT_TYPE_EQUIP_SPELL = 3,
- ITEM_ENCHANTMENT_TYPE_RESISTANCE = 4,
- ITEM_ENCHANTMENT_TYPE_STAT = 5,
- ITEM_ENCHANTMENT_TYPE_TOTEM = 6
-};
-
-struct SpellItemEnchantmentEntry
-{
- uint32 ID; // 0
- uint32 type[3]; // 1-3
- uint32 amount[3]; // 4-6
- //uint32 amount2[3] // 7-9 always same as similar `amount` value
- uint32 spellid[3]; // 10-12
- char* description[16]; // 13-29
- // 30 description flags
- uint32 aura_id; // 31
- uint32 slot; // 32
- uint32 GemID; // 33
- uint32 EnchantmentCondition; // 34
-};
-
-struct SpellItemEnchantmentConditionEntry
-{
- uint32 ID;
- uint8 Color[5];
- uint8 Comparator[5];
- uint8 CompareColor[5];
- uint32 Value[5];
-};
-
-struct StableSlotPricesEntry
-{
- uint32 Slot;
- uint32 Price;
-};
-
-struct TalentEntry
-{
- uint32 TalentID; // 0
- uint32 TalentTab; // 1 index in TalentTab.dbc (TalentTabEntry)
- uint32 Row; // 2
- uint32 Col; // 3
- uint32 RankID[5]; // 4-8
- // 9-12 not used, always 0, maybe not used high ranks
- uint32 DependsOn; // 13 index in Talent.dbc (TalentEntry)
- // 14-15 not used
- uint32 DependsOnRank; // 16
- // 17-19 not used
- uint32 DependsOnSpell; // 20 req.spell
-};
-
-struct TalentTabEntry
-{
- uint32 TalentTabID; // 0
- //char* name[16]; // 1-16, unused
- //uint32 nameFlags; // 17, unused
- //unit32 spellicon; // 18
- // 19 not used
- uint32 ClassMask; // 20
- uint32 tabpage; // 21
- //char* internalname; // 22
-};
-
-struct TaxiPathEntry
-{
- uint32 ID;
- uint32 from;
- uint32 to;
- uint32 price;
-};
-
-struct TaxiNodesEntry
-{
- uint32 ID; // 0
- uint32 map_id; // 1
- float x; // 2
- float y; // 3
- float z; // 4
- //char* name[16]; // 5-21
- // 22 string flags, unused
- uint32 horde_mount_type; // 23
- uint32 alliance_mount_type; // 24
-};
-
-enum TotemCategoryType
-{
- TOTEM_CATEGORY_TYPE_KNIFE = 1,
- TOTEM_CATEGORY_TYPE_TOTEM = 2,
- TOTEM_CATEGORY_TYPE_ROD = 3,
- TOTEM_CATEGORY_TYPE_PICK = 21,
- TOTEM_CATEGORY_TYPE_STONE = 22,
- TOTEM_CATEGORY_TYPE_HAMMER = 23,
- TOTEM_CATEGORY_TYPE_SPANNER = 24
-};
-
-struct TotemCategoryEntry
-{
- uint32 ID; // 0
- //char* name[16]; // 1-16
- // 17 string flags, unused
- uint32 categoryType; // 18 (one for specialization)
- uint32 categoryMask; // 19 (compatibility mask for same type: different for totems, compatible from high to low for rods)
-};
-
-struct WorldMapAreaEntry
-{
- //uint32 ID; // 0
- uint32 map_id; // 1
- uint32 area_id; // 2 index (continent 0 areas ignored)
- //char* internal_name // 3
- float y1; // 4
- float y2; // 5
- float x1; // 6
- float x2; // 7
- int32 virtual_map_id; // 8 -1 (map_id have correct map) other: virtual map where zone show (map_id - where zone in fact internally)
-};
-
-struct WorldSafeLocsEntry
-{
- uint32 ID; // 0
- uint32 map_id; // 1
- float x; // 2
- float y; // 3
- float z; // 4
- //char* name[16] // 5-20 name, unused
- // 21 name flags, unused
-};
-
-// GCC have alternative #pragma pack() syntax and old gcc version not support pack(pop), also any gcc version not support it at some platform
-#if defined( __GNUC__ )
-#pragma pack()
-#else
-#pragma pack(pop)
-#endif
-
-// Structures not used for casting to loaded DBC data and not required then packing
-struct TalentSpellPos
-{
- TalentSpellPos() : talent_id(0), rank(0) {}
- TalentSpellPos(uint16 _talent_id, uint8 _rank) : talent_id(_talent_id), rank(_rank) {}
-
- uint16 talent_id;
- uint8 rank;
-};
-
-typedef std::map<uint32,TalentSpellPos> TalentSpellPosMap;
-
-struct TaxiPathBySourceAndDestination
-{
- TaxiPathBySourceAndDestination() : ID(0),price(0) {}
- TaxiPathBySourceAndDestination(uint32 _id,uint32 _price) : ID(_id),price(_price) {}
-
- uint32 ID;
- uint32 price;
-};
-typedef std::map<uint32,TaxiPathBySourceAndDestination> TaxiPathSetForSource;
-typedef std::map<uint32,TaxiPathSetForSource> TaxiPathSetBySource;
-
-struct TaxiPathNode
-{
- TaxiPathNode() : mapid(0), x(0),y(0),z(0),actionFlag(0),delay(0) {}
- TaxiPathNode(uint32 _mapid, float _x, float _y, float _z, uint32 _actionFlag, uint32 _delay) : mapid(_mapid), x(_x),y(_y),z(_z),actionFlag(_actionFlag),delay(_delay) {}
-
- uint32 mapid;
- float x;
- float y;
- float z;
- uint32 actionFlag;
- uint32 delay;
-};
-typedef std::vector<TaxiPathNode> TaxiPathNodeList;
-typedef std::vector<TaxiPathNodeList> TaxiPathNodesByPath;
-
-#define TaxiMaskSize 16
-typedef uint32 TaxiMask[TaxiMaskSize];
-#endif
+/*
+ * Copyright (C) 2005-2008 MaNGOS <http://www.mangosproject.org/>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#ifndef DBCSTRUCTURE_H
+#define DBCSTRUCTURE_H
+
+#include "Platform/Define.h"
+
+#include <map>
+#include <set>
+#include <vector>
+
+// Structures using to access raw DBC data and required packing to portability
+
+// GCC have alternative #pragma pack(N) syntax and old gcc version not support pack(push,N), also any gcc version not support it at some platform
+#if defined( __GNUC__ )
+#pragma pack(1)
+#else
+#pragma pack(push,1)
+#endif
+
+enum AreaTeams
+{
+ AREATEAM_NONE = 0,
+ AREATEAM_ALLY = 2,
+ AREATEAM_HORDE = 4
+};
+
+enum AreaFlags
+{
+ AREA_FLAG_SNOW = 0x00000001, // snow (only Dun Morogh, Naxxramas, Razorfen Downs and Winterspring)
+ AREA_FLAG_UNK1 = 0x00000002, // unknown, (only Naxxramas and Razorfen Downs)
+ AREA_FLAG_UNK2 = 0x00000004, // Only used on development map
+ AREA_FLAG_SLAVE_CAPITAL = 0x00000008, // slave capital city flag?
+ AREA_FLAG_UNK3 = 0x00000010, // unknown
+ AREA_FLAG_SLAVE_CAPITAL2 = 0x00000020, // slave capital city flag?
+ AREA_FLAG_UNK4 = 0x00000040, // many zones have this flag
+ AREA_FLAG_ARENA = 0x00000080, // arena, both instanced and world arenas
+ AREA_FLAG_CAPITAL = 0x00000100, // main capital city flag
+ AREA_FLAG_CITY = 0x00000200, // only for one zone named "City" (where it located?)
+ AREA_FLAG_OUTLAND = 0x00000400, // outland zones? (only Eye of the Storm not have this flag, but have 0x00004000 flag)
+ AREA_FLAG_SANCTUARY = 0x00000800, // sanctuary area (PvP disabled)
+ AREA_FLAG_NEED_FLY = 0x00001000, // only Netherwing Ledge, Socrethar's Seat, Tempest Keep, The Arcatraz, The Botanica, The Mechanar, Sorrow Wing Point, Dragonspine Ridge, Netherwing Mines, Dragonmaw Base Camp, Dragonmaw Skyway
+ AREA_FLAG_UNUSED1 = 0x00002000, // not used now (no area/zones with this flag set in 2.4.2)
+ AREA_FLAG_OUTLAND2 = 0x00004000, // outland zones? (only Circle of Blood Arena not have this flag, but have 0x00000400 flag)
+ AREA_FLAG_PVP = 0x00008000, // pvp objective area? (Death's Door also has this flag although it's no pvp object area)
+ AREA_FLAG_ARENA_INSTANCE = 0x00010000, // used by instanced arenas only
+ AREA_FLAG_UNUSED2 = 0x00020000, // not used now (no area/zones with this flag set in 2.4.2)
+ AREA_FLAG_UNK5 = 0x00040000, // just used for Amani Pass, Hatchet Hills
+ AREA_FLAG_LOWLEVEL = 0x00100000 // used for some starting areas with area_level <=15
+};
+
+enum FactionTemplateFlags
+{
+ FACTION_TEMPLATE_FLAG_CONTESTED_GUARD = 0x00001000, // faction will attack players that were involved in PvP combats
+};
+
+struct AreaTableEntry
+{
+ uint32 ID; // 0
+ uint32 mapid; // 1
+ uint32 zone; // 2 if 0 then it's zone, else it's zone id of this area
+ uint32 exploreFlag; // 3, main index
+ uint32 flags; // 4, unknown value but 312 for all cities
+ // 5-9 unused
+ int32 area_level; // 10
+ char* area_name[16]; // 11-26
+ // 27, string flags, unused
+ uint32 team; // 28
+};
+
+struct AreaTriggerEntry
+{
+ uint32 id; // 0
+ uint32 mapid; // 1
+ float x; // 2
+ float y; // 3
+ float z; // 4
+ float radius; // 5
+ float box_x; // 6 extent x edge
+ float box_y; // 7 extent y edge
+ float box_z; // 8 extent z edge
+ float box_orientation; // 9 extent rotation by about z axis
+};
+
+struct BankBagSlotPricesEntry
+{
+ uint32 ID;
+ uint32 price;
+};
+
+struct BattlemasterListEntry
+{
+ uint32 id; // 0
+ uint32 mapid[3]; // 1-3 mapid
+ // 4-8 unused
+ uint32 type; // 9 (3 - BG, 4 - arena)
+ uint32 minlvl; // 10
+ uint32 maxlvl; // 11
+ uint32 maxplayersperteam; // 12
+ // 13-14 unused
+ char* name[16]; // 15-30
+ // 31 string flag, unused
+ // 32 unused
+};
+
+struct CharTitlesEntry
+{
+ uint32 ID; // 0, title ids, for example in Quest::GetCharTitleId()
+ //uint32 unk1; // 1 flags?
+ //char* name[16]; // 2-17, unused
+ // 18 string flag, unused
+ //char* name2[16]; // 19-34, unused
+ // 35 string flag, unused
+ uint32 bit_index; // 36 used in PLAYER_CHOSEN_TITLE and 1<<index in PLAYER__FIELD_KNOWN_TITLES
+};
+
+struct ChatChannelsEntry
+{
+ uint32 ChannelID; // 0
+ uint32 flags; // 1
+ char* pattern[16]; // 3-18
+ // 19 string flags, unused
+ //char* name[16]; // 20-35 unused
+ // 36 string flag, unused
+};
+
+struct ChrClassesEntry
+{
+ uint32 ClassID; // 0
+ // 1-2, unused
+ uint32 powerType; // 3
+ // 4, unused
+ //char* name[16]; // 5-20 unused
+ // 21 string flag, unused
+ //char* string1[16]; // 21-36 unused
+ // 37 string flag, unused
+ //char* string2[16]; // 38-53 unused
+ // 54 string flag, unused
+ // 55, unused
+ uint32 spellfamily; // 56
+ // 57, unused
+};
+
+struct ChrRacesEntry
+{
+ uint32 RaceID; // 0
+ // 1 unused
+ uint32 FactionID; // 2 facton template id
+ // 3 unused
+ uint32 model_m; // 4
+ uint32 model_f; // 5
+ // 6-7 unused
+ uint32 TeamID; // 8 (7-Alliance 1-Horde)
+ // 9-12 unused
+ uint32 startmovie; // 13 id from CinematicCamera.dbc
+ char* name[16]; // 14-29 used for DBC language detection/selection
+ // 30 string flags, unused
+ //char* string1[16]; // 31-46 used for DBC language detection/selection
+ // 47 string flags, unused
+ //char* string2[16]; // 48-63 used for DBC language detection/selection
+ // 64 string flags, unused
+ // 65-67 unused
+ //uint32 addon // 68 (0 - original race, 1 - tbc addon, ...) unused
+};
+
+struct CreatureDisplayInfoEntry
+{
+ uint32 Displayid; // 0
+ // 1-3,unused
+ float scale; // 4
+ // 5-13,unused
+};
+
+struct CreatureFamilyEntry
+{
+ uint32 ID; // 0
+ float minScale; // 1
+ uint32 minScaleLevel; // 2 0/1
+ float maxScale; // 3
+ uint32 maxScaleLevel; // 4 0/60
+ uint32 skillLine; // 5
+ uint32 skillLine2; // 6
+ uint32 petFoodMask; // 7
+ char* Name[16]; // 8-23
+ // 24 string flags, unused
+ // 25 icon, unused
+};
+
+struct CreatureSpellDataEntry
+{
+ uint32 ID; // 0
+ //uint32 spellId[4]; // 1-4 hunter pet learned spell (for later use)
+};
+
+struct DurabilityCostsEntry
+{
+ uint32 Itemlvl; // 0
+ uint32 multiplier[29]; // 1-29
+};
+
+struct DurabilityQualityEntry
+{
+ uint32 Id; // 0
+ float quality_mod; // 1
+};
+
+struct EmotesTextEntry
+{
+ uint32 Id;
+ uint32 textid;
+};
+
+struct FactionEntry
+{
+ uint32 ID; // 0
+ int32 reputationListID; // 1
+ uint32 BaseRepRaceMask[4]; // 2-5 Base reputation race masks (see enum Races)
+ uint32 BaseRepClassMask[4]; // 6-9 Base reputation class masks (see enum Classes)
+ int32 BaseRepValue[4]; // 10-13 Base reputation values
+ uint32 ReputationFlags[4]; // 14-17 Default flags to apply
+ uint32 team; // 18 enum Team
+ char* name[16]; // 19-34
+ // 35 string flags, unused
+ //char* description[16]; // 36-51 unused
+ // 52 string flags, unused
+};
+
+enum FactionMasks
+{
+ FACTION_MASK_PLAYER = 1, // any player
+ FACTION_MASK_ALLIANCE = 2, // player or creature from alliance team
+ FACTION_MASK_HORDE = 4, // player or creature from horde team
+ FACTION_MASK_MONSTER = 8 // aggressive creature from monster team
+ // if none flags set then non-aggressive creature
+};
+
+struct FactionTemplateEntry
+{
+ uint32 ID; // 0
+ uint32 faction; // 1
+ uint32 factionFlags; // 2 specific flags for that faction
+ uint32 ourMask; // 3 if mask set (see FactionMasks) then faction included in masked team
+ uint32 friendlyMask; // 4 if mask set (see FactionMasks) then faction friendly to masked team
+ uint32 hostileMask; // 5 if mask set (see FactionMasks) then faction hostile to masked team
+ uint32 enemyFaction1; // 6
+ uint32 enemyFaction2; // 7
+ uint32 enemyFaction3; // 8
+ uint32 enemyFaction4; // 9
+ uint32 friendFaction1; // 10
+ uint32 friendFaction2; // 11
+ uint32 friendFaction3; // 12
+ uint32 friendFaction4; // 13
+ //------------------------------------------------------- end structure
+
+ // helpers
+ bool IsFriendlyTo(FactionTemplateEntry const& entry) const
+ {
+ if(enemyFaction1 == entry.faction || enemyFaction2 == entry.faction || enemyFaction3 == entry.faction || enemyFaction4 == entry.faction )
+ return false;
+ if(friendFaction1 == entry.faction || friendFaction2 == entry.faction || friendFaction3 == entry.faction || friendFaction4 == entry.faction )
+ return true;
+ return (friendlyMask & entry.ourMask) || (ourMask & entry.friendlyMask);
+ }
+ bool IsHostileTo(FactionTemplateEntry const& entry) const
+ {
+ if(enemyFaction1 == entry.faction || enemyFaction2 == entry.faction || enemyFaction3 == entry.faction || enemyFaction4 == entry.faction )
+ return true;
+ if(friendFaction1 == entry.faction || friendFaction2 == entry.faction || friendFaction3 == entry.faction || friendFaction4 == entry.faction )
+ return false;
+ return (hostileMask & entry.ourMask) != 0;
+ }
+ bool IsHostileToPlayers() const { return (hostileMask & FACTION_MASK_PLAYER) !=0; }
+ bool IsNeutralToAll() const { return hostileMask == 0 && friendlyMask == 0 && enemyFaction1==0 && enemyFaction2==0 && enemyFaction3==0 && enemyFaction4==0; }
+ bool IsContestedGuardFaction() const { return (factionFlags & FACTION_TEMPLATE_FLAG_CONTESTED_GUARD)!=0; }
+};
+
+struct GemPropertiesEntry
+{
+ uint32 ID;
+ uint32 spellitemenchantement;
+ uint32 color;
+};
+
+#define GT_MAX_LEVEL 100
+struct GtCombatRatingsEntry
+{
+ float ratio;
+};
+
+struct GtChanceToMeleeCritBaseEntry
+{
+ float base;
+};
+
+struct GtChanceToMeleeCritEntry
+{
+ float ratio;
+};
+
+struct GtChanceToSpellCritBaseEntry
+{
+ float base;
+};
+
+struct GtChanceToSpellCritEntry
+{
+ float ratio;
+};
+
+struct GtOCTRegenHPEntry
+{
+ float ratio;
+};
+
+//struct GtOCTRegenMPEntry
+//{
+// float ratio;
+//};
+
+struct GtRegenHPPerSptEntry
+{
+ float ratio;
+};
+
+struct GtRegenMPPerSptEntry
+{
+ float ratio;
+};
+
+struct ItemEntry
+{
+ uint32 ID;
+ uint32 DisplayId;
+ uint32 InventoryType;
+ uint32 Sheath;
+};
+
+struct ItemDisplayInfoEntry
+{
+ uint32 ID;
+ uint32 randomPropertyChance;
+};
+
+//struct ItemCondExtCostsEntry
+//{
+// uint32 ID;
+// uint32 condExtendedCost; // ItemPrototype::CondExtendedCost
+// uint32 itemextendedcostentry; // ItemPrototype::ExtendedCost
+// uint32 arenaseason; // arena season number(1-4)
+//};
+
+struct ItemExtendedCostEntry
+{
+ uint32 ID; // 0 extended-cost entry id
+ uint32 reqhonorpoints; // 1 required honor points
+ uint32 reqarenapoints; // 2 required arena points
+ uint32 reqitem[5]; // 3-7 required item id
+ uint32 reqitemcount[5]; // 8-12 required count of 1st item
+ uint32 reqpersonalarenarating; // 13 required personal arena rating
+};
+
+struct ItemRandomPropertiesEntry
+{
+ uint32 ID; // 0
+ //char* internalName // 1 unused
+ uint32 enchant_id[3]; // 2-4
+ // 5-6 unused, 0 only values, reserved for additional enchantments?
+ //char* nameSuffix[16] // 7-22, unused
+ // 23 nameSufix flags, unused
+};
+
+struct ItemRandomSuffixEntry
+{
+ uint32 ID; // 0
+ //char* name[16] // 1-16 unused
+ // 17, name flags, unused
+ // 18 unused
+ uint32 enchant_id[3]; // 19-21
+ uint32 prefix[3]; // 22-24
+};
+
+struct ItemSetEntry
+{
+ //uint32 id // 0 item set ID
+ char* name[16]; // 1-16
+ // 17 string flags, unused
+ // 18-28 items from set, but not have all items listed, use ItemPrototype::ItemSet instead
+ // 29-34 unused
+ uint32 spells[8]; // 35-42
+ uint32 items_to_triggerspell[8]; // 43-50
+ uint32 required_skill_id; // 51
+ uint32 required_skill_value; // 52
+};
+
+struct LockEntry
+{
+ uint32 ID; // 0
+ uint32 keytype[5]; // 1-5
+ // 6-8, not used
+ uint32 key[5]; // 9-13
+ // 14-16, not used
+ uint32 requiredminingskill; // 17
+ uint32 requiredlockskill; // 18
+ // 19-32, not used
+};
+
+struct MailTemplateEntry
+{
+ uint32 ID; // 0
+ //char* subject[16]; // 1-16
+ // 17 name flags, unused
+ //char* content[16]; // 18-33
+};
+
+enum MapTypes
+{
+ MAP_COMMON = 0,
+ MAP_INSTANCE = 1,
+ MAP_RAID = 2,
+ MAP_BATTLEGROUND = 3,
+ MAP_ARENA = 4
+};
+
+struct MapEntry
+{
+ uint32 MapID; // 0
+ //char* internalname; // 1 unused
+ uint32 map_type; // 2
+ // 3 unused
+ char* name[16]; // 4-19
+ // 20 name flags, unused
+ // 21-23 unused (something PvPZone related - levels?)
+ // 24-26
+ uint32 linked_zone; // 27 common zone for instance and continent map
+ //char* hordeIntro // 28-43 text for PvP Zones
+ // 44 intro text flags
+ //char* allianceIntro // 45-60 text for PvP Zones
+ // 46 intro text flags
+ // 47-61 not used
+ uint32 multimap_id; // 62
+ // 63-65 not used
+ //chat* unknownText1 // 66-81 unknown empty text fields, possible normal Intro text.
+ // 82 text flags
+ //chat* heroicIntroText // 83-98 heroic mode requirement text
+ // 99 text flags
+ //chat* unknownText2 // 100-115 unknown empty text fields
+ // 116 text flags
+ int32 parent_map; // 117 map_id of parent map
+ //float start_x // 118 enter x coordinate (if exist single entry)
+ //float start_y // 119 enter y coordinate (if exist single entry)
+ uint32 resetTimeRaid; // 120
+ uint32 resetTimeHeroic; // 121
+ // 122-123
+ uint32 addon; // 124 (0-original maps,1-tbc addon)
+
+ // Helpers
+ bool IsExpansionMap() const { return addon != 0; }
+
+
+ bool IsDungeon() const { return map_type == MAP_INSTANCE || map_type == MAP_RAID; }
+ bool Instanceable() const { return map_type == MAP_INSTANCE || map_type == MAP_RAID || map_type == MAP_BATTLEGROUND || map_type == MAP_ARENA; }
+ bool IsRaid() const { return map_type == MAP_RAID; }
+ bool IsBattleGround() const { return map_type == MAP_BATTLEGROUND; }
+ bool IsBattleArena() const { return map_type == MAP_ARENA; }
+ bool IsBattleGroundOrArena() const { return map_type == MAP_BATTLEGROUND || map_type == MAP_ARENA; }
+ bool SupportsHeroicMode() const { return resetTimeHeroic && !resetTimeRaid; }
+ bool HasResetTime() const { return resetTimeHeroic || resetTimeRaid; }
+
+ bool IsMountAllowed() const
+ {
+ return !IsDungeon() ||
+ MapID==568 || MapID==309 || MapID==209 || MapID==534 ||
+ MapID==560 || MapID==509 || MapID==269;
+ }
+};
+
+struct QuestSortEntry
+{
+ uint32 id; // 0, sort id
+ //char* name[16]; // 1-16, unused
+ // 17 name flags, unused
+};
+
+struct RandomPropertiesPointsEntry
+{
+ //uint32 Id; // 0 hidden key
+ uint32 itemLevel; // 1
+ uint32 EpicPropertiesPoints[5]; // 2-6
+ uint32 RarePropertiesPoints[5]; // 7-11
+ uint32 UncommonPropertiesPoints[5]; // 12-16
+};
+
+//struct SkillLineCategoryEntry{
+// uint32 id; // 0 hidden key
+// char* name[16]; // 1 - 17 Category name
+// // 18 string flag
+// uint32 displayOrder; // Display order in character tab
+//};
+
+//struct SkillRaceClassInfoEntry{
+// uint32 id; // 0
+// uint32 skillId; // 1 present some refrences to unknown skill
+// uint32 raceMask; // 2
+// uint32 classMask; // 3
+// uint32 flags; // 4 mask for some thing
+// uint32 reqLevel; // 5
+// uint32 skillTierId; // 6
+// uint32 skillCostID; // 7
+//};
+
+//struct SkillTiersEntry{
+// uint32 id; // 0
+// uint32 skillValue[16]; // 1-17 unknown possibly add value on learn?
+// uint32 maxSkillValue[16]; // Max value for rank
+//};
+
+struct SkillLineEntry
+{
+ uint32 id; // 0
+ uint32 categoryId; // 1 (index from SkillLineCategory.dbc)
+ //uint32 skillCostID; // 2 not used
+ char* name[16]; // 3-18
+ // 19 string flags, not used
+ //char* description[16]; // 20-35, not used
+ // 36 string flags, not used
+ uint32 spellIcon; // 37
+};
+
+enum AbilytyLearnType
+{
+ ABILITY_LEARNED_ON_GET_PROFESSION_SKILL = 1,
+ ABILITY_LEARNED_ON_GET_RACE_OR_CLASS_SKILL = 2
+};
+
+struct SkillLineAbilityEntry
+{
+ uint32 id; // 0, INDEX
+ uint32 skillId; // 1
+ uint32 spellId; // 2
+ uint32 racemask; // 3
+ uint32 classmask; // 4
+ //uint32 racemaskNot; // 5 always 0 in 2.4.2
+ //uint32 classmaskNot; // 6 always 0 in 2.4.2
+ uint32 req_skill_value; // 7 for trade skill.not for training.
+ uint32 forward_spellid; // 8
+ uint32 learnOnGetSkill; // 9 can be 1 or 2 for spells learned on get skill
+ uint32 max_value; // 10
+ uint32 min_value; // 11
+ // 12-13, unknown, always 0
+ uint32 reqtrainpoints; // 14
+};
+
+struct SoundEntriesEntry
+{
+ uint32 Id; // 0, sound id
+ //uint32 Type; // 1, sound type (10 generally for creature, etc)
+ //char* InternalName; // 2, internal name, for use in lookup command for example
+ //char* FileName[10]; // 3-12, file names
+ //uint32 Unk13[10]; // 13-22, linked with file names?
+ //char* Path; // 23
+ // 24-28, unknown
+};
+
+struct SpellEntry
+{
+ uint32 Id; // 0 normally counted from 0 field (but some tools start counting from 1, check this before tool use for data view!)
+ uint32 Category; // 1
+ //uint32 castUI // 2 not used
+ uint32 Dispel; // 3
+ uint32 Mechanic; // 4
+ uint32 Attributes; // 5
+ uint32 AttributesEx; // 6
+ uint32 AttributesEx2; // 7
+ uint32 AttributesEx3; // 8
+ uint32 AttributesEx4; // 9
+ uint32 AttributesEx5; // 10
+ //uint32 AttributesEx6; // 11 not used
+ uint32 Stances; // 12
+ uint32 StancesNot; // 13
+ uint32 Targets; // 14
+ uint32 TargetCreatureType; // 15
+ uint32 RequiresSpellFocus; // 16
+ uint32 FacingCasterFlags; // 17
+ uint32 CasterAuraState; // 18
+ uint32 TargetAuraState; // 19
+ uint32 CasterAuraStateNot; // 20
+ uint32 TargetAuraStateNot; // 21
+ uint32 CastingTimeIndex; // 22
+ uint32 RecoveryTime; // 23
+ uint32 CategoryRecoveryTime; // 24
+ uint32 InterruptFlags; // 25
+ uint32 AuraInterruptFlags; // 26
+ uint32 ChannelInterruptFlags; // 27
+ uint32 procFlags; // 28
+ uint32 procChance; // 29
+ uint32 procCharges; // 30
+ uint32 maxLevel; // 31
+ uint32 baseLevel; // 32
+ uint32 spellLevel; // 33
+ uint32 DurationIndex; // 34
+ uint32 powerType; // 35
+ uint32 manaCost; // 36
+ uint32 manaCostPerlevel; // 37
+ uint32 manaPerSecond; // 38
+ uint32 manaPerSecondPerLevel; // 39
+ uint32 rangeIndex; // 40
+ float speed; // 41
+ //uint32 modalNextSpell; // 42
+ uint32 StackAmount; // 43
+ uint32 Totem[2]; // 44-45
+ int32 Reagent[8]; // 46-53
+ uint32 ReagentCount[8]; // 54-61
+ int32 EquippedItemClass; // 62 (value)
+ int32 EquippedItemSubClassMask; // 63 (mask)
+ int32 EquippedItemInventoryTypeMask; // 64 (mask)
+ uint32 Effect[3]; // 65-67
+ int32 EffectDieSides[3]; // 68-70
+ uint32 EffectBaseDice[3]; // 71-73
+ float EffectDicePerLevel[3]; // 74-76
+ float EffectRealPointsPerLevel[3]; // 77-79
+ int32 EffectBasePoints[3]; // 80-82 (don't must be used in spell/auras explicitly, must be used cached Spell::m_currentBasePoints)
+ uint32 EffectMechanic[3]; // 83-85
+ uint32 EffectImplicitTargetA[3]; // 86-88
+ uint32 EffectImplicitTargetB[3]; // 89-91
+ uint32 EffectRadiusIndex[3]; // 92-94 - spellradius.dbc
+ uint32 EffectApplyAuraName[3]; // 95-97
+ uint32 EffectAmplitude[3]; // 98-100
+ float EffectMultipleValue[3]; // 101-103
+ uint32 EffectChainTarget[3]; // 104-106
+ uint32 EffectItemType[3]; // 107-109
+ int32 EffectMiscValue[3]; // 110-112
+ int32 EffectMiscValueB[3]; // 113-115
+ uint32 EffectTriggerSpell[3]; // 116-118
+ float EffectPointsPerComboPoint[3]; // 119-121
+ uint32 SpellVisual; // 122
+ // 123 not used
+ uint32 SpellIconID; // 124
+ uint32 activeIconID; // 125
+ //uint32 spellPriority; // 126
+ char* SpellName[16]; // 127-142
+ //uint32 SpellNameFlag; // 143
+ char* Rank[16]; // 144-159
+ //uint32 RankFlags; // 160
+ //char* Description[16]; // 161-176 not used
+ //uint32 DescriptionFlags; // 177 not used
+ //char* ToolTip[16]; // 178-193 not used
+ //uint32 ToolTipFlags; // 194 not used
+ uint32 ManaCostPercentage; // 195
+ uint32 StartRecoveryCategory; // 196
+ uint32 StartRecoveryTime; // 197
+ uint32 MaxTargetLevel; // 198
+ uint32 SpellFamilyName; // 199
+ uint64 SpellFamilyFlags; // 200+201
+ uint32 MaxAffectedTargets; // 202
+ uint32 DmgClass; // 203 defenseType
+ uint32 PreventionType; // 204
+ //uint32 StanceBarOrder; // 205 not used
+ float DmgMultiplier[3]; // 206-208
+ //uint32 MinFactionId; // 209 not used, and 0 in 2.4.2
+ //uint32 MinReputation; // 210 not used, and 0 in 2.4.2
+ //uint32 RequiredAuraVision; // 211 not used
+ uint32 TotemCategory[2]; // 212-213
+ uint32 AreaId; // 214
+ uint32 SchoolMask; // 215 school mask
+
+ private:
+ // prevent creating custom entries (copy data from original in fact)
+ SpellEntry(SpellEntry const&); // DON'T must have implementation
+};
+
+typedef std::set<uint32> SpellCategorySet;
+typedef std::map<uint32,SpellCategorySet > SpellCategoryStore;
+typedef std::set<uint32> PetFamilySpellsSet;
+typedef std::map<uint32,PetFamilySpellsSet > PetFamilySpellsStore;
+
+struct SpellCastTimesEntry
+{
+ uint32 ID; // 0
+ int32 CastTime; // 1
+ //float CastTimePerLevel; // 2 unsure / per skill?
+ //int32 MinCastTime; // 3 unsure
+};
+
+struct SpellFocusObjectEntry
+{
+ uint32 ID; // 0
+ //char* Name[16]; // 1-15 unused
+ // 16 string flags, unused
+};
+
+// stored in SQL table
+struct SpellThreatEntry
+{
+ uint32 spellId;
+ int32 threat;
+};
+
+struct SpellRadiusEntry
+{
+ uint32 ID;
+ float Radius;
+ float Radius2;
+};
+
+struct SpellRangeEntry
+{
+ uint32 ID;
+ float minRange;
+ float maxRange;
+};
+
+struct SpellShapeshiftEntry
+{
+ uint32 ID; // 0
+ //uint32 buttonPosition; // 1 unused
+ //char* Name[16]; // 2-17 unused
+ //uint32 NameFlags; // 18 unused
+ uint32 flags1; // 19
+ int32 creatureType; // 20 <=0 humanoid, other normal creature types
+ //uint32 unk1; // 21 unused
+ uint32 attackSpeed; // 22
+ //uint32 modelID; // 23 unused, alliance modelid (where horde case?)
+ //uint32 unk2; // 24 unused
+ //uint32 unk3; // 25 unused
+ //uint32 unk4; // 26 unused
+ //uint32 unk5; // 27 unused
+ //uint32 unk6; // 28 unused
+ //uint32 unk7; // 29 unused
+ //uint32 unk8; // 30 unused
+ //uint32 unk9; // 31 unused
+ //uint32 unk10; // 32 unused
+ //uint32 unk11; // 33 unused
+ //uint32 unk12; // 34 unused
+};
+
+struct SpellDurationEntry
+{
+ uint32 ID;
+ int32 Duration[3];
+};
+
+enum ItemEnchantmentType
+{
+ ITEM_ENCHANTMENT_TYPE_NONE = 0,
+ ITEM_ENCHANTMENT_TYPE_COMBAT_SPELL = 1,
+ ITEM_ENCHANTMENT_TYPE_DAMAGE = 2,
+ ITEM_ENCHANTMENT_TYPE_EQUIP_SPELL = 3,
+ ITEM_ENCHANTMENT_TYPE_RESISTANCE = 4,
+ ITEM_ENCHANTMENT_TYPE_STAT = 5,
+ ITEM_ENCHANTMENT_TYPE_TOTEM = 6
+};
+
+struct SpellItemEnchantmentEntry
+{
+ uint32 ID; // 0
+ uint32 type[3]; // 1-3
+ uint32 amount[3]; // 4-6
+ //uint32 amount2[3] // 7-9 always same as similar `amount` value
+ uint32 spellid[3]; // 10-12
+ char* description[16]; // 13-29
+ // 30 description flags
+ uint32 aura_id; // 31
+ uint32 slot; // 32
+ uint32 GemID; // 33
+ uint32 EnchantmentCondition; // 34
+};
+
+struct SpellItemEnchantmentConditionEntry
+{
+ uint32 ID;
+ uint8 Color[5];
+ uint8 Comparator[5];
+ uint8 CompareColor[5];
+ uint32 Value[5];
+};
+
+struct StableSlotPricesEntry
+{
+ uint32 Slot;
+ uint32 Price;
+};
+
+struct TalentEntry
+{
+ uint32 TalentID; // 0
+ uint32 TalentTab; // 1 index in TalentTab.dbc (TalentTabEntry)
+ uint32 Row; // 2
+ uint32 Col; // 3
+ uint32 RankID[5]; // 4-8
+ // 9-12 not used, always 0, maybe not used high ranks
+ uint32 DependsOn; // 13 index in Talent.dbc (TalentEntry)
+ // 14-15 not used
+ uint32 DependsOnRank; // 16
+ // 17-19 not used
+ uint32 DependsOnSpell; // 20 req.spell
+};
+
+struct TalentTabEntry
+{
+ uint32 TalentTabID; // 0
+ //char* name[16]; // 1-16, unused
+ //uint32 nameFlags; // 17, unused
+ //unit32 spellicon; // 18
+ // 19 not used
+ uint32 ClassMask; // 20
+ uint32 tabpage; // 21
+ //char* internalname; // 22
+};
+
+struct TaxiPathEntry
+{
+ uint32 ID;
+ uint32 from;
+ uint32 to;
+ uint32 price;
+};
+
+struct TaxiNodesEntry
+{
+ uint32 ID; // 0
+ uint32 map_id; // 1
+ float x; // 2
+ float y; // 3
+ float z; // 4
+ //char* name[16]; // 5-21
+ // 22 string flags, unused
+ uint32 horde_mount_type; // 23
+ uint32 alliance_mount_type; // 24
+};
+
+enum TotemCategoryType
+{
+ TOTEM_CATEGORY_TYPE_KNIFE = 1,
+ TOTEM_CATEGORY_TYPE_TOTEM = 2,
+ TOTEM_CATEGORY_TYPE_ROD = 3,
+ TOTEM_CATEGORY_TYPE_PICK = 21,
+ TOTEM_CATEGORY_TYPE_STONE = 22,
+ TOTEM_CATEGORY_TYPE_HAMMER = 23,
+ TOTEM_CATEGORY_TYPE_SPANNER = 24
+};
+
+struct TotemCategoryEntry
+{
+ uint32 ID; // 0
+ //char* name[16]; // 1-16
+ // 17 string flags, unused
+ uint32 categoryType; // 18 (one for specialization)
+ uint32 categoryMask; // 19 (compatibility mask for same type: different for totems, compatible from high to low for rods)
+};
+
+struct WorldMapAreaEntry
+{
+ //uint32 ID; // 0
+ uint32 map_id; // 1
+ uint32 area_id; // 2 index (continent 0 areas ignored)
+ //char* internal_name // 3
+ float y1; // 4
+ float y2; // 5
+ float x1; // 6
+ float x2; // 7
+ int32 virtual_map_id; // 8 -1 (map_id have correct map) other: virtual map where zone show (map_id - where zone in fact internally)
+};
+
+struct WorldSafeLocsEntry
+{
+ uint32 ID; // 0
+ uint32 map_id; // 1
+ float x; // 2
+ float y; // 3
+ float z; // 4
+ //char* name[16] // 5-20 name, unused
+ // 21 name flags, unused
+};
+
+// GCC have alternative #pragma pack() syntax and old gcc version not support pack(pop), also any gcc version not support it at some platform
+#if defined( __GNUC__ )
+#pragma pack()
+#else
+#pragma pack(pop)
+#endif
+
+// Structures not used for casting to loaded DBC data and not required then packing
+struct TalentSpellPos
+{
+ TalentSpellPos() : talent_id(0), rank(0) {}
+ TalentSpellPos(uint16 _talent_id, uint8 _rank) : talent_id(_talent_id), rank(_rank) {}
+
+ uint16 talent_id;
+ uint8 rank;
+};
+
+typedef std::map<uint32,TalentSpellPos> TalentSpellPosMap;
+
+struct TaxiPathBySourceAndDestination
+{
+ TaxiPathBySourceAndDestination() : ID(0),price(0) {}
+ TaxiPathBySourceAndDestination(uint32 _id,uint32 _price) : ID(_id),price(_price) {}
+
+ uint32 ID;
+ uint32 price;
+};
+typedef std::map<uint32,TaxiPathBySourceAndDestination> TaxiPathSetForSource;
+typedef std::map<uint32,TaxiPathSetForSource> TaxiPathSetBySource;
+
+struct TaxiPathNode
+{
+ TaxiPathNode() : mapid(0), x(0),y(0),z(0),actionFlag(0),delay(0) {}
+ TaxiPathNode(uint32 _mapid, float _x, float _y, float _z, uint32 _actionFlag, uint32 _delay) : mapid(_mapid), x(_x),y(_y),z(_z),actionFlag(_actionFlag),delay(_delay) {}
+
+ uint32 mapid;
+ float x;
+ float y;
+ float z;
+ uint32 actionFlag;
+ uint32 delay;
+};
+typedef std::vector<TaxiPathNode> TaxiPathNodeList;
+typedef std::vector<TaxiPathNodeList> TaxiPathNodesByPath;
+
+#define TaxiMaskSize 16
+typedef uint32 TaxiMask[TaxiMaskSize];
+#endif
diff --git a/src/shared/Database/DBCfmt.cpp b/src/shared/Database/DBCfmt.cpp
index c7806e24690..e131d9379c5 100644
--- a/src/shared/Database/DBCfmt.cpp
+++ b/src/shared/Database/DBCfmt.cpp
@@ -1,78 +1,78 @@
-/*
- * Copyright (C) 2005-2008 MaNGOS <http://www.mangosproject.org/>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-const char AreaTableEntryfmt[]="iiinixxxxxissssssssssssssssxixxxxxx";
-const char AreaTriggerEntryfmt[]="niffffffff";
-const char BankBagSlotPricesEntryfmt[]="ni";
-const char BattlemasterListEntryfmt[]="niiixxxxxiiiixxssssssssssssssssxx";
-const char CharTitlesEntryfmt[]="nxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxi";
-const char ChatChannelsEntryfmt[]="iixssssssssssssssssxxxxxxxxxxxxxxxxxx";
- // ChatChannelsEntryfmt, index not used (more compact store)
-const char ChrClassesEntryfmt[]="nxixxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxix";
-const char ChrRacesEntryfmt[]="nxixiixxixxxxissssssssssssssssxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
-const char CreatureDisplayInfofmt[]="nxxxfxxxxxxxxx";
-const char CreatureFamilyfmt[]="nfifiiiissssssssssssssssxx";
-const char CreatureSpellDatafmt[]="nxxxxxxxx";
-const char DurabilityCostsfmt[]="niiiiiiiiiiiiiiiiiiiiiiiiiiiii";
-const char DurabilityQualityfmt[]="nf";
-const char EmoteEntryfmt[]="nxixxxxxxxxxxxxxxxx";
-const char FactionEntryfmt[]="niiiiiiiiiiiiiiiiiissssssssssssssssxxxxxxxxxxxxxxxxxx";
-const char FactionTemplateEntryfmt[]="niiiiiiiiiiiii";
-const char GemPropertiesEntryfmt[]="nixxi";
-const char GtCombatRatingsfmt[]="f";
-const char GtChanceToMeleeCritBasefmt[]="f";
-const char GtChanceToMeleeCritfmt[]="f";
-const char GtChanceToSpellCritBasefmt[]="f";
-const char GtChanceToSpellCritfmt[]="f";
-const char GtOCTRegenHPfmt[]="f";
-//const char GtOCTRegenMPfmt[]="f";
-const char GtRegenHPPerSptfmt[]="f";
-const char GtRegenMPPerSptfmt[]="f";
-const char Itemfmt[]="niii";
-//const char ItemDisplayTemplateEntryfmt[]="nxxxxxxxxxxixxxxxxxxxxx";
-//const char ItemCondExtCostsEntryfmt[]="xiii";
-const char ItemExtendedCostEntryfmt[]="niiiiiiiiiiiii";
-const char ItemRandomPropertiesfmt[]="nxiiixxxxxxxxxxxxxxxxxxx";
-const char ItemRandomSuffixfmt[]="nxxxxxxxxxxxxxxxxxxiiiiii";
-const char ItemSetEntryfmt[]="dssssssssssssssssxxxxxxxxxxxxxxxxxxiiiiiiiiiiiiiiiiii";
-const char LockEntryfmt[]="niiiiixxxiiiiixxxiixxxxxxxxxxxxxx";
-const char MailTemplateEntryfmt[]="nxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
-const char MapEntryfmt[]="nxixssssssssssssssssxxxxxxxixxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxixxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxixxiixxi";
-const char QuestSortEntryfmt[]="nxxxxxxxxxxxxxxxxx";
-const char RandomPropertiesPointsfmt[]="niiiiiiiiiiiiiii";
-const char SkillLinefmt[]="nixssssssssssssssssxxxxxxxxxxxxxxxxxxi";
-const char SkillLineAbilityfmt[]="niiiixxiiiiixxi";
-const char SoundEntriesfmt[]="nxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
-const char SpellCastTimefmt[]="nixx";
-const char SpellDurationfmt[]="niii";
-const char SpellEntryfmt[]="nixiiiiiiiixiiiiiiiiiiiiiiiiiiiiiiiiiiiiifxiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiffffffiiiiiiiiiiiiiiiiiiiiifffiiiiiiiiiiiiiiifffixiixssssssssssssssssxssssssssssssssssxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxiiiiiiiiiixfffxxxiiii";
-const char SpellFocusObjectfmt[]="nxxxxxxxxxxxxxxxxx";
-const char SpellItemEnchantmentfmt[]="niiiiiixxxiiissssssssssssssssxiiii";
-const char SpellItemEnchantmentConditionfmt[]="nbbbbbxxxxxbbbbbbbbbbiiiiiXXXXX";
-const char SpellRadiusfmt[]="nfxf";
-const char SpellRangefmt[]="nffxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
-const char SpellShapeshiftfmt[]="nxxxxxxxxxxxxxxxxxxiixixxxxxxxxxxxx";
-const char StableSlotPricesfmt[] = "ni";
-const char TalentEntryfmt[]="niiiiiiiixxxxixxixxxi";
-const char TalentTabEntryfmt[]="nxxxxxxxxxxxxxxxxxxxiix";
-const char TaxiNodesEntryfmt[]="nifffxxxxxxxxxxxxxxxxxii";
-const char TaxiPathEntryfmt[]="niii";
-const char TaxiPathNodeEntryfmt[]="diiifffiixx";
-const char TotemCategoryEntryfmt[]="nxxxxxxxxxxxxxxxxxii";
-const char WorldMapAreaEntryfmt[]="xinxffffi";
-const char WorldSafeLocsEntryfmt[]="nifffxxxxxxxxxxxxxxxxx";
+/*
+ * Copyright (C) 2005-2008 MaNGOS <http://www.mangosproject.org/>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+const char AreaTableEntryfmt[]="iiinixxxxxissssssssssssssssxixxxxxx";
+const char AreaTriggerEntryfmt[]="niffffffff";
+const char BankBagSlotPricesEntryfmt[]="ni";
+const char BattlemasterListEntryfmt[]="niiixxxxxiiiixxssssssssssssssssxx";
+const char CharTitlesEntryfmt[]="nxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxi";
+const char ChatChannelsEntryfmt[]="iixssssssssssssssssxxxxxxxxxxxxxxxxxx";
+ // ChatChannelsEntryfmt, index not used (more compact store)
+const char ChrClassesEntryfmt[]="nxixxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxix";
+const char ChrRacesEntryfmt[]="nxixiixxixxxxissssssssssssssssxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
+const char CreatureDisplayInfofmt[]="nxxxfxxxxxxxxx";
+const char CreatureFamilyfmt[]="nfifiiiissssssssssssssssxx";
+const char CreatureSpellDatafmt[]="nxxxxxxxx";
+const char DurabilityCostsfmt[]="niiiiiiiiiiiiiiiiiiiiiiiiiiiii";
+const char DurabilityQualityfmt[]="nf";
+const char EmoteEntryfmt[]="nxixxxxxxxxxxxxxxxx";
+const char FactionEntryfmt[]="niiiiiiiiiiiiiiiiiissssssssssssssssxxxxxxxxxxxxxxxxxx";
+const char FactionTemplateEntryfmt[]="niiiiiiiiiiiii";
+const char GemPropertiesEntryfmt[]="nixxi";
+const char GtCombatRatingsfmt[]="f";
+const char GtChanceToMeleeCritBasefmt[]="f";
+const char GtChanceToMeleeCritfmt[]="f";
+const char GtChanceToSpellCritBasefmt[]="f";
+const char GtChanceToSpellCritfmt[]="f";
+const char GtOCTRegenHPfmt[]="f";
+//const char GtOCTRegenMPfmt[]="f";
+const char GtRegenHPPerSptfmt[]="f";
+const char GtRegenMPPerSptfmt[]="f";
+const char Itemfmt[]="niii";
+//const char ItemDisplayTemplateEntryfmt[]="nxxxxxxxxxxixxxxxxxxxxx";
+//const char ItemCondExtCostsEntryfmt[]="xiii";
+const char ItemExtendedCostEntryfmt[]="niiiiiiiiiiiii";
+const char ItemRandomPropertiesfmt[]="nxiiixxxxxxxxxxxxxxxxxxx";
+const char ItemRandomSuffixfmt[]="nxxxxxxxxxxxxxxxxxxiiiiii";
+const char ItemSetEntryfmt[]="dssssssssssssssssxxxxxxxxxxxxxxxxxxiiiiiiiiiiiiiiiiii";
+const char LockEntryfmt[]="niiiiixxxiiiiixxxiixxxxxxxxxxxxxx";
+const char MailTemplateEntryfmt[]="nxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
+const char MapEntryfmt[]="nxixssssssssssssssssxxxxxxxixxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxixxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxixxiixxi";
+const char QuestSortEntryfmt[]="nxxxxxxxxxxxxxxxxx";
+const char RandomPropertiesPointsfmt[]="niiiiiiiiiiiiiii";
+const char SkillLinefmt[]="nixssssssssssssssssxxxxxxxxxxxxxxxxxxi";
+const char SkillLineAbilityfmt[]="niiiixxiiiiixxi";
+const char SoundEntriesfmt[]="nxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
+const char SpellCastTimefmt[]="nixx";
+const char SpellDurationfmt[]="niii";
+const char SpellEntryfmt[]="nixiiiiiiiixiiiiiiiiiiiiiiiiiiiiiiiiiiiiifxiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiffffffiiiiiiiiiiiiiiiiiiiiifffiiiiiiiiiiiiiiifffixiixssssssssssssssssxssssssssssssssssxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxiiiiiiiiiixfffxxxiiii";
+const char SpellFocusObjectfmt[]="nxxxxxxxxxxxxxxxxx";
+const char SpellItemEnchantmentfmt[]="niiiiiixxxiiissssssssssssssssxiiii";
+const char SpellItemEnchantmentConditionfmt[]="nbbbbbxxxxxbbbbbbbbbbiiiiiXXXXX";
+const char SpellRadiusfmt[]="nfxf";
+const char SpellRangefmt[]="nffxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
+const char SpellShapeshiftfmt[]="nxxxxxxxxxxxxxxxxxxiixixxxxxxxxxxxx";
+const char StableSlotPricesfmt[] = "ni";
+const char TalentEntryfmt[]="niiiiiiiixxxxixxixxxi";
+const char TalentTabEntryfmt[]="nxxxxxxxxxxxxxxxxxxxiix";
+const char TaxiNodesEntryfmt[]="nifffxxxxxxxxxxxxxxxxxii";
+const char TaxiPathEntryfmt[]="niii";
+const char TaxiPathNodeEntryfmt[]="diiifffiixx";
+const char TotemCategoryEntryfmt[]="nxxxxxxxxxxxxxxxxxii";
+const char WorldMapAreaEntryfmt[]="xinxffffi";
+const char WorldSafeLocsEntryfmt[]="nifffxxxxxxxxxxxxxxxxx";
diff --git a/src/shared/Database/DatabaseEnv.h b/src/shared/Database/DatabaseEnv.h
index d3210458dbb..405dcbdfa33 100644
--- a/src/shared/Database/DatabaseEnv.h
+++ b/src/shared/Database/DatabaseEnv.h
@@ -1,54 +1,54 @@
-/*
- * Copyright (C) 2005-2008 MaNGOS <http://www.mangosproject.org/>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#if !defined(DATABASEENV_H)
-#define DATABASEENV_H
-
-#include "Common.h"
-#include "Log.h"
-#include "Errors.h"
-
-#include "Database/DBCStores.h"
-#include "Database/Field.h"
-#include "Database/QueryResult.h"
-
-#ifdef DO_POSTGRESQL
-#include "Database/QueryResultPostgre.h"
-#include "Database/Database.h"
-#include "Database/DatabasePostgre.h"
-typedef DatabasePostgre DatabaseType;
-#define _LIKE_ "ILIKE"
-#define _TABLE_SIM_ "\""
-#define _CONCAT3_(A,B,C) "( " A " || " B " || " C " )"
-#else
-#include "Database/QueryResultMysql.h"
-#include "Database/QueryResultSqlite.h"
-#include "Database/Database.h"
-#include "Database/DatabaseMysql.h"
-#include "Database/DatabaseSqlite.h"
-typedef DatabaseMysql DatabaseType;
-#define _LIKE_ "LIKE"
-#define _TABLE_SIM_ "`"
-#define _CONCAT3_(A,B,C) "CONCAT( " A " , " B " , " C " )"
-#endif
-
-extern DatabaseType WorldDatabase;
-extern DatabaseType CharacterDatabase;
-extern DatabaseType loginDatabase;
-
-#endif
+/*
+ * Copyright (C) 2005-2008 MaNGOS <http://www.mangosproject.org/>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#if !defined(DATABASEENV_H)
+#define DATABASEENV_H
+
+#include "Common.h"
+#include "Log.h"
+#include "Errors.h"
+
+#include "Database/DBCStores.h"
+#include "Database/Field.h"
+#include "Database/QueryResult.h"
+
+#ifdef DO_POSTGRESQL
+#include "Database/QueryResultPostgre.h"
+#include "Database/Database.h"
+#include "Database/DatabasePostgre.h"
+typedef DatabasePostgre DatabaseType;
+#define _LIKE_ "ILIKE"
+#define _TABLE_SIM_ "\""
+#define _CONCAT3_(A,B,C) "( " A " || " B " || " C " )"
+#else
+#include "Database/QueryResultMysql.h"
+#include "Database/QueryResultSqlite.h"
+#include "Database/Database.h"
+#include "Database/DatabaseMysql.h"
+#include "Database/DatabaseSqlite.h"
+typedef DatabaseMysql DatabaseType;
+#define _LIKE_ "LIKE"
+#define _TABLE_SIM_ "`"
+#define _CONCAT3_(A,B,C) "CONCAT( " A " , " B " , " C " )"
+#endif
+
+extern DatabaseType WorldDatabase;
+extern DatabaseType CharacterDatabase;
+extern DatabaseType loginDatabase;
+
+#endif
diff --git a/src/shared/WheatyExceptionReport.cpp b/src/shared/WheatyExceptionReport.cpp
index 27fae70e4c1..41d2a5e2727 100644
--- a/src/shared/WheatyExceptionReport.cpp
+++ b/src/shared/WheatyExceptionReport.cpp
@@ -1,1014 +1,1014 @@
-//==========================================
-// Matt Pietrek
-// MSDN Magazine, 2002
-// FILE: WheatyExceptionReport.CPP
-//==========================================
-#define WIN32_LEAN_AND_MEAN
-#pragma warning(disable:4996)
-#pragma warning(disable:4312)
-#pragma warning(disable:4311)
-#include <windows.h>
-#include <tlhelp32.h>
-#include <stdio.h>
-#include <tchar.h>
-#define _NO_CVCONST_H
-#include <dbghelp.h>
-#include "WheatyExceptionReport.h"
-#include "svn_revision.h"
-#define CrashFolder _T("Crashs")
-//#pragma comment(linker, "/defaultlib:dbghelp.lib")
-
-inline LPTSTR ErrorMessage(DWORD dw)
-{
- LPVOID lpMsgBuf;
- FormatMessage(
- FORMAT_MESSAGE_ALLOCATE_BUFFER |
- FORMAT_MESSAGE_FROM_SYSTEM,
- NULL,
- dw,
- MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
- (LPTSTR) &lpMsgBuf,
- 0, NULL );
- return (LPTSTR)lpMsgBuf;
-}
-
-//============================== Global Variables =============================
-
-//
-// Declare the static variables of the WheatyExceptionReport class
-//
-TCHAR WheatyExceptionReport::m_szLogFileName[MAX_PATH];
-LPTOP_LEVEL_EXCEPTION_FILTER WheatyExceptionReport::m_previousFilter;
-HANDLE WheatyExceptionReport::m_hReportFile;
-HANDLE WheatyExceptionReport::m_hProcess;
-
-// Declare global instance of class
-WheatyExceptionReport g_WheatyExceptionReport;
-
-//============================== Class Methods =============================
-
-WheatyExceptionReport::WheatyExceptionReport( ) // Constructor
-{
- // Install the unhandled exception filter function
- m_previousFilter = SetUnhandledExceptionFilter(WheatyUnhandledExceptionFilter);
- m_hProcess = GetCurrentProcess();
-}
-
-//============
-// Destructor
-//============
-WheatyExceptionReport::~WheatyExceptionReport( )
-{
- if(m_previousFilter)
- SetUnhandledExceptionFilter( m_previousFilter );
-}
-
-//===========================================================
-// Entry point where control comes on an unhandled exception
-//===========================================================
-LONG WINAPI WheatyExceptionReport::WheatyUnhandledExceptionFilter(
-PEXCEPTION_POINTERS pExceptionInfo )
-{
- TCHAR module_folder_name[MAX_PATH];
- GetModuleFileName( 0, module_folder_name, MAX_PATH );
- TCHAR* pos = _tcsrchr(module_folder_name, '\\');
- if(!pos)
- return 0;
- pos[0] = '\0';
- ++pos;
-
- TCHAR crash_folder_path[MAX_PATH];
- sprintf(crash_folder_path, "%s\\%s", module_folder_name, CrashFolder);
- if(!CreateDirectory(crash_folder_path, NULL))
- {
- if(GetLastError() != ERROR_ALREADY_EXISTS)
- return 0;
- }
-
- SYSTEMTIME systime;
- GetLocalTime(&systime);
- sprintf(m_szLogFileName, "%s\\%s_[%u-%u_%u-%u-%u].txt",
- crash_folder_path, pos, systime.wDay, systime.wMonth, systime.wHour, systime.wMinute, systime.wSecond
- );
-
- m_hReportFile = CreateFile( m_szLogFileName,
- GENERIC_WRITE,
- 0,
- 0,
- OPEN_ALWAYS,
- FILE_FLAG_WRITE_THROUGH,
- 0 );
-
- if ( m_hReportFile )
- {
- SetFilePointer( m_hReportFile, 0, 0, FILE_END );
-
- GenerateExceptionReport( pExceptionInfo );
-
- CloseHandle( m_hReportFile );
- m_hReportFile = 0;
- }
-
- if ( m_previousFilter )
- return m_previousFilter( pExceptionInfo );
- else
- return EXCEPTION_EXECUTE_HANDLER/*EXCEPTION_CONTINUE_SEARCH*/;
-}
-
-BOOL WheatyExceptionReport::_GetProcessorName(TCHAR* sProcessorName, DWORD maxcount)
-{
- if(!sProcessorName)
- return FALSE;
-
- HKEY hKey;
- LONG lRet;
- lRet = ::RegOpenKeyEx(HKEY_LOCAL_MACHINE, _T("HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0"),
- 0, KEY_QUERY_VALUE, &hKey);
- if (lRet != ERROR_SUCCESS)
- return FALSE;
- TCHAR szTmp[2048];
- DWORD cntBytes = sizeof(szTmp);
- lRet = ::RegQueryValueEx(hKey, _T("ProcessorNameString"), NULL, NULL,
- (LPBYTE)szTmp, &cntBytes);
- if (lRet != ERROR_SUCCESS)
- return FALSE;
- ::RegCloseKey(hKey);
- sProcessorName[0] = '\0';
- // Skip spaces
- TCHAR* psz = szTmp;
- while (iswspace(*psz))
- ++psz;
- _tcsncpy(sProcessorName, psz, maxcount);
- return TRUE;
-}
-
-BOOL WheatyExceptionReport::_GetWindowsVersion(TCHAR* szVersion, DWORD cntMax)
-{
- // Try calling GetVersionEx using the OSVERSIONINFOEX structure.
- // If that fails, try using the OSVERSIONINFO structure.
- OSVERSIONINFOEX osvi = { 0 };
- osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);
- BOOL bOsVersionInfoEx;
- bOsVersionInfoEx = ::GetVersionEx((LPOSVERSIONINFO)(&osvi));
- if (!bOsVersionInfoEx)
- {
- osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
- if (!::GetVersionEx((OSVERSIONINFO*)&osvi))
- return FALSE;
- }
- *szVersion = _T('\0');
- TCHAR wszTmp[128];
- switch (osvi.dwPlatformId)
- {
- // Windows NT product family.
- case VER_PLATFORM_WIN32_NT:
- // Test for the specific product family.
- if (osvi.dwMajorVersion == 6)
- _tcsncat(szVersion, _T("Windows Vista or Windows Server 2008 "), cntMax);
- if (osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 2)
- _tcsncat(szVersion, _T("Microsoft Windows Server 2003 "), cntMax);
- if (osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 1)
- _tcsncat(szVersion, _T("Microsoft Windows XP "), cntMax);
- if (osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 0)
- _tcsncat(szVersion, _T("Microsoft Windows 2000 "), cntMax);
- if (osvi.dwMajorVersion <= 4 )
- _tcsncat(szVersion, _T("Microsoft Windows NT "), cntMax);
-
- // Test for specific product on Windows NT 4.0 SP6 and later.
- if (bOsVersionInfoEx)
- {
- // Test for the workstation type.
- #if WINVER < 0x0500
- if (osvi.wReserved[1] == VER_NT_WORKSTATION)
- #else
- if (osvi.wProductType == VER_NT_WORKSTATION)
- #endif // WINVER < 0x0500
- {
- if (osvi.dwMajorVersion == 4)
- _tcsncat(szVersion, _T("Workstation 4.0 "), cntMax);
- #if WINVER < 0x0500
- else if (osvi.wReserved[0] & VER_SUITE_PERSONAL)
- #else
- else if (osvi.wSuiteMask & VER_SUITE_PERSONAL)
- #endif // WINVER < 0x0500
- _tcsncat(szVersion, _T("Home Edition "), cntMax);
- #if WINVER < 0x0500
- else if (osvi.wReserved[0] & VER_SUITE_EMBEDDEDNT)
- #else
- else if (osvi.wSuiteMask & VER_SUITE_EMBEDDEDNT)
- #endif // WINVER < 0x0500
- _tcsncat(szVersion, _T("Embedded "), cntMax);
- else
- _tcsncat(szVersion, _T("Professional "), cntMax);
- }
- // Test for the server type.
- #if WINVER < 0x0500
- else if (osvi.wReserved[1] == VER_NT_SERVER)
- #else
- else if (osvi.wProductType == VER_NT_SERVER)
- #endif // WINVER < 0x0500
- {
- if (osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 2)
- {
- #if WINVER < 0x0500
- if (osvi.wReserved[0] & VER_SUITE_DATACENTER)
- #else
- if (osvi.wSuiteMask & VER_SUITE_DATACENTER)
- #endif // WINVER < 0x0500
- _tcsncat(szVersion, _T("Datacenter Edition "), cntMax);
- #if WINVER < 0x0500
- else if (osvi.wReserved[0] & VER_SUITE_ENTERPRISE)
- #else
- else if (osvi.wSuiteMask & VER_SUITE_ENTERPRISE)
- #endif // WINVER < 0x0500
- _tcsncat(szVersion, _T("Enterprise Edition "), cntMax);
- #if WINVER < 0x0500
- else if (osvi.wReserved[0] == VER_SUITE_BLADE)
- #else
- else if (osvi.wSuiteMask == VER_SUITE_BLADE)
- #endif // WINVER < 0x0500
- _tcsncat(szVersion, _T("Web Edition "), cntMax);
- else
- _tcsncat(szVersion, _T("Standard Edition "), cntMax);
- }
- else if (osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 0)
- {
- #if WINVER < 0x0500
- if (osvi.wReserved[0] & VER_SUITE_DATACENTER)
- #else
- if (osvi.wSuiteMask & VER_SUITE_DATACENTER)
- #endif // WINVER < 0x0500
- _tcsncat(szVersion, _T("Datacenter Server "), cntMax);
- #if WINVER < 0x0500
- else if (osvi.wReserved[0] & VER_SUITE_ENTERPRISE )
- #else
- else if (osvi.wSuiteMask & VER_SUITE_ENTERPRISE )
- #endif // WINVER < 0x0500
- _tcsncat(szVersion, _T("Advanced Server "), cntMax);
- else
- _tcsncat(szVersion, _T("Server "), cntMax);
- }
- else // Windows NT 4.0
- {
- #if WINVER < 0x0500
- if (osvi.wReserved[0] & VER_SUITE_ENTERPRISE)
- #else
- if (osvi.wSuiteMask & VER_SUITE_ENTERPRISE)
- #endif // WINVER < 0x0500
- _tcsncat(szVersion, _T("Server 4.0, Enterprise Edition "), cntMax);
- else
- _tcsncat(szVersion, _T("Server 4.0 "), cntMax);
- }
- }
- }
- // Display service pack (if any) and build number.
- if (osvi.dwMajorVersion == 4 && _tcsicmp(osvi.szCSDVersion, _T("Service Pack 6")) == 0)
- {
- HKEY hKey;
- LONG lRet;
-
- // Test for SP6 versus SP6a.
- lRet = ::RegOpenKeyEx(HKEY_LOCAL_MACHINE, _T("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Hotfix\\Q246009"), 0, KEY_QUERY_VALUE, &hKey);
- if (lRet == ERROR_SUCCESS)
- {
- _stprintf(wszTmp, _T("Service Pack 6a (Version %d.%d, Build %d)"),
- osvi.dwMajorVersion, osvi.dwMinorVersion, osvi.dwBuildNumber & 0xFFFF);
- _tcsncat(szVersion, wszTmp, cntMax);
- }
- else // Windows NT 4.0 prior to SP6a
- {
- _stprintf(wszTmp, _T("%s (Version %d.%d, Build %d)"),
- osvi.szCSDVersion, osvi.dwMajorVersion, osvi.dwMinorVersion, osvi.dwBuildNumber & 0xFFFF);
- _tcsncat(szVersion, wszTmp, cntMax);
- }
- ::RegCloseKey(hKey);
- }
- else // Windows NT 3.51 and earlier or Windows 2000 and later
- {
- if (!_tcslen(osvi.szCSDVersion))
- _stprintf(wszTmp, _T("(Version %d.%d, Build %d)"),
- osvi.dwMajorVersion, osvi.dwMinorVersion, osvi.dwBuildNumber & 0xFFFF);
- else
- _stprintf(wszTmp, _T("%s (Version %d.%d, Build %d)"),
- osvi.szCSDVersion, osvi.dwMajorVersion, osvi.dwMinorVersion, osvi.dwBuildNumber & 0xFFFF);
- _tcsncat(szVersion, wszTmp, cntMax);
- }
- break;
- default:
- _stprintf(wszTmp, _T("%s (Version %d.%d, Build %d)"),
- osvi.szCSDVersion, osvi.dwMajorVersion, osvi.dwMinorVersion, osvi.dwBuildNumber & 0xFFFF);
- _tcsncat(szVersion, wszTmp, cntMax);
- break;
- }
-
- return TRUE;
-}
-
-void WheatyExceptionReport::PrintSystemInfo()
-{
- SYSTEM_INFO SystemInfo;
- ::GetSystemInfo(&SystemInfo);
-
- MEMORYSTATUS MemoryStatus;
- MemoryStatus.dwLength = sizeof (MEMORYSTATUS);
- ::GlobalMemoryStatus(&MemoryStatus);
- TCHAR sString[1024];
- _tprintf(_T("//=====================================================\r\n"));
- if (_GetProcessorName(sString, countof(sString)))
- _tprintf(_T("*** Hardware ***\r\nProcessor: %s\r\nNumber Of Processors: %d\r\nPhysical Memory: %d KB (Available: %d KB)\r\nCommit Charge Limit: %d KB\r\n"),
- sString, SystemInfo.dwNumberOfProcessors, MemoryStatus.dwTotalPhys/0x400, MemoryStatus.dwAvailPhys/0x400, MemoryStatus.dwTotalPageFile/0x400);
- else
- _tprintf(_T("*** Hardware ***\r\nProcessor: <unknown>\r\nNumber Of Processors: %d\r\nPhysical Memory: %d KB (Available: %d KB)\r\nCommit Charge Limit: %d KB\r\n"),
- SystemInfo.dwNumberOfProcessors, MemoryStatus.dwTotalPhys/0x400, MemoryStatus.dwAvailPhys/0x400, MemoryStatus.dwTotalPageFile/0x400);
-
- if(_GetWindowsVersion(sString, countof(sString)))
- _tprintf(_T("\r\n*** Operation System ***\r\n%s\r\n"), sString);
- else
- _tprintf(_T("\r\n*** Operation System:\r\n<unknown>\r\n"));
-}
-
-//===========================================================================
-void WheatyExceptionReport::printTracesForAllThreads()
-{
- HANDLE hThreadSnap = INVALID_HANDLE_VALUE;
- THREADENTRY32 te32;
-
- DWORD dwOwnerPID = GetCurrentProcessId();
- m_hProcess = GetCurrentProcess();
- // Take a snapshot of all running threads
- hThreadSnap = CreateToolhelp32Snapshot( TH32CS_SNAPTHREAD, 0 );
- if( hThreadSnap == INVALID_HANDLE_VALUE )
- return;
-
- // Fill in the size of the structure before using it.
- te32.dwSize = sizeof(THREADENTRY32 );
-
- // Retrieve information about the first thread,
- // and exit if unsuccessful
- if( !Thread32First( hThreadSnap, &te32 ) )
- {
- CloseHandle( hThreadSnap ); // Must clean up the
- // snapshot object!
- return;
- }
-
- // Now walk the thread list of the system,
- // and display information about each thread
- // associated with the specified process
- do
- {
- if( te32.th32OwnerProcessID == dwOwnerPID )
- {
- CONTEXT context;
- context.ContextFlags = 0xffffffff;
- HANDLE threadHandle = OpenThread(THREAD_GET_CONTEXT | THREAD_QUERY_INFORMATION,false, te32.th32ThreadID);
- if(threadHandle && GetThreadContext(threadHandle, &context))
- {
- WriteStackDetails( &context, false, threadHandle );
- }
- CloseHandle(threadHandle);
- }
- } while( Thread32Next(hThreadSnap, &te32 ) );
-
-// Don't forget to clean up the snapshot object.
- CloseHandle( hThreadSnap );
-}
-
-
-//===========================================================================
-// Open the report file, and write the desired information to it. Called by
-// WheatyUnhandledExceptionFilter
-//===========================================================================
-void WheatyExceptionReport::GenerateExceptionReport(
-PEXCEPTION_POINTERS pExceptionInfo )
-{
- SYSTEMTIME systime;
- GetLocalTime(&systime);
-
- // Start out with a banner
- _tprintf(_T("Revision: %s\r\n"), SVN_REVISION);
- _tprintf(_T("Date %u:%u:%u. Time %u:%u \r\n"), systime.wDay, systime.wMonth, systime.wYear, systime.wHour, systime.wMinute);
- PEXCEPTION_RECORD pExceptionRecord = pExceptionInfo->ExceptionRecord;
-
- PrintSystemInfo();
- // First print information about the type of fault
- _tprintf(_T("\r\n//=====================================================\r\n"));
- _tprintf( _T("Exception code: %08X %s\r\n"),
- pExceptionRecord->ExceptionCode,
- GetExceptionString(pExceptionRecord->ExceptionCode) );
-
- // Now print information about where the fault occured
- TCHAR szFaultingModule[MAX_PATH];
- DWORD section;
- DWORD_PTR offset;
- GetLogicalAddress( pExceptionRecord->ExceptionAddress,
- szFaultingModule,
- sizeof( szFaultingModule ),
- section, offset );
-
-#ifdef _M_IX86
- _tprintf( _T("Fault address: %08X %02X:%08X %s\r\n"),
- pExceptionRecord->ExceptionAddress,
- section, offset, szFaultingModule );
-#endif
-#ifdef _M_X64
- _tprintf( _T("Fault address: %016I64X %02X:%016I64X %s\r\n"),
- pExceptionRecord->ExceptionAddress,
- section, offset, szFaultingModule );
-#endif
-
- PCONTEXT pCtx = pExceptionInfo->ContextRecord;
-
- // Show the registers
- #ifdef _M_IX86 // X86 Only!
- _tprintf( _T("\r\nRegisters:\r\n") );
-
- _tprintf(_T("EAX:%08X\r\nEBX:%08X\r\nECX:%08X\r\nEDX:%08X\r\nESI:%08X\r\nEDI:%08X\r\n")
- ,pCtx->Eax, pCtx->Ebx, pCtx->Ecx, pCtx->Edx,
- pCtx->Esi, pCtx->Edi );
-
- _tprintf( _T("CS:EIP:%04X:%08X\r\n"), pCtx->SegCs, pCtx->Eip );
- _tprintf( _T("SS:ESP:%04X:%08X EBP:%08X\r\n"),
- pCtx->SegSs, pCtx->Esp, pCtx->Ebp );
- _tprintf( _T("DS:%04X ES:%04X FS:%04X GS:%04X\r\n"),
- pCtx->SegDs, pCtx->SegEs, pCtx->SegFs, pCtx->SegGs );
- _tprintf( _T("Flags:%08X\r\n"), pCtx->EFlags );
- #endif
-
- #ifdef _M_X64
- _tprintf( _T("\r\nRegisters:\r\n") );
- _tprintf(_T("RAX:%016I64X\r\nRBX:%016I64X\r\nRCX:%016I64X\r\nRDX:%016I64X\r\nRSI:%016I64X\r\nRDI:%016I64X\r\n")
- _T("R8: %016I64X\r\nR9: %016I64X\r\nR10:%016I64X\r\nR11:%016I64X\r\nR12:%016I64X\r\nR13:%016I64X\r\nR14:%016I64X\r\nR15:%016I64X\r\n")
- ,pCtx->Rax, pCtx->Rbx, pCtx->Rcx, pCtx->Rdx,
- pCtx->Rsi, pCtx->Rdi ,pCtx->R9,pCtx->R10,pCtx->R11,pCtx->R12,pCtx->R13,pCtx->R14,pCtx->R15);
- _tprintf( _T("CS:RIP:%04X:%016I64X\r\n"), pCtx->SegCs, pCtx->Rip );
- _tprintf( _T("SS:RSP:%04X:%016X RBP:%08X\r\n"),
- pCtx->SegSs, pCtx->Rsp, pCtx->Rbp );
- _tprintf( _T("DS:%04X ES:%04X FS:%04X GS:%04X\r\n"),
- pCtx->SegDs, pCtx->SegEs, pCtx->SegFs, pCtx->SegGs );
- _tprintf( _T("Flags:%08X\r\n"), pCtx->EFlags );
- #endif
-
- SymSetOptions( SYMOPT_DEFERRED_LOADS );
-
- // Initialize DbgHelp
- if ( !SymInitialize( GetCurrentProcess(), 0, TRUE ) )
- {
- _tprintf(_T("\n\rCRITICAL ERROR.\n\r Couldn't initialize the symbol handler for process.\n\rError [%s].\n\r\n\r"),
- ErrorMessage(GetLastError()));
- }
-
- CONTEXT trashableContext = *pCtx;
-
- WriteStackDetails( &trashableContext, false, NULL );
- printTracesForAllThreads();
-
-// #ifdef _M_IX86 // X86 Only!
-
- _tprintf( _T("========================\r\n") );
- _tprintf( _T("Local Variables And Parameters\r\n") );
-
- trashableContext = *pCtx;
- WriteStackDetails( &trashableContext, true, NULL );
-
- _tprintf( _T("========================\r\n") );
- _tprintf( _T("Global Variables\r\n") );
-
- SymEnumSymbols( GetCurrentProcess(),
- (DWORD64)GetModuleHandle(szFaultingModule),
- 0, EnumerateSymbolsCallback, 0 );
- // #endif // X86 Only!
-
- SymCleanup( GetCurrentProcess() );
-
- _tprintf( _T("\r\n") );
-}
-
-//======================================================================
-// Given an exception code, returns a pointer to a static string with a
-// description of the exception
-//======================================================================
-LPTSTR WheatyExceptionReport::GetExceptionString( DWORD dwCode )
-{
- #define EXCEPTION( x ) case EXCEPTION_##x: return _T(#x);
-
- switch ( dwCode )
- {
- EXCEPTION( ACCESS_VIOLATION )
- EXCEPTION( DATATYPE_MISALIGNMENT )
- EXCEPTION( BREAKPOINT )
- EXCEPTION( SINGLE_STEP )
- EXCEPTION( ARRAY_BOUNDS_EXCEEDED )
- EXCEPTION( FLT_DENORMAL_OPERAND )
- EXCEPTION( FLT_DIVIDE_BY_ZERO )
- EXCEPTION( FLT_INEXACT_RESULT )
- EXCEPTION( FLT_INVALID_OPERATION )
- EXCEPTION( FLT_OVERFLOW )
- EXCEPTION( FLT_STACK_CHECK )
- EXCEPTION( FLT_UNDERFLOW )
- EXCEPTION( INT_DIVIDE_BY_ZERO )
- EXCEPTION( INT_OVERFLOW )
- EXCEPTION( PRIV_INSTRUCTION )
- EXCEPTION( IN_PAGE_ERROR )
- EXCEPTION( ILLEGAL_INSTRUCTION )
- EXCEPTION( NONCONTINUABLE_EXCEPTION )
- EXCEPTION( STACK_OVERFLOW )
- EXCEPTION( INVALID_DISPOSITION )
- EXCEPTION( GUARD_PAGE )
- EXCEPTION( INVALID_HANDLE )
- }
-
- // If not one of the "known" exceptions, try to get the string
- // from NTDLL.DLL's message table.
-
- static TCHAR szBuffer[512] = { 0 };
-
- FormatMessage( FORMAT_MESSAGE_IGNORE_INSERTS | FORMAT_MESSAGE_FROM_HMODULE,
- GetModuleHandle( _T("NTDLL.DLL") ),
- dwCode, 0, szBuffer, sizeof( szBuffer ), 0 );
-
- return szBuffer;
-}
-
-//=============================================================================
-// Given a linear address, locates the module, section, and offset containing
-// that address.
-//
-// Note: the szModule paramater buffer is an output buffer of length specified
-// by the len parameter (in characters!)
-//=============================================================================
-BOOL WheatyExceptionReport::GetLogicalAddress(
-PVOID addr, PTSTR szModule, DWORD len, DWORD& section, DWORD_PTR& offset )
-{
- MEMORY_BASIC_INFORMATION mbi;
-
- if ( !VirtualQuery( addr, &mbi, sizeof(mbi) ) )
- return FALSE;
-
- DWORD_PTR hMod = (DWORD_PTR)mbi.AllocationBase;
-
- if ( !GetModuleFileName( (HMODULE)hMod, szModule, len ) )
- return FALSE;
-
- // Point to the DOS header in memory
- PIMAGE_DOS_HEADER pDosHdr = (PIMAGE_DOS_HEADER)hMod;
-
- // From the DOS header, find the NT (PE) header
- PIMAGE_NT_HEADERS pNtHdr = (PIMAGE_NT_HEADERS)(hMod + DWORD_PTR(pDosHdr->e_lfanew));
-
- PIMAGE_SECTION_HEADER pSection = IMAGE_FIRST_SECTION( pNtHdr );
-
- DWORD_PTR rva = (DWORD_PTR)addr - hMod; // RVA is offset from module load address
-
- // Iterate through the section table, looking for the one that encompasses
- // the linear address.
- for ( unsigned i = 0;
- i < pNtHdr->FileHeader.NumberOfSections;
- i++, pSection++ )
- {
- DWORD_PTR sectionStart = pSection->VirtualAddress;
- DWORD_PTR sectionEnd = sectionStart
- + DWORD_PTR(max(pSection->SizeOfRawData, pSection->Misc.VirtualSize));
-
- // Is the address in this section???
- if ( (rva >= sectionStart) && (rva <= sectionEnd) )
- {
- // Yes, address is in the section. Calculate section and offset,
- // and store in the "section" & "offset" params, which were
- // passed by reference.
- section = i+1;
- offset = rva - sectionStart;
- return TRUE;
- }
- }
-
- return FALSE; // Should never get here!
-}
-
-// It contains SYMBOL_INFO structure plus additional
-// space for the name of the symbol
-struct CSymbolInfoPackage : public SYMBOL_INFO_PACKAGE
-{
- CSymbolInfoPackage()
- {
- si.SizeOfStruct = sizeof(SYMBOL_INFO);
- si.MaxNameLen = sizeof(name);
- }
-};
-
-//============================================================
-// Walks the stack, and writes the results to the report file
-//============================================================
-void WheatyExceptionReport::WriteStackDetails(
-PCONTEXT pContext,
-bool bWriteVariables, HANDLE pThreadHandle) // true if local/params should be output
-{
- _tprintf( _T("\r\nCall stack:\r\n") );
-
- _tprintf( _T("Address Frame Function SourceFile\r\n") );
-
- DWORD dwMachineType = 0;
- // Could use SymSetOptions here to add the SYMOPT_DEFERRED_LOADS flag
-
- STACKFRAME64 sf;
- memset( &sf, 0, sizeof(sf) );
-
- #ifdef _M_IX86
- // Initialize the STACKFRAME structure for the first call. This is only
- // necessary for Intel CPUs, and isn't mentioned in the documentation.
- sf.AddrPC.Offset = pContext->Eip;
- sf.AddrPC.Mode = AddrModeFlat;
- sf.AddrStack.Offset = pContext->Esp;
- sf.AddrStack.Mode = AddrModeFlat;
- sf.AddrFrame.Offset = pContext->Ebp;
- sf.AddrFrame.Mode = AddrModeFlat;
-
- dwMachineType = IMAGE_FILE_MACHINE_I386;
- #endif
-
-#ifdef _M_X64
- sf.AddrPC.Offset = pContext->Rip;
- sf.AddrPC.Mode = AddrModeFlat;
- sf.AddrStack.Offset = pContext->Rsp;
- sf.AddrStack.Mode = AddrModeFlat;
- sf.AddrFrame.Offset = pContext->Rbp;
- sf.AddrFrame.Mode = AddrModeFlat;
- dwMachineType = IMAGE_FILE_MACHINE_AMD64;
-#endif
-
- while ( 1 )
- {
- // Get the next stack frame
- if ( ! StackWalk64( dwMachineType,
- m_hProcess,
- pThreadHandle != NULL ? pThreadHandle : GetCurrentThread(),
- &sf,
- pContext,
- 0,
- SymFunctionTableAccess64,
- SymGetModuleBase64,
- 0 ) )
- break;
- if ( 0 == sf.AddrFrame.Offset ) // Basic sanity check to make sure
- break; // the frame is OK. Bail if not.
-#ifdef _M_IX86
- _tprintf( _T("%08X %08X "), sf.AddrPC.Offset, sf.AddrFrame.Offset );
-#endif
-#ifdef _M_X64
- _tprintf( _T("%016I64X %016I64X "), sf.AddrPC.Offset, sf.AddrFrame.Offset );
-#endif
-
- DWORD64 symDisplacement = 0; // Displacement of the input address,
- // relative to the start of the symbol
-
- // Get the name of the function for this stack frame entry
- CSymbolInfoPackage sip;
- if ( SymFromAddr(
- m_hProcess, // Process handle of the current process
- sf.AddrPC.Offset, // Symbol address
- &symDisplacement, // Address of the variable that will receive the displacement
- &sip.si // Address of the SYMBOL_INFO structure (inside "sip" object)
- ))
- {
- _tprintf( _T("%hs+%I64X"), sip.si.Name, symDisplacement );
-
- }
- else // No symbol found. Print out the logical address instead.
- {
- TCHAR szModule[MAX_PATH] = _T("");
- DWORD section = 0;
- DWORD_PTR offset = 0;
-
- GetLogicalAddress( (PVOID)sf.AddrPC.Offset,
- szModule, sizeof(szModule), section, offset );
-#ifdef _M_IX86
- _tprintf( _T("%04X:%08X %s"), section, offset, szModule );
-#endif
-#ifdef _M_X64
- _tprintf( _T("%04X:%016I64X %s"), section, offset, szModule );
-#endif
- }
-
- // Get the source line for this stack frame entry
- IMAGEHLP_LINE64 lineInfo = { sizeof(IMAGEHLP_LINE) };
- DWORD dwLineDisplacement;
- if ( SymGetLineFromAddr64( m_hProcess, sf.AddrPC.Offset,
- &dwLineDisplacement, &lineInfo ) )
- {
- _tprintf(_T(" %s line %u"),lineInfo.FileName,lineInfo.LineNumber);
- }
-
- _tprintf( _T("\r\n") );
-
- // Write out the variables, if desired
- if ( bWriteVariables )
- {
- // Use SymSetContext to get just the locals/params for this frame
- IMAGEHLP_STACK_FRAME imagehlpStackFrame;
- imagehlpStackFrame.InstructionOffset = sf.AddrPC.Offset;
- SymSetContext( m_hProcess, &imagehlpStackFrame, 0 );
-
- // Enumerate the locals/parameters
- SymEnumSymbols( m_hProcess, 0, 0, EnumerateSymbolsCallback, &sf );
-
- _tprintf( _T("\r\n") );
- }
- }
-
-}
-
-//////////////////////////////////////////////////////////////////////////////
-// The function invoked by SymEnumSymbols
-//////////////////////////////////////////////////////////////////////////////
-
-BOOL CALLBACK
-WheatyExceptionReport::EnumerateSymbolsCallback(
-PSYMBOL_INFO pSymInfo,
-ULONG SymbolSize,
-PVOID UserContext )
-{
-
- char szBuffer[2048];
-
- __try
- {
- if ( FormatSymbolValue( pSymInfo, (STACKFRAME*)UserContext,
- szBuffer, sizeof(szBuffer) ) )
- _tprintf( _T("\t%s\r\n"), szBuffer );
- }
- __except( 1 )
- {
- _tprintf( _T("punting on symbol %s\r\n"), pSymInfo->Name );
- }
-
- return TRUE;
-}
-
-//////////////////////////////////////////////////////////////////////////////
-// Given a SYMBOL_INFO representing a particular variable, displays its
-// contents. If it's a user defined type, display the members and their
-// values.
-//////////////////////////////////////////////////////////////////////////////
-bool WheatyExceptionReport::FormatSymbolValue(
-PSYMBOL_INFO pSym,
-STACKFRAME * sf,
-char * pszBuffer,
-unsigned cbBuffer )
-{
- char * pszCurrBuffer = pszBuffer;
-
- // Indicate if the variable is a local or parameter
- if ( pSym->Flags & IMAGEHLP_SYMBOL_INFO_PARAMETER )
- pszCurrBuffer += sprintf( pszCurrBuffer, "Parameter " );
- else if ( pSym->Flags & IMAGEHLP_SYMBOL_INFO_LOCAL )
- pszCurrBuffer += sprintf( pszCurrBuffer, "Local " );
-
- // If it's a function, don't do anything.
- if ( pSym->Tag == 5 ) // SymTagFunction from CVCONST.H from the DIA SDK
- return false;
-
- DWORD_PTR pVariable = 0; // Will point to the variable's data in memory
-
- if ( pSym->Flags & IMAGEHLP_SYMBOL_INFO_REGRELATIVE )
- {
- // if ( pSym->Register == 8 ) // EBP is the value 8 (in DBGHELP 5.1)
- { // This may change!!!
- pVariable = sf->AddrFrame.Offset;
- pVariable += (DWORD_PTR)pSym->Address;
- }
- // else
- // return false;
- }
- else if ( pSym->Flags & IMAGEHLP_SYMBOL_INFO_REGISTER )
- {
- return false; // Don't try to report register variable
- }
- else
- {
- pVariable = (DWORD_PTR)pSym->Address; // It must be a global variable
- }
-
- // Determine if the variable is a user defined type (UDT). IF so, bHandled
- // will return true.
- bool bHandled;
- pszCurrBuffer = DumpTypeIndex(pszCurrBuffer,pSym->ModBase, pSym->TypeIndex,
- 0, pVariable, bHandled, pSym->Name );
-
- if ( !bHandled )
- {
- // The symbol wasn't a UDT, so do basic, stupid formatting of the
- // variable. Based on the size, we're assuming it's a char, WORD, or
- // DWORD.
- BasicType basicType = GetBasicType( pSym->TypeIndex, pSym->ModBase );
- pszCurrBuffer += sprintf( pszCurrBuffer, rgBaseType[basicType]);
-
- // Emit the variable name
- pszCurrBuffer += sprintf( pszCurrBuffer, "\'%s\'", pSym->Name );
-
- pszCurrBuffer = FormatOutputValue(pszCurrBuffer, basicType, pSym->Size,
- (PVOID)pVariable );
- }
-
- return true;
-}
-
-//////////////////////////////////////////////////////////////////////////////
-// If it's a user defined type (UDT), recurse through its members until we're
-// at fundamental types. When he hit fundamental types, return
-// bHandled = false, so that FormatSymbolValue() will format them.
-//////////////////////////////////////////////////////////////////////////////
-char * WheatyExceptionReport::DumpTypeIndex(
-char * pszCurrBuffer,
-DWORD64 modBase,
-DWORD dwTypeIndex,
-unsigned nestingLevel,
-DWORD_PTR offset,
-bool & bHandled,
-char* Name)
-{
- bHandled = false;
-
- // Get the name of the symbol. This will either be a Type name (if a UDT),
- // or the structure member name.
- WCHAR * pwszTypeName;
- if ( SymGetTypeInfo( m_hProcess, modBase, dwTypeIndex, TI_GET_SYMNAME,
- &pwszTypeName ) )
- {
- pszCurrBuffer += sprintf( pszCurrBuffer, " %ls", pwszTypeName );
- LocalFree( pwszTypeName );
- }
-
- // Determine how many children this type has.
- DWORD dwChildrenCount = 0;
- SymGetTypeInfo( m_hProcess, modBase, dwTypeIndex, TI_GET_CHILDRENCOUNT,
- &dwChildrenCount );
-
- if ( !dwChildrenCount ) // If no children, we're done
- return pszCurrBuffer;
-
- // Prepare to get an array of "TypeIds", representing each of the children.
- // SymGetTypeInfo(TI_FINDCHILDREN) expects more memory than just a
- // TI_FINDCHILDREN_PARAMS struct has. Use derivation to accomplish this.
- struct FINDCHILDREN : TI_FINDCHILDREN_PARAMS
- {
- ULONG MoreChildIds[1024];
- FINDCHILDREN(){Count = sizeof(MoreChildIds) / sizeof(MoreChildIds[0]);}
- } children;
-
- children.Count = dwChildrenCount;
- children.Start= 0;
-
- // Get the array of TypeIds, one for each child type
- if ( !SymGetTypeInfo( m_hProcess, modBase, dwTypeIndex, TI_FINDCHILDREN,
- &children ) )
- {
- return pszCurrBuffer;
- }
-
- // Append a line feed
- pszCurrBuffer += sprintf( pszCurrBuffer, "\r\n" );
-
- // Iterate through each of the children
- for ( unsigned i = 0; i < dwChildrenCount; i++ )
- {
- // Add appropriate indentation level (since this routine is recursive)
- for ( unsigned j = 0; j <= nestingLevel+1; j++ )
- pszCurrBuffer += sprintf( pszCurrBuffer, "\t" );
-
- // Recurse for each of the child types
- bool bHandled2;
- BasicType basicType = GetBasicType(children.ChildId[i], modBase );
- pszCurrBuffer += sprintf( pszCurrBuffer, rgBaseType[basicType]);
-
- pszCurrBuffer = DumpTypeIndex( pszCurrBuffer, modBase,
- children.ChildId[i], nestingLevel+1,
- offset, bHandled2, ""/*Name */);
-
- // If the child wasn't a UDT, format it appropriately
- if ( !bHandled2 )
- {
- // Get the offset of the child member, relative to its parent
- DWORD dwMemberOffset;
- SymGetTypeInfo( m_hProcess, modBase, children.ChildId[i],
- TI_GET_OFFSET, &dwMemberOffset );
-
- // Get the real "TypeId" of the child. We need this for the
- // SymGetTypeInfo( TI_GET_TYPEID ) call below.
- DWORD typeId;
- SymGetTypeInfo( m_hProcess, modBase, children.ChildId[i],
- TI_GET_TYPEID, &typeId );
-
- // Get the size of the child member
- ULONG64 length;
- SymGetTypeInfo(m_hProcess, modBase, typeId, TI_GET_LENGTH,&length);
-
- // Calculate the address of the member
- DWORD_PTR dwFinalOffset = offset + dwMemberOffset;
-
- // BasicType basicType = GetBasicType(children.ChildId[i], modBase );
- //
- // pszCurrBuffer += sprintf( pszCurrBuffer, rgBaseType[basicType]);
- //
- // Emit the variable name
- // pszCurrBuffer += sprintf( pszCurrBuffer, "\'%s\'", Name );
-
- pszCurrBuffer = FormatOutputValue( pszCurrBuffer, basicType,
- length, (PVOID)dwFinalOffset );
-
- pszCurrBuffer += sprintf( pszCurrBuffer, "\r\n" );
- }
- }
-
- bHandled = true;
- return pszCurrBuffer;
-}
-
-char * WheatyExceptionReport::FormatOutputValue( char * pszCurrBuffer,
-BasicType basicType,
-DWORD64 length,
-PVOID pAddress )
-{
- // Format appropriately (assuming it's a 1, 2, or 4 bytes (!!!)
- if ( length == 1 )
- pszCurrBuffer += sprintf( pszCurrBuffer, " = %X", *(PBYTE)pAddress );
- else if ( length == 2 )
- pszCurrBuffer += sprintf( pszCurrBuffer, " = %X", *(PWORD)pAddress );
- else if ( length == 4 )
- {
- if ( basicType == btFloat )
- {
- pszCurrBuffer += sprintf(pszCurrBuffer," = %f", *(PFLOAT)pAddress);
- }
- else if ( basicType == btChar )
- {
- if ( !IsBadStringPtr( *(PSTR*)pAddress, 32) )
- {
- pszCurrBuffer += sprintf( pszCurrBuffer, " = \"%.31s\"",
- *(PDWORD)pAddress );
- }
- else
- pszCurrBuffer += sprintf( pszCurrBuffer, " = %X",
- *(PDWORD)pAddress );
- }
- else
- pszCurrBuffer += sprintf(pszCurrBuffer," = %X", *(PDWORD)pAddress);
- }
- else if ( length == 8 )
- {
- if ( basicType == btFloat )
- {
- pszCurrBuffer += sprintf( pszCurrBuffer, " = %lf",
- *(double *)pAddress );
- }
- else
- pszCurrBuffer += sprintf( pszCurrBuffer, " = %I64X",
- *(DWORD64*)pAddress );
- }
-
- return pszCurrBuffer;
-}
-
-BasicType
-WheatyExceptionReport::GetBasicType( DWORD typeIndex, DWORD64 modBase )
-{
- BasicType basicType;
- if ( SymGetTypeInfo( m_hProcess, modBase, typeIndex,
- TI_GET_BASETYPE, &basicType ) )
- {
- return basicType;
- }
-
- // Get the real "TypeId" of the child. We need this for the
- // SymGetTypeInfo( TI_GET_TYPEID ) call below.
- DWORD typeId;
- if (SymGetTypeInfo(m_hProcess,modBase, typeIndex, TI_GET_TYPEID, &typeId))
- {
- if ( SymGetTypeInfo( m_hProcess, modBase, typeId, TI_GET_BASETYPE,
- &basicType ) )
- {
- return basicType;
- }
- }
-
- return btNoType;
-}
-
-//============================================================================
-// Helper function that writes to the report file, and allows the user to use
-// printf style formating
-//============================================================================
-int __cdecl WheatyExceptionReport::_tprintf(const TCHAR * format, ...)
-{
- TCHAR szBuff[1024];
- int retValue;
- DWORD cbWritten;
- va_list argptr;
-
- va_start( argptr, format );
- retValue = vsprintf( szBuff, format, argptr );
- va_end( argptr );
-
- WriteFile(m_hReportFile, szBuff, retValue * sizeof(TCHAR), &cbWritten, 0 );
-
- return retValue;
-}
+//==========================================
+// Matt Pietrek
+// MSDN Magazine, 2002
+// FILE: WheatyExceptionReport.CPP
+//==========================================
+#define WIN32_LEAN_AND_MEAN
+#pragma warning(disable:4996)
+#pragma warning(disable:4312)
+#pragma warning(disable:4311)
+#include <windows.h>
+#include <tlhelp32.h>
+#include <stdio.h>
+#include <tchar.h>
+#define _NO_CVCONST_H
+#include <dbghelp.h>
+#include "WheatyExceptionReport.h"
+#include "svn_revision.h"
+#define CrashFolder _T("Crashs")
+//#pragma comment(linker, "/defaultlib:dbghelp.lib")
+
+inline LPTSTR ErrorMessage(DWORD dw)
+{
+ LPVOID lpMsgBuf;
+ FormatMessage(
+ FORMAT_MESSAGE_ALLOCATE_BUFFER |
+ FORMAT_MESSAGE_FROM_SYSTEM,
+ NULL,
+ dw,
+ MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
+ (LPTSTR) &lpMsgBuf,
+ 0, NULL );
+ return (LPTSTR)lpMsgBuf;
+}
+
+//============================== Global Variables =============================
+
+//
+// Declare the static variables of the WheatyExceptionReport class
+//
+TCHAR WheatyExceptionReport::m_szLogFileName[MAX_PATH];
+LPTOP_LEVEL_EXCEPTION_FILTER WheatyExceptionReport::m_previousFilter;
+HANDLE WheatyExceptionReport::m_hReportFile;
+HANDLE WheatyExceptionReport::m_hProcess;
+
+// Declare global instance of class
+WheatyExceptionReport g_WheatyExceptionReport;
+
+//============================== Class Methods =============================
+
+WheatyExceptionReport::WheatyExceptionReport( ) // Constructor
+{
+ // Install the unhandled exception filter function
+ m_previousFilter = SetUnhandledExceptionFilter(WheatyUnhandledExceptionFilter);
+ m_hProcess = GetCurrentProcess();
+}
+
+//============
+// Destructor
+//============
+WheatyExceptionReport::~WheatyExceptionReport( )
+{
+ if(m_previousFilter)
+ SetUnhandledExceptionFilter( m_previousFilter );
+}
+
+//===========================================================
+// Entry point where control comes on an unhandled exception
+//===========================================================
+LONG WINAPI WheatyExceptionReport::WheatyUnhandledExceptionFilter(
+PEXCEPTION_POINTERS pExceptionInfo )
+{
+ TCHAR module_folder_name[MAX_PATH];
+ GetModuleFileName( 0, module_folder_name, MAX_PATH );
+ TCHAR* pos = _tcsrchr(module_folder_name, '\\');
+ if(!pos)
+ return 0;
+ pos[0] = '\0';
+ ++pos;
+
+ TCHAR crash_folder_path[MAX_PATH];
+ sprintf(crash_folder_path, "%s\\%s", module_folder_name, CrashFolder);
+ if(!CreateDirectory(crash_folder_path, NULL))
+ {
+ if(GetLastError() != ERROR_ALREADY_EXISTS)
+ return 0;
+ }
+
+ SYSTEMTIME systime;
+ GetLocalTime(&systime);
+ sprintf(m_szLogFileName, "%s\\%s_[%u-%u_%u-%u-%u].txt",
+ crash_folder_path, pos, systime.wDay, systime.wMonth, systime.wHour, systime.wMinute, systime.wSecond
+ );
+
+ m_hReportFile = CreateFile( m_szLogFileName,
+ GENERIC_WRITE,
+ 0,
+ 0,
+ OPEN_ALWAYS,
+ FILE_FLAG_WRITE_THROUGH,
+ 0 );
+
+ if ( m_hReportFile )
+ {
+ SetFilePointer( m_hReportFile, 0, 0, FILE_END );
+
+ GenerateExceptionReport( pExceptionInfo );
+
+ CloseHandle( m_hReportFile );
+ m_hReportFile = 0;
+ }
+
+ if ( m_previousFilter )
+ return m_previousFilter( pExceptionInfo );
+ else
+ return EXCEPTION_EXECUTE_HANDLER/*EXCEPTION_CONTINUE_SEARCH*/;
+}
+
+BOOL WheatyExceptionReport::_GetProcessorName(TCHAR* sProcessorName, DWORD maxcount)
+{
+ if(!sProcessorName)
+ return FALSE;
+
+ HKEY hKey;
+ LONG lRet;
+ lRet = ::RegOpenKeyEx(HKEY_LOCAL_MACHINE, _T("HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0"),
+ 0, KEY_QUERY_VALUE, &hKey);
+ if (lRet != ERROR_SUCCESS)
+ return FALSE;
+ TCHAR szTmp[2048];
+ DWORD cntBytes = sizeof(szTmp);
+ lRet = ::RegQueryValueEx(hKey, _T("ProcessorNameString"), NULL, NULL,
+ (LPBYTE)szTmp, &cntBytes);
+ if (lRet != ERROR_SUCCESS)
+ return FALSE;
+ ::RegCloseKey(hKey);
+ sProcessorName[0] = '\0';
+ // Skip spaces
+ TCHAR* psz = szTmp;
+ while (iswspace(*psz))
+ ++psz;
+ _tcsncpy(sProcessorName, psz, maxcount);
+ return TRUE;
+}
+
+BOOL WheatyExceptionReport::_GetWindowsVersion(TCHAR* szVersion, DWORD cntMax)
+{
+ // Try calling GetVersionEx using the OSVERSIONINFOEX structure.
+ // If that fails, try using the OSVERSIONINFO structure.
+ OSVERSIONINFOEX osvi = { 0 };
+ osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);
+ BOOL bOsVersionInfoEx;
+ bOsVersionInfoEx = ::GetVersionEx((LPOSVERSIONINFO)(&osvi));
+ if (!bOsVersionInfoEx)
+ {
+ osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
+ if (!::GetVersionEx((OSVERSIONINFO*)&osvi))
+ return FALSE;
+ }
+ *szVersion = _T('\0');
+ TCHAR wszTmp[128];
+ switch (osvi.dwPlatformId)
+ {
+ // Windows NT product family.
+ case VER_PLATFORM_WIN32_NT:
+ // Test for the specific product family.
+ if (osvi.dwMajorVersion == 6)
+ _tcsncat(szVersion, _T("Windows Vista or Windows Server 2008 "), cntMax);
+ if (osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 2)
+ _tcsncat(szVersion, _T("Microsoft Windows Server 2003 "), cntMax);
+ if (osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 1)
+ _tcsncat(szVersion, _T("Microsoft Windows XP "), cntMax);
+ if (osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 0)
+ _tcsncat(szVersion, _T("Microsoft Windows 2000 "), cntMax);
+ if (osvi.dwMajorVersion <= 4 )
+ _tcsncat(szVersion, _T("Microsoft Windows NT "), cntMax);
+
+ // Test for specific product on Windows NT 4.0 SP6 and later.
+ if (bOsVersionInfoEx)
+ {
+ // Test for the workstation type.
+ #if WINVER < 0x0500
+ if (osvi.wReserved[1] == VER_NT_WORKSTATION)
+ #else
+ if (osvi.wProductType == VER_NT_WORKSTATION)
+ #endif // WINVER < 0x0500
+ {
+ if (osvi.dwMajorVersion == 4)
+ _tcsncat(szVersion, _T("Workstation 4.0 "), cntMax);
+ #if WINVER < 0x0500
+ else if (osvi.wReserved[0] & VER_SUITE_PERSONAL)
+ #else
+ else if (osvi.wSuiteMask & VER_SUITE_PERSONAL)
+ #endif // WINVER < 0x0500
+ _tcsncat(szVersion, _T("Home Edition "), cntMax);
+ #if WINVER < 0x0500
+ else if (osvi.wReserved[0] & VER_SUITE_EMBEDDEDNT)
+ #else
+ else if (osvi.wSuiteMask & VER_SUITE_EMBEDDEDNT)
+ #endif // WINVER < 0x0500
+ _tcsncat(szVersion, _T("Embedded "), cntMax);
+ else
+ _tcsncat(szVersion, _T("Professional "), cntMax);
+ }
+ // Test for the server type.
+ #if WINVER < 0x0500
+ else if (osvi.wReserved[1] == VER_NT_SERVER)
+ #else
+ else if (osvi.wProductType == VER_NT_SERVER)
+ #endif // WINVER < 0x0500
+ {
+ if (osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 2)
+ {
+ #if WINVER < 0x0500
+ if (osvi.wReserved[0] & VER_SUITE_DATACENTER)
+ #else
+ if (osvi.wSuiteMask & VER_SUITE_DATACENTER)
+ #endif // WINVER < 0x0500
+ _tcsncat(szVersion, _T("Datacenter Edition "), cntMax);
+ #if WINVER < 0x0500
+ else if (osvi.wReserved[0] & VER_SUITE_ENTERPRISE)
+ #else
+ else if (osvi.wSuiteMask & VER_SUITE_ENTERPRISE)
+ #endif // WINVER < 0x0500
+ _tcsncat(szVersion, _T("Enterprise Edition "), cntMax);
+ #if WINVER < 0x0500
+ else if (osvi.wReserved[0] == VER_SUITE_BLADE)
+ #else
+ else if (osvi.wSuiteMask == VER_SUITE_BLADE)
+ #endif // WINVER < 0x0500
+ _tcsncat(szVersion, _T("Web Edition "), cntMax);
+ else
+ _tcsncat(szVersion, _T("Standard Edition "), cntMax);
+ }
+ else if (osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 0)
+ {
+ #if WINVER < 0x0500
+ if (osvi.wReserved[0] & VER_SUITE_DATACENTER)
+ #else
+ if (osvi.wSuiteMask & VER_SUITE_DATACENTER)
+ #endif // WINVER < 0x0500
+ _tcsncat(szVersion, _T("Datacenter Server "), cntMax);
+ #if WINVER < 0x0500
+ else if (osvi.wReserved[0] & VER_SUITE_ENTERPRISE )
+ #else
+ else if (osvi.wSuiteMask & VER_SUITE_ENTERPRISE )
+ #endif // WINVER < 0x0500
+ _tcsncat(szVersion, _T("Advanced Server "), cntMax);
+ else
+ _tcsncat(szVersion, _T("Server "), cntMax);
+ }
+ else // Windows NT 4.0
+ {
+ #if WINVER < 0x0500
+ if (osvi.wReserved[0] & VER_SUITE_ENTERPRISE)
+ #else
+ if (osvi.wSuiteMask & VER_SUITE_ENTERPRISE)
+ #endif // WINVER < 0x0500
+ _tcsncat(szVersion, _T("Server 4.0, Enterprise Edition "), cntMax);
+ else
+ _tcsncat(szVersion, _T("Server 4.0 "), cntMax);
+ }
+ }
+ }
+ // Display service pack (if any) and build number.
+ if (osvi.dwMajorVersion == 4 && _tcsicmp(osvi.szCSDVersion, _T("Service Pack 6")) == 0)
+ {
+ HKEY hKey;
+ LONG lRet;
+
+ // Test for SP6 versus SP6a.
+ lRet = ::RegOpenKeyEx(HKEY_LOCAL_MACHINE, _T("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Hotfix\\Q246009"), 0, KEY_QUERY_VALUE, &hKey);
+ if (lRet == ERROR_SUCCESS)
+ {
+ _stprintf(wszTmp, _T("Service Pack 6a (Version %d.%d, Build %d)"),
+ osvi.dwMajorVersion, osvi.dwMinorVersion, osvi.dwBuildNumber & 0xFFFF);
+ _tcsncat(szVersion, wszTmp, cntMax);
+ }
+ else // Windows NT 4.0 prior to SP6a
+ {
+ _stprintf(wszTmp, _T("%s (Version %d.%d, Build %d)"),
+ osvi.szCSDVersion, osvi.dwMajorVersion, osvi.dwMinorVersion, osvi.dwBuildNumber & 0xFFFF);
+ _tcsncat(szVersion, wszTmp, cntMax);
+ }
+ ::RegCloseKey(hKey);
+ }
+ else // Windows NT 3.51 and earlier or Windows 2000 and later
+ {
+ if (!_tcslen(osvi.szCSDVersion))
+ _stprintf(wszTmp, _T("(Version %d.%d, Build %d)"),
+ osvi.dwMajorVersion, osvi.dwMinorVersion, osvi.dwBuildNumber & 0xFFFF);
+ else
+ _stprintf(wszTmp, _T("%s (Version %d.%d, Build %d)"),
+ osvi.szCSDVersion, osvi.dwMajorVersion, osvi.dwMinorVersion, osvi.dwBuildNumber & 0xFFFF);
+ _tcsncat(szVersion, wszTmp, cntMax);
+ }
+ break;
+ default:
+ _stprintf(wszTmp, _T("%s (Version %d.%d, Build %d)"),
+ osvi.szCSDVersion, osvi.dwMajorVersion, osvi.dwMinorVersion, osvi.dwBuildNumber & 0xFFFF);
+ _tcsncat(szVersion, wszTmp, cntMax);
+ break;
+ }
+
+ return TRUE;
+}
+
+void WheatyExceptionReport::PrintSystemInfo()
+{
+ SYSTEM_INFO SystemInfo;
+ ::GetSystemInfo(&SystemInfo);
+
+ MEMORYSTATUS MemoryStatus;
+ MemoryStatus.dwLength = sizeof (MEMORYSTATUS);
+ ::GlobalMemoryStatus(&MemoryStatus);
+ TCHAR sString[1024];
+ _tprintf(_T("//=====================================================\r\n"));
+ if (_GetProcessorName(sString, countof(sString)))
+ _tprintf(_T("*** Hardware ***\r\nProcessor: %s\r\nNumber Of Processors: %d\r\nPhysical Memory: %d KB (Available: %d KB)\r\nCommit Charge Limit: %d KB\r\n"),
+ sString, SystemInfo.dwNumberOfProcessors, MemoryStatus.dwTotalPhys/0x400, MemoryStatus.dwAvailPhys/0x400, MemoryStatus.dwTotalPageFile/0x400);
+ else
+ _tprintf(_T("*** Hardware ***\r\nProcessor: <unknown>\r\nNumber Of Processors: %d\r\nPhysical Memory: %d KB (Available: %d KB)\r\nCommit Charge Limit: %d KB\r\n"),
+ SystemInfo.dwNumberOfProcessors, MemoryStatus.dwTotalPhys/0x400, MemoryStatus.dwAvailPhys/0x400, MemoryStatus.dwTotalPageFile/0x400);
+
+ if(_GetWindowsVersion(sString, countof(sString)))
+ _tprintf(_T("\r\n*** Operation System ***\r\n%s\r\n"), sString);
+ else
+ _tprintf(_T("\r\n*** Operation System:\r\n<unknown>\r\n"));
+}
+
+//===========================================================================
+void WheatyExceptionReport::printTracesForAllThreads()
+{
+ HANDLE hThreadSnap = INVALID_HANDLE_VALUE;
+ THREADENTRY32 te32;
+
+ DWORD dwOwnerPID = GetCurrentProcessId();
+ m_hProcess = GetCurrentProcess();
+ // Take a snapshot of all running threads
+ hThreadSnap = CreateToolhelp32Snapshot( TH32CS_SNAPTHREAD, 0 );
+ if( hThreadSnap == INVALID_HANDLE_VALUE )
+ return;
+
+ // Fill in the size of the structure before using it.
+ te32.dwSize = sizeof(THREADENTRY32 );
+
+ // Retrieve information about the first thread,
+ // and exit if unsuccessful
+ if( !Thread32First( hThreadSnap, &te32 ) )
+ {
+ CloseHandle( hThreadSnap ); // Must clean up the
+ // snapshot object!
+ return;
+ }
+
+ // Now walk the thread list of the system,
+ // and display information about each thread
+ // associated with the specified process
+ do
+ {
+ if( te32.th32OwnerProcessID == dwOwnerPID )
+ {
+ CONTEXT context;
+ context.ContextFlags = 0xffffffff;
+ HANDLE threadHandle = OpenThread(THREAD_GET_CONTEXT | THREAD_QUERY_INFORMATION,false, te32.th32ThreadID);
+ if(threadHandle && GetThreadContext(threadHandle, &context))
+ {
+ WriteStackDetails( &context, false, threadHandle );
+ }
+ CloseHandle(threadHandle);
+ }
+ } while( Thread32Next(hThreadSnap, &te32 ) );
+
+// Don't forget to clean up the snapshot object.
+ CloseHandle( hThreadSnap );
+}
+
+
+//===========================================================================
+// Open the report file, and write the desired information to it. Called by
+// WheatyUnhandledExceptionFilter
+//===========================================================================
+void WheatyExceptionReport::GenerateExceptionReport(
+PEXCEPTION_POINTERS pExceptionInfo )
+{
+ SYSTEMTIME systime;
+ GetLocalTime(&systime);
+
+ // Start out with a banner
+ _tprintf(_T("Revision: %s\r\n"), SVN_REVISION);
+ _tprintf(_T("Date %u:%u:%u. Time %u:%u \r\n"), systime.wDay, systime.wMonth, systime.wYear, systime.wHour, systime.wMinute);
+ PEXCEPTION_RECORD pExceptionRecord = pExceptionInfo->ExceptionRecord;
+
+ PrintSystemInfo();
+ // First print information about the type of fault
+ _tprintf(_T("\r\n//=====================================================\r\n"));
+ _tprintf( _T("Exception code: %08X %s\r\n"),
+ pExceptionRecord->ExceptionCode,
+ GetExceptionString(pExceptionRecord->ExceptionCode) );
+
+ // Now print information about where the fault occured
+ TCHAR szFaultingModule[MAX_PATH];
+ DWORD section;
+ DWORD_PTR offset;
+ GetLogicalAddress( pExceptionRecord->ExceptionAddress,
+ szFaultingModule,
+ sizeof( szFaultingModule ),
+ section, offset );
+
+#ifdef _M_IX86
+ _tprintf( _T("Fault address: %08X %02X:%08X %s\r\n"),
+ pExceptionRecord->ExceptionAddress,
+ section, offset, szFaultingModule );
+#endif
+#ifdef _M_X64
+ _tprintf( _T("Fault address: %016I64X %02X:%016I64X %s\r\n"),
+ pExceptionRecord->ExceptionAddress,
+ section, offset, szFaultingModule );
+#endif
+
+ PCONTEXT pCtx = pExceptionInfo->ContextRecord;
+
+ // Show the registers
+ #ifdef _M_IX86 // X86 Only!
+ _tprintf( _T("\r\nRegisters:\r\n") );
+
+ _tprintf(_T("EAX:%08X\r\nEBX:%08X\r\nECX:%08X\r\nEDX:%08X\r\nESI:%08X\r\nEDI:%08X\r\n")
+ ,pCtx->Eax, pCtx->Ebx, pCtx->Ecx, pCtx->Edx,
+ pCtx->Esi, pCtx->Edi );
+
+ _tprintf( _T("CS:EIP:%04X:%08X\r\n"), pCtx->SegCs, pCtx->Eip );
+ _tprintf( _T("SS:ESP:%04X:%08X EBP:%08X\r\n"),
+ pCtx->SegSs, pCtx->Esp, pCtx->Ebp );
+ _tprintf( _T("DS:%04X ES:%04X FS:%04X GS:%04X\r\n"),
+ pCtx->SegDs, pCtx->SegEs, pCtx->SegFs, pCtx->SegGs );
+ _tprintf( _T("Flags:%08X\r\n"), pCtx->EFlags );
+ #endif
+
+ #ifdef _M_X64
+ _tprintf( _T("\r\nRegisters:\r\n") );
+ _tprintf(_T("RAX:%016I64X\r\nRBX:%016I64X\r\nRCX:%016I64X\r\nRDX:%016I64X\r\nRSI:%016I64X\r\nRDI:%016I64X\r\n")
+ _T("R8: %016I64X\r\nR9: %016I64X\r\nR10:%016I64X\r\nR11:%016I64X\r\nR12:%016I64X\r\nR13:%016I64X\r\nR14:%016I64X\r\nR15:%016I64X\r\n")
+ ,pCtx->Rax, pCtx->Rbx, pCtx->Rcx, pCtx->Rdx,
+ pCtx->Rsi, pCtx->Rdi ,pCtx->R9,pCtx->R10,pCtx->R11,pCtx->R12,pCtx->R13,pCtx->R14,pCtx->R15);
+ _tprintf( _T("CS:RIP:%04X:%016I64X\r\n"), pCtx->SegCs, pCtx->Rip );
+ _tprintf( _T("SS:RSP:%04X:%016X RBP:%08X\r\n"),
+ pCtx->SegSs, pCtx->Rsp, pCtx->Rbp );
+ _tprintf( _T("DS:%04X ES:%04X FS:%04X GS:%04X\r\n"),
+ pCtx->SegDs, pCtx->SegEs, pCtx->SegFs, pCtx->SegGs );
+ _tprintf( _T("Flags:%08X\r\n"), pCtx->EFlags );
+ #endif
+
+ SymSetOptions( SYMOPT_DEFERRED_LOADS );
+
+ // Initialize DbgHelp
+ if ( !SymInitialize( GetCurrentProcess(), 0, TRUE ) )
+ {
+ _tprintf(_T("\n\rCRITICAL ERROR.\n\r Couldn't initialize the symbol handler for process.\n\rError [%s].\n\r\n\r"),
+ ErrorMessage(GetLastError()));
+ }
+
+ CONTEXT trashableContext = *pCtx;
+
+ WriteStackDetails( &trashableContext, false, NULL );
+ printTracesForAllThreads();
+
+// #ifdef _M_IX86 // X86 Only!
+
+ _tprintf( _T("========================\r\n") );
+ _tprintf( _T("Local Variables And Parameters\r\n") );
+
+ trashableContext = *pCtx;
+ WriteStackDetails( &trashableContext, true, NULL );
+
+ _tprintf( _T("========================\r\n") );
+ _tprintf( _T("Global Variables\r\n") );
+
+ SymEnumSymbols( GetCurrentProcess(),
+ (DWORD64)GetModuleHandle(szFaultingModule),
+ 0, EnumerateSymbolsCallback, 0 );
+ // #endif // X86 Only!
+
+ SymCleanup( GetCurrentProcess() );
+
+ _tprintf( _T("\r\n") );
+}
+
+//======================================================================
+// Given an exception code, returns a pointer to a static string with a
+// description of the exception
+//======================================================================
+LPTSTR WheatyExceptionReport::GetExceptionString( DWORD dwCode )
+{
+ #define EXCEPTION( x ) case EXCEPTION_##x: return _T(#x);
+
+ switch ( dwCode )
+ {
+ EXCEPTION( ACCESS_VIOLATION )
+ EXCEPTION( DATATYPE_MISALIGNMENT )
+ EXCEPTION( BREAKPOINT )
+ EXCEPTION( SINGLE_STEP )
+ EXCEPTION( ARRAY_BOUNDS_EXCEEDED )
+ EXCEPTION( FLT_DENORMAL_OPERAND )
+ EXCEPTION( FLT_DIVIDE_BY_ZERO )
+ EXCEPTION( FLT_INEXACT_RESULT )
+ EXCEPTION( FLT_INVALID_OPERATION )
+ EXCEPTION( FLT_OVERFLOW )
+ EXCEPTION( FLT_STACK_CHECK )
+ EXCEPTION( FLT_UNDERFLOW )
+ EXCEPTION( INT_DIVIDE_BY_ZERO )
+ EXCEPTION( INT_OVERFLOW )
+ EXCEPTION( PRIV_INSTRUCTION )
+ EXCEPTION( IN_PAGE_ERROR )
+ EXCEPTION( ILLEGAL_INSTRUCTION )
+ EXCEPTION( NONCONTINUABLE_EXCEPTION )
+ EXCEPTION( STACK_OVERFLOW )
+ EXCEPTION( INVALID_DISPOSITION )
+ EXCEPTION( GUARD_PAGE )
+ EXCEPTION( INVALID_HANDLE )
+ }
+
+ // If not one of the "known" exceptions, try to get the string
+ // from NTDLL.DLL's message table.
+
+ static TCHAR szBuffer[512] = { 0 };
+
+ FormatMessage( FORMAT_MESSAGE_IGNORE_INSERTS | FORMAT_MESSAGE_FROM_HMODULE,
+ GetModuleHandle( _T("NTDLL.DLL") ),
+ dwCode, 0, szBuffer, sizeof( szBuffer ), 0 );
+
+ return szBuffer;
+}
+
+//=============================================================================
+// Given a linear address, locates the module, section, and offset containing
+// that address.
+//
+// Note: the szModule paramater buffer is an output buffer of length specified
+// by the len parameter (in characters!)
+//=============================================================================
+BOOL WheatyExceptionReport::GetLogicalAddress(
+PVOID addr, PTSTR szModule, DWORD len, DWORD& section, DWORD_PTR& offset )
+{
+ MEMORY_BASIC_INFORMATION mbi;
+
+ if ( !VirtualQuery( addr, &mbi, sizeof(mbi) ) )
+ return FALSE;
+
+ DWORD_PTR hMod = (DWORD_PTR)mbi.AllocationBase;
+
+ if ( !GetModuleFileName( (HMODULE)hMod, szModule, len ) )
+ return FALSE;
+
+ // Point to the DOS header in memory
+ PIMAGE_DOS_HEADER pDosHdr = (PIMAGE_DOS_HEADER)hMod;
+
+ // From the DOS header, find the NT (PE) header
+ PIMAGE_NT_HEADERS pNtHdr = (PIMAGE_NT_HEADERS)(hMod + DWORD_PTR(pDosHdr->e_lfanew));
+
+ PIMAGE_SECTION_HEADER pSection = IMAGE_FIRST_SECTION( pNtHdr );
+
+ DWORD_PTR rva = (DWORD_PTR)addr - hMod; // RVA is offset from module load address
+
+ // Iterate through the section table, looking for the one that encompasses
+ // the linear address.
+ for ( unsigned i = 0;
+ i < pNtHdr->FileHeader.NumberOfSections;
+ i++, pSection++ )
+ {
+ DWORD_PTR sectionStart = pSection->VirtualAddress;
+ DWORD_PTR sectionEnd = sectionStart
+ + DWORD_PTR(max(pSection->SizeOfRawData, pSection->Misc.VirtualSize));
+
+ // Is the address in this section???
+ if ( (rva >= sectionStart) && (rva <= sectionEnd) )
+ {
+ // Yes, address is in the section. Calculate section and offset,
+ // and store in the "section" & "offset" params, which were
+ // passed by reference.
+ section = i+1;
+ offset = rva - sectionStart;
+ return TRUE;
+ }
+ }
+
+ return FALSE; // Should never get here!
+}
+
+// It contains SYMBOL_INFO structure plus additional
+// space for the name of the symbol
+struct CSymbolInfoPackage : public SYMBOL_INFO_PACKAGE
+{
+ CSymbolInfoPackage()
+ {
+ si.SizeOfStruct = sizeof(SYMBOL_INFO);
+ si.MaxNameLen = sizeof(name);
+ }
+};
+
+//============================================================
+// Walks the stack, and writes the results to the report file
+//============================================================
+void WheatyExceptionReport::WriteStackDetails(
+PCONTEXT pContext,
+bool bWriteVariables, HANDLE pThreadHandle) // true if local/params should be output
+{
+ _tprintf( _T("\r\nCall stack:\r\n") );
+
+ _tprintf( _T("Address Frame Function SourceFile\r\n") );
+
+ DWORD dwMachineType = 0;
+ // Could use SymSetOptions here to add the SYMOPT_DEFERRED_LOADS flag
+
+ STACKFRAME64 sf;
+ memset( &sf, 0, sizeof(sf) );
+
+ #ifdef _M_IX86
+ // Initialize the STACKFRAME structure for the first call. This is only
+ // necessary for Intel CPUs, and isn't mentioned in the documentation.
+ sf.AddrPC.Offset = pContext->Eip;
+ sf.AddrPC.Mode = AddrModeFlat;
+ sf.AddrStack.Offset = pContext->Esp;
+ sf.AddrStack.Mode = AddrModeFlat;
+ sf.AddrFrame.Offset = pContext->Ebp;
+ sf.AddrFrame.Mode = AddrModeFlat;
+
+ dwMachineType = IMAGE_FILE_MACHINE_I386;
+ #endif
+
+#ifdef _M_X64
+ sf.AddrPC.Offset = pContext->Rip;
+ sf.AddrPC.Mode = AddrModeFlat;
+ sf.AddrStack.Offset = pContext->Rsp;
+ sf.AddrStack.Mode = AddrModeFlat;
+ sf.AddrFrame.Offset = pContext->Rbp;
+ sf.AddrFrame.Mode = AddrModeFlat;
+ dwMachineType = IMAGE_FILE_MACHINE_AMD64;
+#endif
+
+ while ( 1 )
+ {
+ // Get the next stack frame
+ if ( ! StackWalk64( dwMachineType,
+ m_hProcess,
+ pThreadHandle != NULL ? pThreadHandle : GetCurrentThread(),
+ &sf,
+ pContext,
+ 0,
+ SymFunctionTableAccess64,
+ SymGetModuleBase64,
+ 0 ) )
+ break;
+ if ( 0 == sf.AddrFrame.Offset ) // Basic sanity check to make sure
+ break; // the frame is OK. Bail if not.
+#ifdef _M_IX86
+ _tprintf( _T("%08X %08X "), sf.AddrPC.Offset, sf.AddrFrame.Offset );
+#endif
+#ifdef _M_X64
+ _tprintf( _T("%016I64X %016I64X "), sf.AddrPC.Offset, sf.AddrFrame.Offset );
+#endif
+
+ DWORD64 symDisplacement = 0; // Displacement of the input address,
+ // relative to the start of the symbol
+
+ // Get the name of the function for this stack frame entry
+ CSymbolInfoPackage sip;
+ if ( SymFromAddr(
+ m_hProcess, // Process handle of the current process
+ sf.AddrPC.Offset, // Symbol address
+ &symDisplacement, // Address of the variable that will receive the displacement
+ &sip.si // Address of the SYMBOL_INFO structure (inside "sip" object)
+ ))
+ {
+ _tprintf( _T("%hs+%I64X"), sip.si.Name, symDisplacement );
+
+ }
+ else // No symbol found. Print out the logical address instead.
+ {
+ TCHAR szModule[MAX_PATH] = _T("");
+ DWORD section = 0;
+ DWORD_PTR offset = 0;
+
+ GetLogicalAddress( (PVOID)sf.AddrPC.Offset,
+ szModule, sizeof(szModule), section, offset );
+#ifdef _M_IX86
+ _tprintf( _T("%04X:%08X %s"), section, offset, szModule );
+#endif
+#ifdef _M_X64
+ _tprintf( _T("%04X:%016I64X %s"), section, offset, szModule );
+#endif
+ }
+
+ // Get the source line for this stack frame entry
+ IMAGEHLP_LINE64 lineInfo = { sizeof(IMAGEHLP_LINE) };
+ DWORD dwLineDisplacement;
+ if ( SymGetLineFromAddr64( m_hProcess, sf.AddrPC.Offset,
+ &dwLineDisplacement, &lineInfo ) )
+ {
+ _tprintf(_T(" %s line %u"),lineInfo.FileName,lineInfo.LineNumber);
+ }
+
+ _tprintf( _T("\r\n") );
+
+ // Write out the variables, if desired
+ if ( bWriteVariables )
+ {
+ // Use SymSetContext to get just the locals/params for this frame
+ IMAGEHLP_STACK_FRAME imagehlpStackFrame;
+ imagehlpStackFrame.InstructionOffset = sf.AddrPC.Offset;
+ SymSetContext( m_hProcess, &imagehlpStackFrame, 0 );
+
+ // Enumerate the locals/parameters
+ SymEnumSymbols( m_hProcess, 0, 0, EnumerateSymbolsCallback, &sf );
+
+ _tprintf( _T("\r\n") );
+ }
+ }
+
+}
+
+//////////////////////////////////////////////////////////////////////////////
+// The function invoked by SymEnumSymbols
+//////////////////////////////////////////////////////////////////////////////
+
+BOOL CALLBACK
+WheatyExceptionReport::EnumerateSymbolsCallback(
+PSYMBOL_INFO pSymInfo,
+ULONG SymbolSize,
+PVOID UserContext )
+{
+
+ char szBuffer[2048];
+
+ __try
+ {
+ if ( FormatSymbolValue( pSymInfo, (STACKFRAME*)UserContext,
+ szBuffer, sizeof(szBuffer) ) )
+ _tprintf( _T("\t%s\r\n"), szBuffer );
+ }
+ __except( 1 )
+ {
+ _tprintf( _T("punting on symbol %s\r\n"), pSymInfo->Name );
+ }
+
+ return TRUE;
+}
+
+//////////////////////////////////////////////////////////////////////////////
+// Given a SYMBOL_INFO representing a particular variable, displays its
+// contents. If it's a user defined type, display the members and their
+// values.
+//////////////////////////////////////////////////////////////////////////////
+bool WheatyExceptionReport::FormatSymbolValue(
+PSYMBOL_INFO pSym,
+STACKFRAME * sf,
+char * pszBuffer,
+unsigned cbBuffer )
+{
+ char * pszCurrBuffer = pszBuffer;
+
+ // Indicate if the variable is a local or parameter
+ if ( pSym->Flags & IMAGEHLP_SYMBOL_INFO_PARAMETER )
+ pszCurrBuffer += sprintf( pszCurrBuffer, "Parameter " );
+ else if ( pSym->Flags & IMAGEHLP_SYMBOL_INFO_LOCAL )
+ pszCurrBuffer += sprintf( pszCurrBuffer, "Local " );
+
+ // If it's a function, don't do anything.
+ if ( pSym->Tag == 5 ) // SymTagFunction from CVCONST.H from the DIA SDK
+ return false;
+
+ DWORD_PTR pVariable = 0; // Will point to the variable's data in memory
+
+ if ( pSym->Flags & IMAGEHLP_SYMBOL_INFO_REGRELATIVE )
+ {
+ // if ( pSym->Register == 8 ) // EBP is the value 8 (in DBGHELP 5.1)
+ { // This may change!!!
+ pVariable = sf->AddrFrame.Offset;
+ pVariable += (DWORD_PTR)pSym->Address;
+ }
+ // else
+ // return false;
+ }
+ else if ( pSym->Flags & IMAGEHLP_SYMBOL_INFO_REGISTER )
+ {
+ return false; // Don't try to report register variable
+ }
+ else
+ {
+ pVariable = (DWORD_PTR)pSym->Address; // It must be a global variable
+ }
+
+ // Determine if the variable is a user defined type (UDT). IF so, bHandled
+ // will return true.
+ bool bHandled;
+ pszCurrBuffer = DumpTypeIndex(pszCurrBuffer,pSym->ModBase, pSym->TypeIndex,
+ 0, pVariable, bHandled, pSym->Name );
+
+ if ( !bHandled )
+ {
+ // The symbol wasn't a UDT, so do basic, stupid formatting of the
+ // variable. Based on the size, we're assuming it's a char, WORD, or
+ // DWORD.
+ BasicType basicType = GetBasicType( pSym->TypeIndex, pSym->ModBase );
+ pszCurrBuffer += sprintf( pszCurrBuffer, rgBaseType[basicType]);
+
+ // Emit the variable name
+ pszCurrBuffer += sprintf( pszCurrBuffer, "\'%s\'", pSym->Name );
+
+ pszCurrBuffer = FormatOutputValue(pszCurrBuffer, basicType, pSym->Size,
+ (PVOID)pVariable );
+ }
+
+ return true;
+}
+
+//////////////////////////////////////////////////////////////////////////////
+// If it's a user defined type (UDT), recurse through its members until we're
+// at fundamental types. When he hit fundamental types, return
+// bHandled = false, so that FormatSymbolValue() will format them.
+//////////////////////////////////////////////////////////////////////////////
+char * WheatyExceptionReport::DumpTypeIndex(
+char * pszCurrBuffer,
+DWORD64 modBase,
+DWORD dwTypeIndex,
+unsigned nestingLevel,
+DWORD_PTR offset,
+bool & bHandled,
+char* Name)
+{
+ bHandled = false;
+
+ // Get the name of the symbol. This will either be a Type name (if a UDT),
+ // or the structure member name.
+ WCHAR * pwszTypeName;
+ if ( SymGetTypeInfo( m_hProcess, modBase, dwTypeIndex, TI_GET_SYMNAME,
+ &pwszTypeName ) )
+ {
+ pszCurrBuffer += sprintf( pszCurrBuffer, " %ls", pwszTypeName );
+ LocalFree( pwszTypeName );
+ }
+
+ // Determine how many children this type has.
+ DWORD dwChildrenCount = 0;
+ SymGetTypeInfo( m_hProcess, modBase, dwTypeIndex, TI_GET_CHILDRENCOUNT,
+ &dwChildrenCount );
+
+ if ( !dwChildrenCount ) // If no children, we're done
+ return pszCurrBuffer;
+
+ // Prepare to get an array of "TypeIds", representing each of the children.
+ // SymGetTypeInfo(TI_FINDCHILDREN) expects more memory than just a
+ // TI_FINDCHILDREN_PARAMS struct has. Use derivation to accomplish this.
+ struct FINDCHILDREN : TI_FINDCHILDREN_PARAMS
+ {
+ ULONG MoreChildIds[1024];
+ FINDCHILDREN(){Count = sizeof(MoreChildIds) / sizeof(MoreChildIds[0]);}
+ } children;
+
+ children.Count = dwChildrenCount;
+ children.Start= 0;
+
+ // Get the array of TypeIds, one for each child type
+ if ( !SymGetTypeInfo( m_hProcess, modBase, dwTypeIndex, TI_FINDCHILDREN,
+ &children ) )
+ {
+ return pszCurrBuffer;
+ }
+
+ // Append a line feed
+ pszCurrBuffer += sprintf( pszCurrBuffer, "\r\n" );
+
+ // Iterate through each of the children
+ for ( unsigned i = 0; i < dwChildrenCount; i++ )
+ {
+ // Add appropriate indentation level (since this routine is recursive)
+ for ( unsigned j = 0; j <= nestingLevel+1; j++ )
+ pszCurrBuffer += sprintf( pszCurrBuffer, "\t" );
+
+ // Recurse for each of the child types
+ bool bHandled2;
+ BasicType basicType = GetBasicType(children.ChildId[i], modBase );
+ pszCurrBuffer += sprintf( pszCurrBuffer, rgBaseType[basicType]);
+
+ pszCurrBuffer = DumpTypeIndex( pszCurrBuffer, modBase,
+ children.ChildId[i], nestingLevel+1,
+ offset, bHandled2, ""/*Name */);
+
+ // If the child wasn't a UDT, format it appropriately
+ if ( !bHandled2 )
+ {
+ // Get the offset of the child member, relative to its parent
+ DWORD dwMemberOffset;
+ SymGetTypeInfo( m_hProcess, modBase, children.ChildId[i],
+ TI_GET_OFFSET, &dwMemberOffset );
+
+ // Get the real "TypeId" of the child. We need this for the
+ // SymGetTypeInfo( TI_GET_TYPEID ) call below.
+ DWORD typeId;
+ SymGetTypeInfo( m_hProcess, modBase, children.ChildId[i],
+ TI_GET_TYPEID, &typeId );
+
+ // Get the size of the child member
+ ULONG64 length;
+ SymGetTypeInfo(m_hProcess, modBase, typeId, TI_GET_LENGTH,&length);
+
+ // Calculate the address of the member
+ DWORD_PTR dwFinalOffset = offset + dwMemberOffset;
+
+ // BasicType basicType = GetBasicType(children.ChildId[i], modBase );
+ //
+ // pszCurrBuffer += sprintf( pszCurrBuffer, rgBaseType[basicType]);
+ //
+ // Emit the variable name
+ // pszCurrBuffer += sprintf( pszCurrBuffer, "\'%s\'", Name );
+
+ pszCurrBuffer = FormatOutputValue( pszCurrBuffer, basicType,
+ length, (PVOID)dwFinalOffset );
+
+ pszCurrBuffer += sprintf( pszCurrBuffer, "\r\n" );
+ }
+ }
+
+ bHandled = true;
+ return pszCurrBuffer;
+}
+
+char * WheatyExceptionReport::FormatOutputValue( char * pszCurrBuffer,
+BasicType basicType,
+DWORD64 length,
+PVOID pAddress )
+{
+ // Format appropriately (assuming it's a 1, 2, or 4 bytes (!!!)
+ if ( length == 1 )
+ pszCurrBuffer += sprintf( pszCurrBuffer, " = %X", *(PBYTE)pAddress );
+ else if ( length == 2 )
+ pszCurrBuffer += sprintf( pszCurrBuffer, " = %X", *(PWORD)pAddress );
+ else if ( length == 4 )
+ {
+ if ( basicType == btFloat )
+ {
+ pszCurrBuffer += sprintf(pszCurrBuffer," = %f", *(PFLOAT)pAddress);
+ }
+ else if ( basicType == btChar )
+ {
+ if ( !IsBadStringPtr( *(PSTR*)pAddress, 32) )
+ {
+ pszCurrBuffer += sprintf( pszCurrBuffer, " = \"%.31s\"",
+ *(PDWORD)pAddress );
+ }
+ else
+ pszCurrBuffer += sprintf( pszCurrBuffer, " = %X",
+ *(PDWORD)pAddress );
+ }
+ else
+ pszCurrBuffer += sprintf(pszCurrBuffer," = %X", *(PDWORD)pAddress);
+ }
+ else if ( length == 8 )
+ {
+ if ( basicType == btFloat )
+ {
+ pszCurrBuffer += sprintf( pszCurrBuffer, " = %lf",
+ *(double *)pAddress );
+ }
+ else
+ pszCurrBuffer += sprintf( pszCurrBuffer, " = %I64X",
+ *(DWORD64*)pAddress );
+ }
+
+ return pszCurrBuffer;
+}
+
+BasicType
+WheatyExceptionReport::GetBasicType( DWORD typeIndex, DWORD64 modBase )
+{
+ BasicType basicType;
+ if ( SymGetTypeInfo( m_hProcess, modBase, typeIndex,
+ TI_GET_BASETYPE, &basicType ) )
+ {
+ return basicType;
+ }
+
+ // Get the real "TypeId" of the child. We need this for the
+ // SymGetTypeInfo( TI_GET_TYPEID ) call below.
+ DWORD typeId;
+ if (SymGetTypeInfo(m_hProcess,modBase, typeIndex, TI_GET_TYPEID, &typeId))
+ {
+ if ( SymGetTypeInfo( m_hProcess, modBase, typeId, TI_GET_BASETYPE,
+ &basicType ) )
+ {
+ return basicType;
+ }
+ }
+
+ return btNoType;
+}
+
+//============================================================================
+// Helper function that writes to the report file, and allows the user to use
+// printf style formating
+//============================================================================
+int __cdecl WheatyExceptionReport::_tprintf(const TCHAR * format, ...)
+{
+ TCHAR szBuff[1024];
+ int retValue;
+ DWORD cbWritten;
+ va_list argptr;
+
+ va_start( argptr, format );
+ retValue = vsprintf( szBuff, format, argptr );
+ va_end( argptr );
+
+ WriteFile(m_hReportFile, szBuff, retValue * sizeof(TCHAR), &cbWritten, 0 );
+
+ return retValue;
+}
diff --git a/src/shared/WheatyExceptionReport.h b/src/shared/WheatyExceptionReport.h
index 055da9a7a5d..896d9c72f36 100644
--- a/src/shared/WheatyExceptionReport.h
+++ b/src/shared/WheatyExceptionReport.h
@@ -1,117 +1,117 @@
-#ifndef _WHEATYEXCEPTIONREPORT_
-#define _WHEATYEXCEPTIONREPORT_
-
-#include <dbghelp.h>
-
-#if _MSC_VER < 1400
-# define countof(array) (sizeof(array) / sizeof(array[0]))
-#else
-# include <stdlib.h>
-# define countof _countof
-#endif // _MSC_VER < 1400
-
-enum BasicType // Stolen from CVCONST.H in the DIA 2.0 SDK
-{
- btNoType = 0,
- btVoid = 1,
- btChar = 2,
- btWChar = 3,
- btInt = 6,
- btUInt = 7,
- btFloat = 8,
- btBCD = 9,
- btBool = 10,
- btLong = 13,
- btULong = 14,
- btCurrency = 25,
- btDate = 26,
- btVariant = 27,
- btComplex = 28,
- btBit = 29,
- btBSTR = 30,
- btHresult = 31
-};
-
-const char* const rgBaseType[] =
-{
- " <user defined> ", // btNoType = 0,
- " void ", // btVoid = 1,
- " char* ", // btChar = 2,
- " wchar_t* ", // btWChar = 3,
- " signed char ",
- " unsigned char ",
- " int ", // btInt = 6,
- " unsigned int ", // btUInt = 7,
- " float ", // btFloat = 8,
- " <BCD> ", // btBCD = 9,
- " bool ", // btBool = 10,
- " short ",
- " unsigned short ",
- " long ", // btLong = 13,
- " unsigned long ", // btULong = 14,
- " __int8 ",
- " __int16 ",
- " __int32 ",
- " __int64 ",
- " __int128 ",
- " unsigned __int8 ",
- " unsigned __int16 ",
- " unsigned __int32 ",
- " unsigned __int64 ",
- " unsigned __int128 ",
- " <currency> ", // btCurrency = 25,
- " <date> ", // btDate = 26,
- " VARIANT ", // btVariant = 27,
- " <complex> ", // btComplex = 28,
- " <bit> ", // btBit = 29,
- " BSTR ", // btBSTR = 30,
- " HRESULT " // btHresult = 31
-};
-
-class WheatyExceptionReport
-{
- public:
-
- WheatyExceptionReport( );
- ~WheatyExceptionReport( );
-
- // entry point where control comes on an unhandled exception
- static LONG WINAPI WheatyUnhandledExceptionFilter(
- PEXCEPTION_POINTERS pExceptionInfo );
-
- static void printTracesForAllThreads();
- private:
- // where report info is extracted and generated
- static void GenerateExceptionReport( PEXCEPTION_POINTERS pExceptionInfo );
- static void PrintSystemInfo();
- static BOOL _GetWindowsVersion(TCHAR* szVersion, DWORD cntMax);
- static BOOL _GetProcessorName(TCHAR* sProcessorName, DWORD maxcount);
-
- // Helper functions
- static LPTSTR GetExceptionString( DWORD dwCode );
- static BOOL GetLogicalAddress( PVOID addr, PTSTR szModule, DWORD len,
- DWORD& section, DWORD_PTR& offset );
-
- static void WriteStackDetails( PCONTEXT pContext, bool bWriteVariables, HANDLE pThreadHandle);
-
- static BOOL CALLBACK EnumerateSymbolsCallback(PSYMBOL_INFO,ULONG, PVOID);
-
- static bool FormatSymbolValue( PSYMBOL_INFO, STACKFRAME *, char * pszBuffer, unsigned cbBuffer );
-
- static char * DumpTypeIndex( char *, DWORD64, DWORD, unsigned, DWORD_PTR, bool & , char*);
-
- static char * FormatOutputValue( char * pszCurrBuffer, BasicType basicType, DWORD64 length, PVOID pAddress );
-
- static BasicType GetBasicType( DWORD typeIndex, DWORD64 modBase );
-
- static int __cdecl _tprintf(const TCHAR * format, ...);
-
- // Variables used by the class
- static TCHAR m_szLogFileName[MAX_PATH];
- static LPTOP_LEVEL_EXCEPTION_FILTER m_previousFilter;
- static HANDLE m_hReportFile;
- static HANDLE m_hProcess;
-};
-
-extern WheatyExceptionReport g_WheatyExceptionReport; // global instance of class
-#endif //WheatyExceptionReport
+#ifndef _WHEATYEXCEPTIONREPORT_
+#define _WHEATYEXCEPTIONREPORT_
+
+#include <dbghelp.h>
+
+#if _MSC_VER < 1400
+# define countof(array) (sizeof(array) / sizeof(array[0]))
+#else
+# include <stdlib.h>
+# define countof _countof
+#endif // _MSC_VER < 1400
+
+enum BasicType // Stolen from CVCONST.H in the DIA 2.0 SDK
+{
+ btNoType = 0,
+ btVoid = 1,
+ btChar = 2,
+ btWChar = 3,
+ btInt = 6,
+ btUInt = 7,
+ btFloat = 8,
+ btBCD = 9,
+ btBool = 10,
+ btLong = 13,
+ btULong = 14,
+ btCurrency = 25,
+ btDate = 26,
+ btVariant = 27,
+ btComplex = 28,
+ btBit = 29,
+ btBSTR = 30,
+ btHresult = 31
+};
+
+const char* const rgBaseType[] =
+{
+ " <user defined> ", // btNoType = 0,
+ " void ", // btVoid = 1,
+ " char* ", // btChar = 2,
+ " wchar_t* ", // btWChar = 3,
+ " signed char ",
+ " unsigned char ",
+ " int ", // btInt = 6,
+ " unsigned int ", // btUInt = 7,
+ " float ", // btFloat = 8,
+ " <BCD> ", // btBCD = 9,
+ " bool ", // btBool = 10,
+ " short ",
+ " unsigned short ",
+ " long ", // btLong = 13,
+ " unsigned long ", // btULong = 14,
+ " __int8 ",
+ " __int16 ",
+ " __int32 ",
+ " __int64 ",
+ " __int128 ",
+ " unsigned __int8 ",
+ " unsigned __int16 ",
+ " unsigned __int32 ",
+ " unsigned __int64 ",
+ " unsigned __int128 ",
+ " <currency> ", // btCurrency = 25,
+ " <date> ", // btDate = 26,
+ " VARIANT ", // btVariant = 27,
+ " <complex> ", // btComplex = 28,
+ " <bit> ", // btBit = 29,
+ " BSTR ", // btBSTR = 30,
+ " HRESULT " // btHresult = 31
+};
+
+class WheatyExceptionReport
+{
+ public:
+
+ WheatyExceptionReport( );
+ ~WheatyExceptionReport( );
+
+ // entry point where control comes on an unhandled exception
+ static LONG WINAPI WheatyUnhandledExceptionFilter(
+ PEXCEPTION_POINTERS pExceptionInfo );
+
+ static void printTracesForAllThreads();
+ private:
+ // where report info is extracted and generated
+ static void GenerateExceptionReport( PEXCEPTION_POINTERS pExceptionInfo );
+ static void PrintSystemInfo();
+ static BOOL _GetWindowsVersion(TCHAR* szVersion, DWORD cntMax);
+ static BOOL _GetProcessorName(TCHAR* sProcessorName, DWORD maxcount);
+
+ // Helper functions
+ static LPTSTR GetExceptionString( DWORD dwCode );
+ static BOOL GetLogicalAddress( PVOID addr, PTSTR szModule, DWORD len,
+ DWORD& section, DWORD_PTR& offset );
+
+ static void WriteStackDetails( PCONTEXT pContext, bool bWriteVariables, HANDLE pThreadHandle);
+
+ static BOOL CALLBACK EnumerateSymbolsCallback(PSYMBOL_INFO,ULONG, PVOID);
+
+ static bool FormatSymbolValue( PSYMBOL_INFO, STACKFRAME *, char * pszBuffer, unsigned cbBuffer );
+
+ static char * DumpTypeIndex( char *, DWORD64, DWORD, unsigned, DWORD_PTR, bool & , char*);
+
+ static char * FormatOutputValue( char * pszCurrBuffer, BasicType basicType, DWORD64 length, PVOID pAddress );
+
+ static BasicType GetBasicType( DWORD typeIndex, DWORD64 modBase );
+
+ static int __cdecl _tprintf(const TCHAR * format, ...);
+
+ // Variables used by the class
+ static TCHAR m_szLogFileName[MAX_PATH];
+ static LPTOP_LEVEL_EXCEPTION_FILTER m_previousFilter;
+ static HANDLE m_hReportFile;
+ static HANDLE m_hProcess;
+};
+
+extern WheatyExceptionReport g_WheatyExceptionReport; // global instance of class
+#endif //WheatyExceptionReport