SlideShare ist ein Scribd-Unternehmen logo
1 von 35
Little Known
Native Debugging Tricks

            Ofek Shilon
 Director of Algorithms @ Sarin Technologies
       www.thetweaker.wordpress.com
DISCLAIMER
VS AS AN INTERPRETER
Expression Evaluator
• Demo
• Scope
  – Watch, QuickWatch,
  – Immediate,
  – BP conditions, ‘when hit’
• Call Functions from the debugger!
Expression Evaluator
• Context Operator
  – Documentation is wrong.
  – Might require decorated names.
  – VS2010 blocked WIN-API, but eased usage of
    others.
  – VS11B supports the simpler syntax
     msvcr110d.dll!fabs(-8.0f)
Expression Evaluator
•   Thread context
•   Access insensitive
•   Blind to inlined functions
•   Things to try when evaluation fails:
    – Very explicit casting,
    – Explicit addresses.
Edit and Continue
• Demo
• Stale code
Edit and Continue
• Preparation: /ZI, /INCREMENTAL
Edit and Continue
• Limitations:
  – Inconsistent with /RELEASE, /OPT:REF, /OPT:ICF,
    /ORDER, /FORCE,
  – Does not invoke custom build steps,
  – Isn’t supported on attached processes,
  – Can’t change object layout,
  – Doesn’t regenerate IDL files,
  – Can’t change resource files,
  – Does not build static libs.
CLICK SAVERS
StepOver
• Demo
StepOver
• VC6: autoexp section [ExecutionControl]
• VC7: Reg key -
 HKCUSoftwareMicrosoftVisualStudio7.0NativeDEStepOver

• VC8:
 HKLMSoftwareMicrosoftVisualStudio8.0NativeDEStepOver

• VC10, VC11B:
 HKCUSoftwareMicrosoftVisualStudio10.0_ConfigNativeDEStepOver
 Dropped ‘=NoStepInto’ syntax
StepOver
• Warning!
  When 2 or more
  instances of VS
  are active, occasionally
  it would create and use
  a duplicate reg key



  … and all ’10.0_Config’ modifications would have no effect !
StepOver
• Credit: Andy Pennell
  http://blogs.msdn.com/b/andypennell/archive/2004/02/06/69004.aspx


• A request to make StepOver official:
  http://visualstudio.uservoice.com/forums/121579-visual-
  studio/suggestions/2668765-support-nostepinto-registry-mechanism
autoexp
• How’s the debugger ‘aware’ of STL containers?
• autoexp.dat
  – By default at
    %VS folder %Common7PackagesDebugger
autoexp
• Demo

• Specialized syntax for common containers:
  Array, List, Map, Tree.
• Re-parsed on every debugging session
• Extremely fragile, yet excellent investment
autoexp
• Status limbo:
autoexp
• Bypass file path via env var: _vcee_autoexp
• Bypass visualizer locally: xxx,!
• Bypass
  globally
  in
  Tools/Options:
autoexp
• Resources:
  – Avery Lee
    http://virtualdub.org/blog/pivot/entry.php?id=120
  – Stephan T. Lavavej BoostCon presentation
    http://filetolink.com/d/?h=a456fc7fd3d35644edcbe5e764d1ba63&t=1315076450&f=17ad36ef

  – My blog: complete MFC containers visualization, Matrix 2D
    visualization, and more
    www.thetweaker.wordpress.org
  – A request to make autoexp official:
    http://visualstudio.uservoice.com/forums/121579-visual-
    studio/suggestions/2056273-support-debug-visualizers-through-
    autoexp-dat
Sound Alerts
• Win7:
 Control Panel 
 Hardware and Sounds 
 Sound 
 Change system sounds
• WinXP:
 Control Panel 
 Sounds and Audio... 
 Program Events –
 Microsoft Developer
TRACING ERRORS
GetLastError Interactively
• GetLastError implementation:



•   (int*)($fs)+0x34
•   (int*)($tib)+0x34
•   $err !
•   Credit: msdn
    http://msdn.microsoft.com/en-us/library/dtw169z6.aspx
Extensions
• Customizing ‘,hr’ display in autoexp.dat:




• Other TEB data: (_TEB*)$tib
Breaking on Errors
• BP location: (int*)($tib)+0x34
• Specific error: BP condition
  – Slooooooooow
• g_dwLastErrorToBreakOn !
  – (int*){,,ntdll.dll}_g_dwLastErrorToBreakOn
  – Fails in VC10 over Win7. Restored in VC11B
• Credit: Daniel Pearson,
  http://blogs.msdn.com/b/danpear/archive/2007/04/06/2033100.aspx
INVESTIGATING CODE
Breaking on all class methods
• Break at function:
           Class::*

• Credit: Habib Heydarian
 http://blogs.msdn.com/b/habibh/archive/2009/09/10/class-breakpoint-
 how-to-set-a-breakpoint-on-a-c-class-in-the-visual-studio-debugger.aspx
