DirectDraw Object struct

DDRAWI_DIRECTDRAW_INT
it is the the return pointer from ddraw.dll to the program

DDRAWI_DIRECTDRAW_LCL
It is the program own private data

DDRAWI_DIRECTDRAW_GBL
This struct is gboal for whole ddraw.dll for all program
it is static in ddraw if it change it change for all
program

The struct

from http://msdn2.microsoft.com/en-us/library/ms898267.aspx
it was not document for windows 2000/xp/2003 but ms did document it
for windows ce 5.0 the link are to windows ce 5.0 arch

typedef struct _DDRAWI_DIRECTDRAW_INT {
  LPVOID lpVtbl;
  LPDDRAWI_DIRECTDRAW_LCL lpLcl;
  LPDDRAWI_DIRECTDRAW_INT lpLink;
  DWORD dwIntRefCnt;
} DDRAWI_DIRECTDRAW_INT;

Rest of the struct are from msdn for windows 2000/xp/2003
typedef struct _DDRAWI_DIRECTDRAW_LCL {
  DWORD  lpDDMore;
  LPDDRAWI_DIRECTDRAW_GBL  lpGbl; // fill it from function Create_DirectDraw with static pointer ddgbl
  DWORD  dwUnused0;
  DWORD  dwLocalFlags;
  DWORD  dwLocalRefCnt;
  DWORD  dwProcessId;
  IUnknown FAR  *pUnkOuter;
  DWORD  dwObsolete1;
  ULONG_PTR  hWnd;
  ULONG_PTR  hDC;                       // create HDC and save it to this pointer
  DWORD  dwErrorMode;
  LPDDRAWI_DDRAWSURFACE_INT  lpPrimary;  // The primary surface
  LPDDRAWI_DDRAWSURFACE_INT  lpCB;
  DWORD   dwPreferredMode;
  HINSTANCE  hD3DInstance;
  IUnknown FAR  *pD3DIUnknown;
  LPDDHAL_CALLBACKS  lpDDCB;           // same memory pointer as DDRAWI_DIRECTDRAW_GBL->lpDDCBtmp, setup by function StartDirectDraw
  ULONG_PTR  hDDVxd;
  DWORD   dwAppHackFlags;
  ULONG_PTR    hFocusWnd;
  DWORD   dwHotTracking;
  DWORD   dwIMEState;
  ULONG_PTR  hWndPopup;
  ULONG_PTR  hDD;                      // from Gdientry1 copy the _DDRAWI_DIRECTDRAW_GBL hDD after startup then copy this back each time we need hDD
  ULONG_PTR  hGammaCalibrator;
  LPDDGAMMACALIBRATORPROC  lpGammaCalibrator;
} DDRAWI_DIRECTDRAW_LCL;

