Today’s fake email of the day

Today’s fake email of the day

Hi Dear,

How are you doing hope you are fine and OK?

I was just going through the Internet search when I found your email address

…….

So you care about an article titled “
Trap CtrlAltDel; Hide Application in Task List on Win2000/XP” in 2020 and downloaded its source code, but still don’t know my name?

Also when I read the message header (it is called view source in hotmail or view original in gmail)
From: Lisa Williams lw716545@gmail.com
Reply-To: lisawilam@yahoo.com
Message-ID: 1900588789.741179.1601566380447@mail.yahoo.com
References: 1900588789.741179.1601566380447.ref@mail.yahoo.com
X-Mailer: WebService/1.1.16718 YMailNodin Mozilla/5.0 (Windows NT 6.1; rv:81.0) Gecko/20100101 Firefox/81.0
Content-Length: 572
X-IncomingHeaderCount: 14
To: Undisclosed recipients:;
Return-Path: lw716545@gmail.com

So this is a bulk mail, I am BCCed. Kinda strange to do for a letter that express love interest. But Kudos to keep your Firefox version up to date! Although the scammer can lie here too if wanted to just like everywhere else, there is nothing really beneficial to say you mailed it from Microsoft Outlook Express.

Also in the mail header:

Received-SPF: SoftFail (protection.outlook.com: domain of transitioning gmail.com discourages use of 74.6.132.41 as permitted sender)

I wonder why…

Posted in Uncategorized | Leave a comment

Finding the right ruby version

I am installing eHMP on Centos 7. Centos 7 has ruby 2.0 out of box, thus the install

chef-client -o workstation –config ~/Projects/vistacore/.chef/knife.rb

fails with

rb-notify version 0.10.0 needs Ruby 2.2.2 or newer

Following the instructions at https://noobient.com/2019/02/12/installing-rvm-and-ruby-on-centos-7/ I got ruby 2.7 installed. However

sudo chef-client -o workstation –config ~/Projects/vistacore/.chef/knife.rb

fails with the same error.

run

ruby –version

shows that rvm has no effect on sudo. I am still running the script against Ruby 2.0

Supposedly I can sudo and install rvm there, but rvm complained and suggested me to use rvmsudo instead. Then I tried it, rvmsudo doesn’t carry over my environment, even $HOME, thus the script still fails.

After searching for awhile I found a walkaround

rvmsudo bash -c “HOME=$HOME; exec bash” chef-client -o workstation –config ~/Projects/vistacore/.chef/knife.rb

This gets the home directory passed to the script, now the script is complaining

STDERR: ERROR:  While executing gem … (OptionParser::InvalidOption) invalid option: –no-rdoc

The script was pretty old, I know. I have no time to fix the script, so I need to downgrade the ruby version. After testing for each version I settled for 2.3.

rvm install 2.3

rvm use 2.3 –default

sudo gem update –system 2.3

Now the script runs successfully.

Posted in eHMP | Tagged | Leave a comment

Fix sphinxcontrib-googleanalytics on Sphinx 1.8

The Google Analytics extension from

python -m pip install  sphinxcontrib-googleanalytics

does not work on Sphinx 1.8. When I run it, I get the following error

Could not import extension sphinxcontrib.googleanalytics (exception: cannot import name ‘ExtensionError’ from ‘sphinx.application’ (c:\python37\lib\site-packages\sphinx\application.py))

Fix is to change C:\Python37\Lib\site-packages\sphinxcontrib\googleanalytics.py Line 4

from

from sphinx.application import ExtensionError

to

from sphinx.errors import ExtensionError

After that I get another warning

WARNING: extension ‘sphinxcontrib.googleanalytics’ returned an unsupported object from its setup() function; it should return None or a metadata dictionary

Fix is to change the last line from

return app

to

return {‘version’: ‘0.1’}

Posted in Uncategorized | Leave a comment

Blinking wifi icon and black screen on Surface 2

