⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 startup.c

📁 winNT技术操作系统,国外开放的原代码和LIUX一样
💻 C
📖 第 1 页 / 共 3 页
字号:
      return DD_FALSE;
    }

    mcvmList = mHALInfo.vmiData.dwNumHeaps;
    mpvmList = (VIDMEM*) DxHeapMemAlloc(sizeof(VIDMEM) * mcvmList);
    if (mpvmList == NULL)
    {      
      DxHeapMemFree(This->lpLcl->lpGbl->lpModeInfo);
      DeleteDC((HDC)This->lpLcl->hDC);     
      // FIXME Close DX fristcall and second call
      return DD_FALSE;
    }

    mcFourCC = mHALInfo.ddCaps.dwNumFourCCCodes;
    mpFourCC = (DWORD *) DxHeapMemAlloc(sizeof(DWORD) * mcFourCC);
    if (mpFourCC == NULL)
    {
      DxHeapMemFree(mpvmList);
      DxHeapMemFree(This->lpLcl->lpGbl->lpModeInfo);
      DeleteDC((HDC)This->lpLcl->hDC);      
      // FIXME Close DX fristcall and second call
      return DD_FALSE;
    }

    mcTextures = mD3dDriverData.dwNumTextureFormats;
    mpTextures = (DDSURFACEDESC*) DxHeapMemAlloc(sizeof(DDSURFACEDESC) * mcTextures);
    if (mpTextures == NULL)
    {      
      DxHeapMemFree( mpFourCC);
      DxHeapMemFree( mpvmList);
      DxHeapMemFree( This->lpLcl->lpGbl->lpModeInfo);
      DeleteDC((HDC)This->lpLcl->hDC);     
      // FIXME Close DX fristcall and second call
      return DD_FALSE;
    }

    mHALInfo.vmiData.pvmList = mpvmList;
    mHALInfo.lpdwFourCC = mpFourCC;
    mD3dDriverData.lpTextureFormats = (DDSURFACEDESC*) mpTextures;

    if (!DdQueryDirectDrawObject(
                                    This->lpLcl->lpGbl,
                                    &mHALInfo,
                                    &ddgbl.lpDDCBtmp->HALDD,
                                    &ddgbl.lpDDCBtmp->HALDDSurface,
                                    &ddgbl.lpDDCBtmp->HALDDPalette, 
                                    &mD3dCallbacks,
                                    &mD3dDriverData,
                                    &ddgbl.lpDDCBtmp->HALDDExeBuf,
                                    (DDSURFACEDESC*)mpTextures,
                                    mpFourCC,
                                    mpvmList))
  
    {
      DxHeapMemFree(mpTextures);
      DxHeapMemFree(mpFourCC);
      DxHeapMemFree(mpvmList);
      DxHeapMemFree(This->lpLcl->lpGbl->lpModeInfo);
      DeleteDC((HDC)This->lpLcl->hDC);      
      // FIXME Close DX fristcall and second call
      return DD_FALSE;
    }


   /*
      Copy over from HalInfo to DirectDrawGlobal
   */

  // this is wrong, cDriverName need be in ASC code not UNICODE 
  //memcpy(mDDrawGlobal.cDriverName, mDisplayAdapter, sizeof(wchar)*MAX_DRIVER_NAME);

  memcpy(&ddgbl.vmiData, &mHALInfo.vmiData,sizeof(VIDMEMINFO));
  memcpy(&ddgbl.ddCaps,  &mHALInfo.ddCaps,sizeof(DDCORECAPS));
  
  mHALInfo.dwNumModes = 1;
  mHALInfo.lpModeInfo = This->lpLcl->lpGbl->lpModeInfo;
  mHALInfo.dwMonitorFrequency = This->lpLcl->lpGbl->lpModeInfo[0].wRefreshRate;

  This->lpLcl->lpGbl->dwMonitorFrequency = mHALInfo.dwMonitorFrequency;
  This->lpLcl->lpGbl->dwModeIndex        = mHALInfo.dwModeIndex;
  This->lpLcl->lpGbl->dwNumModes         = mHALInfo.dwNumModes;
  This->lpLcl->lpGbl->lpModeInfo         = mHALInfo.lpModeInfo;
  This->lpLcl->lpGbl->hInstance          = mHALInfo.hInstance;    
  
  This->lpLcl->lpGbl->lp16DD = This->lpLcl->lpGbl;
  
   
   memset(&DriverInfo,0, sizeof(DDHAL_GETDRIVERINFODATA));
   DriverInfo.dwSize = sizeof(DDHAL_GETDRIVERINFODATA);
   DriverInfo.dwContext = This->lpLcl->lpGbl->hDD; 

  /* Get the MiscellaneousCallbacks  */    
  DriverInfo.guidInfo = GUID_MiscellaneousCallbacks;
  DriverInfo.lpvData = &ddgbl.lpDDCBtmp->HALDDMiscellaneous;
  DriverInfo.dwExpectedSize = sizeof(DDHAL_DDMISCELLANEOUSCALLBACKS);
  mHALInfo.GetDriverInfo(&DriverInfo);


    /* FIXME 
       The 3d and private data are not save at moment 

       we need lest the private data being setup
       for some driver are puting kmode memory there
       the memory often contain the private struct +
       surface, see MS DDK how MS example driver using 
       it

       the 3d interface are not so improten if u do not
       want the 3d, and we are not writing 3d code yet
       so we be okay for now. 
     */

  
  return DD_OK;
}

