個人檔案Nates Stuff相片部落格清單更多 ![]() | 說明 |
|
|
6月16日 Nerd QuizFor now on you may address me as my proper title: I wish the title was a little less blasphemous; therefore you may alternately call me 'King Nerd'. That would also match with my wife who is a "Slightly Dorky Nerd Queen".
I also scored quite high on the version 1.0 test: Remember, that is 92 percentile! --Nathan Zaugg 12月5日 Debugging with Process MonitorNow I am not much of a low-level debugger type. I've seen people use WinDbg like it was an extension of their hand! I am not one of those people but I would sure like to be. Lately I have been working on a project that does some pretty tricky code hooking of some User Mode API calls in Kernal32.dll. Specifically I was hooking calls to CreateFileA, CreateFileW, DeleteFileA, and DeleteFileW in Kernel32.dll. Everything was working as expected but when I drag a file in Windows Explorer I can see the CreateFile call being made in the Kernel, but I was not trapping those calls.
Of course, I looked in the call stack in Process Monitor, but without debug symbols, this information is pretty much useless. All I could see is that Kernal32.dll called down to a lower kernel call and was eventually caught as CreateFile. Well, I recently tried to get the symbols to work in Process Monitor and ran into some difficulty. First, I needed the latest version of WinDbg installed as it uses the latest version of DbgHelp.dll. Secondly the symbol path (as unusual as it is already in WinDbg) is slightly different. For some reason Process Monitor needs to know not only where the symbols are but also the path to the executables that match those symbols. I had to use the path: srv*E:\Symbols\*http://msdl.microsoft.com/download/symbols;E:\Windows\;E:\Windows\system32;E:\Windows\system32\Drivers
My Symbol Settings
My Stack Trace now shows with symbols
So my problem was that it is really making a call to CopyFileExW which uses the Kernel's CreateFile function as part of the work it is doing. Process Monitor doesn't really know what the "parent" call for the stack is in the User Mode as it is a kernel level hook. So while it looks like the call to CreateFileW in Kernel32.dll should have hooked this call, Kernal32.dll is actually a user mode dll and is just a shim to pass the call back to the Kernel to do the work.
Fun Stuff!
--Nathan Zaugg 12月3日 Hot Air BaloonThis was just so funny I coulden't resist!
Nate Zaugg
A man in a hot air balloon realized he was lost. He reduced altitude and spotted a woman below. He descended a bit more and shouted, "Excuse me,can you help me? I promised a friend I would meet him an hour ago, but I don't know where I am." The woman below replied, "You're in a hot air balloon hovering approximately 30 feet above the ground. You're between 40 and 41 degrees north latitude and between 59 and 60 degrees west longitude."
"You must be in Information Technology," said the balloonist.
"I am," replied the woman, "How did you know?"
"Well," answered the balloonist, "everything you told me is,technically correct, but I've no idea what to make of your information, and the fact is I'm still lost Frankly, you've not been much help at all. If anything, you've delayed my trip."
The woman below responded, "You must be in Management."
"I am," replied the balloonist, "but how did you know?"
"Well," said the woman, "you don't know where you are or where you're going. You have risen to where you are, due to a large quantity of hot air. You made a promise, which you've no idea how to keep, and you expect people beneath you to solve your problems. The fact is you are in exactly the same position you were in before we met, but now, somehow, it's my fault." 8月9日 Changing Ones SelfI was recently horrified when I realized that I did not make a blog entry in the month of July! I didn't make a contribution to MSDN forums (there goes my once a day goal) and I did not even read my ever-backlog of RSS feeds. Of course, I have plenty of excuses. The best one is that we had our third child early in the month of July. Other excuses include building a new house, trying to get our current home up for sale, and other miscellaneous family matters. Well, assuming the little boy sleeps at night, I'm almost back to full capacity.
Back to the topic at hand. The other day me and my friend Phil were working like crazy trying to get some stuff done late at night during one of our all-night code-a-thon's. He was looking for something very specific (SQL Server Express 2005 Installation Parameters) and was using google to try to find the page he is looking for. He spent well over half an hour and could not find the page he was looking for. We had recently had a discussion about how I feel that google has been loosing favor in my mind and that I have declared that I was switching to Microsoft's Live Search. He decided to try it out, and poof! Like a magic trick the page he was looking for appeared! He even stated that he is considering switching from google.
Before I go on, one observation I have noticed is that if your are looking for something Microsoft related, google isn't the product for you! It's almost like they have black-listed any Microsoft site in favor of anything else! This is a strange shift as the it used to be that google was the best way to search Microsoft's site, not Microsoft search!
I have been convinced for some time that Live search is better and have even changed my default page in IE7 (yes, I prefer IE7 to Firefox, and I am not the only one), but one thing still plagues me. Whenever I sit at someone else's computer and need to do an Internet search, I always navigate to google.com and after not finding what I am looking for use live.com. Why do I do this? In fact any time I have to type the URL google.com is always what I type. When I suggest to someone that they need to look for something on the Internet I don't say "You should Live search that", I say "You should Google that". Old habits sure die hard!
I believe that one of the hardest things for Adults to do is to change something about themselves. It doesn't matter what...something, ANYTHING! I have been saying for some time that the hardest thing to change is your spending habits but it's much more than that. Your hair style, your daily routine, your brand of soap, deodorant, brand of toothbrush, your mannerisms, your reaction to stress, your style (still in the 80's?), your job, your eating habits, your political positions, your values & morality, your relationships, or your eye color! Some of these things can be more easily changed than others but they are all--to some extent--difficult for us to change. My first thought was that this is horrible! How do we ever better our selves if we can't change! To some extent, that is exactly right. In fact, it's a good thing! It would be really hard to improve if everything about us was random and unpredictable. We can choose to focus our energy on improving one aspect and the rest should remain relatively unchanged. It is difficult to change!! Keeping in mind that all of these things are part of us. Our personality in essence is the combination of all of these things about us, it makes sense that as adults we find change so difficult. Most of us have well defined strong personalities and those are the hardest kinds to change. It's tough to change anything that is working and prove successful.
May we all have the drive and diligence to improve ourselves, and may we all switch back to IE! :)
Nathan Zaugg
5月22日 Truncating SQL Server 2005 Transaction LogI have to look this up all of the time, but if you want to email a database backup to your buddy, you can truncate all of your tables and still have a very large database! This is because the transaction log comes along with the database backup. Here is a script to truncate your transaction log (for development databases only!)
dump tran [dbname] with truncate_only
--nz 5月7日 Job Well DoneIt's not often I get such high compliments! So when I do I like to brag! --nz
Hi Tim,
I’d like to convey our satisfaction with the development work Nate Zaugg completed on the Hotel Online Reservation site for the Jackson Rancheria. As you are aware of the previous issues/delays surrounding the delivery of the Online Reservation site through your conversations with us, we were a bit skeptical it would only take the estimated two days to complete the work that was needed to complete the deliverable to our satisfaction given the previous months in which there was very little progress.
Though it is unknown to us whether Nate was hired in or put under contract, we do know it is individuals like him that get things done. He was able to skim the Opera Web Service manual and our previous in-house development code, and then code from scratch to integrate the Online Reservations to our new Internet site. It was impressive.
We appreciate the expertise you have granted us by bring Nate on-site and hope he is kept aboard your company in some capacity whether for us or for any of your other clients. Thank you, Steven 4月30日 Retrospective on the Utah Code CampUtah Code Camp
3月28日 Utah Spring Code Camp
--nz CODE CAMP OFFICIAL ANNOUNCEMENT: The local .NET Users Group and SQL Server Users Group is conducting a “Code Camp” for local software programmers next month at Neumont University. The code camp is by the community for the community. Always free and Always for the community. We will have Sessions on .NET, SQL Server, and Oracle. Presented by experts around the valley! 3月15日 Better Password SecurityToday while speaking with a colleague we were discussing a user for a website who had lost their password. A trick I have done many times in the past was to copy the password hash from a user that I knew what the password was over the top of the user’s password that we didn’t know. Then we simply log into that user with our password and change it. That’s fairly unsecure! So it hit me…a great idea! Use the username as a salt for the password hash!
If you use the username for the salt then copying the password hash from one user to another will not work! I don’t know if I am the first one to think of that or if someone has done that before but at least if I was the first one then maybe I can get credit for it and get to name it “ZauggHash Encoding” Nathan Zaugg 2月21日 Microsoft Virtual PC 2007 Released TodayThe Long-Awaited (at least by me) release of VPC 2007 has finally come! Microsoft hasn’t released a Virtual PC Platform sense 2004 and with that version being incompatible with Vista we *really* needed a VPC solution quick! Especially those early-adopters of Vista like myself. The good news: Its FREE! 2月13日 Changing JobsAfter two and a half great years at STG (Software Technology Group) I have decided to leave STG and have taken a position with SolutionStream. I have some friends that work there that I am anxious to work with again and it is a good opportunity. I have enjoyed the project I am working on now at the Church and feel like I have a great team and that we've written some awesome stuff!
Thanks Again! 2月9日 Excellent Instrumentation Using Almost Any Language!Do you ever have one of those times where you look for something, a tool perhaps, to help you solve a problem that you've been doing another way for a very long time and found something that by now you really should have already known? This happened to me this week. I just put a bunch of trace statements into my code and decided I'd like to have a class that adds some information to the trace statements like severity and such. Today I realized that there is a tool called TraceTool that does everything I wanted and a lot more!
Of course, this blog is part info for the general public, but also a way for me to always have a valid reference to a link to this stuff (like anyone reads my blog anyway!).
So here are the links:
(alternate emergency nothing-else works link)
--nz 2月6日 The Mighty Mighty Code CounterI was really curious about how many lines of code a project of mine had compared to another. Before you know it I write a simple application to count code! I admit that there is probably hundreds in existence already, most of which are much better than mine, but I am a programmer and dammit I like to do stuff like that! Well, I hope this is useful to someone else someday! If you change it, please send it back to me so I can have the changes as well. Thanks! 1月25日 Patterns and Anti-PatternsIn a discussion with a friend a couple of weeks ago he mentioned a term that I hadn’t heard for a very long time and wanted to focus some discussion on. The term was “Anti-Pattern”. I realized that in code, anything that does not belong to a pattern belongs to an anti-pattern. As an architect it is our job to identify Both patterns and anti-patterns in our projects. Some of the anti-patterns I have come in contact with lately I will describe below but I would like to get a community support in identifying as many anti-patterns as possible. I think it’s just as important to identify the anti-patterns as it is to identify any other design pattern. Anti-Pattern #1 – Event Chain: Often times when writing a MVC style application we want to pass messages from a control 3 children deep (or more) back to the controller so it can take appropriate action against another view. Some have tried to solve this problem by creating an “event sync chain” where every parent/grandparent/etc. of this control must both implement and publish events to pass along to the controller. Example: public class View1 { public void InitializeComponent() { doc = new Document1(); doc.OnOpenSearchPage =+ new EventHandler(OpenSearchPageMethod); } //… the rest of the class …// }
public class Document1 { // my parent is View1 public event OpenSearchPageDelegate OnOpenSearchPage;
public void InitializeComponent() { control = new Control1(); control.OnOpenSearchPage =+ new EventHandler(OpenSearchPageMethod); } //… the rest of the class …// }
public class Control1 { // my parent is View1 public event OpenSearchPageDelegate OnOpenSearchPage;
public void ButtonClick() { if ( OnOpenSearchPage != null ) OnOpenSearchPage.Invoke(new EventArgument()); } //… the rest of the class …// } Resolution #1 – Interface Controller Recursive Lookup Step 1: Make your main controller implement an interface with all of the methods you wish to call Step 2: Remove *all* sync chains! Step 3: (optional) include a property for the parent of the main view that has a reference to the controller by the interface. If you commonly invoke methods in the controller at this level this is very useful! Step 4: Create a function that looks recursively for the controller, and then call the method that you need directly into the controller. public IController GetController(object sender) { if ( sender is IController ) { return (IController)sender; } else if ( sender.Parnet != null ) return GetController(sender.Parent); else Debug.Assert(false, “This control is not housed by a controller”); return null; } Remarks: Using an event is a great way to pass messages from a child control back to its parent, but if you have to pass events up through multiple generations (grandparents and great-grandparents, etc.) then you have encountered an anti-pattern. Sense is generally considered a bad thing to reference your parent directly (let alone a grand-parent) then using an Interface is a great way to keep the abstraction but still keep the code loosely-coupled and reusable. Anti-Pattern #2 – Event Suspension: Often times when modifying the state of a control we inadvertently trigger events that we don’t want to be called. This can even result in infinite recursion if the event that is triggered is the same as the event we are currently in.. Example: public void ListBox1_Click(object sender, EventArgs e) { ListBox1.OnClick -= new EventHandler(ListBox1_Click); // unwire event ListBox1.SelectedIndex = 0; // Reset this for some reason //… Do Some Other Work ..// ListBox1.OnClick -= new EventHandler(ListBox1_Click); // wire the event back } Remarks: I have actually seen this a lot! There is very little good reason to “un-wire” events. The best thing I can think of to do is to provide a global variable to indicate that work is in progress for that list box. A better idea might be to re-consider the design of the application in general. WPF *should* help as there will be much less code written to manage the state of objects through anything but data binding.
Anti-Pattern #3 – Pass by Global?:
Sometimes we get confused about OOP and what things in a class should and should not be used for. This can backfire!.
Example:
public MyObject ListObject { public void MyMethod() { Remarks:
If there were only one method that did that and ListObject was not only used by these methods then this pattern *could* be safe, at least in a single-threaded enviornment. The real problems come when this is multi-threaded and ListObject is unique to this (or this type of) method call. It is better to pass ListObject in as a parameter [MyClass1Object.MyMethod(GetListObject()); ]. DSL .netI have decided that my blog is going to be more about short thoughts or cool topics rather than long/well –thought-out blog entries (not that they ever were).
So for the Kick-All Link of the day I have DSL (Domain-Specific Language) which is a kind of software factory of sorts. I am still learning about it myself so I wish I could be more specific. But this stuff defiantly Kicks-All! 9月8日 A Year In The MakingJust over a year ago I setup this blog with the first entry entitled “Blog....what the heck do we all need blogs for?” There are two things that I have embraced in the past year that I think are valuable. The first is Wikipedia (http://www.wikipedia.org/). Wikipedia is a wealth of information and I could spend the rest of my days contributing to it. It is what the Internet was intended for! If you haven’t yet been converted to Wikipedia then I invite you to try it today! The second is, well, blogs! This is, of course, very hypocritical of me to write my first blog on how it’s stupid that we all need blogs and then to say that over the past year it has been on of the things I have embraced the most! I have noticed that there are, in fact, two types of blogs. The first and most common is the personal blogs. These blogs, like this one, are a bunch of mostly useless bits of poorly worded dribble that rarely speaks of anything of any importance and is never the place where great ideas are cultivated or shared. The other type of blog is an outlet of people, or in some cases companies or people in proxy of companies as with Microsoft. These blogs are used as the “proving ground” for new ideas, for news on the latest trends, for answers to questions that many have, or at times even for a good laugh. You will know these blogs because there are never less than a dozen comments on even the most drab of entries and they tend to get hundreds of hits per day. Which type of blog do I like? The easy answer is there are things I like about both of them and there are things that I don’t like about both of them. I like the personal blogs because if it is someone I already know it is really nice to take a minuet here and there and catch up on what’s going on with them. It’s important to still go to lunch with these former colleagues and friends but you don’t usually have enough time to fully catch up. If I end up on a person’s blog that I don’t know then I am usually just annoyed! I like the other type of blogs for obvious reasons. They give me a lot of information I can’t find anything else. I get important news on upcoming products of interest and I learn a lot from some select people. The thing I don’t like about these ‘blog for the masses’ is that after establishing a reputation or a following the opinion of this one person skews the perspectives of their readers. It’s really not their fault, but some people fix themselves on a single point of view, they don’t diversify in their selection of blog readings and the views and opinion of one perspective is now shared by countless others. It really doesn’t matter the subject or the author and this principal is not thus limited to blogs. Anyone who does not diversify their sources and does not seek out to understand other points of view does not have an accurate portrait of the truth. Said another way, no one person speaks truth. It may be in complete accordance to their point of view and/or experience but this does not make truth. Truth can only be found in perusing it and once it is believed to have been found it can not be thus verified. Nor can it be shared in verbatim. Obtaining truth is tricky! It is up to each of us who desire it to do their due diligence to peruse it the best we can. In much the same way blogs contribute to this problem they also can help solve it. They often add to the limited sources of information which can be used by those looking for another perspective on this information. With technology marching forward its worth wondering, is 2006/2007 going to bring as much innovation as 2005/2006 or is 2005 going to be a year in which other years will be judged. --NZ 9月7日 Better UI
9月6日 Interview QuestionsIf I ever give you a technical interview, here are a sampling of the questions I will ask:
BACKGROUND AND PERSONALITY QUESTIONS:
* Where are you currently working? * Why are you "looking"? * What did you do before that? * How long have you worked in the IT industry? * Have you ever done any consulting? * Do you feel certifications are important or valuable? * What languages do you know and how experienced are you in each? * Do you prefer to work in a group or work solo on a project? * What projects are you working on in your spare time? * What was the last book you have finished? * Who is your favorite non-technical author? * Who is your favorite technical author? * Do you get along well with those you work with? * How do you handle this situation? - Client? GENERAL EXPERIENCE:
* Have you ever worked with MSSQL Server? * Have you ever worked with Oracle? * Which type of version control are you familiar with? * How strong is your XML? * What is an XPath? * What is DOM? * What is SAX? * What is the difference between DOM & SAX? * Have you ever programmed or consumed a Web Services? * What is ORM? * Can you explain the concepts behind the MVC Architecture? * Can you explain the concepts behind SOA Architecture? * What are generics? * How is it used? * What is it useful for? * Have you ever written Unit Tests? * Have you ever done XP or Agile development before? * Do you like it? * What are some "patterns" in programming? SQL QUESTIONS:
- What are the 5 SQL Joins? - Execution Plan - Query Optimization - SQL Diagram (Customers, Orders, Payments, Shipments) - SQL Question - T-SQL Question C# QUESTIONS:
* What is the difference between a class and a struct? * What is the difference between an Abstract Class and an Interface? * How many classes can you inherit from? * How many interfaces can you implement? * What is reflection? * Why would you use a method over a property? * What does the keyword using do? * What is a PInvoke? * What is boxing and unboxing? REMOTING:
* What is remoting? * What is the difference between a singleton object and a singlecall object? ADO.NET:
* What is a Command object and what it is used for? * What is object is required for a command object to communicate with a database? * What is the difference between a DataReader and a DataSet? * Is it possible to return multiple result sets to a DataReader? * How? * Is it possible to return multiple result sets to a DataTable? --NZ
6月2日 SQL Server PreferenceI am currently evaluating wither to use SQL Server for the application or use Oracle. Unfortunately, this is an Oracle shop and it will probably win out, but when asked to put my reasons, concrete or otherwise, this is the list I came up with.
Feel free to add or debate some of the points as comments below.
* Previous versions of Oracle Client for .net require special data type conversion which is cumbersome and slows performance. * Query optimization can be done by the developers by using SQL Servers Execution Plan * The ability to debug stored procs is gone * Historically the Oracle provider for .net has been buggy and less of the features are implemented * Extra software will be required for deployment which makes one-click deployment impossible * We are not familiar with how Oracle does full-text searching * SQL Server 2005 has "MAX" field specifies which allow string fields such as varchar and nvarchar to have a tubular length of something like 2TB which can be processed with string manipulation and regular expressions in the database. * The tools for SQL Server 2005 are far superior to anything available for Oracle * The tools for SQL Server 2005 are built into the development environment which makes the amount of time to access the data or database information very quick * SQL Server Integration Services (a very powerful tool for data migration) is crippled (many of the features are not available when transforming to an oracle database) and Oracle croaks when trying to transform more then 25 tables in a batch * Team Experience favors SQL Server * We could not use .net 2.0 user and roles management tools * We could not use out-of-process .net session state management * Microsoft Technology always works best with Microsoft Technology * Decreased ability to achieve one of the goals of the software rewrite (distributed) NZ |
|
|