Naming Native Threads
• Demo

• ‘Documented hack’
  Credit: MSDN
 http://msdn.microsoft.com/en-us/library/xcb2z8hs.aspx
Breaking on Data Read
• Some code required.
• Links to 4 implementations:
  http://thetweaker.wordpress.com/2011/05/22/breaking-on-data-read/


• Request to make it official:
  http://visualstudio.uservoice.com/forums/121579-visual-
  studio/suggestions/2668700-expose-break-on-read-breakpoints
Static Object Layout
• /d1reportSingleClassLayout
• /d1reportAllClassLayout


• Credit: Andy Rich
  http://blogs.msdn.com/b/vcblog/archive/2007/05/17/diagnosing-hidden-
  odr-violations-in-visual-c-and-fixing-lnk2022.aspx
ENHANCED DIAGNOSIS
Useful Pseudo-registers
• $tid
  -> very useful as a BP condition.
• $env=0
  -> view debugee environment variables
  – In VC11: just $env in watch
• $cmdline = 0
  -> view launching command line
  Credit: John Cunningham,
  http://blogs.msdn.com/b/ms_joc/archive/2004/08/23/218912.aspx
Useful Pseudo-registers
• $handles
  -> narrows down handle leaks
• $clk
  -> rough profiling
• $user
  -> view permissions info

• Credits: Steve Steiner, Gregg Miskelly, et. al.
  http://blogs.msdn.com/b/stevejs/
  http://blogs.msdn.com/b/greggm/
Searching Through Memory




• Credit: msdn
 http://msdn.microsoft.com/en-us/library/ms171363.aspx
www.thetweaker.wordpress.com
ofekshilon@gmail.com
                           THANK YOU.

Weitere ähnliche Inhalte

Was ist angesagt?

Экспресс-анализ вредоносов / Crowdsourced Malware Triage
Экспресс-анализ вредоносов / Crowdsourced Malware TriageЭкспресс-анализ вредоносов / Crowdsourced Malware Triage
Экспресс-анализ вредоносов / Crowdsourced Malware TriagePositive Hack Days
 
Windows Kernel Exploitation : This Time Font hunt you down in 4 bytes
Windows Kernel Exploitation : This Time Font hunt you down in 4 bytesWindows Kernel Exploitation : This Time Font hunt you down in 4 bytes
Windows Kernel Exploitation : This Time Font hunt you down in 4 bytesPeter Hlavaty
 
Power of linked list
Power of linked listPower of linked list
Power of linked listPeter Hlavaty
 
You didnt see it’s coming? "Dawn of hardened Windows Kernel"
You didnt see it’s coming? "Dawn of hardened Windows Kernel" You didnt see it’s coming? "Dawn of hardened Windows Kernel"
You didnt see it’s coming? "Dawn of hardened Windows Kernel" Peter Hlavaty
 
syzkaller: the next gen kernel fuzzer
syzkaller: the next gen kernel fuzzersyzkaller: the next gen kernel fuzzer
syzkaller: the next gen kernel fuzzerDmitry Vyukov
 
How to Root 10 Million Phones with One Exploit
How to Root 10 Million Phones with One ExploitHow to Root 10 Million Phones with One Exploit
How to Root 10 Million Phones with One ExploitJiahong Fang
 
TriplePlay-WebAppPenTestingTools
TriplePlay-WebAppPenTestingToolsTriplePlay-WebAppPenTestingTools
TriplePlay-WebAppPenTestingToolsYury Chemerkin
 
Modern Evasion Techniques
Modern Evasion TechniquesModern Evasion Techniques
Modern Evasion TechniquesJason Lang
 
syzbot and the tale of million kernel bugs
syzbot and the tale of million kernel bugssyzbot and the tale of million kernel bugs
syzbot and the tale of million kernel bugsDmitry Vyukov
 
Multiply your Testing Effectiveness with Parameterized Testing, v1
Multiply your Testing Effectiveness with Parameterized Testing, v1Multiply your Testing Effectiveness with Parameterized Testing, v1
Multiply your Testing Effectiveness with Parameterized Testing, v1Brian Okken
 
How Safe is your Link ?
How Safe is your Link ?How Safe is your Link ?
How Safe is your Link ?Peter Hlavaty
 
Guardians of your CODE
Guardians of your CODEGuardians of your CODE
Guardians of your CODEPeter Hlavaty
 
Статический анализ кода в контексте SSDL
Статический анализ кода в контексте SSDLСтатический анализ кода в контексте SSDL
Статический анализ кода в контексте SSDLPositive Hack Days
 
When is something overflowing
When is something overflowingWhen is something overflowing
When is something overflowingPeter Hlavaty
 
Security research over Windows #defcon china
Security research over Windows #defcon chinaSecurity research over Windows #defcon china
Security research over Windows #defcon chinaPeter Hlavaty
 