HRESULT WINAPI 
StartDirectDrawHel(LPDIRECTDRAW* iface, BOOL reenable)
{
    LPDDRAWI_DIRECTDRAW_INT This = (LPDDRAWI_DIRECTDRAW_INT)iface;

    This->lpLcl->lpGbl->lpDDCBtmp->HELDD.CanCreateSurface     = HelDdCanCreateSurface;	
    This->lpLcl->lpGbl->lpDDCBtmp->HELDD.CreateSurface        = HelDdCreateSurface;		
    This->lpLcl->lpGbl->lpDDCBtmp->HELDD.CreatePalette        = HelDdCreatePalette;
    This->lpLcl->lpGbl->lpDDCBtmp->HELDD.DestroyDriver        = HelDdDestroyDriver;
    This->lpLcl->lpGbl->lpDDCBtmp->HELDD.FlipToGDISurface     = HelDdFlipToGDISurface;
    This->lpLcl->lpGbl->lpDDCBtmp->HELDD.GetScanLine          = HelDdGetScanLine;
    This->lpLcl->lpGbl->lpDDCBtmp->HELDD.SetColorKey          = HelDdSetColorKey;
    This->lpLcl->lpGbl->lpDDCBtmp->HELDD.SetExclusiveMode     = HelDdSetExclusiveMode;
    This->lpLcl->lpGbl->lpDDCBtmp->HELDD.SetMode              = HelDdSetMode;
    This->lpLcl->lpGbl->lpDDCBtmp->HELDD.WaitForVerticalBlank = HelDdWaitForVerticalBlank;

    This->lpLcl->lpGbl->lpDDCBtmp->HELDD.dwFlags =  DDHAL_CB32_CANCREATESURFACE     |
                                          DDHAL_CB32_CREATESURFACE        |
                                          DDHAL_CB32_CREATEPALETTE        |
                                          DDHAL_CB32_DESTROYDRIVER        |
                                          DDHAL_CB32_FLIPTOGDISURFACE     |
                                          DDHAL_CB32_GETSCANLINE          |
                                          DDHAL_CB32_SETCOLORKEY          |
                                          DDHAL_CB32_SETEXCLUSIVEMODE     |
                                          DDHAL_CB32_SETMODE              |
                                          DDHAL_CB32_WAITFORVERTICALBLANK ;

    This->lpLcl->lpGbl->lpDDCBtmp->HELDD.dwSize = sizeof(This->lpLcl->lpDDCB->HELDD);

    This->lpLcl->lpGbl->lpDDCBtmp->HELDDSurface.AddAttachedSurface = HelDdSurfAddAttachedSurface;
    This->lpLcl->lpGbl->lpDDCBtmp->HELDDSurface.Blt = HelDdSurfBlt;
    This->lpLcl->lpGbl->lpDDCBtmp->HELDDSurface.DestroySurface = HelDdSurfDestroySurface;
    This->lpLcl->lpGbl->lpDDCBtmp->HELDDSurface.Flip = HelDdSurfFlip;
    This->lpLcl->lpGbl->lpDDCBtmp->HELDDSurface.GetBltStatus = HelDdSurfGetBltStatus;
    This->lpLcl->lpGbl->lpDDCBtmp->HELDDSurface.GetFlipStatus = HelDdSurfGetFlipStatus;
    This->lpLcl->lpGbl->lpDDCBtmp->HELDDSurface.Lock = HelDdSurfLock;
    This->lpLcl->lpGbl->lpDDCBtmp->HELDDSurface.reserved4 = HelDdSurfreserved4;
    This->lpLcl->lpGbl->lpDDCBtmp->HELDDSurface.SetClipList = HelDdSurfSetClipList;
    This->lpLcl->lpGbl->lpDDCBtmp->HELDDSurface.SetColorKey = HelDdSurfSetColorKey;
    This->lpLcl->lpGbl->lpDDCBtmp->HELDDSurface.SetOverlayPosition = HelDdSurfSetOverlayPosition;
    This->lpLcl->lpGbl->lpDDCBtmp->HELDDSurface.SetPalette = HelDdSurfSetPalette;
    This->lpLcl->lpGbl->lpDDCBtmp->HELDDSurface.Unlock = HelDdSurfUnlock;
    This->lpLcl->lpGbl->lpDDCBtmp->HELDDSurface.UpdateOverlay = HelDdSurfUpdateOverlay;
    This->lpLcl->lpGbl->lpDDCBtmp->HELDDSurface.dwFlags = DDHAL_SURFCB32_ADDATTACHEDSURFACE |
                                                DDHAL_SURFCB32_BLT                |
                                                DDHAL_SURFCB32_DESTROYSURFACE     |
                                                DDHAL_SURFCB32_FLIP               |
                                                DDHAL_SURFCB32_GETBLTSTATUS       |
                                                DDHAL_SURFCB32_GETFLIPSTATUS      |
                                                DDHAL_SURFCB32_LOCK               |
                                                DDHAL_SURFCB32_RESERVED4          |
                                                DDHAL_SURFCB32_SETCLIPLIST        |
                                                DDHAL_SURFCB32_SETCOLORKEY        |
                                                DDHAL_SURFCB32_SETOVERLAYPOSITION |
                                                DDHAL_SURFCB32_SETPALETTE         |
                                                DDHAL_SURFCB32_UNLOCK             |
                                                DDHAL_SURFCB32_UPDATEOVERLAY;

    This->lpLcl->lpGbl->lpDDCBtmp->HELDDSurface.dwSize = sizeof(This->lpLcl->lpDDCB->HELDDSurface);

    /*
    This->lpLcl->lpDDCB->HELDDPalette.DestroyPalette  = HelDdPalDestroyPalette; 
    This->lpLcl->lpDDCB->HELDDPalette.SetEntries = HelDdPalSetEntries;
    This->lpLcl->lpDDCB->HELDDPalette.dwSize = sizeof(This->lpLcl->lpDDCB->HELDDPalette);
    */

    /*
    This->lpLcl->lpDDCB->HELDDExeBuf.CanCreateExecuteBuffer = HelDdExeCanCreateExecuteBuffer;
    This->lpLcl->lpDDCB->HELDDExeBuf.CreateExecuteBuffer = HelDdExeCreateExecuteBuffer;
    This->lpLcl->lpDDCB->HELDDExeBuf.DestroyExecuteBuffer = HelDdExeDestroyExecuteBuffer;
    This->lpLcl->lpDDCB->HELDDExeBuf.LockExecuteBuffer = HelDdExeLockExecuteBuffer;
    This->lpLcl->lpDDCB->HELDDExeBuf.UnlockExecuteBuffer = HelDdExeUnlockExecuteBuffer;
    */

    return DD_OK;
}

