Update contrib.
1 // Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of the License "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
16 #define _CRTIMP // we want to use the static runtime library
18 #include <e32cmn_private.h>
22 #include <e32ldr_private.h>
25 #pragma data_seg(".data2")
27 #pragma bss_seg(".data2")
29 static TBool UnicodeHost;
30 static Emulator::SInit Data;
37 Initializes a module and prepares it to handle requests.
39 @param aInit An object of the structure SInit.
43 EXPORT_C void Emulator::Init(const Emulator::SInit& aInit)
45 UnicodeHost = (GetVersion() & 0x80000000) ? FALSE : TRUE;
47 if (Data.iCodePage == 0)
48 Data.iCodePage = CP_ACP;
51 LOCAL_C DWORD UStringLength(LPCSTR lpMultiByteStr)
53 // returns length of unicode string generated - assumes null terminated string
56 return MultiByteToWideChar(Data.iCodePage,0,lpMultiByteStr,-1,0,0);
60 LOCAL_C DWORD ConvertToUnicode(LPCSTR aNarrow,LPWSTR aUnicode,DWORD aLength,BOOL aCharsRequired)
62 // Converts narrow string to unicode string
65 DWORD uniLength=UStringLength(aNarrow);
66 if(uniLength>aLength || uniLength==0)
67 return aCharsRequired ? uniLength : 0;
68 uniLength=MultiByteToWideChar(Data.iCodePage,0,aNarrow,-1,aUnicode,aLength);
69 // return number of characters excluding the null terminator
70 return uniLength ? uniLength-1 : 0;
74 LOCAL_C DWORD ConvertToNarrow(LPCWSTR aUnicode,LPSTR aNarrow,DWORD aLength)
76 // Converts unicode string to narrow string
79 return WideCharToMultiByte(Data.iCodePage,0,aUnicode,-1,aNarrow,aLength,"@",NULL);
86 Buf8(LPCWSTR aUnicode);
87 inline operator LPCSTR() const
95 Buf8<S>::Buf8(LPCWSTR aUnicode)
100 ConvertToNarrow(aUnicode,iBuf,S);
111 Acquires the global lock for host interaction.
113 EXPORT_C void Emulator::Lock()
119 Releases the global lock for host interaction.
120 This may overwrite the error code for this thread and that is not the behaviour expected,
121 so save and restore it.
123 EXPORT_C void Emulator::Unlock()
125 DWORD error=GetLastError();
131 Takes the current thread out of the emulator scheduling model.
133 EXPORT_C void Emulator::Escape()
139 Returns the calling thread into the emulator scheduling model.
140 This may overwrite the error code for this thread and that is not the behaviour expected,
141 so save and restore it.
143 EXPORT_C void Emulator::Reenter()
145 DWORD error=GetLastError();
152 Jumps to the NThread Win32 SEH exception handler.
154 @param aException Describes an exception.
155 @param aContext Describes the context.
157 @return A handler to handle the exception occurred
159 EXPORT_C DWORD Emulator::Win32SEHException(EXCEPTION_RECORD* aException, CONTEXT* aContext)
161 return Data.iException(aException, aContext);
166 This function wraps the Win32 CreateDirectory API (see http://msdn2.microsoft.com/en-us/library/aa363855.aspx).
168 EXPORT_C BOOL Emulator::CreateDirectory(LPCWSTR lpPathName,LPSECURITY_ATTRIBUTES lpSecurityAttributes)
173 return ::CreateDirectoryW(lpPathName, lpSecurityAttributes);
175 return ::CreateDirectoryA(Buf8<MAX_PATH>(lpPathName),lpSecurityAttributes);
179 //disable unreachable code warning in VC++
180 #pragma warning (disable : 4702)
185 Recursively ensures that the full directory exists.
187 @param aPathName Provides the path name.
189 @return TRUE, if the function succeeds
190 FALSE, if the function fails
192 EXPORT_C BOOL Emulator::CreateAllDirectories(LPCSTR aPathName)
197 strcpy(path, aPathName);
208 DWORD att = ::GetFileAttributesA(path);
209 if ((att == -1 || !(att&FILE_ATTRIBUTE_DIRECTORY)) && !::CreateDirectoryA(path, NULL))
217 //enable unreachable code warning in VC++
218 #pragma warning (default : 4702)
221 #ifndef INVALID_FILE_ATTRIBUTES
222 #define INVALID_FILE_ATTRIBUTES ((DWORD)-1)
227 This function wraps the Win32 CreateFile API (see http://msdn2.microsoft.com/en-us/library/aa363858.aspx).
228 It also modifies file attributes depending on whether the file is hidden or not.
230 EXPORT_C HANDLE Emulator::CreateFile(LPCWSTR lpFileName,DWORD dwDesiredAccess,DWORD dwShareMode,
231 LPSECURITY_ATTRIBUTES lpSecurityAttributes,DWORD dwCreationDistribution,
232 DWORD dwFlagsAndAttributes,HANDLE hTemplateFile)
237 DWORD att = INVALID_FILE_ATTRIBUTES;
238 if(dwCreationDistribution==CREATE_ALWAYS)
240 att = ::GetFileAttributes(lpFileName);
241 if(att!=INVALID_FILE_ATTRIBUTES && (att&FILE_ATTRIBUTE_HIDDEN))
243 hidden = ::SetFileAttributes(lpFileName, (att&~FILE_ATTRIBUTE_HIDDEN));
248 h = ::CreateFileW(lpFileName,dwDesiredAccess,dwShareMode,lpSecurityAttributes,dwCreationDistribution,
249 dwFlagsAndAttributes,hTemplateFile);
251 h = ::CreateFileA(Buf8<MAX_PATH>(lpFileName),dwDesiredAccess,dwShareMode,lpSecurityAttributes,dwCreationDistribution,
252 dwFlagsAndAttributes,hTemplateFile);
254 if(hidden && h!=INVALID_HANDLE_VALUE)
256 ::SetFileAttributes(lpFileName, att);
263 This function wraps the Win32 DeleteFile API (see http://msdn2.microsoft.com/en-us/library/aa363915.aspx).
265 EXPORT_C BOOL Emulator::DeleteFile(LPCWSTR lpFileName)
270 return ::DeleteFileW(lpFileName);
272 return ::DeleteFileA(Buf8<MAX_PATH>(lpFileName));
275 LOCAL_C TBool MapFindFileData(LPWIN32_FIND_DATAW lpFindFileData, LPWIN32_FIND_DATAA lpFindNarrow)
277 lpFindFileData->dwFileAttributes=lpFindNarrow->dwFileAttributes;
278 lpFindFileData->ftCreationTime=lpFindNarrow->ftCreationTime;
279 lpFindFileData->ftLastAccessTime=lpFindNarrow->ftLastAccessTime;
280 lpFindFileData->ftLastWriteTime=lpFindNarrow->ftLastWriteTime;
281 lpFindFileData->nFileSizeHigh=lpFindNarrow->nFileSizeHigh;
282 lpFindFileData->nFileSizeLow=lpFindNarrow->nFileSizeLow;
284 if(!MultiByteToWideChar(Data.iCodePage,0,lpFindNarrow->cFileName,-1,lpFindFileData->cFileName,MAX_PATH))
287 if(lpFindNarrow->cAlternateFileName!=NULL)
289 // magic number 14 comes from MS documentation
290 if(!MultiByteToWideChar(Data.iCodePage,0,lpFindNarrow->cAlternateFileName,-1,lpFindFileData->cAlternateFileName,14))
298 This function wraps the Win32 FindFirstFile API (see http://msdn2.microsoft.com/en-us/library/aa364418.aspx).
300 EXPORT_C HANDLE Emulator::FindFirstFile(LPCWSTR lpFileName,LPWIN32_FIND_DATAW lpFindFileData)
305 return ::FindFirstFileW(lpFileName, lpFindFileData);
307 WIN32_FIND_DATAA lpFindNarrow;
308 HANDLE h=::FindFirstFileA(Buf8<MAX_PATH>(lpFileName),&lpFindNarrow);
309 if(h==INVALID_HANDLE_VALUE)
312 if (!MapFindFileData(lpFindFileData, &lpFindNarrow))
315 return INVALID_HANDLE_VALUE;
323 This function wraps the Win32 FindNextFile API (see http://msdn2.microsoft.com/en-us/library/aa364428.aspx).
325 EXPORT_C BOOL Emulator::FindNextFile(HANDLE hFindFile,LPWIN32_FIND_DATAW lpFindFileData)
330 return ::FindNextFileW(hFindFile, lpFindFileData);
332 WIN32_FIND_DATAA lpFindNarrow;
333 if(!::FindNextFileA(hFindFile,&lpFindNarrow))
336 return MapFindFileData(lpFindFileData, &lpFindNarrow);
340 This function wraps the Win32 GetDiskFreeSpace API (see http://msdn2.microsoft.com/en-us/library/aa364935.aspx).
342 EXPORT_C BOOL Emulator::GetDiskFreeSpace(LPCWSTR lpRootPathName,LPDWORD lpSectorsPerCluster,\
343 LPDWORD lpBytesPerSector,LPDWORD lpNumberOfFreeClusters,\
344 LPDWORD lpTotalNumberOfClusters)
349 return ::GetDiskFreeSpaceW(lpRootPathName,lpSectorsPerCluster,lpBytesPerSector,lpNumberOfFreeClusters,lpTotalNumberOfClusters);
351 return ::GetDiskFreeSpaceA(Buf8<MAX_PATH>(lpRootPathName),lpSectorsPerCluster,lpBytesPerSector,lpNumberOfFreeClusters,lpTotalNumberOfClusters);
357 This function wraps the Win32 GetFileAttributes API (see http://msdn2.microsoft.com/en-us/library/aa364944.aspx).
359 EXPORT_C DWORD Emulator::GetFileAttributes(LPCWSTR lpFileName)
364 return ::GetFileAttributesW(lpFileName);
366 return ::GetFileAttributesA(Buf8<MAX_PATH>(lpFileName));
371 This function wraps the Win32 GetModuleHandle API (see http://msdn2.microsoft.com/en-us/library/ms683199.aspx).
373 EXPORT_C HMODULE Emulator::GetModuleHandle(LPCWSTR lpModuleName)
378 return ::GetModuleHandleW(lpModuleName);
380 return ::GetModuleHandleA(Buf8<MAX_PATH>(lpModuleName));
385 This function wraps the Win32 GetModuleFileName API (see http://msdn2.microsoft.com/en-us/library/ms683197.aspx).
387 EXPORT_C DWORD Emulator::GetModuleFileName(HMODULE hModule, LPWSTR lpFilename)
391 return ::GetModuleFileNameW(hModule, lpFilename, MAX_PATH);
393 DWORD r=::GetModuleFileNameA(hModule, fn, MAX_PATH);
394 if (r>MAX_PATH||r==0)
396 return ConvertToUnicode(fn, lpFilename, MAX_PATH, TRUE);
401 This function wraps the Win32 GetTempPath API (see http://msdn2.microsoft.com/en-us/library/Aa364992.aspx).
403 EXPORT_C DWORD Emulator::GetTempPath(DWORD nBufferLength,LPWSTR lpBuff)
408 return ::GetTempPathW(nBufferLength,lpBuff);
411 DWORD r=::GetTempPathA(MAX_PATH,path);
414 return ConvertToUnicode(path,lpBuff,nBufferLength,TRUE);
419 This function wraps the Win32 GetCurrentDirectory API (see http://msdn2.microsoft.com/en-us/library/aa364934.aspx).
421 EXPORT_C DWORD Emulator::GetCurrentDirectory(DWORD nBufferLength,LPWSTR lpBuff)
426 return ::GetCurrentDirectoryW(nBufferLength,lpBuff);
429 DWORD r=::GetCurrentDirectoryA(MAX_PATH,path);
432 return ConvertToUnicode(path,lpBuff,nBufferLength,TRUE);
437 This function wraps the Win32 GetVolumeInformation API (see http://msdn2.microsoft.com/en-us/library/aa364993.aspx).
439 EXPORT_C BOOL Emulator::GetVolumeInformation(LPCWSTR lpRootPathName,LPWSTR lpVolumeNameBuffer,DWORD nVolumeNameSize,
440 LPDWORD lpVolumeSerialNumber,LPDWORD lpMaximumComponentLength,
441 LPDWORD lpFileSystemFlags,LPWSTR,DWORD)
445 // lpfileSystemNameBuffer always NULL so no need to convert
447 return ::GetVolumeInformationW(lpRootPathName,lpVolumeNameBuffer,nVolumeNameSize,lpVolumeSerialNumber,
448 lpMaximumComponentLength,lpFileSystemFlags,NULL,0);
450 char volName[MAX_PATH];
451 BOOL res=::GetVolumeInformationA(Buf8<MAX_PATH>(lpRootPathName),volName,MAX_PATH,lpVolumeSerialNumber,
452 lpMaximumComponentLength,lpFileSystemFlags,NULL,0);
454 if(res && lpVolumeNameBuffer)
455 ConvertToUnicode(volName,lpVolumeNameBuffer,nVolumeNameSize,FALSE);
461 This function wraps the Win32 LoadLibrary API (see http://msdn2.microsoft.com/en-us/library/ms684175.aspx).
463 EXPORT_C HMODULE Emulator::LoadLibrary(LPCWSTR lpLibFileName)
468 return ::LoadLibraryW(lpLibFileName);
470 return ::LoadLibraryA(Buf8<MAX_PATH>(lpLibFileName));
475 This function wraps the Win32 FreeLibrary API (see http://msdn2.microsoft.com/en-us/library/ms683152.aspx).
477 EXPORT_C BOOL Emulator::FreeLibrary(HMODULE hLibModule)
480 return ::FreeLibrary(hLibModule);
486 This function wraps the Win32 MoveFile API (see http://msdn2.microsoft.com/en-us/library/aa365239.aspx).
488 EXPORT_C BOOL Emulator::MoveFile(LPCWSTR lpExistingFileName,LPCWSTR lpNewFileName)
493 return ::MoveFileW(lpExistingFileName,lpNewFileName);
495 return ::MoveFileA(Buf8<MAX_PATH>(lpExistingFileName),Buf8<MAX_PATH>(lpNewFileName));
500 This function wraps the Win32 CopyFile API (see http://msdn2.microsoft.com/en-us/library/aa363851.aspx).
502 EXPORT_C BOOL Emulator::CopyFile(LPCWSTR lpExistingFileName,LPCWSTR lpNewFileName,BOOL aFailIfExists)
507 return ::CopyFileW(lpExistingFileName,lpNewFileName,aFailIfExists);
509 return ::CopyFileA(Buf8<MAX_PATH>(lpExistingFileName),Buf8<MAX_PATH>(lpNewFileName),aFailIfExists);
514 This function wraps the Win32 OutputDebugString API (see http://msdn2.microsoft.com/en-us/library/aa363362.aspx).
516 EXPORT_C VOID Emulator::OutputDebugString(LPCWSTR lpOutputString)
519 ::OutputDebugStringW(lpOutputString);
521 ::OutputDebugStringA(Buf8<1024>(lpOutputString));
527 This function wraps the Win32 RemoveDirectory API (see http://msdn2.microsoft.com/en-us/library/aa365488.aspx).
529 EXPORT_C BOOL Emulator::RemoveDirectory(LPCWSTR lpPathName)
534 return ::RemoveDirectoryW(lpPathName);
536 return ::RemoveDirectoryA(Buf8<MAX_PATH>(lpPathName));
541 This function wraps the Win32 SetFileAttributes API (see http://msdn2.microsoft.com/en-us/library/aa365535.aspx).
544 EXPORT_C BOOL Emulator::SetFileAttributes(LPCWSTR lpFileName,DWORD dwFileAttributes)
549 return ::SetFileAttributesW(lpFileName,dwFileAttributes);
551 return ::SetFileAttributesA(Buf8<MAX_PATH>(lpFileName),dwFileAttributes);
557 This function wraps the Win32 SetVolumeLabel API (see http://msdn2.microsoft.com/en-us/library/aa365560.aspx).
559 EXPORT_C BOOL Emulator::SetVolumeLabel(LPCWSTR lpRootPathName,LPCWSTR lpVolumeName)
564 return ::SetVolumeLabelW(lpRootPathName,lpVolumeName);
566 return ::SetVolumeLabelA(Buf8<MAX_PATH>(lpRootPathName),Buf8<MAX_PATH>(lpVolumeName));
571 Maps an NT error to an Epoc32 error.
573 @return Last-error code of the calling thread.
575 EXPORT_C TInt Emulator::LastError()
577 // For other error codes look at MSDN "Numerical List of Error Codes"
579 switch (GetLastError())
581 case ERROR_SUCCESS: return KErrNone;
582 case ERROR_INVALID_DRIVE: return KErrNotReady;
583 case ERROR_INVALID_NAME:
584 case ERROR_FILENAME_EXCED_RANGE:
585 case ERROR_OPEN_FAILED: return KErrBadName;
586 case ERROR_INVALID_HANDLE: return KErrBadHandle;
587 case ERROR_NOT_SUPPORTED:
588 case ERROR_INVALID_FUNCTION: return KErrNotSupported;
589 case ERROR_SHARING_VIOLATION:
590 case ERROR_ACCESS_DENIED:
591 case ERROR_WRITE_PROTECT: return KErrAccessDenied;
592 case ERROR_LOCK_VIOLATION: return KErrLocked;
593 case ERROR_FILE_NOT_FOUND:
594 case ERROR_MOD_NOT_FOUND: return KErrNotFound;
595 case ERROR_DIRECTORY:
596 case ERROR_BAD_PATHNAME:
597 case ERROR_PATH_NOT_FOUND: return KErrPathNotFound;
598 case ERROR_ALREADY_EXISTS:
599 case ERROR_FILE_EXISTS: return KErrAlreadyExists;
600 case ERROR_NOT_READY: return KErrNotReady;
601 case ERROR_UNRECOGNIZED_VOLUME:
602 case ERROR_NOT_DOS_DISK: return KErrUnknown;
603 case ERROR_UNRECOGNIZED_MEDIA:
604 case ERROR_BAD_EXE_FORMAT: return KErrCorrupt;
605 case ERROR_NO_MORE_FILES: return KErrEof;
606 case ERROR_DIR_NOT_EMPTY: return KErrInUse;
607 case ERROR_INVALID_USER_BUFFER:
608 case ERROR_NOT_ENOUGH_MEMORY:
609 case ERROR_INSUFFICIENT_BUFFER:
610 case ERROR_OUTOFMEMORY: return KErrNoMemory;
611 case ERROR_DISK_FULL: return KErrDiskFull;
612 case ERROR_INVALID_DATA:
613 case ERROR_INVALID_PARAMETER: return KErrArgument;
614 case ERROR_OPERATION_ABORTED: return KErrCancel;
616 default: return KErrGeneral;
621 This function wraps the Win32 GetProcAddress API (see http://msdn2.microsoft.com/en-us/library/ms683212.aspx).
623 FARPROC Emulator::GetProcAddress(HMODULE hModule, LPCSTR lpProcName)
626 return ::GetProcAddress(hModule, lpProcName);
631 // image file support
637 Gets the header format of the file system.
639 @return Returns the header format of the file system.
641 EXPORT_C const IMAGE_NT_HEADERS32* Emulator::TModule::NtHeader() const
645 const IMAGE_DOS_HEADER* dhead = (const IMAGE_DOS_HEADER*)Translate(0);
646 if ( IMAGE_DOS_SIGNATURE != dhead->e_magic )
648 if (dhead->e_lfarlc < sizeof(IMAGE_DOS_HEADER))
650 const IMAGE_NT_HEADERS32* ntHead = (const IMAGE_NT_HEADERS32*)Translate(dhead->e_lfanew);
651 if ( ntHead->Signature != IMAGE_NT_SIGNATURE )
658 Constructor which sets the handles of loaded module to the specified module.
660 @param aModuleName Holds the name of the module to be loaded.
662 EXPORT_C Emulator::TModule::TModule(LPCSTR aModuleName)
663 : iModule(GetModuleHandleA(aModuleName)), iBase(iModule)
674 Gets the pointer of the section header if the header name matches with the buffer aSection[].
676 @param aSection[] A buffer of type BYTE.
678 @return Returns the pointer to section header of the file system.
680 EXPORT_C const IMAGE_SECTION_HEADER* Emulator::TModule::SectionHeader(const BYTE aSection[]) const
682 const IMAGE_NT_HEADERS32* ntHead = NtHeader();
686 const IMAGE_SECTION_HEADER* imgHead = (const IMAGE_SECTION_HEADER*)((TUint8*)&ntHead->OptionalHeader + ntHead->FileHeader.SizeOfOptionalHeader);
687 const IMAGE_SECTION_HEADER* end = imgHead + ntHead->FileHeader.NumberOfSections;
688 for (; imgHead < end; ++imgHead)
690 if (memcmp(imgHead->Name, aSection, IMAGE_SIZEOF_SHORT_NAME)==0)
698 Points to the first byte or first page of the loaded module or mapped file image.
700 @param aSection[] A buffer of type BYTE.
702 @return TAny Returns first byte of the loaded module or first page of the mapped file image.
704 EXPORT_C const TAny* Emulator::TModule::Section(const BYTE aSection[]) const
706 const IMAGE_SECTION_HEADER* imgHead = SectionHeader(aSection);
708 return Translate(IsLoaded() ? imgHead->VirtualAddress : imgHead->PointerToRawData);
714 Go through the section headers looking for UID section.
716 @param aType Contains a UID type.
718 EXPORT_C void Emulator::TModule::GetUids(TUidType& aType) const
720 const TEmulatorImageHeader* hdr = (const TEmulatorImageHeader*)Section(KWin32SectionName_Symbian);
722 aType = *(const TUidType*)&hdr->iUids[0];
727 Goes through section headers and gets the information of file system.
729 @param aInfo Contains the information of the file system.
731 EXPORT_C void Emulator::TModule::GetInfo(TProcessCreateInfo& aInfo) const
733 aInfo.iExceptionDescriptor = 0;
734 const IMAGE_NT_HEADERS32* ntHead = NtHeader();
737 const TEmulatorImageHeader* hdr = (const TEmulatorImageHeader*)Section(KWin32SectionName_Symbian);
740 aInfo.iUids = *(const TUidType*)&hdr->iUids[0];
741 TBool isExe = (hdr->iUids[0].iUid==KExecutableImageUidValue);
742 TBool data_section_present = (Section(KWin32SectionName_EpocData)!=NULL);
743 TBool data = hdr->iFlags & KEmulatorImageFlagAllowDllData;
744 if (data_section_present && isExe)
746 aInfo.iBssSize=data?1:0;
748 aInfo.iTotalDataSize=aInfo.iBssSize;
750 aInfo.iHeapSizeMin = ntHead->OptionalHeader.SizeOfHeapCommit;
751 aInfo.iHeapSizeMax = ntHead->OptionalHeader.SizeOfHeapReserve;
752 aInfo.iStackSize = 0x1000;
753 aInfo.iPriority = hdr->iPriority;
754 aInfo.iHandle = NULL;
756 aInfo.iModuleVersion = hdr->iModuleVersion;
757 if (ntHead->FileHeader.Characteristics & IMAGE_FILE_DLL)
758 aInfo.iAttr |= ECodeSegAttHDll;
761 GetUids(aInfo.iUids);
766 Finds the import section from the data directory. This relies on the module being loaded.
768 @return Returns the imported executable.
770 EXPORT_C const IMAGE_IMPORT_DESCRIPTOR* Emulator::TModule::Imports() const
774 const IMAGE_NT_HEADERS32* ntHead = NtHeader();
777 DWORD va = ntHead->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_IMPORT].VirtualAddress;
780 return (const IMAGE_IMPORT_DESCRIPTOR*)Translate(va);
783 // modules in the file system
784 EXPORT_C TInt Emulator::RImageFile::Open(LPCTSTR aImageFile)
786 Buf8<MAX_PATH> nameBuf(aImageFile);
787 char *pName = (char *)strrchr(LPCSTR(nameBuf), '\\');
788 pName ? ++pName : pName = (char *)LPCSTR(nameBuf);
791 iMapping = OpenFileMapping(FILE_MAP_READ, FALSE, (LPCTSTR)pName);
794 if (pName == (char *)LPCSTR(nameBuf))
795 iModule = Emulator::GetModuleHandle(aImageFile);
800 // need to map the file instead
801 HANDLE file = Emulator::CreateFile(aImageFile, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL);
802 if (file == INVALID_HANDLE_VALUE)
804 iMapping = CreateFileMappingA(file, NULL, PAGE_READONLY, 0, 0, pName);
813 iBase = MapViewOfFile(iMapping, FILE_MAP_READ, 0, 0, 0);
817 CloseHandle(iMapping);
826 return KErrNotSupported;
831 EXPORT_C void Emulator::RImageFile::Close()
835 UnmapViewOfFile(iBase);
836 CloseHandle(iMapping);