Was ist angesagt? (20)

Os Cook
Os CookOs Cook
Os Cook
 
Экспресс-анализ вредоносов / Crowdsourced Malware Triage
Экспресс-анализ вредоносов / Crowdsourced Malware TriageЭкспресс-анализ вредоносов / Crowdsourced Malware Triage
Экспресс-анализ вредоносов / Crowdsourced Malware Triage
 
Windows Kernel Exploitation : This Time Font hunt you down in 4 bytes
Windows Kernel Exploitation : This Time Font hunt you down in 4 bytesWindows Kernel Exploitation : This Time Font hunt you down in 4 bytes
Windows Kernel Exploitation : This Time Font hunt you down in 4 bytes
 
Power of linked list
Power of linked listPower of linked list
Power of linked list
 
You didnt see it’s coming? "Dawn of hardened Windows Kernel"
You didnt see it’s coming? "Dawn of hardened Windows Kernel" You didnt see it’s coming? "Dawn of hardened Windows Kernel"
You didnt see it’s coming? "Dawn of hardened Windows Kernel"
 
Racing with Droids
Racing with DroidsRacing with Droids
Racing with Droids
 
syzkaller: the next gen kernel fuzzer
syzkaller: the next gen kernel fuzzersyzkaller: the next gen kernel fuzzer
syzkaller: the next gen kernel fuzzer
 
How to Root 10 Million Phones with One Exploit
How to Root 10 Million Phones with One ExploitHow to Root 10 Million Phones with One Exploit
How to Root 10 Million Phones with One Exploit
 
TriplePlay-WebAppPenTestingTools
TriplePlay-WebAppPenTestingToolsTriplePlay-WebAppPenTestingTools
TriplePlay-WebAppPenTestingTools
 
Modern Evasion Techniques
Modern Evasion TechniquesModern Evasion Techniques
Modern Evasion Techniques
 
syzbot and the tale of million kernel bugs
syzbot and the tale of million kernel bugssyzbot and the tale of million kernel bugs
syzbot and the tale of million kernel bugs
 
Audit
AuditAudit
Audit
 
Nikto
NiktoNikto
Nikto
 
JavaCro'15 - Conquer the Internet of Things with Java and Docker - Johan Jans...
JavaCro'15 - Conquer the Internet of Things with Java and Docker - Johan Jans...JavaCro'15 - Conquer the Internet of Things with Java and Docker - Johan Jans...
JavaCro'15 - Conquer the Internet of Things with Java and Docker - Johan Jans...
 
Multiply your Testing Effectiveness with Parameterized Testing, v1
Multiply your Testing Effectiveness with Parameterized Testing, v1Multiply your Testing Effectiveness with Parameterized Testing, v1
Multiply your Testing Effectiveness with Parameterized Testing, v1
 
How Safe is your Link ?
How Safe is your Link ?How Safe is your Link ?
How Safe is your Link ?
 
Guardians of your CODE
Guardians of your CODEGuardians of your CODE
Guardians of your CODE
 
Статический анализ кода в контексте SSDL
Статический анализ кода в контексте SSDLСтатический анализ кода в контексте SSDL
Статический анализ кода в контексте SSDL
 
When is something overflowing
When is something overflowingWhen is something overflowing
When is something overflowing
 
Security research over Windows #defcon china
Security research over Windows #defcon chinaSecurity research over Windows #defcon china
Security research over Windows #defcon china
 

Ähnlich wie VS Debugging Tricks

Little Known VC++ Debugging Tricks
Little Known VC++ Debugging TricksLittle Known VC++ Debugging Tricks
Little Known VC++ Debugging TricksOfek Shilon
 
Here Be Dragons – Advanced JavaScript Debugging
Here Be Dragons – Advanced JavaScript DebuggingHere Be Dragons – Advanced JavaScript Debugging
Here Be Dragons – Advanced JavaScript DebuggingFITC
 
FITC - Here Be Dragons: Advanced JavaScript Debugging
FITC - Here Be Dragons: Advanced JavaScript DebuggingFITC - Here Be Dragons: Advanced JavaScript Debugging
FITC - Here Be Dragons: Advanced JavaScript DebuggingRami Sayar
 
Common Challenges in DevOps Change Management
Common Challenges in DevOps Change ManagementCommon Challenges in DevOps Change Management
Common Challenges in DevOps Change ManagementMatt Ray
 
Best Practices for Building WordPress Applications
Best Practices for Building WordPress ApplicationsBest Practices for Building WordPress Applications
Best Practices for Building WordPress ApplicationsTaylor Lovett
 
Web a Quebec - JS Debugging
Web a Quebec - JS DebuggingWeb a Quebec - JS Debugging
Web a Quebec - JS DebuggingRami Sayar
 