typedef struct _DDRAWI_DIRECTDRAW_GBL {
  DWORD  dwRefCnt;
  DWORD  dwFlags;
  FLATPTR  fpPrimaryOrig;
  DDCORECAPS  ddCaps;
  DWORD  dwInternal1;
  DWORD  dwUnused1[9];
  LPDDHAL_CALLBACKS  lpDDCBtmp;
  LPDDRAWI_DDRAWSURFACE_INT  dsList;   // list of all created directdraw surface, it is a pointer list
  LPDDRAWI_DDRAWPALETTE_INT  palList;
  LPDDRAWI_DDRAWCLIPPER_INT  clipperList;
  LPDDRAWI_DIRECTDRAW_GBL  lp16DD;    // pointer to it self (DDRAWI_DIRECTDRAW_GBL)
  DWORD  dwMaxOverlays;
  DWORD  dwCurrOverlays;
  DWORD  dwMonitorFrequency;         // current monitor freq, (nvidia always set this to 0, it is a bug in nvidia drv)
  DDCORECAPS  ddHELCaps;
  DWORD  dwUnused2[50];
  DDCOLORKEY  ddckCKDestOverlay;
  DDCOLORKEY  ddckCKSrcOverlay;
  VIDMEMINFO  vmiData;
  LPVOID  lpDriverHandle;
  LPDDRAWI_DIRECTDRAW_LCL  lpExclusiveOwner;  // which local directdraw comobject is in Exclusive mode and own this
  DWORD  dwModeIndex;
  DWORD  dwModeIndexOrig;
  DWORD  dwNumFourCC;
  DWORD FAR  *lpdwFourCC;
  DWORD  dwNumModes;
  LPDDHALMODEINFO  lpModeInfo;
  PROCESS_LIST  plProcessList;
  DWORD  dwSurfaceLockCount;
  DWORD  dwAliasedLockCnt;
  ULONG_PTR  dwReserved3;
  ULONG_PTR  hDD;               // GdiEntry1 are filling this pointer
  char  cObsolete[12];
  DWORD  dwReserved1;
  DWORD  dwReserved2;
  DBLNODE  dbnOverlayRoot;
  volatile LPWORD  lpwPDeviceFlags;
  DWORD  dwPDevice;
  DWORD  dwWin16LockCnt;
  DWORD  dwUnused3;
  DWORD  hInstance;
  DWORD  dwEvent16;
  DWORD  dwSaveNumModes;
  ULONG_PTR  lpD3DGlobalDriverData;
  ULONG_PTR  lpD3DHALCallbacks;
  DDCORECAPS  ddBothCaps;
  LPDDVIDEOPORTCAPS  lpDDVideoPortCaps;
  LPDDRAWI_DDVIDEOPORT_INT  dvpList;
  ULONG_PTR  lpD3DHALCallbacks2;
  RECT  rectDevice;
  DWORD  cMonitors;
  LPVOID  gpbmiSrc;
  LPVOID  gpbmiDest;
  LPHEAPALIASINFO  phaiHeapAliases;
  ULONG_PTR  hKernelHandle;
  ULONG_PTR  pfnNotifyProc;
  LPDDKERNELCAPS  lpDDKernelCaps;
  LPDDNONLOCALVIDMEMCAPS  lpddNLVCaps;
  LPDDNONLOCALVIDMEMCAPS  lpddNLVHELCaps;
  LPDDNONLOCALVIDMEMCAPS  lpddNLVBothCaps;
  ULONG_PTR  lpD3DExtendedCaps;
  DWORD  dwDOSBoxEvent;
  RECT  rectDesktop;
  char  cDriverName[MAX_DRIVER_NAME];   // driver name, if we send in CreateDirectDraw(NULL, ...) this will be fill in the name "display"
  ULONG_PTR   lpD3DHALCallbacks3;
  DWORD  dwNumZPixelFormats;
  LPDDPIXELFORMAT  lpZPixelFormats;
  LPDDRAWI_DDMOTIONCOMP_INT mcList;
  DWORD  hDDVxd;
  DDSCAPSEX  ddsCapsMore;
} DDRAWI_DIRECTDRAW_GBL;

Clipper Object struct
DDRAWI_DDRAWCLIPPER_INT
It is the the return pointer from ddraw.dll to the program

DDRAWI_DDRAWCLIPPER_LCL
It is the program own private data

DDRAWI_DDRAWCLIPPER_GBL
This struct is gboal for whole ddraw.dll for all program
it is static in ddraw if it change it change for all
program

The struct

typedef struct _DDRAWI_DDRAWCLIPPER_INT {
  LPVOID  lpVtbl;
  LPDDRAWI_DDRAWCLIPPER_LCL  lpLcl;
  LPDDRAWI_DDRAWCLIPPER_INT  lpLink;
  DWORD  dwIntRefCnt;
} DDRAWI_DDRAWCLIPPER_INT;