This is the second time I run into this problem after a Windows Update. First time was halfway through last year’s Microsoft MVP Summit and I had to Remote Desktop to my home machine with a spare android tablet and Bluetooth keyboard/mouse to get access to Windows apps.  Good that the summit wifi was amazing but a Surface 2 with touch cover was way easier to carry around than the combination of tablet/keyboard/mouse.

I got around the problem by manually uninstalling  KB3033055 with dism remove package in recovery console command prompt and hide the update afterwards. But recently I got the black screen with blinking wifi icon, again after installing a bunch of Windows Updates.  So it probably has multiple causes.

Anyway this is my way to get update working as of July 2018:

1 factory reset

2 go through initial setup (wifi, microsoft account etc)

3 search for update, this would take a while

4 uncheck everything, only install the 2015 firmware update.

5 turn wifi off, reboot.

6 download kb2919355, KB3173424, KB3172614 and KB3097667 on another machine (you need the ARM edition of those updates, not x86 or x64 so the file names should contain arm) to a usb drive.

7 install in the order of kb2919355, KB3173424, KB3172614 and KB3097667 from usb drive, reboot

8 turn wifi back on and search for updates.

9 install remaining updates and reboot

Microsoft says August 14, 2018—KB4343898 (Monthly Rollup) fixes an issue with KB3033055 which has the same syndrome. Not sure if this has anything to do with KB3097667. Hopefully this is the end of black screen with blinking wifi icon for Surface owners.

Posted in Uncategorized | Leave a comment

如何在64位win10的VS2017环境下搭建汇编环境

用户AcmeContracted安装masm32失败,所以想知道是否能集成masm64到Visual Studio 2017中

VS里面masm不是单独的,是C++工具集的一部分,而在VS2017里C++工具集不是默认安装的,所以要先安装C++工具集。

安装完之后创建个C++的Win32命令项目,然后在解决方案浏览器里选中项目节点,右键,选择Build Dependencies->Build Customisations,在弹出的对话框里选中masm,然后选择OK。这会使得你的项目里的新asm文件使用ml或者ml64编译(具体使用哪个取决于你的项目当前编译配置是32位还是64位)。

另外VS里面新建文件的选择里没有asm文件的模板,随便选个纯文本格式(.h,cpp,.txt,.html都行)的来替代,建完了把扩展名改成asm,然后在解决方案浏览器里右键点文件打开文件属性对话框,把项目类型改成Microsoft Macro Assembler。确定之后这个文件就会用masm来编译了,可以重新打开文件属性对话框检查编译时使用的命令行。

如果的项目在启用asm支持之前已经有了asm文件,这些asm文件的编译设置不会被VS2017版的覆盖(因为有可能在使用第三方的asm)。如果没有值得保留的旧编译设置,可以在解决方案浏览器里右键点文件,选择排除(注意不是删除),再把文件加回来。

Posted in Uncategorized | Leave a comment

Can we run 32 bit and 64 bit code in the same process?

User redstone001 wants to know if it is possible to run 32 bit and 64 bit code in the same process – maybe in a different thread?

As Betteridge’s law of headlines say, any news ending with a question mark can be answered with the word no. But this isn’t news, so … the answer is … yeah? Kind of.

The way that Windows implements a 32 bit emulator (e.g. making  Program Files (x86) appear as Program Files to 32 bit processes) is to load 64 bit system dlls in 32 bit code… but specially crafted 64 bit dlls indeed. To be callable from a 32 bit process, everything they generate have to be 32 bit compatible. E.g. do not provide access outside of the x86 memory address space, and zero out higher 32 bit of handles etc. The way it is written is practically creating 64 bit dlls that enjoy none of the 64 bit benefits, but become much slower and heavier thanks to marshal 32 bit calls to 64 bit before calling other system dlls. Because there is no up side except compatibility, Windows only allows its own 64 bit DLLs to be callable inside a 32 bit process. If you want to reuse your code written for a different CPU architecture, it would be much faster to run a separate process and do interprocess communication.

Posted in Computers and Internet | Leave a comment

Farewell, dsoframer

I know, it is long overdue. Microsoft discontinued it a decade ago. And Office is not meant to be embedded. I even advised people to not use it in new development almost a decade ago. Then why I keep using it for so long?

