Replaced a few internal functions by exported ones.

diff --git a/dlls/avifil32/avifile.c b/dlls/avifil32/avifile.c
index 41265e8..a7d838d 100644
--- a/dlls/avifil32/avifile.c
+++ b/dlls/avifil32/avifile.c
@@ -6,7 +6,7 @@
 #include <assert.h>
 
 #include "winbase.h"
-#include "wine/winestring.h"
+#include "winnls.h"
 #include "mmsystem.h"
 #include "winerror.h"
 #include "debugtools.h"
@@ -372,7 +372,8 @@
 	
 	/* Only the szName at the end is different */
 	memcpy(&psiw,psi,sizeof(*psi)-sizeof(psi->szName));
-	lstrcpynAtoW(psiw.szName,psi->szName,sizeof(psi->szName));
+        MultiByteToWideChar( CP_ACP, 0, psi->szName, -1,
+                             psiw.szName, sizeof(psiw.szName) / sizeof(WCHAR) );
 	return IAVIFile_CreateStream(iface,ppavi,&psiw);
 }
 
@@ -402,7 +403,9 @@
 		return AVIERR_BADSIZE;
 	hres = IAVIFile_Info(iface,&afiw,sizeof(afiw));
 	memcpy(afi,&afiw,sizeof(*afi)-sizeof(afi->szFileType));
-	lstrcpynWtoA(afi->szFileType,afiw.szFileType,sizeof(afi->szFileType));
+        WideCharToMultiByte( CP_ACP, 0, afiw.szFileType, -1,
+                             afi->szFileType, sizeof(afi->szFileType), NULL, NULL );
+        afi->szFileType[sizeof(afi->szFileType)-1] = 0;
 	return hres;
 }
 
@@ -426,7 +429,9 @@
 		return AVIERR_BADSIZE;
  	hres = IAVIFile_Info(iface,&asiw,sizeof(asiw));
 	memcpy(asi,&asiw,sizeof(asiw)-sizeof(asiw.szName));
-	lstrcpynWtoA(asi->szName,asiw.szName,sizeof(asi->szName));
+        WideCharToMultiByte( CP_ACP, 0, asiw.szName, -1,
+                             asi->szName, sizeof(asi->szName), NULL, NULL );
+        asi->szName[sizeof(asi->szName)-1] = 0;
 	return hres;
 }
 
diff --git a/dlls/dplayx/dplay.c b/dlls/dplayx/dplay.c
index 3ead55c..aa35d60 100644
--- a/dlls/dplayx/dplay.c
+++ b/dlls/dplayx/dplay.c
@@ -10,8 +10,9 @@
 #include "winbase.h"
 #include "winnt.h"
 #include "winreg.h"
-#include "dplay.h"
+#include "wine/unicode.h"
 #include "heap.h"
+#include "dplay.h"
 #include "debugtools.h"
 
 #include "dpinit.h"
@@ -21,7 +22,7 @@
 #include "dplaysp.h"
 #include "dplay_global.h"
 
-DEFAULT_DEBUG_CHANNEL(dplay)
+DEFAULT_DEBUG_CHANNEL(dplay);
 
 /* FIXME: Should this be externed? */
 extern HRESULT DPL_CreateCompoundAddress 
