Aloha せかい - admin
type: channel
link: https://blog.2cn.in/index.php/tag/admin/
items: [repost] Injecting a DLL in a Modern UI Metro Application
items: [Repost] Network icon showing a red X after installing Bluesoleil
items: The road to retro of pie
items: Repost: 流感下的北京中年 original by 李可 & 复盘 Original by caixin
items: Start-stop-daemon demo
items: Install gcc-4.9 on Ubuntu 14.04 LTS
items: Tricks about Aliyun API signature.
items: Repost: HMAC functions in Delphi (HMAC_SHA256, HMAC_SHA1)
items: Tips on enabling nginx cache

[repost] Injecting a DLL in a Modern UI Metro Application
type: item
date: 2019-09-01T19:37:00+08:00
description: Original link: https://blog.nektra.com/main/2013/02/25/injecting-a-dll-in-modernui-metro-app-win8/Dll injection is one of the oldest techniques used to run custom code inside a target application in Windows. It is usually used to intercept and modify normal application behavior or add new functionality.Injecting a DLL in a target process is a relatively easy task: you simply create a remote thread that calls LoadLibrary using CreateRemoteThread or NtCreateThreadEx. You will need some privileges to be able to access the injected process but that is beyond the scope of this article.When you try to inject a library into a Windows 8 Modern UI Metro application you will find that although the injection code works as expected, your DLL will NOT load, LoadLibrary will return FALSE and GetLastError will return ERROR_ACCESS_DENIED.Well, you think… Modern UI applications have very limited access to computer resources and run in a sandboxed environment, so problems are to be expected.While doing some research on how to add new functionallity to the Windows Mail application that comes with Windows 8 and how to hook Modern UI apps using Deviare, we needed find out why LoadLibrary was failing.Reverse engineering comes into playWe started to analyze what LoadLibrary does. It calls LoadLibraryEx with dwFlags=0 and LoadLibraryEx does some checks. First stop.If you want to load a package you must use the LoadPackagedLibrary API. If you want to load a normal DLL, you have to use LoadLibrary[Ex]. LoadPackagedLibrary documentation says that the path cannot be absolute or contain “..” but these checks are mainly done in the LoadLibraryEx routine. The only difference between LoadLibrary and LoadPackagedLibrary is wether the dwFlags parameter has a value of 4 or of zero.Among other things, LoadLibraryEx will build the search path to locate your DLL and then call the undocumented LdrLoadDll. Because we want to enforce using the path where our library is located, we changed our code to call …

[Repost] Network icon showing a red X after installing Bluesoleil
type: item
date: 2018-09-20T13:44:00+08:00
description: Original: Microsoft CommunitySymptom: After installing Bluesoleil, the network icon on the system tray shows a red X all the time regardless what the current state is with network connectionOne cause: In my particular case, this problem was caused by conflicts between Bluesoleil and VPN softwareSolution: Uninstall both Bluesoleil and VPN, and then install Bluesoleil first. If you need VPN, install VPN after Bluesoleil has been installed.I'm writing this post to benefit people who might have this very same problem. There are a few similar threads in this forum, and there were not any real solutions, but they're all locked for updates. It is an annoying nuisance, but it could be very painful and costly if you want to resolve this problem. Since most of the solutions suggested involve fiddling with drivers and/or Windows Registry, you could brick your computer if you don't really know what you're doing. I'm an experienced software developer, so based on my experiences and instincts, I could tell those dozens of (if not more) suggestions from various forums if they had a chance to solve my problem. But even so, it costed me well over half a day to finally resolve this problem. Luckily I finally found the culprits and a relatively easy and unpainful solution.Bluesoleil is a Bluetooth application provided with many cheap USB bluetooth dongles, especially for those ones made in China. It provides a rich set of BT stacks for supporting extensive BT functionalities. Thanks to the generic and poor BT support in MS Windows, Bluesoleil is one of very few solutions you can get if you want to make the more extensive BT functionalities work in the Windows environment.I have a few USB BT dongles lying around. I use one of them sporadically simply for transferring files between various mobile devices and PC--it's easier than doing this via wired or wifi network connections for not very large files. The generic BT support in Windows suffices this need, so I've never bothered to use a…

The road to retro of pie
type: item
date: 2018-06-05T09:18:00+08:00
description: This is an article under construction...To display Chinese on the game list, install the following components:sudo apt-get install libsdl2-dev libboost-system-dev libboost-filesystem-dev libboost-date-time-dev libboost-locale-dev libfreeimage-dev libfreetype6-dev libeigen3-dev libcurl4-openssl-dev libasound2-dev libgl1-mesa-dev build-essential cmake fonts-droid

