2014-03-25

Debugging Tools on Windows

Windows Error Reporting (WER): Collecting User-Mode Dumps
http://msdn.microsoft.com/en-us/library/bb787181%28VS.85%29.aspx

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\Windows Error Reporting\LocalDumps
  • DumpFolder, REG_EXPAND_SZ, %LOCALAPPDATA%\CrashDumps
  • DumpCount, REG_DWORD, 10
  • DumpType, REG_DWORD, 1 (1: mini dump; 2: full dump;)

Per-application setting:
HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\Windows Error Reporting\LocalDumps\MyApplication.exe

* Need to restart (or log out and log in again) to make the change effective.


Enabling Postmortem Debugging - register a debugger (WinDBG, CDB, ntsd)
http://msdn.microsoft.com/en-us/library/windows/desktop/ff542967%28v=vs.85%29.aspx


Tools comparision matrix (ADPlus; WER; CDB/WinDbg; UserDump)
http://msdn.microsoft.com/en-us/library/windows/desktop/ff539117%28v=vs.85%29.aspx


More tools in the toolset
http://msdn.microsoft.com/en-us/library/windows/desktop/ff543998%28v=vs.85%29.aspx


Application Verifier
http://msdn.microsoft.com/en-us/library/windows/desktop/dd371695%28v=vs.85%29.aspx

Restart of the application is needed - after it is added into AppVerifier.

WinDbg

2014-01-08

bank security token - reverse engineering

The original source is obviously unavailable now.
Just saved for later reading/reference.

2013-08-20

Busy wait, Sleep(0), Sleep(1), Sleep(1000)

* Busy wait, or spin wait: not required for most of the cases
* Sleep(0): fairly good choice
  * if you don't know how long to "sleep", or need to "sleep" less than 1ms
  * if it's not constraint to a single CPU/core
  * if you don't care about the "high" CPU usage
  * if you need an immediate response
* Sleep(1): "sleep" a little bit, but normally more than 1ms
  * if you don't need immediate response
  * if you'd like give out the time slice anyway
  * if you want a "lower" CPU usage than Sleep(1)
* Sleep(1000): just an arbitrary selected number
  * if it's not likely to happen
  * if you are waiting for another time consuming counter part

"Sleep()" is not sleep, but tells the scheduler "Don't bother me for at least some time".

Sleep(0) has a special meaning and handled differently than other values.

WaitOnAddress() seems promising, but:
* seems cause more CPU usage
* with more wall time
Compared to my Sleep(0) version.

Will check the testing/benchmark code later. But, it seems so now.
And the document on MSDN seems at least not reflecting the implementation.

I already sent comments with questions on the documentation and the underlying tech, via email by clicking the bottom link.
I don't expect any (immediate) response. But, before I get any response, I will stop there, no using/testing WaitOnAddress anymore.

Some obvious questions:
* Parameter dwMilliseconds
  * What does "indefinite" mean? If given 0.
  * An optional parameter?
* The example code
  * Why not check the return value?
  * Have you noticed a race condition of using CapturedValue?

Sleep(0) might be further improved, both the performance/speed and power consumption. I'm not sure about the first claim, neither have any knowledge on power consumption.
I'm sure of the implementation of ReaderWriterLockSlim (C#):
* Why not use existing WIN API, like AcquireSRWLockExclusive?
* Why busy wait, then Sleep(0), then Sleep(1)?
* And how to choose the arbitrary numbers for busy wait and Sleep(0)?
* It is with the best performance, or has some compromises?

Anyway, it seems the same approach as the guys from Intel did.
I will give it a try, when I have time.
But, actually, I don't care about performance too much. So, if there is no big improvement (like 10x), I will still use the simple Sleep(0).

Just now, it is only tested against wall time (CPU instruction).
Maybe I'll test it against wall time (performance counter), and analysis the stdev besides just avg.

2013-01-24

利用政策漏洞,套钱买房

利用政策漏洞,套钱买房

http://www.newsmth.net/bbstcon.php?board=SchoolEstate&gid=45221

发信人: evangy (望月寻音), 信区: SchoolEstate
标  题: 超级攻略:你没钱,还想再买个学区房,我来告诉你办法.
发信站: 水木社区 (Tue Jan 22 21:36:57 2013), 站内

竟然到十大了.本文纯属茶余饭后的讨论贴.

一个外地人,在北京需要多少套房子?
答案是4套起,自己住一套,父母住一套,岳父母一套,再给孩子准备一套,当然,再有一套郊区度假的最好.
但太多的人只有一套房,父母接来北京后,明显不够住.
可以参考以下的方法.

条件
1.夫妻名下有房屋(最好全款,能估高一点)
2.夫妻至少一方有公积金或商贷资格,都要有购房资格.
3.房屋最好满5年,唯一(非必要)

流程如下:
一,假离婚,将已有房屋过到一方名下(如只有一方可用公积金,需过户到无公积金的一方身上)

