tag:blogger.com,1999:blog-86439665321237514962023-11-16T16:56:01.740+01:00I work without regaining consciousnessUnknownnoreply@blogger.comBlogger94125tag:blogger.com,1999:blog-8643966532123751496.post-75190094426274174142020-11-25T17:24:00.006+01:002020-11-25T17:42:51.371+01:00How to revive Apple Silicon M1 after the "Failed to personalize the software update" error.<p>I was tried to reset Apple Silicon M1 computers. I have both MacBook Pro and Mac Mini. Unexpectedly, I always got the "Failed to personalize the software update" error every time at the end of clean Big Sur 11.0.1 installation. I tried to user all ways to recover:
<ul>
<li>The recovery mode</li>
<li>The bootable USB installer. See <a href="https://support.apple.com/en-us/HT201372" target="_blank">link #1</a></li>
<li>The device firmware update (DFU) with Apple Configurator 2 on an another Mac. See <a href="https://support.apple.com/guide/apple-configurator-2/revive-or-restore-a-mac-with-apple-silicon-apdd5f3c75ad/mac" target="_blank">link #1</a>, <a href="https://mrmacintosh.com/restore-macos-firmware-on-an-apple-silicon-mac-boot-to-dfu-mode/" target="_blank">link #2</a></li>
</ul>
Unfortunately, Nothing above helped.</p>
<p>I got a piece of progress when I disconnect my MacBook Pro from Apple Id. I got the "Erase Mac" dialog which really helps to recover my MacBook Pro. I failed when I did the reset again because no "Erase Mac" dialog was appeared. The problem is that i can't find the "Erase Mac" menu item in recovery.</p>
<p>The question is how to induce "Erase Mac" dialog. After a day of investigations I found the way on ... apple website: <a href="https://support.apple.com/en-us/HT211983" target="_blank">https://support.apple.com/en-us/HT211983</a> on items from #1 to #9.</p>
<div class="separator" style="clear: both;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjG6lVRQIYslS25zzn6ZNMR2YK3_6RE-oQ_BLG4K528lWCVAzUQv1sUJbgFbQpKr1Txt4M4vf2A2Ewla4cvauXdS-5xLjf9R76-BtBMkENXYlo7xfgYUhsM3kJh726YphuSmApHchn7Ngem/s2048/IMG_20201125_125736.jpg" style="display: block; padding: 1em 0; text-align: center; "><img alt="" border="0" width="320" data-original-height="1536" data-original-width="2048" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjG6lVRQIYslS25zzn6ZNMR2YK3_6RE-oQ_BLG4K528lWCVAzUQv1sUJbgFbQpKr1Txt4M4vf2A2Ewla4cvauXdS-5xLjf9R76-BtBMkENXYlo7xfgYUhsM3kJh726YphuSmApHchn7Ngem/s320/IMG_20201125_125736.jpg"/></a></div><div class="separator" style="clear: both;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgOZaG8uugx0zJpRLHJIMbsODNMjXpjptnh-CfHlFjrz2e204tHGmSSTAaqZ2zeHNvyB11HP7U-HUrYaoBcyH8vftNcL7h__qzzq-kORdsQRKDPhnaJCR35ICVE7oE5AO7mqWW37cuIoru2/s2048/IMG_20201125_125813.jpg" style="display: block; padding: 1em 0; text-align: center; "><img alt="" border="0" width="320" data-original-height="1536" data-original-width="2048" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgOZaG8uugx0zJpRLHJIMbsODNMjXpjptnh-CfHlFjrz2e204tHGmSSTAaqZ2zeHNvyB11HP7U-HUrYaoBcyH8vftNcL7h__qzzq-kORdsQRKDPhnaJCR35ICVE7oE5AO7mqWW37cuIoru2/s320/IMG_20201125_125813.jpg"/></a></div><div class="separator" style="clear: both;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiHhV_TZEh06CHEGioVpAF1BR3hPbrXrT-jSczsVKbYLcH4lBU5UlvdjyNDax-VeTpxJayGX4rxiMTMO1YzFXI9SfL-R57xXj-Z1lR5EpJNM8O85xJlcVjoruvplC97yb6qtRd9ee8FBaWu/s2048/IMG_20201125_125837.jpg" style="display: block; padding: 1em 0; text-align: center; "><img alt="" border="0" width="320" data-original-height="1536" data-original-width="2048" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiHhV_TZEh06CHEGioVpAF1BR3hPbrXrT-jSczsVKbYLcH4lBU5UlvdjyNDax-VeTpxJayGX4rxiMTMO1YzFXI9SfL-R57xXj-Z1lR5EpJNM8O85xJlcVjoruvplC97yb6qtRd9ee8FBaWu/s320/IMG_20201125_125837.jpg"/></a></div>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-8643966532123751496.post-27246796749855193022017-01-18T11:21:00.002+01:002017-02-09T12:14:22.268+01:00The unexpected behavior of std::mutexHi there, this time I would like to tell about the issue in Microsoft implementation of <i>std::mutex</i> for VS2013. This night I spent in deep debugging trying to understand why my test is failing with <i>std::mutex</i>. but isn't failing with <i>boost::mutex</i>. The only difference was in calling <i>DllMain()</i> for my DLL. It was looked like somebody secretly called <i>LoadLibrary()</i> during <i>std::mutex::lock()</i>. I was very surprised when found that it's truth (Important: our product has static linking with Microsoft CRT):
<a href="http://workblog.pilin.name/2017/01/the-unexpected-behavior-of-stdmutex.html#more">Read more »</a>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-8643966532123751496.post-62923543617384308962016-10-26T00:13:00.002+02:002016-10-31T12:46:58.856+01:00Trampolines for hooking<p>Here I would like to show all variants of trampolines which I know.</p>
<h3>32-bits Intel architecture (x86):</h3>
<pre class="brush:windbg_x86">
; 5 code bytes
; relative addressing
; no registers modification
; EIP+78563412h == 0019fa9ah+78563412h == 78702each
0019fa95 e912345678 jmp 78702each
0019fa9a
</pre>
<pre class="brush:windbg_x86">
; 6 code bytes
; absolute addressing
; no registers modification
0019fa95 6812345678 push 78563412h
0019fa9a c3 ret
0019fa9b
</pre>
<pre class="brush:windbg_x86">
; 8 code bytes
; absolute addressing
; EAX value lost
0019fa95 c7c012345678 mov eax,78563412h
0019fa9b ffe0 jmp eax
0019fa9d
</pre>
<pre class="brush:windbg_x86">
; 6 code bytes + 4 data bytes
; absolute addressing
; no registers modification
; data in execution code
; absolute data addressing
0019fa95 ff259bfa1900 jmp dword ptr ds:[19FA9Bh]
0019fa9b 12345678 dd 78563412h
0019fa9f
</pre>
<h3>64-bits AMD architecture (amd64 / x86_64 / x64):</h3>
<pre class="brush:windbg_x64">
; 14 code bytes
; absolute addressing
; no registers modification
00000000`0014f605 6812345678 push 78563412h
00000000`0014f60a c74424049abcdef0 mov dword ptr [rsp+4],0F0DEBC9Ah
00000000`0014f612 c3 ret
00000000`0014f613
</pre>
<pre class="brush:windbg_x64">
; 6 code bytes
; absolute addressing in lower 4Gb
; no registers modification
00000000`0014f605 6812345678 push 78563412h
00000000`0014f60a c3 ret
00000000`0014f60b
</pre>
<pre class="brush:windbg_x64">
; 12 code bytes
; absolute addressing
; change RAX (return value register)
00000000`0014f605 48b8123456789abcdef0 mov rax,0F0DEBC9A78563412h
00000000`0014f60f ffe0 jmp rax
00000000`0014f611
</pre>
<pre class="brush:windbg_x64">
; 13 code bytes
; absolute addressing
; change R11 (temporary register)
00000000`0014f605 49bb123456789abcdef0 mov r11,0F0DEBC9A78563412h
00000000`0014f60f 41ffe3 jmp r11
00000000`0014f612
</pre>
<pre class="brush:windbg_x64">
; 6 code bytes + 8 data bytes in range RIP±2Gb
; absolute addressing
; no registers modification
; data in execution code
; relative data addressing
; RIP+00000000h == 00000000`0014f60bh+00000000h == 00000000`0014f60bh
00000000`0014f605 ff2500000000 jmp qword ptr [00000000`0014f60bh]
00000000`0014f60b 123456789abcdef0 dq 0F0DEBC9A78563412h
00000000`0014f613
</pre>
<pre class="brush:windbg_x64">
; 5 code bytes
; relative addressing RIP±2Gb
; no registers modification
; EIP+78563412h == 00000000`0014f60ah+78563412h == 00000000`786b2a1ch
00000000`0014f605 e912345678 jmp 00000000`786b2a1ch
00000000`0014f60a
</pre>
<p>P.S. Please let me know if you have new variant.</p>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-8643966532123751496.post-23727514335993108492016-07-09T12:21:00.002+02:002016-07-09T12:45:12.831+02:00Solve the "no GUID has been associated with this object" compiler error for __uuidof in templates instantinations<p>As you know WinRT has C++ interfaces <i>ABI::Windows::Foundation::Collections::IIterable</i> and <i>ABI::Windows::</i><i>Foundation</i><i>::Collections::IIterable</i> to make iteration in collections universal. This is the very good idea, but you got interfaces with templates: (see <i>windows.foundation.collections.h</i>):</p>
<pre class="brush:cpp">namespace ABI {
namespace Windows {
namespace Foundation {
namespace Collections {
template <class T>
struct IIterator
: IIterator_impl<T>
, detail::not_yet_specialized<IIterator<T>>
{
};
template <class T>
struct IIterable
: IIterable_impl<T>
, detail::not_yet_specialized<IIterable<T>>
{
};
template <class T, bool isStruct>
struct IIterator_impl : IInspectable
{
private:
typedef typename Windows::Foundation::Internal::GetAbiType<T>::type T_abi;
typedef typename Windows::Foundation::Internal::GetLogicalType<T>::type T_logical;
public:
typedef T T_complex;
virtual /* propget */ HRESULT STDMETHODCALLTYPE get_Current(_Out_ T_abi *current) = 0;
virtual /* propget */ HRESULT STDMETHODCALLTYPE get_HasCurrent(_Out_ boolean *hasCurrent) = 0;
virtual HRESULT STDMETHODCALLTYPE MoveNext(_Out_ boolean *hasCurrent) = 0;
virtual HRESULT STDMETHODCALLTYPE GetMany(_In_ unsigned capacity, _Out_writes_to_(capacity,*actual) T_abi *value, _Out_ unsigned *actual) = 0;
};
template <class T>
struct IIterable_impl : IInspectable
{
private:
typedef typename Windows::Foundation::Internal::GetAbiType<T>::type T_abi;
typedef typename Windows::Foundation::Internal::GetLogicalType<T>::type T_logical;
public:
typedef T T_complex;
virtual HRESULT STDMETHODCALLTYPE First(_Outptr_result_maybenull_ IIterator<T_logical> **first) = 0;
};
}}}}
</pre>
<a href="http://workblog.pilin.name/2016/07/solve-no-guid-has-been-associated-with.html#more">Read more »</a>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-8643966532123751496.post-88912689986383280312015-09-18T18:07:00.001+02:002015-09-18T18:07:50.754+02:00How to load strong named assembly from the location out of application base directory to new application domainI found the only one decision: dynamically generate the configuration file in temporary folder:
<pre class="brush:xml">
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="YYY" culture="" publicKeyToken="0123456789012345" />
<codeBase version="K.L.M.N" href="file:///X:/XXX/YYY.DLL" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="ZZZ" culture="" publicKeyToken="1234567890123456" />
<codeBase version="A.B.C.D" href="file:///X:/XXX/ZZZ.DLL" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
</pre>
And set it to <i>AppDomainSetup.ConfigurationFile</i>:
<pre class="brush:csharp">
var appDomain = AppDomain.CreateDomain("MyDomain", null, new AppDomainSetup
{
ConfigurationFile = configFile
});
</pre>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-8643966532123751496.post-18446749006311261002014-09-07T03:24:00.001+02:002014-09-09T18:14:13.764+02:00Powershell script to close mercurial branches older then 60 daysGitHub <a href="https://github.com/ww898/HgCloseOldBranches">link</a>
<pre class="brush:powershell">
# Close old branches for Mercurial
# Copyright (C) 2014 Mikhail Pilin
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
if ($PSVersionTable.PSVersion.Major -lt 3) {
throw "PS Version $($PSVersionTable.PSVersion) is below 3.0."
}
Set-StrictMode -Version Latest
$ErrorActionPreference = [System.Management.Automation.ActionPreference]::Stop
$script:VerbosePreference = "Continue"
$encoding = "cp866"
[System.TimeSpan]$alive = [System.TimeSpan]::FromDays(60)
[System.DateTime]$now = [System.DateTime]::Now
[System.Object]$current = & hg parent --encoding $encoding -T "{node} {branch}" | ForEach-Object {
$result = $_ | Select-Object -Property node, name
$parts = $_.Split(' ', 2)
$result.node = $parts[0]
$result.name = $parts[1]
$result
} | Select-Object
Write-Host "Current branch: " -nonewline
Write-Host -foregroundcolor gray $current.name
[System.Object[]]$branches = @(& hg head --encoding $encoding -T "{date(date,'%Y%m%d%H%M%S')} {node} {branch}\n" | ForEach-Object {
$result = $_ | Select-Object -Property date, node, name
$parts = $_.Split(' ', 3)
[System.DateTime]$result.date = [System.DateTime]::ParseExact($parts[0], "yyyyMMddHHmmss", [System.Globalization.CultureInfo]::InvariantCulture)
$result.node = $parts[1]
$result.name = $parts[2]
$result
} | Where-Object { $now - $_.date -gt $alive } | Sort-Object -property date)
function EscapeBranchName
{
Param([System.String]$name)
$name.Replace('"', '\"')
}
if ($branches.Length -eq 0) { Write-Host "No old branches were detected" } else {
Write-Host "Closing $($branches.Length) old branches:"
$branches | ForEach-Object {
Write-Host "[$([System.String]::Format("{0:%d}", $now - $_.date)) days] " -nonewline
Write-Host -foregroundcolor gray $_.name
& hg debugsetparent $_.node | Out-Null
if ($LastExitCode -ne 0) { Write-Warning "Failed to set node (exit code $LastExitCode)." } else {
& hg branch $(EscapeBranchName $_.name) | Out-Null
if ($LastExitCode -ne 0) { Write-Warning "Failed to set branch (exit code $LastExitCode)." } else {
& hg commit --close-branch -X * -m $("The branch was not used for {0:%d} days and closed automatically." -f ($now - $_.date)) | Out-Null
if ($LastExitCode -ne 0) { Write-Warning "Failed to commit (exit code $LastExitCode)." }
}
}
}
Write-Host "Restore current branch: " -nonewline
Write-Host -foregroundcolor gray $current.name
& hg debugsetparent $current.node | Out-Null
if ($LastExitCode -ne 0) { Write-Warning "Failed to set node (exit code $LastExitCode)." } else {
& hg branch $(EscapeBranchName $current.name) | Out-Null
if ($LastExitCode -ne 0) { Write-Warning "Failed to set branch (exit code $LastExitCode)." }
}
}</pre>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-8643966532123751496.post-24174566548822449722014-03-02T03:12:00.001+01:002016-07-09T12:26:07.430+02:00Decoding the parameters of a thrown C++ exception (0xE06D7363)<p>I have a lot questions after reading the <a href="http://blogs.msdn.com/b/oldnewthing/archive/2010/07/30/10044061.aspx" target="_blank">post</a> about decoding structural exception 0xE06D7363 from <a href="http://blogs.msdn.com/b/oldnewthing/" target="_blank">"The Old New Thing"</a>. I like computer magic like that: take address from here add the constant two and half time and you get it. However, this magic don't help to understand how it really works and what happened if I do that. So, following code from CRT kill all magic.</p><a href="http://workblog.pilin.name/2014/03/decoding-parameters-of-thrown-c.html#more">Read more »</a>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-8643966532123751496.post-90969636641972837132013-11-06T17:16:00.002+01:002013-11-06T17:24:06.724+01:00How to install .NET Framework 1.1 on Windows 8.1<p>After update from Windows 8.0 to Windows 8.1 I found that .NET Framework 1.1 was unexpectedly disappeared. Here I give you the tested way to return it back:
<ul>
<li>Download .NET Framework Cleanup Tool (product guide <a href="http://blogs.msdn.com/b/astebner/archive/2008/08/28/8904493.aspx">here</a>) from following locations: <a href="http://cid-27e6a35d1a492af7.skydrive.live.com/self.aspx/Blog_Tools/dotnetfx_cleanup_tool.zip">here</a> or <a href="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Components-PostAttachments/00-08-90-44-93/dotnetfx_5F00_cleanup_5F00_tool.zip">here</a></li>
<li>Unzip and run following commands:</br>
<pre class="brush:plain">
cleanup_tool.exe /q:a /c:"cleanup.exe /p .NET Framework 1.0"
cleanup_tool.exe /q:a /c:"cleanup.exe /p .NET Framework 1.1"
</pre></li>
<li>Following instructions were taken from <a href="http://saranspot.blogspot.de/2009/02/installing-dotnet-framework-11-on.html">here</a>:
<ul>
<li>Create a new folder named DotNet in C:\ drive. (The path i used was C:\DotNet)</li>
<li>Download <a href="http://www.microsoft.com/Downloads/details.aspx?FamilyId=262D25E3-F589-4842-8157-034D1E7CF3A3&displaylang=en">Microsoft .NET Framework 1.1 Redistributable Package</a> (dotnetfx.exe). Make sure the setup file is saved as dotnetfx.exe.</li>
<li>Download <a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=a8f5654f-088e-40b2-bbdb-a83353618b38&displaylang=en">Microsoft .NET Framework 1.1 Service Pack 1</a> (NDP1.1sp1-KB867460-X86.exe). Rename the file to dotnetfxsp1.exe.</li>
<li>Copy both installation files into the same directory (i.e. C:\DotNet),.</li>
<li>Open Command Prompt as Administrator.</li>
<li>Change to the directory where the two installation files are stored, ie C:\DotNet.</li>
<li>Run the following commands one by one:</br>
<pre class="brush:plain">
dotnetfx.exe /c:"msiexec.exe /a netfx.msi TARGETDIR=C:\DotNet"
dotnetfxsp1.exe /Xp:C:\DotNet\netfxsp.msp
msiexec.exe /a c:\DotNet\netfx.msi /p c:\DotNet\netfxsp.msp
</pre></li>
<li>Install Microsoft .Net Framework 1.1 with slipstreamed Service Pack 1 by running netfx.msi from the working folder.</li>
</ul>
</li>
</ul>
</p>
<p>Good luck!</p>Unknownnoreply@blogger.com10Munich, Germany48.1367203 11.57675399999993747.9672328 11.254030499999937 48.3062078 11.899477499999938tag:blogger.com,1999:blog-8643966532123751496.post-88207901631309169862013-06-07T17:04:00.000+02:002016-07-09T12:26:07.499+02:00Tricky macro to add file name and line number in C++ operator new<p>
Header file:
<pre class="brush:cpp">
#if defined(_DEBUG)
#define _CRTDBG_MAP_ALLOC
#include <crtdbg.h>
extern __declspec(thread) char const * t_File;
extern __declspec(thread) int t_Line;
inline void * __CRTDECL operator new (size_t const size) { return ::operator new (size, _NORMAL_BLOCK, t_File, t_Line); }
inline void * __CRTDECL operator new[](size_t const size) { return ::operator new[](size, _NORMAL_BLOCK, t_File, t_Line); }
#define new (t_File = __FILE__, t_Line = __LINE__, false) ? nullptr : new
#endif
</pre>
Source file:
<pre class="brush:cpp">
#if defined(_DEBUG)
__declspec(thread) char const * t_File = "???";
__declspec(thread) int t_Line = 0;
#endif
</pre>
</p>
<p>This macro doesn't work with direct operator call like <i><b>operator new(...)</b></i> in code.</p>
<p>P.S. This macro tested only on Visual Studio 2012</p>Unknownnoreply@blogger.com1tag:blogger.com,1999:blog-8643966532123751496.post-21075165427800781962013-06-06T19:35:00.002+02:002013-06-06T19:35:59.647+02:00How to enable ARM support for desktop application in Visual Studio 2012?<p>Just add following in your <i>.vcxproj</i> file, somewhere at the beginning:
<pre class="bush:xml">
<PropertyGroup>
<WindowsSDKDesktopARMSupport>true</WindowsSDKDesktopARMSupport>
</PropertyGroup>
</pre>
</p>
<p>
P.S. Surely Windows SDK for Windows 8 has to be installed.
</p>
Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-8643966532123751496.post-63693572923132379382013-03-26T21:09:00.000+01:002013-03-26T21:09:29.884+01:00The important difference between <i>ICorProfilerInfo::GetClassIDInfo()</i> and <i>ICorProfilerInfo2::GetClassIDInfo2()</i> is <i>CORPROF_E_CLASSID_IS_ARRAY</i>. The first method never returns it.Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-8643966532123751496.post-39172142730057542992013-03-07T22:02:00.002+01:002013-03-07T22:12:39.049+01:00Service environment variables<p>As you know <i>service.exe</i> generates environment variables for service every time when it starts the new service process. It merges it's own environment with ones from different places such as:
<ul>
<li><i>HKLM\System\CurrentControlSet\Control\Session Manager\Environment</i></li>
<li><i>Environment</i> key from <i>HKLM\SYSTEM\CurrentControlSet\Services\<b>YourService</b></i></li>
<li><i>AppEnvironment</i> key from <i>HKLM\SYSTEM\CurrentControlSet\Services\<b>YourService</b>\Parameters</i></li>
</ul></p>
<p>However, there are some not clear things with <i>service.exe</i>. It doesn't work correctly with <i>REG_DWORD</i>, but other part of Windows understand <i>REG_DWORD</i> correctly. So, newer write <i>REG_DWORD</i> values in <i>HKLM\System\CurrentControlSet\Control\Session Manager\Environment</i>. Please use only <i>REG_SZ</i>.</p>
<p>
<i>service.exe</i> got it's own environment variables at the system startup and doesn't change till shutdown. So, every service in system get the mix of current environment variables and environment variables from startup. So, it's impossible to delete environment variable if it was on system startup, but it's possible to overlap the value.</p>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-8643966532123751496.post-84883940478550405432012-11-22T17:44:00.000+01:002012-11-25T00:38:51.790+01:00Visual Studio project type GUIDs<p>I updated the original <a href="http://www.mztools.com/articles/2008/mz2008017.aspx">table</a>.
<table cellpadding="1" cellspacing="0" border="1">
<tr align="left" bgcolor="lightgray">
<th>Project Language</th>
<th>Project Type Guid</th>
</tr>
<tr>
<td>C#</td>
<td>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</td>
</tr>
<tr>
<td>F#</td>
<td>{F2A71F9B-5D33-465A-A702-920D77279786}</td>
</tr>
<tr>
<td>J#</td>
<td>{E6FDF86B-F3D1-11D4-8576-0002A516ECE8}</td>
</tr>
<tr>
<td>VB.NET</td>
<td>{F184B08F-C81C-45F6-A57F-5ABD9991F28F}</td>
</tr>
<tr>
<td>C++</td>
<td>{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}</td>
</tr>
</table>
</br>
<table cellpadding="1" cellspacing="0" border="1">
<tr align="left" bgcolor="lightgray">
<th>Project Type Description</th>
<th>Project Type Guid</th>
</tr>
<tr>
<td>Web Application</td>
<td>{349C5851-65DF-11DA-9384-00065B846F21}</td>
</tr>
<tr>
<td>Web Site</td>
<td>{E24C65DC-7377-472B-9ABA-BC803B73C61A}</td>
</tr>
<tr>
<td>Distributed System</td>
<td>{F135691A-BF7E-435D-8960-F99683D2D49C}</td>
</tr>
<tr>
<td>Windows Communication Foundation (WCF)</td>
<td>{3D9AD99F-2412-4246-B90B-4EAA41C64699}</td>
</tr>
<tr>
<td>Windows Presentation Foundation (WPF)</td>
<td>{60DC8134-EBA5-43B8-BCC9-BB4BC16C2548}</td>
</tr>
<tr>
<td>Visual Database Tools</td>
<td>{C252FEB5-A946-4202-B1D4-9916A0590387}</td>
</tr>
<tr>
<td>Database</td>
<td>{A9ACE9BB-CECE-4E62-9AA4-C7E7C5BD2124}</td>
</tr>
<tr>
<td>Database (other project types)</td>
<td>{4F174C21-8C12-11D0-8340-0000F80270F8}</td>
</tr>
<tr>
<td>Test</td>
<td>{3AC096D0-A1C2-E12C-1390-A8335801FDAB}</td>
</tr>
<tr>
<td>Legacy (2003) Smart Device (C#)</td>
<td>{20D4826A-C6FA-45DB-90F4-C717570B9F32}</td>
</tr>
<tr>
<td>Legacy (2003) Smart Device (VB.NET)</td>
<td>{CB4CE8C6-1BDB-4DC7-A4D3-65A1999772F8}</td>
</tr>
<tr>
<td>Smart Device (C#)</td>
<td>{4D628B5B-2FBC-4AA6-8C16-197242AEB884}</td>
</tr>
<tr>
<td>Smart Device (VB.NET)</td>
<td>{68B1623D-7FB9-47D8-8664-7ECEA3297D4F}</td>
</tr>
<tr>
<td>Workflow Foundation</td>
<td>{32F31D43-81CC-4C15-9DE6-3FC5453562B6}</td>
</tr>
<tr>
<td>Workflow (C#)</td>
<td>{14822709-B5A1-4724-98CA-57A101D1B079}</td>
</tr>
<tr>
<td>Workflow (VB.NET)</td>
<td>{D59BE175-2ED0-4C54-BE3D-CDAA9F3214C8}</td>
</tr>
<tr>
<td>Deployment Merge Module</td>
<td>{06A35CCD-C46D-44D5-987B-CF40FF872267}</td>
</tr>
<tr>
<td>Deployment Cab</td>
<td>{3EA9E505-35AC-4774-B492-AD1749C4943A}</td>
</tr>
<tr>
<td>Deployment Setup</td>
<td>{978C614F-708E-4E1A-B201-565925725DBA}</td>
</tr>
<tr>
<td>Deployment Smart Device Cab</td>
<td>{AB322303-2255-48EF-A496-5904EB18DA55}</td>
</tr>
<tr>
<td>Visual Studio Tools for Applications (VSTA)</td>
<td>{A860303F-1F3F-4691-B57E-529FC101A107}</td>
</tr>
<tr>
<td>Visual Studio Tools for Office (VSTO)</td>
<td>{BAA0C2D2-18E2-41B9-852F-F413020CAA33}</td>
</tr>
<tr>
<td>SharePoint Workflow</td>
<td>{F8810EC1-6754-47FC-A15F-DFABD2E3FA90}</td>
</tr>
<tr>
<td>SharePoint (VB.NET)</td>
<td>{EC05E597-79D4-47f3-ADA0-324C4F7C7484}</td>
</tr>
<tr>
<td>SharePoint (C#)</td>
<td>{593B0543-81F6-4436-BA1E-4747859CAAE2}</td>
</tr>
<tr>
<td>XNA (Windows)</td>
<td>{6D335F3A-9D43-41b4-9D22-F6F17C4BE596}</td>
</tr>
<tr>
<td>XNA (XBox)</td>
<td>{2DF5C3F4-5A5F-47a9-8E94-23B4456F55E2}</td>
</tr>
<tr>
<td>XNA (Zune)</td>
<td>{D399B71A-8929-442a-A9AC-8BEC78BB2433}</td>
</tr>
<tr>
<td>Silverlight</td>
<td>{A1591282-1198-4647-A2B1-27E5FF5F6F3B}</td>
</tr>
<tr>
<td>Model-View-Controller v2 (MVC2)</td>
<td>{F85E285D-A4E0-4152-9332-AB1D724D3325}</td>
</tr>
<tr>
<td>Model-View-Controller v3 (MVC3)</td>
<td>{E53F8FEA-EAE0-44A6-8774-FFD645390401}</td>
</tr>
<tr>
<td>Model-View-Controller v4 (MVC4)</td>
<td>{E3E379DF-F4C6-4180-9B81-6769533ABE47}</td>
</tr>
<tr>
<td>Windows Store Apps (Metro Apps)</td>
<td>{BC8A1FFA-BEE3-4634-8014-F334798102B3}</td>
</table>
</p>Unknownnoreply@blogger.com2tag:blogger.com,1999:blog-8643966532123751496.post-22191993122234789432012-11-10T16:23:00.001+01:002012-11-11T09:57:35.627+01:00SyntaxHighlighter brushes for WinDbg disassembler output<p>I spent a lot of time looking for <a href="http://alexgorbatchev.com/SyntaxHighlighter/">SyntaxHighlighter</a> brush for disassembler output. Unfortunately, I didn't find a good one. So, today I have to write my own brushes for it:
<ul>
<li><a href="http://pilin.name/scripts/shBrushWinDbgDisasm.js">WinDbg x86/x64 disassembler output brush</a></li>
<li><a href="http://pilin.name/scripts/shBrushWinDbgStack.js">WinDbg x86/x64 stack dump brush</a></li>
</ul>
</p><a href="http://workblog.pilin.name/2012/11/syntaxhighlighter-brush-for-windbg.html#more">Read more »</a>Unknownnoreply@blogger.com0Munich, Germany48.1366069 11.577085147.967062399999996 11.2612281 48.3061514 11.892942099999999tag:blogger.com,1999:blog-8643966532123751496.post-45035308885608269452012-10-22T22:49:00.001+02:002012-10-22T23:30:28.945+02:00How to get x64 dynamic function table critical section?<p>There is the standard way to walk on stack under Windows x64: <i>RtlLookupFunctionEntry()</i> and <i>RtlVirtualUnwind()</i> API calls. These methods use additional information to unwind stack: static and dynamic function tables. Static tables are generated by compilers and stored insight DLLs. Dynamic ones generated by application (CLR in fact is part of application) for dynamically created methods.</p>
<a href="http://workblog.pilin.name/2012/10/how-to-get-x64-dynamic-function-table.html#more">Read more »</a>Unknownnoreply@blogger.com11Munich, Germany48.1366069 11.577085147.967062399999996 11.2612281 48.3061514 11.892942099999999tag:blogger.com,1999:blog-8643966532123751496.post-42022774454181121182012-10-22T15:54:00.002+02:002012-10-23T23:22:52.169+02:00How RegSvr32 works on x64?<p><a href="http://msdn.microsoft.com/en-us/library/windows/desktop/aa384187(v=vs.85).aspx">File system redirection</a> works in x64 OS. It means that when you are 32-bits application and try to run <i>%WinDir%\<b>System32</b>\RegSvr32.exe</i>, you run <i>%WinDir%\<b>SysWOW64</b>\RegSvr32.exe</i> in fact. It's very good for compatibility. However, there is the problem when you want to register 64-bits COM DLL from 32-bits process: <b>32-bits process can't work with 64-bits DLL</b>.</p>
<p><i>RegSvr32</i> do the special work to solve this problem. It detects that it works in WOW64 mode and DLL is 64-bit then ... it disable file system redirection for current thread by the <i>Wow64EnableWow64FsRedirection()</i> call and run itself (the command line contains original path: <i>%WinDir%\System32\RegSvr32.exe</i>) with the same arguments. Ta-da... It's beautiful decision!
</p>
<p><b>Update:</b> However, run itself in 64-bits mode will be skipped when 32-bits application loads 64-bits DLL by <i>LoadLibraryEx()</i> call and get the non-right error code - only the ERROR_BAD_EXE_FORMAT (0xC1) error code is expected.
</p>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-8643966532123751496.post-22335407397485208692012-10-12T12:33:00.000+02:002012-10-13T12:53:29.463+02:00WinRT local network isolation<p>By default only VS2012 deployed applications have the localhost network isolation in disabled state. All other application can't connect to localhost. There are at least two tools to control which application can connect to localhost which not: <a href="http://msdn.microsoft.com/en-us/library/windows/apps/hh780593.aspx">CheckNetIsolation</a> and <a href="http://blogs.msdn.com/b/fiddler/archive/2011/12/10/fiddler-windows-8-apps-enable-loopback-network-isolation-exemption.aspx">EnableLoopback</a>. Here is the way how to do it from you own program:
</p><a href="http://workblog.pilin.name/2012/10/winrt-local-network-isolation.html#more">Read more »</a>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-8643966532123751496.post-33524041815305887052012-09-21T22:40:00.000+02:002012-09-25T13:00:12.150+02:00Identifiers in ETW and Profiling API<p>CLR v4.0/v4.5 can generate <a href="http://msdn.microsoft.com/en-us/library/dd264810(v=vs.100).aspx">ETW CLR events</a>. There is special section and for <a href="http://msdn.microsoft.com/en-us/library/ff356159(v=vs.100).aspx">operations relating to loading and unloading application domains, assemblies, and modules</a>. This article contains a lot of identifiers such as AppDomainID, AssemblyID, ModuleID. Descriptions of them sometimes contains word "unique". This word is parasite. All identifiers are unique, but unique only during object life. It means that it possible to have two and more different objects with the same identifier, but in different moments of an application life.</p>
<a href="http://workblog.pilin.name/2012/09/identifiers-in-etw-and-profiling-api.html#more">Read more »</a>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-8643966532123751496.post-42966597290881025032012-08-17T11:49:00.003+02:002012-10-12T12:39:33.322+02:00Windows Store feature<p>Your Windows Store application will be automatically registered if you compile it under Visual Studio 2012 and run/debug. However, <i>get_InstalledLocation()</i> method of <i>ABI::Windows::ApplicationModel::IPackage</i> interface will return error if you press Clean Build in Visual Studio.</p>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-8643966532123751496.post-10613326957884415942012-06-27T11:39:00.000+02:002016-07-09T12:26:07.406+02:00How to detect is UAC enabled or not?<p>There are at least three ways to detect UAC (User Access Control) is active or not:<ul>
<li>Check the registry value <i>EnableLUA</i> at <i>HKLM\Software\Microsoft\Windows\CurrentVersion\Policies\System</i>. However, there is the one problem: the value can be changed at any time, but it won't be used by OS until the computer reboot. So, this way is possible, but it isn't good.</li>
<li>Call <i>GetTokenInformation()</i> with <i>TokenElevationType</i> and <i>TokenElevation</i>. It doesn't work in all situations. It's impossible to detect UAC when an application runs under conventional user (<i>TokenElevationType</i> returns <i>TokenElevationTypeDefault</i> and <i>TokenElevation</i> returns <i>FALSE</i>).</li>
<li>Call private API method (valid only for Windows Vista and later):
<pre class="brush:cpp">
#pragma comment(lib, "ntdll.lib")
#define ELEVATION_UAC_ENABLED 0x1
#define ELEVATION_VIRTUALIZATION_ENABLED 0x2
#define ELEVATION_INSTALLER_DETECTION_ENABLED 0x4
extern "C"
NTSTATUS
NTAPI
RtlQueryElevationFlags(
DWORD* pFlags);
</pre>
Unfortunately, there is no declaration of this method in <a href="http://msdn.microsoft.com/en-us/library/windows/hardware/gg487428.aspx">Windows Driver Kit (WDK)</a>, but <i>ntdll.lib</i> from WDK contains it.
</li>
</ul></p>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-8643966532123751496.post-54956904123568213942012-06-24T12:44:00.000+02:002012-09-23T13:54:37.234+02:00This blog change the language today<p>Hi everybody. Today I decided to change the language of this blog. So, next messages will be in English. I promise to translate old messages from Russian to English in future.</p>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhXb_v_fjS_pCupuY6U2wTcHd5eZq0h9yT55u-BH6VCdOAGu3F2V7vcyszb9CWXXWV2NUp6qadPNcePZWfcoJr2EtzmHIjCKcHzVngjmlnjII3vxZpKVTbMMU8FruPy9E1nd-N4dqqTJcap/s1600/EnglishSpokenHere.jpg" imageanchor="1" style="margin-left:1em; margin-right:1em"><img border="0" height="78" width="400" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhXb_v_fjS_pCupuY6U2wTcHd5eZq0h9yT55u-BH6VCdOAGu3F2V7vcyszb9CWXXWV2NUp6qadPNcePZWfcoJr2EtzmHIjCKcHzVngjmlnjII3vxZpKVTbMMU8FruPy9E1nd-N4dqqTJcap/s400/EnglishSpokenHere.jpg" /></a></div>
Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-8643966532123751496.post-3375598778405649732012-06-23T09:04:00.001+02:002016-07-09T12:26:07.441+02:00Запуск non-elevated процесса из под elevated<p>Неожиданно возникла проблема, что некоторые API в Windows 8 работают только из под non-elevated пользователя и только когда UAC включен. Соответственно встал вопрос как прикинуться non-elevated пользователем, если программа запущена под elevated пользователем. Сразу скажу, мы не знаем пользователький пароль.</p>
<a href="http://workblog.pilin.name/2012/06/non-elevated-elevated.html#more">Read more »</a>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-8643966532123751496.post-18557969488027163492012-06-12T01:20:00.001+02:002012-10-12T12:39:45.713+02:00Репортаж из песочницы<p><b><a href="http://msdn.microsoft.com/en-us/library/cc980032(v=prot.10).aspx">S-1-15-2-1</a></b> (ALL_APP_PACKAGES) - это магический SID позволяет достучатся к любому файлу или каталогу из WinRT песочницы.</p>
<p><b>Update:</b> Этот же SID помогает установить соединение через named pipe из песочницы наружу.</p>
<p><b>Update:</b> Этот же SID помогает достучаться до реестра.</p>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-8643966532123751496.post-61244028029951144902012-04-28T23:18:00.011+02:002012-11-10T15:54:30.288+01:00Stack walker для CLR x64<p>Сразу оговорюсь, что в принципе можно не использовать DoStackSnapshot() вообще для платформы x64 так как в наличии есть RtlLookupFunctionEntry() и RtlVirtualUnwind(). Но, я бы не рекомендовал так делать (хотя некоторые могут со мной не согласиться), потому что во время вызова DoStackSnapshot() происходят дополнительные проверки и синхронизации, которые вы не сможете сделать другими средствами. А как же GetFunctionFromIP() скажете вы? Отвечаю, что это очень простой по устройству метод, который просто не делает весь спектр необходимых проверок.<br>
</p><a href="http://workblog.pilin.name/2012/04/stack-walker-clr-x64.html#more">Read more »</a>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-8643966532123751496.post-69016027909457214852012-01-28T18:34:00.003+01:002012-06-23T09:31:35.602+02:00Сюрприз Profiling API<p>На днях, при отладке профайлера, на приложении выделяющим и инициализирующим массив в 2Gb (максимальный размер объекта в CLR), во время очередного GC, был замечен странный кратковременный всплеск потребления памяти - выделялось дополнительно еще 2Gb (итого пиково было 4Gb). После расследования выяснилось, что на время вызова ICorProfilerCallback::ObjectReferences() CLR выделяет массив для передачи в профайлер всех исходящих рефернсов соответствующего объекта. Если референсы занимают эти самые 2Gb, то будут выделен массив в 2Gb. Проблема возникает только тогда, когда ICorProfilerCallback::ObjectReferences() возвращает всегда S_OK и производится полный обход графа для профайлера.</p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh5LP29etsJtHxakgOXFpH9blKK-NXTto-429egfyF7iILyYUNt8UojnDWJbX2nKZ95matzaoLdoSUpn5DXLWT3z3ZGEMsFkTLI9G8Mloj44SeVBNpRl3nJ8r2yg0uqhPkC2hJp1YM0DW-c/s1600/Test.jpg" imageanchor="1" style="margin-left:1em; margin-right:1em"><img border="0" height="152" width="392" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh5LP29etsJtHxakgOXFpH9blKK-NXTto-429egfyF7iILyYUNt8UojnDWJbX2nKZ95matzaoLdoSUpn5DXLWT3z3ZGEMsFkTLI9G8Mloj44SeVBNpRl3nJ8r2yg0uqhPkC2hJp1YM0DW-c/s400/Test.jpg" /></a></div><p>Собственно приложение (число 9 в коде подобрано для CLR 4.0 x64):<br />
<pre class="brush:csharp">using System;
namespace AllocationTest
{
internal class Program
{
private static void Main()
{
var tmp = new object[0x80000000U / (uint) IntPtr.Size - 9];
for (int n = 0; n < tmp.Length; ++n)
tmp[n] = tmp;
Console.Write("Press any key...");
Console.ReadKey();
Console.WriteLine();
GC.KeepAlive(tmp);
}
}
}
</pre>
<b>P.S.</b> Если убрать в примере запонение массива, то эффект наблюдается не будет.</br>
<b>P.P.S.</b>CLR v4.5 x64 может выделять массивы больше чем 2Gb! Смотри <a href="http://msdn.microsoft.com/en-us/library/hh285054(v=vs.110).aspx">gcAllowVeryLargeObjects</a>.
</p>Unknownnoreply@blogger.com0