Repost: 流感下的北京中年 original by 李可 & 复盘 Original by caixin
type: item
date: 2018-04-27T15:07:00+08:00
description: Source: https://mp.weixin.qq.com/s/fqJ0NYpumVKPQhkOMQd8Hg女儿：“姥爷怎么这么长时间还不回来？”妈妈：“姥爷生病了，在医院打针。”女儿：“姥爷是我最好的朋友，姥爷给我吃巧克力。”“妈妈怎么哭了？”==========================全文近2.6万字，与平时巴菲特主题无关，请订阅者见谅。本文逐日记录岳父从流感到肺炎、从门诊到ICU，29天阴阳两隔的经历。涉及就诊、用药、开销、求血、插管、人工肺（ECMO）等信息，希望大家用不上！下列主题，可以搜索标题里的关键字或日期进行查询：不隔离流感家人，你就是在害孩子：12月28日-31日病毒阴性、高烧不退，马上去大医院：1月3日-4日护士不给高热病人挂号，你应该怎么办：1月4日为何感冒病人要吸氧：1月5日卧倒、卧倒，别再让重症感冒病人走路了：1月5日选择住院医院的标准，如果你能选的话：1月5日从流感到肺炎，不是小病，是生命保卫战：1月5日如何买达菲：1月5日心电监护仪，没他真不行：1月7日救护车费用：1月8日ICU开销：1月8日人在ICU，你借出的钱能收得回来吗：1月8日插管前，说出遗言：1月11日人工肺（ECMO）费用：1月11日为亲属上人工肺（ECMO），你的决定遗漏了什么？：1月11日，1月18日医生不会告诉你的人工肺（ECMO）信息：治愈概率、愈后情况、治疗时间：1月13日人工肺（ECMO）与脑溢血和血栓：1月13日人工肺（ECMO）与谵（zhan）妄：1月18日输血不是花钱就能有，互助献血操作流程：1月13日大医院转小医院，为什么会这样：1月22日肺移植：1月22日远程重症病人救护车运输：1月22日担架病人搭乘民航班机规定：1月22日远程重症病人医疗飞机运输（实现小目标后入）：1月22日民航关于携带骨灰的规定：1月23日亲人过世，通知殡仪馆，远离太平间：1月23日开具死亡证明，你需要的证件：1月24日为遗体穿衣，谁会帮你的第一次：1月24日火化流程：1月24日==========================一、流感女儿：“姥爷不听话，光膀子，感冒啦！”*12月27日（星期三）下午，阳光灿烂，岳母打开主卧窗子通风。岳父忽然来了个念头，一定要同时打开厨房窗子南北对流通风，并且坚持不穿上衣，吹了半小时。期间岳母两次要他穿衣服，一次让他关窗，均被拒绝。当时我也在家，为了避免矛盾，我没有径直去关窗，故意和岳母打了个招呼：“妈，我把窗关了哈！”岳母还没说话，岳父说：“不得（dei，三声）！”岳父开窗和不穿衣服和他的习惯有关。我们南方人冬天在家都穿羽绒服，我结婚前第一次去黑龙江惊掉了下巴：外面零下20度，屋里零上30度；家家都开窗，人人小背心。但北京不是黑龙江，屋里只有21度。今年又没有下雪，流感肆虐。岳父表态后，我习惯性沉默，检查三岁的孩子已经穿上羽绒服后，自己裹上衣服回屋去了。作为一个能伺候夫人穿袜的南方女婿，和餐桌上动辄骂岳母菜咸了淡了的东北岳父，相处只能说是表面上过得去。双方都是为了孩子，互相忍受。偶尔和天南海北的朋友吐槽，一美国朋友下决心：“我宁可穷三年，也不让老人帮我带孩子。”我心有戚戚焉，但夫人坚决反对：“你去哪里找那么放心的人带孩子？”*12月28日（星期四）岳父开始感冒流涕。他懒得一遍一遍去洗手间，拿了孩子的尿不湿放在床边，让鼻涕淌在尿不湿上。我开始尽量让岳父和孩子隔离。但岳父是女儿“最好的朋友”+唯一的巧克力提供者，用东北话说叫岳父是女儿的“仗义”。孩子一发现我们要和她“谈话”，大喊姥爷，流出两滴眼泪，就能迅速反败为胜，绽开胜利的笑容。岳父东北man式喷嚏，瀑布式流鼻涕都是逗孩子的新手段，完全不能制止他们亲密无间。岳母：“吃点感冒药吧”。岳父：“我这身板，没事”。岳母：“打喷嚏你挡着点，别喷到孩子”岳父大怒：“这又没啥病毒”。*12月29日（星期五）岳父开始发烧，愿意吃感冒药了。孩子继续跟姥爷粘在一起。我感觉不对了，和夫人商量带孩子出去住酒店。夫人不同意，因为孩子上幼儿园后一直生病，外出怕有病菌。又问能不能岳父岳母出去住。夫人还是不同意，说是爸爸发烧了，需要在家照顾。我问：“感冒会不会传染？夫人答：“我也担心”。“传染”这个词需要定义概念。有人，比如我，认为接近100%会发生。而另一些人，例如我夫人，认为只有20%的概率，而且自己孩子还绝对不在这20%之中。就像我一贯认为发芽的大蒜有毒，每次扔这种大蒜都会引发矛盾，夫人经常嘲笑：“你家宝都已经吃了好久发芽大蒜做的菜了。”我大怒。然后洗洗就睡了。*12月30日（星期六）岳父挺不住了，去了通州民营医院甲。为啥会到这个医院呢，因为小孩进幼儿园前到这个小医院体检过。老人觉得位置近，不排队，反正异地医保也报不了多少。东北老国企，现在的医保大概只结算到2014年…

