Revert previous commit for loader as it is external to vlc
authorRafaël Carré <funman@videolan.org>
Mon, 10 Sep 2007 20:28:47 +0000 (20:28 +0000)
committerRafaël Carré <funman@videolan.org>
Mon, 10 Sep 2007 20:28:47 +0000 (20:28 +0000)
34 files changed:
libs/loader/afl.c
libs/loader/com.h
libs/loader/driver.c
libs/loader/driver.h
libs/loader/ext.c
libs/loader/ext.h
libs/loader/kludge.c
libs/loader/ldt_keeper.c
libs/loader/loader.h
libs/loader/module.c
libs/loader/pe_image.c
libs/loader/pe_resource.c
libs/loader/qtx/qtxsdk/components.h
libs/loader/registry.c
libs/loader/registry.h
libs/loader/resource.c
libs/loader/vfl.c
libs/loader/win32.c
libs/loader/wine/avifmt.h
libs/loader/wine/driver.h
libs/loader/wine/heap.h
libs/loader/wine/mmreg.h
libs/loader/wine/module.h
libs/loader/wine/msacm.h
libs/loader/wine/msacmdrv.h
libs/loader/wine/pe_image.h
libs/loader/wine/vfw.h
libs/loader/wine/winbase.h
libs/loader/wine/windef.h
libs/loader/wine/winerror.h
libs/loader/wine/winnt.h
libs/loader/wine/winreg.h
libs/loader/wine/winuser.h
libs/loader/wineacm.h

index 5f6b59a..4214148 100644 (file)
@@ -33,7 +33,7 @@
   Its content will be based mainly on wine/dlls/msacm32
   actually, for audio decompression only the following functions
   are needed:
+  
   acmStreamOpen ( takes formats of src and dest, returns stream handle )
   acmStreamPrepareHeader ( takes stream handler and info on data )
   acmStreamConvert ( the same as PrepareHeader )
   acmStreamClose
   acmStreamSize
   maybe acmStreamReset
-  In future I'll also add functions for format enumeration,
+  
+  In future I'll also add functions for format enumeration, 
   but not right now.
 
   Modified for use with MPlayer, detailed CVS changelog at
   http://www.mplayerhq.hu/cgi-bin/cvsweb.cgi/main/
+  
 ***************************************************************************/
 #include "config.h"
 
@@ -82,30 +82,30 @@ static inline PWINE_ACMSTREAM ACM_GetStream(HACMSTREAM has)
  *           acmDriverAddA (MSACM32.2)
  */
 MMRESULT WINAPI acmDriverAddA(PHACMDRIVERID phadid, HINSTANCE hinstModule,
-                  LPARAM lParam, DWORD dwPriority, DWORD fdwAdd)
+                             LPARAM lParam, DWORD dwPriority, DWORD fdwAdd)
 {
     if (!phadid)
-    return MMSYSERR_INVALPARAM;
+       return MMSYSERR_INVALPARAM;
+    
     /* Check if any unknown flags */
-    if (fdwAdd &
-    ~(ACM_DRIVERADDF_FUNCTION|ACM_DRIVERADDF_NOTIFYHWND|
-      ACM_DRIVERADDF_GLOBAL))
-    return MMSYSERR_INVALFLAG;
+    if (fdwAdd & 
+       ~(ACM_DRIVERADDF_FUNCTION|ACM_DRIVERADDF_NOTIFYHWND|
+         ACM_DRIVERADDF_GLOBAL))
+       return MMSYSERR_INVALFLAG;
+    
     /* Check if any incompatible flags */
-    if ((fdwAdd & ACM_DRIVERADDF_FUNCTION) &&
-    (fdwAdd & ACM_DRIVERADDF_NOTIFYHWND))
-    return MMSYSERR_INVALFLAG;
-    /* FIXME: in fact, should GetModuleFileName(hinstModule) and do a
+    if ((fdwAdd & ACM_DRIVERADDF_FUNCTION) && 
+       (fdwAdd & ACM_DRIVERADDF_NOTIFYHWND))
+       return MMSYSERR_INVALFLAG;
+    
+    /* FIXME: in fact, should GetModuleFileName(hinstModule) and do a 
      * LoadDriver on it, to be sure we can call SendDriverMessage on the
      * hDrvr handle.
      */
     *phadid = (HACMDRIVERID) MSACM_RegisterDriver(NULL, 0, hinstModule);
+    
     /* FIXME: lParam, dwPriority and fdwAdd ignored */
+    
     return MMSYSERR_NOERROR;
 }
 
@@ -116,26 +116,26 @@ MMRESULT WINAPI acmDriverClose(HACMDRIVER had, DWORD fdwClose)
 {
     PWINE_ACMDRIVER  p;
     PWINE_ACMDRIVER* tp;
+    
     if (fdwClose)
-    return MMSYSERR_INVALFLAG;
+       return MMSYSERR_INVALFLAG;
+    
     p = MSACM_GetDriver(had);
     if (!p)
-    return MMSYSERR_INVALHANDLE;
+       return MMSYSERR_INVALHANDLE;
 
     for (tp = &(p->obj.pACMDriverID->pACMDriverList); *tp; *tp = (*tp)->pNextACMDriver) {
-    if (*tp == p) {
-        *tp = (*tp)->pNextACMDriver;
-        break;
+       if (*tp == p) {
+           *tp = (*tp)->pNextACMDriver;
+           break;
+       }
     }
-    }
+    
     if (p->hDrvr && !p->obj.pACMDriverID->pACMDriverList)
-    CloseDriver(p->hDrvr);
+       CloseDriver(p->hDrvr);
+    
     HeapFree(MSACM_hHeap, 0, p);
+    
     return MMSYSERR_NOERROR;
 }
 
@@ -144,28 +144,28 @@ MMRESULT WINAPI acmDriverClose(HACMDRIVER had, DWORD fdwClose)
  */
 MMRESULT WINAPI acmDriverEnum(ACMDRIVERENUMCB fnCallback, DWORD dwInstance, DWORD fdwEnum)
 {
-    PWINE_ACMDRIVERID    p;
-    DWORD        fdwSupport;
+    PWINE_ACMDRIVERID  p;
+    DWORD              fdwSupport;
 
     if (!fnCallback) {
-    return MMSYSERR_INVALPARAM;
+       return MMSYSERR_INVALPARAM;
     }
+    
     if (fdwEnum && ~(ACM_DRIVERENUMF_NOLOCAL|ACM_DRIVERENUMF_DISABLED)) {
-    return MMSYSERR_INVALFLAG;
+       return MMSYSERR_INVALFLAG;
     }
+    
     for (p = MSACM_pFirstACMDriverID; p; p = p->pNextACMDriverID) {
-    fdwSupport = ACMDRIVERDETAILS_SUPPORTF_CODEC;
-    if (!p->bEnabled) {
-        if (fdwEnum & ACM_DRIVERENUMF_DISABLED)
-        fdwSupport |= ACMDRIVERDETAILS_SUPPORTF_DISABLED;
-        else
-        continue;
-    }
-    (*fnCallback)((HACMDRIVERID) p, dwInstance, fdwSupport);
+       fdwSupport = ACMDRIVERDETAILS_SUPPORTF_CODEC;
+       if (!p->bEnabled) {
+           if (fdwEnum & ACM_DRIVERENUMF_DISABLED)
+               fdwSupport |= ACMDRIVERDETAILS_SUPPORTF_DISABLED;
+           else
+               continue;
+       }
+       (*fnCallback)((HACMDRIVERID) p, dwInstance, fdwSupport);
     }
+    
     return MMSYSERR_NOERROR;
 }
 
@@ -175,19 +175,19 @@ MMRESULT WINAPI acmDriverEnum(ACMDRIVERENUMCB fnCallback, DWORD dwInstance, DWOR
 MMRESULT WINAPI acmDriverID(HACMOBJ hao, PHACMDRIVERID phadid, DWORD fdwDriverID)
 {
     PWINE_ACMOBJ pao;
+    
     pao = MSACM_GetObj(hao);
     if (!pao)
-    return MMSYSERR_INVALHANDLE;
+       return MMSYSERR_INVALHANDLE;
+    
     if (!phadid)
-    return MMSYSERR_INVALPARAM;
+       return MMSYSERR_INVALPARAM;
+    
     if (fdwDriverID)
-    return MMSYSERR_INVALFLAG;
+       return MMSYSERR_INVALFLAG;
+    
     *phadid = (HACMDRIVERID) pao->pACMDriverID;
+    
     return MMSYSERR_NOERROR;
 }
 
@@ -200,13 +200,13 @@ LRESULT WINAPI acmDriverMessage(HACMDRIVER had, UINT uMsg, LPARAM lParam1, LPARA
 {
     PWINE_ACMDRIVER pad = MSACM_GetDriver(had);
     if (!pad)
-    return MMSYSERR_INVALPARAM;
+       return MMSYSERR_INVALPARAM;
+    
     /* FIXME: Check if uMsg legal */
+    
     if (!SendDriverMessage(pad->hDrvr, uMsg, lParam1, lParam2))
-    return MMSYSERR_NOTSUPPORTED;
+       return MMSYSERR_NOTSUPPORTED;
+    
     return MMSYSERR_NOERROR;
 }
 
@@ -216,43 +216,43 @@ LRESULT WINAPI acmDriverMessage(HACMDRIVER had, UINT uMsg, LPARAM lParam1, LPARA
  */
 MMRESULT WINAPI acmDriverOpen(PHACMDRIVER phad, HACMDRIVERID hadid, DWORD fdwOpen)
 {
-    PWINE_ACMDRIVERID    padid;
-    PWINE_ACMDRIVER    pad;
-    ICOPEN        icopen;
-    HDRVR        hdrv;
+    PWINE_ACMDRIVERID  padid;
+    PWINE_ACMDRIVER    pad;
+    ICOPEN             icopen;
+    HDRVR              hdrv;
 
 
     TRACE("(%p, %x, %08lu)\n", phad, hadid, fdwOpen);
 
     if (!phad)
-    return MMSYSERR_INVALPARAM;
-    padid = MSACM_GetDriverID(hadid);
+       return MMSYSERR_INVALPARAM;
+    
+    padid = MSACM_GetDriverID(hadid); 
     if (!padid)
-    return MMSYSERR_INVALHANDLE;
+       return MMSYSERR_INVALHANDLE;
+    
     if (fdwOpen)
-    return MMSYSERR_INVALFLAG;
+       return MMSYSERR_INVALFLAG;
+    
     pad = (PWINE_ACMDRIVER) HeapAlloc(MSACM_hHeap, 0, sizeof(WINE_ACMDRIVER));
     if (!pad)
-    return MMSYSERR_NOMEM;
+       return MMSYSERR_NOMEM;
 
     pad->obj.pACMDriverID = padid;
-    icopen.fccType        = mmioFOURCC('a', 'u', 'd', 'c');
-    icopen.fccHandler        = (long)padid->pszFileName;
-    icopen.dwSize        = sizeof(ICOPEN);
-    icopen.dwFlags        = 0;
+    icopen.fccType             = mmioFOURCC('a', 'u', 'd', 'c');
+    icopen.fccHandler          = (long)padid->pszFileName;
+    icopen.dwSize              = sizeof(ICOPEN);
+    icopen.dwFlags             = 0;
 
     icopen.pV1Reserved = padid->pszFileName;
     if (!padid->hInstModule)
-    pad->hDrvr = OpenDriverA((long)&icopen);
+       pad->hDrvr = OpenDriverA((long)&icopen);
     else
-    pad->hDrvr = padid->hInstModule;
+       pad->hDrvr = padid->hInstModule;
+    
     if (!pad->hDrvr) {
-    HeapFree(MSACM_hHeap, 0, pad);
-    return MMSYSERR_ERROR;
+       HeapFree(MSACM_hHeap, 0, pad);
+       return MMSYSERR_ERROR;
     }
 
     pad->pfnDriverProc = GetProcAddress(pad->hDrvr, "DriverProc");
@@ -273,16 +273,16 @@ MMRESULT WINAPI acmDriverOpen(PHACMDRIVER phad, HACMDRIVERID hadid, DWORD fdwOpe
 MMRESULT WINAPI acmDriverRemove(HACMDRIVERID hadid, DWORD fdwRemove)
 {
     PWINE_ACMDRIVERID padid;
+    
     padid = MSACM_GetDriverID(hadid);
     if (!padid)
-    return MMSYSERR_INVALHANDLE;
+       return MMSYSERR_INVALHANDLE;
+    
     if (fdwRemove)
-    return MMSYSERR_INVALFLAG;
+       return MMSYSERR_INVALFLAG;
+    
     MSACM_UnregisterDriver(padid);
+    
     return MMSYSERR_NOERROR;
 }
 
@@ -295,18 +295,18 @@ PWINE_ACMDRIVERID MSACM_pFirstACMDriverID = NULL;
 PWINE_ACMDRIVERID MSACM_pLastACMDriverID = NULL;
 
 /***********************************************************************
- *           MSACM_RegisterDriver32()
+ *           MSACM_RegisterDriver32() 
  */
 PWINE_ACMDRIVERID MSACM_RegisterDriver(const char* pszFileName,
-                       WORD wFormatTag,
-                       HINSTANCE hinstModule)
+                                      WORD wFormatTag,
+                                      HINSTANCE hinstModule)
 {
     PWINE_ACMDRIVERID padid;
 
     TRACE("('%s', '%x', 0x%08x)\n", pszFileName, wFormatTag, hinstModule);
 
 #ifndef WIN32_LOADER
-    MSACM_hHeap = GetProcessHeap();
+       MSACM_hHeap = GetProcessHeap();
 #endif
     padid = (PWINE_ACMDRIVERID) HeapAlloc(MSACM_hHeap, 0, sizeof(WINE_ACMDRIVERID));
     padid->pszFileName = (char*)malloc(strlen(pszFileName)+1);
@@ -319,11 +319,11 @@ PWINE_ACMDRIVERID MSACM_RegisterDriver(const char* pszFileName,
     padid->pNextACMDriverID = NULL;
     padid->pPrevACMDriverID = MSACM_pLastACMDriverID;
     if (MSACM_pLastACMDriverID)
-    MSACM_pLastACMDriverID->pNextACMDriverID = padid;
+       MSACM_pLastACMDriverID->pNextACMDriverID = padid;
     MSACM_pLastACMDriverID = padid;
     if (!MSACM_pFirstACMDriverID)
-    MSACM_pFirstACMDriverID = padid;
+       MSACM_pFirstACMDriverID = padid;
+    
     return padid;
 }
 
@@ -334,27 +334,27 @@ PWINE_ACMDRIVERID MSACM_RegisterDriver(const char* pszFileName,
 PWINE_ACMDRIVERID MSACM_UnregisterDriver(PWINE_ACMDRIVERID p)
 {
     PWINE_ACMDRIVERID pNextACMDriverID;
+    
     while (p->pACMDriverList)
-    acmDriverClose((HACMDRIVER) p->pACMDriverList, 0);
+       acmDriverClose((HACMDRIVER) p->pACMDriverList, 0);
+    
     if (p->pszFileName)
-    free(p->pszFileName);
+       free(p->pszFileName);
+    
     if (p == MSACM_pFirstACMDriverID)
-    MSACM_pFirstACMDriverID = p->pNextACMDriverID;
+       MSACM_pFirstACMDriverID = p->pNextACMDriverID;
     if (p == MSACM_pLastACMDriverID)
-    MSACM_pLastACMDriverID = p->pPrevACMDriverID;
+       MSACM_pLastACMDriverID = p->pPrevACMDriverID;
 
     if (p->pPrevACMDriverID)
-    p->pPrevACMDriverID->pNextACMDriverID = p->pNextACMDriverID;
+       p->pPrevACMDriverID->pNextACMDriverID = p->pNextACMDriverID;
     if (p->pNextACMDriverID)
-    p->pNextACMDriverID->pPrevACMDriverID = p->pPrevACMDriverID;
+       p->pNextACMDriverID->pPrevACMDriverID = p->pPrevACMDriverID;
+    
     pNextACMDriverID = p->pNextACMDriverID;
+    
     HeapFree(MSACM_hHeap, 0, p);
+    
     return pNextACMDriverID;
 }
 
@@ -371,7 +371,7 @@ void MSACM_UnregisterAllDrivers(void)
 }
 
 /***********************************************************************
- *           MSACM_GetDriverID32()
+ *           MSACM_GetDriverID32() 
  */
 PWINE_ACMDRIVERID MSACM_GetDriverID(HACMDRIVERID hDriverID)
 {
@@ -400,25 +400,25 @@ PWINE_ACMOBJ MSACM_GetObj(HACMOBJ hObj)
  *           acmStreamOpen (MSACM32.40)
  */
 MMRESULT WINAPI acmStreamOpen(PHACMSTREAM phas, HACMDRIVER had, PWAVEFORMATEX pwfxSrc,
-                  PWAVEFORMATEX pwfxDst, PWAVEFILTER pwfltr, DWORD dwCallback,
-                  DWORD dwInstance, DWORD fdwOpen)
+                             PWAVEFORMATEX pwfxDst, PWAVEFILTER pwfltr, DWORD dwCallback,
+                             DWORD dwInstance, DWORD fdwOpen)
 {
-    PWINE_ACMSTREAM    was;
-    PWINE_ACMDRIVER    wad;
-    MMRESULT        ret;
-    int            wfxSrcSize;
-    int            wfxDstSize;
+    PWINE_ACMSTREAM    was;
+    PWINE_ACMDRIVER    wad;
+    MMRESULT           ret;
+    int                        wfxSrcSize;
+    int                        wfxDstSize;
+    
     TRACE("(%p, 0x%08x, %p, %p, %p, %ld, %ld, %ld)\n",
-      phas, had, pwfxSrc, pwfxDst, pwfltr, dwCallback, dwInstance, fdwOpen);
+         phas, had, pwfxSrc, pwfxDst, pwfltr, dwCallback, dwInstance, fdwOpen);
 
-    TRACE("src [wFormatTag=%u, nChannels=%u, nSamplesPerSec=%lu, nAvgBytesPerSec=%lu, nBlockAlign=%u, wBitsPerSample=%u, cbSize=%u]\n",
-      pwfxSrc->wFormatTag, pwfxSrc->nChannels, pwfxSrc->nSamplesPerSec, pwfxSrc->nAvgBytesPerSec,
-      pwfxSrc->nBlockAlign, pwfxSrc->wBitsPerSample, pwfxSrc->cbSize);
+    TRACE("src [wFormatTag=%u, nChannels=%u, nSamplesPerSec=%lu, nAvgBytesPerSec=%lu, nBlockAlign=%u, wBitsPerSample=%u, cbSize=%u]\n", 
+         pwfxSrc->wFormatTag, pwfxSrc->nChannels, pwfxSrc->nSamplesPerSec, pwfxSrc->nAvgBytesPerSec, 
+         pwfxSrc->nBlockAlign, pwfxSrc->wBitsPerSample, pwfxSrc->cbSize);
 
-    TRACE("dst [wFormatTag=%u, nChannels=%u, nSamplesPerSec=%lu, nAvgBytesPerSec=%lu, nBlockAlign=%u, wBitsPerSample=%u, cbSize=%u]\n",
-      pwfxDst->wFormatTag, pwfxDst->nChannels, pwfxDst->nSamplesPerSec, pwfxDst->nAvgBytesPerSec,
-      pwfxDst->nBlockAlign, pwfxDst->wBitsPerSample, pwfxDst->cbSize);
+    TRACE("dst [wFormatTag=%u, nChannels=%u, nSamplesPerSec=%lu, nAvgBytesPerSec=%lu, nBlockAlign=%u, wBitsPerSample=%u, cbSize=%u]\n", 
+         pwfxDst->wFormatTag, pwfxDst->nChannels, pwfxDst->nSamplesPerSec, pwfxDst->nAvgBytesPerSec, 
+         pwfxDst->nBlockAlign, pwfxDst->wBitsPerSample, pwfxDst->cbSize);
 
 #define SIZEOF_WFX(wfx) (sizeof(WAVEFORMATEX) + ((wfx->wFormatTag == WAVE_FORMAT_PCM) ? 0 : wfx->cbSize))
     wfxSrcSize = SIZEOF_WFX(pwfxSrc);
@@ -427,7 +427,7 @@ MMRESULT WINAPI acmStreamOpen(PHACMSTREAM phas, HACMDRIVER had, PWAVEFORMATEX pw
 
     was = (PWINE_ACMSTREAM) HeapAlloc(MSACM_hHeap, 0, sizeof(*was) + wfxSrcSize + wfxDstSize + ((pwfltr) ? sizeof(WAVEFILTER) : 0));
     if (was == NULL)
-    return MMSYSERR_NOMEM;
+       return MMSYSERR_NOMEM;
     was->drvInst.cbStruct = sizeof(was->drvInst);
     was->drvInst.pwfxSrc = (PWAVEFORMATEX)((LPSTR)was + sizeof(*was));
     memcpy(was->drvInst.pwfxSrc, pwfxSrc, wfxSrcSize);
@@ -437,106 +437,106 @@ MMRESULT WINAPI acmStreamOpen(PHACMSTREAM phas, HACMDRIVER had, PWAVEFORMATEX pw
     was->drvInst.pwfxDst = (PWAVEFORMATEX)((LPSTR)was + sizeof(*was) + wfxSrcSize);
     memcpy(was->drvInst.pwfxDst, pwfxDst, wfxDstSize);
     if (pwfltr) {
-    was->drvInst.pwfltr = (PWAVEFILTER)((LPSTR)was + sizeof(*was) + wfxSrcSize + wfxDstSize);
-    memcpy(was->drvInst.pwfltr, pwfltr, sizeof(WAVEFILTER));
+       was->drvInst.pwfltr = (PWAVEFILTER)((LPSTR)was + sizeof(*was) + wfxSrcSize + wfxDstSize);
+       memcpy(was->drvInst.pwfltr, pwfltr, sizeof(WAVEFILTER));
     } else {
-    was->drvInst.pwfltr = NULL;
+       was->drvInst.pwfltr = NULL;
     }
-    was->drvInst.dwCallback = dwCallback;
+    was->drvInst.dwCallback = dwCallback;    
     was->drvInst.dwInstance = dwInstance;
     was->drvInst.fdwOpen = fdwOpen;
-    was->drvInst.fdwDriver = 0L;
-    was->drvInst.dwDriver = 0L;
+    was->drvInst.fdwDriver = 0L;  
+    was->drvInst.dwDriver = 0L;     
     was->drvInst.has = (HACMSTREAM)was;
-    if (had) {
-    if (!(wad = MSACM_GetDriver(had))) {
-        ret = MMSYSERR_INVALPARAM;
-        goto errCleanUp;
-    }
     
-    was->obj.pACMDriverID = wad->obj.pACMDriverID;
-    was->pDrv = wad;
-    was->hAcmDriver = 0; /* not to close it in acmStreamClose */
-
-    ret = SendDriverMessage(wad->hDrvr, ACMDM_STREAM_OPEN, (DWORD)&was->drvInst, 0L);
-    if (ret != MMSYSERR_NOERROR)
-        goto errCleanUp;
+    if (had) {
+       if (!(wad = MSACM_GetDriver(had))) {
+           ret = MMSYSERR_INVALPARAM;
+           goto errCleanUp;
+       }
+       
+       was->obj.pACMDriverID = wad->obj.pACMDriverID;
+       was->pDrv = wad;
+       was->hAcmDriver = 0; /* not to close it in acmStreamClose */
+
+       ret = SendDriverMessage(wad->hDrvr, ACMDM_STREAM_OPEN, (DWORD)&was->drvInst, 0L);
+       if (ret != MMSYSERR_NOERROR)
+           goto errCleanUp;
     } else {
-    PWINE_ACMDRIVERID wadi;
-    short drv_tag;
-    ret = ACMERR_NOTPOSSIBLE;
-/*    if(pwfxSrc->wFormatTag==1)//compression
-        drv_tag=pwfxDst->wFormatTag;
-        else
-        if(pwfxDst->wFormatTag==1)//decompression
-        drv_tag=pwfxSrc->wFormatTag;
-        else
-        goto errCleanUp;
-
-        ret=acmDriverOpen2(drv_tag);
-        if (ret == MMSYSERR_NOERROR) {
-        if ((wad = MSACM_GetDriver(had)) != 0) {
-            was->obj.pACMDriverID = wad->obj.pACMDriverID;
-            was->pDrv = wad;
-            was->hAcmDriver = had;
-        
-            ret = SendDriverMessage(wad->hDrvr, ACMDM_STREAM_OPEN, (DWORD)&was->drvInst, 0L);
-            if (ret == MMSYSERR_NOERROR) {
-            if (fdwOpen & ACM_STREAMOPENF_QUERY) {
-                acmDriverClose(had, 0L);
-            }
-            break;
-            }
-        }
-        acmDriverClose(had, 0L);*/
-    //if(MSACM_pFirstACMDriverID==NULL)
-    //    MSACM_RegisterAllDrivers();
-    
-    for (wadi = MSACM_pFirstACMDriverID; wadi; wadi = wadi->pNextACMDriverID)
-    {
-        /* Check Format */
-        if ((int)wadi->wFormatTag != (int)pwfxSrc->wFormatTag) continue;
-
-        ret = acmDriverOpen(&had, (HACMDRIVERID)wadi, 0L);
-        if (ret == MMSYSERR_NOERROR) {
-        if ((wad = MSACM_GetDriver(had)) != 0) {
-            was->obj.pACMDriverID = wad->obj.pACMDriverID;
-            was->pDrv = wad;
-            was->hAcmDriver = had;
-        
-            ret = SendDriverMessage(wad->hDrvr, ACMDM_STREAM_OPEN, (DWORD)&was->drvInst, 0L);
-            //lhacm - crash printf("RETOPEN %d\n", ret);
+       PWINE_ACMDRIVERID wadi;
+       short drv_tag;
+       ret = ACMERR_NOTPOSSIBLE;
+/*     if(pwfxSrc->wFormatTag==1)//compression
+           drv_tag=pwfxDst->wFormatTag;
+           else
+           if(pwfxDst->wFormatTag==1)//decompression
+               drv_tag=pwfxSrc->wFormatTag;
+               else
+               goto errCleanUp;
+
+           ret=acmDriverOpen2(drv_tag); 
+           if (ret == MMSYSERR_NOERROR) {
+               if ((wad = MSACM_GetDriver(had)) != 0) {
+                   was->obj.pACMDriverID = wad->obj.pACMDriverID;
+                   was->pDrv = wad;
+                   was->hAcmDriver = had;
+                   
+                   ret = SendDriverMessage(wad->hDrvr, ACMDM_STREAM_OPEN, (DWORD)&was->drvInst, 0L);
+                   if (ret == MMSYSERR_NOERROR) {
+                       if (fdwOpen & ACM_STREAMOPENF_QUERY) {
+                           acmDriverClose(had, 0L);
+                       }
+                       break;
+                   }
+               }
+               acmDriverClose(had, 0L);*/
+       //if(MSACM_pFirstACMDriverID==NULL)
+       //    MSACM_RegisterAllDrivers();
+       
+       for (wadi = MSACM_pFirstACMDriverID; wadi; wadi = wadi->pNextACMDriverID)
+       {
+           /* Check Format */
+           if ((int)wadi->wFormatTag != (int)pwfxSrc->wFormatTag) continue;
+
+           ret = acmDriverOpen(&had, (HACMDRIVERID)wadi, 0L);
+           if (ret == MMSYSERR_NOERROR) {
+               if ((wad = MSACM_GetDriver(had)) != 0) {
+                   was->obj.pACMDriverID = wad->obj.pACMDriverID;
+                   was->pDrv = wad;
+                   was->hAcmDriver = had;
+                   
+                   ret = SendDriverMessage(wad->hDrvr, ACMDM_STREAM_OPEN, (DWORD)&was->drvInst, 0L);
+                   //lhacm - crash printf("RETOPEN %d\n", ret);
                     //ret = 0;
-            if (ret == MMSYSERR_NOERROR) {
-            if (fdwOpen & ACM_STREAMOPENF_QUERY) {
-                acmDriverClose(had, 0L);
-            }
-            break;
-            }
-        }
-        // no match, close this acm driver and try next one
-        acmDriverClose(had, 0L);
-        }
-    }
-    if (ret != MMSYSERR_NOERROR) {
-        ret = ACMERR_NOTPOSSIBLE;
-        goto errCleanUp;
-    }
+                   if (ret == MMSYSERR_NOERROR) {
+                       if (fdwOpen & ACM_STREAMOPENF_QUERY) {
+                           acmDriverClose(had, 0L);
+                       }
+                       break;
+                   }
+               }
+               // no match, close this acm driver and try next one 
+               acmDriverClose(had, 0L);
+           }
+       }
+       if (ret != MMSYSERR_NOERROR) {
+           ret = ACMERR_NOTPOSSIBLE;
+           goto errCleanUp;
+       }
     }
     ret = MMSYSERR_NOERROR;
     if (!(fdwOpen & ACM_STREAMOPENF_QUERY)) {
-    if (phas)
-        *phas = (HACMSTREAM)was;
-    TRACE("=> (%d)\n", ret);
+       if (phas)
+           *phas = (HACMSTREAM)was;
+       TRACE("=> (%d)\n", ret);
 #ifdef WIN32_LOADER
         CodecAlloc();
 #endif
-    return ret;
+       return ret;
     }
-errCleanUp:        
+errCleanUp:            
     if (phas)
-    *phas = (HACMSTREAM)0;
+       *phas = (HACMSTREAM)0;
     HeapFree(MSACM_hHeap, 0, was);
     TRACE("=> (%d)\n", ret);
     return ret;
@@ -545,19 +545,19 @@ errCleanUp:
 
 MMRESULT WINAPI acmStreamClose(HACMSTREAM has, DWORD fdwClose)
 {
-    PWINE_ACMSTREAM    was;
-    MMRESULT        ret;
-        
+    PWINE_ACMSTREAM    was;
+    MMRESULT           ret;
+               
     TRACE("(0x%08x, %ld)\n", has, fdwClose);
+    
     if ((was = ACM_GetStream(has)) == NULL) {
-    return MMSYSERR_INVALHANDLE;
+       return MMSYSERR_INVALHANDLE;
     }
     ret = SendDriverMessage(was->pDrv->hDrvr, ACMDM_STREAM_CLOSE, (DWORD)&was->drvInst, 0);
     if (ret == MMSYSERR_NOERROR) {
-    if (was->hAcmDriver)
-        acmDriverClose(was->hAcmDriver, 0L);    
-    HeapFree(MSACM_hHeap, 0, was);
+       if (was->hAcmDriver)
+           acmDriverClose(was->hAcmDriver, 0L);        
+       HeapFree(MSACM_hHeap, 0, was);
 #ifdef WIN32_LOADER
         CodecRelease();
 #endif
@@ -569,22 +569,22 @@ MMRESULT WINAPI acmStreamClose(HACMSTREAM has, DWORD fdwClose)
 /***********************************************************************
  *           acmStreamConvert (MSACM32.38)
  */
-MMRESULT WINAPI acmStreamConvert(HACMSTREAM has, PACMSTREAMHEADER pash,
-                 DWORD fdwConvert)
+MMRESULT WINAPI acmStreamConvert(HACMSTREAM has, PACMSTREAMHEADER pash, 
+                                DWORD fdwConvert)
 {
-    PWINE_ACMSTREAM    was;
-    MMRESULT        ret = MMSYSERR_NOERROR;
-    PACMDRVSTREAMHEADER    padsh;
+    PWINE_ACMSTREAM    was;
+    MMRESULT           ret = MMSYSERR_NOERROR;
+    PACMDRVSTREAMHEADER        padsh;
 
     TRACE("(0x%08x, %p, %ld)\n", has, pash, fdwConvert);
 
     if ((was = ACM_GetStream(has)) == NULL)
-    return MMSYSERR_INVALHANDLE;
+       return MMSYSERR_INVALHANDLE;
     if (!pash || pash->cbStruct < sizeof(ACMSTREAMHEADER))
-    return MMSYSERR_INVALPARAM;
+       return MMSYSERR_INVALPARAM;
 
     if (!(pash->fdwStatus & ACMSTREAMHEADER_STATUSF_PREPARED))
-    return ACMERR_UNPREPARED;
+       return ACMERR_UNPREPARED;
 
     /* Note: the ACMSTREAMHEADER and ACMDRVSTREAMHEADER structs are of same
      * size. some fields are private to msacm internals, and are exposed
@@ -594,17 +594,17 @@ MMRESULT WINAPI acmStreamConvert(HACMSTREAM has, PACMSTREAMHEADER pash,
 
     /* check that pointers have not been modified */
     if (padsh->pbPreparedSrc != padsh->pbSrc ||
-    padsh->cbPreparedSrcLength < padsh->cbSrcLength ||
-    padsh->pbPreparedDst != padsh->pbDst ||
-    padsh->cbPreparedDstLength < padsh->cbDstLength) {
-    return MMSYSERR_INVALPARAM;
-    }    
+       padsh->cbPreparedSrcLength < padsh->cbSrcLength ||
+       padsh->pbPreparedDst != padsh->pbDst ||
+       padsh->cbPreparedDstLength < padsh->cbDstLength) {
+       return MMSYSERR_INVALPARAM;
+    }  
 
     padsh->fdwConvert = fdwConvert;
 
     ret = SendDriverMessage(was->pDrv->hDrvr, ACMDM_STREAM_CONVERT, (DWORD)&was->drvInst, (DWORD)padsh);
     if (ret == MMSYSERR_NOERROR) {
-    padsh->fdwStatus |= ACMSTREAMHEADER_STATUSF_DONE;
+       padsh->fdwStatus |= ACMSTREAMHEADER_STATUSF_DONE;
     }
     TRACE("=> (%d)\n", ret);
     return ret;
@@ -614,24 +614,24 @@ MMRESULT WINAPI acmStreamConvert(HACMSTREAM has, PACMSTREAMHEADER pash,
 /***********************************************************************
  *           acmStreamPrepareHeader (MSACM32.41)
  */
-MMRESULT WINAPI acmStreamPrepareHeader(HACMSTREAM has, PACMSTREAMHEADER pash,
-                       DWORD fdwPrepare)
+MMRESULT WINAPI acmStreamPrepareHeader(HACMSTREAM has, PACMSTREAMHEADER pash, 
+                                      DWORD fdwPrepare)
 {
-    PWINE_ACMSTREAM    was;
-    MMRESULT        ret = MMSYSERR_NOERROR;
-    PACMDRVSTREAMHEADER    padsh;
+    PWINE_ACMSTREAM    was;
+    MMRESULT           ret = MMSYSERR_NOERROR;
+    PACMDRVSTREAMHEADER        padsh;
 
     TRACE("(0x%08x, %p, %ld)\n", has, pash, fdwPrepare);
+    
     if ((was = ACM_GetStream(has)) == NULL)
-    return MMSYSERR_INVALHANDLE;
+       return MMSYSERR_INVALHANDLE;
     if (!pash || pash->cbStruct < sizeof(ACMSTREAMHEADER))
-    return MMSYSERR_INVALPARAM;
+       return MMSYSERR_INVALPARAM;
     if (fdwPrepare)
-    ret = MMSYSERR_INVALFLAG;
+       ret = MMSYSERR_INVALFLAG;
 
     if (pash->fdwStatus & ACMSTREAMHEADER_STATUSF_DONE)
-    return MMSYSERR_NOERROR;
+       return MMSYSERR_NOERROR;
 
     /* Note: the ACMSTREAMHEADER and ACMDRVSTREAMHEADER structs are of same
      * size. some fields are private to msacm internals, and are exposed
@@ -652,22 +652,22 @@ MMRESULT WINAPI acmStreamPrepareHeader(HACMSTREAM has, PACMSTREAMHEADER pash,
 
     ret = SendDriverMessage(was->pDrv->hDrvr, ACMDM_STREAM_PREPARE, (DWORD)&was->drvInst, (DWORD)padsh);
     if (ret == MMSYSERR_NOERROR || ret == MMSYSERR_NOTSUPPORTED) {
-    ret = MMSYSERR_NOERROR;
-    padsh->fdwStatus &= ~(ACMSTREAMHEADER_STATUSF_DONE|ACMSTREAMHEADER_STATUSF_INQUEUE);
-    padsh->fdwStatus |= ACMSTREAMHEADER_STATUSF_PREPARED;
-    padsh->fdwPrepared = padsh->fdwStatus;
-    padsh->dwPrepared = 0;
-    padsh->pbPreparedSrc = padsh->pbSrc;
-    padsh->cbPreparedSrcLength = padsh->cbSrcLength;
-    padsh->pbPreparedDst = padsh->pbDst;
-    padsh->cbPreparedDstLength = padsh->cbDstLength;
+       ret = MMSYSERR_NOERROR;
+       padsh->fdwStatus &= ~(ACMSTREAMHEADER_STATUSF_DONE|ACMSTREAMHEADER_STATUSF_INQUEUE);
+       padsh->fdwStatus |= ACMSTREAMHEADER_STATUSF_PREPARED;
+       padsh->fdwPrepared = padsh->fdwStatus;
+       padsh->dwPrepared = 0;
+       padsh->pbPreparedSrc = padsh->pbSrc;
+       padsh->cbPreparedSrcLength = padsh->cbSrcLength;
+       padsh->pbPreparedDst = padsh->pbDst;
+       padsh->cbPreparedDstLength = padsh->cbDstLength;
     } else {
-    padsh->fdwPrepared = 0;
-    padsh->dwPrepared = 0;
-    padsh->pbPreparedSrc = 0;
-    padsh->cbPreparedSrcLength = 0;
-    padsh->pbPreparedDst = 0;
-    padsh->cbPreparedDstLength = 0;
+       padsh->fdwPrepared = 0;
+       padsh->dwPrepared = 0;
+       padsh->pbPreparedSrc = 0;
+       padsh->cbPreparedSrcLength = 0;
+       padsh->pbPreparedDst = 0;
+       padsh->cbPreparedDstLength = 0;
     }
     TRACE("=> (%d)\n", ret);
     return ret;
@@ -678,17 +678,17 @@ MMRESULT WINAPI acmStreamPrepareHeader(HACMSTREAM has, PACMSTREAMHEADER pash,
  */
 MMRESULT WINAPI acmStreamReset(HACMSTREAM has, DWORD fdwReset)
 {
-    PWINE_ACMSTREAM    was;
-    MMRESULT        ret = MMSYSERR_NOERROR;
+    PWINE_ACMSTREAM    was;
+    MMRESULT           ret = MMSYSERR_NOERROR;
 
     TRACE("(0x%08x, %ld)\n", has, fdwReset);
 
     if (fdwReset) {
-    ret = MMSYSERR_INVALFLAG;
+       ret = MMSYSERR_INVALFLAG;
     } else if ((was = ACM_GetStream(has)) == NULL) {
-    return MMSYSERR_INVALHANDLE;
+       return MMSYSERR_INVALHANDLE;
     } else if (was->drvInst.fdwOpen & ACM_STREAMOPENF_ASYNC) {
-    ret = SendDriverMessage(was->pDrv->hDrvr, ACMDM_STREAM_RESET, (DWORD)&was->drvInst, 0);
+       ret = SendDriverMessage(was->pDrv->hDrvr, ACMDM_STREAM_RESET, (DWORD)&was->drvInst, 0);
     }
     TRACE("=> (%d)\n", ret);
     return ret;
@@ -697,50 +697,50 @@ MMRESULT WINAPI acmStreamReset(HACMSTREAM has, DWORD fdwReset)
 /***********************************************************************
  *           acmStreamSize (MSACM32.43)
  */
-MMRESULT WINAPI acmStreamSize(HACMSTREAM has, DWORD cbInput,
-                  LPDWORD pdwOutputBytes, DWORD fdwSize)
+MMRESULT WINAPI acmStreamSize(HACMSTREAM has, DWORD cbInput, 
+                             LPDWORD pdwOutputBytes, DWORD fdwSize)
 {
-    PWINE_ACMSTREAM    was;
-    ACMDRVSTREAMSIZE    adss;
-    MMRESULT        ret;
+    PWINE_ACMSTREAM    was;
+    ACMDRVSTREAMSIZE   adss;
+    MMRESULT           ret;
+    
     TRACE("(0x%08x, %ld, %p, %ld)\n", has, cbInput, pdwOutputBytes, fdwSize);
+    
     if ((was = ACM_GetStream(has)) == NULL) {
-    return MMSYSERR_INVALHANDLE;
+       return MMSYSERR_INVALHANDLE;
     }
     if ((fdwSize & ~ACM_STREAMSIZEF_QUERYMASK) != 0) {
-    return MMSYSERR_INVALFLAG;
+       return MMSYSERR_INVALFLAG;
     }
 
     *pdwOutputBytes = 0L;
+    
     switch (fdwSize & ACM_STREAMSIZEF_QUERYMASK) {
     case ACM_STREAMSIZEF_DESTINATION:
-    adss.cbDstLength = cbInput;
-    adss.cbSrcLength = 0;
-    break;
+       adss.cbDstLength = cbInput;
+       adss.cbSrcLength = 0;
+       break;
     case ACM_STREAMSIZEF_SOURCE:
-    adss.cbSrcLength = cbInput;
-    adss.cbDstLength = 0;
-    break;
-    default:    
-    return MMSYSERR_INVALFLAG;
+       adss.cbSrcLength = cbInput;
+       adss.cbDstLength = 0;
+       break;
+    default:   
+       return MMSYSERR_INVALFLAG;
     }
+    
     adss.cbStruct = sizeof(adss);
     adss.fdwSize = fdwSize;
-    ret = SendDriverMessage(was->pDrv->hDrvr, ACMDM_STREAM_SIZE,
-                (DWORD)&was->drvInst, (DWORD)&adss);
+    ret = SendDriverMessage(was->pDrv->hDrvr, ACMDM_STREAM_SIZE, 
+                           (DWORD)&was->drvInst, (DWORD)&adss);
     if (ret == MMSYSERR_NOERROR) {
-    switch (fdwSize & ACM_STREAMSIZEF_QUERYMASK) {
-    case ACM_STREAMSIZEF_DESTINATION:
-        *pdwOutputBytes = adss.cbSrcLength;
-        break;
-    case ACM_STREAMSIZEF_SOURCE:
-        *pdwOutputBytes = adss.cbDstLength;
-        break;
-    }
+       switch (fdwSize & ACM_STREAMSIZEF_QUERYMASK) {
+       case ACM_STREAMSIZEF_DESTINATION:
+           *pdwOutputBytes = adss.cbSrcLength;
+           break;
+       case ACM_STREAMSIZEF_SOURCE:
+           *pdwOutputBytes = adss.cbDstLength;
+           break;
+       }
     }
     TRACE("=> (%d) [%lu]\n", ret, *pdwOutputBytes);
     return ret;
@@ -749,22 +749,22 @@ MMRESULT WINAPI acmStreamSize(HACMSTREAM has, DWORD cbInput,
 /***********************************************************************
  *           acmStreamUnprepareHeader (MSACM32.44)
  */
-MMRESULT WINAPI acmStreamUnprepareHeader(HACMSTREAM has, PACMSTREAMHEADER pash,
-                     DWORD fdwUnprepare)
+MMRESULT WINAPI acmStreamUnprepareHeader(HACMSTREAM has, PACMSTREAMHEADER pash, 
+                                        DWORD fdwUnprepare)
 {
-    PWINE_ACMSTREAM    was;
-    MMRESULT        ret = MMSYSERR_NOERROR;
-    PACMDRVSTREAMHEADER    padsh;
+    PWINE_ACMSTREAM    was;
+    MMRESULT           ret = MMSYSERR_NOERROR;
+    PACMDRVSTREAMHEADER        padsh;
 
     TRACE("(0x%08x, %p, %ld)\n", has, pash, fdwUnprepare);
+    
     if ((was = ACM_GetStream(has)) == NULL)
-    return MMSYSERR_INVALHANDLE;
+       return MMSYSERR_INVALHANDLE;
     if (!pash || pash->cbStruct < sizeof(ACMSTREAMHEADER))
-    return MMSYSERR_INVALPARAM;
+       return MMSYSERR_INVALPARAM;
 
     if (!(pash->fdwStatus & ACMSTREAMHEADER_STATUSF_PREPARED))
-    return ACMERR_UNPREPARED;
+       return ACMERR_UNPREPARED;
 
     /* Note: the ACMSTREAMHEADER and ACMDRVSTREAMHEADER structs are of same
      * size. some fields are private to msacm internals, and are exposed
@@ -774,18 +774,18 @@ MMRESULT WINAPI acmStreamUnprepareHeader(HACMSTREAM has, PACMSTREAMHEADER pash,
 
     /* check that pointers have not been modified */
     if (padsh->pbPreparedSrc != padsh->pbSrc ||
-    padsh->cbPreparedSrcLength < padsh->cbSrcLength ||
-    padsh->pbPreparedDst != padsh->pbDst ||
-    padsh->cbPreparedDstLength < padsh->cbDstLength) {
-    return MMSYSERR_INVALPARAM;
-    }    
+       padsh->cbPreparedSrcLength < padsh->cbSrcLength ||
+       padsh->pbPreparedDst != padsh->pbDst ||
+       padsh->cbPreparedDstLength < padsh->cbDstLength) {
+       return MMSYSERR_INVALPARAM;
+    }  
 
     padsh->fdwConvert = fdwUnprepare;
 
     ret = SendDriverMessage(was->pDrv->hDrvr, ACMDM_STREAM_UNPREPARE, (DWORD)&was->drvInst, (DWORD)padsh);
     if (ret == MMSYSERR_NOERROR || ret == MMSYSERR_NOTSUPPORTED) {
-    ret = MMSYSERR_NOERROR;
-    padsh->fdwStatus &= ~(ACMSTREAMHEADER_STATUSF_DONE|ACMSTREAMHEADER_STATUSF_INQUEUE|ACMSTREAMHEADER_STATUSF_PREPARED);
+       ret = MMSYSERR_NOERROR;
+       padsh->fdwStatus &= ~(ACMSTREAMHEADER_STATUSF_DONE|ACMSTREAMHEADER_STATUSF_INQUEUE|ACMSTREAMHEADER_STATUSF_PREPARED);
     }
     TRACE("=> (%d)\n", ret);
     return ret;
index bdaaa18..a647235 100644 (file)
@@ -78,7 +78,7 @@ struct IClassFactory
 };
 
 long CoCreateInstance(GUID* rclsid, struct IUnknown* pUnkOuter,
-              long dwClsContext, const GUID* riid, void** ppv);
+                     long dwClsContext, const GUID* riid, void** ppv);
 
 #ifdef __cplusplus
 };
index 8e7c25f..24c8715 100644 (file)
@@ -97,9 +97,9 @@ void SetCodecPath(const char* path)
     if(needs_free)free(def_path);
     if(path==0)
     {
-    def_path=WIN32_PATH;
-    needs_free=0;
-    return;
+       def_path=WIN32_PATH;
+       needs_free=0;
+       return;
     }
     def_path = (char*) malloc(strlen(path)+1);
     strcpy(def_path, path);
@@ -109,7 +109,7 @@ void SetCodecPath(const char* path)
 static DWORD dwDrvID = 0;
 
 LRESULT WINAPI SendDriverMessage(HDRVR hDriver, UINT message,
-                 LPARAM lParam1, LPARAM lParam2)
+                                LPARAM lParam1, LPARAM lParam2)
 {
     DRVR* module=(DRVR*)hDriver;
     int result;
@@ -146,21 +146,21 @@ void DrvClose(HDRVR hDriver)
 {
     if (hDriver)
     {
-    DRVR* d = (DRVR*)hDriver;
-    if (d->hDriverModule)
-    {
+       DRVR* d = (DRVR*)hDriver;
+       if (d->hDriverModule)
+       {
 #ifdef WIN32_LOADER
-        Setup_FS_Segment();
-#endif
-        if (d->DriverProc)
-        {
-        SendDriverMessage(hDriver, DRV_CLOSE, 0, 0);
-        d->dwDriverID = 0;
-        SendDriverMessage(hDriver, DRV_FREE, 0, 0);
-        }
-        FreeLibrary(d->hDriverModule);
-    }
-    free(d);
+           Setup_FS_Segment();
+#endif
+           if (d->DriverProc)
+           {
+               SendDriverMessage(hDriver, DRV_CLOSE, 0, 0);
+               d->dwDriverID = 0;
+               SendDriverMessage(hDriver, DRV_FREE, 0, 0);
+           }
+           FreeLibrary(d->hDriverModule);
+       }
+       free(d);
     }
 #ifdef WIN32_LOADER
     CodecRelease();
@@ -184,7 +184,7 @@ HDRVR DrvOpen(LPARAM lParam2)
 
     hDriver = (NPDRVR) malloc(sizeof(DRVR));
     if (!hDriver)
-    return ((HDRVR) 0);
+       return ((HDRVR) 0);
     memset((void*)hDriver, 0, sizeof(DRVR));
 
 #ifdef WIN32_LOADER
@@ -195,18 +195,18 @@ HDRVR DrvOpen(LPARAM lParam2)
     hDriver->hDriverModule = LoadLibraryA(filename);
     if (!hDriver->hDriverModule)
     {
-    printf("Can't open library %s\n", filename);
-    DrvClose((HDRVR)hDriver);
-    return ((HDRVR) 0);
+       printf("Can't open library %s\n", filename);
+       DrvClose((HDRVR)hDriver);
+       return ((HDRVR) 0);
     }
 
     hDriver->DriverProc = (DRIVERPROC) GetProcAddress(hDriver->hDriverModule,
-                              "DriverProc");
+                                                     "DriverProc");
     if (!hDriver->DriverProc)
     {
-    printf("Library %s is not a valid VfW/ACM codec\n", filename);
-    DrvClose((HDRVR)hDriver);
-    return ((HDRVR) 0);
+       printf("Library %s is not a valid VfW/ACM codec\n", filename);
+       DrvClose((HDRVR)hDriver);
+       return ((HDRVR) 0);
     }
 
     TRACE("DriverProc == %X\n", hDriver->DriverProc);
index 81b0156..f7e369d 100644 (file)
@@ -5,7 +5,7 @@
  */
 
 #ifndef loader_driver_h
-#define    loader_driver_h
+#define        loader_driver_h
 
 #ifdef __cplusplus
 extern "C" {
index 959037d..2a41830 100644 (file)
@@ -132,10 +132,10 @@ INT WINAPI lstrlenW(LPCWSTR s)
 {
     int l;
     if(!s)
-    return 0;
+       return 0;
     l=0;
     while(s[l])
-    l++;
+       l++;
      return l;
 }
 LPSTR WINAPI lstrcpynWtoA(LPSTR dest, LPCWSTR src, INT count)
@@ -143,15 +143,15 @@ LPSTR WINAPI lstrcpynWtoA(LPSTR dest, LPCWSTR src, INT count)
     LPSTR result = dest;
     int moved=0;
     if((dest==0) || (src==0))
-    return 0;
+       return 0;
     while(moved<count)
     {
         *dest=*src;
-    moved++;
-    if(*src==0)
-        break;
-    src++;
-    dest++;
+       moved++;
+       if(*src==0)
+           break;
+       src++;
+       dest++;
     }
     return result;
 }
@@ -160,27 +160,27 @@ int wcsnicmp(const unsigned short* s1, const unsigned short* s2, int n)
 {
     /*
     if(s1==0)
-    return;
+       return;
     if(s2==0)
         return;
     */
     while(n>0)
     {
-    if (((*s1 | *s2) & 0xff00) || toupper((char)*s1) != toupper((char)*s2))
-    {
-
-        if(*s1<*s2)
-        return -1;
-        else
-        if(*s1>*s2)
-            return 1;
-        else
-            if(*s1==0)
-            return 0;
-    }
-    s1++;
-    s2++;
-    n--;
+       if (((*s1 | *s2) & 0xff00) || toupper((char)*s1) != toupper((char)*s2))
+       {
+
+           if(*s1<*s2)
+               return -1;
+           else
+               if(*s1>*s2)
+                   return 1;
+               else
+                   if(*s1==0)
+                       return 0;
+       }
+       s1++;
+       s2++;
+       n--;
     }
     return 0;
 }
@@ -188,7 +188,7 @@ int wcsnicmp(const unsigned short* s1, const unsigned short* s2, int n)
 WIN_BOOL WINAPI IsBadReadPtr(LPCVOID data, UINT size)
 {
     if(size==0)
-    return 0;
+       return 0;
     if(data==NULL)
         return 1;
     return 0;
@@ -205,11 +205,11 @@ LPWSTR HEAP_strdupAtoW(HANDLE heap, DWORD flags, LPCSTR string)
     int size, i;
     WCHAR* answer;
     if(string==0)
-    return 0;
+       return 0;
     size=strlen(string);
     answer = (WCHAR*) malloc(sizeof(WCHAR) * (size + 1));
     for(i=0; i<=size; i++)
-    answer[i]=(short)string[i];
+       answer[i]=(short)string[i];
     return answer;
 }
 LPSTR HEAP_strdupWtoA(HANDLE heap, DWORD flags, LPCWSTR string)
@@ -217,13 +217,13 @@ LPSTR HEAP_strdupWtoA(HANDLE heap, DWORD flags, LPCWSTR string)
     int size, i;
     char* answer;
     if(string==0)
-    return 0;
+       return 0;
     size=0;
     while(string[size])
        size++;
     answer = (char*) malloc(size + 2);
     for(i=0; i<=size; i++)
-    answer[i]=(char)string[i];
+       answer[i]=(char)string[i];
     return answer;
 }
 
@@ -249,7 +249,7 @@ LPVOID FILE_dommap( int unix_handle, LPVOID start,
     if (unix_handle == -1)
     {
 #ifdef MAP_ANON
-//    printf("Anonymous\n");
+//     printf("Anonymous\n");
         flags |= MAP_ANON;
 #else
         static int fdzero = -1;
@@ -258,18 +258,18 @@ LPVOID FILE_dommap( int unix_handle, LPVOID start,
         {
             if ((fdzero = open( "/dev/zero", O_RDONLY )) == -1)
             {
-            perror( "Cannot open /dev/zero for READ. Check permissions! error: " );
+               perror( "Cannot open /dev/zero for READ. Check permissions! error: " );
                 exit(1);
             }
         }
         fd = fdzero;
 #endif  /* MAP_ANON */
-    /* Linux EINVAL's on us if we don't pass MAP_PRIVATE to an anon mmap */
+       /* Linux EINVAL's on us if we don't pass MAP_PRIVATE to an anon mmap */
 #ifdef MAP_SHARED
-    flags &= ~MAP_SHARED;
+       flags &= ~MAP_SHARED;
 #endif
 #ifdef MAP_PRIVATE
-    flags |= MAP_PRIVATE;
+       flags |= MAP_PRIVATE;
 #endif
     }
     else fd = unix_handle;
@@ -279,9 +279,9 @@ LPVOID FILE_dommap( int unix_handle, LPVOID start,
     if ((ret = mmap( start, size_low, prot,
                      MAP_PRIVATE | MAP_FIXED, fd, offset_low )) != (LPVOID)-1)
     {
-//        printf("address %08x\n", *(int*)ret);
-//    printf("%x\n", ret);
-        return ret;
+//         printf("address %08x\n", *(int*)ret);
+//     printf("%x\n", ret);
+           return ret;
     }
 
 //    printf("mmap %d\n", errno);
@@ -296,10 +296,10 @@ LPVOID FILE_dommap( int unix_handle, LPVOID start,
     {
         /* We cannot fake shared write mappings */
 #ifdef MAP_SHARED
-    if (flags & MAP_SHARED) return ret;
+       if (flags & MAP_SHARED) return ret;
 #endif
 #ifdef MAP_PRIVATE
-    if (!(flags & MAP_PRIVATE)) return ret;
+       if (!(flags & MAP_PRIVATE)) return ret;
 #endif
     }
 /*    printf( "FILE_mmap: mmap failed (%d), faking it\n", errno );*/
@@ -308,13 +308,13 @@ LPVOID FILE_dommap( int unix_handle, LPVOID start,
                        PROT_READ | PROT_WRITE, flags );
     if (ret == (LPVOID)-1)
 //    {
-//    perror(
-     return ret;
+//     perror(
+        return ret;
     /* Now read in the file */
     if ((pos = lseek( fd, offset_low, SEEK_SET )) == -1)
     {
         FILE_munmap( ret, size_high, size_low );
-//    printf("lseek\n");
+//     printf("lseek\n");
         return (LPVOID)-1;
     }
     read( fd, ret, size_low );
@@ -349,21 +349,21 @@ static file_mapping* fm=0;
 
 
 
-#define    PAGE_NOACCESS        0x01
-#define    PAGE_READONLY        0x02
-#define    PAGE_READWRITE        0x04
-#define    PAGE_WRITECOPY        0x08
-#define    PAGE_EXECUTE        0x10
-#define    PAGE_EXECUTE_READ    0x20
-#define    PAGE_EXECUTE_READWRITE    0x40
-#define    PAGE_EXECUTE_WRITECOPY    0x80
-#define    PAGE_GUARD        0x100
-#define    PAGE_NOCACHE        0x200
+#define        PAGE_NOACCESS           0x01
+#define        PAGE_READONLY           0x02
+#define        PAGE_READWRITE          0x04
+#define        PAGE_WRITECOPY          0x08
+#define        PAGE_EXECUTE            0x10
+#define        PAGE_EXECUTE_READ       0x20
+#define        PAGE_EXECUTE_READWRITE  0x40
+#define        PAGE_EXECUTE_WRITECOPY  0x80
+#define        PAGE_GUARD              0x100
+#define        PAGE_NOCACHE            0x200
 
 HANDLE WINAPI CreateFileMappingA(HANDLE handle, LPSECURITY_ATTRIBUTES lpAttr,
-                 DWORD flProtect,
-                 DWORD dwMaxHigh, DWORD dwMaxLow,
-                 LPCSTR name)
+                                DWORD flProtect,
+                                DWORD dwMaxHigh, DWORD dwMaxLow,
+                                LPCSTR name)
 {
     int hFile = (int)handle;
     unsigned int len;
@@ -372,55 +372,55 @@ HANDLE WINAPI CreateFileMappingA(HANDLE handle, LPSECURITY_ATTRIBUTES lpAttr,
     int mmap_access=0;
     if(hFile<0)
     {
-    anon=1;
-    hFile=open("/dev/zero", O_RDWR);
-    if(hFile<0){
-            perror( "Cannot open /dev/zero for READ+WRITE. Check permissions! error: " );
-        return 0;
-    }
+       anon=1;
+       hFile=open("/dev/zero", O_RDWR);
+       if(hFile<0){
+           perror( "Cannot open /dev/zero for READ+WRITE. Check permissions! error: " );
+           return 0;
+       }
     }
     if(!anon)
     {
         len=lseek(hFile, 0, SEEK_END);
-    lseek(hFile, 0, SEEK_SET);
+       lseek(hFile, 0, SEEK_SET);
     }
     else len=dwMaxLow;
 
     if(flProtect & PAGE_READONLY)
-    mmap_access |=PROT_READ;
+       mmap_access |=PROT_READ;
     else
-    mmap_access |=PROT_READ|PROT_WRITE;
+       mmap_access |=PROT_READ|PROT_WRITE;
 
     answer=mmap(NULL, len, mmap_access, MAP_PRIVATE, hFile, 0);
     if(anon)
         close(hFile);
     if(answer!=(LPVOID)-1)
     {
-    if(fm==0)
-    {
-        fm = (file_mapping*) malloc(sizeof(file_mapping));
-        fm->prev=NULL;
-    }
-    else
-    {
-        fm->next = (file_mapping*) malloc(sizeof(file_mapping));
-        fm->next->prev=fm;
-        fm=fm->next;
-    }
-    fm->next=NULL;
-    fm->handle=answer;
-    if(name)
-    {
-        fm->name = (char*) malloc(strlen(name)+1);
-        strcpy(fm->name, name);
-    }
-    else
-        fm->name=NULL;
-    fm->mapping_size=len;
-
-    if(anon)
-        close(hFile);
-    return (HANDLE)answer;
+       if(fm==0)
+       {
+           fm = (file_mapping*) malloc(sizeof(file_mapping));
+           fm->prev=NULL;
+       }
+       else
+       {
+           fm->next = (file_mapping*) malloc(sizeof(file_mapping));
+           fm->next->prev=fm;
+           fm=fm->next;
+       }
+       fm->next=NULL;
+       fm->handle=answer;
+       if(name)
+       {
+           fm->name = (char*) malloc(strlen(name)+1);
+           strcpy(fm->name, name);
+       }
+       else
+           fm->name=NULL;
+       fm->mapping_size=len;
+
+       if(anon)
+           close(hFile);
+       return (HANDLE)answer;
     }
     return (HANDLE)0;
 }
@@ -429,21 +429,21 @@ WIN_BOOL WINAPI UnmapViewOfFile(LPVOID handle)
     file_mapping* p;
     int result;
     if(fm==0)
-    return 0;
+       return 0;
     for(p=fm; p; p=p->next)
     {
-    if(p->handle==handle)
-    {
-        result=munmap((void*)handle, p->mapping_size);
-        if(p->next)p->next->prev=p->prev;
-        if(p->prev)p->prev->next=p->next;
-        if(p->name)
-        free(p->name);
-        if(p==fm)
-        fm=p->prev;
-        free(p);
-        return result;
-    }
+       if(p->handle==handle)
+       {
+           result=munmap((void*)handle, p->mapping_size);
+           if(p->next)p->next->prev=p->prev;
+           if(p->prev)p->prev->next=p->next;
+           if(p->name)
+               free(p->name);
+           if(p==fm)
+               fm=p->prev;
+           free(p);
+           return result;
+       }
     }
     return 0;
 }
@@ -474,17 +474,17 @@ LPVOID WINAPI VirtualAlloc(LPVOID address, DWORD size, DWORD type,  DWORD protec
     fd=open("/dev/zero", O_RDWR);
     if(fd<0){
         perror( "Cannot open /dev/zero for READ+WRITE. Check permissions! error: " );
-    return NULL;
+       return NULL;
     }
 
     if (type&MEM_RESERVE && (unsigned)address&0xffff) {
-    size += (unsigned)address&0xffff;
-    address = (unsigned)address&~0xffff;
+       size += (unsigned)address&0xffff;
+       address = (unsigned)address&~0xffff;
     }
     pgsz = sysconf(_SC_PAGESIZE);
     if (type&MEM_COMMIT && (unsigned)address%pgsz) {
-    size += (unsigned)address%pgsz;
-    address -= (unsigned)address%pgsz;
+       size += (unsigned)address%pgsz;
+       address -= (unsigned)address%pgsz;
     }
 
     if (type&MEM_RESERVE && size<0x10000) size = 0x10000;
@@ -496,72 +496,72 @@ LPVOID WINAPI VirtualAlloc(LPVOID address, DWORD size, DWORD type,  DWORD protec
         virt_alloc* str=vm;
         while(str)
         {
-        if((unsigned)address>=(unsigned)str->address+str->mapping_size)
-        {
-        str=str->prev;
-        continue;
-        }
-        if((unsigned)address+size<=(unsigned)str->address)
-        {
-        str=str->prev;
-        continue;
-        }
-        if(str->state==0)
-        {
+           if((unsigned)address>=(unsigned)str->address+str->mapping_size)
+           {
+               str=str->prev;
+               continue;
+           }
+           if((unsigned)address+size<=(unsigned)str->address)
+           {
+               str=str->prev;
+               continue;
+           }
+           if(str->state==0)
+           {
 #warning FIXME
-        if(   ((unsigned)address >= (unsigned)str->address)
-           && ((unsigned)address+size<=(unsigned)str->address+str->mapping_size)
-           && (type & MEM_COMMIT))
-        {
-            close(fd);
-            return address; //returning previously reserved memory
-        }
-        //printf(" VirtualAlloc(...) does not commit or not entirely within reserved, and\n");
-        }
-        /*printf(" VirtualAlloc(...) (0x%08X, %u) overlaps with (0x%08X, %u, state=%d)\n",
-               (unsigned)address, size, (unsigned)str->address, str->mapping_size, str->state);*/
-        close(fd);
-        return NULL;
-    }
+               if(   ((unsigned)address >= (unsigned)str->address)
+                  && ((unsigned)address+size<=(unsigned)str->address+str->mapping_size)
+                  && (type & MEM_COMMIT))
+               {
+                   close(fd);
+                   return address; //returning previously reserved memory
+               }
+               //printf(" VirtualAlloc(...) does not commit or not entirely within reserved, and\n");
+           }
+           /*printf(" VirtualAlloc(...) (0x%08X, %u) overlaps with (0x%08X, %u, state=%d)\n",
+                  (unsigned)address, size, (unsigned)str->address, str->mapping_size, str->state);*/
+           close(fd);
+           return NULL;
+       }
     }
 
     answer=mmap(address, size, PROT_READ | PROT_WRITE | PROT_EXEC,
-        MAP_PRIVATE, fd, 0);
+               MAP_PRIVATE, fd, 0);
 //    answer=FILE_dommap(-1, address, 0, size, 0, 0,
-//    PROT_READ | PROT_WRITE | PROT_EXEC, MAP_PRIVATE);
+//     PROT_READ | PROT_WRITE | PROT_EXEC, MAP_PRIVATE);
     close(fd);
     if (answer != (void *)-1 && address && answer != address) {
-    /* It is dangerous to try mmap() with MAP_FIXED since it does not
-       always detect conflicts or non-allocation and chaos ensues after
-       a successful call but an overlapping or non-allocated region.  */
-    munmap(answer, size);
-    answer = (void *) -1;
-    errno = EINVAL;
-    //printf(" VirtualAlloc(...) cannot satisfy requested address but address=NULL would work.\n");
+       /* It is dangerous to try mmap() with MAP_FIXED since it does not
+          always detect conflicts or non-allocation and chaos ensues after
+          a successful call but an overlapping or non-allocated region.  */
+       munmap(answer, size);
+       answer = (void *) -1;
+       errno = EINVAL;
+       //printf(" VirtualAlloc(...) cannot satisfy requested address but address=NULL would work.\n");
     }
     if(answer==(void*)-1)
     {
-    /*printf(" VirtualAlloc(...) mmap(0x%08X, %u, ...) failed with errno=%d (\"%s\")\n",
-           (unsigned)address, size, errno, strerror(errno));*/
-    return NULL;
+       /*printf(" VirtualAlloc(...) mmap(0x%08X, %u, ...) failed with errno=%d (\"%s\")\n",
+              (unsigned)address, size, errno, strerror(errno));*/
+       return NULL;
     }
     else
     {
-    virt_alloc *new_vm = (virt_alloc*) malloc(sizeof(virt_alloc));
-    new_vm->mapping_size=size;
-    new_vm->address=(char*)answer;
+       virt_alloc *new_vm = (virt_alloc*) malloc(sizeof(virt_alloc));
+       new_vm->mapping_size=size;
+       new_vm->address=(char*)answer;
         new_vm->prev=vm;
-    if(type == MEM_RESERVE)
-        new_vm->state=0;
-    else
-        new_vm->state=1;
-    if(vm)
-        vm->next=new_vm;
-        vm=new_vm;
-    vm->next=0;
-    //if(va_size!=0)
-    //    printf("Multiple VirtualAlloc!\n");
-    //printf(" VirtualAlloc(...) provides (0x%08X, %u)\n", (unsigned)answer, size);
+       if(type == MEM_RESERVE)
+           new_vm->state=0;
+       else
+           new_vm->state=1;
+       if(vm)
+           vm->next=new_vm;
+       vm=new_vm;
+       vm->next=0;
+       //if(va_size!=0)
+       //    printf("Multiple VirtualAlloc!\n");
+       //printf(" VirtualAlloc(...) provides (0x%08X, %u)\n", (unsigned)answer, size);
         return answer;
     }
 }
@@ -574,18 +574,18 @@ WIN_BOOL WINAPI VirtualFree(LPVOID  address, SIZE_T dwSize, DWORD dwFreeType)//n
     //printf("VirtualFree(0x%08X, %d, 0x%08X)\n", (unsigned)address, dwSize, dwFreeType);
     while(str)
     {
-    if(address!=str->address)
-    {
-        str=str->prev;
-        continue;
-    }
-    //printf(" VirtualFree(...) munmap(0x%08X, %d)\n", (unsigned)str->address, str->mapping_size);
-    answer=munmap(str->address, str->mapping_size);
-    if(str->next)str->next->prev=str->prev;
-    if(str->prev)str->prev->next=str->next;
-    if(vm==str)vm=str->prev;
-    free(str);
-    return 0;
+       if(address!=str->address)
+       {
+           str=str->prev;
+           continue;
+       }
+       //printf(" VirtualFree(...) munmap(0x%08X, %d)\n", (unsigned)str->address, str->mapping_size);
+       answer=munmap(str->address, str->mapping_size);
+       if(str->next)str->next->prev=str->prev;
+       if(str->prev)str->prev->next=str->next;
+       if(vm==str)vm=str->prev;
+       free(str);
+       return 0;
     }
     return -1;
 }
@@ -595,31 +595,31 @@ INT WINAPI WideCharToMultiByte(UINT codepage, DWORD flags, LPCWSTR src,
 {
     int i;
     if(src==0)
-    return 0;
+       return 0;
     if ((srclen==-1)&&(dest==0)) return 0;
     if(srclen==-1){srclen=0; while(src[srclen++]);}
 //    for(i=0; i<srclen; i++)
-//    printf("%c", src[i]);
+//     printf("%c", src[i]);
 //    printf("\n");
     if(dest==0)
     {
     for(i=0; i<srclen; i++)
     {
-    src++;
-        if(*src==0)
-        return i+1;
+       src++;
+       if(*src==0)
+           return i+1;
     }
-    return srclen+1;
+       return srclen+1;
     }
     if(used_defch)
-    *used_defch=0;
+       *used_defch=0;
     for(i=0; i<min(srclen, destlen); i++)
     {
-    *dest=(char)*src;
-    dest++;
-    src++;
-    if(*src==0)
-        return i+1;
+       *dest=(char)*src;
+       dest++;
+       src++;
+       if(*src==0)
+           return i+1;
     }
     return min(srclen, destlen);
 }
@@ -632,15 +632,15 @@ HANDLE WINAPI OpenFileMappingA(DWORD access, WIN_BOOL prot, LPCSTR name)
 {
     file_mapping* p;
     if(fm==0)
-    return (HANDLE)0;
+       return (HANDLE)0;
     if(name==0)
-    return (HANDLE)0;
+       return (HANDLE)0;
     for(p=fm; p; p=p->prev)
     {
-    if(p->name==0)
-        continue;
-    if(strcmp(p->name, name)==0)
-        return (HANDLE)p->handle;
+       if(p->name==0)
+           continue;
+       if(strcmp(p->name, name)==0)
+           return (HANDLE)p->handle;
     }
     return 0;
 }
index d1060d1..668219f 100644 (file)
@@ -10,9 +10,9 @@
 #include "wine/windef.h"
 
 extern LPVOID FILE_dommap( int unix_handle, LPVOID start,
-               DWORD size_high, DWORD size_low,
-               DWORD offset_high, DWORD offset_low,
-               int prot, int flags );
+                          DWORD size_high, DWORD size_low,
+                          DWORD offset_high, DWORD offset_low,
+                          int prot, int flags );
 extern int FILE_munmap( LPVOID start, DWORD size_high, DWORD size_low );
 extern int wcsnicmp(const unsigned short* s1, const unsigned short* s2, int n);
 extern int __vprintf( const char *format, ... );
index 44ec008..a22af0a 100644 (file)
@@ -23,5 +23,5 @@
 
 int dbg_printf(const char *format, ...)
 {
-    return 0;
+       return 0;
 }
index 433a83a..2cfae68 100644 (file)
@@ -146,8 +146,8 @@ void Setup_FS_Segment(void)
     unsigned int ldt_desc = LDT_SEL(fs_ldt);
 
     __asm__ __volatile__(
-    "movl %0,%%eax; movw %%ax, %%fs" : : "r" (ldt_desc)
-    :"eax"
+       "movl %0,%%eax; movw %%ax, %%fs" : : "r" (ldt_desc)
+       :"eax"
     );
 }
 
@@ -157,28 +157,28 @@ void Setup_FS_Segment(void)
 /* XXX: why is this routine from libc redefined here? */
 /* NOTE: the redefined version ignores the count param, count is hardcoded as 16 */
 static int LDT_Modify( int func, struct modify_ldt_ldt_s *ptr,
-               unsigned long count )
+                      unsigned long count )
 {
     int res;
 #ifdef __PIC__
     __asm__ __volatile__( "pushl %%ebx\n\t"
-              "movl %2,%%ebx\n\t"
-              "int $0x80\n\t"
-              "popl %%ebx"
-              : "=a" (res)
-              : "0" (__NR_modify_ldt),
-              "r" (func),
-              "c" (ptr),
-              "d"(16)//sizeof(*ptr) from kernel point of view
-              :"esi"     );
+                         "movl %2,%%ebx\n\t"
+                         "int $0x80\n\t"
+                         "popl %%ebx"
+                         : "=a" (res)
+                         : "0" (__NR_modify_ldt),
+                         "r" (func),
+                         "c" (ptr),
+                         "d"(16)//sizeof(*ptr) from kernel point of view
+                         :"esi"     );
 #else
     __asm__ __volatile__("int $0x80"
-             : "=a" (res)
-             : "0" (__NR_modify_ldt),
-             "b" (func),
-             "c" (ptr),
-             "d"(16)
-             :"esi");
+                        : "=a" (res)
+                        : "0" (__NR_modify_ldt),
+                        "b" (func),
+                        "c" (ptr),
+                        "d"(16)
+                        :"esi");
 #endif  /* __PIC__ */
     if (res >= 0) return res;
     errno = -res;
@@ -191,15 +191,15 @@ static int LDT_Modify( int func, struct modify_ldt_ldt_s *ptr,
 static void LDT_EntryToBytes( unsigned long *buffer, const struct modify_ldt_ldt_s *content )
 {
     *buffer++ = ((content->base_addr & 0x0000ffff) << 16) |
-    (content->limit & 0x0ffff);
+       (content->limit & 0x0ffff);
     *buffer = (content->base_addr & 0xff000000) |
-    ((content->base_addr & 0x00ff0000)>>16) |
-    (content->limit & 0xf0000) |
-    (content->contents << 10) |
-    ((content->read_exec_only == 0) << 9) |
-    ((content->seg_32bit != 0) << 22) |
-    ((content->limit_in_pages != 0) << 23) |
-    0xf000;
+       ((content->base_addr & 0x00ff0000)>>16) |
+       (content->limit & 0xf0000) |
+       (content->contents << 10) |
+       ((content->read_exec_only == 0) << 9) |
+       ((content->seg_32bit != 0) << 22) |
+       ((content->limit_in_pages != 0) << 23) |
+       0xf000;
 }
 #endif
 
@@ -212,22 +212,22 @@ ldt_fs_t* Setup_LDT_Keeper(void)
     ldt_fs_t* ldt_fs = (ldt_fs_t*) malloc(sizeof(ldt_fs_t));
 
     if (!ldt_fs)
-    return NULL;
+       return NULL;
 
     ldt_fs->fd = open("/dev/zero", O_RDWR);
     if(ldt_fs->fd<0){
         perror( "Cannot open /dev/zero for READ+WRITE. Check permissions! error: ");
-    return NULL;
+       return NULL;
     }
     fs_seg=
     ldt_fs->fs_seg = mmap(NULL, getpagesize(), PROT_READ | PROT_WRITE, MAP_PRIVATE,
-              ldt_fs->fd, 0);
+                         ldt_fs->fd, 0);
     if (ldt_fs->fs_seg == (void*)-1)
     {
-    perror("ERROR: Couldn't allocate memory for fs segment");
+       perror("ERROR: Couldn't allocate memory for fs segment");
         close(ldt_fs->fd);
         free(ldt_fs);
-    return NULL;
+       return NULL;
     }
     *(void**)((char*)ldt_fs->fs_seg+0x18) = ldt_fs->fs_seg;
     memset(&array, 0, sizeof(array));
@@ -244,8 +244,8 @@ ldt_fs_t* Setup_LDT_Keeper(void)
     ret=modify_ldt(0x1, &array, sizeof(struct modify_ldt_ldt_s));
     if(ret<0)
     {
-    perror("install_fs");
-    printf("Couldn't install fs segment, expect segfault\n");
+       perror("install_fs");
+       printf("Couldn't install fs segment, expect segfault\n");
     }
 #endif /*linux*/
 
@@ -264,7 +264,7 @@ ldt_fs_t* Setup_LDT_Keeper(void)
         if (ret < 0)
         {
             perror("install_fs");
-        printf("Couldn't install fs segment, expect segfault\n");
+           printf("Couldn't install fs segment, expect segfault\n");
             printf("Did you reconfigure the kernel with \"options USER_LDT\"?\n");
         }
     }
@@ -272,18 +272,18 @@ ldt_fs_t* Setup_LDT_Keeper(void)
 
 #if defined(__svr4__)
     {
-    struct ssd ssd;
-    ssd.sel = LDT_SEL(TEB_SEL_IDX);
-    ssd.bo = array.base_addr;
-    ssd.ls = array.limit - array.base_addr;
-    ssd.acc1 = ((array.read_exec_only == 0) << 1) |
-        (array.contents << 2) |
-        0xf0;   /* P(resent) | DPL3 | S */
-    ssd.acc2 = 0x4;   /* byte limit, 32-bit segment */
-    if (sysi86(SI86DSCR, &ssd) < 0) {
-        perror("sysi86(SI86DSCR)");
-        printf("Couldn't install fs segment, expect segfault\n");
-    }
+       struct ssd ssd;
+       ssd.sel = LDT_SEL(TEB_SEL_IDX);
+       ssd.bo = array.base_addr;
+       ssd.ls = array.limit - array.base_addr;
+       ssd.acc1 = ((array.read_exec_only == 0) << 1) |
+           (array.contents << 2) |
+           0xf0;   /* P(resent) | DPL3 | S */
+       ssd.acc2 = 0x4;   /* byte limit, 32-bit segment */
+       if (sysi86(SI86DSCR, &ssd) < 0) {
+           perror("sysi86(SI86DSCR)");
+           printf("Couldn't install fs segment, expect segfault\n");
+       }
     }
 #endif
 
@@ -298,9 +298,9 @@ ldt_fs_t* Setup_LDT_Keeper(void)
 void Restore_LDT_Keeper(ldt_fs_t* ldt_fs)
 {
     if (ldt_fs == NULL || ldt_fs->fs_seg == 0)
-    return;
+       return;
     if (ldt_fs->prev_struct)
-    free(ldt_fs->prev_struct);
+       free(ldt_fs->prev_struct);
     munmap((char*)ldt_fs->fs_seg, getpagesize());
     ldt_fs->fs_seg = 0;
     close(ldt_fs->fd);
index b495814..ec29983 100644 (file)
@@ -42,9 +42,9 @@ extern "C" {
 
 unsigned int _GetPrivateProfileIntA(const char* appname, const char* keyname, int default_value, const char* filename);
 int _GetPrivateProfileStringA(const char* appname, const char* keyname,
-    const char* def_val, char* dest, unsigned int len, const char* filename);
+       const char* def_val, char* dest, unsigned int len, const char* filename);
 int _WritePrivateProfileStringA(const char* appname, const char* keyname,
-    const char* string, const char* filename);
+       const char* string, const char* filename);
 
 INT WINAPI LoadStringA( HINSTANCE instance, UINT resource_id,
                             LPSTR buffer, INT buflen );
index e88b9f4..2e42dff 100644 (file)
@@ -80,14 +80,14 @@ WINE_MODREF* MODULE_FindModule(LPCSTR m)
     modref_list* list=local_wm;
     TRACE("FindModule: Module %s request\n", m);
     if(list==NULL)
-    return NULL;
+       return NULL;
 //    while(strcmp(m, list->wm->filename))
     while(!strstr(list->wm->filename, m))
     {
-    TRACE("%s: %x\n", list->wm->filename, list->wm->module);
-    list=list->prev;
-    if(list==NULL)
-        return NULL;
+       TRACE("%s: %x\n", list->wm->filename, list->wm->module);
+       list=list->prev;
+       if(list==NULL)
+           return NULL;
     }
     TRACE("Resolved to %s\n", list->wm->filename);
     return list->wm;
@@ -97,29 +97,29 @@ static void MODULE_RemoveFromList(WINE_MODREF *mod)
 {
     modref_list* list=local_wm;
     if(list==0)
-    return;
+       return;
     if(mod==0)
-    return;
+       return;
     if((list->prev==NULL)&&(list->next==NULL))
     {
-    free(list);
-    local_wm=NULL;
-//    uninstall_fs();
-    return;
+       free(list);
+       local_wm=NULL;
+//     uninstall_fs();
+       return;
     }
     for(;list;list=list->prev)
     {
-    if(list->wm==mod)
-    {
-        if(list->prev)
-        list->prev->next=list->next;
-        if(list->next)
-        list->next->prev=list->prev;
-        if(list==local_wm)
-        local_wm=list->prev;
-        free(list);
-        return;
-    }
+       if(list->wm==mod)
+       {
+           if(list->prev)
+               list->prev->next=list->next;
+           if(list->next)
+               list->next->prev=list->prev;
+           if(list==local_wm)
+               local_wm=list->prev;
+           free(list);
+           return;
+       }
     }
 
 }
@@ -130,26 +130,26 @@ WINE_MODREF *MODULE32_LookupHMODULE(HMODULE m)
     TRACE("LookupHMODULE: Module %X request\n", m);
     if(list==NULL)
     {
-    TRACE("LookupHMODULE failed\n");
-    return NULL;
+       TRACE("LookupHMODULE failed\n");
+       return NULL;
     }
     while(m!=list->wm->module)
     {
 //      printf("Checking list %X wm %X module %X\n",
-//    list, list->wm, list->wm->module);
-    list=list->prev;
-    if(list==NULL)
-    {
-        TRACE("LookupHMODULE failed\n");
-        return NULL;
-    }
+//     list, list->wm, list->wm->module);
+       list=list->prev;
+       if(list==NULL)
+       {
+           TRACE("LookupHMODULE failed\n");
+           return NULL;
+       }
     }
     TRACE("LookupHMODULE hit %p\n", list->wm);
     return list->wm;
 }
 
 /*************************************************************************
- *        MODULE_InitDll
+ *             MODULE_InitDll
  */
 static WIN_BOOL MODULE_InitDll( WINE_MODREF *wm, DWORD type, LPVOID lpReserved )
 {
@@ -195,7 +195,7 @@ static WIN_BOOL MODULE_InitDll( WINE_MODREF *wm, DWORD type, LPVOID lpReserved )
 }
 
 /*************************************************************************
- *        MODULE_DllProcessAttach
+ *             MODULE_DllProcessAttach
  *
  * Send the process attach notification to all DLLs the given module
  * depends on (recursively). This is somewhat complicated due to the fact that
@@ -252,7 +252,7 @@ static WIN_BOOL MODULE_DllProcessAttach( WINE_MODREF *wm, LPVOID lpReserved )
     //local_wm=wm;
     if(local_wm)
     {
-    local_wm->next = (modref_list*) malloc(sizeof(modref_list));
+       local_wm->next = (modref_list*) malloc(sizeof(modref_list));
         local_wm->next->prev=local_wm;
         local_wm->next->next=NULL;
         local_wm->next->wm=wm;
@@ -260,9 +260,9 @@ static WIN_BOOL MODULE_DllProcessAttach( WINE_MODREF *wm, LPVOID lpReserved )
     }
     else
     {
-    local_wm = (modref_list*)malloc(sizeof(modref_list));
-    local_wm->next=local_wm->prev=NULL;
-    local_wm->wm=wm;
+       local_wm = (modref_list*)malloc(sizeof(modref_list));
+       local_wm->next=local_wm->prev=NULL;
+       local_wm->wm=wm;
     }
     /* Remove recursion flag */
     wm->flags &= ~WINE_MODREF_MARKER;
@@ -281,7 +281,7 @@ static WIN_BOOL MODULE_DllProcessAttach( WINE_MODREF *wm, LPVOID lpReserved )
 }
 
 /*************************************************************************
- *        MODULE_DllProcessDetach
+ *             MODULE_DllProcessDetach
  *
  * Send DLL process detach notifications.  See the comment about calling
  * sequence at MODULE_DllProcessAttach.  Unless the bForceDetach flag
@@ -295,15 +295,15 @@ static void MODULE_DllProcessDetach( WINE_MODREF* wm, WIN_BOOL bForceDetach, LPV
     MODULE_InitDll( wm, DLL_PROCESS_DETACH, lpReserved );
 /*    while (l)
     {
-    modref_list* f = l;
-    l = l->next;
-    free(f);
+       modref_list* f = l;
+       l = l->next;
+       free(f);
     }
     local_wm = 0;*/
 }
 
 /***********************************************************************
- *    MODULE_LoadLibraryExA    (internal)
+ *     MODULE_LoadLibraryExA   (internal)
  *
  * Load a PE style module according to the load order.
  *
@@ -315,38 +315,38 @@ static void MODULE_DllProcessDetach( WINE_MODREF* wm, WIN_BOOL bForceDetach, LPV
  */
 static WINE_MODREF *MODULE_LoadLibraryExA( LPCSTR libname, HFILE hfile, DWORD flags )
 {
-    DWORD err = GetLastError();
-    WINE_MODREF *pwm;
-    int i;
-//    module_loadorder_t *plo;
+       DWORD err = GetLastError();
+       WINE_MODREF *pwm;
+       int i;
+//     module_loadorder_t *plo;
 
         SetLastError( ERROR_FILE_NOT_FOUND );
-    TRACE("Trying native dll '%s'\n", libname);
-    pwm = PE_LoadLibraryExA(libname, flags);
+       TRACE("Trying native dll '%s'\n", libname);
+       pwm = PE_LoadLibraryExA(libname, flags);
 #ifdef HAVE_LIBDL
-    if(!pwm)
-    {
-            TRACE("Trying ELF dll '%s'\n", libname);
-        pwm=(WINE_MODREF*)ELFDLL_LoadLibraryExA(libname, flags);
-    }
+       if(!pwm)
+       {
+           TRACE("Trying ELF dll '%s'\n", libname);
+           pwm=(WINE_MODREF*)ELFDLL_LoadLibraryExA(libname, flags);
+       }
 #endif
-//        printf("0x%08x\n", pwm);
-//        break;
-    if(pwm)
-    {
-        /* Initialize DLL just loaded */
-        TRACE("Loaded module '%s' at 0x%08x, \n", libname, pwm->module);
-        /* Set the refCount here so that an attach failure will */
-        /* decrement the dependencies through the MODULE_FreeLibrary call. */
-        pwm->refCount++;
+//             printf("0x%08x\n", pwm);
+//             break;
+       if(pwm)
+       {
+               /* Initialize DLL just loaded */
+               TRACE("Loaded module '%s' at 0x%08x, \n", libname, pwm->module);
+               /* Set the refCount here so that an attach failure will */
+               /* decrement the dependencies through the MODULE_FreeLibrary call. */
+               pwm->refCount++;
 
                 SetLastError( err );  /* restore last error */
-        return pwm;
-    }
+               return pwm;
+       }
 
 
-    WARN("Failed to load module '%s'; error=0x%08lx, \n", libname, GetLastError());
-    return NULL;
+       WARN("Failed to load module '%s'; error=0x%08lx, \n", libname, GetLastError());
+       return NULL;
 }
 
 /***********************************************************************
@@ -376,85 +376,85 @@ static WIN_BOOL MODULE_FreeLibrary( WINE_MODREF *wm )
  */
 HMODULE WINAPI LoadLibraryExA(LPCSTR libname, HANDLE hfile, DWORD flags)
 {
-    WINE_MODREF *wm = 0;
-    char* listpath[] = { "", "", "/usr/lib/win32", "/usr/local/lib/win32", "/usr/lib/codecs", "/usr/local/lib/codecs", 0 };
-    extern char* def_path;
-    char path[512];
-    char checked[2000];
+       WINE_MODREF *wm = 0;
+       char* listpath[] = { "", "", "/usr/lib/win32", "/usr/local/lib/win32", "/usr/lib/codecs", "/usr/local/lib/codecs", 0 };
+       extern char* def_path;
+       char path[512];
+       char checked[2000];
         int i = -1;
 
         checked[0] = 0;
-    if(!libname)
-    {
-        SetLastError(ERROR_INVALID_PARAMETER);
-        return 0;
-    }
-
-    wm=MODULE_FindModule(libname);
-    if(wm) return wm->module;
-
-//    if(fs_installed==0)
-//        install_fs();
-
-    while (wm == 0 && listpath[++i])
-    {
-        if (i < 2)
-        {
-        if (i == 0)
-            /* check just original file name */
-            strncpy(path, libname, 511);
+       if(!libname)
+       {
+               SetLastError(ERROR_INVALID_PARAMETER);
+               return 0;
+       }
+
+       wm=MODULE_FindModule(libname);
+       if(wm) return wm->module;
+
+//     if(fs_installed==0)
+//         install_fs();
+
+       while (wm == 0 && listpath[++i])
+       {
+           if (i < 2)
+           {
+               if (i == 0)
+                   /* check just original file name */
+                   strncpy(path, libname, 511);
                 else
-            /* check default user path */
-            strncpy(path, def_path, 300);
-        }
-        else if (strcmp(def_path, listpath[i]))
+                   /* check default user path */
+                   strncpy(path, def_path, 300);
+           }
+           else if (strcmp(def_path, listpath[i]))
                 /* path from the list */
-        strncpy(path, listpath[i], 300);
-        else
-        continue;
-
-        if (i > 0)
-        {
-        strcat(path, "/");
-        strncat(path, libname, 100);
-        }
-        path[511] = 0;
-        wm = MODULE_LoadLibraryExA( path, hfile, flags );
-
-        if (!wm)
-        {
-        if (checked[0])
-            strcat(checked, ", ");
-        strcat(checked, path);
+               strncpy(path, listpath[i], 300);
+           else
+               continue;
+
+           if (i > 0)
+           {
+               strcat(path, "/");
+               strncat(path, libname, 100);
+           }
+           path[511] = 0;
+           wm = MODULE_LoadLibraryExA( path, hfile, flags );
+
+           if (!wm)
+           {
+               if (checked[0])
+                   strcat(checked, ", ");
+               strcat(checked, path);
                 checked[1500] = 0;
 
-        }
-    }
-    if ( wm )
-    {
-        if ( !MODULE_DllProcessAttach( wm, NULL ) )
-        {
-            WARN_(module)("Attach failed for module '%s', \n", libname);
-            MODULE_FreeLibrary(wm);
-            SetLastError(ERROR_DLL_INIT_FAILED);
-            MODULE_RemoveFromList(wm);
-            wm = NULL;
-        }
-    }
-
-    if (!wm)
-        printf("Win32 LoadLibrary failed to load: %s\n", checked);
-
-    if (strstr(libname,"vp31vfw.dll") && wm)
-    {
-        int i;
-
-      // sse hack moved from patch dll into runtime patching
+           }
+       }
+       if ( wm )
+       {
+               if ( !MODULE_DllProcessAttach( wm, NULL ) )
+               {
+                       WARN_(module)("Attach failed for module '%s', \n", libname);
+                       MODULE_FreeLibrary(wm);
+                       SetLastError(ERROR_DLL_INIT_FAILED);
+                       MODULE_RemoveFromList(wm);
+                       wm = NULL;
+               }
+       }
+
+       if (!wm)
+           printf("Win32 LoadLibrary failed to load: %s\n", checked);
+
+       if (strstr(libname,"vp31vfw.dll") && wm)
+       {
+           int i;
+
+         // sse hack moved from patch dll into runtime patching
           if (PE_FindExportedFunction(wm, "DriverProc", TRUE)==(void*)0x10001000) {
-        fprintf(stderr, "VP3 DLL found\n");
-        for (i=0;i<18;i++) ((char*)0x10004bd6)[i]=0x90;
-      }
-    }
+           fprintf(stderr, "VP3 DLL found\n");
+           for (i=0;i<18;i++) ((char*)0x10004bd6)[i]=0x90;
+         }
+       }
 
         // remove a few divs in the VP codecs that make trouble
         if (strstr(libname,"vp5vfw.dll") && wm)
@@ -508,78 +508,78 @@ HMODULE WINAPI LoadLibraryExA(LPCSTR libname, HANDLE hfile, DWORD flags)
           }
         }
 
-    if (strstr(libname,"QuickTime.qts") && wm)
-    {
-        void** ptr;
-        void *dispatch_addr;
-        int i;
-
-//        dispatch_addr = GetProcAddress(wm->module, "theQuickTimeDispatcher", TRUE);
-        dispatch_addr = PE_FindExportedFunction(wm, "theQuickTimeDispatcher", TRUE);
-        if (dispatch_addr == (void *)0x62924c30)
-        {
-            fprintf(stderr, "QuickTime5 DLLs found\n");
-        ptr = (void **)0x62b75ca4; // dispatch_ptr
-            for (i=0;i<5;i++)  ((char*)0x6299e842)[i]=0x90; // make_new_region ?
-            for (i=0;i<28;i++) ((char*)0x6299e86d)[i]=0x90; // call__call_CreateCompatibleDC ?
-        for (i=0;i<5;i++)  ((char*)0x6299e898)[i]=0x90; // jmp_to_call_loadbitmap ?
-            for (i=0;i<9;i++)  ((char*)0x6299e8ac)[i]=0x90; // call__calls_OLE_shit ?
-            for (i=0;i<106;i++) ((char*)0x62a61b10)[i]=0x90; // disable threads
+       if (strstr(libname,"QuickTime.qts") && wm)
+       {
+           void** ptr;
+           void *dispatch_addr;
+           int i;
+
+//         dispatch_addr = GetProcAddress(wm->module, "theQuickTimeDispatcher", TRUE);
+           dispatch_addr = PE_FindExportedFunction(wm, "theQuickTimeDispatcher", TRUE);
+           if (dispatch_addr == (void *)0x62924c30)
+           {
+               fprintf(stderr, "QuickTime5 DLLs found\n");
+               ptr = (void **)0x62b75ca4; // dispatch_ptr
+               for (i=0;i<5;i++)  ((char*)0x6299e842)[i]=0x90; // make_new_region ?
+               for (i=0;i<28;i++) ((char*)0x6299e86d)[i]=0x90; // call__call_CreateCompatibleDC ?
+               for (i=0;i<5;i++)  ((char*)0x6299e898)[i]=0x90; // jmp_to_call_loadbitmap ?
+               for (i=0;i<9;i++)  ((char*)0x6299e8ac)[i]=0x90; // call__calls_OLE_shit ?
+               for (i=0;i<106;i++) ((char*)0x62a61b10)[i]=0x90; // disable threads
 #if 0
-        /* CreateThread callers */
-        for (i=0;i<5;i++) ((char*)0x629487c5)[i]=0x90;
-        for (i=0;i<5;i++) ((char*)0x6294b275)[i]=0x90;
-        for (i=0;i<5;i++) ((char*)0x629a24b1)[i]=0x90;
-        for (i=0;i<5;i++) ((char*)0x629afc5a)[i]=0x90;
-        for (i=0;i<5;i++) ((char*)0x62af799c)[i]=0x90;
-        for (i=0;i<5;i++) ((char*)0x62af7efe)[i]=0x90;
-        for (i=0;i<5;i++) ((char*)0x62afa33e)[i]=0x90;
+               /* CreateThread callers */
+               for (i=0;i<5;i++) ((char*)0x629487c5)[i]=0x90;
+               for (i=0;i<5;i++) ((char*)0x6294b275)[i]=0x90;
+               for (i=0;i<5;i++) ((char*)0x629a24b1)[i]=0x90;
+               for (i=0;i<5;i++) ((char*)0x629afc5a)[i]=0x90;
+               for (i=0;i<5;i++) ((char*)0x62af799c)[i]=0x90;
+               for (i=0;i<5;i++) ((char*)0x62af7efe)[i]=0x90;
+               for (i=0;i<5;i++) ((char*)0x62afa33e)[i]=0x90;
 #endif
 
 #if 0
-        /* TerminateQTML fix */
-        for (i=0;i<47;i++) ((char*)0x62afa3b8)[i]=0x90; // terminate thread
-        for (i=0;i<47;i++) ((char*)0x62af7f78)[i]=0x90; // terminate thread
-        for (i=0;i<77;i++) ((char*)0x629a13d5)[i]=0x90;
-        ((char *)0x6288e0ae)[0] = 0xc3; // font/dc remover
-        for (i=0;i<24;i++) ((char*)0x6287a1ad)[i]=0x90; // destroy window
+               /* TerminateQTML fix */
+               for (i=0;i<47;i++) ((char*)0x62afa3b8)[i]=0x90; // terminate thread
+               for (i=0;i<47;i++) ((char*)0x62af7f78)[i]=0x90; // terminate thread
+               for (i=0;i<77;i++) ((char*)0x629a13d5)[i]=0x90;
+               ((char *)0x6288e0ae)[0] = 0xc3; // font/dc remover
+               for (i=0;i<24;i++) ((char*)0x6287a1ad)[i]=0x90; // destroy window
 #endif
-        } else if (dispatch_addr == (void *)0x6693b330)
-        {
-            fprintf(stderr, "QuickTime6 DLLs found\n");
-        ptr = (void **)0x66bb9524; // dispatcher_ptr
-        for (i=0;i<5;i++)  ((char *)0x66a730cc)[i]=0x90; // make_new_region
-        for (i=0;i<28;i++) ((char *)0x66a730f7)[i]=0x90; // call__call_CreateCompatibleDC
-        for (i=0;i<5;i++)  ((char *)0x66a73122)[i]=0x90; // jmp_to_call_loadbitmap
-        for (i=0;i<9;i++)  ((char *)0x66a73131)[i]=0x90; // call__calls_OLE_shit
-        for (i=0;i<96;i++) ((char *)0x66aac852)[i]=0x90; // disable threads
-        } else if (dispatch_addr == (void *)0x6693c3e0)
-        {
-            fprintf(stderr, "QuickTime6.3 DLLs found\n");
-        ptr = (void **)0x66bca01c; // dispatcher_ptr
-        for (i=0;i<5;i++)  ((char *)0x66a68f6c)[i]=0x90; // make_new_region
-        for (i=0;i<28;i++) ((char *)0x66a68f97)[i]=0x90; // call__call_CreateCompatibleDC
-        for (i=0;i<5;i++)  ((char *)0x66a68fc2)[i]=0x90; // jmp_to_call_loadbitmap
-        for (i=0;i<9;i++)  ((char *)0x66a68fd1)[i]=0x90; // call__calls_OLE_shit
-        for (i=0;i<96;i++) ((char *)0x66ab4722)[i]=0x90; // disable threads
-        } else
-        {
-            fprintf(stderr, "Unsupported QuickTime version (%p)\n",
-            dispatch_addr);
-        return 0;
-        }
-
-        fprintf(stderr,"QuickTime.qts patched!!! old entry=%p\n",ptr[0]);
+           } else if (dispatch_addr == (void *)0x6693b330)
+           {
+               fprintf(stderr, "QuickTime6 DLLs found\n");
+               ptr = (void **)0x66bb9524; // dispatcher_ptr
+               for (i=0;i<5;i++)  ((char *)0x66a730cc)[i]=0x90; // make_new_region
+               for (i=0;i<28;i++) ((char *)0x66a730f7)[i]=0x90; // call__call_CreateCompatibleDC
+               for (i=0;i<5;i++)  ((char *)0x66a73122)[i]=0x90; // jmp_to_call_loadbitmap
+               for (i=0;i<9;i++)  ((char *)0x66a73131)[i]=0x90; // call__calls_OLE_shit
+               for (i=0;i<96;i++) ((char *)0x66aac852)[i]=0x90; // disable threads
+           } else if (dispatch_addr == (void *)0x6693c3e0)
+           {
+               fprintf(stderr, "QuickTime6.3 DLLs found\n");
+               ptr = (void **)0x66bca01c; // dispatcher_ptr
+               for (i=0;i<5;i++)  ((char *)0x66a68f6c)[i]=0x90; // make_new_region
+               for (i=0;i<28;i++) ((char *)0x66a68f97)[i]=0x90; // call__call_CreateCompatibleDC
+               for (i=0;i<5;i++)  ((char *)0x66a68fc2)[i]=0x90; // jmp_to_call_loadbitmap
+               for (i=0;i<9;i++)  ((char *)0x66a68fd1)[i]=0x90; // call__calls_OLE_shit
+               for (i=0;i<96;i++) ((char *)0x66ab4722)[i]=0x90; // disable threads
+           } else
+           {
+               fprintf(stderr, "Unsupported QuickTime version (%p)\n",
+                   dispatch_addr);
+               return 0;
+           }
+
+           fprintf(stderr,"QuickTime.qts patched!!! old entry=%p\n",ptr[0]);
 
 #ifdef EMU_QTX_API
-        report_entry = report_func;
-        report_ret   = report_func_ret;
-        wrapper_target=ptr[0];
-        ptr[0]=wrapper;
+           report_entry = report_func;
+           report_ret   = report_func_ret;
+           wrapper_target=ptr[0];
+           ptr[0]=wrapper;
 #endif
-    }
+       }
 
-    return wm ? wm->module : 0;
+       return wm ? wm->module : 0;
 }
 
 
@@ -587,7 +587,7 @@ HMODULE WINAPI LoadLibraryExA(LPCSTR libname, HANDLE hfile, DWORD flags)
  *           LoadLibraryA         (KERNEL32)
  */
 HMODULE WINAPI LoadLibraryA(LPCSTR libname) {
-    return LoadLibraryExA(libname,0,0);
+       return LoadLibraryExA(libname,0,0);
 }
 
 /***********************************************************************
@@ -603,7 +603,7 @@ WIN_BOOL WINAPI FreeLibrary(HINSTANCE hLibModule)
     if ( !wm || !hLibModule )
     {
         SetLastError( ERROR_INVALID_HANDLE );
-    return 0;
+       return 0;
     }
     else
         retv = MODULE_FreeLibrary( wm );
@@ -647,7 +647,7 @@ static void MODULE_DecRefCount( WINE_MODREF *wm )
 }
 
 /***********************************************************************
- *           GetProcAddress           (KERNEL32.257)
+ *           GetProcAddress            (KERNEL32.257)
  */
 FARPROC WINAPI GetProcAddress( HMODULE hModule, LPCSTR function )
 {
@@ -656,7 +656,7 @@ FARPROC WINAPI GetProcAddress( HMODULE hModule, LPCSTR function )
 
 #ifdef DEBUG_QTX_API
 
-/*
+/* 
 http://lists.apple.com/archives/quicktime-api/2003/Jan/msg00278.html
 */
 
@@ -722,23 +722,23 @@ static int dump_component(char* name,int type,void* _orig, ComponentParameters *
     fprintf(stderr,"%*sComponentCall: %s  flags=0x%X  size=%d  what=0x%X %s\n",3*c_level,"",name,params->flags, params->paramSize, params->what, component_func(params->what));
 
     for(i=0;i<params->paramSize/4;i++)
-    fprintf(stderr,"%*s param[%d] = 0x%X\n",3*c_level,"",i,params->params[i]);
+       fprintf(stderr,"%*s param[%d] = 0x%X\n",3*c_level,"",i,params->params[i]);
 
     ++c_level;
     ret=orig(params,glob);
     --c_level;
+    
     if(ret>=0x1000)
-    fprintf(stderr,"%*s return=0x%X\n",3*c_level,"",ret);
+       fprintf(stderr,"%*s return=0x%X\n",3*c_level,"",ret);
     else
-    fprintf(stderr,"%*s return=%d\n",3*c_level,"",ret);
+       fprintf(stderr,"%*s return=%d\n",3*c_level,"",ret);
     return ret;
 }
 
 #define DECL_COMPONENT(sname,name,type) \
     static void* real_ ## sname = NULL; \
     static int fake_ ## sname(ComponentParameters *params,void** glob){ \
-    return dump_component(name,type,real_ ## sname, params, glob); \
+       return dump_component(name,type,real_ ## sname, params, glob); \
     }
 
 #include "qt_comp.h"
@@ -764,47 +764,47 @@ static int report_func(void *stack_base, int stack_size, reg386_t *reg, uint32_t
   char* pname=NULL;
   int plen=-1;
   // find the code:
+  
   dptr=0x62b67ae0;dptr+=2*((reg->eax>>16)&255);
 //  printf("FUNC: flag=%d ptr=%p\n",dptr[0],dptr[1]);
   if(dptr[0]&255){
       dptr=dptr[1];dptr+=4*(reg->eax&65535);
 //      printf("FUNC: ptr2=%p  eax=%p  edx=%p\n",dptr[1],dptr[0],dptr[2]);
-      pwrapper=dptr[1]; pptr=dptr[0]; plen=dptr[2];
+      pwrapper=dptr[1]; pptr=dptr[0]; plen=dptr[2]; 
   } else {
       pwrapper=0x62924910;
       switch(dptr[1]){
       case 0x629248d0:
           dptr=0x62b672c0;dptr+=2*(reg->eax&65535);
 //          printf("FUNC: ptr2=%p  eax=%p  edx=%p\n",0x62924910,dptr[0],dptr[1]);
-          pptr=dptr[0]; plen=dptr[1];
-      break;
+          pptr=dptr[0]; plen=dptr[1]; 
+         break;
       case 0x62924e40:
           dptr=0x62b67c70;dptr+=2*(reg->eax&65535);
 //          printf("FUNC: ptr2=%p  eax=%p  edx=%p\n",0x62924910,dptr[0],dptr[1]);
-          pptr=dptr[0]; plen=dptr[1];
-      break;
+          pptr=dptr[0]; plen=dptr[1]; 
+         break;
       case 0x62924e60:
           dptr=0x62b68108;if(reg->eax&0x8000) dptr+=2*(reg->eax|0xffff0000); else dptr+=2*(reg->eax&65535);
 //          printf("FUNC: ptr2=%p  eax=%p  edx=%p\n",0x62924910,dptr[0],dptr[1]);
-          pptr=dptr[0]; plen=dptr[1];
-      break;
+          pptr=dptr[0]; plen=dptr[1]; 
+         break;
       case 0x62924e80:
           dptr=0x62b68108;if(reg->eax&0x8000) dptr+=2*(reg->eax|0xffff0000); else dptr+=2*(reg->eax&65535);
 //          printf("FUNC: ptr2=%p  eax=%p  edx=%p\n",0x62924910,dptr[0],dptr[1]);
-          pptr=dptr[0]; plen=dptr[1];
-      break;
+          pptr=dptr[0]; plen=dptr[1]; 
+         break;
       default:
           printf("FUNC: unknown ptr & psize!\n");
-      pwrapper=dptr[1];
+         pwrapper=dptr[1];
       }
   }
 
   for(i=0;qt_fv_list[i].name;i++){
           if(qt_fv_list[i].id==reg->eax){
-          pname=qt_fv_list[i].name;
-          break;
-      }
+             pname=qt_fv_list[i].name;
+             break;
+         }
   }
 
   printf("FUNC[%X/%s]: wrapper=%p  func=%p  len=%d\n",reg->eax,
@@ -830,7 +830,7 @@ static int report_func(void *stack_base, int stack_size, reg386_t *reg, uint32_t
   fflush(stdout);
 
 #endif
+  
 #if 1
   // emulate some functions:
   switch(reg->eax){
@@ -914,22 +914,22 @@ static int report_func(void *stack_base, int stack_size, reg386_t *reg, uint32_t
       int i;
       for(i=0;qt_fv_list[i].name;i++){
           if(qt_fv_list[i].id==reg->eax){
-          printf("FUNC: %s\n",qt_fv_list[i].name);
-          break;
-      }
+             printf("FUNC: %s\n",qt_fv_list[i].name);
+             break;
+         }
       }
       }
   }
 
-  // print stack/reg information
+  // print stack/reg information 
   printf("ENTER(%d) stack = %d bytes @ %p\n"
-     "eax = 0x%08x edx = 0x%08x ebx = 0x%08x ecx = 0x%08x\n"
-     "esp = 0x%08x ebp = 0x%08x esi = 0x%08x edi = 0x%08x\n"
-     "flags = 0x%08x\n", ret_i,
-     stack_size, stack_base,
-     reg->eax, reg->edx, reg->ebx, reg->ecx,
-     reg->esp, reg->ebp, reg->esi, reg->edi,
-     *flags);
+        "eax = 0x%08x edx = 0x%08x ebx = 0x%08x ecx = 0x%08x\n"
+        "esp = 0x%08x ebp = 0x%08x esi = 0x%08x edi = 0x%08x\n"
+        "flags = 0x%08x\n", ret_i,
+        stack_size, stack_base,
+        reg->eax, reg->edx, reg->ebx, reg->ecx,
+        reg->esp, reg->ebp, reg->esi, reg->edi,
+        *flags);
 #endif
 
   // save ret addr:
@@ -937,15 +937,15 @@ static int report_func(void *stack_base, int stack_size, reg386_t *reg, uint32_t
   ++ret_i;
 
 #if 0
-  // print first 7 longs in the stack (return address, arg[1], arg[2] ... )
+  // print first 7 longs in the stack (return address, arg[1], arg[2] ... ) 
   printf("stack[] = { ");
   for (i=0;i<7;i++) {
     printf("%08x ", ((uint32_t *)stack_base)[i]);
   }
   printf("}\n\n");
 #endif
-//  // mess with function parameters
+  
+//  // mess with function parameters 
 //  ((uint32_t *)stack_base)[1] = 0x66554433;
 
 //  // mess with return address...
@@ -971,19 +971,19 @@ static int report_func_ret(void *stack_base, int stack_size, reg386_t *reg, uint
   printf("\n");
   fflush(stdout);
 #else
-  // print stack/reg information
+  // print stack/reg information 
   printf("LEAVE(%d) stack = %d bytes @ %p\n"
-     "eax = 0x%08x edx = 0x%08x ebx = 0x%08x ecx = 0x%08x\n"
-     "esp = 0x%08x ebp = 0x%08x esi = 0x%08x edi = 0x%08x\n"
-     "flags = 0x%08x\n", ret_i,
-     stack_size, stack_base,
-     reg->eax, reg->edx, reg->ebx, reg->ecx,
-     reg->esp, reg->ebp, reg->esi, reg->edi,
-     *flags);
+        "eax = 0x%08x edx = 0x%08x ebx = 0x%08x ecx = 0x%08x\n"
+        "esp = 0x%08x ebp = 0x%08x esi = 0x%08x edi = 0x%08x\n"
+        "flags = 0x%08x\n", ret_i,
+        stack_size, stack_base,
+        reg->eax, reg->edx, reg->ebx, reg->ecx,
+        reg->esp, reg->ebp, reg->esi, reg->edi,
+        *flags);
 #endif
 
 #if 0
-  // print first 7 longs in the stack (return address, arg[1], arg[2] ... )
+  // print first 7 longs in the stack (return address, arg[1], arg[2] ... ) 
   printf("stack[] = { ");
   for (i=0;i<7;i++) {
     printf("%08x ", ((uint32_t *)stack_base)[i]);
@@ -992,8 +992,8 @@ static int report_func_ret(void *stack_base, int stack_size, reg386_t *reg, uint
 #endif
 
 #endif
-//  // mess with function parameters
+  
+//  // mess with function parameters 
 //  ((uint32_t *)stack_base)[1] = 0x66554433;
 
 //  // mess with return address...
@@ -1004,48 +1004,48 @@ static int report_func_ret(void *stack_base, int stack_size, reg386_t *reg, uint
 #endif
 
 /***********************************************************************
- *           MODULE_GetProcAddress           (internal)
+ *           MODULE_GetProcAddress             (internal)
  */
 FARPROC MODULE_GetProcAddress(
-    HMODULE hModule,     /* [in] current module handle */
-    LPCSTR function,    /* [in] function to be looked up */
-    WIN_BOOL snoop )
+       HMODULE hModule,        /* [in] current module handle */
+       LPCSTR function,        /* [in] function to be looked up */
+       WIN_BOOL snoop )
 {
-    WINE_MODREF    *wm = MODULE32_LookupHMODULE( hModule );
+    WINE_MODREF        *wm = MODULE32_LookupHMODULE( hModule );
 //    WINE_MODREF *wm=local_wm;
-    FARPROC    retproc;
+    FARPROC    retproc;
 
 #ifdef DEBUG_QTX_API
     if (HIWORD(function))
-    fprintf(stderr,"XXX GetProcAddress(%08lx,%s)\n",(DWORD)hModule,function);
+       fprintf(stderr,"XXX GetProcAddress(%08lx,%s)\n",(DWORD)hModule,function);
     else
-    fprintf(stderr,"XXX GetProcAddress(%08lx,%p)\n",(DWORD)hModule,function);
+       fprintf(stderr,"XXX GetProcAddress(%08lx,%p)\n",(DWORD)hModule,function);
 #endif
 
-//    TRACE_(win32)("(%08lx,%s)\n",(DWORD)hModule,function);
+//     TRACE_(win32)("(%08lx,%s)\n",(DWORD)hModule,function);
 //    else
-//    TRACE_(win32)("(%08lx,%p)\n",(DWORD)hModule,function);
+//     TRACE_(win32)("(%08lx,%p)\n",(DWORD)hModule,function);
 
     if (!wm) {
-        SetLastError(ERROR_INVALID_HANDLE);
+       SetLastError(ERROR_INVALID_HANDLE);
         return (FARPROC)0;
     }
     switch (wm->type)
     {
     case MODULE32_PE:
-         retproc = PE_FindExportedFunction( wm, function, snoop );
-    if (!retproc) SetLastError(ERROR_PROC_NOT_FOUND);
-    break;
+       retproc = PE_FindExportedFunction( wm, function, snoop );
+       if (!retproc) SetLastError(ERROR_PROC_NOT_FOUND);
+       break;
 #ifdef HAVE_LIBDL
     case MODULE32_ELF:
-    retproc = (FARPROC) dlsym( (void*) wm->module, function);
-    if (!retproc) SetLastError(ERROR_PROC_NOT_FOUND);
-    return retproc;
+       retproc = (FARPROC) dlsym( (void*) wm->module, function);
+       if (!retproc) SetLastError(ERROR_PROC_NOT_FOUND);
+       return retproc;
 #endif
     default:
-        ERR("wine_modref type %d not handled.\n",wm->type);
-        SetLastError(ERROR_INVALID_HANDLE);
-        return (FARPROC)0;
+       ERR("wine_modref type %d not handled.\n",wm->type);
+       SetLastError(ERROR_INVALID_HANDLE);
+       return (FARPROC)0;
     }
 
 #ifdef EMU_QTX_API
@@ -1054,8 +1054,8 @@ FARPROC MODULE_GetProcAddress(
 #ifdef DEBUG_QTX_API
 #define DECL_COMPONENT(sname,name,type) \
     if(!strcmp(function,name)){ \
-    fprintf(stderr,name "dispatcher catched -> %p\n",retproc); \
-    real_ ## sname = retproc; retproc = fake_ ## sname; \
+       fprintf(stderr,name "dispatcher catched -> %p\n",retproc); \
+       real_ ## sname = retproc; retproc = fake_ ## sname; \
     }
 #include "qt_comp.h"
 #undef DECL_COMPONENT
@@ -1065,7 +1065,7 @@ FARPROC MODULE_GetProcAddress(
 //      || !strcmp(function,"_CallComponentFunctionWithStorage")
 //      || !strcmp(function,"_CallComponent")
       ){
-    fprintf(stderr,"theQuickTimeDispatcher catched -> %p\n",retproc);
+       fprintf(stderr,"theQuickTimeDispatcher catched -> %p\n",retproc);
       report_entry = report_func;
       report_ret   = report_func_ret;
       wrapper_target=(void(*)(void))retproc;
@@ -1091,16 +1091,16 @@ void CodecRelease(void)
     //printf("**************CODEC RELEASE %d\n", acounter);
     if (acounter == 0)
     {
-    for (;;)
-    {
-        modref_list* list = local_wm;
-        if (!local_wm)
-        break;
-        //printf("CODECRELEASE %p\n", list);
+       for (;;)
+       {
+           modref_list* list = local_wm;
+           if (!local_wm)
+               break;
+           //printf("CODECRELEASE %p\n", list);
             MODULE_FreeLibrary(list->wm);
-        MODULE_RemoveFromList(list->wm);
+           MODULE_RemoveFromList(list->wm);
             if (local_wm == NULL)
-        my_garbagecollection();
-    }
+               my_garbagecollection();
+       }
     }
 }
index 30d09ff..13465a7 100644 (file)
@@ -1,15 +1,15 @@
 /*
  * $Id$
  *
- *  Copyright    1994    Eric Youndale & Erik Bos
- *  Copyright    1995    Martin von Löwis
+ *  Copyright  1994    Eric Youndale & Erik Bos
+ *  Copyright  1995    Martin von Löwis
  *  Copyright   1996-98 Marcus Meissner
  *
- *    based on Eric Youndale's pe-test and:
+ *     based on Eric Youndale's pe-test and:
  *
- *    ftp.microsoft.com:/pub/developer/MSDN/CD8/PEFILE.ZIP
+ *     ftp.microsoft.com:/pub/developer/MSDN/CD8/PEFILE.ZIP
  * make that:
- *    ftp.microsoft.com:/developr/MSDN/OctCD/PEFILE.ZIP
+ *     ftp.microsoft.com:/developr/MSDN/OctCD/PEFILE.ZIP
  *
  * Modified for use with MPlayer, detailed CVS changelog at
  * http://www.mplayerhq.hu/cgi-bin/cvsweb.cgi/main/
 /* Notes:
  * Before you start changing something in this file be aware of the following:
  *
- * - There are several functions called recursively. In a very subtle and
+ * - There are several functions called recursively. In a very subtle and 
  *   obscure way. DLLs can reference each other recursively etc.
  * - If you want to enhance, speed up or clean up something in here, think
  *   twice WHY it is implemented in that strange way. There is usually a reason.
  *   Though sometimes it might just be lazyness ;)
- * - In PE_MapImage, right before fixup_imports() all external and internal
+ * - In PE_MapImage, right before fixup_imports() all external and internal 
  *   state MUST be correct since this function can be called with the SAME image
  *   AGAIN. (Thats recursion for you.) That means MODREF.module and
  *   NE_MODULE.module32.
@@ -86,12 +86,12 @@ extern void* LookupExternal(const char* library, int ordinal);
 extern void* LookupExternalByName(const char* library, const char* name);
 
 static void dump_exports( HMODULE hModule )
-{
-  char        *Module;
+{ 
+  char         *Module;
   unsigned int i, j;
-  u_short    *ordinal;
-  u_long    *function,*functions;
-  u_char    **name;
+  u_short      *ordinal;
+  u_long       *function,*functions;
+  u_char       **name;
   unsigned int load_addr = hModule;
 
   DWORD rva_start = PE_HEADER(hModule)->OptionalHeader
@@ -102,7 +102,7 @@ static void dump_exports( HMODULE hModule )
 
   Module = (char*)RVA(pe_exports->Name);
   TRACE("*******EXPORT DATA*******\n");
-  TRACE("Module name is %s, %ld functions, %ld names\n",
+  TRACE("Module name is %s, %ld functions, %ld names\n", 
         Module, pe_exports->NumberOfFunctions, pe_exports->NumberOfNames);
 
   ordinal=(u_short*) RVA(pe_exports->AddressOfNameOrdinals);
@@ -112,78 +112,78 @@ static void dump_exports( HMODULE hModule )
   TRACE(" Ord    RVA     Addr   Name\n" );
   for (i=0;i<pe_exports->NumberOfFunctions;i++, function++)
   {
-      if (!*function) continue;
+      if (!*function) continue;  
       if (TRACE_ON(win32))
       {
-    DPRINTF( "%4ld %08lx %p", i + pe_exports->Base, *function, RVA(*function) );
-    
-    for (j = 0; j < pe_exports->NumberOfNames; j++)
+       DPRINTF( "%4ld %08lx %p", i + pe_exports->Base, *function, RVA(*function) );
+       
+       for (j = 0; j < pe_exports->NumberOfNames; j++)
           if (ordinal[j] == i)
           {
               DPRINTF( "  %s", (char*)RVA(name[j]) );
               break;
           }
-    if ((*function >= rva_start) && (*function <= rva_end))
-      DPRINTF(" (forwarded -> %s)", (char *)RVA(*function));
-    DPRINTF("\n");
+       if ((*function >= rva_start) && (*function <= rva_end))
+         DPRINTF(" (forwarded -> %s)", (char *)RVA(*function));
+       DPRINTF("\n");
       }
   }
 }
 
 /* Look up the specified function or ordinal in the exportlist:
  * If it is a string:
- *     - look up the name in the Name list.
- *    - look up the ordinal with that index.
- *    - use the ordinal as offset into the functionlist
+ *     - look up the name in the Name list. 
+ *     - look up the ordinal with that index.
+ *     - use the ordinal as offset into the functionlist
  * If it is a ordinal:
- *    - use ordinal-pe_export->Base as offset into the functionlist
+ *     - use ordinal-pe_export->Base as offset into the functionlist
  */
-FARPROC PE_FindExportedFunction(
-    WINE_MODREF *wm,    
-    LPCSTR funcName,    
+FARPROC PE_FindExportedFunction( 
+       WINE_MODREF *wm,        
+       LPCSTR funcName,        
         WIN_BOOL snoop )
 {
-    u_short                * ordinals;
-    u_long                * function;
-    u_char                ** name;
-    const char *ename = NULL;
-    int                i, ordinal;
-    PE_MODREF            *pem = &(wm->binfmt.pe);
-    IMAGE_EXPORT_DIRECTORY         *exports = pem->pe_export;
-    unsigned int            load_addr = wm->module;
-    u_long                rva_start, rva_end, addr;
-    char                * forward;
-
-    if (HIWORD(funcName))
-        TRACE("(%s)\n",funcName);
-    else
-        TRACE("(%d)\n",(int)funcName);
-    if (!exports) {
-        /* Not a fatal problem, some apps do
-         * GetProcAddress(0,"RegisterPenApp") which triggers this
-         * case.
-         */
-        WARN("Module %08x(%s)/MODREF %p doesn't have a exports table.\n",wm->module,wm->modname,pem);
-        return NULL;
-    }
-    ordinals= (u_short*)  RVA(exports->AddressOfNameOrdinals);
-    function= (u_long*)   RVA(exports->AddressOfFunctions);
-    name    = (u_char **) RVA(exports->AddressOfNames);
-    forward = NULL;
-    rva_start = PE_HEADER(wm->module)->OptionalHeader
-        .DataDirectory[IMAGE_DIRECTORY_ENTRY_EXPORT].VirtualAddress;
-    rva_end = rva_start + PE_HEADER(wm->module)->OptionalHeader
-        .DataDirectory[IMAGE_DIRECTORY_ENTRY_EXPORT].Size;
-
-    if (HIWORD(funcName))
+       u_short                         * ordinals;
+       u_long                          * function;
+       u_char                          ** name;
+       const char *ename = NULL;
+       int                             i, ordinal;
+       PE_MODREF                       *pem = &(wm->binfmt.pe);
+       IMAGE_EXPORT_DIRECTORY          *exports = pem->pe_export;
+       unsigned int                    load_addr = wm->module;
+       u_long                          rva_start, rva_end, addr;
+       char                            * forward;
+
+       if (HIWORD(funcName))
+               TRACE("(%s)\n",funcName);
+       else
+               TRACE("(%d)\n",(int)funcName);
+       if (!exports) {
+               /* Not a fatal problem, some apps do
+                * GetProcAddress(0,"RegisterPenApp") which triggers this
+                * case.
+                */
+               WARN("Module %08x(%s)/MODREF %p doesn't have a exports table.\n",wm->module,wm->modname,pem);
+               return NULL;
+       }
+       ordinals= (u_short*)  RVA(exports->AddressOfNameOrdinals);
+       function= (u_long*)   RVA(exports->AddressOfFunctions);
+       name    = (u_char **) RVA(exports->AddressOfNames);
+       forward = NULL;
+       rva_start = PE_HEADER(wm->module)->OptionalHeader
+               .DataDirectory[IMAGE_DIRECTORY_ENTRY_EXPORT].VirtualAddress;
+       rva_end = rva_start + PE_HEADER(wm->module)->OptionalHeader
+               .DataDirectory[IMAGE_DIRECTORY_ENTRY_EXPORT].Size;
+
+       if (HIWORD(funcName))
         {
+            
             int min = 0, max = exports->NumberOfNames - 1;
             while (min <= max)
             {
                 int res, pos = (min + max) / 2;
-        ename = (const char*) RVA(name[pos]);
-        if (!(res = strcmp( ename, funcName )))
+               ename = (const char*) RVA(name[pos]);
+               if (!(res = strcmp( ename, funcName )))
                 {
                     ordinal = ordinals[pos];
                     goto found;
@@ -191,23 +191,23 @@ FARPROC PE_FindExportedFunction(
                 if (res > 0) max = pos - 1;
                 else min = pos + 1;
             }
-        for (i = 0; i < exports->NumberOfNames; i++)
+            
+           for (i = 0; i < exports->NumberOfNames; i++)
             {
-        ename = (const char*) RVA(name[i]);
+               ename = (const char*) RVA(name[i]);
                 if (!strcmp( ename, funcName ))
                 {
-            ERR( "%s.%s required a linear search\n", wm->modname, funcName );
+                   ERR( "%s.%s required a linear search\n", wm->modname, funcName );
                     ordinal = ordinals[i];
                     goto found;
                 }
             }
             return NULL;
-    }
-        else
+       }
+        else  
         {
             ordinal = LOWORD(funcName) - exports->Base;
-            if (snoop && name)
+            if (snoop && name)  
             {
                 for (i = 0; i < exports->NumberOfNames; i++)
                     if (ordinals[i] == ordinal)
@@ -216,12 +216,12 @@ FARPROC PE_FindExportedFunction(
                         break;
                     }
             }
-    }
+       }
 
  found:
         if (ordinal >= exports->NumberOfFunctions)
         {
-            TRACE("    ordinal %ld out of range!\n", ordinal + exports->Base );
+            TRACE("    ordinal %ld out of range!\n", ordinal + exports->Base );
             return NULL;
         }
         addr = function[ordinal];
@@ -233,50 +233,50 @@ FARPROC PE_FindExportedFunction(
             {
                 if (!ename) ename = "@";
 //                proc = SNOOP_GetProcAddress(wm->module,ename,ordinal,proc);
-        TRACE("SNOOP_GetProcAddress n/a\n");
-        
+               TRACE("SNOOP_GetProcAddress n/a\n");
+               
             }
             return proc;
         }
-        else
+        else  
         {
                 WINE_MODREF *wm;
                 char *forward = RVA(addr);
-        char module[256];
-        char *end = strchr(forward, '.');
+               char module[256];
+               char *end = strchr(forward, '.');
 
-        if (!end) return NULL;
+               if (!end) return NULL;
                 if (end - forward >= sizeof(module)) return NULL;
                 memcpy( module, forward, end - forward );
-        module[end-forward] = 0;
+               module[end-forward] = 0;
                 if (!(wm = MODULE_FindModule( module )))
                 {
                     ERR("module not found for forward '%s'\n", forward );
                     return NULL;
                 }
-        return MODULE_GetProcAddress( wm->module, end + 1, snoop );
-    }
+               return MODULE_GetProcAddress( wm->module, end + 1, snoop );
+       }
 }
 
 static DWORD fixup_imports( WINE_MODREF *wm )
 {
-    IMAGE_IMPORT_DESCRIPTOR    *pe_imp;
-    PE_MODREF            *pem;
-    unsigned int load_addr    = wm->module;
-    int                i,characteristics_detection=1;
-    char            *modname;
+    IMAGE_IMPORT_DESCRIPTOR    *pe_imp;
+    PE_MODREF                  *pem;
+    unsigned int load_addr     = wm->module;
+    int                                i,characteristics_detection=1;
+    char                       *modname;
+    
     assert(wm->type==MODULE32_PE);
     pem = &(wm->binfmt.pe);
     if (pem->pe_export)
-        modname = (char*) RVA(pem->pe_export->Name);
+       modname = (char*) RVA(pem->pe_export->Name);
     else
         modname = "<unknown>";
 
+    
     TRACE("Dumping imports list\n");
 
+    
     pe_imp = pem->pe_import;
     if (!pe_imp) return 0;
 
@@ -285,75 +285,75 @@ static DWORD fixup_imports( WINE_MODREF *wm )
      * switch the detection off for them.
      */
     for (i = 0; pe_imp->Name ; pe_imp++) {
-    if (!i && !pe_imp->u.Characteristics)
-        characteristics_detection = 0;
-    if (characteristics_detection && !pe_imp->u.Characteristics)
-        break;
-    i++;
+       if (!i && !pe_imp->u.Characteristics)
+               characteristics_detection = 0;
+       if (characteristics_detection && !pe_imp->u.Characteristics)
+               break;
+       i++;
     }
-    if (!i) return 0;
+    if (!i) return 0;  
 
+    
     wm->nDeps = i;
     wm->deps  = HeapAlloc( GetProcessHeap(), 0, i*sizeof(WINE_MODREF *) );
 
-    /* load the imported modules. They are automatically
+    /* load the imported modules. They are automatically 
      * added to the modref list of the process.
      */
  
     for (i = 0, pe_imp = pem->pe_import; pe_imp->Name ; pe_imp++) {
-        WINE_MODREF        *wmImp;
-    IMAGE_IMPORT_BY_NAME    *pe_name;
-    PIMAGE_THUNK_DATA    import_list,thunk_list;
-     char            *name = (char *) RVA(pe_imp->Name);
+       WINE_MODREF             *wmImp;
+       IMAGE_IMPORT_BY_NAME    *pe_name;
+       PIMAGE_THUNK_DATA       import_list,thunk_list;
+       char                    *name = (char *) RVA(pe_imp->Name);
 
-    if (characteristics_detection && !pe_imp->u.Characteristics)
-        break;
+       if (characteristics_detection && !pe_imp->u.Characteristics)
+               break;
 
 //#warning FIXME: here we should fill imports
         TRACE("Loading imports for %s.dll\n", name);
-    if (pe_imp->u.OriginalFirstThunk != 0) {
-        TRACE("Microsoft style imports used\n");
-        import_list =(PIMAGE_THUNK_DATA) RVA(pe_imp->u.OriginalFirstThunk);
-        thunk_list = (PIMAGE_THUNK_DATA) RVA(pe_imp->FirstThunk);
-
-        while (import_list->u1.Ordinal) {
-        if (IMAGE_SNAP_BY_ORDINAL(import_list->u1.Ordinal)) {
-            int ordinal = IMAGE_ORDINAL(import_list->u1.Ordinal);
-
-//            TRACE("--- Ordinal %s,%d\n", name, ordinal);
-        
-            thunk_list->u1.Function=LookupExternal(name, ordinal);
-        } else {        
-            pe_name = (PIMAGE_IMPORT_BY_NAME)RVA(import_list->u1.AddressOfData);
-//            TRACE("--- %s %s.%d\n", pe_name->Name, name, pe_name->Hint);
-            thunk_list->u1.Function=LookupExternalByName(name, pe_name->Name);
-        }
-        import_list++;
-        thunk_list++;
-        }
-    } else {    
-        TRACE("Borland style imports used\n");
-        thunk_list = (PIMAGE_THUNK_DATA) RVA(pe_imp->FirstThunk);
-        while (thunk_list->u1.Ordinal) {
-        if (IMAGE_SNAP_BY_ORDINAL(thunk_list->u1.Ordinal)) {
-        
-            int ordinal = IMAGE_ORDINAL(thunk_list->u1.Ordinal);
-
-            TRACE("--- Ordinal %s.%d\n",name,ordinal);
-            thunk_list->u1.Function=LookupExternal(
-              name, ordinal);
-        } else {
-            pe_name=(PIMAGE_IMPORT_BY_NAME) RVA(thunk_list->u1.AddressOfData);
-            TRACE("--- %s %s.%d\n",
-                     pe_name->Name,name,pe_name->Hint);
-            thunk_list->u1.Function=LookupExternalByName(
-              name, pe_name->Name);
-        }
-        thunk_list++;
-        }
-    }
+    
+       if (pe_imp->u.OriginalFirstThunk != 0) { 
+           TRACE("Microsoft style imports used\n");
+           import_list =(PIMAGE_THUNK_DATA) RVA(pe_imp->u.OriginalFirstThunk);
+           thunk_list = (PIMAGE_THUNK_DATA) RVA(pe_imp->FirstThunk);
+
+           while (import_list->u1.Ordinal) {
+               if (IMAGE_SNAP_BY_ORDINAL(import_list->u1.Ordinal)) {
+                   int ordinal = IMAGE_ORDINAL(import_list->u1.Ordinal);
+
+//                 TRACE("--- Ordinal %s,%d\n", name, ordinal);
+                   
+                   thunk_list->u1.Function=LookupExternal(name, ordinal);
+               } else {                
+                   pe_name = (PIMAGE_IMPORT_BY_NAME)RVA(import_list->u1.AddressOfData);
+//                 TRACE("--- %s %s.%d\n", pe_name->Name, name, pe_name->Hint);
+                   thunk_list->u1.Function=LookupExternalByName(name, pe_name->Name);
+               }
+               import_list++;
+               thunk_list++;
+           }
+       } else {        
+           TRACE("Borland style imports used\n");
+           thunk_list = (PIMAGE_THUNK_DATA) RVA(pe_imp->FirstThunk);
+           while (thunk_list->u1.Ordinal) {
+               if (IMAGE_SNAP_BY_ORDINAL(thunk_list->u1.Ordinal)) {
+                   
+                   int ordinal = IMAGE_ORDINAL(thunk_list->u1.Ordinal);
+
+                   TRACE("--- Ordinal %s.%d\n",name,ordinal);
+                   thunk_list->u1.Function=LookupExternal(
+                     name, ordinal);
+               } else {
+                   pe_name=(PIMAGE_IMPORT_BY_NAME) RVA(thunk_list->u1.AddressOfData);
+                   TRACE("--- %s %s.%d\n",
+                                 pe_name->Name,name,pe_name->Hint);
+                   thunk_list->u1.Function=LookupExternalByName(
+                     name, pe_name->Name);
+               }
+               thunk_list++;
+           }
+       }
     }
     return 0;
 }
@@ -367,8 +367,8 @@ static int calc_vma_size( HMODULE hModule )
     TRACE("   Name    VSz  Vaddr     SzRaw   Fileadr  *Reloc *Lineum #Reloc #Linum Char\n");
     for (i = 0; i< PE_HEADER(hModule)->FileHeader.NumberOfSections; i++)
     {
-        TRACE("%8s: %4.4lx %8.8lx %8.8lx %8.8lx %8.8lx %8.8lx %4.4x %4.4x %8.8lx\n",
-                      pe_seg->Name,
+        TRACE("%8s: %4.4lx %8.8lx %8.8lx %8.8lx %8.8lx %8.8lx %4.4x %4.4x %8.8lx\n", 
+                      pe_seg->Name, 
                       pe_seg->Misc.VirtualSize,
                       pe_seg->VirtualAddress,
                       pe_seg->SizeOfRawData,
@@ -388,62 +388,62 @@ static int calc_vma_size( HMODULE hModule )
 static void do_relocations( unsigned int load_addr, IMAGE_BASE_RELOCATION *r )
 {
     int delta = load_addr - PE_HEADER(load_addr)->OptionalHeader.ImageBase;
-    int    hdelta = (delta >> 16) & 0xFFFF;
-    int    ldelta = delta & 0xFFFF;
-
-    if(delta == 0)
-        
-        return;
-    while(r->VirtualAddress)
-    {
-        char *page = (char*) RVA(r->VirtualAddress);
-        int count = (r->SizeOfBlock - 8)/2;
-        int i;
-        TRACE_(fixup)("%x relocations for page %lx\n",
-            count, r->VirtualAddress);
-        
-        for(i=0;i<count;i++)
-        {
-            int offset = r->TypeOffset[i] & 0xFFF;
-            int type = r->TypeOffset[i] >> 12;
-//            TRACE_(fixup)("patching %x type %x\n", offset, type);
-            switch(type)
-            {
-            case IMAGE_REL_BASED_ABSOLUTE: break;
-            case IMAGE_REL_BASED_HIGH:
-                *(short*)(page+offset) += hdelta;
-                break;
-            case IMAGE_REL_BASED_LOW:
-                *(short*)(page+offset) += ldelta;
-                break;
-            case IMAGE_REL_BASED_HIGHLOW:
-                *(int*)(page+offset) += delta;
-                
-                break;
-            case IMAGE_REL_BASED_HIGHADJ:
-                FIXME("Don't know what to do with IMAGE_REL_BASED_HIGHADJ\n");
-                break;
-            case IMAGE_REL_BASED_MIPS_JMPADDR:
-                FIXME("Is this a MIPS machine ???\n");
-                break;
-            default:
-                FIXME("Unknown fixup type\n");
-                break;
-            }
-        }
-        r = (IMAGE_BASE_RELOCATION*)((char*)r + r->SizeOfBlock);
-    }
+    int        hdelta = (delta >> 16) & 0xFFFF;
+    int        ldelta = delta & 0xFFFF;
+
+       if(delta == 0)
+               
+               return;
+       while(r->VirtualAddress)
+       {
+               char *page = (char*) RVA(r->VirtualAddress);
+               int count = (r->SizeOfBlock - 8)/2;
+               int i;
+               TRACE_(fixup)("%x relocations for page %lx\n",
+                       count, r->VirtualAddress);
+               
+               for(i=0;i<count;i++)
+               {
+                       int offset = r->TypeOffset[i] & 0xFFF;
+                       int type = r->TypeOffset[i] >> 12;
+//                     TRACE_(fixup)("patching %x type %x\n", offset, type);
+                       switch(type)
+                       {
+                       case IMAGE_REL_BASED_ABSOLUTE: break;
+                       case IMAGE_REL_BASED_HIGH:
+                               *(short*)(page+offset) += hdelta;
+                               break;
+                       case IMAGE_REL_BASED_LOW:
+                               *(short*)(page+offset) += ldelta;
+                               break;
+                       case IMAGE_REL_BASED_HIGHLOW:
+                               *(int*)(page+offset) += delta;
+                               
+                               break;
+                       case IMAGE_REL_BASED_HIGHADJ:
+                               FIXME("Don't know what to do with IMAGE_REL_BASED_HIGHADJ\n");
+                               break;
+                       case IMAGE_REL_BASED_MIPS_JMPADDR:
+                               FIXME("Is this a MIPS machine ???\n");
+                               break;
+                       default:
+                               FIXME("Unknown fixup type\n");
+                               break;
+                       }
+               }
+               r = (IMAGE_BASE_RELOCATION*)((char*)r + r->SizeOfBlock);
+       }
 }
-        
+               
 
-    
-    
+       
+       
 
 /**********************************************************************
- *            PE_LoadImage
+ *                     PE_LoadImage
  * Load one PE format DLL/EXE into memory
- *
- * Unluckily we can't just mmap the sections where we want them, for
+ * 
+ * Unluckily we can't just mmap the sections where we want them, for 
  * (at least) Linux does only support offsets which are page-aligned.
  *
  * BUT we have to map the whole image anyway, for Win32 programs sometimes
@@ -451,22 +451,22 @@ static void do_relocations( unsigned int load_addr, IMAGE_BASE_RELOCATION *r )
  */
 HMODULE PE_LoadImage( int handle, LPCSTR filename, WORD *version )
 {
-    HMODULE    hModule;
-    HANDLE    mapping;
+    HMODULE    hModule;
+    HANDLE     mapping;
 
     IMAGE_NT_HEADERS *nt;
     IMAGE_SECTION_HEADER *pe_sec;
     IMAGE_DATA_DIRECTORY *dir;
     BY_HANDLE_FILE_INFORMATION bhfi;
-    int    i, rawsize, lowest_va, vma_size, file_size = 0;
+    int        i, rawsize, lowest_va, vma_size, file_size = 0;
     DWORD load_addr = 0, aoep, reloc = 0;
 //    struct get_read_fd_request *req = get_req_buffer();
     int unix_handle = handle;
     int page_size = getpagesize();
 
-//    if ( GetFileInformationByHandle( hFile, &bhfi ) )
-//        file_size = bhfi.nFileSizeLow;
+    
+//    if ( GetFileInformationByHandle( hFile, &bhfi ) ) 
+//     file_size = bhfi.nFileSizeLow; 
     file_size=lseek(handle, 0, SEEK_END);
     lseek(handle, 0, SEEK_SET);
 
@@ -494,14 +494,14 @@ HMODULE PE_LoadImage( int handle, LPCSTR filename, WORD *version )
 
     nt = PE_HEADER( hModule );
 
+    
     if ( nt->Signature != IMAGE_NT_SIGNATURE )
     {
         WARN("%s image doesn't have PE signature, but 0x%08lx\n", filename, nt->Signature );
         goto error;
     }
 
+    
     if ( nt->FileHeader.Machine != IMAGE_FILE_MACHINE_I386 )
     {
         MESSAGE("Trying to load PE image for unsupported architecture (");
@@ -520,29 +520,29 @@ HMODULE PE_LoadImage( int handle, LPCSTR filename, WORD *version )
         goto error;
     }
 
+    
     pe_sec = PE_SECTIONS( hModule );
     rawsize = 0; lowest_va = 0x10000;
-    for (i = 0; i < nt->FileHeader.NumberOfSections; i++)
+    for (i = 0; i < nt->FileHeader.NumberOfSections; i++) 
     {
         if (lowest_va > pe_sec[i].VirtualAddress)
            lowest_va = pe_sec[i].VirtualAddress;
-        if (pe_sec[i].Characteristics & IMAGE_SCN_CNT_UNINITIALIZED_DATA)
-        continue;
-    if (pe_sec[i].PointerToRawData+pe_sec[i].SizeOfRawData > rawsize)
-        rawsize = pe_sec[i].PointerToRawData+pe_sec[i].SizeOfRawData;
+       if (pe_sec[i].Characteristics & IMAGE_SCN_CNT_UNINITIALIZED_DATA)
+           continue;
+       if (pe_sec[i].PointerToRawData+pe_sec[i].SizeOfRawData > rawsize)
+           rawsize = pe_sec[i].PointerToRawData+pe_sec[i].SizeOfRawData;
     }
  
+    
     if ( file_size && file_size < rawsize )
     {
         ERR("PE module is too small (header: %d, filesize: %d), "
-                    "probably truncated download?\n",
+                    "probably truncated download?\n", 
                     rawsize, file_size );
         goto error;
     }
 
+    
     aoep = nt->OptionalHeader.AddressOfEntryPoint;
     if (aoep && (aoep < lowest_va))
         FIXME("VIRUS WARNING: '%s' has an invalid entrypoint (0x%08lx) "
@@ -563,11 +563,11 @@ HMODULE PE_LoadImage( int handle, LPCSTR filename, WORD *version )
 
     if ( nt->OptionalHeader.ImageBase & 0x80000000 )
     {
-        HMODULE sharedMod = (HMODULE)nt->OptionalHeader.ImageBase;
+        HMODULE sharedMod = (HMODULE)nt->OptionalHeader.ImageBase; 
         IMAGE_NT_HEADERS *sharedNt = (PIMAGE_NT_HEADERS)
                ( (LPBYTE)sharedMod + ((LPBYTE)nt - (LPBYTE)hModule) );
 
-        /* Well, this check is not really comprehensive,
+        /* Well, this check is not really comprehensive, 
            but should be good enough for now ... */
         if (    !IsBadReadPtr( (LPBYTE)sharedMod, sizeof(IMAGE_DOS_HEADER) )
              && memcmp( (LPBYTE)sharedMod, (LPBYTE)hModule, sizeof(IMAGE_DOS_HEADER) ) == 0
@@ -580,21 +580,21 @@ HMODULE PE_LoadImage( int handle, LPCSTR filename, WORD *version )
     }
 
 
+    
     load_addr = nt->OptionalHeader.ImageBase;
     vma_size = calc_vma_size( hModule );
 
     load_addr = (DWORD)VirtualAlloc( (void*)load_addr, vma_size,
                                      MEM_RESERVE | MEM_COMMIT,
                                      PAGE_EXECUTE_READWRITE );
-    if (load_addr == 0)
+    if (load_addr == 0) 
     {
+        
         FIXME("We need to perform base relocations for %s\n", filename);
-    dir = nt->OptionalHeader.DataDirectory+IMAGE_DIRECTORY_ENTRY_BASERELOC;
+       dir = nt->OptionalHeader.DataDirectory+IMAGE_DIRECTORY_ENTRY_BASERELOC;
         if (dir->Size)
             reloc = dir->VirtualAddress;
-        else
+        else 
         {
             FIXME( "FATAL: Need to relocate %s, but no relocation records present (%s). Try to run that file directly !\n",
                    filename,
@@ -611,13 +611,13 @@ HMODULE PE_LoadImage( int handle, LPCSTR filename, WORD *version )
             ERR( "Forced to relocate system DLL (base > 2GB). This is not good.\n" );
 
         load_addr = (DWORD)VirtualAlloc( NULL, vma_size,
-                     MEM_RESERVE | MEM_COMMIT,
-                     PAGE_EXECUTE_READWRITE );
-    if (!load_addr) {
+                                        MEM_RESERVE | MEM_COMMIT,
+                                        PAGE_EXECUTE_READWRITE );
+       if (!load_addr) {
             FIXME_(win32)(
                    "FATAL: Couldn't load module %s (out of memory, %d needed)!\n", filename, vma_size);
             goto error;
-    }
+       }
     }
 
     TRACE("Load addr is %lx (base %lx), range %x\n",
@@ -626,13 +626,13 @@ HMODULE PE_LoadImage( int handle, LPCSTR filename, WORD *version )
                     filename, load_addr, vma_size );
 
 #if 0
+    
     *(PIMAGE_DOS_HEADER)load_addr = *(PIMAGE_DOS_HEADER)hModule;
     *PE_HEADER( load_addr ) = *nt;
     memcpy( PE_SECTIONS(load_addr), PE_SECTIONS(hModule),
             sizeof(IMAGE_SECTION_HEADER) * nt->FileHeader.NumberOfSections );
 
+    
     memcpy( load_addr, hModule, lowest_fa );
 #endif
 
@@ -640,11 +640,11 @@ HMODULE PE_LoadImage( int handle, LPCSTR filename, WORD *version )
                      0, 0, PROT_EXEC | PROT_WRITE | PROT_READ,
                      MAP_PRIVATE | MAP_FIXED ) != (void*)load_addr)
     {
-        ERR_(win32)( "Critical Error: failed to map PE header to necessary address.\n");    
+        ERR_(win32)( "Critical Error: failed to map PE header to necessary address.\n");       
         goto error;
     }
 
+    
     pe_sec = PE_SECTIONS( hModule );
     for (i = 0; i < nt->FileHeader.NumberOfSections; i++, pe_sec++)
     {
@@ -657,7 +657,7 @@ HMODULE PE_LoadImage( int handle, LPCSTR filename, WORD *version )
                          PROT_EXEC | PROT_WRITE | PROT_READ,
                          MAP_PRIVATE | MAP_FIXED ) != (void*)RVA(pe_sec->VirtualAddress))
         {
+            
             ERR_(win32)( "Critical Error: failed to map PE section to necessary address.\n");
             goto error;
         }
@@ -674,21 +674,21 @@ HMODULE PE_LoadImage( int handle, LPCSTR filename, WORD *version )
         }
     }
 
+    
     if ( reloc )
         do_relocations( load_addr, (IMAGE_BASE_RELOCATION *)RVA(reloc) );
 
+    
     *version =   ( (nt->OptionalHeader.MajorSubsystemVersion & 0xff) << 8 )
                |   (nt->OptionalHeader.MinorSubsystemVersion & 0xff);
 
+    
     UnmapViewOfFile( (LPVOID)hModule );
     return (HMODULE)load_addr;
 
 error:
     if (unix_handle != -1) close( unix_handle );
-    if (load_addr)
+    if (load_addr) 
     VirtualFree( (LPVOID)load_addr, 0, MEM_RELEASE );
     UnmapViewOfFile( (LPVOID)hModule );
     return 0;
@@ -707,20 +707,20 @@ error:
  * Note: This routine must always be called in the context of the
  *       process that is to own the module to be created.
  */
-WINE_MODREF *PE_CreateModule( HMODULE hModule,
+WINE_MODREF *PE_CreateModule( HMODULE hModule, 
                               LPCSTR filename, DWORD flags, WIN_BOOL builtin )
 {
-    DWORD load_addr = (DWORD)hModule;
+    DWORD load_addr = (DWORD)hModule;  
     IMAGE_NT_HEADERS *nt = PE_HEADER(hModule);
     IMAGE_DATA_DIRECTORY *dir;
     IMAGE_IMPORT_DESCRIPTOR *pe_import = NULL;
     IMAGE_EXPORT_DIRECTORY *pe_export = NULL;
     IMAGE_RESOURCE_DIRECTORY *pe_resource = NULL;
     WINE_MODREF *wm;
-    int    result;
+    int        result;
 
 
+    
 
     dir = nt->OptionalHeader.DataDirectory+IMAGE_DIRECTORY_ENTRY_EXPORT;
     if (dir->Size)
@@ -740,8 +740,8 @@ WINE_MODREF *PE_CreateModule( HMODULE hModule,
     dir = nt->OptionalHeader.DataDirectory+IMAGE_DIRECTORY_ENTRY_SECURITY;
     if (dir->Size) FIXME("Security directory ignored\n" );
 
+    
+    
 
     dir = nt->OptionalHeader.DataDirectory+IMAGE_DIRECTORY_ENTRY_DEBUG;
     if (dir->Size) TRACE("Debug directory ignored\n" );
@@ -752,7 +752,7 @@ WINE_MODREF *PE_CreateModule( HMODULE hModule,
     dir = nt->OptionalHeader.DataDirectory+IMAGE_DIRECTORY_ENTRY_GLOBALPTR;
     if (dir->Size) FIXME("Global Pointer (MIPS) ignored\n" );
 
+    
 
     dir = nt->OptionalHeader.DataDirectory+IMAGE_DIRECTORY_ENTRY_LOAD_CONFIG;
     if (dir->Size) FIXME("Load Configuration directory ignored\n" );
@@ -766,17 +766,17 @@ WINE_MODREF *PE_CreateModule( HMODULE hModule,
     dir = nt->OptionalHeader.DataDirectory+IMAGE_DIRECTORY_ENTRY_DELAY_IMPORT;
     if (dir->Size)
     {
-        TRACE("Delayed import, stub calls LoadLibrary\n" );
-        /*
-         * Nothing to do here.
-         */
+               TRACE("Delayed import, stub calls LoadLibrary\n" );
+               /*
+                * Nothing to do here.
+                */
 
 #ifdef ImgDelayDescr
-        /*
-         * This code is useful to observe what the heck is going on.
-         */
-        {
-        ImgDelayDescr *pe_delay = NULL;
+               /*
+                * This code is useful to observe what the heck is going on.
+                */
+               {
+               ImgDelayDescr *pe_delay = NULL;
         pe_delay = (PImgDelayDescr)RVA(dir->VirtualAddress);
         TRACE_(delayhlp)("pe_delay->grAttrs = %08x\n", pe_delay->grAttrs);
         TRACE_(delayhlp)("pe_delay->szName = %s\n", pe_delay->szName);
@@ -787,8 +787,8 @@ WINE_MODREF *PE_CreateModule( HMODULE hModule,
         TRACE_(delayhlp)("pe_delay->pUnloadIAT = %08x\n", pe_delay->pUnloadIAT);
         TRACE_(delayhlp)("pe_delay->dwTimeStamp = %08x\n", pe_delay->dwTimeStamp);
         }
-#endif
-    }
+#endif 
+       }
 
     dir = nt->OptionalHeader.DataDirectory+IMAGE_DIRECTORY_ENTRY_COM_DESCRIPTOR;
     if (dir->Size) FIXME("Unknown directory 14 ignored\n" );
@@ -797,13 +797,13 @@ WINE_MODREF *PE_CreateModule( HMODULE hModule,
     if (dir->Size) FIXME("Unknown directory 15 ignored\n" );
 
 
+    
 
-    wm = (WINE_MODREF *)HeapAlloc( GetProcessHeap(),
+    wm = (WINE_MODREF *)HeapAlloc( GetProcessHeap(), 
                                    HEAP_ZERO_MEMORY, sizeof(*wm) );
     wm->module = hModule;
 
-    if ( builtin )
+    if ( builtin ) 
         wm->flags |= WINE_MODREF_INTERNAL;
     if ( flags & DONT_RESOLVE_DLL_REFERENCES )
         wm->flags |= WINE_MODREF_DONT_RESOLVE_REFS;
@@ -829,8 +829,8 @@ WINE_MODREF *PE_CreateModule( HMODULE hModule,
 
     if (    pe_import
          && !( wm->flags & WINE_MODREF_LOAD_AS_DATAFILE )
-         && !( wm->flags & WINE_MODREF_DONT_RESOLVE_REFS )
-         && fixup_imports( wm ) )
+         && !( wm->flags & WINE_MODREF_DONT_RESOLVE_REFS ) 
+         && fixup_imports( wm ) ) 
     {
         /* remove entry from modref chain */
          return NULL;
@@ -842,45 +842,45 @@ WINE_MODREF *PE_CreateModule( HMODULE hModule,
 }
 
 /******************************************************************************
- * The PE Library Loader frontend.
+ * The PE Library Loader frontend. 
  * FIXME: handle the flags.
  */
 WINE_MODREF *PE_LoadLibraryExA (LPCSTR name, DWORD flags)
 {
-    HMODULE        hModule32;
-    WINE_MODREF    *wm;
-    char            filename[256];
-    int hFile;
-    WORD        version = 0;
-
-    
-    strncpy(filename, name, sizeof(filename));
-    hFile=open(filename, O_RDONLY);
-    if(hFile==-1)
-        return NULL;
-    
-    
-    hModule32 = PE_LoadImage( hFile, filename, &version );
-    if (!hModule32)
-    {
-        SetLastError( ERROR_OUTOFMEMORY );    
-        return NULL;
-    }
-
-    if ( !(wm = PE_CreateModule( hModule32, filename, flags, FALSE )) )
-    {
-        ERR( "can't load %s\n", filename );
-        SetLastError( ERROR_OUTOFMEMORY );
-        return NULL;
-    }
-    close(hFile);
-    //printf("^^^^^^^^^^^^^^^^Alloc VM1  %p\n", wm);
-    return wm;
+       HMODULE         hModule32;
+       WINE_MODREF     *wm;
+       char            filename[256];
+       int hFile;
+       WORD            version = 0;
+
+       
+       strncpy(filename, name, sizeof(filename));      
+       hFile=open(filename, O_RDONLY);
+       if(hFile==-1)
+           return NULL;
+       
+       
+       hModule32 = PE_LoadImage( hFile, filename, &version );
+       if (!hModule32)
+       {
+               SetLastError( ERROR_OUTOFMEMORY );      
+               return NULL;
+       }
+
+       if ( !(wm = PE_CreateModule( hModule32, filename, flags, FALSE )) )
+       {
+               ERR( "can't load %s\n", filename );
+               SetLastError( ERROR_OUTOFMEMORY );
+               return NULL;
+       }
+       close(hFile);
+       //printf("^^^^^^^^^^^^^^^^Alloc VM1  %p\n", wm);
+       return wm;
 }
 
 
 /*****************************************************************************
- *    PE_UnloadLibrary
+ *     PE_UnloadLibrary
  *
  * Unload the library unmapping the image and freeing the modref structure.
  */
@@ -889,9 +889,9 @@ void PE_UnloadLibrary(WINE_MODREF *wm)
     TRACE(" unloading %s\n", wm->filename);
 
     if (wm->filename)
-    free(wm->filename);
+       free(wm->filename);
     if (wm->short_filename)
-    free(wm->short_filename);
+       free(wm->short_filename);
     HeapFree( GetProcessHeap(), 0, wm->deps );
     VirtualFree( (LPVOID)wm->module, 0, MEM_RELEASE );
     HeapFree( GetProcessHeap(), 0, wm );
@@ -937,37 +937,37 @@ WIN_BOOL PE_InitDLL( WINE_MODREF *wm, DWORD type, LPVOID lpReserved )
     WIN_BOOL retv = TRUE;
     assert( wm->type == MODULE32_PE );
 
+    
     if ((PE_HEADER(wm->module)->FileHeader.Characteristics & IMAGE_FILE_DLL) &&
         (PE_HEADER(wm->module)->OptionalHeader.AddressOfEntryPoint)
     ) {
-    DLLENTRYPROC entry ;
-    entry = (void*)PE_FindExportedFunction(wm, "DllMain", 0);
-    if(entry==NULL)
-        entry = (void*)RVA_PTR( wm->module,OptionalHeader.AddressOfEntryPoint );
-    TRACE_(relay)("CallTo32(entryproc=%p,module=%08x,type=%ld,res=%p)\n",
+       DLLENTRYPROC entry ;
+       entry = (void*)PE_FindExportedFunction(wm, "DllMain", 0);
+       if(entry==NULL)
+           entry = (void*)RVA_PTR( wm->module,OptionalHeader.AddressOfEntryPoint );
+        
+       TRACE_(relay)("CallTo32(entryproc=%p,module=%08x,type=%ld,res=%p)\n",
                        entry, wm->module, type, lpReserved );
-    
-    
-    TRACE("Entering DllMain(");
-    switch(type)
-    {
-        case DLL_PROCESS_DETACH:
-            TRACE("DLL_PROCESS_DETACH) ");
-        break;
-        case DLL_PROCESS_ATTACH:
-            TRACE("DLL_PROCESS_ATTACH) ");
-        break;
-        case DLL_THREAD_DETACH:
-            TRACE("DLL_THREAD_DETACH) ");
-        break;
-        case DLL_THREAD_ATTACH:
-            TRACE("DLL_THREAD_ATTACH) ");
-        break;
-    }    
-    TRACE("for %s\n", wm->filename);
-    extend_stack_for_dll_alloca();
+       
+       
+       TRACE("Entering DllMain(");
+       switch(type)
+       {
+           case DLL_PROCESS_DETACH:
+               TRACE("DLL_PROCESS_DETACH) ");
+               break;
+           case DLL_PROCESS_ATTACH:
+               TRACE("DLL_PROCESS_ATTACH) ");
+               break;
+           case DLL_THREAD_DETACH:
+               TRACE("DLL_THREAD_DETACH) ");
+               break;
+           case DLL_THREAD_ATTACH:
+               TRACE("DLL_THREAD_ATTACH) ");
+               break;
+       }       
+       TRACE("for %s\n", wm->filename);
+       extend_stack_for_dll_alloca();
         retv = entry( wm->module, type, lpReserved );
     }
 
@@ -976,12 +976,12 @@ WIN_BOOL PE_InitDLL( WINE_MODREF *wm, DWORD type, LPVOID lpReserved )
 
 static LPVOID
 _fixup_address(PIMAGE_OPTIONAL_HEADER opt,int delta,LPVOID addr) {
-    if (    ((DWORD)addr>opt->ImageBase) &&
-        ((DWORD)addr<opt->ImageBase+opt->SizeOfImage)
-    )
-        
-        return (LPVOID)(((DWORD)addr)+delta);
-    else
-        
-        return addr;
+       if (    ((DWORD)addr>opt->ImageBase) &&
+               ((DWORD)addr<opt->ImageBase+opt->SizeOfImage)
+       )
+               
+               return (LPVOID)(((DWORD)addr)+delta);
+       else
+               
+               return addr;
 }
index ff091b0..5e54e5e 100644 (file)
 #include "ext.h"
 
 /**********************************************************************
- *  HMODULE32toPE_MODREF
+ *  HMODULE32toPE_MODREF 
  *
  * small helper function to get a PE_MODREF from a passed HMODULE32
  */
 static PE_MODREF*
 HMODULE32toPE_MODREF(HMODULE hmod) {
-    WINE_MODREF    *wm;
+       WINE_MODREF     *wm;
 
-    wm = MODULE32_LookupHMODULE( hmod );
-    if (!wm || wm->type!=MODULE32_PE)
-        return NULL;
-    return &(wm->binfmt.pe);
+       wm = MODULE32_LookupHMODULE( hmod );
+       if (!wm || wm->type!=MODULE32_PE)
+               return NULL;
+       return &(wm->binfmt.pe);
 }
 
 /**********************************************************************
- *        GetResDirEntryW
+ *         GetResDirEntryW
  *
- *    Helper function - goes down one level of PE resource tree
+ *     Helper function - goes down one level of PE resource tree
  *
  */
 PIMAGE_RESOURCE_DIRECTORY GetResDirEntryW(PIMAGE_RESOURCE_DIRECTORY resdirptr,
-                       LPCWSTR name,DWORD root,
-                       WIN_BOOL allowdefault)
+                                          LPCWSTR name,DWORD root,
+                                          WIN_BOOL allowdefault)
 {
     int entrynum;
     PIMAGE_RESOURCE_DIRECTORY_ENTRY entryTable;
     int namelen;
 
     if (HIWORD(name)) {
-        if (name[0]=='#') {
-        char    buf[10];
-
-        lstrcpynWtoA(buf,name+1,10);
-        return GetResDirEntryW(resdirptr,(LPCWSTR)atoi(buf),root,allowdefault);
-    }
-    entryTable = (PIMAGE_RESOURCE_DIRECTORY_ENTRY) (
-            (BYTE *) resdirptr +
+       if (name[0]=='#') {
+               char    buf[10];
+
+               lstrcpynWtoA(buf,name+1,10);
+               return GetResDirEntryW(resdirptr,(LPCWSTR)atoi(buf),root,allowdefault);
+       }
+       entryTable = (PIMAGE_RESOURCE_DIRECTORY_ENTRY) (
+                       (BYTE *) resdirptr + 
                         sizeof(IMAGE_RESOURCE_DIRECTORY));
-    namelen = lstrlenW(name);
-    for (entrynum = 0; entrynum < resdirptr->NumberOfNamedEntries; entrynum++)
-    {
-        PIMAGE_RESOURCE_DIR_STRING_U str =
-        (PIMAGE_RESOURCE_DIR_STRING_U) (root +
-            entryTable[entrynum].u1.s.NameOffset);
-        if(namelen != str->Length)
-            continue;
-        if(wcsnicmp(name,str->NameString,str->Length)==0)
-            return (PIMAGE_RESOURCE_DIRECTORY) (
-                root +
-                entryTable[entrynum].u2.s.OffsetToDirectory);
-    }
-    return NULL;
+       namelen = lstrlenW(name);
+       for (entrynum = 0; entrynum < resdirptr->NumberOfNamedEntries; entrynum++)
+       {
+               PIMAGE_RESOURCE_DIR_STRING_U str =
+               (PIMAGE_RESOURCE_DIR_STRING_U) (root + 
+                       entryTable[entrynum].u1.s.NameOffset);
+               if(namelen != str->Length)
+                       continue;
+               if(wcsnicmp(name,str->NameString,str->Length)==0)
+                       return (PIMAGE_RESOURCE_DIRECTORY) (
+                               root +
+                               entryTable[entrynum].u2.s.OffsetToDirectory);
+       }
+       return NULL;
     } else {
-    entryTable = (PIMAGE_RESOURCE_DIRECTORY_ENTRY) (
-            (BYTE *) resdirptr +
+       entryTable = (PIMAGE_RESOURCE_DIRECTORY_ENTRY) (
+                       (BYTE *) resdirptr + 
                         sizeof(IMAGE_RESOURCE_DIRECTORY) +
-            resdirptr->NumberOfNamedEntries * sizeof(IMAGE_RESOURCE_DIRECTORY_ENTRY));
-    for (entrynum = 0; entrynum < resdirptr->NumberOfIdEntries; entrynum++)
-        if ((DWORD)entryTable[entrynum].u1.Name == (DWORD)name)
-        return (PIMAGE_RESOURCE_DIRECTORY) (
-            root +
-            entryTable[entrynum].u2.s.OffsetToDirectory);
-    /* just use first entry if no default can be found */
-    if (allowdefault && !name && resdirptr->NumberOfIdEntries)
-        return (PIMAGE_RESOURCE_DIRECTORY) (
-            root +
-            entryTable[0].u2.s.OffsetToDirectory);
-    return NULL;
+                       resdirptr->NumberOfNamedEntries * sizeof(IMAGE_RESOURCE_DIRECTORY_ENTRY));
+       for (entrynum = 0; entrynum < resdirptr->NumberOfIdEntries; entrynum++)
+           if ((DWORD)entryTable[entrynum].u1.Name == (DWORD)name)
+               return (PIMAGE_RESOURCE_DIRECTORY) (
+                       root +
+                       entryTable[entrynum].u2.s.OffsetToDirectory);
+       /* just use first entry if no default can be found */
+       if (allowdefault && !name && resdirptr->NumberOfIdEntries)
+               return (PIMAGE_RESOURCE_DIRECTORY) (
+                       root +
+                       entryTable[0].u2.s.OffsetToDirectory);
+       return NULL;
     }
 }
 
 /**********************************************************************
- *        GetResDirEntryA
+ *         GetResDirEntryA
  */
 PIMAGE_RESOURCE_DIRECTORY GetResDirEntryA( PIMAGE_RESOURCE_DIRECTORY resdirptr,
-                       LPCSTR name, DWORD root,
-                       WIN_BOOL allowdefault )
+                                          LPCSTR name, DWORD root,
+                                          WIN_BOOL allowdefault )
 {
     PIMAGE_RESOURCE_DIRECTORY retv;
-    LPWSTR nameW = HIWORD(name)? HEAP_strdupAtoW( GetProcessHeap(), 0, name )
+    LPWSTR nameW = HIWORD(name)? HEAP_strdupAtoW( GetProcessHeap(), 0, name ) 
                                : (LPWSTR)name;
 
     retv = GetResDirEntryW( resdirptr, nameW, root, allowdefault );
@@ -135,27 +135,27 @@ PIMAGE_RESOURCE_DIRECTORY GetResDirEntryA( PIMAGE_RESOURCE_DIRECTORY resdirptr,
 }
 
 /**********************************************************************
- *        PE_FindResourceEx32W
+ *         PE_FindResourceEx32W
  */
 HANDLE PE_FindResourceExW(
-    WINE_MODREF *wm,LPCWSTR name,LPCWSTR type,WORD lang
+       WINE_MODREF *wm,LPCWSTR name,LPCWSTR type,WORD lang
 ) {
     PIMAGE_RESOURCE_DIRECTORY resdirptr;
     DWORD root;
     HANDLE result;
-    PE_MODREF    *pem = &(wm->binfmt.pe);
+    PE_MODREF  *pem = &(wm->binfmt.pe);
 
     if (!pem || !pem->pe_resource)
-        return 0;
+       return 0;
 
     resdirptr = pem->pe_resource;
     root = (DWORD) resdirptr;
     if ((resdirptr = GetResDirEntryW(resdirptr, type, root, FALSE)) == NULL)
-    return 0;
+       return 0;
     if ((resdirptr = GetResDirEntryW(resdirptr, name, root, FALSE)) == NULL)
-    return 0;
+       return 0;
     result = (HANDLE)GetResDirEntryW(resdirptr, (LPCWSTR)(UINT)lang, root, FALSE);
-    /* Try LANG_NEUTRAL, too */
+       /* Try LANG_NEUTRAL, too */
     if(!result)
         return (HANDLE)GetResDirEntryW(resdirptr, (LPCWSTR)0, root, TRUE);
     return result;
@@ -163,250 +163,250 @@ HANDLE PE_FindResourceExW(
 
 
 /**********************************************************************
- *        PE_LoadResource32
+ *         PE_LoadResource32
  */
 HANDLE PE_LoadResource( WINE_MODREF *wm, HANDLE hRsrc )
 {
     if (!hRsrc || !wm || wm->type!=MODULE32_PE)
-        return 0;
+       return 0;
     return (HANDLE) (wm->module + ((PIMAGE_RESOURCE_DATA_ENTRY)hRsrc)->OffsetToData);
 }
 
 
 /**********************************************************************
- *        PE_SizeofResource32
+ *         PE_SizeofResource32
  */
 DWORD PE_SizeofResource( HINSTANCE hModule, HANDLE hRsrc )
 {
     /* we don't need hModule */
     if (!hRsrc)
-        return 0;
+        return 0;
     return ((PIMAGE_RESOURCE_DATA_ENTRY)hRsrc)->Size;
 }
 
 /**********************************************************************
- *        PE_EnumResourceTypes32A
+ *         PE_EnumResourceTypes32A
  */
 WIN_BOOL
 PE_EnumResourceTypesA(HMODULE hmod,ENUMRESTYPEPROCA lpfun,LONG lparam) {
-    PE_MODREF    *pem = HMODULE32toPE_MODREF(hmod);
-    int        i;
-    PIMAGE_RESOURCE_DIRECTORY        resdir;
-    PIMAGE_RESOURCE_DIRECTORY_ENTRY    et;
-    WIN_BOOL    ret;
-    HANDLE    heap = GetProcessHeap();    
+    PE_MODREF  *pem = HMODULE32toPE_MODREF(hmod);
+    int                i;
+    PIMAGE_RESOURCE_DIRECTORY          resdir;
+    PIMAGE_RESOURCE_DIRECTORY_ENTRY    et;
+    WIN_BOOL   ret;
+    HANDLE     heap = GetProcessHeap();        
 
     if (!pem || !pem->pe_resource)
-        return FALSE;
+       return FALSE;
 
     resdir = (PIMAGE_RESOURCE_DIRECTORY)pem->pe_resource;
     et =(PIMAGE_RESOURCE_DIRECTORY_ENTRY)((LPBYTE)resdir+sizeof(IMAGE_RESOURCE_DIRECTORY));
     ret = FALSE;
     for (i=0;i<resdir->NumberOfNamedEntries+resdir->NumberOfIdEntries;i++) {
-        LPSTR    name;
-
-    if (et[i].u1.s.NameIsString)
-        name = HEAP_strdupWtoA(heap,0,(LPWSTR)((LPBYTE)pem->pe_resource+et[i].u1.s.NameOffset));
-    else
-        name = (LPSTR)(int)et[i].u1.Id;
-    ret = lpfun(hmod,name,lparam);
-    if (HIWORD(name))
-        HeapFree(heap,0,name);
-    if (!ret)
-        break;
+       LPSTR   name;
+
+       if (et[i].u1.s.NameIsString)
+               name = HEAP_strdupWtoA(heap,0,(LPWSTR)((LPBYTE)pem->pe_resource+et[i].u1.s.NameOffset));
+       else
+               name = (LPSTR)(int)et[i].u1.Id;
+       ret = lpfun(hmod,name,lparam);
+       if (HIWORD(name))
+               HeapFree(heap,0,name);
+       if (!ret)
+               break;
     }
     return ret;
 }
 
 /**********************************************************************
- *        PE_EnumResourceTypes32W
+ *         PE_EnumResourceTypes32W
  */
 WIN_BOOL
 PE_EnumResourceTypesW(HMODULE hmod,ENUMRESTYPEPROCW lpfun,LONG lparam) {
-    PE_MODREF    *pem = HMODULE32toPE_MODREF(hmod);
-    int        i;
-    PIMAGE_RESOURCE_DIRECTORY        resdir;
-    PIMAGE_RESOURCE_DIRECTORY_ENTRY    et;
-    WIN_BOOL    ret;
+    PE_MODREF  *pem = HMODULE32toPE_MODREF(hmod);
+    int                i;
+    PIMAGE_RESOURCE_DIRECTORY          resdir;
+    PIMAGE_RESOURCE_DIRECTORY_ENTRY    et;
+    WIN_BOOL   ret;
 
     if (!pem || !pem->pe_resource)
-        return FALSE;
+       return FALSE;
 
     resdir = (PIMAGE_RESOURCE_DIRECTORY)pem->pe_resource;
     et =(PIMAGE_RESOURCE_DIRECTORY_ENTRY)((LPBYTE)resdir+sizeof(IMAGE_RESOURCE_DIRECTORY));
     ret = FALSE;
     for (i=0;i<resdir->NumberOfNamedEntries+resdir->NumberOfIdEntries;i++) {
-    LPWSTR    type;
-        if (et[i].u1.s.NameIsString)
-        type = (LPWSTR)((LPBYTE)pem->pe_resource+et[i].u1.s.NameOffset);
-    else
-        type = (LPWSTR)(int)et[i].u1.Id;
-
-    ret = lpfun(hmod,type,lparam);
-    if (!ret)
-        break;
+       LPWSTR  type;
+       if (et[i].u1.s.NameIsString)
+               type = (LPWSTR)((LPBYTE)pem->pe_resource+et[i].u1.s.NameOffset);
+       else
+               type = (LPWSTR)(int)et[i].u1.Id;
+
+       ret = lpfun(hmod,type,lparam);
+       if (!ret)
+               break;
     }
     return ret;
 }
 
 /**********************************************************************
- *        PE_EnumResourceNames32A
+ *         PE_EnumResourceNames32A
  */
 WIN_BOOL
 PE_EnumResourceNamesA(
-    HMODULE hmod,LPCSTR type,ENUMRESNAMEPROCA lpfun,LONG lparam
+       HMODULE hmod,LPCSTR type,ENUMRESNAMEPROCA lpfun,LONG lparam
 ) {
-    PE_MODREF    *pem = HMODULE32toPE_MODREF(hmod);
-    int        i;
-    PIMAGE_RESOURCE_DIRECTORY        resdir;
-    PIMAGE_RESOURCE_DIRECTORY_ENTRY    et;
-    WIN_BOOL    ret;
-    HANDLE    heap = GetProcessHeap();    
-    LPWSTR    typeW;
+    PE_MODREF  *pem = HMODULE32toPE_MODREF(hmod);
+    int                i;
+    PIMAGE_RESOURCE_DIRECTORY          resdir;
+    PIMAGE_RESOURCE_DIRECTORY_ENTRY    et;
+    WIN_BOOL   ret;
+    HANDLE     heap = GetProcessHeap();        
+    LPWSTR     typeW;
 
     if (!pem || !pem->pe_resource)
-        return FALSE;
+       return FALSE;
     resdir = (PIMAGE_RESOURCE_DIRECTORY)pem->pe_resource;
     if (HIWORD(type))
-    typeW = HEAP_strdupAtoW(heap,0,type);
+       typeW = HEAP_strdupAtoW(heap,0,type);
     else
-    typeW = (LPWSTR)type;
+       typeW = (LPWSTR)type;
     resdir = GetResDirEntryW(resdir,typeW,(DWORD)pem->pe_resource,FALSE);
     if (HIWORD(typeW))
-        HeapFree(heap,0,typeW);
+       HeapFree(heap,0,typeW);
     if (!resdir)
-        return FALSE;
+       return FALSE;
     et =(PIMAGE_RESOURCE_DIRECTORY_ENTRY)((LPBYTE)resdir+sizeof(IMAGE_RESOURCE_DIRECTORY));
     ret = FALSE;
     for (i=0;i<resdir->NumberOfNamedEntries+resdir->NumberOfIdEntries;i++) {
-        LPSTR    name;
-
-    if (et[i].u1.s.NameIsString)
-        name = HEAP_strdupWtoA(heap,0,(LPWSTR)((LPBYTE)pem->pe_resource+et[i].u1.s.NameOffset));
-    else
-        name = (LPSTR)(int)et[i].u1.Id;
-    ret = lpfun(hmod,type,name,lparam);
-    if (HIWORD(name)) HeapFree(heap,0,name);
-    if (!ret)
-        break;
+       LPSTR   name;
+
+       if (et[i].u1.s.NameIsString)
+           name = HEAP_strdupWtoA(heap,0,(LPWSTR)((LPBYTE)pem->pe_resource+et[i].u1.s.NameOffset));
+       else
+           name = (LPSTR)(int)et[i].u1.Id;
+       ret = lpfun(hmod,type,name,lparam);
+       if (HIWORD(name)) HeapFree(heap,0,name);
+       if (!ret)
+               break;
     }
     return ret;
 }
 
 /**********************************************************************
- *        PE_EnumResourceNames32W
+ *         PE_EnumResourceNames32W
  */
 WIN_BOOL
 PE_EnumResourceNamesW(
-    HMODULE hmod,LPCWSTR type,ENUMRESNAMEPROCW lpfun,LONG lparam
+       HMODULE hmod,LPCWSTR type,ENUMRESNAMEPROCW lpfun,LONG lparam
 ) {
-    PE_MODREF    *pem = HMODULE32toPE_MODREF(hmod);
-    int        i;
-    PIMAGE_RESOURCE_DIRECTORY        resdir;
-    PIMAGE_RESOURCE_DIRECTORY_ENTRY    et;
-    WIN_BOOL    ret;
+    PE_MODREF  *pem = HMODULE32toPE_MODREF(hmod);
+    int                i;
+    PIMAGE_RESOURCE_DIRECTORY          resdir;
+    PIMAGE_RESOURCE_DIRECTORY_ENTRY    et;
+    WIN_BOOL   ret;
 
     if (!pem || !pem->pe_resource)
-        return FALSE;
+       return FALSE;
 
     resdir = (PIMAGE_RESOURCE_DIRECTORY)pem->pe_resource;
     resdir = GetResDirEntryW(resdir,type,(DWORD)pem->pe_resource,FALSE);
     if (!resdir)
-        return FALSE;
+       return FALSE;
     et =(PIMAGE_RESOURCE_DIRECTORY_ENTRY)((LPBYTE)resdir+sizeof(IMAGE_RESOURCE_DIRECTORY));
     ret = FALSE;
     for (i=0;i<resdir->NumberOfNamedEntries+resdir->NumberOfIdEntries;i++) {
-    LPWSTR    name;
-        if (et[i].u1.s.NameIsString)
-        name = (LPWSTR)((LPBYTE)pem->pe_resource+et[i].u1.s.NameOffset);
-    else
-        name = (LPWSTR)(int)et[i].u1.Id;
-    ret = lpfun(hmod,type,name,lparam);
-    if (!ret)
-        break;
+       LPWSTR  name;
+       if (et[i].u1.s.NameIsString)
+               name = (LPWSTR)((LPBYTE)pem->pe_resource+et[i].u1.s.NameOffset);
+       else
+               name = (LPWSTR)(int)et[i].u1.Id;
+       ret = lpfun(hmod,type,name,lparam);
+       if (!ret)
+               break;
     }
     return ret;
 }
 
 /**********************************************************************
- *        PE_EnumResourceNames32A
+ *         PE_EnumResourceNames32A
  */
 WIN_BOOL
 PE_EnumResourceLanguagesA(
-    HMODULE hmod,LPCSTR name,LPCSTR type,ENUMRESLANGPROCA lpfun,
-    LONG lparam
+       HMODULE hmod,LPCSTR name,LPCSTR type,ENUMRESLANGPROCA lpfun,
+       LONG lparam
 ) {
-    PE_MODREF    *pem = HMODULE32toPE_MODREF(hmod);
-    int        i;
-    PIMAGE_RESOURCE_DIRECTORY        resdir;
-    PIMAGE_RESOURCE_DIRECTORY_ENTRY    et;
-    WIN_BOOL    ret;
-    HANDLE    heap = GetProcessHeap();    
-    LPWSTR    nameW,typeW;
+    PE_MODREF  *pem = HMODULE32toPE_MODREF(hmod);
+    int                i;
+    PIMAGE_RESOURCE_DIRECTORY          resdir;
+    PIMAGE_RESOURCE_DIRECTORY_ENTRY    et;
+    WIN_BOOL   ret;
+    HANDLE     heap = GetProcessHeap();        
+    LPWSTR     nameW,typeW;
 
     if (!pem || !pem->pe_resource)
-        return FALSE;
+       return FALSE;
 
     resdir = (PIMAGE_RESOURCE_DIRECTORY)pem->pe_resource;
     if (HIWORD(name))
-    nameW = HEAP_strdupAtoW(heap,0,name);
+       nameW = HEAP_strdupAtoW(heap,0,name);
     else
-        nameW = (LPWSTR)name;
+       nameW = (LPWSTR)name;
     resdir = GetResDirEntryW(resdir,nameW,(DWORD)pem->pe_resource,FALSE);
     if (HIWORD(nameW))
-        HeapFree(heap,0,nameW);
+       HeapFree(heap,0,nameW);
     if (!resdir)
-        return FALSE;
+       return FALSE;
     if (HIWORD(type))
-    typeW = HEAP_strdupAtoW(heap,0,type);
+       typeW = HEAP_strdupAtoW(heap,0,type);
     else
-    typeW = (LPWSTR)type;
+       typeW = (LPWSTR)type;
     resdir = GetResDirEntryW(resdir,typeW,(DWORD)pem->pe_resource,FALSE);
     if (HIWORD(typeW))
-        HeapFree(heap,0,typeW);
+       HeapFree(heap,0,typeW);
     if (!resdir)
-        return FALSE;
+       return FALSE;
     et =(PIMAGE_RESOURCE_DIRECTORY_ENTRY)((LPBYTE)resdir+sizeof(IMAGE_RESOURCE_DIRECTORY));
     ret = FALSE;
     for (i=0;i<resdir->NumberOfNamedEntries+resdir->NumberOfIdEntries;i++) {
-        /* languages are just ids... I hopem */
-    ret = lpfun(hmod,name,type,et[i].u1.Id,lparam);
-    if (!ret)
-        break;
+       /* languages are just ids... I hopem */
+       ret = lpfun(hmod,name,type,et[i].u1.Id,lparam);
+       if (!ret)
+               break;
     }
     return ret;
 }
 
 /**********************************************************************
- *        PE_EnumResourceLanguages32W
+ *         PE_EnumResourceLanguages32W
  */
 WIN_BOOL
 PE_EnumResourceLanguagesW(
-    HMODULE hmod,LPCWSTR name,LPCWSTR type,ENUMRESLANGPROCW lpfun,
-    LONG lparam
+       HMODULE hmod,LPCWSTR name,LPCWSTR type,ENUMRESLANGPROCW lpfun,
+       LONG lparam
 ) {
-    PE_MODREF    *pem = HMODULE32toPE_MODREF(hmod);
-    int        i;
-    PIMAGE_RESOURCE_DIRECTORY        resdir;
-    PIMAGE_RESOURCE_DIRECTORY_ENTRY    et;
-    WIN_BOOL    ret;
+    PE_MODREF  *pem = HMODULE32toPE_MODREF(hmod);
+    int                i;
+    PIMAGE_RESOURCE_DIRECTORY          resdir;
+    PIMAGE_RESOURCE_DIRECTORY_ENTRY    et;
+    WIN_BOOL   ret;
 
     if (!pem || !pem->pe_resource)
-        return FALSE;
+       return FALSE;
 
     resdir = (PIMAGE_RESOURCE_DIRECTORY)pem->pe_resource;
     resdir = GetResDirEntryW(resdir,name,(DWORD)pem->pe_resource,FALSE);
     if (!resdir)
-        return FALSE;
+       return FALSE;
     resdir = GetResDirEntryW(resdir,type,(DWORD)pem->pe_resource,FALSE);
     if (!resdir)
-        return FALSE;
+       return FALSE;
     et =(PIMAGE_RESOURCE_DIRECTORY_ENTRY)((LPBYTE)resdir+sizeof(IMAGE_RESOURCE_DIRECTORY));
     ret = FALSE;
     for (i=0;i<resdir->NumberOfNamedEntries+resdir->NumberOfIdEntries;i++) {
-    ret = lpfun(hmod,name,type,et[i].u1.Id,lparam);
-    if (!ret)
-        break;
+       ret = lpfun(hmod,name,type,et[i].u1.Id,lparam);
+       if (!ret)
+               break;
     }
     return ret;
 }
index a3530ca..4609124 100644 (file)
@@ -336,31 +336,31 @@ typedef GrafPtr                         CGrafPtr;
 
 /*  codec capabilities flags    */
 enum {
-    codecCanScale               = 1L << 0,    // 1
-    codecCanMask                = 1L << 1,    // 2
-    codecCanMatte               = 1L << 2,    // 4
-    codecCanTransform           = 1L << 3,    // 8
-    codecCanTransferMode        = 1L << 4,    // 10
-    codecCanCopyPrev            = 1L << 5,    // 20
-    codecCanSpool               = 1L << 6,    // 40
-    codecCanClipVertical        = 1L << 7,    // 80
-    codecCanClipRectangular     = 1L << 8,    // 100
-    codecCanRemapColor          = 1L << 9,    // 200
-    codecCanFastDither          = 1L << 10,    // 400
-    codecCanSrcExtract          = 1L << 11,    // 800
-    codecCanCopyPrevComp        = 1L << 12,    // 1000
-    codecCanAsync               = 1L << 13,    // 2000
-    codecCanMakeMask            = 1L << 14,    // 4000
-    codecCanShift               = 1L << 15,    // 8000
-    codecCanAsyncWhen           = 1L << 16,    // 10000
-    codecCanShieldCursor        = 1L << 17,    // 20000
-    codecCanManagePrevBuffer    = 1L << 18,    // 40000
+    codecCanScale               = 1L << 0,     // 1
+    codecCanMask                = 1L << 1,     // 2
+    codecCanMatte               = 1L << 2,     // 4
+    codecCanTransform           = 1L << 3,     // 8
+    codecCanTransferMode        = 1L << 4,     // 10
+    codecCanCopyPrev            = 1L << 5,     // 20
+    codecCanSpool               = 1L << 6,     // 40
+    codecCanClipVertical        = 1L << 7,     // 80
+    codecCanClipRectangular     = 1L << 8,     // 100
+    codecCanRemapColor          = 1L << 9,     // 200
+    codecCanFastDither          = 1L << 10,    // 400
+    codecCanSrcExtract          = 1L << 11,    // 800
+    codecCanCopyPrevComp        = 1L << 12,    // 1000
+    codecCanAsync               = 1L << 13,    // 2000
+    codecCanMakeMask            = 1L << 14,    // 4000
+    codecCanShift               = 1L << 15,    // 8000
+    codecCanAsyncWhen           = 1L << 16,    // 10000
+    codecCanShieldCursor        = 1L << 17,    // 20000
+    codecCanManagePrevBuffer    = 1L << 18,    // 40000
     codecHasVolatileBuffer      = 1L << 19,     // 80000                /* codec requires redraw after window movement */
-    codecWantsRegionMask        = 1L << 20,    // 100000
+    codecWantsRegionMask        = 1L << 20,    // 100000
     codecImageBufferIsOnScreen  = 1L << 21,     // 200000                /* old def of codec using overlay surface, = ( codecIsDirectToScreenOnly | codecUsesOverlaySurface | codecImageBufferIsOverlaySurface | codecSrcMustBeImageBuffer ) */
     codecWantsDestinationPixels = 1L << 22,     // 400000
     codecWantsSpecialScaling    = 1L << 23,     // 800000
-    codecHandlesInputs          = 1L << 24,    // 1000000
+    codecHandlesInputs          = 1L << 24,    // 1000000
     codecCanDoIndirectSurface   = 1L << 25,                     /* codec can handle indirect surface (GDI) */
     codecIsSequenceSensitive    = 1L << 26,
     codecRequiresOffscreen      = 1L << 27,
@@ -382,24 +382,24 @@ enum {
 /*  codec condition flags   */
 // FFD =  13 = 8+4+1
 enum {
-    codecConditionFirstBand     = 1L << 0,    // 1
-    codecConditionLastBand      = 1L << 1,    // 2
-    codecConditionFirstFrame    = 1L << 2,    // 4
-    codecConditionNewDepth      = 1L << 3,    // 8
-    codecConditionNewTransform  = 1L << 4,    // 10
-    codecConditionNewSrcRect    = 1L << 5,    // 20
-    codecConditionNewMask       = 1L << 6,    // 40
-    codecConditionNewMatte      = 1L << 7,    // 80
-    codecConditionNewTransferMode = 1L << 8,    // 100
-    codecConditionNewClut       = 1L << 9,    // 200
-    codecConditionNewAccuracy   = 1L << 10,    // 400
-    codecConditionNewDestination = 1L << 11,    // 800
-    codecConditionFirstScreen   = 1L << 12,    // 1000
-    codecConditionDoCursor      = 1L << 13,    // 2000
-    codecConditionCatchUpDiff   = 1L << 14,    // 4000
-    codecConditionMaskMayBeChanged = 1L << 15,    // 8000
-    codecConditionToBuffer      = 1L << 16,    // 10000
-    codecConditionCodecChangedMask = 1L << 31    // 20000
+    codecConditionFirstBand     = 1L << 0,     // 1
+    codecConditionLastBand      = 1L << 1,     // 2
+    codecConditionFirstFrame    = 1L << 2,     // 4
+    codecConditionNewDepth      = 1L << 3,     // 8
+    codecConditionNewTransform  = 1L << 4,     // 10
+    codecConditionNewSrcRect    = 1L << 5,     // 20
+    codecConditionNewMask       = 1L << 6,     // 40
+    codecConditionNewMatte      = 1L << 7,     // 80
+    codecConditionNewTransferMode = 1L << 8,   // 100
+    codecConditionNewClut       = 1L << 9,     // 200
+    codecConditionNewAccuracy   = 1L << 10,    // 400
+    codecConditionNewDestination = 1L << 11,   // 800
+    codecConditionFirstScreen   = 1L << 12,    // 1000
+    codecConditionDoCursor      = 1L << 13,    // 2000
+    codecConditionCatchUpDiff   = 1L << 14,    // 4000
+    codecConditionMaskMayBeChanged = 1L << 15, // 8000
+    codecConditionToBuffer      = 1L << 16,    // 10000
+    codecConditionCodecChangedMask = 1L << 31  // 20000
 };
 
 
@@ -627,8 +627,8 @@ static inline void dump_ImageDescription(void* xxx){
     int i;
 
     for(i=0;i<id->idSize;i++){
-    printf(" %02X",((unsigned char*)id)[i]);
-    if((i%16)==15) printf("\n");
+       printf(" %02X",((unsigned char*)id)[i]);
+       if((i%16)==15) printf("\n");
     }
     printf("\n");
 
@@ -637,16 +637,16 @@ static inline void dump_ImageDescription(void* xxx){
     printf("idSize=0x%X  fourcc=0x%08X\n",id->idSize,id->cType);
     printf("ver=%d rev=%d vendor=0x%08X\n",id->version,id->revisionLevel,id->vendor);
     printf("tempQ=%d spatQ=%d  dim: %d x %d  dpi: %d x %d  depth: %d\n",
-    id->temporalQuality,id->spatialQuality,
-    id->width, id->height,
-    id->hRes, id->vRes,
-    id->depth);
+       id->temporalQuality,id->spatialQuality,
+       id->width, id->height,
+       id->hRes, id->vRes,
+       id->depth);
     printf("dataSize=%d frameCount=%d clutID=%d\n",id->dataSize, id->frameCount, id->clutID);
     printf("name='%.*s'\n",((char*)(&id->name))[0],((char*)(&id->name))+1);
     x=((char*)(&id->clutID))+2;
     if(id->idSize>sizeof(ImageDescription)){
-    printf("%02X %02X %02X %02X | %02X %02X %02X %02X | %02X %02X %02X %02X | %02X %02X %02X %02X\n",
-    x[0],x[1],x[2],x[3],x[4],x[5],x[6],x[7],x[8],x[9],x[10],x[11],x[12],x[13],x[14],x[15]);
+       printf("%02X %02X %02X %02X | %02X %02X %02X %02X | %02X %02X %02X %02X | %02X %02X %02X %02X\n",
+       x[0],x[1],x[2],x[3],x[4],x[5],x[6],x[7],x[8],x[9],x[10],x[11],x[12],x[13],x[14],x[15]);
     }
     printf("=========================================================\n");
 }
@@ -658,9 +658,9 @@ static inline void dump_Rect(char* title,Rect *r){
 
 static inline void dump_MatrixRecord(char* title, MatrixRecord *m){
     printf("%s: [%d %d %d][%d %d %d][%d %d %d]\n",title,
-    m->matrix[0][0],m->matrix[0][1],m->matrix[0][2],
-    m->matrix[1][0],m->matrix[1][1],m->matrix[1][2],
-    m->matrix[2][0],m->matrix[2][1],m->matrix[2][2]);
+       m->matrix[0][0],m->matrix[0][1],m->matrix[0][2],
+       m->matrix[1][0],m->matrix[1][1],m->matrix[1][2],
+       m->matrix[2][0],m->matrix[2][1],m->matrix[2][2]);
 }
 
 static inline void dump_PixMap(void* xxx){
@@ -669,11 +669,11 @@ static inline void dump_PixMap(void* xxx){
     printf("base=%p  stride=%d\n",p->baseAddr, p->rowBytes);
     dump_Rect("bounds",&p->bounds);
     printf("pmVersion=0x%X packType=0x%X\n packSize=0x%X\n",
-    p->pmVersion,p->packType, p->packSize);
+       p->pmVersion,p->packType, p->packSize);
     printf("hRes=0x%X vRes=0x%X pixelType=0x%X pixelSize=0x%X\n",
-    p->hRes,p->vRes,p->pixelType,p->pixelSize);
+       p->hRes,p->vRes,p->pixelType,p->pixelSize);
     printf("cmpCount=0x%X cmpSize=0x%X pixelFormat=0x%X\n",
-    p->cmpCount,p->cmpSize,p->pixelFormat);
+       p->cmpCount,p->cmpSize,p->pixelFormat);
     printf("pmTable=%p pmExt=%p\n",p->pmTable,p->pmExt);
     printf("=========================================================\n");
 }
@@ -684,8 +684,8 @@ static inline void dump_CodecCapabilities(void* xxx){
     printf("=============== CodecCapabilities at %p =================\n",xxx);
     printf("flags=0x%X  flags2=0x%X\n",cc->flags,cc->flags2);
     printf("wantedPixelSize=%d extendWidth=%d extendHeight=%d band=%d+%d\n",
-    cc->wantedPixelSize,cc->extendWidth,cc->extendHeight,
-    cc->bandMin,cc->bandInc);
+       cc->wantedPixelSize,cc->extendWidth,cc->extendHeight,
+       cc->bandMin,cc->bandInc);
     printf("pad=0x%X  time=0x%X\n",cc->pad,cc->time);
     printf("=========================================================\n");
 }
@@ -699,36 +699,36 @@ static inline void dump_CodecDecompressParams(void* xxx){
     printf("sequenceID=%d\n",cd->sequenceID);
     idh=cd->imageDescription;
     if(idh && idh[0]) dump_ImageDescription(idh[0]);
+    
     for(i=0;i<sizeof(CodecDecompressParams);i++){
-    printf(" %02X",((unsigned char*)cd)[i]);
-    if((i%16)==15) printf("\n");
+       printf(" %02X",((unsigned char*)cd)[i]);
+       if((i%16)==15) printf("\n");
     }
     printf("\n");
+    
     printf("data=%p  size=%d\n",cd->data,cd->bufferSize);
     printf("frameno=%d  lines: %d .. %d   condflags=0x%X  callerflags=0x%X\n",
-    cd->frameNumber, cd->startLine, cd->stopLine, cd->conditionFlags,cd->callerFlags);
+       cd->frameNumber, cd->startLine, cd->stopLine, cd->conditionFlags,cd->callerFlags);
 //    printf("maskBits=%p mattePixMap=%p\n",
-//    cd->maskBits,cd->mattePixMap);
+//     cd->maskBits,cd->mattePixMap);
     dump_PixMap(&cd->dstPixMap);
 //    if(cd->mattePixMap) dump_PixMap(cd->mattePixMap);
     if(cd->matrix) dump_MatrixRecord("matrix",cd->matrix);
     if(cd->capabilities) dump_CodecCapabilities(cd->capabilities);
     printf("accuracy=%d  transferMode=%d  matrixFlags=0x%X matrixType=%d\n",
-    (int)cd->accuracy, (int)cd->transferMode, (int)cd->matrixFlags, (int)cd->matrixType);
+       (int)cd->accuracy, (int)cd->transferMode, (int)cd->matrixFlags, (int)cd->matrixType);
     printf("srcrect: %d;%d - %d;%d\n",cd->srcRect.top,cd->srcRect.left,cd->srcRect.bottom,cd->srcRect.right);
     printf("dstrect: %d;%d - %d;%d\n",cd->dstRect.top,cd->dstRect.left,cd->dstRect.bottom,cd->dstRect.right);
     printf("wantedDestinationPixelTypes=%p\n",cd->wantedDestinationPixelTypes);
     if(cd->wantedDestinationPixelTypes){
-    unsigned int* p=cd->wantedDestinationPixelTypes;
-    while(p[0]){
-        printf("  0x%08X %.4s\n",p[0],&p[0]);
-        ++p;
-    }
+       unsigned int* p=cd->wantedDestinationPixelTypes;
+       while(p[0]){
+           printf("  0x%08X %.4s\n",p[0],&p[0]);
+           ++p;
+       }
     }
     printf("screenFloodMethod=%d value=%d  preferredOffscreenPixelSize=%d\n",
-    cd->screenFloodMethod, cd->screenFloodValue, cd->preferredOffscreenPixelSize);
+       cd->screenFloodMethod, cd->screenFloodValue, cd->preferredOffscreenPixelSize);
     printf("callbacks: progress=%p compl=%p data=%p ftime=%p srcdata=%p sync=%p\n",
      cd->progressProcRecord, cd->completionProcRecord,
      cd->dataProcRecord, cd->frameTime, cd->sourceData, cd->syncFrameTime);
index 8620cb1..2505bf2 100644 (file)
@@ -54,18 +54,18 @@ static char* localregpathname = NULL;
 
 typedef struct reg_handle_s
 {
-    int handle;
-    char* name;
-    struct reg_handle_s* next;
-    struct reg_handle_s* prev;
+       int handle;
+       char* name;
+       struct reg_handle_s* next;
+       struct reg_handle_s* prev;
 } reg_handle_t;
 
 struct reg_value
 {
-    int type;
-    char* name;
-    int len;
-    char* value;
+       int type;
+       char* name;
+       int len;
+       char* value;
 };
 
 static struct reg_value* regs = NULL;
@@ -83,9 +83,9 @@ static void init_registry(void);
 static void create_registry(void){
     if(regs)
     {
-    printf("Logic error: create_registry() called with existing registry\n");
-    save_registry();
-    return;
+       printf("Logic error: create_registry() called with existing registry\n");
+       save_registry();
+       return;
     }
     regs=(struct reg_value*)malloc(3*sizeof(struct reg_value));
     regs[0].type=regs[1].type=DIR;
@@ -102,75 +102,75 @@ static void create_registry(void){
 
 static void open_registry(void)
 {
-    int fd;
-    int i;
-    unsigned int len;
-    if(regs)
-    {
-        printf("Multiple open_registry(>\n");
-        return;
-    }
-    fd = open(localregpathname, O_RDONLY);
-    if (fd == -1)
-    {
-        printf("Creating new registry\n");
-        create_registry();
-        return;
-    }
-    read(fd, &reg_size, 4);
-    regs=(struct reg_value*)malloc(reg_size*sizeof(struct reg_value));
-    head = 0;
-    for(i=0; i<reg_size; i++)
-    {
-        read(fd,&regs[i].type,4);
-        read(fd,&len,4);
-        regs[i].name=(char*)malloc(len+1);
-        if(regs[i].name==0)
-        {
-            reg_size=i+1;
-            goto error;
-        }
-        read(fd, regs[i].name, len);
-        regs[i].name[len]=0;
-        read(fd,&regs[i].len,4);
-        regs[i].value=(char*)malloc(regs[i].len+1);
-        if(regs[i].value==0)
-        {
-                free(regs[i].name);
-            reg_size=i+1;
-            goto error;
-        }
-        read(fd, regs[i].value, regs[i].len);
-        regs[i].value[regs[i].len]=0;
-    }
+       int fd;
+       int i;
+       unsigned int len;
+       if(regs)
+       {
+               printf("Multiple open_registry(>\n");
+               return;
+       }
+       fd = open(localregpathname, O_RDONLY);
+       if (fd == -1)
+       {
+           printf("Creating new registry\n");
+           create_registry();
+           return;
+       }
+       read(fd, &reg_size, 4);
+       regs=(struct reg_value*)malloc(reg_size*sizeof(struct reg_value));
+       head = 0;
+       for(i=0; i<reg_size; i++)
+       {
+               read(fd,&regs[i].type,4);
+               read(fd,&len,4);
+               regs[i].name=(char*)malloc(len+1);
+               if(regs[i].name==0)
+               {
+                       reg_size=i+1;
+                       goto error;
+               }
+               read(fd, regs[i].name, len);
+               regs[i].name[len]=0;
+               read(fd,&regs[i].len,4);
+               regs[i].value=(char*)malloc(regs[i].len+1);
+               if(regs[i].value==0)
+               {
+                       free(regs[i].name);
+                       reg_size=i+1;
+                       goto error;
+               }
+               read(fd, regs[i].value, regs[i].len);
+               regs[i].value[regs[i].len]=0;
+       }
 error:
-    close(fd);
-    return;
+       close(fd);
+       return;
 }
 
 static void save_registry(void)
 {
-    int fd, i;
-    if (!regs)
-        init_registry();
-    fd = open(localregpathname, O_WRONLY | O_CREAT, 00666);
-    if (fd == -1)
-    {
-        printf("Failed to open registry file '%s' for writing.\n",
-           localregpathname);
-        return;
-    }
-    write(fd, &reg_size, 4);
-    for(i=0; i<reg_size; i++)
-    {
-            unsigned len=strlen(regs[i].name);
-        write(fd, &regs[i].type, 4);
-        write(fd, &len, 4);
-        write(fd, regs[i].name, len);
-        write(fd, &regs[i].len, 4);
-        write(fd, regs[i].value, regs[i].len);
-    }
-    close(fd);
+       int fd, i;
+       if (!regs)
+               init_registry();
+       fd = open(localregpathname, O_WRONLY | O_CREAT, 00666);
+       if (fd == -1)
+       {
+           printf("Failed to open registry file '%s' for writing.\n",
+                  localregpathname);
+           return;
+       }
+       write(fd, &reg_size, 4);
+       for(i=0; i<reg_size; i++)
+       {
+               unsigned len=strlen(regs[i].name);
+               write(fd, &regs[i].type, 4);
+               write(fd, &len, 4);
+               write(fd, regs[i].name, len);
+               write(fd, &regs[i].len, 4);
+               write(fd, regs[i].value, regs[i].len);
+       }
+       close(fd);
 }
 
 void free_registry(void)
@@ -178,203 +178,203 @@ void free_registry(void)
     reg_handle_t* t = head;
     while (t)
     {
-    reg_handle_t* f = t;
+       reg_handle_t* f = t;
         if (t->name)
-        free(t->name);
-    t=t->prev;
+           free(t->name);
+       t=t->prev;
         free(f);
     }
     head = 0;
     if (regs)
     {
         int i;
-    for(i=0; i<reg_size; i++)
-    {
-        free(regs[i].name);
-        free(regs[i].value);
-    }
-    free(regs);
-    regs = 0;
+       for(i=0; i<reg_size; i++)
+       {
+           free(regs[i].name);
+           free(regs[i].value);
+       }
+       free(regs);
+       regs = 0;
     }
 
     if (localregpathname && localregpathname != regpathname)
-    free(localregpathname);
+       free(localregpathname);
     localregpathname = 0;
 }
 
 
 static reg_handle_t* find_handle_by_name(const char* name)
 {
-    reg_handle_t* t;
-    for(t=head; t; t=t->prev)
-    {
-        if(!strcmp(t->name, name))
-        {
-            return t;
-        }
-    }
-    return 0;
+       reg_handle_t* t;
+       for(t=head; t; t=t->prev)
+       {
+               if(!strcmp(t->name, name))
+               {
+                       return t;
+               }
+       }
+       return 0;
 }
 static struct reg_value* find_value_by_name(const char* name)
 {
-    int i;
-    for(i=0; i<reg_size; i++)
-        if(!strcmp(regs[i].name, name))
-            return regs+i;
-    return 0;
+       int i;
+       for(i=0; i<reg_size; i++)
+               if(!strcmp(regs[i].name, name))
+                       return regs+i;
+       return 0;
 }
 static reg_handle_t* find_handle(int handle)
 {
-    reg_handle_t* t;
-    for(t=head; t; t=t->prev)
-    {
-        if(t->handle==handle)
-        {
-            return t;
-        }
-    }
-    return 0;
+       reg_handle_t* t;
+       for(t=head; t; t=t->prev)
+       {
+               if(t->handle==handle)
+               {
+                       return t;
+               }
+       }
+       return 0;
 }
 static int generate_handle()
 {
-    static unsigned int zz=249;
-    zz++;
-    while((zz==HKEY_LOCAL_MACHINE) || (zz==HKEY_CURRENT_USER))
-        zz++;
-    return zz;
+       static unsigned int zz=249;
+       zz++;
+       while((zz==HKEY_LOCAL_MACHINE) || (zz==HKEY_CURRENT_USER))
+               zz++;
+       return zz;
 }
 
 static reg_handle_t* insert_handle(long handle, const char* name)
 {
-    reg_handle_t* t;
-    t=(reg_handle_t*)malloc(sizeof(reg_handle_t));
-    if(head==0)
-    {
-        t->prev=0;
-    }
-    else
-    {
-        head->next=t;
-        t->prev=head;
-    }
-    t->next=0;
-    t->name=(char*)malloc(strlen(name)+1);
-    strcpy(t->name, name);
-    t->handle=handle;
-    head=t;
-    return t;
+       reg_handle_t* t;
+       t=(reg_handle_t*)malloc(sizeof(reg_handle_t));
+       if(head==0)
+       {
+               t->prev=0;
+       }
+       else
+       {
+               head->next=t;
+               t->prev=head;
+       }
+       t->next=0;
+       t->name=(char*)malloc(strlen(name)+1);
+       strcpy(t->name, name);
+       t->handle=handle;
+       head=t;
+       return t;
 }
 static char* build_keyname(long key, const char* subkey)
 {
-    char* full_name;
-    reg_handle_t* t;
-     if((t=find_handle(key))==0)
-    {
-        TRACE("Invalid key\n");
-        return NULL;
-    }
-    if(subkey==NULL)
-        subkey="<default>";
-    full_name=(char*)malloc(strlen(t->name)+strlen(subkey)+10);
-    strcpy(full_name, t->name);
-    strcat(full_name, "\\");
-    strcat(full_name, subkey);
-    return full_name;
+       char* full_name;
+       reg_handle_t* t;
+       if((t=find_handle(key))==0)
+       {
+               TRACE("Invalid key\n");
+               return NULL;
+       }
+       if(subkey==NULL)
+               subkey="<default>";
+       full_name=(char*)malloc(strlen(t->name)+strlen(subkey)+10);
+       strcpy(full_name, t->name);
+       strcat(full_name, "\\");
+       strcat(full_name, subkey);
+       return full_name;
 }
 static struct reg_value* insert_reg_value(int handle, const char* name, int type, const void* value, int len)
 {
-    reg_handle_t* t;
-    struct reg_value* v;
-    char* fullname;
-    if((fullname=build_keyname(handle, name))==NULL)
-    {
-        TRACE("Invalid handle\n");
-        return NULL;
-    }
-
-    if((v=find_value_by_name(fullname))==0)
-    //creating new value in registry
-    {
-        if(regs==0)
-            create_registry();
-        regs=(struct reg_value*)realloc(regs, sizeof(struct reg_value)*(reg_size+1));
-        //regs=(struct reg_value*)my_realloc(regs, sizeof(struct reg_value)*(reg_size+1));
-        v=regs+reg_size;
-        reg_size++;
-    }
-    else
-    //replacing old one
-    {
-        free(v->value);
-        free(v->name);
-    }
-    TRACE("RegInsert '%s'  %p  v:%d  len:%d\n", name, value, *(int*)value, len);
-    v->type=type;
-    v->len=len;
-    v->value=(char*)malloc(len);
-    memcpy(v->value, value, len);
-    v->name=(char*)malloc(strlen(fullname)+1);
-    strcpy(v->name, fullname);
+       reg_handle_t* t;
+       struct reg_value* v;
+       char* fullname;
+       if((fullname=build_keyname(handle, name))==NULL)
+       {
+               TRACE("Invalid handle\n");
+               return NULL;
+       }
+
+       if((v=find_value_by_name(fullname))==0)
+       //creating new value in registry
+       {
+               if(regs==0)
+                   create_registry();
+               regs=(struct reg_value*)realloc(regs, sizeof(struct reg_value)*(reg_size+1));
+               //regs=(struct reg_value*)my_realloc(regs, sizeof(struct reg_value)*(reg_size+1));
+               v=regs+reg_size;
+               reg_size++;
+       }
+       else
+       //replacing old one
+       {
+           free(v->value);
+           free(v->name);
+       }
+       TRACE("RegInsert '%s'  %p  v:%d  len:%d\n", name, value, *(int*)value, len);
+       v->type=type;
+       v->len=len;
+       v->value=(char*)malloc(len);
+       memcpy(v->value, value, len);
+       v->name=(char*)malloc(strlen(fullname)+1);
+       strcpy(v->name, fullname);
         free(fullname);
-    save_registry();
-    return v;
+       save_registry();
+       return v;
 }
 
 static void init_registry(void)
 {
-    TRACE("Initializing registry\n");
-    // can't be free-ed - it's static and probably thread
-    // unsafe structure which is stored in glibc
+       TRACE("Initializing registry\n");
+       // can't be free-ed - it's static and probably thread
+       // unsafe structure which is stored in glibc
 
 #ifdef MPLAYER
-    regpathname = get_path("registry");
-    localregpathname = regpathname;
+       regpathname = get_path("registry");
+       localregpathname = regpathname;
 #else
-    // regpathname is an external pointer
+       // regpathname is an external pointer
         //
-    // registry.c is holding its own internal pointer
-    // localregpathname  - which is being allocate/deallocated
+       // registry.c is holding its own internal pointer
+       // localregpathname  - which is being allocate/deallocated
 
-    if (localregpathname == 0)
-    {
+       if (localregpathname == 0)
+       {
             const char* pthn = regpathname;
-        if (!regpathname)
-        {
-        // avifile - for now reading data from user's home
-        struct passwd* pwent;
-        pwent = getpwuid(geteuid());
+           if (!regpathname)
+           {
+               // avifile - for now reading data from user's home
+               struct passwd* pwent;
+               pwent = getpwuid(geteuid());
                 pthn = pwent->pw_dir;
-        }
+           }
 
-        localregpathname = (char*)malloc(strlen(pthn)+20);
-        strcpy(localregpathname, pthn);
-        strcat(localregpathname, "/.registry");
-    }
+           localregpathname = (char*)malloc(strlen(pthn)+20);
+           strcpy(localregpathname, pthn);
+           strcat(localregpathname, "/.registry");
+       }
 #endif
 
-    open_registry();
-    insert_handle(HKEY_LOCAL_MACHINE, "HKLM");
-    insert_handle(HKEY_CURRENT_USER, "HKCU");
+       open_registry();
+       insert_handle(HKEY_LOCAL_MACHINE, "HKLM");
+       insert_handle(HKEY_CURRENT_USER, "HKCU");
 }
 
 static reg_handle_t* find_handle_2(long key, const char* subkey)
 {
-    char* full_name;
-    reg_handle_t* t;
-     if((t=find_handle(key))==0)
-    {
-        TRACE("Invalid key\n");
-        return (reg_handle_t*)-1;
-    }
-    if(subkey==NULL)
-        return t;
-    full_name=(char*)malloc(strlen(t->name)+strlen(subkey)+10);
-    strcpy(full_name, t->name);
-    strcat(full_name, "\\");
-    strcat(full_name, subkey);
-    t=find_handle_by_name(full_name);
-    free(full_name);
-    return t;
+       char* full_name;
+       reg_handle_t* t;
+       if((t=find_handle(key))==0)
+       {
+               TRACE("Invalid key\n");
+               return (reg_handle_t*)-1;
+       }
+       if(subkey==NULL)
+               return t;
+       full_name=(char*)malloc(strlen(t->name)+strlen(subkey)+10);
+       strcpy(full_name, t->name);
+       strcat(full_name, "\\");
+       strcat(full_name, subkey);
+       t=find_handle_by_name(full_name);
+       free(full_name);
+       return t;
 }
 
 long __stdcall RegOpenKeyExA(long key, const char* subkey, long reserved, long access, int* newkey)
@@ -387,13 +387,13 @@ long __stdcall RegOpenKeyExA(long key, const char* subkey, long reserved, long a
     if(!regs)
         init_registry()
 ;
-/*    t=find_handle_2(key, subkey);
+/*     t=find_handle_2(key, subkey);
 
-    if(t==0)
-        return -1;
+       if(t==0)
+               return -1;
 
-    if(t==(reg_handle_t*)-1)
-        return -1;
+       if(t==(reg_handle_t*)-1)
+               return -1;
 */
     full_name=build_keyname(key, subkey);
     if(!full_name)
@@ -411,20 +411,20 @@ long __stdcall RegCloseKey(long key)
 {
     reg_handle_t *handle;
     if(key==(long)HKEY_LOCAL_MACHINE)
-    return 0;
+       return 0;
     if(key==(long)HKEY_CURRENT_USER)
-    return 0;
+       return 0;
     handle=find_handle(key);
     if(handle==0)
-    return 0;
+       return 0;
     if(handle->prev)
-    handle->prev->next=handle->next;
+       handle->prev->next=handle->next;
     if(handle->next)
-    handle->next->prev=handle->prev;
+       handle->next->prev=handle->prev;
     if(handle->name)
-    free(handle->name);
+       free(handle->name);
     if(handle==head)
-    head=head->prev;
+       head=head->prev;
     free(handle);
     return 1;
 }
@@ -435,55 +435,55 @@ long __stdcall RegQueryValueExA(long key, const char* value, int* reserved, int*
     char* c;
     TRACE("Querying value %s\n", value);
     if(!regs)
-    init_registry();
+       init_registry();
 
     c=build_keyname(key, value);
     if (!c)
-    return 1;
+       return 1;
     t=find_value_by_name(c);
     free(c);
     if (t==0)
-    return 2;
+       return 2;
     if (type)
-    *type=t->type;
+       *type=t->type;
     if (data)
     {
-    memcpy(data, t->value, (t->len<*count)?t->len:*count);
-    TRACE("returning %d bytes: %d\n", t->len, *(int*)data);
+       memcpy(data, t->value, (t->len<*count)?t->len:*count);
+       TRACE("returning %d bytes: %d\n", t->len, *(int*)data);
     }
     if(*count<t->len)
     {
-    *count=t->len;
-    return ERROR_MORE_DATA;
+       *count=t->len;
+       return ERROR_MORE_DATA;
     }
     else
     {
-    *count=t->len;
+       *count=t->len;
     }
     return 0;
 }
 long __stdcall RegCreateKeyExA(long key, const char* name, long reserved,
-             void* classs, long options, long security,
-             void* sec_attr, int* newkey, int* status)
+                    void* classs, long options, long security,
+                    void* sec_attr, int* newkey, int* status)
 {
     reg_handle_t* t;
     char* fullname;
     struct reg_value* v;
     //        TRACE("Creating/Opening key %s\n", name);
     if(!regs)
-    init_registry();
+       init_registry();
 
     fullname=build_keyname(key, name);
     if (!fullname)
-    return 1;
+       return 1;
     TRACE("Creating/Opening key %s\n", fullname);
     v=find_value_by_name(fullname);
     if(v==0)
     {
-    int qw=45708;
-    v=insert_reg_value(key, name, DIR, &qw, 4);
-    if (status) *status=REG_CREATED_NEW_KEY;
-    //        return 0;
+       int qw=45708;
+       v=insert_reg_value(key, name, DIR, &qw, 4);
+       if (status) *status=REG_CREATED_NEW_KEY;
+       //              return 0;
     }
 
     t=insert_handle(generate_handle(), fullname);
@@ -506,7 +506,7 @@ LONG RegEnumValue(
 */
 
 long __stdcall RegEnumValueA(HKEY hkey, DWORD index, LPSTR value, LPDWORD val_count,
-           LPDWORD reserved, LPDWORD type, LPBYTE data, LPDWORD count)
+                  LPDWORD reserved, LPDWORD type, LPBYTE data, LPDWORD count)
 {
     // currenly just made to support MSZH & ZLIB
     //printf("Reg Enum 0x%x %d  %s %d   data: %p %d  %d >%s<\n", hkey, index,
@@ -514,17 +514,17 @@ long __stdcall RegEnumValueA(HKEY hkey, DWORD index, LPSTR value, LPDWORD val_co
     reg_handle_t* t = find_handle(hkey);
     if (t && index < 10)
     {
-    struct reg_value* v=find_value_by_name(t->name);
-    if (v)
-    {
-        memcpy(data, v->value, (v->len < *count) ? v->len : *count);
-        if(*count < v->len)
-        *count = v->len;
-        if (type)
-        *type = v->type;
-        //printf("Found handle  %s\n", v->name);
-        return 0;
-    }
+       struct reg_value* v=find_value_by_name(t->name);
+       if (v)
+       {
+           memcpy(data, v->value, (v->len < *count) ? v->len : *count);
+           if(*count < v->len)
+               *count = v->len;
+           if (type)
+               *type = v->type;
+           //printf("Found handle  %s\n", v->name);
+           return 0;
+       }
     }
     return ERROR_NO_MORE_ITEMS;
 }
@@ -535,19 +535,19 @@ long __stdcall RegSetValueExA(long key, const char* name, long v1, long v2, cons
     char* c;
     TRACE("Request to set value %s %d\n", name, *(const int*)data);
     if(!regs)
-    init_registry();
+       init_registry();
 
     c=build_keyname(key, name);
     if(c==NULL)
-    return 1;
+       return 1;
     insert_reg_value(key, name, v2, data, size);
     free(c);
     return 0;
 }
 
 long __stdcall RegEnumKeyExA(HKEY hKey, DWORD dwIndex, LPSTR lpName, LPDWORD lpcbName,
-           LPDWORD lpReserved, LPSTR lpClass, LPDWORD lpcbClass,
-           LPFILETIME lpftLastWriteTime)
+                  LPDWORD lpReserved, LPSTR lpClass, LPDWORD lpcbClass,
+                  LPFILETIME lpftLastWriteTime)
 {
     return ERROR_NO_MORE_ITEMS;
 }
index 711cf30..fd27576 100644 (file)
@@ -21,23 +21,23 @@ extern "C" {
 void free_registry(void);
 
 long __stdcall RegOpenKeyExA(long key, const char* subkey, long reserved,
-           long access, int* newkey);
+                  long access, int* newkey);
 long __stdcall RegCloseKey(long key);
 long __stdcall RegQueryValueExA(long key, const char* value, int* reserved,
-              int* type, int* data, int* count);
+                     int* type, int* data, int* count);
 long __stdcall RegCreateKeyExA(long key, const char* name, long reserved,
-             void* classs, long options, long security,
-             void* sec_attr, int* newkey, int* status);
+                    void* classs, long options, long security,
+                    void* sec_attr, int* newkey, int* status);
 long __stdcall RegSetValueExA(long key, const char* name, long v1, long v2,
-            const void* data, long size);
+                   const void* data, long size);
 
 #ifdef __WINE_WINERROR_H
 
 long __stdcall RegEnumKeyExA(HKEY hKey, DWORD dwIndex, LPSTR lpName, LPDWORD lpcbName,
-           LPDWORD lpReserved, LPSTR lpClass, LPDWORD lpcbClass,
-           LPFILETIME lpftLastWriteTime);
+                  LPDWORD lpReserved, LPSTR lpClass, LPDWORD lpcbClass,
+                  LPFILETIME lpftLastWriteTime);
 long __stdcall RegEnumValueA(HKEY hkey, DWORD index, LPSTR value, LPDWORD val_count,
-           LPDWORD reserved, LPDWORD type, LPBYTE data, LPDWORD count);
+                  LPDWORD reserved, LPDWORD type, LPBYTE data, LPDWORD count);
 #endif
 #ifdef __cplusplus
 };
index dd05a3b..3560dd0 100644 (file)
@@ -46,7 +46,7 @@
 #include "wine/winerror.h"
 #include "loader.h"
 
-#define CP_ACP                    0
+#define CP_ACP                                 0
 
 WORD WINE_LanguageId=0x409;//english
 
@@ -66,32 +66,32 @@ typedef struct _HRSRC_MAP
 } HRSRC_MAP;
 
 static HRSRC RES_FindResource2( HMODULE hModule, LPCSTR type,
-                LPCSTR name, WORD lang, int unicode)
+                               LPCSTR name, WORD lang, int unicode)
 {
     HRSRC hRsrc = 0;
-    LPWSTR typeStr, nameStr;
+    LPWSTR typeStr, nameStr;    
     WINE_MODREF *wm = MODULE32_LookupHMODULE( hModule );
 
     if(!wm)
-    return 0;
+       return 0;    
     /* 32-bit PE module */
 
+    
     if ( HIWORD( type ) && (!unicode))
-    typeStr = HEAP_strdupAtoW( GetProcessHeap(), 0, type );
+       typeStr = HEAP_strdupAtoW( GetProcessHeap(), 0, type );
     else
-    typeStr = (LPWSTR)type;
+       typeStr = (LPWSTR)type;
     if ( HIWORD( name ) && (!unicode))
-    nameStr = HEAP_strdupAtoW( GetProcessHeap(), 0, name );
+       nameStr = HEAP_strdupAtoW( GetProcessHeap(), 0, name );
     else
-    nameStr = (LPWSTR)name;
+       nameStr = (LPWSTR)name;
+    
     hRsrc = PE_FindResourceExW( wm, nameStr, typeStr, lang );
-    if ( HIWORD( type ) && (!unicode))
-    HeapFree( GetProcessHeap(), 0, typeStr );
-    if ( HIWORD( name ) && (!unicode))
-    HeapFree( GetProcessHeap(), 0, nameStr );
+    
+    if ( HIWORD( type ) && (!unicode)) 
+       HeapFree( GetProcessHeap(), 0, typeStr );
+    if ( HIWORD( name ) && (!unicode)) 
+       HeapFree( GetProcessHeap(), 0, nameStr );
 
     return hRsrc;
 }
@@ -106,13 +106,13 @@ static HRSRC RES_FindResource( HMODULE hModule, LPCSTR type,
     HRSRC hRsrc;
 //    __TRY
 //    {
-    hRsrc = RES_FindResource2(hModule, type, name, lang, unicode);
+       hRsrc = RES_FindResource2(hModule, type, name, lang, unicode);
 //    }
 //    __EXCEPT(page_fault)
 //    {
-//    WARN("page fault\n");
-//    SetLastError(ERROR_INVALID_PARAMETER);
-//    return 0;
+//     WARN("page fault\n");
+//     SetLastError(ERROR_INVALID_PARAMETER);
+//     return 0;
 //    }
 //    __ENDTRY
     return hRsrc;
@@ -128,7 +128,7 @@ static DWORD RES_SizeofResource( HMODULE hModule, HRSRC hRsrc)
 
 //    HMODULE16 hMod16   = MapHModuleLS( hModule );
 //    NE_MODULE *pModule = NE_GetPtr( hMod16 );
-//    WINE_MODREF *wm    = pModule && pModule->module32?
+//    WINE_MODREF *wm    = pModule && pModule->module32? 
 //                         MODULE32_LookupHMODULE( pModule->module32 ) : NULL;
     WINE_MODREF *wm = MODULE32_LookupHMODULE( hModule );
 
@@ -139,9 +139,9 @@ static DWORD RES_SizeofResource( HMODULE hModule, HRSRC hRsrc)
 //    hRsrc32  = HIWORD(hRsrc)? hRsrc : MapHRsrc16To32( pModule, hRsrc );
     if(!HIWORD(hRsrc))
     {
-    printf("16-bit hRsrcs not supported\n");
-    return 0;
-    }    
+       printf("16-bit hRsrcs not supported\n");
+       return 0;
+    }  
     size = PE_SizeofResource( hModule, hRsrc );
     return size;
 }
@@ -182,8 +182,8 @@ static HGLOBAL RES_LoadResource( HMODULE hModule, HRSRC hRsrc)
 //    hRsrc32 = HIWORD(hRsrc)? hRsrc : MapHRsrc16To32( pModule, hRsrc );
     if(!HIWORD(hRsrc))
     {
-    printf("16-bit hRsrcs not supported\n");
-    return 0;
+       printf("16-bit hRsrcs not supported\n");
+       return 0;
     }
     hMem = PE_LoadResource( wm, hRsrc );
 
@@ -214,40 +214,40 @@ static WIN_BOOL RES_FreeResource( HGLOBAL handle )
 }
 
 /**********************************************************************
- *        FindResourceA    (KERNEL32.128)
+ *         FindResourceA    (KERNEL32.128)
  */
 HANDLE WINAPI FindResourceA( HMODULE hModule, LPCSTR name, LPCSTR type )
 {
-    return RES_FindResource( hModule, type, name,
+    return RES_FindResource( hModule, type, name, 
                              WINE_LanguageId, 0);
 }
 HANDLE WINAPI FindResourceW( HMODULE hModule, LPCWSTR name, LPCWSTR type )
 {
-    return RES_FindResource( hModule, (LPCSTR)type, (LPCSTR)name,
+    return RES_FindResource( hModule, (LPCSTR)type, (LPCSTR)name, 
                              WINE_LanguageId, 1);
 }
 
 /**********************************************************************
- *        FindResourceExA  (KERNEL32.129)
+ *         FindResourceExA  (KERNEL32.129)
  */
-HANDLE WINAPI FindResourceExA( HMODULE hModule,
+HANDLE WINAPI FindResourceExA( HMODULE hModule, 
                                LPCSTR type, LPCSTR name, WORD lang )
 {
-    return RES_FindResource( hModule, type, name,
+    return RES_FindResource( hModule, type, name, 
                              lang, 0 );
 }
 
-HANDLE WINAPI FindResourceExW( HMODULE hModule,
+HANDLE WINAPI FindResourceExW( HMODULE hModule, 
                                LPCWSTR type, LPCWSTR name, WORD lang )
 {
-    return RES_FindResource( hModule, (LPCSTR)type, (LPCSTR)name,
+    return RES_FindResource( hModule, (LPCSTR)type, (LPCSTR)name, 
                              lang, 1 );
 }
 
 
 
 /**********************************************************************
- *        LockResource     (KERNEL32.384)
+ *         LockResource     (KERNEL32.384)
  */
 LPVOID WINAPI LockResource( HGLOBAL handle )
 {
@@ -256,7 +256,7 @@ LPVOID WINAPI LockResource( HGLOBAL handle )
 
 
 /**********************************************************************
- *        FreeResource     (KERNEL32.145)
+ *         FreeResource     (KERNEL32.145)
  */
 WIN_BOOL WINAPI FreeResource( HGLOBAL handle )
 {
@@ -265,14 +265,14 @@ WIN_BOOL WINAPI FreeResource( HGLOBAL handle )
 
 
 /**********************************************************************
- *        AccessResource   (KERNEL32.64)
+ *         AccessResource   (KERNEL32.64)
  */
 INT WINAPI AccessResource( HMODULE hModule, HRSRC hRsrc )
 {
     return RES_AccessResource( hModule, hRsrc );
 }
 /**********************************************************************
- *        SizeofResource   (KERNEL32.522)
+ *         SizeofResource   (KERNEL32.522)
  */
 DWORD WINAPI SizeofResource( HINSTANCE hModule, HRSRC hRsrc )
 {
@@ -284,7 +284,7 @@ INT WINAPI LoadStringW( HINSTANCE instance, UINT resource_id,
                             LPWSTR buffer, INT buflen );
 
 /**********************************************************************
- *    LoadStringA    (USER32.375)
+ *     LoadStringA     (USER32.375)
  */
 INT WINAPI LoadStringA( HINSTANCE instance, UINT resource_id,
                             LPSTR buffer, INT buflen )
@@ -296,11 +296,11 @@ INT WINAPI LoadStringA( HINSTANCE instance, UINT resource_id,
     LPSTR  abuf = NULL;
 
     if ( buffer != NULL && buflen > 0 )
-    *buffer = 0;
+       *buffer = 0;
 
     wbuflen = LoadStringW(instance,resource_id,NULL,0);
     if ( !wbuflen )
-    return 0;
+       return 0;
     wbuflen ++;
 
     retval = 0;
@@ -308,25 +308,25 @@ INT WINAPI LoadStringA( HINSTANCE instance, UINT resource_id,
     wbuflen = LoadStringW(instance,resource_id,wbuf,wbuflen);
     if ( wbuflen > 0 )
     {
-    abuflen = WideCharToMultiByte(CP_ACP,0,wbuf,wbuflen,NULL,0,NULL,NULL);
-    if ( abuflen > 0 )
-    {
-        if ( buffer == NULL || buflen == 0 )
-        retval = abuflen;
-        else
-        {
-        abuf = (LPSTR) HeapAlloc( GetProcessHeap(), 0, abuflen * sizeof(CHAR) );
-        abuflen = WideCharToMultiByte(CP_ACP,0,wbuf,wbuflen,abuf,abuflen,NULL,NULL);
-        if ( abuflen > 0 )
-        {
-            abuflen = min(abuflen,buflen - 1);
-            memcpy( buffer, abuf, abuflen );
-            buffer[abuflen] = 0;
-            retval = abuflen;
-        }
-        HeapFree( GetProcessHeap(), 0, abuf );
-        }
-    }
+       abuflen = WideCharToMultiByte(CP_ACP,0,wbuf,wbuflen,NULL,0,NULL,NULL);
+       if ( abuflen > 0 )
+       {
+           if ( buffer == NULL || buflen == 0 )
+               retval = abuflen;
+           else
+           {
+               abuf = (LPSTR) HeapAlloc( GetProcessHeap(), 0, abuflen * sizeof(CHAR) );
+               abuflen = WideCharToMultiByte(CP_ACP,0,wbuf,wbuflen,abuf,abuflen,NULL,NULL);
+               if ( abuflen > 0 )
+               {
+                   abuflen = min(abuflen,buflen - 1);
+                   memcpy( buffer, abuf, abuflen );
+                   buffer[abuflen] = 0;
+                   retval = abuflen;
+               }
+               HeapFree( GetProcessHeap(), 0, abuf );
+           }
+       }
     }
     HeapFree( GetProcessHeap(), 0, wbuf );
 
@@ -334,7 +334,7 @@ INT WINAPI LoadStringA( HINSTANCE instance, UINT resource_id,
 }
 
 /**********************************************************************
- *    LoadStringW        (USER32.376)
+ *     LoadStringW             (USER32.376)
  */
 INT WINAPI LoadStringW( HINSTANCE instance, UINT resource_id,
                             LPWSTR buffer, INT buflen )
@@ -346,37 +346,37 @@ INT WINAPI LoadStringW( HINSTANCE instance, UINT resource_id,
     int i;
 
     if (HIWORD(resource_id)==0xFFFF) /* netscape 3 passes this */
-    resource_id = (UINT)(-((INT)resource_id));
+       resource_id = (UINT)(-((INT)resource_id));
     TRACE("instance = %04x, id = %04x, buffer = %08x, "
           "length = %d\n", instance, (int)resource_id, (int) buffer, buflen);
 
-    /* Use bits 4 - 19 (incremented by 1) as resourceid, mask out
+    /* Use bits 4 - 19 (incremented by 1) as resourceid, mask out 
      * 20 - 31. */
     hrsrc = FindResourceW( instance, (LPCWSTR)(((resource_id>>4)&0xffff)+1),
                              RT_STRINGW );
     if (!hrsrc) return 0;
     hmem = LoadResource( instance, hrsrc );
     if (!hmem) return 0;
+    
     p = (WCHAR*) LockResource(hmem);
     string_num = resource_id & 0x000f;
     for (i = 0; i < string_num; i++)
-    p += *p + 1;
+       p += *p + 1;
+    
     TRACE("strlen = %d\n", (int)*p );
+    
     if (buffer == NULL) return *p;
     i = min(buflen - 1, *p);
     if (i > 0) {
-    memcpy(buffer, p + 1, i * sizeof (WCHAR));
-    buffer[i] = (WCHAR) 0;
+       memcpy(buffer, p + 1, i * sizeof (WCHAR));
+       buffer[i] = (WCHAR) 0;
     } else {
-    if (buflen > 1) {
-        buffer[0] = (WCHAR) 0;
-        return 0;
-    }
+       if (buflen > 1) {
+           buffer[0] = (WCHAR) 0;
+           return 0;
+       }
 #if 0
-    WARN("Don't know why caller give buflen=%d *p=%d trying to obtain string '%s'\n", buflen, *p, p + 1);
+       WARN("Don't know why caller give buflen=%d *p=%d trying to obtain string '%s'\n", buflen, *p, p + 1);
 #endif
     }
 
@@ -385,39 +385,39 @@ INT WINAPI LoadStringW( HINSTANCE instance, UINT resource_id,
 }
 
 /* Messages...used by FormatMessage32* (KERNEL32.something)
- *
+ * 
  * They can be specified either directly or using a message ID and
  * loading them from the resource.
- *
+ * 
  * The resourcedata has following format:
  * start:
  * 0: DWORD nrofentries
  * nrofentries * subentry:
- *    0: DWORD firstentry
- *    4: DWORD lastentry
+ *     0: DWORD firstentry
+ *     4: DWORD lastentry
  *      8: DWORD offset from start to the stringentries
  *
  * (lastentry-firstentry) * stringentry:
  * 0: WORD len (0 marks end)
  * 2: WORD flags
  * 4: CHAR[len-4]
- *     (stringentry i of a subentry refers to the ID 'firstentry+i')
+ *     (stringentry i of a subentry refers to the ID 'firstentry+i')
  *
  * Yes, ANSI strings in win32 resources. Go figure.
  */
 
 /**********************************************************************
- *    LoadMessageA        (internal)
+ *     LoadMessageA            (internal)
  */
 INT WINAPI LoadMessageA( HMODULE instance, UINT id, WORD lang,
                       LPSTR buffer, INT buflen )
 {
-    HGLOBAL    hmem;
-    HRSRC    hrsrc;
-    PMESSAGE_RESOURCE_DATA    mrd;
-    PMESSAGE_RESOURCE_BLOCK    mrb;
-    PMESSAGE_RESOURCE_ENTRY    mre;
-    int        i,slen;
+    HGLOBAL    hmem;
+    HRSRC      hrsrc;
+    PMESSAGE_RESOURCE_DATA     mrd;
+    PMESSAGE_RESOURCE_BLOCK    mrb;
+    PMESSAGE_RESOURCE_ENTRY    mre;
+    int                i,slen;
 
     TRACE("instance = %08lx, id = %08lx, buffer = %p, length = %ld\n", (DWORD)instance, (DWORD)id, buffer, (DWORD)buflen);
 
@@ -426,77 +426,77 @@ INT WINAPI LoadMessageA( HMODULE instance, UINT id, WORD lang,
     if (!hrsrc) return 0;
     hmem = LoadResource( instance, hrsrc );
     if (!hmem) return 0;
+    
     mrd = (PMESSAGE_RESOURCE_DATA)LockResource(hmem);
     mre = NULL;
     mrb = &(mrd->Blocks[0]);
     for (i=mrd->NumberOfBlocks;i--;) {
-        if ((id>=mrb->LowId) && (id<=mrb->HighId)) {
-        mre = (PMESSAGE_RESOURCE_ENTRY)(((char*)mrd)+mrb->OffsetToEntries);
-        id    -= mrb->LowId;
-        break;
-    }
-    mrb++;
+       if ((id>=mrb->LowId) && (id<=mrb->HighId)) {
+           mre = (PMESSAGE_RESOURCE_ENTRY)(((char*)mrd)+mrb->OffsetToEntries);
+           id  -= mrb->LowId;
+           break;
+       }
+       mrb++;
     }
     if (!mre)
-        return 0;
+       return 0;
     for (i=id;i--;) {
-        if (!mre->Length)
-        return 0;
-        mre = (PMESSAGE_RESOURCE_ENTRY)(((char*)mre)+(mre->Length));
+       if (!mre->Length)
+               return 0;
+       mre = (PMESSAGE_RESOURCE_ENTRY)(((char*)mre)+(mre->Length));
     }
     slen=mre->Length;
-    TRACE("    - strlen=%d\n",slen);
+    TRACE("    - strlen=%d\n",slen);
     i = min(buflen - 1, slen);
     if (buffer == NULL)
-    return slen;
+       return slen;
     if (i>0) {
-    lstrcpynA(buffer,(char*)mre->Text,i);
-    buffer[i]=0;
+       lstrcpynA(buffer,(char*)mre->Text,i);
+       buffer[i]=0;
     } else {
-    if (buflen>1) {
-        buffer[0]=0;
-        return 0;
-    }
+       if (buflen>1) {
+           buffer[0]=0;
+           return 0;
+       }
     }
     if (buffer)
-        TRACE("'%s' copied !\n", buffer);
+           TRACE("'%s' copied !\n", buffer);
     return i;
 }
 
 
 
 /**********************************************************************
- *    EnumResourceTypesA    (KERNEL32.90)
+ *     EnumResourceTypesA      (KERNEL32.90)
  */
 WIN_BOOL WINAPI EnumResourceTypesA( HMODULE hmodule,ENUMRESTYPEPROCA lpfun,
                                     LONG lParam)
 {
-    /* FIXME: move WINE_MODREF stuff here */
+       /* FIXME: move WINE_MODREF stuff here */
     return PE_EnumResourceTypesA(hmodule,lpfun,lParam);
 }
 
 /**********************************************************************
- *    EnumResourceNamesA    (KERNEL32.88)
+ *     EnumResourceNamesA      (KERNEL32.88)
  */
 WIN_BOOL WINAPI EnumResourceNamesA( HMODULE hmodule, LPCSTR type,
                                     ENUMRESNAMEPROCA lpfun, LONG lParam )
 {
-    /* FIXME: move WINE_MODREF stuff here */
+       /* FIXME: move WINE_MODREF stuff here */
     return PE_EnumResourceNamesA(hmodule,type,lpfun,lParam);
 }
 /**********************************************************************
- *    EnumResourceLanguagesA    (KERNEL32.86)
+ *     EnumResourceLanguagesA  (KERNEL32.86)
  */
 WIN_BOOL WINAPI EnumResourceLanguagesA( HMODULE hmodule, LPCSTR type,
                                         LPCSTR name, ENUMRESLANGPROCA lpfun,
                                         LONG lParam)
 {
-    /* FIXME: move WINE_MODREF stuff here */
+       /* FIXME: move WINE_MODREF stuff here */
     return PE_EnumResourceLanguagesA(hmodule,type,name,lpfun,lParam);
 }
 /**********************************************************************
- *        LoadResource     (KERNEL32.370)
+ *         LoadResource     (KERNEL32.370)
  */
 HGLOBAL WINAPI LoadResource( HINSTANCE hModule, HRSRC hRsrc )
 {
index 840b9b3..cc3b866 100644 (file)
 #define CloseDriver DrvClose
 
 /***********************************************************************
- *        VideoForWindowsVersion        [MSVFW.2][MSVIDEO.2]
+ *             VideoForWindowsVersion          [MSVFW.2][MSVIDEO.2]
  * Returns the version in major.minor form.
  * In Windows95 this returns 0x040003b6 (4.950)
  */
 long VFWAPI VideoForWindowsVersion(void) {
-    return 0x040003B6; /* 4.950 */
+       return 0x040003B6; /* 4.950 */
 }
 
 /* system.ini: [drivers] */
 
 /***********************************************************************
- *        ICInfo                [MSVFW.33]
+ *             ICInfo                          [MSVFW.33]
  * Get information about an installable compressor. Return TRUE if there
  * is one.
  */
 int VFWAPI
 ICInfo(
-    long fccType,        /* [in] type of compressor ('vidc') */
-    long fccHandler,    /* [in] <n>th compressor */
-    ICINFO *lpicinfo    /* [out] information about compressor */
+       long fccType,           /* [in] type of compressor ('vidc') */
+       long fccHandler,        /* [in] <n>th compressor */
+       ICINFO *lpicinfo        /* [out] information about compressor */
 ) {
-    /* does OpenDriver/CloseDriver */
-    lpicinfo->dwSize = sizeof(ICINFO);
-    lpicinfo->fccType = fccType;
-    lpicinfo->dwFlags = 0;
-    return TRUE;
+       /* does OpenDriver/CloseDriver */
+       lpicinfo->dwSize = sizeof(ICINFO);
+       lpicinfo->fccType = fccType;
+       lpicinfo->dwFlags = 0;
+       return TRUE;
 }
 
 /***********************************************************************
- *        ICOpen                [MSVFW.37]
+ *             ICOpen                          [MSVFW.37]
  * Opens an installable compressor. Return special handle.
  */
 HIC VFWAPI
 //ICOpen(long fccType,long fccHandler,unsigned int wMode) {
 ICOpen(long filename,long fccHandler,unsigned int wMode) {
-    ICOPEN        icopen;
-    HDRVR        hdrv;
-    WINE_HIC    *whic;
-
-    /* Well, lParam2 is in fact a LPVIDEO_OPEN_PARMS, but it has the
-     * same layout as ICOPEN
-     */
-    icopen.fccType        = 0x63646976; // "vidc" //fccType;
-    icopen.fccHandler    = fccHandler;
-    icopen.dwSize        = sizeof(ICOPEN);
-    icopen.dwFlags        = wMode;
-    icopen.pV1Reserved    = (void*)filename;
-    /* FIXME: do we need to fill out the rest too? */
-    hdrv=OpenDriverA((long)&icopen);
-    if (!hdrv) return 0;
-    whic = (WINE_HIC*)malloc(sizeof(WINE_HIC));
-    whic->hdrv    = hdrv;
-    whic->driverproc= ((DRVR*)hdrv)->DriverProc;
-//    whic->private    = ICSendMessage((HIC)whic,DRV_OPEN,0,(long)&icopen);
-    whic->driverid    = ((DRVR*)hdrv)->dwDriverID;
-    return (HIC)whic;
+       ICOPEN          icopen;
+       HDRVR           hdrv;
+       WINE_HIC        *whic;
+
+       /* Well, lParam2 is in fact a LPVIDEO_OPEN_PARMS, but it has the 
+        * same layout as ICOPEN
+        */
+       icopen.fccType          = 0x63646976; // "vidc" //fccType;
+       icopen.fccHandler       = fccHandler;
+       icopen.dwSize           = sizeof(ICOPEN);
+       icopen.dwFlags          = wMode;
+       icopen.pV1Reserved      = (void*)filename;
+       /* FIXME: do we need to fill out the rest too? */
+       hdrv=OpenDriverA((long)&icopen);
+       if (!hdrv) return 0;
+       whic = (WINE_HIC*)malloc(sizeof(WINE_HIC));
+       whic->hdrv      = hdrv;
+       whic->driverproc= ((DRVR*)hdrv)->DriverProc;
+//     whic->private   = ICSendMessage((HIC)whic,DRV_OPEN,0,(long)&icopen);
+       whic->driverid  = ((DRVR*)hdrv)->dwDriverID;
+       return (HIC)whic;
 }
 
 /***********************************************************************
- *        ICGetInfo            [MSVFW.30]
+ *             ICGetInfo                       [MSVFW.30]
  */
 LRESULT VFWAPI
 ICGetInfo(HIC hic,ICINFO *picinfo,long cb) {
-    LRESULT        ret;
+       LRESULT         ret;
 
-    ret = ICSendMessage(hic,ICM_GETINFO,(long)picinfo,cb);
-    
-    return ret;
+       ret = ICSendMessage(hic,ICM_GETINFO,(long)picinfo,cb);
+       
+       return ret;
 }
 
 /***********************************************************************
- *        ICCompress            [MSVFW.23]
+ *             ICCompress                      [MSVFW.23]
  */
 long VFWAPIV
 ICCompress(
-    HIC hic,long dwFlags,LPBITMAPINFOHEADER lpbiOutput,void* lpData,
-    LPBITMAPINFOHEADER lpbiInput,void* lpBits,long* lpckid,
-    long* lpdwFlags,long lFrameNum,long dwFrameSize,long dwQuality,
-    LPBITMAPINFOHEADER lpbiPrev,void* lpPrev
+       HIC hic,long dwFlags,LPBITMAPINFOHEADER lpbiOutput,void* lpData,
+       LPBITMAPINFOHEADER lpbiInput,void* lpBits,long* lpckid,
+       long* lpdwFlags,long lFrameNum,long dwFrameSize,long dwQuality,
+       LPBITMAPINFOHEADER lpbiPrev,void* lpPrev
 ) {
-    ICCOMPRESS    iccmp;
-
-    iccmp.dwFlags        = dwFlags;
-
-    iccmp.lpbiOutput    = lpbiOutput;
-    iccmp.lpOutput        = lpData;
-    iccmp.lpbiInput        = lpbiInput;
-    iccmp.lpInput        = lpBits;
-
-    iccmp.lpckid        = lpckid;
-    iccmp.lpdwFlags        = lpdwFlags;
-    iccmp.lFrameNum        = lFrameNum;
-    iccmp.dwFrameSize    = dwFrameSize;
-    iccmp.dwQuality        = dwQuality;
-    iccmp.lpbiPrev        = lpbiPrev;
-    iccmp.lpPrev        = lpPrev;
-    return ICSendMessage(hic,ICM_COMPRESS,(long)&iccmp,sizeof(iccmp));
+       ICCOMPRESS      iccmp;
+
+       iccmp.dwFlags           = dwFlags;
+
+       iccmp.lpbiOutput        = lpbiOutput;
+       iccmp.lpOutput          = lpData;
+       iccmp.lpbiInput         = lpbiInput;
+       iccmp.lpInput           = lpBits;
+
+       iccmp.lpckid            = lpckid;
+       iccmp.lpdwFlags         = lpdwFlags;
+       iccmp.lFrameNum         = lFrameNum;
+       iccmp.dwFrameSize       = dwFrameSize;
+       iccmp.dwQuality         = dwQuality;
+       iccmp.lpbiPrev          = lpbiPrev;
+       iccmp.lpPrev            = lpPrev;
+       return ICSendMessage(hic,ICM_COMPRESS,(long)&iccmp,sizeof(iccmp));
 }
 
 /***********************************************************************
- *        ICDecompress            [MSVFW.26]
+ *             ICDecompress                    [MSVFW.26]
  */
-long VFWAPIV
+long VFWAPIV 
 ICDecompress(HIC hic,long dwFlags,LPBITMAPINFOHEADER lpbiFormat,void* lpData,LPBITMAPINFOHEADER  lpbi,void* lpBits) {
-    ICDECOMPRESS    icd;
-    int result;
-    icd.dwFlags    = dwFlags;
-    icd.lpbiInput    = lpbiFormat;
-    icd.lpInput    = lpData;
-
-    icd.lpbiOutput    = lpbi;
-    icd.lpOutput    = lpBits;
-    icd.ckid    = 0;
-    result=ICSendMessage(hic,ICM_DECOMPRESS,(long)&icd,sizeof(icd));
-    return result;
+       ICDECOMPRESS    icd;
+       int result;
+       icd.dwFlags     = dwFlags;
+       icd.lpbiInput   = lpbiFormat;
+       icd.lpInput     = lpData;
+
+       icd.lpbiOutput  = lpbi;
+       icd.lpOutput    = lpBits;
+       icd.ckid        = 0;
+       result=ICSendMessage(hic,ICM_DECOMPRESS,(long)&icd,sizeof(icd));
+       return result;
 }
 
 /***********************************************************************
- *        ICDecompressEx            [MSVFW.26]
+ *             ICDecompressEx                  [MSVFW.26]
  */
-long VFWAPIV
+long VFWAPIV 
 ICDecompressEx(HIC hic,long dwFlags,LPBITMAPINFOHEADER lpbiFormat,void* lpData,LPBITMAPINFOHEADER  lpbi,void* lpBits) {
-    ICDECOMPRESSEX    icd;
-    int result;
-    
-    icd.dwFlags    = dwFlags;
-
-    icd.lpbiSrc    = lpbiFormat;
-    icd.lpSrc    = lpData;
-
-    icd.lpbiDst    = lpbi;
-    icd.lpDst    = lpBits;
-    
-    icd.xSrc=icd.ySrc=0;
-    icd.dxSrc=lpbiFormat->biWidth;
-    icd.dySrc=abs(lpbiFormat->biHeight);
-
-    icd.xDst=icd.yDst=0;
-    icd.dxDst=lpbi->biWidth;
-    icd.dyDst=abs(lpbi->biHeight);
-    
-    //icd.ckid    = 0;
-    result=ICSendMessage(hic,ICM_DECOMPRESSEX,(long)&icd,sizeof(icd));
-    return result;
+       ICDECOMPRESSEX  icd;
+       int result;
+       
+       icd.dwFlags     = dwFlags;
+
+       icd.lpbiSrc     = lpbiFormat;
+       icd.lpSrc       = lpData;
+
+       icd.lpbiDst     = lpbi;
+       icd.lpDst       = lpBits;
+       
+       icd.xSrc=icd.ySrc=0;
+       icd.dxSrc=lpbiFormat->biWidth;
+       icd.dySrc=abs(lpbiFormat->biHeight);
+
+       icd.xDst=icd.yDst=0;
+       icd.dxDst=lpbi->biWidth;
+       icd.dyDst=abs(lpbi->biHeight);
+       
+       //icd.ckid      = 0;
+       result=ICSendMessage(hic,ICM_DECOMPRESSEX,(long)&icd,sizeof(icd));
+       return result;
 }
 
-long VFWAPIV
+long VFWAPIV 
 ICUniversalEx(HIC hic,int command,LPBITMAPINFOHEADER lpbiFormat,LPBITMAPINFOHEADER lpbi) {
-    ICDECOMPRESSEX    icd;
-    int result;
-    
-    icd.dwFlags    = 0;
-
-    icd.lpbiSrc    = lpbiFormat;
-    icd.lpSrc    = 0;
-
-    icd.lpbiDst    = lpbi;
-    icd.lpDst    = 0;
-    
-    icd.xSrc=icd.ySrc=0;
-    icd.dxSrc=lpbiFormat->biWidth;
-    icd.dySrc=abs(lpbiFormat->biHeight);
-
-    icd.xDst=icd.yDst=0;
-    icd.dxDst=lpbi->biWidth;
-    icd.dyDst=abs(lpbi->biHeight);
-    
-    //icd.ckid    = 0;
-    result=ICSendMessage(hic,command,(long)&icd,sizeof(icd));
-    return result;
+       ICDECOMPRESSEX  icd;
+       int result;
+       
+       icd.dwFlags     = 0;
+
+       icd.lpbiSrc     = lpbiFormat;
+       icd.lpSrc       = 0;
+
+       icd.lpbiDst     = lpbi;
+       icd.lpDst       = 0;
+       
+       icd.xSrc=icd.ySrc=0;
+       icd.dxSrc=lpbiFormat->biWidth;
+       icd.dySrc=abs(lpbiFormat->biHeight);
+
+       icd.xDst=icd.yDst=0;
+       icd.dxDst=lpbi->biWidth;
+       icd.dyDst=abs(lpbi->biHeight);
+       
+       //icd.ckid      = 0;
+       result=ICSendMessage(hic,command,(long)&icd,sizeof(icd));
+       return result;
 }
 
 
 /***********************************************************************
- *        ICSendMessage            [MSVFW.40]
+ *             ICSendMessage                   [MSVFW.40]
  */
 LRESULT VFWAPI
 ICSendMessage(HIC hic,unsigned int msg,long lParam1,long lParam2) {
-    WINE_HIC    *whic = (WINE_HIC*)hic;
+    WINE_HIC   *whic = (WINE_HIC*)hic;
     return SendDriverMessage(whic->hdrv, msg, lParam1,lParam2);
 }
 
 
 /***********************************************************************
- *        ICClose            [MSVFW.22]
+ *             ICClose                 [MSVFW.22]
  */
 LRESULT VFWAPI ICClose(HIC hic) {
-    WINE_HIC    *whic = (WINE_HIC*)hic;
-    /* FIXME: correct? */
-//    CloseDriver(whic->hdrv,0,0);
+       WINE_HIC        *whic = (WINE_HIC*)hic;
+       /* FIXME: correct? */
+//     CloseDriver(whic->hdrv,0,0);
         DrvClose(whic->hdrv);
 //#warning FIXME: DrvClose
-    free(whic);
-    return 0;
+       free(whic);
+       return 0;
 }
 
 int VFWAPI ICDoSomething()
index dad695d..08fd21d 100644 (file)
@@ -47,8 +47,8 @@ for DLL to know too much about its environment.
 #endif
 
 #ifdef QTX
-#define PSEUDO_SCREEN_WIDTH    /*640*/800
-#define PSEUDO_SCREEN_HEIGHT    /*480*/600
+#define PSEUDO_SCREEN_WIDTH    /*640*/800
+#define PSEUDO_SCREEN_HEIGHT   /*480*/600
 #endif
 
 #include "wine/winbase.h"
@@ -84,7 +84,7 @@ for DLL to know too much about its environment.
 #include <dirent.h>
 #include <sys/time.h>
 #include <sys/timeb.h>
-#ifdef    HAVE_KSTAT
+#ifdef HAVE_KSTAT
 #include <kstat.h>
 #endif
 
@@ -108,43 +108,43 @@ static char* def_path = WIN32_PATH;
 static void do_cpuid(unsigned int ax, unsigned int *regs)
 {
     __asm__ __volatile__
-    (
-     "pushl %%ebx; pushl %%ecx; pushl %%edx;"
-     ".byte  0x0f, 0xa2;"
-     "movl   %%eax, (%2);"
-     "movl   %%ebx, 4(%2);"
-     "movl   %%ecx, 8(%2);"
-     "movl   %%edx, 12(%2);"
-     "popl %%edx; popl %%ecx; popl %%ebx;"
-     : "=a" (ax)
-     :  "0" (ax), "S" (regs)
-    );
+       (
+        "pushl %%ebx; pushl %%ecx; pushl %%edx;"
+        ".byte  0x0f, 0xa2;"
+        "movl   %%eax, (%2);"
+        "movl   %%ebx, 4(%2);"
+        "movl   %%ecx, 8(%2);"
+        "movl   %%edx, 12(%2);"
+        "popl %%edx; popl %%ecx; popl %%ebx;"
+        : "=a" (ax)
+        :  "0" (ax), "S" (regs)
+       );
 }
 static unsigned int c_localcount_tsc()
 {
     int a;
     __asm__ __volatile__
-    (
-     "rdtsc\n\t"
-     :"=a"(a)
-     :
-     :"edx"
-    );
+       (
+        "rdtsc\n\t"
+        :"=a"(a)
+        :
+        :"edx"
+       );
     return a;
 }
 static void c_longcount_tsc(long long* z)
 {
     __asm__ __volatile__
-    (
-     "pushl %%ebx\n\t"
-     "movl %%eax, %%ebx\n\t"
-     "rdtsc\n\t"
-     "movl %%eax, 0(%%ebx)\n\t"
-     "movl %%edx, 4(%%ebx)\n\t"
-     "popl %%ebx\n\t"
-     ::"a"(z)
-     :"edx"
-    );
+       (
+        "pushl %%ebx\n\t"
+        "movl %%eax, %%ebx\n\t"
+        "rdtsc\n\t"
+        "movl %%eax, 0(%%ebx)\n\t"
+        "movl %%edx, 4(%%ebx)\n\t"
+        "popl %%ebx\n\t"
+        ::"a"(z)
+        :"edx"
+       );
 }
 static unsigned int c_localcount_notsc()
 {
@@ -180,13 +180,13 @@ static unsigned int localcount_stub(void)
     do_cpuid(1, regs);
     if ((regs[3] & 0x00000010) != 0)
     {
-    localcount=c_localcount_tsc;
-    longcount=c_longcount_tsc;
+       localcount=c_localcount_tsc;
+       longcount=c_longcount_tsc;
     }
     else
     {
-    localcount=c_localcount_notsc;
-    longcount=c_longcount_notsc;
+       localcount=c_localcount_notsc;
+       longcount=c_longcount_notsc;
     }
     return localcount();
 }
@@ -196,13 +196,13 @@ static void longcount_stub(long long* z)
     do_cpuid(1, regs);
     if ((regs[3] & 0x00000010) != 0)
     {
-    localcount=c_localcount_tsc;
-    longcount=c_longcount_tsc;
+       localcount=c_localcount_tsc;
+       longcount=c_longcount_tsc;
     }
     else
     {
-    localcount=c_localcount_notsc;
-    longcount=c_longcount_notsc;
+       localcount=c_localcount_notsc;
+       longcount=c_longcount_notsc;
     }
     longcount(z);
 }
@@ -217,30 +217,30 @@ static inline void dbgprintf(char* fmt, ...)
 #ifdef DETAILED_OUT
     if(LOADER_DEBUG)
     {
-    FILE* f;
-    va_list va;
-    va_start(va, fmt);
-    f=fopen("./log", "a");
-    vprintf(fmt, va);
-    fflush(stdout);
-    if(f)
-    {
-        vfprintf(f, fmt, va);
-        fsync(fileno(f));
-        fclose(f);
-    }
-    va_end(va);
+       FILE* f;
+       va_list va;
+       va_start(va, fmt);
+       f=fopen("./log", "a");
+       vprintf(fmt, va);
+       fflush(stdout);
+       if(f)
+       {
+           vfprintf(f, fmt, va);
+           fsync(fileno(f));
+           fclose(f);
+       }
+       va_end(va);
     }
 #endif
 #ifdef MPLAYER
     if (verbose > 2)
     {
-    va_list va;
-    
-    va_start(va, fmt);
-    vprintf(fmt, va);
-//    mp_dbg(MSGT_WIN32, MSGL_DBG3, fmt, va);
-    va_end(va);
+       va_list va;
+       
+       va_start(va, fmt);
+       vprintf(fmt, va);
+//     mp_dbg(MSGT_WIN32, MSGL_DBG3, fmt, va);
+       va_end(va);
     }
   fflush(stdout);
 #endif
@@ -275,21 +275,21 @@ static void test_heap(void)
 {
     int offset=0;
     if(heap==0)
-    return;
+       return;
     while(offset<heap_counter)
     {
-    if(*(int*)(heap+offset)!=0x433476)
-    {
-        printf("Heap corruption at address %d\n", offset);
-        return;
-    }
-    offset+=8+*(int*)(heap+offset+4);
+       if(*(int*)(heap+offset)!=0x433476)
+       {
+           printf("Heap corruption at address %d\n", offset);
+           return;
+       }
+       offset+=8+*(int*)(heap+offset+4);
     }
     for(;offset<min(offset+1000, 20000000); offset++)
-    if(heap[offset]!=0xCC)
-    {
-        printf("Free heap corruption at address %d\n", offset);
-    }
+       if(heap[offset]!=0xCC)
+       {
+           printf("Free heap corruption at address %d\n", offset);
+       }
 }
 #undef MEMORY_DEBUG
 
@@ -303,18 +303,18 @@ static void* my_mreq(int size, int to_zero)
     //    test_heap();
     if(heap==NULL)
     {
-    heap=malloc(20000000);
-    memset(heap, 0xCC,20000000);
+       heap=malloc(20000000);
+       memset(heap, 0xCC,20000000);
     }
     if(heap==0)
     {
-    printf("No enough memory\n");
-    return 0;
+       printf("No enough memory\n");
+       return 0;
     }
     if(heap_counter+size>20000000)
     {
-    printf("No enough memory\n");
-    return 0;
+       printf("No enough memory\n");
+       return 0;
     }
     *(int*)(heap+heap_counter)=0x433476;
     heap_counter+=4;
@@ -322,9 +322,9 @@ static void* my_mreq(int size, int to_zero)
     heap_counter+=4;
     printf("Allocated %d bytes of memory: sys %d, user %d-%d\n", size, heap_counter-8, heap_counter, heap_counter+size);
     if(to_zero)
-    memset(heap+heap_counter, 0, size);
+       memset(heap+heap_counter, 0, size);
     else
-    memset(heap+heap_counter, 0xcc, size);  // make crash reproducable
+       memset(heap+heap_counter, 0xcc, size);  // make crash reproducable
     heap_counter+=size;
     return heap+heap_counter-size;
 }
@@ -333,13 +333,13 @@ static int my_release(char* memory)
     //    test_heap();
     if(memory==NULL)
     {
-    printf("ERROR: free(0)\n");
-    return 0;
+       printf("ERROR: free(0)\n");
+       return 0;
     }
     if(*(int*)(memory-8)!=0x433476)
     {
-    printf("MEMORY CORRUPTION !!!!!!!!!!!!!!!!!!!\n");
-    return 0;
+       printf("MEMORY CORRUPTION !!!!!!!!!!!!!!!!!!!\n");
+       return 0;
     }
     printf("Freed %d bytes of memory\n", *(int*)(memory-4));
     //    memset(memory-8, *(int*)(memory-4), 0xCC);
@@ -390,17 +390,17 @@ void* mreq_private(int size, int to_zero, int type)
     if (!header)
         return 0;
     if (to_zero)
-    memset(header, 0, nsize);
+       memset(header, 0, nsize);
 #ifdef GARBAGE
     if (!last_alloc)
     {
-    pthread_mutex_init(&memmut, NULL);
-    pthread_mutex_lock(&memmut);
+       pthread_mutex_init(&memmut, NULL);
+       pthread_mutex_lock(&memmut);
     }
     else
     {
-    pthread_mutex_lock(&memmut);
-    last_alloc->next = header;  /* set next */
+       pthread_mutex_lock(&memmut);
+       last_alloc->next = header;  /* set next */
     }
 
     header->prev = last_alloc;
@@ -425,12 +425,12 @@ static int my_release(void* memory)
     alloc_header* nextmem;
 
     if (memory == 0)
-    return 0;
+       return 0;
 
     if (header->deadbeef != (long) 0xdeadbeef)
     {
-    dbgprintf("FATAL releasing corrupted memory! %p  0x%lx  (%d)\n", header, header->deadbeef, alccnt);
-    return 0;
+       dbgprintf("FATAL releasing corrupted memory! %p  0x%lx  (%d)\n", header, header->deadbeef, alccnt);
+       return 0;
     }
 
     pthread_mutex_lock(&memmut);
@@ -438,20 +438,20 @@ static int my_release(void* memory)
     switch(header->type)
     {
     case AREATYPE_EVENT:
-    destroy_event(memory);
-    break;
+       destroy_event(memory);
+       break;
     case AREATYPE_COND:
-    pthread_cond_destroy((pthread_cond_t*)memory);
-    break;
+       pthread_cond_destroy((pthread_cond_t*)memory);
+       break;
     case AREATYPE_MUTEX:
-    pthread_mutex_destroy((pthread_mutex_t*)memory);
-    break;
+       pthread_mutex_destroy((pthread_mutex_t*)memory);
+       break;
     case AREATYPE_CRITSECT:
-    pthread_mutex_destroy(&((struct CRITSECT*)memory)->mutex);
-    break;
+       pthread_mutex_destroy(&((struct CRITSECT*)memory)->mutex);
+       break;
     default:
-    //memset(memory, 0xcc, header->size);
-    ;
+       //memset(memory, 0xcc, header->size);
+       ;
     }
 
     header->deadbeef = 0;
@@ -459,24 +459,24 @@ static int my_release(void* memory)
     nextmem = header->next;
 
     if (prevmem)
-    prevmem->next = nextmem;
+       prevmem->next = nextmem;
     if (nextmem)
-    nextmem->prev = prevmem;
+       nextmem->prev = prevmem;
 
     if (header == last_alloc)
-    last_alloc = prevmem;
+       last_alloc = prevmem;
 
     alccnt--;
 
     if (last_alloc)
-    pthread_mutex_unlock(&memmut);
+       pthread_mutex_unlock(&memmut);
     else
-    pthread_mutex_destroy(&memmut);
+       pthread_mutex_destroy(&memmut);
 
     //if (alccnt < 40000) printf("MY_RELEASE: %p\t%ld    (%d)\n", header, header->size, alccnt);
 #else
     if (memory == 0)
-    return 0;
+       return 0;
 #endif
     //memset(header + 1, 0xcc, header->size);
     free(header);
@@ -500,13 +500,13 @@ static void* my_realloc(void* memory, int size)
     void *ans = memory;
     int osize;
     if (memory == NULL)
-    return my_mreq(size, 0);
+       return my_mreq(size, 0);
     osize = my_size(memory);
     if (osize < size)
     {
-    ans = my_mreq(size, 0);
-    memcpy(ans, memory, osize);
-    my_release(memory);
+       ans = my_mreq(size, 0);
+       memcpy(ans, memory, osize);
+       my_release(memory);
     }
     return ans;
 }
@@ -529,7 +529,7 @@ static int  WINAPI expGetVolumeInformationA( const char *root, char *label,
                                        char *fsname, unsigned int fsname_len )
 {
 dbgprintf("GetVolumeInformationA( %s, 0x%x, %ld, 0x%x, 0x%x, 0x%x, 0x%x, %ld) => 1\n",
-              root,label,label_len,serial,filename_len,flags,fsname,fsname_len);
+                     root,label,label_len,serial,filename_len,flags,fsname,fsname_len);
 //hack Do not return any real data - do nothing
 return 1;
 }
@@ -576,24 +576,24 @@ static HMODULE WINAPI expGetDriverModuleHandle(DRVR* pdrv)
 {
     HMODULE result;
     if (pdrv==NULL)
-    result=0;
+       result=0;
     else
-    result=pdrv->hDriverModule;
+       result=pdrv->hDriverModule;
     dbgprintf("GetDriverModuleHandle(%p) => %p\n", pdrv, result);
     return result;
 }
 
-#define    MODULE_HANDLE_kernel32    ((HMODULE)0x120)
-#define    MODULE_HANDLE_user32    ((HMODULE)0x121)
+#define        MODULE_HANDLE_kernel32  ((HMODULE)0x120)
+#define        MODULE_HANDLE_user32    ((HMODULE)0x121)
 #ifdef QTX
-#define    MODULE_HANDLE_wininet    ((HMODULE)0x122)
-#define    MODULE_HANDLE_ddraw    ((HMODULE)0x123)
-#define    MODULE_HANDLE_advapi32    ((HMODULE)0x124)
+#define        MODULE_HANDLE_wininet   ((HMODULE)0x122)
+#define        MODULE_HANDLE_ddraw     ((HMODULE)0x123)
+#define        MODULE_HANDLE_advapi32  ((HMODULE)0x124)
 #endif
-#define    MODULE_HANDLE_comdlg32    ((HMODULE)0x125)
-#define    MODULE_HANDLE_msvcrt    ((HMODULE)0x126)
-#define    MODULE_HANDLE_ole32    ((HMODULE)0x127)
-#define    MODULE_HANDLE_winmm    ((HMODULE)0x128)
+#define        MODULE_HANDLE_comdlg32  ((HMODULE)0x125)
+#define        MODULE_HANDLE_msvcrt    ((HMODULE)0x126)
+#define        MODULE_HANDLE_ole32     ((HMODULE)0x127)
+#define        MODULE_HANDLE_winmm     ((HMODULE)0x128)
 
 static HMODULE WINAPI expGetModuleHandleA(const char* name)
 {
@@ -601,24 +601,24 @@ static HMODULE WINAPI expGetModuleHandleA(const char* name)
     HMODULE result;
     if(!name)
 #ifdef QTX
-    result=1;
+       result=1;
 #else
-    result=0;
+       result=0;
 #endif
     else
     {
-    wm=MODULE_FindModule(name);
-    if(wm==0)result=0;
-    else
-        result=(HMODULE)(wm->module);
+       wm=MODULE_FindModule(name);
+       if(wm==0)result=0;
+       else
+           result=(HMODULE)(wm->module);
     }
     if(!result)
     {
-    if(name && (strcasecmp(name, "kernel32")==0 || !strcasecmp(name, "kernel32.dll")))
-        result=MODULE_HANDLE_kernel32;
+       if(name && (strcasecmp(name, "kernel32")==0 || !strcasecmp(name, "kernel32.dll")))
+           result=MODULE_HANDLE_kernel32;
 #ifdef QTX
-    if(name && strcasecmp(name, "user32")==0)
-        result=MODULE_HANDLE_user32;
+       if(name && strcasecmp(name, "user32")==0)
+           result=MODULE_HANDLE_user32;
 #endif
     }
     dbgprintf("GetModuleHandleA('%s') => 0x%x\n", name, result);
@@ -626,32 +626,32 @@ static HMODULE WINAPI expGetModuleHandleA(const char* name)
 }
 
 static void* WINAPI expCreateThread(void* pSecAttr, long dwStackSize,
-                    void* lpStartAddress, void* lpParameter,
-                    long dwFlags, long* dwThreadId)
+                                   void* lpStartAddress, void* lpParameter,
+                                   long dwFlags, long* dwThreadId)
 {
     pthread_t *pth;
     //    printf("CreateThread:");
     pth = (pthread_t*) my_mreq(sizeof(pthread_t), 0);
     pthread_create(pth, NULL, (void*(*)(void*))lpStartAddress, lpParameter);
     if(dwFlags)
-    printf( "WARNING: CreateThread flags not supported\n");
+       printf( "WARNING: CreateThread flags not supported\n");
     if(dwThreadId)
-    *dwThreadId=(long)pth;
+       *dwThreadId=(long)pth;
     if(list==NULL)
     {
-    list=my_mreq(sizeof(th_list), 1);
-    list->next=list->prev=NULL;
+       list=my_mreq(sizeof(th_list), 1);
+       list->next=list->prev=NULL;
     }
     else
     {
-    list->next=my_mreq(sizeof(th_list), 0);
-    list->next->prev=list;
-    list->next->next=NULL;
-    list=list->next;
+       list->next=my_mreq(sizeof(th_list), 0);
+       list->next->prev=list;
+       list->next->next=NULL;
+       list=list->next;
     }
     list->thread=pth;
     dbgprintf("CreateThread(0x%x, 0x%x, 0x%x, 0x%x, 0x%x, 0x%x) => 0x%x\n",
-          pSecAttr, dwStackSize, lpStartAddress, lpParameter, dwFlags, dwThreadId, pth);
+             pSecAttr, dwStackSize, lpStartAddress, lpParameter, dwFlags, dwThreadId, pth);
     return pth;
 }
 
@@ -678,31 +678,31 @@ void destroy_event(void* event)
     //    printf("garbage collector: destroy_event(%x)\n", event);
     while(pp)
     {
-    if(pp==(mutex_list*)event)
-    {
-        if(pp->next)
-        pp->next->prev=pp->prev;
-        if(pp->prev)
-        pp->prev->next=pp->next;
-        if(mlist==(mutex_list*)event)
-        mlist=mlist->prev;
-        /*
-         pp=mlist;
-         while(pp)
-         {
-         printf("%x => ", pp);
-         pp=pp->prev;
-         }
-         printf("0\n");
-         */
-        return;
-    }
-    pp=pp->prev;
+       if(pp==(mutex_list*)event)
+       {
+           if(pp->next)
+               pp->next->prev=pp->prev;
+           if(pp->prev)
+               pp->prev->next=pp->next;
+           if(mlist==(mutex_list*)event)
+               mlist=mlist->prev;
+           /*
+            pp=mlist;
+            while(pp)
+            {
+            printf("%x => ", pp);
+            pp=pp->prev;
+            }
+            printf("0\n");
+            */
+           return;
+       }
+       pp=pp->prev;
     }
 }
 
 static void* WINAPI expCreateEventA(void* pSecAttr, char bManualReset,
-                    char bInitialState, const char* name)
+                                   char bInitialState, const char* name)
 {
     pthread_mutex_t *pm;
     pthread_cond_t  *pc;
@@ -718,17 +718,17 @@ static void* WINAPI expCreateEventA(void* pSecAttr, char bManualReset,
      */
     if(mlist!=NULL)
     {
-    mutex_list* pp=mlist;
-    if(name!=NULL)
-        do
-    {
-        if((strcmp(pp->name, name)==0) && (pp->type==0))
-        {
-        dbgprintf("CreateEventA(0x%x, 0x%x, 0x%x, 0x%x='%s') => 0x%x\n",
-              pSecAttr, bManualReset, bInitialState, name, name, pp->pm);
-        return pp->pm;
-        }
-    }while((pp=pp->prev) != NULL);
+       mutex_list* pp=mlist;
+       if(name!=NULL)
+           do
+       {
+           if((strcmp(pp->name, name)==0) && (pp->type==0))
+           {
+               dbgprintf("CreateEventA(0x%x, 0x%x, 0x%x, 0x%x='%s') => 0x%x\n",
+                         pSecAttr, bManualReset, bInitialState, name, name, pp->pm);
+               return pp->pm;
+           }
+       }while((pp=pp->prev) != NULL);
     }
     pm=mreq_private(sizeof(pthread_mutex_t), 0, AREATYPE_MUTEX);
     pthread_mutex_init(pm, NULL);
@@ -736,15 +736,15 @@ static void* WINAPI expCreateEventA(void* pSecAttr, char bManualReset,
     pthread_cond_init(pc, NULL);
     if(mlist==NULL)
     {
-    mlist=mreq_private(sizeof(mutex_list), 00, AREATYPE_EVENT);
-    mlist->next=mlist->prev=NULL;
+       mlist=mreq_private(sizeof(mutex_list), 00, AREATYPE_EVENT);
+       mlist->next=mlist->prev=NULL;
     }
     else
     {
-    mlist->next=mreq_private(sizeof(mutex_list), 00, AREATYPE_EVENT);
-    mlist->next->prev=mlist;
-    mlist->next->next=NULL;
-    mlist=mlist->next;
+       mlist->next=mreq_private(sizeof(mutex_list), 00, AREATYPE_EVENT);
+       mlist->next->prev=mlist;
+       mlist->next->next=NULL;
+       mlist=mlist->next;
     }
     mlist->type=0; /* Type Event */
     mlist->pm=pm;
@@ -752,21 +752,21 @@ static void* WINAPI expCreateEventA(void* pSecAttr, char bManualReset,
     mlist->state=bInitialState;
     mlist->reset=bManualReset;
     if(name)
-    strncpy(mlist->name, name, 127);
+       strncpy(mlist->name, name, 127);
     else
-    mlist->name[0]=0;
+       mlist->name[0]=0;
     if(pm==NULL)
-    dbgprintf("ERROR::: CreateEventA failure\n");
+       dbgprintf("ERROR::: CreateEventA failure\n");
     /*
      if(bInitialState)
      pthread_mutex_lock(pm);
      */
     if(name)
-    dbgprintf("CreateEventA(0x%x, 0x%x, 0x%x, 0x%x='%s') => 0x%x\n",
-          pSecAttr, bManualReset, bInitialState, name, name, mlist);
+       dbgprintf("CreateEventA(0x%x, 0x%x, 0x%x, 0x%x='%s') => 0x%x\n",
+                 pSecAttr, bManualReset, bInitialState, name, name, mlist);
     else
-    dbgprintf("CreateEventA(0x%x, 0x%x, 0x%x, NULL) => 0x%x\n",
-          pSecAttr, bManualReset, bInitialState, mlist);
+       dbgprintf("CreateEventA(0x%x, 0x%x, 0x%x, NULL) => 0x%x\n",
+                 pSecAttr, bManualReset, bInitialState, mlist);
     return mlist;
 }
 
@@ -776,8 +776,8 @@ static void* WINAPI expSetEvent(void* event)
     dbgprintf("SetEvent(%x) => 0x1\n", event);
     pthread_mutex_lock(ml->pm);
     if (ml->state == 0) {
-    ml->state = 1;
-    pthread_cond_signal(ml->pc);
+       ml->state = 1;
+       pthread_cond_signal(ml->pc);
     }
     pthread_mutex_unlock(ml->pm);
 
@@ -802,73 +802,73 @@ static void* WINAPI expWaitForSingleObject(void* object, int duration)
     mutex_list* pp=mlist;
     if(object == (void*)0xcfcf9898)
     {
-    /**
-     From GetCurrentThread() documentation:
-     A pseudo handle is a special constant that is interpreted as the current thread handle. The calling thread can use this handle to specify itself whenever a thread handle is required. Pseudo handles are not inherited by child processes.
+       /**
+        From GetCurrentThread() documentation:
+        A pseudo handle is a special constant that is interpreted as the current thread handle. The calling thread can use this handle to specify itself whenever a thread handle is required. Pseudo handles are not inherited by child processes.
 
-     This handle has the maximum possible access to the thread object. For systems that support security descriptors, this is the maximum access allowed by the security descriptor for the calling process. For systems that do not support security descriptors, this is THREAD_ALL_ACCESS.
+        This handle has the maximum possible access to the thread object. For systems that support security descriptors, this is the maximum access allowed by the security descriptor for the calling process. For systems that do not support security descriptors, this is THREAD_ALL_ACCESS.
 
-     The function cannot be used by one thread to create a handle that can be used by other threads to refer to the first thread. The handle is always interpreted as referring to the thread that is using it. A thread can create a "real" handle to itself that can be used by other threads, or inherited by other processes, by specifying the pseudo handle as the source handle in a call to the DuplicateHandle function.
-     **/
-    dbgprintf("WaitForSingleObject(thread_handle) called\n");
-    return (void*)WAIT_FAILED;
+        The function cannot be used by one thread to create a handle that can be used by other threads to refer to the first thread. The handle is always interpreted as referring to the thread that is using it. A thread can create a "real" handle to itself that can be used by other threads, or inherited by other processes, by specifying the pseudo handle as the source handle in a call to the DuplicateHandle function.
+        **/
+       dbgprintf("WaitForSingleObject(thread_handle) called\n");
+       return (void*)WAIT_FAILED;
     }
     dbgprintf("WaitForSingleObject(0x%x, duration %d) =>\n",object, duration);
 
     // loop below was slightly fixed - its used just for checking if
     // this object really exists in our list
     if (!ml)
-    return (void*) ret;
+       return (void*) ret;
     while (pp && (pp->pm != ml->pm))
-    pp = pp->prev;
+       pp = pp->prev;
     if (!pp) {
-    dbgprintf("WaitForSingleObject: NotFound\n");
-    return (void*)ret;
+       dbgprintf("WaitForSingleObject: NotFound\n");
+       return (void*)ret;
     }
 
     pthread_mutex_lock(ml->pm);
 
     switch(ml->type) {
     case 0: /* Event */
-    if (duration == 0) { /* Check Only */
-        if (ml->state == 1) ret = WAIT_FAILED;
-        else                   ret = WAIT_OBJECT_0;
-    }
-    if (duration == -1) { /* INFINITE */
-        if (ml->state == 0)
-        pthread_cond_wait(ml->pc,ml->pm);
-        if (ml->reset)
-        ml->state = 0;
-        ret = WAIT_OBJECT_0;
-    }
-    if (duration > 0) {  /* Timed Wait */
-        struct timespec abstime;
-        struct timeval now;
-        gettimeofday(&now, 0);
-        abstime.tv_sec = now.tv_sec + (now.tv_usec+duration)/1000000;
-        abstime.tv_nsec = ((now.tv_usec+duration)%1000000)*1000;
-        if (ml->state == 0)
-        ret=pthread_cond_timedwait(ml->pc,ml->pm,&abstime);
-        if (ret == ETIMEDOUT) ret = WAIT_TIMEOUT;
-        else                  ret = WAIT_OBJECT_0;
-        if (ml->reset)
-        ml->state = 0;
-    }
-    break;
+       if (duration == 0) { /* Check Only */
+           if (ml->state == 1) ret = WAIT_FAILED;
+           else                   ret = WAIT_OBJECT_0;
+       }
+       if (duration == -1) { /* INFINITE */
+           if (ml->state == 0)
+               pthread_cond_wait(ml->pc,ml->pm);
+           if (ml->reset)
+               ml->state = 0;
+           ret = WAIT_OBJECT_0;
+       }
+       if (duration > 0) {  /* Timed Wait */
+           struct timespec abstime;
+           struct timeval now;
+           gettimeofday(&now, 0);
+           abstime.tv_sec = now.tv_sec + (now.tv_usec+duration)/1000000;
+           abstime.tv_nsec = ((now.tv_usec+duration)%1000000)*1000;
+           if (ml->state == 0)
+               ret=pthread_cond_timedwait(ml->pc,ml->pm,&abstime);
+           if (ret == ETIMEDOUT) ret = WAIT_TIMEOUT;
+           else                  ret = WAIT_OBJECT_0;
+           if (ml->reset)
+               ml->state = 0;
+       }
+       break;
     case 1:  /* Semaphore */
-    if (duration == 0) {
-        if(ml->semaphore==0) ret = WAIT_FAILED;
-        else {
-        ml->semaphore++;
-        ret = WAIT_OBJECT_0;
-        }
-    }
-    if (duration == -1) {
-        if (ml->semaphore==0)
-        pthread_cond_wait(ml->pc,ml->pm);
-        ml->semaphore--;
-    }
-    break;
+       if (duration == 0) {
+           if(ml->semaphore==0) ret = WAIT_FAILED;
+           else {
+               ml->semaphore++;
+               ret = WAIT_OBJECT_0;
+           }
+       }
+       if (duration == -1) {
+           if (ml->semaphore==0)
+               pthread_cond_wait(ml->pc,ml->pm);
+           ml->semaphore--;
+       }
+       break;
     }
     pthread_mutex_unlock(ml->pm);
 
@@ -878,23 +878,23 @@ static void* WINAPI expWaitForSingleObject(void* object, int duration)
 
 #ifdef QTX
 static void* WINAPI expWaitForMultipleObjects(int count, const void** objects,
-            int WaitAll, int duration)
+                   int WaitAll, int duration)
 {
     int i;
     void *object;
     void *ret;
 
     dbgprintf("WaitForMultipleObjects(%d, 0x%x, %d, duration %d) =>\n",
-    count, objects, WaitAll, duration);
+       count, objects, WaitAll, duration);
+    
     for (i = 0; i < count; i++)
     {
-    object = (void *)objects[i];
-    ret = expWaitForSingleObject(object, duration);
-    if (WaitAll)
-        dbgprintf("WaitAll flag not yet supported...\n");
-    else
-        return ret;
+       object = (void *)objects[i];
+       ret = expWaitForSingleObject(object, duration);
+       if (WaitAll)
+           dbgprintf("WaitAll flag not yet supported...\n");
+       else
+           return ret;
     }
     return NULL;
 }
@@ -906,16 +906,16 @@ static void WINAPI expExitThread(int retcode)
 }
 
 static HANDLE WINAPI expCreateMutexA(void *pSecAttr,
-            char bInitialOwner, const char *name)
+                   char bInitialOwner, const char *name)
 {
     HANDLE mlist = (HANDLE)expCreateEventA(pSecAttr, 0, 0, name);
+    
     if (name)
-    dbgprintf("CreateMutexA(0x%x, %d, '%s') => 0x%x\n",
-        pSecAttr, bInitialOwner, name, mlist);
+       dbgprintf("CreateMutexA(0x%x, %d, '%s') => 0x%x\n",
+           pSecAttr, bInitialOwner, name, mlist);
     else
-    dbgprintf("CreateMutexA(0x%x, %d, NULL) => 0x%x\n",
-        pSecAttr, bInitialOwner, mlist);
+       dbgprintf("CreateMutexA(0x%x, %d, NULL) => 0x%x\n",
+           pSecAttr, bInitialOwner, mlist);
 #ifndef QTX
     /* 10l to QTX, if CreateMutex returns a real mutex, WaitForSingleObject
        waits for ever, else it works ;) */
@@ -957,56 +957,56 @@ static void WINAPI expGetSystemInfo(SYSTEM_INFO* si)
     dbgprintf("GetSystemInfo(%p) =>\n", si);
 
     if (cache) {
-    memcpy(si,&cachedsi,sizeof(*si));
-    DumpSystemInfo(si);
-    return;
+       memcpy(si,&cachedsi,sizeof(*si));
+       DumpSystemInfo(si);
+       return;
     }
     memset(PF,0,sizeof(PF));
     pf_set = 1;
 
     cachedsi.u.s.wProcessorArchitecture     = PROCESSOR_ARCHITECTURE_INTEL;
-    cachedsi.dwPageSize             = getpagesize();
+    cachedsi.dwPageSize                        = getpagesize();
 
     /* FIXME: better values for the two entries below... */
-    cachedsi.lpMinimumApplicationAddress    = (void *)0x00000000;
-    cachedsi.lpMaximumApplicationAddress    = (void *)0x7FFFFFFF;
-    cachedsi.dwActiveProcessorMask        = 1;
-    cachedsi.dwNumberOfProcessors        = 1;
-    cachedsi.dwProcessorType        = PROCESSOR_INTEL_386;
-    cachedsi.dwAllocationGranularity    = 0x10000;
-    cachedsi.wProcessorLevel        = 5; /* pentium */
-    cachedsi.wProcessorRevision        = 0x0101;
+    cachedsi.lpMinimumApplicationAddress       = (void *)0x00000000;
+    cachedsi.lpMaximumApplicationAddress       = (void *)0x7FFFFFFF;
+    cachedsi.dwActiveProcessorMask             = 1;
+    cachedsi.dwNumberOfProcessors              = 1;
+    cachedsi.dwProcessorType           = PROCESSOR_INTEL_386;
+    cachedsi.dwAllocationGranularity   = 0x10000;
+    cachedsi.wProcessorLevel           = 5; /* pentium */
+    cachedsi.wProcessorRevision                = 0x0101;
 
 #ifdef MPLAYER
     /* mplayer's way to detect PF's */
     {
 #include "../cpudetect.h"
-    extern CpuCaps gCpuCaps;
-
-    if (gCpuCaps.hasMMX)
-        PF[PF_MMX_INSTRUCTIONS_AVAILABLE] = TRUE;
-    if (gCpuCaps.hasSSE)
-        PF[PF_XMMI_INSTRUCTIONS_AVAILABLE] = TRUE;
-    if (gCpuCaps.has3DNow)
-        PF[PF_AMD3D_INSTRUCTIONS_AVAILABLE] = TRUE;
-
-        if (gCpuCaps.cpuType == 4)
-        {
-            cachedsi.dwProcessorType = PROCESSOR_INTEL_486;
-        cachedsi.wProcessorLevel = 4;
-        }
-        else if (gCpuCaps.cpuType >= 5)
-        {
-        cachedsi.dwProcessorType = PROCESSOR_INTEL_PENTIUM;
-        cachedsi.wProcessorLevel = 5;
-        }
-        else
-        {
-            cachedsi.dwProcessorType = PROCESSOR_INTEL_386;
-        cachedsi.wProcessorLevel = 3;
-        }
-        cachedsi.wProcessorRevision = gCpuCaps.cpuStepping;
-            cachedsi.dwNumberOfProcessors = 1;    /* hardcoded */
+       extern CpuCaps gCpuCaps;
+
+       if (gCpuCaps.hasMMX)
+           PF[PF_MMX_INSTRUCTIONS_AVAILABLE] = TRUE;
+       if (gCpuCaps.hasSSE)
+           PF[PF_XMMI_INSTRUCTIONS_AVAILABLE] = TRUE;
+       if (gCpuCaps.has3DNow)
+           PF[PF_AMD3D_INSTRUCTIONS_AVAILABLE] = TRUE;
+
+           if (gCpuCaps.cpuType == 4)
+           {
+               cachedsi.dwProcessorType = PROCESSOR_INTEL_486;
+               cachedsi.wProcessorLevel = 4;
+           }
+           else if (gCpuCaps.cpuType >= 5)
+           {
+               cachedsi.dwProcessorType = PROCESSOR_INTEL_PENTIUM;
+               cachedsi.wProcessorLevel = 5;
+           }
+           else
+           {
+               cachedsi.dwProcessorType = PROCESSOR_INTEL_386;
+               cachedsi.wProcessorLevel = 3;
+           }
+           cachedsi.wProcessorRevision = gCpuCaps.cpuStepping;
+           cachedsi.dwNumberOfProcessors = 1;  /* hardcoded */
     }
 #endif
 
@@ -1014,7 +1014,7 @@ static void WINAPI expGetSystemInfo(SYSTEM_INFO* si)
 #ifndef MPLAYER
 #if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__svr4__) || defined(__DragonFly__)
     do_cpuid(1, regs);
-    switch ((regs[0] >> 8) & 0xf) {            // cpu family
+    switch ((regs[0] >> 8) & 0xf) {                    // cpu family
     case 3: cachedsi.dwProcessorType = PROCESSOR_INTEL_386;
     cachedsi.wProcessorLevel= 3;
     break;
@@ -1031,15 +1031,15 @@ static void WINAPI expGetSystemInfo(SYSTEM_INFO* si)
     cachedsi.wProcessorLevel= 5;
     break;
     }
-    cachedsi.wProcessorRevision = regs[0] & 0xf;    // stepping
+    cachedsi.wProcessorRevision = regs[0] & 0xf;       // stepping
     if (regs[3] & (1 <<  8))
-    PF[PF_COMPARE_EXCHANGE_DOUBLE] = TRUE;
+       PF[PF_COMPARE_EXCHANGE_DOUBLE] = TRUE;
     if (regs[3] & (1 << 23))
-    PF[PF_MMX_INSTRUCTIONS_AVAILABLE] = TRUE;
+       PF[PF_MMX_INSTRUCTIONS_AVAILABLE] = TRUE;
     if (regs[3] & (1 << 25))
-    PF[PF_XMMI_INSTRUCTIONS_AVAILABLE] = TRUE;
+       PF[PF_XMMI_INSTRUCTIONS_AVAILABLE] = TRUE;
     if (regs[3] & (1 << 31))
-    PF[PF_AMD3D_INSTRUCTIONS_AVAILABLE] = TRUE;
+       PF[PF_AMD3D_INSTRUCTIONS_AVAILABLE] = TRUE;
     cachedsi.dwNumberOfProcessors=1;
 #endif
 #endif /* MPLAYER */
@@ -1048,132 +1048,132 @@ static void WINAPI expGetSystemInfo(SYSTEM_INFO* si)
    fdiv_bug and fpu emulation flags -- alex/MPlayer */
 #ifdef __linux__
     {
-    char buf[20];
-    char line[200];
-    FILE *f = fopen ("/proc/cpuinfo", "r");
-
-    if (!f)
-        return;
-    while (fgets(line,200,f)!=NULL) {
-        char    *s,*value;
-
-        /* NOTE: the ':' is the only character we can rely on */
-        if (!(value = strchr(line,':')))
-        continue;
-        /* terminate the valuename */
-        *value++ = '\0';
-        /* skip any leading spaces */
-        while (*value==' ') value++;
-        if ((s=strchr(value,'\n')))
-        *s='\0';
-
-        /* 2.1 method */
-        if (!lstrncmpiA(line, "cpu family",strlen("cpu family"))) {
-        if (isdigit (value[0])) {
-            switch (value[0] - '0') {
-            case 3: cachedsi.dwProcessorType = PROCESSOR_INTEL_386;
-            cachedsi.wProcessorLevel= 3;
-            break;
-            case 4: cachedsi.dwProcessorType = PROCESSOR_INTEL_486;
-            cachedsi.wProcessorLevel= 4;
-            break;
-            case 5: cachedsi.dwProcessorType = PROCESSOR_INTEL_PENTIUM;
-            cachedsi.wProcessorLevel= 5;
-            break;
-            case 6: cachedsi.dwProcessorType = PROCESSOR_INTEL_PENTIUM;
-            cachedsi.wProcessorLevel= 5;
-            break;
-            default:cachedsi.dwProcessorType = PROCESSOR_INTEL_PENTIUM;
-            cachedsi.wProcessorLevel= 5;
-            break;
-            }
-        }
-        /* set the CPU type of the current processor */
-        sprintf(buf,"CPU %ld",cachedsi.dwProcessorType);
-        continue;
-        }
-        /* old 2.0 method */
-        if (!lstrncmpiA(line, "cpu",strlen("cpu"))) {
-        if (    isdigit (value[0]) && value[1] == '8' &&
-            value[2] == '6' && value[3] == 0
-           ) {
-            switch (value[0] - '0') {
-            case 3: cachedsi.dwProcessorType = PROCESSOR_INTEL_386;
-            cachedsi.wProcessorLevel= 3;
-            break;
-            case 4: cachedsi.dwProcessorType = PROCESSOR_INTEL_486;
-            cachedsi.wProcessorLevel= 4;
-            break;
-            case 5: cachedsi.dwProcessorType = PROCESSOR_INTEL_PENTIUM;
-            cachedsi.wProcessorLevel= 5;
-            break;
-            case 6: cachedsi.dwProcessorType = PROCESSOR_INTEL_PENTIUM;
-            cachedsi.wProcessorLevel= 5;
-            break;
-            default:cachedsi.dwProcessorType = PROCESSOR_INTEL_PENTIUM;
-            cachedsi.wProcessorLevel= 5;
-            break;
-            }
-        }
-        /* set the CPU type of the current processor */
-        sprintf(buf,"CPU %ld",cachedsi.dwProcessorType);
-        continue;
-        }
-        if (!lstrncmpiA(line,"fdiv_bug",strlen("fdiv_bug"))) {
-        if (!lstrncmpiA(value,"yes",3))
-            PF[PF_FLOATING_POINT_PRECISION_ERRATA] = TRUE;
-
-        continue;
-        }
-        if (!lstrncmpiA(line,"fpu",strlen("fpu"))) {
-        if (!lstrncmpiA(value,"no",2))
-            PF[PF_FLOATING_POINT_EMULATED] = TRUE;
-
-        continue;
-        }
-        if (!lstrncmpiA(line,"processor",strlen("processor"))) {
-        /* processor number counts up...*/
-        unsigned int x;
-
-        if (sscanf(value,"%d",&x))
-            if (x+1>cachedsi.dwNumberOfProcessors)
-            cachedsi.dwNumberOfProcessors=x+1;
-
-        /* Create a new processor subkey on a multiprocessor
-         * system
-         */
-        sprintf(buf,"%d",x);
-        }
-        if (!lstrncmpiA(line,"stepping",strlen("stepping"))) {
-        int    x;
-
-        if (sscanf(value,"%d",&x))
-            cachedsi.wProcessorRevision = x;
-        }
-        if
-        ( (!lstrncmpiA(line,"flags",strlen("flags")))
-          || (!lstrncmpiA(line,"features",strlen("features"))) )
-        {
-        if (strstr(value,"cx8"))
-            PF[PF_COMPARE_EXCHANGE_DOUBLE] = TRUE;
-        if (strstr(value,"mmx"))
-            PF[PF_MMX_INSTRUCTIONS_AVAILABLE] = TRUE;
-        if (strstr(value,"tsc"))
-            PF[PF_RDTSC_INSTRUCTION_AVAILABLE] = TRUE;
-        if (strstr(value,"xmm"))
-            PF[PF_XMMI_INSTRUCTIONS_AVAILABLE] = TRUE;
-        if (strstr(value,"3dnow"))
-            PF[PF_AMD3D_INSTRUCTIONS_AVAILABLE] = TRUE;
-        }
-    }
-    fclose (f);
-    /*
-     *    ad hoc fix for smp machines.
-     *    some problems on WaitForSingleObject,CreateEvent,SetEvent
-     *            CreateThread ...etc..
-     *
-     */
-    cachedsi.dwNumberOfProcessors=1;
+       char buf[20];
+       char line[200];
+       FILE *f = fopen ("/proc/cpuinfo", "r");
+
+       if (!f)
+           return;
+       while (fgets(line,200,f)!=NULL) {
+           char        *s,*value;
+
+           /* NOTE: the ':' is the only character we can rely on */
+           if (!(value = strchr(line,':')))
+               continue;
+           /* terminate the valuename */
+           *value++ = '\0';
+           /* skip any leading spaces */
+           while (*value==' ') value++;
+           if ((s=strchr(value,'\n')))
+               *s='\0';
+
+           /* 2.1 method */
+           if (!lstrncmpiA(line, "cpu family",strlen("cpu family"))) {
+               if (isdigit (value[0])) {
+                   switch (value[0] - '0') {
+                   case 3: cachedsi.dwProcessorType = PROCESSOR_INTEL_386;
+                   cachedsi.wProcessorLevel= 3;
+                   break;
+                   case 4: cachedsi.dwProcessorType = PROCESSOR_INTEL_486;
+                   cachedsi.wProcessorLevel= 4;
+                   break;
+                   case 5: cachedsi.dwProcessorType = PROCESSOR_INTEL_PENTIUM;
+                   cachedsi.wProcessorLevel= 5;
+                   break;
+                   case 6: cachedsi.dwProcessorType = PROCESSOR_INTEL_PENTIUM;
+                   cachedsi.wProcessorLevel= 5;
+                   break;
+                   default:cachedsi.dwProcessorType = PROCESSOR_INTEL_PENTIUM;
+                   cachedsi.wProcessorLevel= 5;
+                   break;
+                   }
+               }
+               /* set the CPU type of the current processor */
+               sprintf(buf,"CPU %ld",cachedsi.dwProcessorType);
+               continue;
+           }
+           /* old 2.0 method */
+           if (!lstrncmpiA(line, "cpu",strlen("cpu"))) {
+               if (    isdigit (value[0]) && value[1] == '8' &&
+                       value[2] == '6' && value[3] == 0
+                  ) {
+                   switch (value[0] - '0') {
+                   case 3: cachedsi.dwProcessorType = PROCESSOR_INTEL_386;
+                   cachedsi.wProcessorLevel= 3;
+                   break;
+                   case 4: cachedsi.dwProcessorType = PROCESSOR_INTEL_486;
+                   cachedsi.wProcessorLevel= 4;
+                   break;
+                   case 5: cachedsi.dwProcessorType = PROCESSOR_INTEL_PENTIUM;
+                   cachedsi.wProcessorLevel= 5;
+                   break;
+                   case 6: cachedsi.dwProcessorType = PROCESSOR_INTEL_PENTIUM;
+                   cachedsi.wProcessorLevel= 5;
+                   break;
+                   default:cachedsi.dwProcessorType = PROCESSOR_INTEL_PENTIUM;
+                   cachedsi.wProcessorLevel= 5;
+                   break;
+                   }
+               }
+               /* set the CPU type of the current processor */
+               sprintf(buf,"CPU %ld",cachedsi.dwProcessorType);
+               continue;
+           }
+           if (!lstrncmpiA(line,"fdiv_bug",strlen("fdiv_bug"))) {
+               if (!lstrncmpiA(value,"yes",3))
+                   PF[PF_FLOATING_POINT_PRECISION_ERRATA] = TRUE;
+
+               continue;
+           }
+           if (!lstrncmpiA(line,"fpu",strlen("fpu"))) {
+               if (!lstrncmpiA(value,"no",2))
+                   PF[PF_FLOATING_POINT_EMULATED] = TRUE;
+
+               continue;
+           }
+           if (!lstrncmpiA(line,"processor",strlen("processor"))) {
+               /* processor number counts up...*/
+               unsigned int x;
+
+               if (sscanf(value,"%d",&x))
+                   if (x+1>cachedsi.dwNumberOfProcessors)
+                       cachedsi.dwNumberOfProcessors=x+1;
+
+               /* Create a new processor subkey on a multiprocessor
+                * system
+                */
+               sprintf(buf,"%d",x);
+           }
+           if (!lstrncmpiA(line,"stepping",strlen("stepping"))) {
+               int     x;
+
+               if (sscanf(value,"%d",&x))
+                   cachedsi.wProcessorRevision = x;
+           }
+           if
+               ( (!lstrncmpiA(line,"flags",strlen("flags")))
+                 || (!lstrncmpiA(line,"features",strlen("features"))) )
+           {
+               if (strstr(value,"cx8"))
+                   PF[PF_COMPARE_EXCHANGE_DOUBLE] = TRUE;
+               if (strstr(value,"mmx"))
+                   PF[PF_MMX_INSTRUCTIONS_AVAILABLE] = TRUE;
+               if (strstr(value,"tsc"))
+                   PF[PF_RDTSC_INSTRUCTION_AVAILABLE] = TRUE;
+               if (strstr(value,"xmm"))
+                   PF[PF_XMMI_INSTRUCTIONS_AVAILABLE] = TRUE;
+               if (strstr(value,"3dnow"))
+                   PF[PF_AMD3D_INSTRUCTIONS_AVAILABLE] = TRUE;
+           }
+       }
+       fclose (f);
+       /*
+        *      ad hoc fix for smp machines.
+        *      some problems on WaitForSingleObject,CreateEvent,SetEvent
+        *                      CreateThread ...etc..
+        *
+        */
+       cachedsi.dwNumberOfProcessors=1;
     }
 #endif /* __linux__ */
     cache = 1;
@@ -1187,8 +1187,8 @@ static WIN_BOOL WINAPI expIsProcessorFeaturePresent(DWORD v)
     WIN_BOOL result = 0;
     if (!pf_set)
     {
-    SYSTEM_INFO si;
-    expGetSystemInfo(&si);
+       SYSTEM_INFO si;
+       expGetSystemInfo(&si);
     }
     if(v<64) result=PF[v];
     dbgprintf("IsProcessorFeaturePresent(0x%x) => 0x%x\n", v, result);
@@ -1207,9 +1207,9 @@ static HANDLE WINAPI expHeapCreate(long flags, long init_size, long max_size)
     //    printf("HeapCreate:");
     HANDLE result;
     if(init_size==0)
-    result=(HANDLE)my_mreq(0x110000, 0);
+       result=(HANDLE)my_mreq(0x110000, 0);
     else
-    result=(HANDLE)my_mreq((init_size + 0xfff) & 0x7ffff000 , 0);
+       result=(HANDLE)my_mreq((init_size + 0xfff) & 0x7ffff000 , 0);
     dbgprintf("HeapCreate(flags 0x%x, initial size %d, maximum size %d) => 0x%x\n", flags, init_size, max_size, result);
     return result;
 }
@@ -1233,7 +1233,7 @@ static void* WINAPI expHeapAlloc(HANDLE heap, int flags, int size)
     //if (size == 22276) trapbug();
     z=my_mreq((size + 0xfff) & 0x7ffff000, (flags & HEAP_ZERO_MEMORY));
     if(z==0)
-    printf("HeapAlloc failure\n");
+       printf("HeapAlloc failure\n");
     dbgprintf("HeapAlloc(heap 0x%x, flags 0x%x, size %d) => 0x%x\n", heap, flags, size, z);
     heapfreehack = 0; // reset
     return z;
@@ -1249,15 +1249,15 @@ static long WINAPI expHeapFree(HANDLE heap, DWORD dwFlags, LPVOID lpMem)
 {
     dbgprintf("HeapFree(0x%x, 0x%x, pointer 0x%x) => 1\n", heap, dwFlags, lpMem);
     if (heapfreehack != lpMem && lpMem != (void*)0xffffffff
-    && lpMem != (void*)0xbdbdbdbd)
-    // 0xbdbdbdbd is for i263_drv.drv && libefence
-    // it seems to be reading from relased memory
+       && lpMem != (void*)0xbdbdbdbd)
+       // 0xbdbdbdbd is for i263_drv.drv && libefence
+       // it seems to be reading from relased memory
         // EF_PROTECT_FREE doens't show any probleme
-    my_release(lpMem);
+       my_release(lpMem);
     else
     {
-    if (!heapfreehackshown++)
-        printf("Info: HeapFree deallocating same memory twice! (%p)\n", lpMem);
+       if (!heapfreehackshown++)
+           printf("Info: HeapFree deallocating same memory twice! (%p)\n", lpMem);
     }
     heapfreehack = lpMem;
     return 1;
@@ -1283,7 +1283,7 @@ static void* WINAPI expVirtualAlloc(void* v1, long v2, long v3, long v4)
 {
     void* z = VirtualAlloc(v1, v2, v3, v4);
     if(z==0)
-    printf("VirtualAlloc failure\n");
+       printf("VirtualAlloc failure\n");
     dbgprintf("VirtualAlloc(0x%x, %d, %d, %d) => 0x%x \n",v1,v2,v3,v4, z);
     return z;
 }
@@ -1317,8 +1317,8 @@ static int critsecs_get_pos(CRITICAL_SECTION *cs_win)
     int i;
 
     for (i=0; i < CRITSECS_LIST_MAX; i++)
-    if (critsecs_list[i].cs_win == cs_win)
-        return(i);
+       if (critsecs_list[i].cs_win == cs_win)
+           return(i);
     return(-1);
 }
 
@@ -1327,8 +1327,8 @@ static int critsecs_get_unused(void)
     int i;
 
     for (i=0; i < CRITSECS_LIST_MAX; i++)
-    if (critsecs_list[i].cs_win == NULL)
-        return(i);
+       if (critsecs_list[i].cs_win == NULL)
+           return(i);
     return(-1);
 }
 
@@ -1337,8 +1337,8 @@ struct CRITSECT *critsecs_get_unix(CRITICAL_SECTION *cs_win)
     int i;
 
     for (i=0; i < CRITSECS_LIST_MAX; i++)
-    if (critsecs_list[i].cs_win == cs_win && critsecs_list[i].cs_unix)
-        return(critsecs_list[i].cs_unix);
+       if (critsecs_list[i].cs_win == cs_win && critsecs_list[i].cs_unix)
+           return(critsecs_list[i].cs_unix);
     return(NULL);
 }
 #endif
@@ -1355,36 +1355,36 @@ static void WINAPI expInitializeCriticalSection(CRITICAL_SECTION* c)
     /*    pthread_mutex_init((pthread_mutex_t*)c, NULL);   */
 #ifdef CRITSECS_NEWTYPE
     {
-    struct CRITSECT *cs;
-    int i = critsecs_get_unused();
-
-    if (i < 0)
-    {
-        printf("InitializeCriticalSection(%p) - no more space in list\n", c);
-        return;
-    }
-    dbgprintf("got unused space at %d\n", i);
-    cs = malloc(sizeof(struct CRITSECT));
-    if (!cs)
-    {
-        printf("InitializeCriticalSection(%p) - out of memory\n", c);
-        return;
-    }
-    pthread_mutex_init(&cs->mutex, NULL);
-    cs->locked = 0;
-    critsecs_list[i].cs_win = c;
-    critsecs_list[i].cs_unix = cs;
-    dbgprintf("InitializeCriticalSection -> itemno=%d, cs_win=%p, cs_unix=%p\n",
-          i, c, cs);
+       struct CRITSECT *cs;
+       int i = critsecs_get_unused();
+
+       if (i < 0)
+       {
+           printf("InitializeCriticalSection(%p) - no more space in list\n", c);
+           return;
+       }
+       dbgprintf("got unused space at %d\n", i);
+       cs = malloc(sizeof(struct CRITSECT));
+       if (!cs)
+       {
+           printf("InitializeCriticalSection(%p) - out of memory\n", c);
+           return;
+       }
+       pthread_mutex_init(&cs->mutex, NULL);
+       cs->locked = 0;
+       critsecs_list[i].cs_win = c;
+       critsecs_list[i].cs_unix = cs;
+       dbgprintf("InitializeCriticalSection -> itemno=%d, cs_win=%p, cs_unix=%p\n",
+                 i, c, cs);
     }
 #else
     {
-    struct CRITSECT* cs = mreq_private(sizeof(struct CRITSECT) + sizeof(CRITICAL_SECTION),
-                       0, AREATYPE_CRITSECT);
-    pthread_mutex_init(&cs->mutex, NULL);
-    cs->locked=0;
+       struct CRITSECT* cs = mreq_private(sizeof(struct CRITSECT) + sizeof(CRITICAL_SECTION),
+                                          0, AREATYPE_CRITSECT);
+       pthread_mutex_init(&cs->mutex, NULL);
+       cs->locked=0;
         cs->deadbeef = 0xdeadbeef;
-    *(void**)c = cs;
+       *(void**)c = cs;
     }
 #endif
     return;
@@ -1400,18 +1400,18 @@ static void WINAPI expEnterCriticalSection(CRITICAL_SECTION* c)
     dbgprintf("EnterCriticalSection(0x%x) %p\n",c, cs);
     if (!cs)
     {
-    dbgprintf("entered uninitialized critisec!\n");
-    expInitializeCriticalSection(c);
+       dbgprintf("entered uninitialized critisec!\n");
+       expInitializeCriticalSection(c);
 #ifdef CRITSECS_NEWTYPE
-    cs=critsecs_get_unix(c);
+       cs=critsecs_get_unix(c);
 #else
-    cs = (*(struct CRITSECT**)c);
+       cs = (*(struct CRITSECT**)c);
 #endif
-    dbgprintf("Win32 Warning: Accessed uninitialized Critical Section (%p)!\n", c);
+       dbgprintf("Win32 Warning: Accessed uninitialized Critical Section (%p)!\n", c);
     }
     if(cs->locked)
-    if(cs->id==pthread_self())
-        return;
+       if(cs->id==pthread_self())
+           return;
     pthread_mutex_lock(&(cs->mutex));
     cs->locked=1;
     cs->id=pthread_self();
@@ -1428,16 +1428,16 @@ static void WINAPI expLeaveCriticalSection(CRITICAL_SECTION* c)
     dbgprintf("LeaveCriticalSection(0x%x) 0x%x\n",c, cs);
     if (!cs)
     {
-    dbgprintf("Win32 Warning: Leaving uninitialized Critical Section %p!!\n", c);
-    return;
+       dbgprintf("Win32 Warning: Leaving uninitialized Critical Section %p!!\n", c);
+       return;
     }
     if (cs->locked)
     {
-    cs->locked=0;
-    pthread_mutex_unlock(&(cs->mutex));
+       cs->locked=0;
+       pthread_mutex_unlock(&(cs->mutex));
     }
     else
-    dbgprintf("Win32 Warning: Unlocking unlocked Critical Section %p!!\n", c);
+       dbgprintf("Win32 Warning: Unlocking unlocked Critical Section %p!!\n", c);
     return;
 }
 
@@ -1455,14 +1455,14 @@ static void WINAPI expDeleteCriticalSection(CRITICAL_SECTION *c)
 
     if (!cs)
     {
-    dbgprintf("Win32 Warning: Deleting uninitialized Critical Section %p!!\n", c);
-    return;
+       dbgprintf("Win32 Warning: Deleting uninitialized Critical Section %p!!\n", c);
+       return;
     }
+    
     if (cs->locked)
     {
-    dbgprintf("Win32 Warning: Deleting unlocked Critical Section %p!!\n", c);
-    pthread_mutex_unlock(&(cs->mutex));
+       dbgprintf("Win32 Warning: Deleting unlocked Critical Section %p!!\n", c);
+       pthread_mutex_unlock(&(cs->mutex));
     }
 
 #ifndef GARBAGE
@@ -1472,18 +1472,18 @@ static void WINAPI expDeleteCriticalSection(CRITICAL_SECTION *c)
     my_release(cs);
 #ifdef CRITSECS_NEWTYPE
     {
-    int i = critsecs_get_pos(c);
+       int i = critsecs_get_pos(c);
 
-    if (i < 0)
-    {
-        printf("DeleteCriticalSection(%p) error (critsec not found)\n", c);
-        return;
-    }
+       if (i < 0)
+       {
+           printf("DeleteCriticalSection(%p) error (critsec not found)\n", c);
+           return;
+       }
 
-    critsecs_list[i].cs_win = NULL;
-    expfree(critsecs_list[i].cs_unix);
-    critsecs_list[i].cs_unix = NULL;
-    dbgprintf("DeleteCriticalSection -> itemno=%d\n", i);
+       critsecs_list[i].cs_win = NULL;
+       expfree(critsecs_list[i].cs_unix);
+       critsecs_list[i].cs_unix = NULL;
+       dbgprintf("DeleteCriticalSection -> itemno=%d\n", i);
     }
 #endif
     return;
@@ -1511,12 +1511,12 @@ static int WINAPI expTlsAlloc()
 {
     int i;
     for(i=0; i<64; i++)
-    if(tls_use_map[i]==0)
-    {
-        tls_use_map[i]=1;
-        dbgprintf("TlsAlloc() => %d\n",i);
-        return i;
-    }
+       if(tls_use_map[i]==0)
+       {
+           tls_use_map[i]=1;
+           dbgprintf("TlsAlloc() => %d\n",i);
+           return i;
+       }
     dbgprintf("TlsAlloc() => -1 (ERROR)\n");
     return -1;
 }
@@ -1527,7 +1527,7 @@ static int WINAPI expTlsSetValue(int index, void* value)
     dbgprintf("TlsSetValue(%d,0x%x) => 1\n",index,value);
 //    if((index<0) || (index>64))
     if((index>=64))
-    return 0;
+       return 0;
     *(void**)((char*)fs_seg+0x88+4*index) = value;
     return 1;
 }
@@ -1545,7 +1545,7 @@ static int WINAPI expTlsFree(int idx)
     int index = (int) idx;
     dbgprintf("TlsFree(%d)\n",index);
     if((index<0) || (index>64))
-    return 0;
+       return 0;
     tls_use_map[index]=0;
     return 1;
 }
@@ -1562,19 +1562,19 @@ static void* WINAPI expTlsAlloc()
 {
     if (g_tls == NULL)
     {
-    g_tls=my_mreq(sizeof(tls_t), 0);
-    g_tls->next=g_tls->prev=NULL;
+       g_tls=my_mreq(sizeof(tls_t), 0);
+       g_tls->next=g_tls->prev=NULL;
     }
     else
     {
-    g_tls->next=my_mreq(sizeof(tls_t), 0);
-    g_tls->next->prev=g_tls;
-    g_tls->next->next=NULL;
-    g_tls=g_tls->next;
+       g_tls->next=my_mreq(sizeof(tls_t), 0);
+       g_tls->next->prev=g_tls;
+       g_tls->next->next=NULL;
+       g_tls=g_tls->next;
     }
     dbgprintf("TlsAlloc() => 0x%x\n", g_tls);
     if (g_tls)
-    g_tls->value=0; /* XXX For Divx.dll */
+       g_tls->value=0; /* XXX For Divx.dll */
     return g_tls;
 }
 
@@ -1583,11 +1583,11 @@ static int WINAPI expTlsSetValue(void* idx, void* value)
     tls_t* index = (tls_t*) idx;
     int result;
     if(index==0)
-    result=0;
+       result=0;
     else
     {
-    index->value=value;
-    result=1;
+       index->value=value;
+       result=1;
     }
     dbgprintf("TlsSetValue(index 0x%x, value 0x%x) => %d \n", index, value, result );
     return result;
@@ -1597,9 +1597,9 @@ static void* WINAPI expTlsGetValue(void* idx)
     tls_t* index = (tls_t*) idx;
     void* result;
     if(index==0)
-    result=0;
+       result=0;
     else
-    result=index->value;
+       result=index->value;
     dbgprintf("TlsGetValue(index 0x%x) => 0x%x\n", index, result);
     return result;
 }
@@ -1608,17 +1608,17 @@ static int WINAPI expTlsFree(void* idx)
     tls_t* index = (tls_t*) idx;
     int result;
     if(index==0)
-    result=0;
+       result=0;
     else
     {
-    if(index->next)
-        index->next->prev=index->prev;
-    if(index->prev)
-        index->prev->next=index->next;
-    if (g_tls == index)
+       if(index->next)
+           index->next->prev=index->prev;
+       if(index->prev)
+           index->prev->next=index->next;
+       if (g_tls == index)
             g_tls = index->prev;
-    my_release((void*)index);
-    result=1;
+       my_release((void*)index);
+       result=1;
     }
     dbgprintf("TlsFree(index 0x%x) => %d\n", index, result);
     return result;
@@ -1629,7 +1629,7 @@ static void* WINAPI expLocalAlloc(int flags, int size)
 {
     void* z = my_mreq(size, (flags & GMEM_ZEROINIT));
     if (z == 0)
-    printf("LocalAlloc() failed\n");
+       printf("LocalAlloc() failed\n");
     dbgprintf("LocalAlloc(%d, flags 0x%x) => 0x%x\n", size, flags, z);
     return z;
 }
@@ -1641,8 +1641,8 @@ static void* WINAPI expLocalReAlloc(int handle,int size, int flags)
 
     newpointer=NULL;
     if (flags & LMEM_MODIFY) {
-    dbgprintf("LocalReAlloc MODIFY\n");
-    return (void *)handle;
+       dbgprintf("LocalReAlloc MODIFY\n");
+       return (void *)handle;
     }
     oldsize = my_size((void *)handle);
     newpointer = my_realloc((void *)handle,size);
@@ -1666,7 +1666,7 @@ static void* WINAPI expGlobalAlloc(int flags, int size)
     //z=calloc(size, 1);
     //z=malloc(size);
     if(z==0)
-    printf("GlobalAlloc() failed\n");
+       printf("GlobalAlloc() failed\n");
     dbgprintf("GlobalAlloc(%d, flags 0x%x) => 0x%x\n", size, flags, z);
     return z;
 }
@@ -1683,23 +1683,23 @@ static int WINAPI expGlobalSize(void* amem)
     alloc_header* header = last_alloc;
     alloc_header* mem = (alloc_header*) amem - 1;
     if (amem == 0)
-    return 0;
+       return 0;
     pthread_mutex_lock(&memmut);
     while (header)
     {
-    if (header->deadbeef != 0xdeadbeef)
-    {
-        dbgprintf("FATAL found corrupted memory! %p  0x%lx  (%d)\n", header, header->deadbeef, alccnt);
-        break;
-    }
+       if (header->deadbeef != 0xdeadbeef)
+       {
+           dbgprintf("FATAL found corrupted memory! %p  0x%lx  (%d)\n", header, header->deadbeef, alccnt);
+           break;
+       }
 
-    if (header == mem)
-    {
-        size = header->size;
-        break;
-    }
+       if (header == mem)
+       {
+           size = header->size;
+           break;
+       }
 
-    header = header->prev;
+       header = header->prev;
     }
     pthread_mutex_unlock(&memmut);
 #endif
@@ -1719,10 +1719,10 @@ static int WINAPI expLoadStringA(long instance, long  id, void* buf, long size)
     int result=LoadStringA(instance, id, buf, size);
     //    if(buf)
     dbgprintf("LoadStringA(instance 0x%x, id 0x%x, buffer 0x%x, size %d) => %d ( %s )\n",
-          instance, id, buf, size, result, buf);
+             instance, id, buf, size, result, buf);
     //    else
     //    dbgprintf("LoadStringA(instance 0x%x, id 0x%x, buffer 0x%x, size %d) => %d\n",
-    //    instance, id, buf, size, result);
+    // instance, id, buf, size, result);
     return result;
 }
 
@@ -1732,27 +1732,27 @@ static long WINAPI expMultiByteToWideChar(long v1, long v2, char* s1, long siz1,
     int i;
     int result;
     if(s2==0)
-    result=1;
+       result=1;
     else
     {
-    if(siz1>siz2/2)siz1=siz2/2;
-    for(i=1; i<=siz1; i++)
-    {
-        *s2=*s1;
-        if(!*s1)break;
-        s2++;
-        s1++;
-    }
-    result=i;
+       if(siz1>siz2/2)siz1=siz2/2;
+       for(i=1; i<=siz1; i++)
+       {
+           *s2=*s1;
+           if(!*s1)break;
+           s2++;
+           s1++;
+       }
+       result=i;
     }
     if(s1)
-    dbgprintf("MultiByteToWideChar(codepage %d, flags 0x%x, string 0x%x='%s',"
-          "size %d, dest buffer 0x%x, dest size %d) => %d\n",
-          v1, v2, s1, s1, siz1, s2, siz2, result);
+       dbgprintf("MultiByteToWideChar(codepage %d, flags 0x%x, string 0x%x='%s',"
+                 "size %d, dest buffer 0x%x, dest size %d) => %d\n",
+                 v1, v2, s1, s1, siz1, s2, siz2, result);
     else
-    dbgprintf("MultiByteToWideChar(codepage %d, flags 0x%x, string NULL,"
-          "size %d, dest buffer 0x%x, dest size %d) =>\n",
-          v1, v2, siz1, s2, siz2, result);
+       dbgprintf("MultiByteToWideChar(codepage %d, flags 0x%x, string NULL,"
+                 "size %d, dest buffer 0x%x, dest size %d) =>\n",
+                 v1, v2, siz1, s2, siz2, result);
     return result;
 }
 static void wch_print(const short* str)
@@ -1762,11 +1762,11 @@ static void wch_print(const short* str)
     dbgprintf("\n");
 }
 static long WINAPI expWideCharToMultiByte(long v1, long v2, short* s1, long siz1,
-                      char* s2, int siz2, char* c3, int* siz3)
+                                         char* s2, int siz2, char* c3, int* siz3)
 {
     int result;
     dbgprintf("WideCharToMultiByte(codepage %d, flags 0x%x, src 0x%x, src size %d, "
-          "dest 0x%x, dest size %d, defch 0x%x, used_defch 0x%x)", v1, v2, s1, siz1, s2, siz2, c3, siz3);
+             "dest 0x%x, dest size %d, defch 0x%x, used_defch 0x%x)", v1, v2, s1, siz1, s2, siz2, c3, siz3);
     result=WideCharToMultiByte(v1, v2, s1, siz1, s2, siz2, c3, siz3);
     dbgprintf("=> %d\n", result);
     //if(s1)wch_print(s1);
@@ -1789,11 +1789,11 @@ static long WINAPI expGetVersionExA(OSVERSIONINFOA* c)
     strcpy(c->szCSDVersion, "Service Pack 3");
 #endif
     dbgprintf("  Major version: 4\n  Minor version: 0\n  Build number: 0x4000457\n"
-          "  Platform Id: VER_PLATFORM_WIN32_NT\n Version string: 'Service Pack 3'\n");
+             "  Platform Id: VER_PLATFORM_WIN32_NT\n Version string: 'Service Pack 3'\n");
     return 1;
 }
 static HANDLE WINAPI expCreateSemaphoreA(char* v1, long init_count,
-                     long max_count, char* name)
+                                        long max_count, char* name)
 {
     pthread_mutex_t *pm;
     pthread_cond_t  *pc;
@@ -1810,17 +1810,17 @@ static HANDLE WINAPI expCreateSemaphoreA(char* v1, long init_count,
      */
     if(mlist!=NULL)
     {
-    mutex_list* pp=mlist;
-    if(name!=NULL)
-        do
-    {
-        if((strcmp(pp->name, name)==0) && (pp->type==1))
-        {
-        dbgprintf("CreateSemaphoreA(0x%x, init_count %d, max_count %d, name 0x%x='%s') => 0x%x\n",
-              v1, init_count, max_count, name, name, mlist);
-        return (HANDLE)mlist;
-        }
-    }while((pp=pp->prev) != NULL);
+       mutex_list* pp=mlist;
+       if(name!=NULL)
+           do
+       {
+           if((strcmp(pp->name, name)==0) && (pp->type==1))
+           {
+               dbgprintf("CreateSemaphoreA(0x%x, init_count %d, max_count %d, name 0x%x='%s') => 0x%x\n",
+                         v1, init_count, max_count, name, name, mlist);
+               return (HANDLE)mlist;
+      &nb