Windows Mobile setup.dll fails to run from .cab install

atomicgs12
atomicgs12 used Ask the Experts™
on
I have a .cab file that I have associated my setup.dll file to. The problem I am having is that I have used some code to check my sms messages before I let the cab install by calling the helper function from within codeINSTALL_INIT Install_Init() function inside the setup.dll. I first tested and ran all the code in console app then just cut and pasted the code over to the setup.dll so theratically it should run. The problem is that even though it compiles clean when I put the .cab on the device I get 'Installation  of my.CAB was unsuccessful'. But when I comment out the SMS search code the installation runs find. I have MessageBox statements even before the call to the SMS find message code and with the SMS find message code in the build I can ot even get to the MessageBox, comment out the find code and I can hit the message box. It seems the cab file is failing like it preprocesses the code of something before it runs.

Also I have noticed if I build my .cab file in debug mode and it is larger than 500K it will also fail less than 500K and it runs fine, as long as the SMS find message code is commented out.

I have been able to determine the SMS find message code will allow the cab to install up to the following line: hr = pSession->GetMsgStoresTable(0, &ptbl); if I keep this line comented out and everything below it and compile in Release mode the .cab installs.

The code prior to the line above is:
    HRESULT hr = S_FALSE;

    static const SizedSPropTagArray (2, spta) = { 2, PR_DISPLAY_NAME, PR_ENTRYID };  

    SRowSet *prowset = NULL;
    CComPtr<IMAPITable> ptbl;
    CComPtr<IMsgStore> pStore;

       IMAPISession *pSession = NULL;
       hr = MAPILogonEx(0, NULL, NULL, 0, &pSession);
      
       if(SUCCEEDED(hr))
       {
            // Get the table of accounts
            hr = pSession->GetMsgStoresTable(0, &ptbl);// .cab will not work     with this line or anything below it include.

Any ideas, suggestions? Anyone see anything like this before including the limit size of the .cab file?

Thank You
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®

Commented:
Something with the privileges?
MSDN. Privileged APIs
http://msdn.microsoft.com/en-us/library/aa919335.aspx

I do not know how it is relevant to the OS image you are working with, but you describe exactly the case when an app tries to call a privileged API.
Understanding Windows Mobile Security
http://www.devx.com/wireless/Article/38730/1954
Sign Your Windows Mobile Application
http://msdn.microsoft.com/en-us/windowsmobile/dd569931.aspx
 
I never heard of size limits for setup.dll.

if I were you I'd try to load it manually and call init function to see what happens. Besides, you could add some debug output to track memory usage.
what is the value of hr??
OWASP Proactive Controls

Learn the most important control and control categories that every architect and developer should include in their projects.

Author

Commented:
pgnatyuk: -
I was looking into the privilege thing then I got thinking if the exact same code runs on the device as an app (.exe file) why would it fail when it is in a setup.dll? Should it not fail the same way from the app or is it because the dll is called from within the .cab the dll never gets the 'manual' 'OK' from the user as the app does on install?

Anyone?

Author

Commented:
alexey_gusev: - It's not the dll that seems to have the size limit it's .cab file.
hmm, I've been installing cab files about 4MB in size with NO problems at all, on various WM6.x devices.
you could run WceLoad.exe from test application, wait until its process exits and then get the exit code - perhaps it would tell you something.

besides, what's hr value you get from the call? and memory usage?

Author

Commented:
Well something odd is going on. I commented out the offending line of code and subsituted a 'new' call and then still get the crash, see below. Seems to be some memory/allocation problem. Any ideas?

HRESULT MyMessages(LPCTSTR pszFilename)
{  
      HRESULT hr = S_FALSE;

    static const SizedSPropTagArray (2, spta) = { 2, PR_DISPLAY_NAME, PR_ENTRYID };  

    SRowSet *prowset = NULL;
    CComPtr<IMAPITable> ptbl;
    CComPtr<IMsgStore> pStore;

       IMAPISession *pSession = NULL;
       hr = MAPILogonEx(0, NULL, NULL, 0, &pSession);
      
       if(SUCCEEDED(hr))
       {
             char buf[256]={0};
             _TCHAR *testbuf = new _TCHAR[512];
                                        //   hr = pSession->GetMsgStoresTable(0, &ptbl);

Author

Commented:
OK figured it out. It was a memory problem. Those stupid smart pointer classes CComPTR, why would anyone use them? Must be memory hogs. That is why I am not a fan of managed code. I'm not so lazy I can't control my own appliations memory. I like to know pretty much what is going on and not have everything hidden by another layer of code.

Thanks for everyone's input.

Author

Commented:
No direct answer.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial