SlideShare uma empresa Scribd logo
1 de 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.

Mais conteúdo relacionado

Mais procurados

Экспресс-анализ вредоносов / 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
 

Mais procurados (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
 

Semelhante a 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
 

Semelhante a 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
 

Mais de 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
 

Mais de 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
 

Último

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingEdi Saputra
 
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Principled Technologies
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesBoston Institute of Analytics
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024The Digital Insurer
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 

Último (20)

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 

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

Notas do Editor

  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"שימושי בדיבוג של דמפים מלאים