@@ -1224,30 +1225,30 @@
   {
     if( lpSrc->psn.lpszShortNameA )
     {
-      lpDst->psn.lpszShortNameA = 
-        HEAP_strdupA( GetProcessHeap(), HEAP_ZERO_MEMORY, 
-                        lpSrc->psn.lpszShortNameA );
+        lpDst->psn.lpszShortNameA = HeapAlloc( GetProcessHeap(), 0,
+                                             strlen(lpSrc->psn.lpszShortNameA)+1 );
+        strcpy( lpDst->psn.lpszShortNameA, lpSrc->psn.lpszShortNameA );
     }
     if( lpSrc->pln.lpszLongNameA )
     {
-      lpDst->pln.lpszLongNameA =
-        HEAP_strdupA( GetProcessHeap(), HEAP_ZERO_MEMORY,
-                        lpSrc->pln.lpszLongNameA );
+        lpDst->pln.lpszLongNameA = HeapAlloc( GetProcessHeap(), 0,
+                                              strlen(lpSrc->pln.lpszLongNameA)+1 );
+        strcpy( lpDst->pln.lpszLongNameA, lpSrc->pln.lpszLongNameA );
     }
   }
   else
   {
     if( lpSrc->psn.lpszShortNameA )
     {
-      lpDst->psn.lpszShortName = 
-        HEAP_strdupW( GetProcessHeap(), HEAP_ZERO_MEMORY,
-                        lpSrc->psn.lpszShortName );
+        lpDst->psn.lpszShortName = HeapAlloc( GetProcessHeap(), 0,
+                                              (strlenW(lpSrc->psn.lpszShortName)+1)*sizeof(WCHAR) );
+        strcpyW( lpDst->psn.lpszShortName, lpSrc->psn.lpszShortName );
     }
     if( lpSrc->pln.lpszLongNameA )
     {
-      lpDst->pln.lpszLongName =
-        HEAP_strdupW( GetProcessHeap(), HEAP_ZERO_MEMORY,
-                        lpSrc->pln.lpszLongName );
+        lpDst->pln.lpszLongName = HeapAlloc( GetProcessHeap(), 0,
+                                             (strlenW(lpSrc->pln.lpszLongName)+1)*sizeof(WCHAR) );
+        strcpyW( lpDst->pln.lpszLongName, lpSrc->pln.lpszLongName );
     }
   }
 
diff --git a/dlls/imagehlp/access.c b/dlls/imagehlp/access.c
index 30d23f3..c6a5375 100644
--- a/dlls/imagehlp/access.c
+++ b/dlls/imagehlp/access.c
@@ -8,7 +8,6 @@
 #include "winnt.h"
 #include "winerror.h"
 #include "windef.h"
-#include "heap.h"
 #include "debugtools.h"
 #include "imagehlp.h"
 
@@ -240,8 +239,8 @@
 
   pNtHeader = ImageNtHeader((PVOID) hModule);
 
-  pLoadedImage->ModuleName =
-    HEAP_strdupA(IMAGEHLP_hHeap, 0, pszDllPath); /* FIXME: Correct? */
+  pLoadedImage->ModuleName = HeapAlloc(IMAGEHLP_hHeap, 0, strlen(pszDllPath)+1); /* FIXME: Correct? */
+  strcpy( pLoadedImage->ModuleName, pszDllPath );
   pLoadedImage->hFile = hFile;
   pLoadedImage->MappedAddress = (PUCHAR) hModule;
   pLoadedImage->FileHeader = pNtHeader;
diff --git a/dlls/msacm/internal.c b/dlls/msacm/internal.c
index 293513c..4f6924c 100644
--- a/dlls/msacm/internal.c
+++ b/dlls/msacm/internal.c
@@ -14,14 +14,13 @@
 #include "wingdi.h"
 #include "winuser.h"
 #include "winerror.h"
-#include "heap.h"
 #include "mmsystem.h"
 #include "msacm.h"
 #include "msacmdrv.h"
 #include "wineacm.h"
 #include "debugtools.h"
 
-DEFAULT_DEBUG_CHANNEL(msacm)	
+DEFAULT_DEBUG_CHANNEL(msacm);
 
 /**********************************************************************/
 
@@ -42,8 +41,18 @@
     padid = (PWINE_ACMDRIVERID) HeapAlloc(MSACM_hHeap, 0, sizeof(WINE_ACMDRIVERID));
     padid->obj.dwType = WINE_ACMOBJ_DRIVERID;
     padid->obj.pACMDriverID = padid;
-    padid->pszDriverAlias = pszDriverAlias ? HEAP_strdupA(MSACM_hHeap, 0, pszDriverAlias) : NULL;
-    padid->pszFileName = pszFileName ? HEAP_strdupA(MSACM_hHeap, 0, pszFileName) : NULL;
+    padid->pszDriverAlias = NULL;
+    if (pszDriverAlias)
+    {
+        padid->pszDriverAlias = HeapAlloc( MSACM_hHeap, 0, strlen(pszDriverAlias)+1 );
+        strcpy( padid->pszDriverAlias, pszDriverAlias );
+    }
+    padid->pszFileName = NULL;
+    if (pszFileName)
+    {
+        padid->pszFileName = HeapAlloc( MSACM_hHeap, 0, strlen(pszFileName)+1 );
+        strcpy( padid->pszFileName, pszFileName );
+    }
     padid->hInstModule = hinstModule;
     padid->bEnabled = TRUE;
     padid->pACMDriverList = NULL;
