debug page 2 - Dave's Blog

Search
My timeline on Mastodon

Time/Date Conversion Tool

2009 Aug 28, 3:39

I built timestamp.exe, a Windows command line tool to convert between computer and human readable date/time formats mostly for working on the first run wizard for IE8. We commonly write out our dates in binary form to the registry and in order to test and debug my work it became useful to be able to determine to what date the binary value of a FILETIME or SYSTEMTIME corresponded or to produce my own binary value of a FILETIME and insert it into the registry.

For instance, to convert to a binary value:

[PS C:\] timestamp -inString 2009/08/28:10:18 -outHexValue -convert filetime
2009/08/28:10:18 as FILETIME: 00 7c c8 d1 c8 27 ca 01

Converting in the other direction, if you don't know what format the bytes are in, just feed them in and timestamp will try all conversions and list only the valid ones:

[PS C:\] timestamp -inHexValue  "40 52 1c 3b"
40 52 1c 3b as FILETIME: 1601-01-01:00:01:39.171
40 52 1c 3b as Unix Time: 2001-06-05:03:30:08.000
40 52 1c 3b as DOS Time: 2009-08-28:10:18:00.000
(it also supports OLE Dates, and SYSTEMTIME which aren't listed there because the hex value isn't valid for those types). Or use the guess option to get timestamp's best guess:
[PS C:\] timestamp -inHexValue  "40 52 1c 3b" -convert guess
40 52 1c 3b as DOS Time: 2009-08-28:10:18:00.000

When I first wrote this I had a bug in my function that parses the date-time value string in which I could parse 2009-07-02:10:18 just fine, but I wouldn't be able to parse 2009-09-02:10:18 correctly. This was my code:

success = swscanf_s(timeString, L"%hi%*[\\/- ,]%hi%*[\\/- ,]%hi%*[\\/- ,Tt:.]%hi%*[:.]%hi%*[:.]%hi%*[:.]%hi", 
&systemTime->wYear,
&systemTime->wMonth,
&systemTime->wDay,
&systemTime->wHour,
&systemTime->wMinute,
&systemTime->wSecond,
&systemTime->wMilliseconds) > 1;
See the problem?

To convert between these various forms yourself read The Old New Thing date conversion article or Josh Poley's date time article. I previously wrote about date formats I like and dislike.

PermalinkCommentsdate date-time technical time windows tool

Creating Accelerators for Other People's Web Services

2009 Aug 18, 4:19

Before we shipped IE8 there were no Accelerators, so we had some fun making our own for our favorite web services. I've got a small set of tips for creating Accelerators for other people's web services. I was planning on writing this up as an IE blog post, but Jon wrote a post covering a similar area so rather than write a full and coherent blog post I'll just list a few points:

PermalinkCommentstechnical accelerator ie8 ie

The Old New Thing : The history of calling conventions, part 5: amd64

2009 Apr 1, 6:19"The first four parameters to a function are passed in rcx, rdx, r8 and r9. Any further parameters are pushed on the stack. Furthermore, space for the register parameters is reserved on the stack, in case the called function wants to spill them; this is important if the function is variadic."PermalinkCommentsamd64 calling-convention debug x64 msdn raymond-chen assembly

The 'Is It UTF-8?' Quick and Dirty Test

2009 Mar 6, 5:16

I've found while debugging networking in IE its often useful to quickly tell if a string is encoded in UTF-8. You can check for the Byte Order Mark (EF BB BF in UTF-8) but, I rarely see the BOM on UTF-8 strings. Instead I apply a quick and dirty UTF-8 test that takes advantage of the well-formed UTF-8 restrictions.