HRESULT 
WINAPI 
Create_DirectDraw (LPGUID pGUID, 
                   LPDIRECTDRAW* pIface, 
                   REFIID id, 
                   BOOL ex)
{   
    LPDDRAWI_DIRECTDRAW_INT This = (LPDDRAWI_DIRECTDRAW_INT)*pIface;
    
    DX_WINDBG_trace();

    if (!IsEqualGUID(&IID_IDirectDraw7, id))
    {
        return DDERR_INVALIDDIRECTDRAWGUID;
    }

    if (This == NULL)
    {
        LPDDRAWI_DIRECTDRAW_INT memThis;
        
       /* We do not have any DirectDraw interface alloc 
        * or a idot send in pIface as NULL
        */
        memThis = DxHeapMemAlloc(sizeof(DDRAWI_DIRECTDRAW_INT));
        This = memThis;
        if (This == NULL) 
        {
            if (memThis != NULL)
            {
                /* do not create memmory leak if some 
                 * idot send in pIface as NULL
                 */
                DxHeapMemFree(memThis);
            }
            return DDERR_OUTOFMEMORY;
        }
    }
    else
    {
        /* We got the DirectDraw interface alloc and we need create the link */

        LPDDRAWI_DIRECTDRAW_INT  newThis;	
        newThis = DxHeapMemAlloc(sizeof(DDRAWI_DIRECTDRAW_INT));
        if (newThis == NULL) 
        {
            return DDERR_OUTOFMEMORY;
        }
        
        /* we need check the GUID lpGUID what type it is */
        if (pGUID != DDCREATE_HARDWAREONLY)
        {
            if (pGUID !=NULL)
            {
                This = newThis;
                return DDERR_INVALIDDIRECTDRAWGUID;
            }
        }

        newThis->lpLink = This;
        This = newThis;		
    }

    This->lpLcl = DxHeapMemAlloc(sizeof(DDRAWI_DIRECTDRAW_INT));

    if (This->lpLcl == NULL)
    {
        /* FIXME cleanup */
        return DDERR_OUTOFMEMORY;
    }

    /*
       FIXME 
       read dwAppHackFlags flag from the system register instead for hard code it
     */
    This->lpLcl->dwAppHackFlags = 0; 
    This->lpLcl->dwHotTracking = 0;
    This->lpLcl->dwIMEState = 0;
    This->lpLcl->dwLocalFlags = DDRAWILCL_DIRECTDRAW7;
    This->lpLcl->dwLocalRefCnt = 0;
    /* 
       do not rest this flag to NULL it need be unistae for some reason other wise 
       somet thing will crash dwObsolete1 seam being use for something this was a 
       supriese for me
    */
    //This->lpLcl->dwObsolete1 = 0;
    This->lpLcl->dwProcessId = 0;
    This->lpLcl->dwUnused0 = 0;
    This->lpLcl->hD3DInstance = NULL;
    This->lpLcl->hDC = 0;	
    This->lpLcl->hDDVxd = 0;
    This->lpLcl->hFocusWnd = 0;
    This->lpLcl->hGammaCalibrator = 0;
    /* Do mot inistate this value if we do we can not open the HAL interface */
    //This->lpLcl->hWnd = 0;
    This->lpLcl->hWndPopup = 0;	
    This->lpLcl->lpCB = NULL;
    This->lpLcl->lpDDCB = NULL;
    This->lpLcl->lpDDMore = 0;
    This->lpLcl->lpGammaCalibrator = 0;
    This->lpLcl->lpGbl = &ddgbl;

    /* Do mot inistate this value if we do we can not open the HAL interface */
    //This->lpLcl->lpPrimary = NULL;
    This->lpLcl->pD3DIUnknown = NULL;
    This->lpLcl->pUnkOuter = NULL;

    *pIface = (LPDIRECTDRAW)This;

    if(Main_DirectDraw_QueryInterface((LPDIRECTDRAW7)This, id, (void**)&pIface) != S_OK)
    {
        return DDERR_INVALIDPARAMS;
    }

    if (StartDirectDraw((LPDIRECTDRAW*)This, pGUID, FALSE) == DD_OK);
    {        
        return DD_OK;
    }
    return DDERR_INVALIDPARAMS;
}



HRESULT WINAPI 
ReCreateDirectDraw(LPDIRECTDRAW* iface)
{
    LPDDRAWI_DIRECTDRAW_INT This = (LPDDRAWI_DIRECTDRAW_INT)iface;

    DdDeleteDirectDrawObject(This->lpLcl->lpGbl);

    if ((This->lpLcl->lpGbl->dwFlags & DDRAWI_NOHARDWARE) != DDRAWI_NOHARDWARE)
    {
       if (This->lpLcl->lpGbl->dwFlags & DDRAWI_EMULATIONINITIALIZED) 
       {
           return StartDirectDraw(iface,NULL, TRUE);
       }
       else
       {
           return StartDirectDraw(iface,(LPGUID)DDCREATE_HARDWAREONLY, TRUE);
       }
    }
    else
    {
        return StartDirectDraw(iface,(LPGUID)DDCREATE_EMULATIONONLY, TRUE);
    }

    return DD_FALSE;
}


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -