hjk41的日志

Avatar

building zlib 1.2.7 (64bit) with Visual Studio 2012

1. Open a command line window

2. C:>\ "(visual studio install directory)\Microsoft Visual Studio 10.0\VC\bin\amd64\vsvars32.bat"

3. C:>\ set path="(visual studio install directory)\Microsoft Visual Studio 10.0\VC\bin\amd64\";%path%
This is to enable the system to find "ml64.exe" when we execute the next command

4. C:>\ cd "(zlib directory)\contrib\masmx64"

5. D:\zlib\> bld_ml64.bat
This batch file will compile two assembly files into corresponding object files: inffasx64.obj and gvmat64.obj. If you want to compile into 32bit library, just replace masmx64 with masmx32, and bld_ml64.bat with bld_ml32.bat.

6. Open "(zlib directory)\contrib\vstudio\vc10\zlibvc.sln" with VS2012, and choose to update the solution. Of course you can also use VS2010, but it may pop up an error saying "error LNK1123. failure during conversion to COFF". It is said that installing SP1
of VS2010 may solve it. But I didn't try.

7. Open the project property of "zlibvc" -> Build Events -> Pre-Build Event -> Command Line. Clean the "Command Line" field. You can see that the they are trying to execute the bld_ml64.bat file. But somehow it does not work. If you don't clean the command line, you will get an error when compiling, saying "bld_ml64.bat is not recognized as command or executable".

8. Modify "zlibvc.def" line 4 from "VERSION 1.2.7" to "VERSION 1.2". Visual Studio seems to support only "Major.Minor" version number. If you don't do this, you get a "LNK1118: syntax error in 'VERSION' statement" message.

9. Compile the solution.

10. Now you should have dll and lib files generated in "(zlib directory)\contrib\vstudio\vc10\x64\ZlibDllRelease". Include "zlib.h" and link to dll or lib files in your project, and you should be able to use zlib.

买了个MK802,便宜,但还是太geek


MK802是一个U盘大小的,使用android 4.0的mini pc,提供一个HDMI接口输出和两个USB接口,并通过一个DC转换器供电。

我是打算买来当播放器接电视用的。原来家里有个HTPC,用的是amd fusion,大小大概是20*20,但声音有点大。我想把这htpc找个柜子放起来,作为下载机和文件服务器,然后用MK802来播放HTPC上的电影。

350买的,淘宝有一堆卖这个的,昨天到货。拿到手后,首先看到的是这个东西的个子还是比U盘要大一圈的,甚至比3G上网卡还要大。做工还行,虽然是塑料的,但看着挺结实。

外观:先尝试使用USB供电,发现即使是用HTPC的usb口供电,也不能正常启动,会在启动界面上反复重启,只能使用变压器来供电。另外,还要把HDMI通过接线接到电视上,所以整套系统看起来其实还是挺乱的,感觉就像一堆线接到电视上,还是不够cool啊。。。要是有一个单靠HDMI口就能驱动起来的,做成类似U盘的形状,直接插到HDMI口上就好了

稳定性: 昨天晚上开了一晚上,很稳定,没有死机现象,不过机器非常烫,不知道用久了会不会出问题。

字体:字体还是太小,我离32寸的电视2米远,使用最大的字体,在用软件的时候还是看得很费劲。

控制:控制上不太好控制,只能用无线鼠标和无线键盘,用着很费劲,因为得一直抬着头看。昨天试图装vnc server,发现droid vnc server不能用,在pc能能登录,但是完全无法控制。droidmote也不能用,于是很杯具的只能使用无线鼠标。

视频播放:据说能放1080P,但是我没试。mk802有内置的2G空间,另外还可以装32G的SD卡。但我想放samba服务器上的视频,于是装了个cifsmanager,结果cifsmanager在ICS下还不能用。于是装es file explorer,然后很杯具的发现es file explorer居然不能用系统自带的那个有硬件加速的播放器来放视频,而mx player只能放rmvb之类的,4G的mkv放不了。。。