Building production websites with Node.js on the Microsoft stack
Building production websites with Node.js on the Microsoft stackBuilding production websites with Node.js on the Microsoft stack
Building production websites with Node.js on the Microsoft stackCellarTracker
 
DevOpsDaysRiga 2017: Mandi Walls - Building security into your workflow with ...
DevOpsDaysRiga 2017: Mandi Walls - Building security into your workflow with ...DevOpsDaysRiga 2017: Mandi Walls - Building security into your workflow with ...
DevOpsDaysRiga 2017: Mandi Walls - Building security into your workflow with ...DevOpsDays Riga
 
InSpec Workflow for DevOpsDays Riga 2017
InSpec Workflow for DevOpsDays Riga 2017InSpec Workflow for DevOpsDays Riga 2017
InSpec Workflow for DevOpsDays Riga 2017Mandi Walls
 
[HES2013] Virtually secure, analysis to remote root 0day on an industry leadi...
[HES2013] Virtually secure, analysis to remote root 0day on an industry leadi...[HES2013] Virtually secure, analysis to remote root 0day on an industry leadi...
[HES2013] Virtually secure, analysis to remote root 0day on an industry leadi...Hackito Ergo Sum
 
DEF CON 27 - ORANGE TSAI and MEH CHANG - infiltrating corporate intranet like...
DEF CON 27 - ORANGE TSAI and MEH CHANG - infiltrating corporate intranet like...DEF CON 27 - ORANGE TSAI and MEH CHANG - infiltrating corporate intranet like...
DEF CON 27 - ORANGE TSAI and MEH CHANG - infiltrating corporate intranet like...Felipe Prado
 
"You Don't Know NODE.JS" by Hengki Mardongan Sihombing (Urbanhire)
"You Don't Know NODE.JS" by Hengki Mardongan Sihombing (Urbanhire)"You Don't Know NODE.JS" by Hengki Mardongan Sihombing (Urbanhire)
"You Don't Know NODE.JS" by Hengki Mardongan Sihombing (Urbanhire)Tech in Asia ID
 
OSCON 2011 - Node.js Tutorial
OSCON 2011 - Node.js TutorialOSCON 2011 - Node.js Tutorial
OSCON 2011 - Node.js TutorialTom Croucher
 
Using Chef InSpec for Infrastructure Security
Using Chef InSpec for Infrastructure SecurityUsing Chef InSpec for Infrastructure Security
Using Chef InSpec for Infrastructure SecurityMandi Walls
 
On non existent 0-days, stable binary exploits and
On non existent 0-days, stable binary exploits andOn non existent 0-days, stable binary exploits and
On non existent 0-days, stable binary exploits andAlisa Esage Шевченко
 
Wireless Developing Wireless Monitoring and Control devices
Wireless Developing Wireless Monitoring and Control devicesWireless Developing Wireless Monitoring and Control devices
Wireless Developing Wireless Monitoring and Control devicesAidan Venn MSc
 
Stress Free Deployment - Confoo 2011
Stress Free Deployment  - Confoo 2011Stress Free Deployment  - Confoo 2011
Stress Free Deployment - Confoo 2011Bachkoutou Toutou
 
SharePoint 2014: Where to save my data, for devs!
SharePoint 2014: Where to save my data, for devs!SharePoint 2014: Where to save my data, for devs!
SharePoint 2014: Where to save my data, for devs!Ben Steinhauser
 
Add-On Development: EE Expects that Every Developer will do his Duty
Add-On Development: EE Expects that Every Developer will do his DutyAdd-On Development: EE Expects that Every Developer will do his Duty
Add-On Development: EE Expects that Every Developer will do his Dutyreedmaniac
 

Ähnlich wie VS Debugging Tricks (20)

Little Known VC++ Debugging Tricks
Little Known VC++ Debugging TricksLittle Known VC++ Debugging Tricks
Little Known VC++ Debugging Tricks
 
Here Be Dragons – Advanced JavaScript Debugging
Here Be Dragons – Advanced JavaScript DebuggingHere Be Dragons – Advanced JavaScript Debugging
Here Be Dragons – Advanced JavaScript Debugging
 
FITC - Here Be Dragons: Advanced JavaScript Debugging
FITC - Here Be Dragons: Advanced JavaScript DebuggingFITC - Here Be Dragons: Advanced JavaScript Debugging
FITC - Here Be Dragons: Advanced JavaScript Debugging
 
Common Challenges in DevOps Change Management
Common Challenges in DevOps Change ManagementCommon Challenges in DevOps Change Management
Common Challenges in DevOps Change Management
 
Best Practices for Building WordPress Applications
Best Practices for Building WordPress ApplicationsBest Practices for Building WordPress Applications
Best Practices for Building WordPress Applications
 
Web a Quebec - JS Debugging
Web a Quebec - JS DebuggingWeb a Quebec - JS Debugging
Web a Quebec - JS Debugging
 
