2013年10月13日 星期日
windbg local mode study
It will call dbgeng!LocalLiveKernelTargetInfo::InitDriver and then create kldbgdrv.sys in the c:\Windows\System32 folder.
2013年10月5日 星期六
PCI address to Device manager device description
TCHAR buf[MAX_DEVICE_ID_LEN]; // (Dynamically size this instead?)
PTSTR DriverNameToDeviceDesc (UCHAR bn, UCHAR dn, UCHAR fn, BOOLEAN DeviceId)
{
HDEVINFO hDevInfo;
SP_DEVINFO_DATA DeviceInfoData;
DWORD i;
BOOL r;
int j=0;
// Create a HDEVINFO with all present devices.
hDevInfo = SetupDiGetClassDevs(NULL,
0, // Enumerator
0,
DIGCF_PRESENT | DIGCF_ALLCLASSES );
if (hDevInfo == INVALID_HANDLE_VALUE)
{
// Insert error handling here.
return NULL;
}
// Enumerate through all devices in Set.
DWORD DataT;
DWORD buffersize = 0;
DeviceInfoData.cbSize = sizeof(SP_DEVINFO_DATA);
for (i=0;SetupDiEnumDeviceInfo(hDevInfo,i,
&DeviceInfoData);i++)
{
if(SetupDiGetDeviceRegistryProperty(
hDevInfo,
&DeviceInfoData,
SPDRP_BUSNUMBER,
&DataT,
(PBYTE)buf,
MAX_DEVICE_ID_LEN,
&buffersize))
{
if(buffersize == 4 && (UCHAR) buf[0] == bn)
{
if(SetupDiGetDeviceRegistryProperty(
hDevInfo,
&DeviceInfoData,
SPDRP_ADDRESS,
&DataT,
(PBYTE)buf,
MAX_DEVICE_ID_LEN,
&buffersize))
{
if (buffersize == 4 && (UCHAR) buf[0] == fn && (UCHAR) buf[2] == dn)
{
if(SetupDiGetDeviceRegistryProperty(
hDevInfo,
&DeviceInfoData,
SPDRP_DEVICEDESC,
&DataT,
(PBYTE)buf,
MAX_DEVICE_ID_LEN,
&buffersize))
{
return buf;
}
else
{
SetupDiDestroyDeviceInfoList(hDevInfo);
return NULL;
}
}
}
}
}
}
// Cleanup
SetupDiDestroyDeviceInfoList(hDevInfo);
return NULL;
}
PTSTR DriverNameToDeviceDesc (UCHAR bn, UCHAR dn, UCHAR fn, BOOLEAN DeviceId)
{
HDEVINFO hDevInfo;
SP_DEVINFO_DATA DeviceInfoData;
DWORD i;
BOOL r;
int j=0;
// Create a HDEVINFO with all present devices.
hDevInfo = SetupDiGetClassDevs(NULL,
0, // Enumerator
0,
DIGCF_PRESENT | DIGCF_ALLCLASSES );
if (hDevInfo == INVALID_HANDLE_VALUE)
{
// Insert error handling here.
return NULL;
}
// Enumerate through all devices in Set.
DWORD DataT;
DWORD buffersize = 0;
DeviceInfoData.cbSize = sizeof(SP_DEVINFO_DATA);
for (i=0;SetupDiEnumDeviceInfo(hDevInfo,i,
&DeviceInfoData);i++)
{
if(SetupDiGetDeviceRegistryProperty(
hDevInfo,
&DeviceInfoData,
SPDRP_BUSNUMBER,
&DataT,
(PBYTE)buf,
MAX_DEVICE_ID_LEN,
&buffersize))
{
if(buffersize == 4 && (UCHAR) buf[0] == bn)
{
if(SetupDiGetDeviceRegistryProperty(
hDevInfo,
&DeviceInfoData,
SPDRP_ADDRESS,
&DataT,
(PBYTE)buf,
MAX_DEVICE_ID_LEN,
&buffersize))
{
if (buffersize == 4 && (UCHAR) buf[0] == fn && (UCHAR) buf[2] == dn)
{
if(SetupDiGetDeviceRegistryProperty(
hDevInfo,
&DeviceInfoData,
SPDRP_DEVICEDESC,
&DataT,
(PBYTE)buf,
MAX_DEVICE_ID_LEN,
&buffersize))
{
return buf;
}
else
{
SetupDiDestroyDeviceInfoList(hDevInfo);
return NULL;
}
}
}
}
}
}
// Cleanup
SetupDiDestroyDeviceInfoList(hDevInfo);
return NULL;
}
2013年7月31日 星期三
About the GRID control for the VS MFC
I don't understand why MS don't try to provide a MFC GRID control. We can try to make CListCtrl to be the Grid control style. You can refer the MSDN document here (http://msdn.microsoft.com/en-us/library/ms364048(v=vs.80).aspx), but it's not easy. Anyway, we can use the code (http://www.codeproject.com/Articles/8/MFC-Grid-control-2-27) in the codeproject to be the base and modify it.
2013年5月7日 星期二
Windows AHCI Link power management setting
1. Run Registry Editor (type "regedit" in the search field on the Start Menu).
2. Navigate to "HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Power\PowerSettings\0012ee47-9041-4b5d-9b77-535fba8b1442\0b2d69d7-a2a1-449c-9680-f91c70521c60".
3. Change value "Attributes" to 2. At this step you won't have modified ANY functionality in Windows (except for a tiny detail in the power management USER interface), so it's 100% safe.
4. Reboot.
5. Now go to "Power Management" in Control Panel and click "Change plan settings" of your power plan, then click "Change advanced power settings".
6. Expand the "Hard Disk" settings tree. You'll see that now there is and ADDITIONAL setting: "AHCI Link Power Management - HIPM/DIPM". Expand this one.
--------------------------------------------------------------------------------------------------------
The default power setting for Balanced about ALPM (AC,DC).
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Power\PowerSettings\0012ee47-9041-4b5d-9b77-535fba8b1442\0b2d69d7-a2a1-449c-9680-f91c70521c60\DefaultPowerSchemeValues\381b4222-f694-41f0-9685-ff5bb260df2e]
"ACSettingIndex"=dword:00000001
"DCSettingIndex"=dword:00000001
2. Navigate to "HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Power\PowerSettings\0012ee47-9041-4b5d-9b77-535fba8b1442\0b2d69d7-a2a1-449c-9680-f91c70521c60".
3. Change value "Attributes" to 2. At this step you won't have modified ANY functionality in Windows (except for a tiny detail in the power management USER interface), so it's 100% safe.
4. Reboot.
5. Now go to "Power Management" in Control Panel and click "Change plan settings" of your power plan, then click "Change advanced power settings".
6. Expand the "Hard Disk" settings tree. You'll see that now there is and ADDITIONAL setting: "AHCI Link Power Management - HIPM/DIPM". Expand this one.
--------------------------------------------------------------------------------------------------------
The default power setting for Balanced about ALPM (AC,DC).
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Power\PowerSettings\0012ee47-9041-4b5d-9b77-535fba8b1442\0b2d69d7-a2a1-449c-9680-f91c70521c60\DefaultPowerSchemeValues\381b4222-f694-41f0-9685-ff5bb260df2e]
"ACSettingIndex"=dword:00000001
"DCSettingIndex"=dword:00000001
Some information is in the http://msdn.microsoft.com/en-us/library/windows/hardware/gg463243.aspx
2013年2月17日 星期日
Undocumented windbg command !chkallimg
The !chkimg extension detects corruption in the images of executable files by comparing them to the copy on a symbol store or other file repository.
!chkimg [Options] [-mmw LogFile LogOptions] [Module]
The !chkimg is useful for us to check the memory (code section) corruption problem. But if you want to check all the images, you can use the command !chkallimg. The weird thing is that it need to create the temp folder in the c:\ for !chkallimg command.
2013年1月10日 星期四
Windows -- how to send mail in the application
There is a good document to help us about this -- http://zabkat.com/blog/send-emails-with-CDOSYS.htm. You can get first view about this. And there is some sample code in the
http://www.experts-exchange.com/Programming/System/Windows__Programming/A_1820-Sending-Email-with-MAPI.html.
The easiest way is mailto..You can check http://msdn.microsoft.com/en-us/library/aa767737(VS.85).aspx.
The common way is Microsoft MAPI..http://msdn.microsoft.com/en-us/library/windows/desktop/dd296734(v=vs.85).aspx
Anyway..From the MS document..It say..[The use of Simple MAPI is discouraged. It may be altered or unavailable in subsequent versions of Windows.]
Anyway, the MAPI still work in the Win 7/Win 8. But sometime, it will return MAPI_E_FAILURE. Then you can check your application UAC setting. You can check here (http://social.msdn.microsoft.com/Forums/en-US/outlookdev/thread/63e9f5b2-f5f2-4cf8-bdc2-ca1fad88ebe5).
http://www.experts-exchange.com/Programming/System/Windows__Programming/A_1820-Sending-Email-with-MAPI.html.
The easiest way is mailto..You can check http://msdn.microsoft.com/en-us/library/aa767737(VS.85).aspx.
The common way is Microsoft MAPI..http://msdn.microsoft.com/en-us/library/windows/desktop/dd296734(v=vs.85).aspx
Anyway..From the MS document..It say..[The use of Simple MAPI is discouraged. It may be altered or unavailable in subsequent versions of Windows.]
Anyway, the MAPI still work in the Win 7/Win 8. But sometime, it will return MAPI_E_FAILURE. Then you can check your application UAC setting. You can check here (http://social.msdn.microsoft.com/Forums/en-US/outlookdev/thread/63e9f5b2-f5f2-4cf8-bdc2-ca1fad88ebe5).
2013年1月7日 星期一
PHP run executable file in the xampp of Windows
There is the document talk about this -- http://php.net/manual/en/function.exec.php
<?php function execInBackground($cmd) {
if (substr(php_uname(), 0, 7) == "Windows"){
pclose(popen("start /B ". $cmd, "r"));
}
else {
exec($cmd . " > /dev/null &");
}
} ?>
And there is also another document talk about this -- http://www.somacon.com/p395.php. In this document , it provide many methods to do this. And after my try, pclose(popen("start /B ". " c:\\new\\New2.bat", "r")); is workable.
For more information, you can check http://php.net/manual/en/function.popen.php.
<?php function execInBackground($cmd) {
if (substr(php_uname(), 0, 7) == "Windows"){
pclose(popen("start /B ". $cmd, "r"));
}
else {
exec($cmd . " > /dev/null &");
}
} ?>
And there is also another document talk about this -- http://www.somacon.com/p395.php. In this document , it provide many methods to do this. And after my try, pclose(popen("start /B ". " c:\\new\\New2.bat", "r")); is workable.
For more information, you can check http://php.net/manual/en/function.popen.php.
訂閱:
文章 (Atom)