Trick:Hack wallpaper(Symbian/UIQ)

王朝other·作者佚名  2006-01-09
窄屏简体版  字體: |||超大  

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;

}

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
 
 
© 2005- 王朝網路 版權所有 導航