typedef struct _DDRAWI_DDRAWCLIPPER_LCL {
  DWORD  lpClipMore;
  LPDDRAWI_DDRAWCLIPPER_GBL  lpGbl;
  LPDDRAWI_DIRECTDRAW_LCL  lpDD_lcl;
  DWORD  dwLocalRefCnt;
  IUnknown  FAR  *pUnkOuter;
  LPDDRAWI_DIRECTDRAW_INT  lpDD_int;
  ULONG_PTR  dwReserved1;
  IUnknown  *pAddrefedThisOwner;
} DDRAWI_DDRAWCLIPPER_LCL;


typedef struct _DDRAWI_DDRAWCLIPPER_GBL {
  DWORD  dwRefCnt;
  DWORD  dwFlags;
  LPDDRAWI_DIRECTDRAW_GBL lpDD;
  DWORD  dwProcessId;
  ULONG_PTR  dwReserved1;
  ULONG_PTR  hWnd;
  LPRGNDATA  lpStaticClipList;
} DDRAWI_DDRAWCLIPPER_GBL;

typedef struct _DDRAWI_DDRAWPALETTE_INT {
  LPVOID  lpVtbl;
  LPDDRAWI_DDRAWPALETTE_LCL  lpLcl;
  LPDDRAWI_DDRAWPALETTE_INT  lpLink;
  DWORD  dwIntRefCnt;
} DDRAWI_DDRAWPALETTE_INT;

typedef struct _DDRAWI_DDRAWPALETTE_LCL {
  DWORD  lpPalMore;
  LPDDRAWI_DDRAWPALETTE_GBL  lpGbl;
  ULONG_PTR  dwUnused0;
  DWORD  dwLocalRefCnt;
  IUnknown FAR  *pUnkOuter;
  LPDDRAWI_DIRECTDRAW_LCL  lpDD_lcl;
  ULONG_PTR  dwReserved1;
  ULONG_PTR  dwDDRAWReserved1;
  ULONG_PTR  dwDDRAWReserved2;
  ULONG_PTR  dwDDRAWReserved3;
} DDRAWI_DDRAWPALETTE_LCL;

typedef struct _DDRAWI_DDRAWPALETTE_GBL {
  DWORD  dwRefCnt;
  DWORD  dwFlags;
  LPDDRAWI_DIRECTDRAW_LCL  lpDD_lcl;
  DWORD  dwProcessId;
  LPPALETTEENTRY  lpColorTable;
  union {
     ULONG_PTR  dwReserved1;
     HPALETTE  hHELGDIPalette;
  };
  DWORD  dwDriverReserved;
  DWORD  dwContentsStamp;
  DWORD  dwSaveStamp;
  DWORD  dwHandle;
} DDRAWI_DDRAWPALETTE_GBL;


typedef struct _DDRAWI_DDVIDEOPORT_INT {
  LPVOID  lpVtbl;
  LPDDRAWI_DDVIDEOPORT_LCL  lpLcl;
  LPDDRAWI_DDVIDEOPORT_INT  lpLink;
  DWORD  dwIntRefCnt;
  DWORD  dwFlags;
} DDRAWI_DDVIDEOPORT_INT;

typedef struct _DDRAWI_DDVIDEOPORT_LCL {
  LPDDRAWI_DIRECTDRAW_LCL  lpDD;
  DDVIDEOPORTDESC  ddvpDesc;
  DDVIDEOPORTINFO  ddvpInfo;
  LPDDRAWI_DDRAWSURFACE_INT  lpSurface;
  LPDDRAWI_DDRAWSURFACE_INT  lpVBISurface;
  LPDDRAWI_DDRAWSURFACE_INT *lpFlipInts;
  DWORD  dwNumAutoflip;
  DWORD  dwProcessID;
  DWORD  dwStateFlags;
  DWORD  dwFlags;
  DWORD  dwRefCnt;
  FLATPTR  fpLastFlip;
  ULONG_PTR  dwReserved1;
  ULONG_PTR  dwReserved2;
  HANDLE  hDDVideoPort;
  DWORD  dwNumVBIAutoflip;
  LPDDVIDEOPORTDESC  lpVBIDesc;
  LPDDVIDEOPORTDESC  lpVideoDesc;
  LPDDVIDEOPORTINFO  lpVBIInfo;
  LPDDVIDEOPORTINFO  lpVideoInfo;
  DWORD  dwVBIProcessID;
} DDRAWI_DDVIDEOPORT_LCL;