Unlike other multibyte character encoding forms (see Windows supported character sets or IANA's list of character sets), for example Big5, where sticking together any two bytes is more likely than not to give a valid byte sequence, UTF-8 is more restrictive. And unlike other multibyte character encodings, UTF-8 bytes may be taken out of context and one can still know that its a single byte character, the starting byte of a three byte sequence, etc.

The full rules for well-formed UTF-8 are a little too complicated for me to commit to memory. Instead I've got my own simpler (this is the quick part) set of rules that will be mostly correct (this is the dirty part). For as many bytes in the string as you care to examine, check the most significant digit of the byte:

F:
This is byte 1 of a 4 byte encoded codepoint and must be followed by 3 trail bytes.
E:
This is byte 1 of a 3 byte encoded codepoint and must be followed by 2 trail bytes.
C..D:
This is byte 1 of a 2 byte encoded codepoint and must be followed by 1 trail byte.
8..B:
This is a trail byte.
0..7:
This is a single byte encoded codepoint.
The simpler rules can produce false positives in some cases: that is, they'll say a string is UTF-8 when in fact it might not be. But it won't produce false negatives. The following is table from the Unicode spec. that actually describes well-formed UTF-8.
Code Points 1st Byte 2nd Byte 3rd Byte 4th Byte
U+0000..U+007F 00..7F
U+0080..U+07FF C2..DF 80..BF
U+0800..U+0FFF E0 A0..BF 80..BF
U+1000..U+CFFF E1..EC 80..BF 80..BF
U+D000..U+D7FF ED 80..9F 80..BF
U+E000..U+FFFF EE..EF 80..BF 80..BF
U+10000..U+3FFFF F0 90..BF 80..BF 80..BF
U+40000..U+FFFFF F1..F3 80..BF 80..BF 80..BF
U+100000..U+10FFFF F4 80..8F 80..BF 80..BF

PermalinkCommentstest technical unicode boring charset utf8 encoding

QuickBase Formula Pretty Printer and Syntax Highlighter

2008 Oct 5, 9:17

Sarah asked me if I knew of a syntax highlighter for the QuickBase formula language which she uses at work. I couldn't find one but thought it might be fun to make a QuickBase Formula syntax highlighter based on the QuickBase help's description of the formula syntax. Thankfully the language is relatively simple since my skills with ANTLR, the parser generator, are rusty now and I've only used it previously for personal projects (like Javaish, the ridiculous Java based shell idea I had).

With the help of some great ANTLR examples and an ANTLR cheat sheet I was able to come up with the grammar that parses the QuickBase Formula syntax and prints out the same formula marked up with HTML SPAN tags and various CSS classes. ANTLR produces the parser in Java which I wrapped up in an applet, put in a jar, and embedded in an HTML page. The script in that page runs user input through the applet's parser and sticks the output at the bottom of the page with appropriate CSS rules to highlight and print the formula in a pretty fashion.

What I learned:

PermalinkCommentsjava technical programming quickbase language antlr antlrworks

ANTLRWorks: The ANTLR GUI Development Environment

2008 Oct 2, 9:37Cool graphical ANTLR IDE! They didn't have this the last time I used ANTLR. "ANTLRWorks is a novel grammar development environment for ANTLR v3 grammars written by Jean Bovet (with suggested use cases from Terence Parr). It combines an excellent grammar-aware editor with an interpreter for rapid prototyping and a language-agnostic debugger for isolating grammar errors. ANTLRWorks helps eliminate grammar nondeterminisms, one of the most difficult problems for beginners and experts alike, by highlighting nondeterministic paths in the syntax diagram associated with a grammar."PermalinkCommentsantlr ide graph grammar tool free download development opensource java

Debugging Toolbox

2008 Sep 30, 11:14Tools and hints for debugging esp. WinDbg. Some interesting things in here. "...When I'm not debugging applications with Windbg, I'm working on tools (utility software) like those presented in this blog. My tools should help you during your debugging or troubleshooting session. "PermalinkCommentsblog windows debug windbg powershell tool programming

Debugging XSLT

2008 Aug 15, 4:02VS debugs XSLT. Didn't know that. Neat. "You can use the Visual Studio debugger to debug XSLT. The debugger supports setting breakpoints, viewing XSLT execution state, and so on. The debugger can be used to debug a style sheet, or to debug an XSLT transformation invoked from another application. XSLT debugging is available in the Visual Studio Team System and the Professional Edition." Unfortunately I couldn't figure out how to pass in parameter values... I just ended up setting the default value for my param elements. Otherwise, cool.PermalinkCommentsdebug visual-studio microsoft msdn reference xsl xslt xml

The Microsoft Wow Blog!: Mike Klucher: XNA Framework games running on Zune

2008 May 5, 11:42Video of "Mike Klucher talks about building XNA Framework games for the Zune and shows the soon-to-be-released CTP that enables developers to build Zune projects, adds a new menu on your Zune for games, and also enables device debugging directly from VisuPermalinkCommentszune xbox videogame development microsoft blog article video

/EP (Preprocess to stdout Without #line Directives) (C++)

2008 Jan 28, 2:42Use this option with cl.exe (the Visual Studio C/C++ compiler) to see what your files look like after all the #define macro magic occurs. Useful when debugging crufty or organic macros.PermalinkCommentsmicrosoft msdn reference c++ cpp preprocessor tool compiler cl

IEBlog : Scripting Debugging in Internet Explorer

2007 Sep 7, 11:29Info on debugging script in IE.PermalinkCommentsie ie7 blog javascript debug debugger debugging web development programming vbscript tools tool download browser reference microsoft msdn

CSSVista: Live CSS editing with Internet Explorer and Firefox simultaneously

2007 Jun 20, 1:05A tool that lets you edit HTML & CSS in realtime with views rendered in IE and Firefox side by side.PermalinkCommentsbrowser ie ie7 firefox mozilla css debug html free software download tool tools web

Install Debugging Tools for Windows 32-bit Version

2007 May 20, 5:14Debugging tools for Windows executables.PermalinkCommentsmsdn microsoft c++ c debug debugger development download free programming software tool tools windbg windows cdb

Fiddler2 HTTP Debugger - Fiddler2

2006 Nov 27, 11:23Fiddler2 is a free tool that lets you view and fiddle with HTTP and now HTTPS traffic! Supports automated modification of traffic using javascript as well as manual modification using breakpoints. Very cool tool.PermalinkCommentseric-lawrence tool tools free internet http debugger debug fiddler fiddler2 microsoft proxy

Intel Assembly Quick Reference

2006 Aug 31, 7:25Debugging assembly isn't that bad... Although source+symbols is much nicer.PermalinkCommentsintel x86 assembly programming reference

Frequently Used Debugger Commands

2006 Apr 21, 4:52Quick list of Debugging Commands for the Microsoft debuggers windbg and cdbPermalinkCommentstony-schriner debug debugger windows microsoft windbg tools tool

Fiddler HTTP Debugger - Debugging Essentials

2006 Apr 7, 4:59Good tools for debugging IE problems.PermalinkCommentseric-lawrence fiddler tool tools debug development http http-header ie ie7 web internet

Download details: Script Debugger for Windows NT 4.0 and Later

2006 Mar 29, 11:27Debug Javascript in IEPermalinkCommentsdebug debugger script development ie javascript microsoft windows

Download details: Application Verifier

2006 Mar 20, 4:36PermalinkCommentsmicrosoft security tools windows x64 x86 debug programming free

Debugging Tools and Symbols: Getting Started

2006 Mar 9, 9:53PermalinkCommentsmicrosoft windows decompiler debug debugger x64 x86
Older EntriesNewer Entries Creative Commons License Some rights reserved.