首先,谢谢 Robert Kuster 为我们提供了这么好的CrashMe项目.
很多人想寻找一个CrashMe分析的教程, 我也想要, 但是似乎网络里没有, 所以我就决定用业余时间写一个小系列来共享我在故障排除以及debug上面的经验和所知,希望这个系列教程可以帮助你更好的研究项目、软件故障排除领域。
关于怎么抓dump的教程文章很多,所以我在这里也就不多提那方面的东西了,如果你需要抓dump方面的教程,可以参考下这篇文章

系统: Windows 7 x64
我们开始吧!
1. 双击打开执行CrashMe.exe, 然后点击按钮"BreakPoint", 我们将会看到这样的画面

1

3

 

2

在把注意力放到dump分析上之前,我们可以像这样收集故障排除工作所需的信息资源。

现在我们开始抓dump来分析问题的根本原因。

adplus -crash -o G:\FreeZone\MSDN\Debug\CrashMe\release -sc CrashMe.exe
[你也可以直接用WinDbg载入并执行此程序,然后直接抓dump, 或者当进程崩溃时也可以使用x86的任务管理器去转储内存信息。]
请不要着急打开WinDbg, 注意看adplus的输出,它已经自动分析出了一些有用的信息:
ADPlus_log_23b4_2012-06-19_21-11-37-882.log

4

我们可以发现这个调用栈告诉我们了根本问题时出在CrashMe!CCrashMeDlg::OnBnClicked_ExecuteBreakPoint方法调用了KERNELBASE!DebugBreak API才使用进程崩掉。

现在我们来启动WinDbg(x86)加载分析dmp:
我们需要将我们的私有调试符号文件的路径配置到WinDbg里,或者配置到系统的环境变量中。

6

有时,你会发现类似于调试目标没有连接上的信息在WinDbg底部,不用担心它,它那是正在加载你的dump文件内容,等一会就好了。

5

我们可以看到这里给出了与adplus log同样的分析结果。
接下来我们尝试下!analyze -v命令:
如果你发现CrashMe.exe的方法名不能显示在WinDbg下,尝试下重新载入符号文件命令: ld * or .reload /f

7

它给出了同样于adplus log的调用栈描述信息。
当我们成功配置好符号文件时,它还可以告诉我们问题出在哪一行源代码上面。然后我们就可以打开源代码文件在WinDbg提示的位置进行检查并修改。
现在看来第一次“crash”不需要太多的研究了,问题的原因已经很明显出来了。

 

 

在我的英文博客里此系列教程以告一段落了,总共写了16篇,过后几天我会陆续将教程内容用中文重述在此中文博客中供没有VPN连接国外网站的朋友们学习研究。

如果你有VPN的话,可以直接访问我的英文博客,因为有很多文章用英文写完之后没时间就没翻译到此中文博客中。

http://mikedoszhang.blogspot.com/

看雪帖子连接: http://bbs.pediy.com/showthread.php?p=1089206#post1089206

翻译自我的英文博客: http://mikedoszhang.blogspot.com/2012/06/crashme-analysis-tutorial-1-breakpoint.html

posted @ 2012-07-20 17:00 Mike Dos Zhang 阅读(64) 评论(0) 编辑

最近看到不少人在比较Windows系统和Linux系统,有说Linux比Windows好很多,Windows能做的Linux能做的更好,Linux做不了的Windows也照样做不到,同样也有太多太多的人更青睐于Windows的系统。大家先不要忙着瞎寻思待会儿怎么批判我,找毛病,我这只是我自己对着一话题的个人理解和看法,不求苟同。

在我看来他们根本就不存在比较性,因为他们的出发点在我看来就是不一样的,在我看来Windows是让所有人(高智商人群也好,普通大众也好)都可以使用计算机工作、学习、生活、娱乐;而就我对linux的了解来看,它的用户群更倾向于科学家们,它的目的是支撑和发展计算机先进科技知识和理论,它不是为了所有人都能立即使用上计算机进行常规的生活而存在的。

Linux在计算机科技比较前沿的科技研究上面有着更多的优势,不管是传统的计算机知识理论的研究与建立,还是非传统的黑客相关技术的研究。

Windows,他可以让一个普通人即使没有经过计算机知识教育,或者说不必了解计算机知识,便可以很快上手进行工作、学习、生活以及娱乐。