diff --git a/dlls/setupapi/infparse.c b/dlls/setupapi/infparse.c
index f703cd1..4bde7e1 100644
--- a/dlls/setupapi/infparse.c
+++ b/dlls/setupapi/infparse.c
@@ -33,7 +33,9 @@
 	InfList = HeapReAlloc(GetProcessHeap(), 0, InfList, InfNumEntries+1);
 	InfList[InfNumEntries].hInf = IP_curr_handle++;
 	InfList[InfNumEntries].hInfFile = hFile;
-	InfList[InfNumEntries].lpInfFileName = HEAP_strdupA(GetProcessHeap(), 0, lpInfFileName);
+	InfList[InfNumEntries].lpInfFileName = HeapAlloc( GetProcessHeap(), 0,
+                                                          strlen(lpInfFileName)+1);
+        strcpy( InfList[InfNumEntries].lpInfFileName, lpInfFileName );
         *lphInf = InfList[InfNumEntries].hInf;
 	InfNumEntries++;
 	TRACE("ret handle %d.\n", *lphInf);
@@ -110,6 +112,6 @@
 RETERR16 WINAPI IpGetProfileString16(HINF16 hInf, LPCSTR section, LPCSTR entry, LPSTR buffer, WORD buflen) 
 {
     TRACE("'%s': section '%s' entry '%s'\n", IP_GetFileName(hInf), section, entry);
-    GetPrivateProfileString16(section, entry, "", buffer, buflen, IP_GetFileName(hInf));
+    GetPrivateProfileStringA(section, entry, "", buffer, buflen, IP_GetFileName(hInf));
     return 0;
 }
diff --git a/dlls/winmm/mciseq/mcimidi.c b/dlls/winmm/mciseq/mcimidi.c
index db89734..633e6f2 100644
--- a/dlls/winmm/mciseq/mcimidi.c
+++ b/dlls/winmm/mciseq/mcimidi.c
@@ -21,7 +21,6 @@
 #include "wingdi.h"
 #include "winuser.h"
 #include "mmddk.h"
-#include "heap.h"
 #include "debugtools.h"
 
 DEFAULT_DEBUG_CHANNEL(mcimidi);
@@ -49,9 +48,9 @@
     WORD		wNotifyDeviceID;    	/* MCI device ID with a pending notification */
     HANDLE 		hCallback;         	/* Callback handle for pending notification  */
     HMMIO		hFile;	            	/* mmio file handle open as Element          */
-    LPCSTR		lpstrElementName;	/* Name of file */
-    LPCSTR		lpstrCopyright;
-    LPCSTR		lpstrName;	       	
+    LPSTR		lpstrElementName;	/* Name of file */
+    LPSTR		lpstrCopyright;
+    LPSTR		lpstrName;	       	
     WORD		dwStatus;		/* one from MCI_MODE_xxxx */
     DWORD		dwMciTimeFormat;	/* One of the supported MCI_FORMAT_xxxx */	       
     WORD		wFormat;		/* Format of MIDI hFile (0, 1 or 2) */
@@ -396,14 +395,16 @@
 		    if (wmm->lpstrCopyright) {
 			WARN("Two copyright notices (%s|%s)\n", wmm->lpstrCopyright, buf);
 		    } else {
-			wmm->lpstrCopyright = HEAP_strdupA(GetProcessHeap(), 0, buf);
+                        wmm->lpstrCopyright = HeapAlloc( GetProcessHeap(), 0, strlen(buf)+1 );
+                        strcpy( wmm->lpstrCopyright, buf );
 		    }
 		    break;
 		case 0x03:
 		    if (wmm->lpstrCopyright) {
 			WARN("Two names (%s|%s)\n", wmm->lpstrName, buf);
 		    } else {
-			wmm->lpstrName = HEAP_strdupA(GetProcessHeap(), 0, buf);
+			wmm->lpstrName = HeapAlloc( GetProcessHeap(), 0, strlen(buf)+1 );
+                        strcpy( wmm->lpstrName, buf );
 		    }
 		    break;
 		}