Building production websites with Node.js on the Microsoft stack
Building production websites with Node.js on the Microsoft stackBuilding production websites with Node.js on the Microsoft stack
Building production websites with Node.js on the Microsoft stack
 
DevOpsDaysRiga 2017: Mandi Walls - Building security into your workflow with ...
DevOpsDaysRiga 2017: Mandi Walls - Building security into your workflow with ...DevOpsDaysRiga 2017: Mandi Walls - Building security into your workflow with ...
DevOpsDaysRiga 2017: Mandi Walls - Building security into your workflow with ...
 
InSpec Workflow for DevOpsDays Riga 2017
InSpec Workflow for DevOpsDays Riga 2017InSpec Workflow for DevOpsDays Riga 2017
InSpec Workflow for DevOpsDays Riga 2017
 
[HES2013] Virtually secure, analysis to remote root 0day on an industry leadi...
[HES2013] Virtually secure, analysis to remote root 0day on an industry leadi...[HES2013] Virtually secure, analysis to remote root 0day on an industry leadi...
[HES2013] Virtually secure, analysis to remote root 0day on an industry leadi...
 
DEF CON 27 - ORANGE TSAI and MEH CHANG - infiltrating corporate intranet like...
DEF CON 27 - ORANGE TSAI and MEH CHANG - infiltrating corporate intranet like...DEF CON 27 - ORANGE TSAI and MEH CHANG - infiltrating corporate intranet like...
DEF CON 27 - ORANGE TSAI and MEH CHANG - infiltrating corporate intranet like...
 
"You Don't Know NODE.JS" by Hengki Mardongan Sihombing (Urbanhire)
"You Don't Know NODE.JS" by Hengki Mardongan Sihombing (Urbanhire)"You Don't Know NODE.JS" by Hengki Mardongan Sihombing (Urbanhire)
"You Don't Know NODE.JS" by Hengki Mardongan Sihombing (Urbanhire)
 
OSCON 2011 - Node.js Tutorial
OSCON 2011 - Node.js TutorialOSCON 2011 - Node.js Tutorial
OSCON 2011 - Node.js Tutorial
 
Using Chef InSpec for Infrastructure Security
Using Chef InSpec for Infrastructure SecurityUsing Chef InSpec for Infrastructure Security
Using Chef InSpec for Infrastructure Security
 
On non existent 0-days, stable binary exploits and
On non existent 0-days, stable binary exploits andOn non existent 0-days, stable binary exploits and
On non existent 0-days, stable binary exploits and
 
Wireless Developing Wireless Monitoring and Control devices
Wireless Developing Wireless Monitoring and Control devicesWireless Developing Wireless Monitoring and Control devices
Wireless Developing Wireless Monitoring and Control devices
 
Stress Free Deployment - Confoo 2011
Stress Free Deployment  - Confoo 2011Stress Free Deployment  - Confoo 2011
Stress Free Deployment - Confoo 2011
 
SharePoint 2014: Where to save my data, for devs!
SharePoint 2014: Where to save my data, for devs!SharePoint 2014: Where to save my data, for devs!
SharePoint 2014: Where to save my data, for devs!
 
Add-On Development: EE Expects that Every Developer will do his Duty
Add-On Development: EE Expects that Every Developer will do his DutyAdd-On Development: EE Expects that Every Developer will do his Duty
Add-On Development: EE Expects that Every Developer will do his Duty
 
presentation
presentationpresentation
presentation
 

Mehr von Sasha Goldshtein

Modern Linux Tracing Landscape
Modern Linux Tracing LandscapeModern Linux Tracing Landscape
Modern Linux Tracing LandscapeSasha Goldshtein
 
The Next Linux Superpower: eBPF Primer
The Next Linux Superpower: eBPF PrimerThe Next Linux Superpower: eBPF Primer
The Next Linux Superpower: eBPF PrimerSasha Goldshtein
 
Staring into the eBPF Abyss
Staring into the eBPF AbyssStaring into the eBPF Abyss
Staring into the eBPF AbyssSasha Goldshtein
 
Visual Studio 2015 and the Next .NET Framework
Visual Studio 2015 and the Next .NET FrameworkVisual Studio 2015 and the Next .NET Framework
Visual Studio 2015 and the Next .NET FrameworkSasha Goldshtein
 
Swift: Apple's New Programming Language for iOS and OS X
Swift: Apple's New Programming Language for iOS and OS XSwift: Apple's New Programming Language for iOS and OS X
Swift: Apple's New Programming Language for iOS and OS XSasha Goldshtein
 
C# Everywhere: Cross-Platform Mobile Apps with Xamarin
C# Everywhere: Cross-Platform Mobile Apps with XamarinC# Everywhere: Cross-Platform Mobile Apps with Xamarin
C# Everywhere: Cross-Platform Mobile Apps with XamarinSasha Goldshtein
 
