Porting radio driver from MS to Linux

Arjen Verweij sphere at vengeance.et.tudelft.nl
Sun Sep 7 08:37:42 CDT 2003


Hi,

I am looking to port a MSVC++ driver to Linux. The recommended approach,
to convert the Makefile and compile it didn't work for me, so I am trying
to compile seperate cpp.files by implementing the winapi functions I need
in a seperate linuxapi.cpp

There are about 30 functions I have to port at the moment, and some of
them are easier than others. Basically they are part of the DLL (so),
thread/event/mutex, File*Find apis, with some miscellaneous ones. I think
I could do myself a favor by asking if the MSVC++ code could use
libpthread instead of the MS threads, so I'm not too worried about those,
and simulating DLL with the dl* api seems easy enough as well. Still,
there are problems with Find*File, FindClose, GetModuleFileName and so on.

I'm not too familiar with winapi myself, because I learn C/C++ in a
college environment, where most programming assignments are geared towards
Linux. Can anyone comment sensibly on this? If you are of the opinion that
I should just rewrite the app from scratch, I agree in part, but the
assignment is to leave as much of the original code as it is, apart from
isolated cases where g++ can't quite follow the MSVC++ compiler.

At the end of the email is a list of prototypes included, that I ripped
from winbase.h


Looking forward to read your thoughts on this matter,

Regards,


Arjen Verweij



Here is the list:

DWORD GetModuleFileName(HMODULE, LPTSTR, DWORD);

HANDLE FindFirstFile(LPCSTR lpFileName, LPWIN32_FIND_DATA lpFindFileData);

BOOL FindNextFile(HANDLE hFindFile, LPWIN32_FIND_DATA lpFindFileData);

BOOL FindClose(HANDLE hFindFile);

BOOL SetEvent(HANDLE hEvent);

FARPROC GetProcAddress(HMODULE hModule, LPCSTR lpProcName);

HMODULE LoadLibrary(LPCSTR lpLibFileName);

BOOL FreeLibrary(HMODULE hLibModule);

HANDLE CreateMutex(LPSECURITY_ATTRIBUTES lpMutexAttributes,
	BOOL bInitialOwner, LPCSTR lpName);

DWORD WaitForMultipleObjects(DWORD nCount, CONST HANDLE *lpHandles,
	BOOL bWaitAll, DWORD dwMilliseconds);

BOOL CloseHandle(HANDLE hObject);

BOOL ReleaseMutex(HANDLE hMutex);

DWORD GetCurrentProcessId(VOID);

HANDLE CreateEvent(LPSECURITY_ATTRIBUTES lpEventAttributes,
	BOOL bManualReset, BOOL bInitialState, LPCSTR lpName);

VOID Sleep(DWORD dwMilliseconds);

BOOL ResetEvent(HANDLE hEvent);

DWORD _beginthread(void(__cdecl *start_address) (void*), unsigned, void*);

VOID OutputDebugString(LPCSTR lpOutputString);

DWORD WaitForSingleObject(HANDLE hHandle, DWORD dwMilliseconds);

void _endthread(void);

BOOL ReleaseSemaphore(HANDLE hSemaphore, LONG lReleaseCount,
	LPLONG lpPreviousCount);

HANDLE CreateSemaphore(LPSECURITY_ATTRIBUTES lpSemaphoreAttributes,
	LONG lInitialCount, LONG lMaximumCount, LPCSTR lpName);

BOOL UnmapViewOfFile(LPCVOID lpBaseAddress);

HANDLE CreateFileMapping(HANDLE hFile,
	LPSECURITY_ATTRIBUTES lpFileMappingAttributes,
	DWORD flProtect, DWORD dwMaximumSizeHigh, DWORD dwMaximumSizeLow,
	LPCSTR lpName);

DWORD GetLastError(VOID);

LPVOID MapViewOfFile(HANDLE hFileMappingObject, DWORD dwDesiredAccess,
	DWORD dwFileOffsetHigh, DWORD dwFileOffsetLow,
	DWORD dwNumberOfBytesToMap);





More information about the wine-devel mailing list