@@ -733,7 +734,8 @@
     TRACE("hFile=%u\n", wmm->hFile);
     
     /* FIXME: should I get a strdup() of it instead? */
-    wmm->lpstrElementName = HEAP_strdupA(GetProcessHeap(), 0, lpParms->lpstrElementName);
+    wmm->lpstrElementName = HeapAlloc( GetProcessHeap(), 0, strlen(lpParms->lpstrElementName)+1 );
+    strcpy( wmm->lpstrElementName, lpParms->lpstrElementName );
     wmm->lpstrCopyright = NULL;
     wmm->lpstrName = NULL;
 
diff --git a/dlls/winspool/info.c b/dlls/winspool/info.c
index c5d3df4..ebb110b 100644
--- a/dlls/winspool/info.c
+++ b/dlls/winspool/info.c
@@ -498,8 +498,9 @@
     }
 
     /* Get the name of the printer */
-    lpOpenedPrinter->lpsPrinterName = 
-      HEAP_strdupW( GetProcessHeap(), 0, lpPrinterName );
+    lpOpenedPrinter->lpsPrinterName = HeapAlloc( GetProcessHeap(), 0,
+                                                 (strlenW(lpPrinterName)+1)*sizeof(WCHAR) );
+    strcpyW( lpOpenedPrinter->lpsPrinterName, lpPrinterName );
 
     /* Get the unique handle of the printer*/
     *phPrinter = lpOpenedPrinter->hPrinter;
diff --git a/graphics/x11drv/dib.c b/graphics/x11drv/dib.c
index b1812bc..0dee543 100644
--- a/graphics/x11drv/dib.c
+++ b/graphics/x11drv/dib.c
@@ -3603,7 +3603,7 @@
   
   if (dib->selector)
     {
-      WORD count = (GET_SEL_LIMIT( dib->selector ) >> 16) + 1;
+      WORD count = (GetSelectorLimit16( dib->selector ) >> 16) + 1;
       SELECTOR_FreeBlock( dib->selector, count );
     }
 }
diff --git a/memory/global.c b/memory/global.c
index 18b1401..3d9dce2 100644
--- a/memory/global.c
+++ b/memory/global.c
@@ -136,7 +136,7 @@
       /* Fill the arena block */
 
     pArena->base = (DWORD)ptr;
-    pArena->size = GET_SEL_LIMIT(sel) + 1;
+    pArena->size = GetSelectorLimit16(sel) + 1;
     pArena->handle = (flags & GMEM_MOVEABLE) ? sel - 1 : sel;
     pArena->hOwner = hOwner;
     pArena->lockCount = 0;
@@ -360,7 +360,7 @@
 
     if (pNewArena != pArena) memcpy( pNewArena, pArena, sizeof(GLOBALARENA) );
     pNewArena->base = (DWORD)ptr;
-    pNewArena->size = GET_SEL_LIMIT(sel) + 1;
+    pNewArena->size = GetSelectorLimit16(sel) + 1;
     pNewArena->selCount = selcount;
     pNewArena->handle = (pNewArena->flags & GA_MOVEABLE) ? sel - 1 : sel;
 
diff --git a/scheduler/thread.c b/scheduler/thread.c
index 4b0f128..f0024c7e 100644
--- a/scheduler/thread.c
+++ b/scheduler/thread.c
@@ -112,8 +112,8 @@
     /* Free the associated memory */
 
     if (teb->socket != -1) close( teb->socket );
-    if (teb->stack_sel) SELECTOR_FreeBlock( teb->stack_sel, 1 );
-    SELECTOR_FreeBlock( teb->teb_sel, 1 );
+    if (teb->stack_sel) FreeSelector16( teb->stack_sel );
+    FreeSelector16( teb->teb_sel );
     if (teb->buffer) munmap( (void *)teb->buffer,
                              (char *)(teb->buffer_info+1) - (char *)teb->buffer );
     if (teb->debug_info) HeapFree( GetProcessHeap(), 0, teb->debug_info );