Modern Backends for Mobile Apps
Modern Backends for Mobile AppsModern Backends for Mobile Apps
Modern Backends for Mobile AppsSasha Goldshtein
 
Performance and Debugging with the Diagnostics Hub in Visual Studio 2013
Performance and Debugging with the Diagnostics Hub in Visual Studio 2013Performance and Debugging with the Diagnostics Hub in Visual Studio 2013
Performance and Debugging with the Diagnostics Hub in Visual Studio 2013Sasha Goldshtein
 
Mastering IntelliTrace in Development and Production
Mastering IntelliTrace in Development and ProductionMastering IntelliTrace in Development and Production
Mastering IntelliTrace in Development and ProductionSasha Goldshtein
 
Delivering Millions of Push Notifications in Minutes
Delivering Millions of Push Notifications in MinutesDelivering Millions of Push Notifications in Minutes
Delivering Millions of Push Notifications in MinutesSasha Goldshtein
 
Building Mobile Apps with a Mobile Services .NET Backend
Building Mobile Apps with a Mobile Services .NET BackendBuilding Mobile Apps with a Mobile Services .NET Backend
Building Mobile Apps with a Mobile Services .NET BackendSasha Goldshtein
 
Building iOS and Android Apps with Mobile Services
Building iOS and Android Apps with Mobile ServicesBuilding iOS and Android Apps with Mobile Services
Building iOS and Android Apps with Mobile ServicesSasha Goldshtein
 
Attacking Web Applications
Attacking Web ApplicationsAttacking Web Applications
Attacking Web ApplicationsSasha Goldshtein
 
Windows Azure Mobile Services
Windows Azure Mobile ServicesWindows Azure Mobile Services
Windows Azure Mobile ServicesSasha Goldshtein
 
First Steps in Android Development
First Steps in Android DevelopmentFirst Steps in Android Development
First Steps in Android DevelopmentSasha Goldshtein
 
First Steps in iOS Development
First Steps in iOS DevelopmentFirst Steps in iOS Development
First Steps in iOS DevelopmentSasha Goldshtein
 

Mehr von Sasha Goldshtein (20)

Modern Linux Tracing Landscape
Modern Linux Tracing LandscapeModern Linux Tracing Landscape
Modern Linux Tracing Landscape
 
The Next Linux Superpower: eBPF Primer
The Next Linux Superpower: eBPF PrimerThe Next Linux Superpower: eBPF Primer
The Next Linux Superpower: eBPF Primer
 
Staring into the eBPF Abyss
Staring into the eBPF AbyssStaring into the eBPF Abyss
Staring into the eBPF Abyss
 
Visual Studio 2015 and the Next .NET Framework
Visual Studio 2015 and the Next .NET FrameworkVisual Studio 2015 and the Next .NET Framework
Visual Studio 2015 and the Next .NET Framework
 
Swift: Apple's New Programming Language for iOS and OS X
Swift: Apple's New Programming Language for iOS and OS XSwift: Apple's New Programming Language for iOS and OS X
Swift: Apple's New Programming Language for iOS and OS X
 
C# Everywhere: Cross-Platform Mobile Apps with Xamarin
C# Everywhere: Cross-Platform Mobile Apps with XamarinC# Everywhere: Cross-Platform Mobile Apps with Xamarin
C# Everywhere: Cross-Platform Mobile Apps with Xamarin
 
Modern Backends for Mobile Apps
Modern Backends for Mobile AppsModern Backends for Mobile Apps
Modern Backends for Mobile Apps
 
Performance and Debugging with the Diagnostics Hub in Visual Studio 2013
Performance and Debugging with the Diagnostics Hub in Visual Studio 2013Performance and Debugging with the Diagnostics Hub in Visual Studio 2013
Performance and Debugging with the Diagnostics Hub in Visual Studio 2013
 
Mastering IntelliTrace in Development and Production
Mastering IntelliTrace in Development and ProductionMastering IntelliTrace in Development and Production
Mastering IntelliTrace in Development and Production
 
Introduction to RavenDB
Introduction to RavenDBIntroduction to RavenDB
Introduction to RavenDB
 
State of the Platforms
State of the PlatformsState of the Platforms
State of the Platforms
 
Delivering Millions of Push Notifications in Minutes
Delivering Millions of Push Notifications in MinutesDelivering Millions of Push Notifications in Minutes
Delivering Millions of Push Notifications in Minutes
 
Building Mobile Apps with a Mobile Services .NET Backend
Building Mobile Apps with a Mobile Services .NET BackendBuilding Mobile Apps with a Mobile Services .NET Backend
Building Mobile Apps with a Mobile Services .NET Backend
 
Building iOS and Android Apps with Mobile Services
Building iOS and Android Apps with Mobile ServicesBuilding iOS and Android Apps with Mobile Services
Building iOS and Android Apps with Mobile Services
 
