0

I have a project which I need to get working in C++ in VS2010 under Windows 7. The project was originally developed to run on WinCE . It was developed in VC++ but linked to some libraries used in the WinCE dev environment.

The project uses ::VirtualCopy which fails to compile as I believe it’s in Coredll.lib. in the WinCE environment. https://msdn.microsoft.com/en-us/library/aa450977.aspx

error LNK2028: unresolved token (0A000B85) "extern "C" int __cdecl VirtualCopy(void *,void *,unsigned long,unsigned long)" (?VirtualCopy@@$$J0YAHPAX0KK@Z) referenced in ..
error LNK2019: unresolved external symbol "extern "C" int __cdecl VirtualCopy(void *,void *,unsigned long,unsigned long)" (?VirtualCopy@@$$J0YAHPAX0KK@Z) referenced in ..

The function in my code is reference through:

extern "C" 
{
BOOL VirtualCopy(LPVOID lpvDest, LPVOID lpvSrc, DWORD cbSize, DWORD fdwProtect);
}

And then used:

if( ! ::VirtualCopy(pVMem, reinterpret_cast<void *>(dwASIC_REGISTERS_BASE), tSystemInfo.dwPageSize, PAGE_READWRITE | PAGE_NOCACHE) )
{
    DWORD dwError = ::GetLastError();

    TRACE1("Failed ", dwError);
    return;
}

The projects uses:

  • MFC in a shared dll
  • Static link to ATL
  • Common Language Runtime Support (/clr)

I have a few of question:

  1. Is there an alternative?
  2. Is there any way I can import some of the old winCE libraries and link against those, allowing me to use this function?

Any help would be greatly appreciated

Many Thanks

  • I can't really say, but it seems like in e.g Windows CE it was a kernel-mode function and not a user-space function. It's probably the reason why you don't have it when building user-space applications in a desktop Windows environment. – Some programmer dude Apr 30 '15 at 09:26

1 Answers1

0

I'm not an expert in WinCE programming, but below are some thoughts:

It seems that this function is used to map a pointer accessible in program code (virtual address) to some device registers (physical address). In embedded programming such approach is used to directly drive a device (e.g. light a LED connected to SoC).

  1. I believe that in Win32 such function isn't accessible because direct setting/reading registers is reserved for device drivers, not application code.

  2. I believe that there is no way to link against WinCE libraries in Win32 environment. But what is more important, even if there is a way to achieve this, you would gain nothing - the registers (physical address) is specific to the embedded device. On a PC this particular physical address probably points to RAM so you'll be writing in address space of other application.

  3. You should not get around lack of VirtualCopy function. You should understand what the code did on the device and then either remove it (if it isn't necessary to application behavior) or implement it in a way that is correct for Win32 environment.

smbear
  • 1,007
  • 9
  • 17
  • Hi smbear, Thank you for your prompt response, You are right, the original application was used to send and receive data down an RS-232 serial port –  Apr 30 '15 at 09:48
  • 1
    Then I think you should use Win32 functions to communicate over RS-232. – smbear Apr 30 '15 at 09:59
  • thanks, further digging around found that a driver was needed to access the data on a win32 machine. The driver wasn't needed on the CE device. –  May 08 '15 at 11:15