Because customers don’t want changes. I work in the medical field, where some of the clients still use telnet to interface with their medical software that are probably older than I am. Once you get people hooked to a UI it is hard to change that. The fact that Microsoft discontinues dsoframer means nothing to them – once I use it, I own it. It is like Microsoft having to release an Office update for the old equation editor made by MathType 16 years ago. So I have been doing patchwork as much as I can to keep dsoframer alive.

It might be a blessing in disguise that Office 2016 finally broke dsoframer on Windows 10 in a way that I can’t fix. The control just keep calculates the scrolling sizes wrong. I have to work on a solution for customers who can accept a side-by-side UI instead of embedding Office. Shortly after I published the update Microsoft dropped the bomb that the MSI edition of Office is being discontinued, I have to say that I am lucky to have some doctors finally start accepting the side by side UI. Maybe the rest will also get use to it now there’s no alternative.

Some issues I encountered over the years

The click-to-run edition of Office dropped the registry entries required by dsoframer to function .

.Net Programmability support is not a default install option of Office

Adobe Acrobat Reader shipped with dsoframer too, and uninstall either the reader or my app breaks the remaining one. Note to self: GuidGen on samples.

Does not open document if Office is running

Various drawing issues.

I supported embedding Word longer than the Outlook team, I am really not proud of that.

Posted in Microsoft | Tagged , | 2 Comments

Getting around “Strong name signature not valid for assembly” for a ClickOnce application

When building a ClickOnce application, I need to redistribute a third party dll. But it failed the strong name validation under sn-vf thus ClickOnce launcher failed with the same error.

Microsoft (R) .NET Framework Strong Name Utility Version 4.0.30319.0
Copyright (c) Microsoft Corporation. All rights reserved.

Failed to verify assembly — Strong name validation failed.

I have no idea why the vendor signed a the file with the correct Authenticode signature but with the wrong strong name signature . However, given that they never released an update, it is unlikely to have them to fix the problem on their end.

Based on my research I now have three options:

  1. remove the strong name signature, find and replace all references to this dll by ildasm and modifying the result il code to remove the PublicKeyToken from the reference, then recompile the il code to dll using ilasm
  2. bypass ClickOnce’s strong name signature validation by coding
  3. sn-vr to remove the file from strong name signature validation

Because the dll is referenced by too many other third party assemblies it is kinda time consuming to modify all of them. And I don’t really have the permission to run anything else but my ClickOnce app on client machines so changing client side strong validation name policy is out too. I continued with the second route.

First thing I tried was to rename the file. After all, ClickOnce did not complain my database file’s strong name signature right? So I went ahead and set the reference’s CopyLocal property to false, excluded the file from application files, and added a copy of the dll under the name of dllname.dll1 to the project.  With the BuildAction property set to content this would add the dll1 file as a data file .  At the run time I used the AssemblyResolve event to load the dll1 file as an assembly when the dll is requested. Debugged the AssemblyResolve  code so the program ran without a dllname.dll file in the application directory. Now publish it as a ClickOnce Application and wait…

And ClickOnce launcher reported the same error! So ClickOnce validates strong name for data files as long as it has one, regardless of the file extension. Maybe I need to hide the strong name somehow. A natural wrapper would be a zip file, I can unzipping the file for use during AssemblyResolve .Unzipping during AssemblyResolve did not really work, the dll loading failed when I called SharpZipLib to extract the zip file. So this looked like a catch 22 – AssemblyResolve fails when loading another dll and I need another dll to unzip the file (or I have to ilmerge the code to my main executable, another thing I don’t want to do).

So AssemblyResolve is out of question. I have to unzip the dependency files before use. A natural time to do this is the beginning of Program.Main. And ClickOnce has no problem with my zip file approach now.

Since I got this zip mechanism in place what I can do more about it? Maybe putting other files that I do not really update in the file like my UI framework library or Microsoft Enterprise Library? But then I get dll not found exception before Main is executed. Maybe I need to move the extraction even earlier. What gets executed before Main? Static constructors! After moving the extracting code to a static constructor, I now suddenly cut my download size from 100mb to 30mb, a nice bonus indeed.