Task and Data Parallelism
Task and Data ParallelismTask and Data Parallelism
Task and Data Parallelism
 
What's New in C++ 11?
What's New in C++ 11?What's New in C++ 11?
What's New in C++ 11?
 
Attacking Web Applications
Attacking Web ApplicationsAttacking Web Applications
Attacking Web Applications
 
Windows Azure Mobile Services
Windows Azure Mobile ServicesWindows Azure Mobile Services
Windows Azure Mobile Services
 
First Steps in Android Development
First Steps in Android DevelopmentFirst Steps in Android Development
First Steps in Android Development
 
First Steps in iOS Development
First Steps in iOS DevelopmentFirst Steps in iOS Development
First Steps in iOS Development
 

Kürzlich hochgeladen

Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Manik S Magar
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostZilliz
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024The Digital Insurer
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embeddingZilliz
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 

Kürzlich hochgeladen (20)

Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embedding
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 

VS Debugging Tricks

  • 1. Little Known Native Debugging Tricks Ofek Shilon Director of Algorithms @ Sarin Technologies www.thetweaker.wordpress.com
  • 2.
  • 4. VS AS AN INTERPRETER
  • 5. Expression Evaluator • Demo • Scope – Watch, QuickWatch, – Immediate, – BP conditions, ‘when hit’ • Call Functions from the debugger!
  • 6. Expression Evaluator • Context Operator – Documentation is wrong. – Might require decorated names. – VS2010 blocked WIN-API, but eased usage of others. – VS11B supports the simpler syntax msvcr110d.dll!fabs(-8.0f)
  • 7. Expression Evaluator • Thread context • Access insensitive • Blind to inlined functions • Things to try when evaluation fails: – Very explicit casting, – Explicit addresses.
  • 8. Edit and Continue • Demo • Stale code
  • 9. Edit and Continue • Preparation: /ZI, /INCREMENTAL
  • 10. Edit and Continue • Limitations: – Inconsistent with /RELEASE, /OPT:REF, /OPT:ICF, /ORDER, /FORCE, – Does not invoke custom build steps, – Isn’t supported on attached processes, – Can’t change object layout, – Doesn’t regenerate IDL files, – Can’t change resource files, – Does not build static libs.
  • 13. StepOver • VC6: autoexp section [ExecutionControl] • VC7: Reg key - HKCUSoftwareMicrosoftVisualStudio7.0NativeDEStepOver • VC8: HKLMSoftwareMicrosoftVisualStudio8.0NativeDEStepOver • VC10, VC11B: HKCUSoftwareMicrosoftVisualStudio10.0_ConfigNativeDEStepOver Dropped ‘=NoStepInto’ syntax
  • 14. StepOver • Warning! When 2 or more instances of VS are active, occasionally it would create and use a duplicate reg key … and all ’10.0_Config’ modifications would have no effect !
  • 15. StepOver • Credit: Andy Pennell http://blogs.msdn.com/b/andypennell/archive/2004/02/06/69004.aspx • A request to make StepOver official: http://visualstudio.uservoice.com/forums/121579-visual- studio/suggestions/2668765-support-nostepinto-registry-mechanism
  • 16. autoexp • How’s the debugger ‘aware’ of STL containers? • autoexp.dat – By default at %VS folder %Common7PackagesDebugger
  • 17. autoexp • Demo • Specialized syntax for common containers: Array, List, Map, Tree. • Re-parsed on every debugging session • Extremely fragile, yet excellent investment
  • 19. autoexp • Bypass file path via env var: _vcee_autoexp • Bypass visualizer locally: xxx,! • Bypass globally in Tools/Options:
  • 20. autoexp • Resources: – Avery Lee http://virtualdub.org/blog/pivot/entry.php?id=120 – Stephan T. Lavavej BoostCon presentation http://filetolink.com/d/?h=a456fc7fd3d35644edcbe5e764d1ba63&t=1315076450&f=17ad36ef – My blog: complete MFC containers visualization, Matrix 2D visualization, and more www.thetweaker.wordpress.org – A request to make autoexp official: http://visualstudio.uservoice.com/forums/121579-visual- studio/suggestions/2056273-support-debug-visualizers-through- autoexp-dat
  • 21. Sound Alerts • Win7: Control Panel Hardware and Sounds Sound Change system sounds • WinXP: Control Panel Sounds and Audio... Program Events – Microsoft Developer
  • 23. GetLastError Interactively • GetLastError implementation: • (int*)($fs)+0x34 • (int*)($tib)+0x34 • $err ! • Credit: msdn http://msdn.microsoft.com/en-us/library/dtw169z6.aspx
  • 24. Extensions • Customizing ‘,hr’ display in autoexp.dat: • Other TEB data: (_TEB*)$tib
  • 25. Breaking on Errors • BP location: (int*)($tib)+0x34 • Specific error: BP condition – Slooooooooow • g_dwLastErrorToBreakOn ! – (int*){,,ntdll.dll}_g_dwLastErrorToBreakOn – Fails in VC10 over Win7. Restored in VC11B • Credit: Daniel Pearson, http://blogs.msdn.com/b/danpear/archive/2007/04/06/2033100.aspx
  • 27. Breaking on all class methods • Break at function: Class::* • Credit: Habib Heydarian http://blogs.msdn.com/b/habibh/archive/2009/09/10/class-breakpoint- how-to-set-a-breakpoint-on-a-c-class-in-the-visual-studio-debugger.aspx
  • 28. Naming Native Threads • Demo • ‘Documented hack’ Credit: MSDN http://msdn.microsoft.com/en-us/library/xcb2z8hs.aspx
  • 29. Breaking on Data Read • Some code required. • Links to 4 implementations: http://thetweaker.wordpress.com/2011/05/22/breaking-on-data-read/ • Request to make it official: http://visualstudio.uservoice.com/forums/121579-visual- studio/suggestions/2668700-expose-break-on-read-breakpoints
  • 30. Static Object Layout • /d1reportSingleClassLayout • /d1reportAllClassLayout • Credit: Andy Rich http://blogs.msdn.com/b/vcblog/archive/2007/05/17/diagnosing-hidden- odr-violations-in-visual-c-and-fixing-lnk2022.aspx
  • 32. Useful Pseudo-registers • $tid -> very useful as a BP condition. • $env=0 -> view debugee environment variables – In VC11: just $env in watch • $cmdline = 0 -> view launching command line Credit: John Cunningham, http://blogs.msdn.com/b/ms_joc/archive/2004/08/23/218912.aspx
  • 33. Useful Pseudo-registers • $handles -> narrows down handle leaks • $clk -> rough profiling • $user -> view permissions info • Credits: Steve Steiner, Gregg Miskelly, et. al. http://blogs.msdn.com/b/stevejs/ http://blogs.msdn.com/b/greggm/
  • 34. Searching Through Memory • Credit: msdn http://msdn.microsoft.com/en-us/library/ms171363.aspx

