none
Converting a .dll from XP to CE. Getting some errors. RRS feed

  • Question

  • Hello,

    I have a 3rd party driver that was created for XP. I need to convert if to run on a CE device. We are using VS2005 and PB 6. I have a working CE image that we created. I have created a .dll subproject for the image. I copied the code over and of course got some errors. Some of them I have been able to resolve. Here are a few of the errors that I am having problems with though, so if you have any info on any of the errors please post.

     

    Error    1    error C2065: 'STARTF_USESHOWWINDOW' : undeclared identifier 81 

    Line 81:

    si.dwFlags = STARTF_USESHOWWINDOW;<br/>

    Error    2    error C3861: 'OpenFileMapping': identifier not found 116 

    Line 116:

    hMap = OpenFileMapping (FILE_MAP_ALL_ACCESS, FALSE, "SEI32FileMap");<br/>

    Error    3    error C2440: '=' : cannot convert from 'long *' to 'DWORD *' 118   

    Line 118:

    pMap = (long *) MapViewOfFile (hMap, FILE_MAP_WRITE, 0, 0, 0);	// get polonger<br/>

    Error    4    error C2065: 'MUTEX_ALL_ACCESS' : undeclared identifier 120 

    Error    5    error C3861: 'OpenMutex': identifier not found 120 

    Line 120:

    hMutex = OpenMutex(MUTEX_ALL_ACCESS, FALSE, "SEI32AccessMutex");<br/>

    Error    6    error C2664: 'GetParent' : cannot convert parameter 1 from 'HANDLE' to 'HWND' 134   

    Error    7    error C2664: 'GetWindowTextW' : cannot convert parameter 2 from 'char *' to 'LPWSTR' 134   

    Line 134:

    GetWindowText(GetParent(hModule), (char*)&pMap[2], 128L);

     

    If you can help solve any that would be fantastic.

    Thanks,

    Flip



    Wednesday, March 30, 2011 2:38 PM

