软件工程

本类阅读TOP10

·PHP4 + MYSQL + APACHE 在 WIN 系统下的安装、配置
·Linux 入门常用命令(1)
·Linux 入门常用命令(2)
·使用 DCPROMO/FORCEREMOVAL 命令强制将 Active Directory 域控制器降级
·DirectShow学习(八): CBaseRender类及相应Pin类的源代码分析
·基于ICE方式SIP信令穿透Symmetric NAT技术研究
·Windows 2003网络负载均衡的实现
·一网打尽Win十四种系统故障解决方法
·数百种 Windows 软件的免费替代品列表
·收藏---行百里半九十

分类导航
VC语言Delphi
VB语言ASP
PerlJava
Script数据库
其他语言游戏开发
文件格式网站制作
软件工程.NET开发
Trick:Hack wallpaper(Symbian/UIQ)

作者:未知 来源:月光软件站 加入时间:2005-2-28 月光软件站

There is no public API which we can use to achieve the goal.So we have to hack the launcher.mbm which is used to hold the wallpaper image.
The following code segment which was used in our project demontrates this:

void PutQuad( TPtr8& des, TInt val )
{
 TUint8 buffer[4];
 TUint8* ptr = (TUint8*)&buffer;
 TUint8* pt = (TUint8*)&val;
 *ptr++ = *(pt++);
 *ptr++ = *(pt++);
 *ptr++ = *(pt++);
 *ptr++ = *(pt++);
 des.Append((TUint8*)&buffer, 4);
}

_LIT(KMbmFileName, "c:\\system\\Data\\Themes\\wallpaper\\launcher.mbm");
void SaveWallpaper(BYTE* grBuf8, TSize size)
{
 TSize size1=size;
 TSize size2(143, 101);

 TInt fileHeaderLen = 5*4;
 TInt firstSize = 10*4 + (size1.iHeight * size1.iWidth << 1);
 TInt secondSize = 10*4 + (size2.iHeight * (size2.iWidth+1) << 1); // 4 byte align for width
 TInt trailerPos = fileHeaderLen + firstSize + secondSize;
 TInt firstDataPos = fileHeaderLen;
 TInt secondDataPos = firstDataPos + firstSize;
 TInt noBitmaps = 2;
 TInt trailerSize = 4 + noBitmaps*4;
 TInt len = secondDataPos + secondSize + trailerSize;
 HBufC8* outBuf = HBufC8::NewL(len);
 TPtr8 des = outBuf->Des();

 // file header
 PutQuad(des, UID1);
 PutQuad(des, UID2);
 PutQuad(des, UID3);
 PutQuad(des, SIG);
 PutQuad(des, trailerPos);

 // first bitmap header
 PutQuad(des, firstSize);
 PutQuad(des, 40);
 PutQuad(des, size1.iWidth);
 PutQuad(des, size1.iHeight);
 PutQuad(des, 0);
 PutQuad(des, 0);
 PutQuad(des, 16);
 PutQuad(des, 1);
 PutQuad(des, 0);
 PutQuad(des, 0);

 // first bitmap data
 TInt sx = 1,
  sy = 39;
 TInt height = size1.iHeight;
 TInt width = size.iWidth<<1;
 TInt scan = size1.iWidth<<1;
 TUint8* ptr = grBuf8;// + ((sy-1)*width + sx<<1);
 TInt j;
 for( j=0; j< height; j++ )
 {
  ptr += width;
  des.Append(ptr, scan);
 }

 // second bitmap header
 PutQuad(des, secondSize);
 PutQuad(des, 40);
 PutQuad(des, size2.iWidth);
 PutQuad(des, size2.iHeight);
 PutQuad(des, 0);
 PutQuad(des, 0);
 PutQuad(des, 12);
 PutQuad(des, 1);
 PutQuad(des, 0);
 PutQuad(des, 0);

 // second bitmap data
 sx = 1, sy = 39;
 scan = (size2.iWidth+1)<<1;
 height = size2.iHeight;
 ptr = grBuf8;// + ((sy-1)*width + sx<<1);
 for( j=0; j< height; j++ )
 {
  ptr += width;
  des.Append(ptr, scan);
 }

 // mbm trailer
 PutQuad(des, noBitmaps);
 PutQuad(des, firstDataPos);
 PutQuad(des, secondDataPos);

 TInt aStat = KErrNone;
 RFs m_fs;
 if( (aStat=m_fs.Connect()) != KErrNone )
  return;
 //aStat = m_fs.SetSessionPath( kMFPath() );

 // Write MBM Data to file
 RFile file;
 TInt res = file.Replace(m_fs, KMbmFileName, EFileShareAny | EFileWrite | EFileStream );
 User::LeaveIfError(res);
 file.Write(des);
 file.Close();
 delete outBuf;

 m_fs.Close();
 //delete outBuf;
}

 




相关文章

相关软件