有的人说Windows就是个傻瓜系统,把用户当成傻瓜,大部分东西都是用户界面,等等的话语。我想说的是,就因为有了傻瓜相机的产生,才让一个小孩子知道按按钮便可以自己记录生活的点滴乐趣,为生活添彩;同样正因为Windows系统的易操作性,才使得一个再普通的人也可以做一些操作,为自己的工作提高效率,为生活时间增添更多的乐趣。而Linux现在的情况,还有他的存在的目的,导致了每一个使用它的人都多少要懂一些编程、ini、xml之类的知识和经验,这是普通大众或者说各行各业的工作者们无法接受的,最起码人类的现在是这样,不知道人类发展到如电影里所说的未来是否会改变。每个人都有每个人的主要工作,这样才使得社会有序,普通人在生活中只需要知道怎么上网看电影,怎么用电脑打游戏就够了,他们可不想白天工作累的要死,晚上还要稍微学习下编程知识、或者系统原理才能再去使用计算计看电影玩游戏放松消遣、丰富生活。

而研究计算计的人们,或者受过一些高等教育,能够很快接受计算机软件方面的技术(每个人都有每个人能够很快接受的知识领域,在这里并不是说聪明人)的学者、工作者们,他们才会有可能或者说必须去使用Linux,不管是产品限制还是为了更好的研究计算机技术(Linux可以让你看到各种模块的代码,Windows可不会这么容易的让你研究到窥探到)。

(有人)虽说工作用Linux,娱乐便去找ps系统或者别的专业游戏设备。我想说不是每个人都可以精通或者说比较熟练的掌握高级或者比较高级的计算机里的东西去辅助工作的,大老板的忙着每天的决策就够累的了,再让他为了做点东西(文档之类的东西),就要再去专门学点编程配置文件之类的东西(不可能使用上了Linux,只是写文档吧,他也要做点别的事情,而一旦要做的事情多了,要使用的软件工具多了,我敢说一般人是不太会接受Linux那套在非业界人士看来很高深的东西的),同样别的工作着也一样,每个人都有自己的主要工作。

咋们再说下程序员,有人说那微软的智能IDE灵活性没有Linux各工具搭配使用好,有人说他的朋友在一直使用Visual Studio做开发,导致很少接触编译过程之类的东西,最后连什么是编译器什么是汇编器都很含糊。我想说的是,最起码在我对现在的软件开发业界来看,有很多人只是知道一点编程语言知道拖拽,他们也许只是为企业简单的OA系统而生的,他们的主要目标就是能从数据库取出数据,能帮我计算出收银员该找多少钱给顾客就行了,他们就是站在第一线为企业而生的辅助者,在开发业界,也许他们的sense还没有达到一个真正的软件开发者的level,大家做的产品针对客户不同,导致了这样的事情发生。你让他们学习熟知编译过程编译原理,他们会感觉有点扯淡,老子托拖拽拽就够了,完全可以完成一个外包项目。而level稍高一点的也许才可以叫做程序员,他们也许需要知道一些底层的东西,来做出更高级一点的应用程序。而再高级一点的才是开发者、研发者,他们的工作才是为软件开发业内需作贡献,也许开发的是开发工具,也许开发的是计算机系统或者底层的东西。每个业界工作者应对的主要工作不同,你不可能让每个人都必须了解到计算机编程的每个部分,这也和每个人的业务专长有关。

还有安全,很多人,甚至那些稍微懂些计算机知识(包括电脑城那些)都很正经的说Linux最安全,Windows不安全、漏洞太多,我只想说产品没有无bug的,用的人多了,也就是测试用例多了,自然问题就会发现的多,而修复之后他只会越来越健全,反之用的人少了,当然不会检测出很多问题,特别的普通大众很少使用Linux,而不安全、黑客攻击会跟着大人群走,如果现在的主流系统是Linux的话,我相信针对于他的安全问题也不会少到哪里去,虽然说Linux高级,但是高级的东西一样会有它的问题。

看来我对Linux的认知就是难操作,不适合大众使用,这是我个人的看法,但我感觉很多人也是这么看的,再加上工作生活需要导致大家感觉使用Windows比较快乐,Linux孩儿们不要批判我们懒、我们不爱学更深层的东西,因为大家的工作重点不同。

特别是现在是Windows的天下(就用户群数量),大部分应用厂商做出来的Windows上面的应用都感觉很易用,让普通人可以很快上手,也让许多只懂一点点编程知识的人也可以发挥他们的力量为别人做贡献,让自己可以挣到钱生存下去。如果去做Linux应用产品的开发的话,我感觉就现在的市场情况,还有现在业界人员水平来看要死很多人的。

然后让刚迈入程序开发领域的新人一点建议:发现自己的却有开发者、编程人员的sense之后再去尝试、追捧Linux吧,不要盲目,要不然别说你是半瓶酱油,更有可能死的很惨。

 

Linux是高级的,但Windows不是傻瓜的,Linux让计算机知识领域越来越丰富健全起来,Windows让大众的生活变得越来越丰富简单一点。

帮助计算机领域发展快速,和帮助大众可以使用计算机使得生活简单快乐同样重要。

posted @ 2012-06-09 18:27 Mike Dos Zhang 阅读(117) 评论(0) 编辑

