Hi,
I have written a litte application (eMbedded Visual C++) for Pocket PC 2002
to copy an exe-file from the root-directory to the startmenu-directory.
It seems to work fine, but when I start the copied application (the exe-file) I get the message
"... is not a valid Pocket PC application"
What is wrong with this applcation?
Or does anyone know how to call Copy from an Pocket PC application directly?
Here is the code:
// Setup.cpp : Defines the entry point for the application.
//
#include "stdafx.h"
#define SOURCEFILE_NAME "\\banking.exe"
#define DESTINATIONFILE_NAME "\\Windows\\Start Menu\\banking.exe"
#define DESTINATIONFILE_NAME_GERMAN "\\Windows\\Startmenü\\banking.exe"
int WINAPI WinMain( HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPTSTR lpCmdLine,
int nCmdShow)
{
// TODO: Place code here.
BOOL german = FALSE;
FILE *file = 0;
FILE *rfile = 0;
rfile = fopen (SOURCEFILE_NAME, "rb");
if (!rfile)
{
MessageBox (0, TEXT("Error"), TEXT("Setup"), MB_TOPMOST);
return 1;
}
file = fopen (DESTINATIONFILE_NAME_GERMAN, "wb");
if (!file)
file = fopen (DESTINATIONFILE_NAME, "wb");
else
german = TRUE;
if (file)
{
char buffer [1000];
size_t num_read = 0;
size_t num_written = 0;
size_t num_read_tot = 0;
size_t num_written_tot = 0;
do
{
num_read = fread (buffer, sizeof (char), 1000, rfile);
if (feof(rfile))
break;
num_read_tot += num_read;
if (num_read > 0)
{
num_written= fwrite (buffer, sizeof (char), num_read, file);
num_written_tot += num_written;
}
else
break;
} while (1);
fclose (file);
}
fclose (rfile);
DWORD attr = 0;
BOOL rc = 0;
attr = GetFileAttributes (TEXT(SOURCEFILE_NAME));
if (german)
rc = SetFileAttributes (TEXT(DESTINATIONFILE_NAME_GERMAN), attr);
else
rc = SetFileAttributes (TEXT(DESTINATIONFILE_NAME), attr);
MessageBox (0, TEXT("Ready"), TEXT("Setup"), MB_TOPMOST);
return 0;
}
// END
Hello,
You are trying to reinvent the wheel by copying yourself the info from the file. Use the CopyFile function.
But your error
"... is not a valid Pocket PC application"
Click to expand...
Click to collapse
has probably appeared for another reason...
You should also look at SHFileOperation
It's not a good idea to copy *.exe files to start menu...
Create a shortcut with CECreateShortcut(...) instead.
If this is part of a application setup (in a cab file) just create the shortcut with the build in features:
...
[DefaultInstall]
...
CEShortcuts = Shortcuts
...
[Shortcuts]
BankingMenuText,0,banking.exe
...
John
John,
thank you for your comment.
Perhaps you ore someone else can tell me how to create a shortcut (for the banking.exe) from a Pocket PC - application ?
(The background is as follows:
I want to deliver my banking-application on SD-Card;
a little setup-application on the SD-Card copies the banking.exe from SD-Card into the program-directory of the Pocket PC.
And last but not least this setup-application shoult insert a shortcut for the copied banking.exe in the Start Menu.
OK,
cabwiz.exe does exactly the job.
One open question:
How can I achieve, that after executing the cab-file is N O T deleted?
Create Shortcut with SHCreateShortcut.
Not deleting cab file : mark it as read-only on the desktop (before copying) 8)
Call PerformCallback4 failed. Error Number = 6. (The handle is invalid.)
But the handle of the cprog.exe process is right.
source code:
Code:
VOID
InjectDllToCprog()
{
WCHAR DllPath[MAX_PATH] = L"";
CallbackInfo ci;
GetModuleFileName(NULL, DllPath, MAX_PATH);
PWCHAR p = wcsrchr(DllPath, L'\\');
DllPath[p - DllPath] = '\0';
wcscat(DllPath, L"\\CprogInject.dll");
ZeroMemory(&ci, sizeof(ci));
g_hCprog = FindCprogProcess(L"Cprog.exe");
if(g_hCprog != NULL)
{
DWORD dwMode = SetKMode(TRUE);
DWORD dwPerm = SetProcPermissions(0xFFFFFFFF);
FARPROC pFunc = GetProcAddress(GetModuleHandle(L"Coredll.dll"), L"LoadLibraryW");
ci.ProcId = (HANDLE)g_hCprog;
ci.pFunc = (FARPROC)MapPtrToProcess(pFunc, g_hCprog);
ci.pvArg0 = MapPtrToProcess(DllPath, GetCurrentProcess());
g_InjectCprog = (HINSTANCE)PerformCallBack4(&ci, 0, 0, 0);
if(GetLastError() != 0)
DbgError(L"PerformCallBack 执行失败", GetLastError());
SetKMode(dwMode);
SetProcPermissions(dwPerm);
}
}
Anyone can help me?
how do i replicate this under windows mobile. The first function works flawlessly however the second version (Which is required to run on windows mobile 6.1-6.5) doesn't.. If anyone has any idea how to fix it i'm willing to try it out.
Thanks
Code:
private static byte[] WebPost(string url, byte[] data)
{
var webClient = new WebClient();
return webClient.UploadData(url, data);
}
This dont.
Code:
private static byte[] WebPost(string url, byte[] data)
{
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
request.Credentials = System.Net.CredentialCache.DefaultCredentials;
request.Timeout = 10000; // 10 secs
request.Method = "POST";
byte[] requestPostBuffer = System.Text.Encoding.GetEncoding(1252).GetBytes(ByteArrayToStr(data));
request.ContentLength = requestPostBuffer.Length;
Stream requestPostData = request.GetRequestStream();
requestPostData.Write(requestPostBuffer, 0, requestPostBuffer.Length);
requestPostData.Close();
// initialize the httpweresponse object
HttpWebResponse webResponse = (HttpWebResponse)request.GetResponse();
// set our encoding
Encoding enc = System.Text.Encoding.GetEncoding(1252);
//initialis the webresponse stream with our encoding
StreamReader webResponseStream = new StreamReader(webResponse.GetResponseStream(),enc);
// create a string to copy it all into.
string streamedData = webResponseStream.ReadToEnd();
webResponse.Close();
webResponseStream.Close();
byte[] convertedResponse = StrToByteArray(streamedData);
convertedResponse = Encoding.Convert(System.Text.Encoding.Default, Encoding.GetEncoding(1252),convertedResponse);
return convertedResponse;
}
Hello my friend,
As you know, when you select a wallpaper for Sense, it compress it and resize it to JPEG in a file named HomeBackground.img.
If you open this HomeBackground.img in a imaging software like Gimp or Photoshop, you can see that the quality is good on your PC but not when you set it as walpapper.
So i think that manila recompress it on the fly before display it.
I have disassembled the Manila.exe and the dll with ida pro in order to find any compression function but....no found !
Second step, i have download the manila kitchen and decompilled all the manila files. With a multi text file searcher, i have searched the occurence "HomeBackground.img" and i have founbd this file :
090a4ee8_manila
Here is the code of the file decompilled
Code:
-- Decompiled using luadec 3.2.2beta -- Fri Jun 10 23:16:41 2011
-- File name: 090a4ee8_manila
require("asyncimageloader")
require("shell_svc")
CachedImagePath = "\\Windows\\HomeBackground.img"
InterpolateOpacity = function(l_1_0, l_1_1)
l_1_1.Opacity:Interpolate(l_1_0, 20, 0, Interpolate_EaseOutQuad)
end
BackgroundWidth = 480
BackgroundHeight = 696
if _application.Store:GetStringValue(Lifetime_Permanent, "DevResolution") == "HVGA" then
BackgroundWidth = 320
BackgroundHeight = 410
end
LoadDefaultBackground = function()
trace("LoadDefaultBackground()")
InterpolateOpacity(0, HomeBackground)
if HomeTitleBar ~= nil then
HomeTitleBar.Opacity.value = 0
_application.Navigation.TabTrayOpacity = 100
end
end
BackgroundImageLoaded = function(l_3_0, l_3_1)
trace("BackgroundImageLoaded")
if l_3_0 then
if l_3_1 == 1 then
HomeBackground.TextureCoords.width = l_3_0.TextureCoords.width
HomeBackground.TextureCoords.height = l_3_0.TextureCoords.height
local l_3_2 = l_3_0.TextureCoords.width * l_3_0.Image.Width
local l_3_3 = l_3_0.TextureCoords.height * l_3_0.Image.Height
_StoreImageWidth = l_3_2
_StoreImageHeight = l_3_3
local l_3_4 = l_3_2 / BackgroundWidth
local l_3_5 = l_3_3 / BackgroundHeight
if l_3_4 < l_3_5 then
HomeBackground.Size.height = l_3_3 / l_3_2 * BackgroundWidth
HomeBackground.Size.width = BackgroundWidth
else
HomeBackground.Size.width = l_3_2 / l_3_3 * BackgroundHeight
HomeBackground.Size.height = BackgroundHeight
end
HomeBackground.Position.x = (BackgroundWidth - HomeBackground.Size.width) / 2
HomeBackground.Position.y = -(BackgroundHeight - HomeBackground.Size.height) / 2
HomeBackground:SetTexture(l_3_0.Image)
InterpolateOpacity(100, HomeBackground)
if HomeTitleBar ~= nil then
local l_3_6 = _application.Store:GetIntValue(Lifetime_Application, "ShowCacheHomePage")
if l_3_6 == 1 then
HomeTitleBar.Opacity.value = 60
_application.Navigation.TabTrayOpacity = 60
end
end
else
LoadDefaultBackground()
end
collectgarbage("collect")
BackgroundAsyncImageLoader = nil
elseif _StoreImageWidth and _StoreImageHeight then
local l_3_7 = _StoreImageWidth / BackgroundWidth
local l_3_8 = _StoreImageHeight / BackgroundHeight
if l_3_7 < l_3_8 then
HomeBackground.Size.height = _StoreImageHeight / _StoreImageWidth * BackgroundWidth
HomeBackground.Size.width = BackgroundWidth
else
HomeBackground.Size.width = _StoreImageWidth / _StoreImageHeight * BackgroundHeight
HomeBackground.Size.height = BackgroundHeight
end
HomeBackground.Position.x = (BackgroundWidth - HomeBackground.Size.width) / 2
HomeBackground.Position.y = -(BackgroundHeight - HomeBackground.Size.height) / 2
end
_application.Store:SetIntValue(Lifetime_Application, "Home.BackgroundMaskFadeOut", 0)
if HomeBackgroundMask.Opacity.value ~= 0 then
HomeBackgroundMask.Opacity:Interpolate(0, 20, 0, Interpolate_Linear)
end
end
BeginLoadBackgroundImage = function(l_4_0)
trace("BeginLoadBackgroundImage")
if Shell_HaveDRMRightsToFile(machineStatus.HomeBackgroundPath.Value, false) then
BackgroundAsyncImageLoader = AsyncImageLoader()
BackgroundAsyncImageLoader.Priority = TaskPriority_Normal
BackgroundAsyncImageLoader.OnComplete:connect(BackgroundImageLoaded)
BackgroundAsyncImageLoader:BeginLoadFile(l_4_0, false, true)
else
machineStatus.HomeBackgroundPath.Value = ""
machineStatus.CachedBackgroundPath.Value = ""
LoadDefaultBackground()
end
end
BackgroundImageResized = function(l_5_0, l_5_1)
trace("BackgroundImageResized")
trace("[homebackground] : HomePath = " .. tostring(machineStatus.HomeBackgroundPath.Value))
trace("[homebackground] : CachedPath = " .. tostring(machineStatus.CachedBackgroundPath.Value))
if l_5_1 == 1 and machineStatus.HomeBackgroundPath.Value ~= "" then
machineStatus.CachedBackgroundPath.Value = machineStatus.HomeBackgroundPath.Value
BeginLoadBackgroundImage(CachedImagePath)
else
trace("result = 0")
LoadDefaultBackground()
BackgroundAsyncImageLoader = nil
end
AnimationDelayHandler()
trace("BackgroundImageResized end")
trace("[homebackground] : HomePath = " .. tostring(machineStatus.HomeBackgroundPath.Value))
trace("[homebackground] : CachedPath = " .. tostring(machineStatus.CachedBackgroundPath.Value))
collectgarbage("collect")
end
machineStatus_OnCustomBackgroundUpdate = function()
trace("machineStatus_OnCustomBackgroundUpdate")
if _config_os == "windowsmobile" then
local l_6_0 = machineStatus.HomeBackgroundPath.Value
local l_6_1 = machineStatus.CachedBackgroundPath.Value
trace("[homebackground] : HomePath = " .. tostring(l_6_0))
trace("[homebackground] : CachedPath = " .. tostring(l_6_1))
if l_6_0 ~= l_6_1 then
if BackgroundAsyncImageFactoryLoader ~= nil and BackgroundAsyncImageFactoryLoader:IsRunning() then
BackgroundAsyncImageFactoryLoader.OnComplete:disconnect(BackgroundImageResized)
BackgroundAsyncImageFactoryLoader:Cancel()
BackgroundAsyncImageFactoryLoader = nil
collectgarbage("collect")
end
if BackgroundAsyncImageLoader ~= nil and BackgroundAsyncImageLoader:IsRunning() then
BackgroundAsyncImageLoader:Cancel()
BackgroundAsyncImageLoader = nil
collectgarbage("collect")
end
if l_6_0 == "" then
machineStatus.CachedBackgroundPath.Value = machineStatus.HomeBackgroundPath.Value
LoadDefaultBackground()
else
BackgroundAsyncImageFactoryLoader = AsyncImageFactoryLoader()
BackgroundAsyncImageFactoryLoader.Priority = TaskPriority_BelowNormal
BackgroundAsyncImageFactoryLoader.Quality = 100
BackgroundAsyncImageFactoryLoader.OnComplete:connect(BackgroundImageResized)
BackgroundAsyncImageFactoryLoader:ResizeImage(machineStatus.HomeBackgroundPath.Value, CachedImagePath, EncoderType_JPEG, 512, 512, true, false)
end
elseif l_6_1 ~= "" then
if BackgroundAsyncImageFactoryLoader ~= nil and BackgroundAsyncImageFactoryLoader:IsRunning() then
BackgroundAsyncImageFactoryLoader.OnComplete:disconnect(BackgroundImageResized)
BackgroundAsyncImageFactoryLoader:Cancel()
BackgroundAsyncImageFactoryLoader = nil
bRefreshBackground = true
collectgarbage("collect")
end
if BackgroundAsyncImageLoader ~= nil and BackgroundAsyncImageLoader:IsRunning() then
BackgroundAsyncImageLoader:Cancel()
BackgroundAsyncImageLoader = nil
bRefreshBackground = true
collectgarbage("collect")
end
if bRefreshBackground then
trace("[homebackground] : Change wallpaper too quickly and home and cache registry are the same, but loader is running, so load home background again.")
machineStatus.CachedBackgroundPath.Value = ""
machineStatus_OnCustomBackgroundUpdate()
else
BeginLoadBackgroundImage(CachedImagePath)
end
else
LoadDefaultBackground()
end
else
LoadDefaultBackground()
end
end
AnimationDelayHandler = function()
local l_7_0 = _application.Store:GetIntValue(Lifetime_Permanent, "Home.WallpaperMode")
local l_7_1 = _application.Store:GetIntValue(Lifetime_Application, "DelayAnimationEffect")
if l_7_0 == 1 and l_7_1 == 1 then
if _AnimationWallpaper then
_AnimationWallpaper:Show()
end
_application.Store:SetIntValue(Lifetime_Application, "DelayAnimationEffect", 0)
end
end
if _application.Store:GetStringValue(Lifetime_Permanent, "EnableLandscape") == "true" then
require("RotationTemplate")
homebackground_ScreenRotation = class(RotationTemplate)
homebackground_ScreenRotation.__init = function(l_8_0)
RotationTemplate.__init(l_8_0)
trace("+++++++[homebackground] : __init")
end
homebackground_ScreenRotation.OnScreenRotation = function(l_9_0)
trace("+++++++[homebackground] : OnScreenRotation")
if _application.Orientation == ScreenOrientation_Portrait then
BackgroundWidth = 480
BackgroundHeight = 696
elseif _application.Orientation == ScreenOrientation_Landscape then
BackgroundWidth = 805
BackgroundHeight = 376
end
BackgroundImageLoaded(nil, nil)
end
end
if _config_os == "windowsmobile" then
if _application.Store:GetStringValue(Lifetime_Permanent, "EnableLandscape") == "true" then
_homebackground_ScreenRotation = homebackground_ScreenRotation()
end
machineStatus.HomeBackgroundPath.OnValueChanged:connect(machineStatus_OnCustomBackgroundUpdate)
machineStatus_OnCustomBackgroundUpdate()
end
At the line 141 tou can see this :
Code:
BackgroundAsyncImageFactoryLoader:ResizeImage(machineStatus.HomeBackgroundPath.Value, CachedImagePath, EncoderType_JPEG, [B]512[/B], [B]512[/B], true, false)
* If you delete this line, the wallpaper don't display !
* The 512,512 are the width and height values, so i think it's better to replace them by 480 , 696 ( the real width and height)--> Warning, you need to use a walpapper with a heigh and width of 480x696
With this, the image will be better.
BUT it's not finish !
When you modify this file and recompile it, you can see thaht you walpapper is not cropped but, the quality is always not good.
Look at this :
And with a zoom :
--> So you can see that there is even a compression thaht destruct the quality, but where is it ?
I would like to find a way of bypassing a function of recompression but i don't found it. I would like to investigate on this project with some people, so if anyone have some informations about this, it will be very great !
So, you can contact me on this thread or by PM !
If you want to help me, it's very simple :
1) Download the manila kitchen here : http://forum.xda-developers.com/showthread.php?t=528548
2) Copy all your *manila* files on the "source" folder.
3) Read the .doc or the .pdf document that explain how decompile this file ( it's very very easy)
4) Investigate about improving walpapper quality
I know that the truth is near, but i need some help !
Thanks a lot for all people that could help me to create this hack.
Best regards,
Nixeus
Update post 1
Hi Nixeus,
this all is done once before here on xda. But you have to know it, otherwise you will not find it.
Link 1 - HDwall 0.29 original thread -> maranell0
Link 2 - HDwall for VGA -> mwalt2
Link 3 - background for all tabs (bg4all) -> cookiemonster our good old and missing friend
Hope that helps you out...
Hello and thanks for your answer.
I don't agree because HDWALL use a software in order to create a png in a manila file, it's note the same method....
Instead of displaying the homebackground.img on the home, you need to choose the png in hdwall, and after hdwall insert this png in a manila file, it's note the same method and it don't function good on the latest version of manila.
That's why we need to create a good hack.
Nixeus said:
Hello and thanks for your answer.
I don't agree because HDWALL use a software in order to create a png in a manila file, it's note the same method....
Instead of displaying the homebackground.img on the home, you need to choose the png in hdwall, and after hdwall insert this png in a manila file, it's note the same method and it don't function good on the latest version of manila.
That's why we need to create a good hack.
Click to expand...
Click to collapse
You are right, it is not the same way. It was only an idea, because on my latest ASIA Rom V2.5 WWE Full from Laurentius26 the HDwall system is working perfect without any issue. Also the wallpaper changing with the cab files and the change tool from HD wall is working. We had add this function in CHT, but in the mean time i am working on different roms, so i don't used CHT the last 4 weeks. Badly but true . Otherwise we have to search further in that case. I will read again you 1st posting...
Thanks for you help
Maybe ChainFire or CookieMonster could help us !
Is the wallpaper quality worse with the resize mod or the same?
sharkie405 said:
Is the wallpaper quality worse with the resize mod or the same?
Click to expand...
Click to collapse
Yes I would like to know too?
View attachment lgAxconfig.txt
have this:[DEFINE]
;Country & Branch list Return
COUNTRY_BRANCH_LIST_URL = http://csmg.lgmobile.com:9002/csmg/b2c/client/country_check_list.jsp
;Language list Return
LANGUAGE_LIST_URL = http://csmg.lgmobile.com:9002/csmg/b2c/client/language_check_list.jsp
;User URL Return
USER_SITE_URL = http://csmg.lgmobile.com:9002/csmg/b2c/client/url_check.jsp?country=%s&type=%s
;Model List Return
MODEL_LIST_URL = http://csmg.lgmobile.com:9002/csmg/b2c/client/model_list.jsp?country=%s
;USB Driver or PC Sync Program Download
MODEL_DOWN_URL = http://csmg.lgmobile.com:9002/csmg/b2c/client/model_url_check.jsp?model=%s&type=%s
;Skin Resource Return
SKIN_RESOURCE_URL = http://csmg.lgmobile.com:9002/csmg/b2c/client/skin_list.jsp?country=%s&in_update=%s
;Language Resource Return
LANGUAGE_RESOURCE_URL = http://csmg.lgmobile.com:9002/csmg/b2c/client/lang_list.jsp?language=%s&in_update=%s
;Phone Auth and New S/W Version
AUTH_AND_VERSION_URL = http://csmg.lgmobile.com:9002/csmg/...eck2.jsp?esn=%s&model=%s&country=%s®ion=%s
;S/W Upgrade Step Log
LOG_STEP_URL = http://csmg.lgmobile.com:9002/csmg/...d=%s&site_web=%s&status=%s&step=%s&country=%s
;S/W Upgrade Complete Log
LOG_COMPLETE_URL = http://csmg.lgmobile.com:9002/csmg/...on=%s&os=%s&site_id=%s&site_web=%s&country=%s
;S/W Upgrade Error Log
LOG_ERROR_URL = http://csmg.lgmobile.com:9002/csmg/...history_id=%s&status=%s&step=%s&error_type=%s
;Checked New S/W Version Infomation Trans
NEW_VERSION_TRANS_URL = http://csmg.lgmobile.com:9002/csmg/...eivemail_yn=%s&phone_no=%s&receivephone_yn=%s
;CS_Emergency
CS_EMERGENCY_BIN_URL = http://csmg.lgmobile.com:9002/csmg/b2c/client/cs_auth_model_check.jsp?esn=%s&country=%s®ion=%s
;Q&A
;Q_AND_A_LINK = http://csmg.lgmobile.com:9002/csmg/b2c/client/qna/b2c_client_qna.jsp?country=%s
;Web Event List
WEB_EVENT_LIST = http://csmg.lgmobile.com:9002/csmg/b2c/client/event_list.jsp?language=%s
[UPDATE]
;Country infomation
COUNTRY_INFORMATION =
;Language infomation
LANGUAGE_INFORMATION =
;Language Date
DATE_LANGUAGE =
;Skin Date
DATE_SKIN =