Hinweis der Redaktion

  1. C++התחלות שלא הבשילו בזמןמקור עיקרי – בלוגים של מפתחי VSדברים מאד שימושיים – לחלק שמתי בקשות להפוך לפיצ'רים רשמייםVS2010 / VS2011B
  2. Many people think that editing variables is the most they can intervene with the debugeeEdit variables, move execution around
  3. אינליין – רלבנטי בRELEASE
  4. Break *before* code change, greatly reduces the chance of stale codeUse directX sample!
  5. Incremental linking: pads functions code, contains jump thunks to handle function relocationInconsistent with /OPT:REF, /OPT:ICF, /ORDER, /RELEASE, /FORCESome changes are too great, full linking occurs.All options are on by default in debug
  6. 2005: for all users
  7. comment std::vector רפרוף בסיסי על הסינטקס, רפרנסים טובים בסוףInsert carray childrenCarray previewVect3d preview
  8. טוב גם לבדוק שם אם נדמה שלא פועל
  9. כשיודעים מה לחפש – מוצאים המון
  10. לא מוחבא ברג'יסטרי, יש UI, אבל במקום ממש לא סביר ורחוק מאד מVS עצמוהועף ב2005, הוחזר ב2008 לקול מחאות הציבור
  11. Code: ::DeleteFile, GetLastError$fs fakes it...(int*)($fs)+0x18(int*)($tib)+0x34$errFormatting strings:12.3412.34,g$err,hr(_TEB*)$tib
  12. HRESULT customization doesn’t even require debugger restart!!_TEB is not defined publically, but the debugger is aware of it. Contains much useful data for advanced scenarios (fiber-specific data, etc)
  13. Doesn’t work for templated classes/methodsDoesn’t extend to wildcards/regexGood way to find entry points
  14. No ‘name’ slot in TEB
  15. Write-to BPs are implemented in hardware – dedicated x86 debug registers.Read-from debugs registers are available too, but were never exposed in VS.Some code required Maybe historical portability constraints? Dunno4 very similar implementations
  16. Not investigating code *flow* - static feature.After /d1reportSingleClassLayout, type immediatelly your classTest: /d1reportSingleClassLayoutCDialog . show vftable, alignment, adjustorsDebug ODR violationsOptimize storageGain deep insightSince VS2010, collides with /showIncludes (?)Watch out for PCH – if your class definition isn’t compiled, its layout won’t be shown
  17. $cmdline credit: John Cunningham, http://blogs.msdn.com/b/ms_joc/archive/2004/08/23/218912.aspx$env=0 no longer works in VS2010
  18. Demo – on envvars.S -U 0x006fdad0 60 "ALLUSERSPROFILE"שימושי בדיבוג של דמפים מלאים