因为时间问题,我只仓促的把我在google blog上写的原稿粘贴在这,而没有翻译,相信大家能看得明白,如有疑问可留言。

http://sdrv.ms/Kez9H1

I have not found a sample code from MSDN documents, so I wrote some test codes for research your this problem.

Since I'm not very familiar with Windows 8 new APIs and the Metro Style Application project dev, so I just try to make theWindows Form Application project can demonstrate the answer to you.

And now, I think my demo code can prove the document content:

            //GetImageStream Remarks: http://msdn.microsoft.com/en-us/library/windows/apps/windows.system.userprofile.lockscreen.getimagestream.aspx
            //This method can be called only by apps that have set the "Picture Library Access" capability in the package manifest
            //**or bythe app that set this image on the lock screen.

            //OriginalImageFile Remarks: http://msdn.microsoft.com/en-us/library/windows/apps/windows.system.userprofile.lockscreen.originalimagefile
            //This property retrieves only files. 
            //**If the image was set through a stream, this call will return E_FILE_NOT_FOUND.

using System;
using System.IO;
using System.Windows.Forms;
using Windows.Foundation;
using Windows.Storage;
using Windows.Storage.Streams;
using Windows.System.UserProfile;

namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        IRandomAccessStream picStream = null;
        private async void BtnSetLockScreenImage_Click(object sender, EventArgs e)
        {
            await SetLockScreenImage();

            this.richTextBox1.Text = "AccountPictureChangeEnabled: " + Windows.System.UserProfile.UserInformation.AccountPictureChangeEnabled +
                "\nNameAccessAllowed: " + Windows.System.UserProfile.UserInformation.NameAccessAllowed;
        }

        private async System.Threading.Tasks.Task SetLockScreenImage()
        {
            StorageFolder storageFolder = KnownFolders.PicturesLibrary;
            StorageFile sampleFile = await storageFolder.GetFileAsync("abc.png");
            picStream = await sampleFile.OpenAsync(FileAccessMode.Read);
            await Windows.System.UserProfile.LockScreen.SetImageStreamAsync(picStream);
            picStream.Dispose();
        }

        private void BtnSaveAndRead_Click(object sender, EventArgs e)
        {
            SaveLockScreenImage();
            this.pictureBox1.ImageLocation = "1.png";
        }

        private void SaveLockScreenImage()
        {
            //GetImageStream Remarks: http://msdn.microsoft.com/en-us/library/windows/apps/windows.system.userprofile.lockscreen.getimagestream.aspx
            //This method can be called only by apps that have set the "Picture Library Access" capability in the package manifest 
            //**or by the app that set this image on the lock screen.
            using (IRandomAccessStream imageStream = Windows.System.UserProfile.LockScreen.GetImageStream())
            {
                SaveStreamToFile(imageStream);
            }
        }
        DataReader dr;
        private void SaveStreamToFile(IRandomAccessStream stream)
        {
            try
            {
                dr = new DataReader(stream.GetInputStreamAt(0));
                DataReaderLoadOperation drlo = dr.LoadAsync((uint)stream.Size);
                drlo.Completed = new AsyncOperationCompletedHandler<uint>(SaveToFileCompleted);
            }
            catch (Exception)
            {
            }
        }
        void SaveToFileCompleted(IAsyncOperation<uint> asyncInfo, AsyncStatus asyncStatus)
        {
            if (asyncStatus == AsyncStatus.Completed)
            {
                uint size = asyncInfo.GetResults();
                byte[] bytesArray = new byte[size];
                dr.ReadBytes(bytesArray);
                FileStream fs = new FileStream("1.png", FileMode.Create);
                fs.Write(bytesArray, 0, bytesArray.Length);
                fs.Flush();
                fs.Close();
                dr.Dispose();
            }
        }

        private void BtnGetOriginalImageFile_Click(object sender, EventArgs e)
        {
            //OriginalImageFile Remarks: http://msdn.microsoft.com/en-us/library/windows/apps/windows.system.userprofile.lockscreen.originalimagefile
            //This property retrieves only files. 
            //**If the image was set through a stream, this call will return E_FILE_NOT_FOUND.

            //So we can use the More PC Settings or the SetImageFileAsync function to set the image, and then call this method to get the image file.
            try
            {
                this.pictureBox2.ImageLocation = Windows.System.UserProfile.LockScreen.OriginalImageFile.AbsolutePath;
            }
            catch(FileNotFoundException) 
            {
                MessageBox.Show("If the image was set through a stream, this call will return E_FILE_NOT_FOUND."
                    + "/nPlease use SetImageFileAsync");
            }
        }

        private async void BtnSetImageFileAsync_Click(object sender, EventArgs e)
        {
            StorageFolder storageFolder = KnownFolders.PicturesLibrary;
            StorageFile sampleFile = await storageFolder.GetFileAsync("abc.png");
            await LockScreen.SetImageFileAsync(sampleFile);
        }
    }
}

 