结论:这玩意还是太geek了,自己装过HTPC的应该都能理解我说的--拿着个无线键盘鼠标看电视,实在是很奇怪的事情。此外播放网络硬盘上视频还是不方便,希望过段时间能有改善

2012/08/01更新:现在Rev 2.0的firmware可以下载了,刷完以后,VNC Server和cifs manager能用了,不过market上还是有好些应用找不到,过几天再折腾

setting process affinity in windows in command line

If you need to bind a process to some specific cores, you can use the "Set Affinity" function in taskmgr.exe. Open task manager->processes->right click a process->set affinity.

However, if you want to set affinity in command line, you will need some tools. Here is a program I wrote to deal with this:


#include <iostream>
#include <sstream>
using namespace std;

#include <Windows.h>


int main(int argc, char ** argv)
{
    if(argc!=3)
    {
        cout<<"usage: "<< argv[0] << " pid mask" <<endl;
        return 1;
    }

    int pid = 0;
    istringstream sspid(argv[1]);
    sspid>>pid;
    if(pid<=0)
    {
        cout<<"bad pid"<<endl;
        return 1;
    }

    HANDLE hProcess = OpenProcess(PROCESS_ALL_ACCESS, TRUE, pid);
    if(!hProcess)
    {
        cout<<"cannot open the process"<<endl;
        return 1;
    }

    string mask_str = argv[2];
	DWORD_PTR mask = 0;
    if(mask_str.size()>sizeof(mask)*8)
    {
        cout<<"mask is too long: mask_size="<<mask_str.size()<<", sizeof(mask)="<<sizeof(mask)*8<<endl;
        return 1;
    }

    for(int i=mask_str.size()-1; i>=0;i--)
    {
        mask = mask<<1;
        if(mask_str[i]=='1')
        {
            mask |= 1;
        }
    }

    if( !SetProcessAffinityMask(hProcess, mask) )
    {
        cout<<"error setting affinity mask: "<<mask<<endl;
        cout<<"error num: "<<GetLastError()<<endl;
        CloseHandle(hProcess);
        return 1;
    }
    CloseHandle(hProcess);
    return 0;
}

Compile the code with Visual C++, and use it like this:
C:>\ setaffinity.exe [pid] [mask]

The mask is a binary number string. e.g. "1011" will bind the process to cores #0, #2 and #3.
For more information, check out my github project: https://github.com/hjk41/setaffinity_windows

MIUI download icon won't go away issue [solved]

I flashed a MIUI rom on my HD2. One day I tried to use the browser on the phone to download an APK, but it failed. The download icon on the top left corner of the screen then sticks. I tried reboot, downloading the APK again, and clearing the browser data cache, none worked. Finally, I found a software called "Download Manager" in the applications. I cleared the data and cache of that software, and the download icon disappears.

simple command line timer for windows

I have just switched to working on Windows. And I found that there is no such thing as the time command line tool in Linux. So I decided to write one myself. I don't need many features. Counting the number of seconds a command takes is enough. I used the QueryPerformanceCounter() function to get the accurate time. So it is not portable to Linux or other platforms.

Anyone who is interested can modify the code at its own will. But I would appreciate it if you can give me your improved version of the code. I have also attached a compiled version. It works on Windows Server 2008 R2 and Windows 7. Other Windows versions are not tested.

Use it like this:
C:\> timer command [arguments]

It gives:
[command outputs]...
--------------
time elapsed: 0.123s

Download:
http://www.mediafire.com/?vzf4yv5xs9saemu
http://www.rayfile.com/zh-cn/files/f5a8ae19-b81c-11e0-93f2-0015c55db73d/


-----------------------------------
Source code:


#define NOMINMAX
#include <windows.h>
#include <stdlib.h>
#include <string>
#include <iostream>
using namespace std;