二,假离婚后,假设LP为无房户,LG为有房户,无房户LP"购买"有房户LG的房屋,如满5且唯一,税非常低,按照指导价过户即可.无房户LP交易中要申请公积金或商业贷款.这里假设申请80w公积金.

三,现在,仍然一房为无房户,一方为有房户(注意,换过来拉,LG无房,LP有房),此时,无房LG手中神奇的多出了80w,80w耶,来自步骤二!无房LG再去购买住房(注意:这个是学区房,不是刚才自己买卖的那套,那套房本已经盖银行抵押章了.),此时我们假设买新房,算首套,再申请80w的公积金!(商贷可申请更多)

四,现在LG买到了80w+80w的新房,当然要复婚了,现在二套房入手,贷款只要8K多,房租4K+,毫无压力的日子啊~~

五,如愿意,可重复以上步骤(成本会增加)

课后作业:
160万不够买学区房怎么办??
提供的思路是:丈夫娶丈母娘,老婆嫁公公。。。。。。。

--
※ 修改:·evangy 于 Jan 23 19:25:01 2013 修改本文·[FROM: 123.112.166.*]
※ 来源:·水木社区 http://www.newsmth.net·[FROM: 123.112.152.*]

2012-12-29

2013 精简日历

Compact Calendar 2013 基础上:
  • 页面"Tables",增加了倒休日期功能
  • 页面"12-Month",以背景色区分工作日和节假日(休息日灰背景)
其他还有些小改动,主要是根据个人喜好修改了部分界面显示。

节假日安排依据国务院办公厅通知

=====8<=====8<=====8<=====8<=====8<=====8<=====8<=====8<=====8<=====

Based on Compact Calendar 2013:
  • On worksheet Tables, added Workday Lookup Table for workday shift
  • On worksheet 12-Month, distinguish workdays and holidays with different background color (white for workdays)
There might be some small changes on the display according to my own preference.

The holidays and workday shift are according to the government's announcement.

2012-09-13

退税,以及欧盟、欧元区、申根国的区别

主要参考:[實用資訊] 歐盟.歐元區.申根國傻傻分不清楚 暨 各種退稅方式

退税(有多种渠道和方式,我估计也就只会涉及下面两种):
* Global Blue 机场退税
* Amazon.de 网购退税
送货地址和账单(RECHNUNG)地址可以分开,账单地址需要为欧盟外国家或地区,邮寄地址可以为欧盟境内(免费送货)的地址。
拿着RECHNUNG在机场海关盖章。(机场海关还会再夹一张表格?)
将以下东西寄给Amazon.de:
原件:海关盖章的RECHNUNG
复印件:护照的首页、签证页、出入境页
地址如下:
Amazon.de
Umsatzsteuererstattung
Im Gewerbepark D 55
93059 Regensburg
Deutschland

申根(签证)主要是和出入境相关的。
欧盟主要和退税相关。
欧元区是指当地主要流通货币是欧元。

我在amazon.de据说和.uk, .us是一个账户;但和.cn的账户是用不了的)上注册了个账号,然后就退税提问,下面是回答的主体——应该是同一模版,没有细节,也没有回答我的具体问题。结合网上的一些中文信息,可以有个大体了解,可能实际操作也很简单、没有各种坑,就没有人有动力提供详细攻略了。

From: cs-reply@amazon.de
To qualify for the refund, the following legal deadline must be met: the item must be exported before the third calendar month following the month in which the goods were received has expired.

For legal reason, we require proof that:

*your residence is abroad (*non*EU) as far as this is not evident from the export certificate, and
*that the items you purchased from Amazon.de have been declared at the customs

Please send both documents as well as the original invoice (essential!) to the following address:

Amazon.de
Umsatzsteuererstattung
Im Gewerbepark D 55
93059 Regensburg
Deutschland

We will keep the original invoice and the confirmation for our records. If you need a copy of your invoices, please tell us the respective order numbers and we will send you the copies.

2012-07-17

Time sync issues - SQL Server login

There is weird problem occurred just yesterday: in the same domain, using the same domain account (Windows Authentication), but on two different computers, everything is fine on the first computer (which is the domain controller); but, one the other computer it is impossible to connect to SQL Server DB (which is also in the same domain).

We doubted our own program first, so we tried SQL Server Management Studio, and it also failed, mentioning "Failed to generate SSPI context".
Then, we switched from FQDN to IP address, succeeded but seems a little bit slower than normal.
So, we doubted the DNS server - running nslookup - but it's fine.

We compared every possible differences might exist between the two, finally there is the one: the second computer has the year as 2010 instead of 2012!
As it is a shared testing environment, it is hard to know and remember who did the change and why.

The reason is that for security the time is critical and a much longer one which is knowledge oriented not problem concentrated.
And this could be in a more subtle: different time zone showing the same time.