I put my image abc.png into the Picture library do the test.

[Edit:

Build the project to x64 once you are on x64 Windows 8 CP.]

About the x64 problem was found after my friend asked me the same question on his x64 System, and we use the Process Monitor to capture what the API did, and there's a registry key is not in the 32bit path under x64 System, so we need build the application to x64 then run, it works. Since that key is undocumented, it is hard to say if this is a issue or just the engineer design it like this.(So I just do not mentioned that registry key name here, you can find it according to my way.)

挂上VPN就可以访问我的英文blog了: http://mikedoszhang.blogspot.com/2012/05/lockscreen-apis-in-windows-8-cp.html

posted @ 2012-05-29 17:55 Mike Dos Zhang 阅读(161) 评论(0) 编辑

delegate

 

 

delegate

event

编译后

声明一个返回值和参数列表时供Invoke 方法使用的, 方法将作为函数指针传递给此类的构造方法.

声明/封装/protect 一个私有的 delegate 声明的类的引用.

允许对其引用使用的操作[]

=, +=, -=

+=, -=

调用

此类型的变量可直接调用。

不可直接调用,需要事件发布者调用此类型的变量。

此文是在阅读Jimmy Zhang的博文之后,自我总结出来的: http://www.cnblogs.com/jimmyzhang/archive/2007/09/23/903360.html

希望此总结会给更多的人帮助,去更好的理解delegate和event关键字。

 

引自我的英文博客: http://mikedoszhang.blogspot.com/2012/04/delegate-event-keywords.html

posted @ 2012-04-20 11:02 Mike Dos Zhang 阅读(436) 评论(0) 编辑

If you check HKLM\Software\Microsoft\NET Framework Setup\NDP\v4
and HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\.NETFramework\v4.0.30319\SKUs\.NETFramework,Version=v4.0.2
you will find there's nothing you can use the do the checkpoint for your bootstrapper.
The .Net Framework 4.0.2 is installed by the update KB2544514, so our target is this KB updates information.
[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Updates\Microsoft .NET Framework 4 Client Profile\KB2544514]

But this is not a MSDN way, I have not found a way for this checking in MSDN documents.

ref from my Google blog: http://mikedoszhang.blogspot.com/2012/04/bootstapper-for-checking-net-framwork.html

posted @ 2012-04-05 14:44 Mike Dos Zhang 阅读(41) 评论(0) 编辑
摘要: http://msdn.microsoft.com/en-us/library/windows/desktop/aa371221(v=vs.85).aspx Since there's no File Version attribute for the SDF database file for the Existing File replacement policy, but sometimes we really need to replace the SDF file(change the init data, or others things makes you need to阅读全文
posted @ 2012-02-06 15:34 Mike Dos Zhang 阅读(57) 评论(0) 编辑
摘要: Before the end user really have no way to solve this issue, they only can uninstall and re-install the product again, and the way developer can do is use a minimum required version to force the end us...阅读全文
posted @ 2012-01-27 18:22 Mike Dos Zhang 阅读(58) 评论(0) 编辑
摘要: Then "Explore Decompiled Assemblies", and double click on the method, it will open the source code in your Visual Studio.Now, we can set break point through our Visual Studio to this source code.[F9]The prerequisite steps were finished…"Debug an Executable..."When that assembly s阅读全文
posted @ 2012-01-22 12:35 Mike Dos Zhang 阅读(93) 评论(0) 编辑
摘要: 兴趣,梦想使我踏入了这个圈圈兴趣,梦想,我的哲学,加上我的理性使我在进步中调整调整人生,调整思维方式,调整学习方向,同时调整我的兴趣Copy -> Debug -> Coding -> Debug & Reading codes当你能够静下心来专门钻研编程的基础知识时,并且能够做到批判某些国内书籍,那么你应该才算是有编程基础。现在太多太多的刚毕业的学生的基础实在是有点说不过去,我一个没读过计算机本科,也才毕业两年的,连我的基础关都过不了。学校教授了C++,但却对C++了解的不是一般的少,说自己学了一些C#,做过C#这个那个项目,但问及基础时,感觉就像没学过似的。当你会阅读全文
posted @ 2011-12-23 14:06 Mike Dos Zhang 阅读(222) 评论(0) 编辑
摘要: 产品名:WindowsFormsApplication2. version 1.0.0.0 Publishing Folder: \\MIKEWIN-MSFT\publish\ Installation Folder: \\MIKEWIN-MSFT\publish\ Update Folder: \\MIKEWIN-MSFT\publish\ 然后发布,终端用户安装此应用。 现在...阅读全文
posted @ 2011-12-03 00:28 Mike Dos Zhang 阅读(206) 评论(2) 编辑