double gettime(){
	LARGE_INTEGER nFreq;
	LARGE_INTEGER nTime;
	QueryPerformanceFrequency(&nFreq);
	QueryPerformanceCounter(&nTime);
	return (double)nTime.QuadPart*1000/nFreq.QuadPart;
}

int main(int argc, char ** argv){
	if(argc<2 || argc>=2 && string(argv[1])=="--help"){
		cout<<endl;
		cout<<"This is a very very simple timing tool by hjk41."<<endl;
		cout<<endl;
		cout<<"Use it this way: "<<endl;
		cout<<"\tC:\\>"<<argv[0]<<" command [arguments]"<<endl;
		cout<<endl;
		return 0;
	}

	double start=gettime();

	string cmd=argv[1];
	for(int i=2;i<argc; i++){
		cmd= cmd+" "+argv[i];
	}
	system(cmd.c_str());

	double end=gettime();
	double exe_time=(end-start)/1000;

	cout<<"----------------"<<endl;
	cout<<"time elapsed: "<<exe_time<<"s"<<endl;

	return 0;
}

--------------------------------------
Chinese Edition, ignore this if you cannot read Chinese. :-)

Windows下的简单计时程序。
使用方法
C:\> timer 命令 [参数]

结果:
[命令输出]...
--------------
time elapsed: 0.123s

下载链接:
http://www.rayfile.com/zh-cn/files/f5a8ae19-b81c-11e0-93f2-0015c55db73d/
http://www.mediafire.com/?vzf4yv5xs9saemu

上面有源码。你可以随便改,但是如果有什么改进,希望你能告诉我,我好更新一下。 :-)

android market force close on Typhoon CM7 firmware v3.4.2

After a clean install of Typhoon CM7 v3.4.2 on HD2, I found that android market always force closes. A brief search on the Internet indicates that market works well with v3.4.1, but force closes on v3.4.2. Then I found the following solution on xda-developers:

With a rooted rom:
1) open a terminal emulator
2) su
3) chmod 777 /cache

Then everything works well.

starting / stopping service in windows using command line

In Linux, you typically use "service stop xxx" or "/etc/init.d/xxx stop" for this purpose.

Here is the equivalent on windows:
net stop xxx

You can also start a service using:
net start xxx

However, there is no such thing as "net restart". So you have to do it manually by stopping and then starting the service.

list logged-on users in windows

In Linux, we do that with "w" or "who". In windows, we can use "query session".

杯具,在M8上装上了M9 ROM,然后屏幕失灵了

本来还想买M9来玩玩呢,毕竟从硬件配置上,M9已经直追ip4了,而且才卖2.5K。

今天给M8装了个M9 ROM,跟HD2装android原理一样,估计就是拿HD2那个loader弄的。开机发现界面挺漂亮,是我见过的android界面中最漂亮的一个。杯具的是,屏幕在这个时候失灵了。

M8屏幕失灵是个很普遍的毛病,据说新机一年之内能换,可惜这机器已经用了两年了。这个机器原来也有一次失灵,把贴膜揭开再贴回去就好了,没想到这次完全的不行了。

据说M9也有屏幕失灵的问题,看来meizu还是没找到根本的解决办法。本来还想买个M9来玩呢,现在看来,暂时不能买了

贴个非常牛x,非常快的HD2 android

从xda-developers看到的,自己装了一下,发现真的很快。相同的CPU频率下,运行速度明显快于以前用过的shubcraft啊,matt之类。另外,启动速度也非常快,快到发指,基本上5-10秒的样子。

作者自己的解释是说,他把所有系统文件都放到RAM里了,所以快。不过原来运行时不也放在RAM里的吗?

不管怎么样,强力推荐这个版本:darkstone SuperRAM FroYo

XDA-developer链接:
http://forum.xda-developers.com/showthread.php?t=870518

目前最新版本是1.5,下载链接:
http://www.multiupload.com/01Q9CDT76Y

似乎要翻墙 ;-(

read_more

更多网志请见归档分类