Start-stop-daemon demo
type: item
date: 2018-03-25T15:11:57+08:00
description: Start-stop-daemon is a tiny but useful stock Linux util by Debian and Ubuntu. You can turn almost every executable into background daemon.Usage: start-stop-daemon [ ...] <command> Commands: -S|--start -- <argument> ... start a program and pass <arguments> to it -K|--stop stop a program -T|--status get the program status -H|--help print help information -V|--version print version Matching options (at least one is required): -p|--pidfile <pid-file> pid file to check -x|--exec <executable> program to start/check if it is running -n|--name <process-name> process name to check -u|--user <username|uid> process owner to check Options: -g|--group <group|gid> run process as this group -c|--chuid <name|uid[:group|gid]> change to this user/group before starting process -s|--signal <signal> signal to send (default TERM) -a|--startas <pathname> program to start (default is <executable>) -r|--chroot <directory> chroot to <directory> before starting -d|--chdir <directory> change to <directory> (default is /) -N|--nicelevel <incr> add incr to the process' nice level -P|--procsched <policy[:prio]> use <policy> with <prio> for the kernel process scheduler (default prio is 0) -I|--iosched <class[:prio]> use <class> with <prio> to set the IO scheduler (default prio is 4) -k|--umask <mask> change the umask to <mask> before starting -b|--background force the process to detach -C|--no-close do not close any file descriptor -m|--make-pidfile create the pidfile before starting -R|--retry <schedule> check whether processes die, and retry -t|--test test mode, don't do anything -o|--oknodo exit status 0 (not 1) if nothing done -q|--quiet be more quiet -v|--verbose be more verbose Retry <schedule> is <item>|/<item>/... where <item> is one of -<signal-num>|[-]<signal-name> send that signal <timeout> wait that many seconds forever repeat remainder forever or <schedule> may be just <timeout>, meaning <signal>/<timeout>/KILL/<timeout> The process scheduler <policy> can be one of: other, fifo or rr …

Install gcc-4.9 on Ubuntu 14.04 LTS
type: item
date: 2018-01-17T15:13:11+08:00
description: As you may know, Ubuntu 14.04 comes with GCC 4.8.4 which is sometimes not up to date enough to compile some project. You may want to install 4.9 or higher but "apt-get install gcc-4.9" will report that the gcc-4.9-base is already up-to-date.Here are the steps to install the real compiler on Ubuntu 14.04.First, you need to ensure you have "add-apt-repository" command installed. If not, install it byapt-get install software-properties-commonPS: for Ubuntu version lower than 12, you need: sudo apt-get install python-software-propertiesSecond, add test ppa repo:add-apt-repository ppa:ubuntu-toolchain-r/test and update your library apt-get updateThird, install the new gcc:apt-get install gcc-4.9 g++-4.9 cpp-4.9Lastly, update the symbolic links or you will not able to compile with the typical gcc command.There are mainly two ways to do it.Create links manuallycd /usr/bin rm gcc g++ cpp ln -s gcc-4.9 gcc ln -s g++-4.9 g++ ln -s cpp-4.9 cppUse update alternatives commandupdate-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.8 48 \ --slave /usr/bin/g++ g++ /usr/bin/g++-4.8 \ --slave /usr/bin/gcc-ar gcc-ar /usr/bin/gcc-ar-4.8 \ --slave /usr/bin/gcc-nm gcc-nm /usr/bin/gcc-nm-4.8 \ --slave /usr/bin/gcc-ranlib gcc-ranlib /usr/bin/gcc-ranlib-4.8update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.9 49 \ --slave /usr/bin/g++ g++ /usr/bin/g++-4.9 \ --slave /usr/bin/gcc-ar gcc-ar /usr/bin/gcc-ar-4.9 \ --slave /usr/bin/gcc-nm gcc-nm /usr/bin/gcc-nm-4.9 \ --slave /usr/bin/gcc-ranlib gcc-ranlib /usr/bin/gcc-ranlib-4.9update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-5 53 \ --slave /usr/bin/g++ g++ /usr/bin/g++-5 \ --slave /usr/bin/gcc-ar gcc-ar /usr/bin/gcc-ar-5 \ --slave /usr/bin/gcc-nm gcc-nm /usr/bin/gcc-nm-5 \ --slave /usr/bin/gcc-ranlib gcc-ranlib /usr/bin/gcc-ranlib-5Now, try gcc -v and see it reports the correct version.