Surface:

typedef struct _DDRAWI_DDRAWSURFACE_GBL {
  DWORD  dwRefCnt;
  DWORD  dwGlobalFlags;
  union {
     LPACCESSRECTLIST  lpRectList;
     DWORD  dwBlockSizeY;
  };
  union {
     LPVMEMHEAP  lpVidMemHeap;
     DWORD  dwBlockSizeX;
  };
  union {
     LPDDRAWI_DIRECTDRAW_GBL lpDD;
     LPVOID   lpDDHandle;
  };
  FLATPTR   fpVidMem;
  union {
     LONG   lPitch;
     DWORD  dwLinearSize;
  };
  WORD    wHeight;
  WORD    wWidth;
  DWORD   dwUsageCount;
  ULONG_PTR   dwReserved1;
  DDPIXELFORMAT   ddpfSurface;
} DDRAWI_DDRAWSURFACE_GBL;

The following informations might be incorrectly
I am using logic thinking since the info does
not exists in MSDN so I am drawing clue how
previews stuffs works that are document in MSDN/DDK

follow struct should exists ???
DDRAWI_DDVIDEOPORT_GBL
DDRAWI_DDGAMMACONTROL_INT
DDRAWI_DDGAMMACONTROL_LCL
DDRAWI_DDGAMMACONTROL_GBL
DDRAWI_DDCOLORCONTROL_INT
DDRAWI_DDCOLORCONTROL_LCL
DDRAWI_DDCOLORCONTROL_GBL
DDRAWI_KERNEL_INT
DDRAWI_KERNEL_LCL
DDRAWI_KERNEL_GBL
DDRAWI_DDKERNELSURFACE_INT
DDRAWI_DDKERNELSURFACE_LCL
DDRAWI_DDKERNELSURFACE_GBL

follow struct can be easy create
DDRAWI_DDGAMMACONTROL_INT
DDRAWI_DDCOLORCONTROL_INT
DDRAWI_KERNEL_INT

the DDRAWI_DDGAMMACONTROL_INT should looking like this
typedef struct _DDRAWI_DDGAMMACONTROL_INT
{
  LPVOID  lpVtbl;
  LPDDRAWI_DDGAMMACONTROL_LCL  lpLcl;
  LPDDRAWI_DDGAMMACONTROL_INT  lpLink;
  DWORD  dwIntRefCnt;
} DDRAWI_DDGAMMACONTROL_INT, *LPDDRAWI_DDGAMMACONTROL_INT

how did I got this struct I looked at all other INT struct how they where
build. But it is not 100% sure this one is right untill I/we known how
the DDRAWI_DDGAMMACONTROL_LCL works and  DDRAWI_DDCOLORCONTROL_GBL
our internal struct will look like this

typedef struct _DDRAWI_DDGAMMACONTROL_INT
{
  LPVOID  lpVtbl;
  LPVOID  lpLcl;
  LPVOID  lpLink;
  DWORD  dwIntRefCnt;
} DDRAWI_DDGAMMACONTROL_INT, *LPDDRAWI_DDGAMMACONTROL_INT

same goes for DDRAWI_DDCOLORCONTROL_INT

typedef struct DDRAWI_DDCOLORCONTROL_INT
{
  LPVOID  lpVtbl;
  LPVOID  lpLcl;
  LPVOID  lpLink;
  DWORD  dwIntRefCnt;
} DDRAWI_DDCOLORCONTROL_INT, *LPDDRAWI_DDCOLORCONTROL_INT