Answers

  • Error 1: don't think STARTUPINFO is suppertode in Windows CE

    Error 2: See MapViewOfFile prototype (http://msdn.microsoft.com/en-us/library/ms891386.aspx), it has VOID as return type

    Error 3: Similarly to mutex and semaphore functions you have to use CreateFileMapping, OpenfileMapping does not exist in CE

    Error 4: in Windows CE the first parameter must be NULL. the mutex, by default has MUTEX_ALL_ACCESS (see http://msdn.microsoft.com/en-us/library/ms885181.aspx)

    Error 5: hModule is a Windows handle or a module handle?

    Error 6: Windows CE functions use UNICODE  (look for TCHAR, WCHAR) not ASCII


    Luca Calligaris lucaDOTcalligarisATeurotechDOTcom www.eurotech.com Check my blog: http://lcalligaris.wordpress.com
    • Marked as answer by Rob Filippi Tuesday, April 5, 2011 8:39 PM
    Monday, April 4, 2011 1:14 PM
  • Thank you again, I ended up casting things fix errors:

     

    Error 3 was solved by this:

    pMap = (DWORD *)(long *) MapViewOfFile (hMap, FILE_MAP_WRITE, 0, 0, 0);	// get polonger

    Error 4 was solved by setting first parameter to NULL like you suggested

    Error 5 and 6 were solved by this:

    GetWindowText(GetParent((HWND)hModule), (LPWSTR)(char*)&pMap[2], 128L);

     

    The remaining errors are 1 and 2.

    Error 1 Do you have any suggestions since STARTUPINFO is not supported?

    Error 2 for the first parameter (HANDLE hfile) of CreateFileMapping() what would be used from the code I have. I am not sure...

    • Marked as answer by Rob Filippi Tuesday, April 5, 2011 8:39 PM
    Monday, April 4, 2011 2:39 PM

All replies

  • Error    5    error C3861: 'OpenMutex': identifier not found 120 

    Line 120:

    hMutex = OpenMutex(MUTEX_ALL_ACCESS, FALSE, "SEI32AccessMutex");

     

    I think I fixed this error by replacing OpenMutex with CreateMutex. Is this a valid option?

    Wednesday, March 30, 2011 3:37 PM
  • OpenMutex, OpenSemaphore do not exist in WCE: converting a desktop project I used CreateXxx which will return ERROR_ALREADY_EXIST but it worked fine
    Luca Calligaris lucaDOTcalligarisATeurotechDOTcom www.eurotech.com Check my blog: http://lcalligaris.wordpress.com
    Thursday, March 31, 2011 6:28 AM
  • Thanks for the reply Luca, I am having a hard time finding documentation for CreateXxx so I am not sure how to use that funciton.

     

    I had the line:

    hMutex = OpenMutex(MUTEX_ALL_ACCESS, FALSE, "SEI32AccessMutex");

    and changed it to

    hMutex = CreateMutex(MUTEX_ALL_ACCESS, FALSE, "SEI32AccessMutex");

    and this error went away. Now I just am stuck with the following errors:

    Error    1    error C2065: 'STARTF_USESHOWWINDOW' : undeclared identifier 81 

    Line 81:

    si.dwFlags = STARTF_USESHOWWINDOW;<br/>

    Error    2    error C3861: 'OpenFileMapping': identifier not found 116 

    Line 116:

    hMap = OpenFileMapping (FILE_MAP_ALL_ACCESS, FALSE, "SEI32FileMap");

    Error    3    error C2440: '=' : cannot convert from 'long *' to 'DWORD *' 118   

    Line 118:

    pMap = (long *) MapViewOfFile (hMap, FILE_MAP_WRITE, 0, 0, 0);	// get polonger

    Error    4    error C2065: 'MUTEX_ALL_ACCESS' : undeclared identifier 120 

    Line 120:

    hMutex = CreateMutex(MUTEX_ALL_ACCESS, FALSE, "SEI32AccessMutex");

    Error   5    error C2664: 'GetParent' : cannot convert parameter 1 from 'HANDLE' to 'HWND' 134   

    Error    6    error C2664: 'GetWindowTextW' : cannot convert parameter 2 from 'char *' to 'LPWSTR' 134   

    Line 134:

    GetWindowText(GetParent(hModule), (char*)&pMap[2], 128L);

    Monday, April 4, 2011 12:46 PM
  • Error 1: don't think STARTUPINFO is suppertode in Windows CE

    Error 2: See MapViewOfFile prototype (http://msdn.microsoft.com/en-us/library/ms891386.aspx), it has VOID as return type

    Error 3: Similarly to mutex and semaphore functions you have to use CreateFileMapping, OpenfileMapping does not exist in CE

    Error 4: in Windows CE the first parameter must be NULL. the mutex, by default has MUTEX_ALL_ACCESS (see http://msdn.microsoft.com/en-us/library/ms885181.aspx)

    Error 5: hModule is a Windows handle or a module handle?

    Error 6: Windows CE functions use UNICODE  (look for TCHAR, WCHAR) not ASCII


    Luca Calligaris lucaDOTcalligarisATeurotechDOTcom www.eurotech.com Check my blog: http://lcalligaris.wordpress.com
    • Marked as answer by Rob Filippi Tuesday, April 5, 2011 8:39 PM
    Monday, April 4, 2011 1:14 PM
  • Thank you again, I ended up casting things fix errors:

     

    Error 3 was solved by this:

    pMap = (DWORD *)(long *) MapViewOfFile (hMap, FILE_MAP_WRITE, 0, 0, 0);	// get polonger

    Error 4 was solved by setting first parameter to NULL like you suggested

    Error 5 and 6 were solved by this:

    GetWindowText(GetParent((HWND)hModule), (LPWSTR)(char*)&pMap[2], 128L);

     

    The remaining errors are 1 and 2.

    Error 1 Do you have any suggestions since STARTUPINFO is not supported?

    Error 2 for the first parameter (HANDLE hfile) of CreateFileMapping() what would be used from the code I have. I am not sure...

    • Marked as answer by Rob Filippi Tuesday, April 5, 2011 8:39 PM
    Monday, April 4, 2011 2:39 PM
  • see he documentation for CreateFileMapping (http://msdn.microsoft.com/en-us/library/ee490172.aspx): it depends on what you're trying to achieve.

    are you sure that the cast to LPWSTR in GetWindowText is sufficient: WCHAR are 16bit values, while char is 8bit

    STARTUPINFO must set to NULL in CreateProcess implementation in Windows CE: what would you set in the si.wShowWindow? you may find some other functions that, given the process ID or the windows handle, allow you to obtain the same result

     


    Luca Calligaris lucaDOTcalligarisATeurotechDOTcom www.eurotech.com Check my blog: http://lcalligaris.wordpress.com
    Monday, April 4, 2011 2:57 PM
  • see he documentation for CreateFileMapping (http://msdn.microsoft.com/en-us/library/ee490172.aspx): it depends on what you're trying to achieve.

     


    Luca Calligaris lucaDOTcalligarisATeurotechDOTcom www.eurotech.com Check my blog: http://lcalligaris.wordpress.com

    I am not sure exactly what the code is trying to achieve since it is 3rd party. I will look into this.

    are you sure that the cast to LPWSTR in GetWindowText is sufficient: WCHAR are 16bit values, while char is 8bit

     


    Luca Calligaris lucaDOTcalligarisATeurotechDOTcom www.eurotech.com Check my blog: http://lcalligaris.wordpress.com

    I have no idea... I was not sure how to fix it.

    STARTUPINFO must set to NULL in CreateProcess implementation in Windows CE: what would you set in the si.wShowWindow? you may find some other functions that, given the process ID or the windows handle, allow you to obtain the same result

     


    Luca Calligaris lucaDOTcalligarisATeurotechDOTcom www.eurotech.com Check my blog: http://lcalligaris.wordpress.com

    I do not think its that important. So I can just change the code to si.dwFlags = NULL; and that will fix it.


    Monday, April 4, 2011 3:10 PM
  • All errors gone that I previously had, but now I am getting an error because in my directory where my additional libraries are I am missing Kernel32.lib.

     

    This is the directory where all my other libraries are:\

    $(_PROJECTROOT)\cesysgen\sdk\lib\$(_CPUINDPATH)\

     

    I did a search for Kernel32.lib on the PC and I do have a copy ( 9 actually), but they have different file sizes. I am not sure which one should be copied. I will just copy the largest to make sure I get everything it has.

     

     

    Monday, April 4, 2011 5:17 PM
  • Remove it from your linker settings.   You do not need it for Windows CE.
    Bruce Eitman (eMVP)
    Senior Engineer
    Bruce.Eitman AT Eurotech DOT com
    My BLOG http://geekswithblogs.net/bruceeitman

    Eurotech Inc.
    www.Eurotech.com
    Monday, April 4, 2011 6:00 PM
    Moderator
  • Oh? It said createFileMapping() needed it. So I did what I said and compiled fine.

     

    Tuesday, April 5, 2011 8:39 PM