Posted in C#, enmsdn, Microsoft | Tagged | 3 Comments

What part of Windows is written in .Net/WPF/Silverlight?

user 曹一聪 on zhihu is curious how widely .Net is used within Windows components.

Obviously an operating system component cannot depend on something that isn’t in the operating system, so nothing uses Silverlight in the desktop version Windows. And because XP editions mostly did not ship with any .Net framework version, practically nothing from the XP days can use .Net. Only components newer than XP or rewrote after XP can use .Net, except those Windows Media Center and Tablet PC components that have .Net dependencies.

The first time .Net is available in almost all editions is Windows Vista/2008 (the server core editions make .Net optional). Because a Vista Capable sticker does not guarantee a machine with user-acceptable speed, not much in Windows Vista is using .Net. OR Windows 7 on that matter if you skip Windows Powershell. The usage of .Net is more in the consumer software (e.g. Windows Live Essentials), developer tools (e.g. Visual Studio) and business tools (e.g. SQL Server). In short, .Net is for writing apps, not really for the OS itself.

After Windows 8, Microsoft’s focus moved to Windows RT, now UWP, not much effort is done to improve the desktop, so practically nothing in the desktop got rewritten in .Net Framework.  Windows Help 2.0 is a notable exception however. Because more and more desktop components are moving to UWP (control panel, calculator, games etc), Windows 8 might be the peak of .Net Framework usage in Windows.

If you want a completed list of managed assemblies, you can just scan all dll/exe files on your system and see which file is a managed. And if a file is a managed assembly, search its references to find if WPF is used. AssemblyName.GetAssemblyName can detect a managed assembly file but it throws too many exceptions as most dll/exe files are not managed, so I use Meta Data APIs (IMetaDataDispenser/IMetaDataImport) to detect managed assemblies. The full code can be found at github.com/jiangsheng/Samples/blob/master/FindDotnetInWindows.

The initial list of managed files I found is pretty long so the scanner skip known locations that have known .Net assemblies, like the GAC, the .Net Framework folder, Windows Powershell, Visual Studio, SQL Server and  IIS. The usage of .Net in the rest of system is surprisingly sparse.  Windows itself is still a C/C++ stronghold.

Posted in enmsdn, Microsoft | Tagged , | 2 Comments

Flash Player: Loading from memory

user cucao wants to know how to play a flash file from application resource. The user wants to use a dongle to protect unauthorized viewing of the flash file so can’t just put the swf file in plain sight.

Adobe’s Flash Player, being an ActiveX with supports for many OLE containers such as Internet Explorer and Microsoft Word, implements many standard OLE interfaces (for details open the ActiveX in oleview). One of them is IPersistStreamInit, a standard interface for ActiveX controls who want to distinguish new page load vs refresh, but can be used for the user to load the swf file from memory.

The data source passed into IPersistStreamInit::Load could be a home-brew COM server that implements IStream, but since Windows already has such an implementation (CreateStreamOnHGlobal), it saves a lot of work to just load the resource into global memory (GlobalAlloc/GlobalLock/memcpy/GlobalUnlock), and creates a stream off there for loading.

//MFC and ATL instead of Windows API for readability

void LoadFlash(LPUNKNOWN player, LPCVOID data, UINT size) {
COleStreamFile streamFile; if(!streamFile.CreateMemoryStream() return;
CArchive ar (&streamFile, CArchive::store );
ar.Write(data,size); ar.Close();
streamFile.SeekToBegin();
CComQIPtr<IPersistStreamInit> playerStreamLoader(player);
if(playerStreamLoader==NULL) return;
playerStreamLoader->InitNew();
playerStreamLoader->Load(streamFile.GetStream());
}

This only works for self-contained swf files, however. To set a base url for relative url search in action scripts, a home-brew COM server that implements both IStream and IMoniker is needed.

Posted in ATL, enmsdn, MFC, Microsoft Foundation Class Library | Tagged , , , | Leave a comment