Tricks about Aliyun API signature.
type: item
date: 2018-01-10T16:18:49+08:00
description: Aliyun provided an official description of the signature of API query.Here is the official document about API signature: CALL METHODThere is a small problem with its description: you must use TimeStamp instead of Timestamp!That's all and good luck.

Repost: HMAC functions in Delphi (HMAC_SHA256, HMAC_SHA1)
type: item
date: 2018-01-09T13:42:40+08:00
description: Credit: Yanniel's notesI came across HMAC (Hash-based message authentication code) functions when developing a RESTful client application in Delphi. The RESTful Web Service API required me to send HMAC_SHA256 signatures (Base64 encoded) with each HTTP request.HMAC functions take two parameters: a key and a message. The purpose of the HMAC function is to authenticate the message and guarantee the data integrity of the message.The cryptographic strength of the HMAC function lies on the underlying hashing function that it uses: MD5, SHA1, SHA256, etc.So, these functions are usually are termed HMAC_SHA256, HMAC_SHA1, HMAC_MD5 to connote the core hashing function being used.The outcome of a HMAC function is basically an array of bytes, but it is usually represented as a hexadecimal string or encoded as a Base64 string. (The RESTful Web Service API needed the Base64 encoded output).I Googled around for a bit, but I didn’t get a clean implementation of HMAC_SHA256 in Delphi (encoded as Base64). I glued together the pieces from some questions on StackOverflow and coded an Indy based implementation that uses generics to specify the core hashing function.Brief description: I created a helper class called THMACUtils. Note that this class uses generics to indicate the hashing algorithm (TIdHMACSHA256, TIdHMACSHA1). Three functions are provided: the main thing happens in the HMAC(...) function; HMAC_HexStr(...) and HMAC_Base64(...) are simply decorations of the output.unit HMAC; interface uses System.SysUtils, EncdDecd, IdHMAC, IdSSLOpenSSL, IdHash; type THMACUtils<T: TIdHMAC, constructor> = class public class function HMAC(aKey, aMessage: RawByteString): TBytes; class function HMAC_HexStr(aKey, aMessage: RawByteString): RawByteString; class function HMAC_Base64(aKey, aMessage: RawByteString): RawByteString; end; implementation class function THMACUtils<T>.HMAC(aKey, aMessage: RawByteString): TBytes; var _HMAC: T; begin if not IdSSLOpenSSL.LoadOpenSSLLibrary then Exit; _HMAC:= T…

Tips on enabling nginx cache
type: item
date: 2018-01-03T15:18:00+08:00
description: Enabling nginx cache system is simple, just follow the official tutorial step by step, and you're ready to go. Or is it?Here is a typical nginx conf file configured as a reverse proxy with cache enabled:http { proxy_cache_path /data/nginx/cache levels=1:2 keys_zone=STATIC:10m inactive=24h max_size=1g use_temp_path=off; server { location / { proxy_pass http://1.2.3.4; proxy_set_header Host $host; proxy_cache STATIC; proxy_cache_valid 200 1d; proxy_cache_lock on; proxy_cache_background_update on; proxy_cache_use_stale error timeout invalid_header updating http_500 http_502 http_503 http_504; } } } This configures nginx to forward requests to the upstream server at http://1.2.3.4 and cache it as files in /data/nginx/cache with a maximum size of 1GB, inactive time of 24hours and in memory key cache up to 10MB, and it indeed works.However, if you copy these to your exist confs, and you'll probably find out that your cache folder is always empty. That's because there are 2 exceptions that under which the caching system won't work:Upstream server's response contains the header "Set-Cookies"proxy_buffering sets to off.Also, here are two more tips to let your nginx handles the cache request more appropriately:add directiveadd_header X-Proxy-Cache $upstream_cache_status;This will add an extra header to your response to give you an explicit vision of what your cache state is.add directiveproxy_cache_bypass $http_cache_control;This will make nginx ignore/bypass its cache when browsers/clients request resources with a no-cache header (this happens to every main page in Chrome browser).add directive:proxy_cache_purge PURGE purge_all from all; proxy_pass {your upstream server here};This will purge the entire cache if your visit the specific URL by a special PURGE request viacurl -X PURGE yoururlhere You can also purge only one page at a time by removing the purge_all option as well.Notice:proxy_cache_purge is not available for nginx free version, you need to add THIS MODULE to mak…