示例#1
0
文件: wudlg.c 项目: chunhualiu/OpenNT
ULONG FASTCALL WU32DlgDirList(PVDMFRAME pFrame)
{
    ULONG ul;
    PSZ psz2;
    register PDLGDIRLIST16 parg16;

    UpdateDosCurrentDirectory(DIR_DOS_TO_NT);

    GETARGPTR(pFrame, sizeof(DLGDIRLIST16), parg16);
    GETPSZPTR(parg16->f2, psz2);

    //
    // KidPix passes an invalid filetype flag (0x1000) that Win3.1 doesn't
    // check for.  Win32 does, and fails the API, so mask that flag off here.
    //  John Vert (jvert) 11-Jun-1993
    //

    ul = GETINT16(DlgDirList(
    HWND32(parg16->f1),
    psz2,
    WORD32(parg16->f3),
    WORD32(parg16->f4),
    WORD32(parg16->f5) & DDL_VALID
    ));

    UpdateDosCurrentDirectory(DIR_NT_TO_DOS);

    FREEPSZPTR(psz2);
    FREEARGPTR(parg16);
    RETURN(ul);
}
示例#2
0
文件: wudlg.c 项目: chunhualiu/OpenNT
ULONG FASTCALL WU32DlgDirListComboBox(PVDMFRAME pFrame)
{
    ULONG ul;
    PSZ psz2;
    register PDLGDIRLISTCOMBOBOX16 parg16;

    UpdateDosCurrentDirectory(DIR_DOS_TO_NT);

    GETARGPTR(pFrame, sizeof(DLGDIRLISTCOMBOBOX16), parg16);
    GETPSZPTR(parg16->f2, psz2);

    ul = GETINT16(DlgDirListComboBox(
    HWND32(parg16->f1),
    psz2,
    WORD32(parg16->f3),
    WORD32(parg16->f4),
    WORD32(parg16->f5)
    ));

    UpdateDosCurrentDirectory(DIR_NT_TO_DOS);


    FREEPSZPTR(psz2);
    FREEARGPTR(parg16);
    RETURN(ul);
}
示例#3
0
文件: wudlg.c 项目: chunhualiu/OpenNT
ULONG FASTCALL WU32CheckDlgButton(PVDMFRAME pFrame)
{
    register PCHECKDLGBUTTON16 parg16;

    GETARGPTR(pFrame, sizeof(CHECKDLGBUTTON16), parg16);

    CheckDlgButton(
    HWND32(parg16->f1),
    WORD32(parg16->f2),
    WORD32(parg16->f3)
    );

    FREEARGPTR(parg16);
    RETURN(0);
}
示例#4
0
文件: wudlg.c 项目: chunhualiu/OpenNT
ULONG FASTCALL WU32SetDlgItemInt(PVDMFRAME pFrame)
{
    register PSETDLGITEMINT16 parg16;

    GETARGPTR(pFrame, sizeof(SETDLGITEMINT16), parg16);

    SetDlgItemInt(
    HWND32(parg16->f1),
    WORD32(parg16->f2),         // see comment in wu32getdlgitem
    (parg16->f4) ? INT32(parg16->f3) : WORD32(parg16->f3),
    BOOL32(parg16->f4)
    );

    FREEARGPTR(parg16);
    RETURN(0);
}
示例#5
0
文件: wudlg.c 项目: chunhualiu/OpenNT
ULONG FASTCALL WU32GetDlgItemText(PVDMFRAME pFrame)
{
    ULONG ul;
    PSZ psz3;
    register PGETDLGITEMTEXT16 parg16;

    GETARGPTR(pFrame, sizeof(GETDLGITEMTEXT16), parg16);
    ALLOCVDMPTR(parg16->f3, parg16->f4, psz3);

    ul = GETINT16(GetDlgItemText(
    HWND32(parg16->f1),
    WORD32(parg16->f2),     // see comment in wu32getdlgitem
    psz3,
    WORD32(parg16->f4)
    ));

    FLUSHVDMPTR(parg16->f3, strlen(psz3)+1, psz3);
    FREEVDMPTR(psz3);
    FREEARGPTR(parg16);
    RETURN(ul);
}
示例#6
0
文件: wudlg.c 项目: chunhualiu/OpenNT
ULONG FASTCALL WU32IsDlgButtonChecked(PVDMFRAME pFrame)
{
    ULONG ul;
    register PISDLGBUTTONCHECKED16 parg16;

    GETARGPTR(pFrame, sizeof(ISDLGBUTTONCHECKED16), parg16);

    ul = GETWORD16(IsDlgButtonChecked(
    HWND32(parg16->f1),
    WORD32(parg16->f2)
    ));

    FREEARGPTR(parg16);
    RETURN(ul);
}
示例#7
0
文件: wudlg.c 项目: chunhualiu/OpenNT
ULONG FASTCALL WU32SetDlgItemText(PVDMFRAME pFrame)
{
    PSZ psz3;
    register PSETDLGITEMTEXT16 parg16;

    GETARGPTR(pFrame, sizeof(SETDLGITEMTEXT16), parg16);
    GETPSZPTR(parg16->f3, psz3);

    SetDlgItemText(
    HWND32(parg16->f1),
    WORD32(parg16->f2),     // see comment in wu32getdlgitem
    psz3
    );

    FREEPSZPTR(psz3);
    FREEARGPTR(parg16);
    RETURN(0);
}
示例#8
0
文件: wudlg.c 项目: chunhualiu/OpenNT
ULONG FASTCALL WU32GetDlgItemInt(PVDMFRAME pFrame)
{
    ULONG ul;
    BOOL t3;
    register PGETDLGITEMINT16 parg16;

    GETARGPTR(pFrame, sizeof(GETDLGITEMINT16), parg16);

    ul = GETWORD16(GetDlgItemInt(
    HWND32(parg16->f1),
    WORD32(parg16->f2),     // see comment in wu32getdlgitem
    &t3,
    BOOL32(parg16->f4)
    ));

    PUTBOOL16(parg16->f3, t3);
    FREEARGPTR(parg16);
    RETURN(ul);
}
示例#9
0
文件: wudlg.c 项目: chunhualiu/OpenNT
ULONG FASTCALL WU32DlgDirSelectComboBox(PVDMFRAME pFrame)
{
    ULONG ul;
    PSZ psz2;
    register PDLGDIRSELECTCOMBOBOX16 parg16;

    GETARGPTR(pFrame, sizeof(DLGDIRSELECTCOMBOBOX16), parg16);
    ALLOCVDMPTR(parg16->f2, MAX_VDMFILENAME, psz2);

    ul = GETBOOL16(DlgDirSelectComboBoxEx(
    HWND32(parg16->f1),
    psz2,
    SIZE_BOGUS,
    WORD32(parg16->f3)
    ));

    FLUSHVDMPTR(parg16->f2, strlen(psz2)+1, psz2);
    FREEVDMPTR(psz2);
    FREEARGPTR(parg16);
    RETURN(ul);
}
示例#10
0
文件: wudlg.c 项目: chunhualiu/OpenNT
ULONG FASTCALL WU32MessageBox(PVDMFRAME pFrame)
{
    ULONG ul;
    PSZ psz2;
    PSZ psz3;
    register PMESSAGEBOX16 parg16;

    GETARGPTR(pFrame, sizeof(MESSAGEBOX16), parg16);
    GETPSZPTR(parg16->f2, psz2);
    GETPSZPTR(parg16->f3, psz3);

    ul = GETINT16(MessageBox(
    HWND32(parg16->f1),
    psz2,
    psz3,
    WORD32(parg16->f4)
    ));

    FREEPSZPTR(psz2);
    FREEPSZPTR(psz3);
    FREEARGPTR(parg16);
    RETURN(ul);
}
示例#11
0
ULONG FASTCALL WU32SetClassWord(PVDMFRAME pFrame)
{
    ULONG  ul, flag;
    HWND   hwnd;
    INT    iOffset;
    register PSETCLASSWORD16 parg16;

    GETARGPTR(pFrame, sizeof(SETCLASSWORD16), parg16);

    // Make sure Win32 didn't change offsets

#if (GCL_HBRBACKGROUND != (-10) || GCL_HCURSOR != (-12) || GCL_HICON != (-14) || GCL_CBWNDEXTRA != (-18) || GCL_CBCLSEXTRA != (-20) || GCL_STYLE != (-26))
#error Win16/Win32 GCW constants differ
#endif

    // Make sure the 16-bit app is requesting allowable offsets
    // (It's just assertion code, so it doesn't have to be pretty! -JTP)

    iOffset = INT32(parg16->f2);
    WOW32ASSERT(iOffset >= 0 ||
        iOffset == GCL_HBRBACKGROUND ||
        iOffset == GCL_HCURSOR ||
        iOffset == GCL_HICON ||
        iOffset == GCL_CBWNDEXTRA ||
        iOffset == GCL_CBCLSEXTRA ||
        iOffset == GCL_STYLE)

    hwnd = HWND32(parg16->f1);
    ul = WORD32(parg16->f3);

    switch(iOffset) {
        case GCL_HBRBACKGROUND:
            if (ul > COLOR_ENDCOLORS)
                ul = (LONG) HBRUSH32(ul);

            ul = SetClassLong(hwnd, iOffset, (LONG) ul);

            if (ul > COLOR_ENDCOLORS)
                ul = GETHBRUSH16(ul);
            break;

        case GCL_HCURSOR:
            ul = GETHCURSOR16(SetClassLong(hwnd, iOffset, (LONG)HCURSOR32(ul)));
            break;

        case GCL_HICON:
            ul = GETHICON16(SetClassLong(hwnd, iOffset, (LONG)HICON32(ul)));
            break;

        case GCL_HMODULE:
            ul = 0;         // not allowed to set this
            break;

        case GCL_CBWNDEXTRA:
        case GCL_STYLE:
            ul = SetClassLong(hwnd, iOffset, (LONG)ul);
            break;

        case GCL_CBCLSEXTRA:
            // apps shouldn't do this but of course some do!
            // (see GCW_CBCLSEXTRA notes in thunk for RegisterClass())
            WOW32WARNMSG(0, ("WOW:SetClassWord(): app changing cbClsExtra!"));

            // only allow this to be set by classes registered via WOW
            if(GetClassLong(hwnd, GCL_WNDPROC) & WNDPROC_WOW) { 

                // set the bozo flag 
                iOffset = GetClassLong(hwnd, GCL_CBCLSEXTRA);
                iOffset -= sizeof(DWORD);
                flag = SetClassLong(hwnd, iOffset, 1);

                // save the value the app passed 
                iOffset -= sizeof(DWORD);
                ul      = (WORD)SetClassWord(hwnd, iOffset, LOWORD(ul));

                // SetClassWord() returns the "previous" value.
                // if this is the first time the app pulls this stunt it will
                // get back the original cbClsExtra, otherwise it will get back
                // the value it stored here on the previous call.
                if(!flag) {
                    ul = iOffset; // the WOW DWORDs have already been subtracted
                }
            }
            else {
                ul = 0;  // no can do for non-WOW classes
            }
            break;

        default:
            ul = SetClassWord(hwnd, iOffset, (WORD)ul);
            break;
    }

    FREEARGPTR(parg16);
    RETURN(ul);
}
示例#12
0
ULONG FASTCALL WU32SetClassLong(PVDMFRAME pFrame)
{
    ULONG ul, flag;
    INT iOffset;
    PSZ pszMenu;
    register PWC pwc;
    register PSETCLASSLONG16 parg16;

    GETARGPTR(pFrame, sizeof(SETCLASSLONG16), parg16);

    // Make sure Win32 didn't change offsets for GCL constants

#if (GCL_MENUNAME != (-8) || GCL_WNDPROC != (-24))
#error Win16/Win32 GCL constants differ
#endif

    // Make sure the 16-bit app is requesting allowable offsets

    iOffset = INT32(parg16->f2);

    WOW32ASSERT(iOffset >= 0 ||
                iOffset == GCL_WNDPROC ||
                iOffset == GCL_MENUNAME);

    ul = 0;

    switch (iOffset) {
        case GCL_WNDPROC:
            {
                DWORD   dwWndProc32Old;
                DWORD   dwWndProc32New;
                PWW     pww;

                // Look to see if the new 16:16 proc is a thunk for a 32-bit proc.
                dwWndProc32New = IsThunkWindowProc(LONG32(parg16->f3), NULL );

                if ( dwWndProc32New != 0 ) {
                    //
                    // They are attempting to set the window proc to an existing
                    // 16-bit thunk that is really just a thunk for a 32-bit
                    // routine.  We can just set it back to the 32-bit routine.
                    //
                    dwWndProc32Old = SetClassLong(HWND32(parg16->f1), GCL_WNDPROC, (LONG)dwWndProc32New);
                    SETWC(HWND32(parg16->f1), GCL_WOWvpfnWndProc, 0);
                } else {
                    //
                    // They are attempting to set it to a real 16:16 proc.
                    //
                    LONG l;

                    l = LONG32(parg16->f3);

                    //
                    // FEATURE-O-RAMA
                    //
                    // if the selector already has the high bit on then turn off bit 2
                    // of the selector (the LDT bit, which should always be on).  we
                    // need a way to not blindly strip off the high bit in our wndproc.
                    //

                    if (l & WNDPROC_WOW) {
                        WOW32ASSERT(l & WOWCLASS_VIRTUAL_NOT_BIT31);
                        l &= ~WOWCLASS_VIRTUAL_NOT_BIT31;
                    }

                    dwWndProc32Old = SetClassLong(HWND32(parg16->f1), GCL_WNDPROC, l | WNDPROC_WOW );
                    SETWC(HWND32(parg16->f1), GCL_WOWvpfnWndProc, LONG32(parg16->f3));
                }

                if ( dwWndProc32Old & WNDPROC_WOW ) {
                    if ( HIWORD(dwWndProc32Old) == WNDPROC_HANDLE ) {
                        //
                        // If the return value is a handle, then just thunk it.
                        //
                        pww = FindPWW(HWND32(parg16->f1), WOWCLASS_UNKNOWN);
                        if ( pww == NULL ) {
                            ul = 0;
                        } else {
                            ul = GetThunkWindowProc(dwWndProc32Old, NULL, pww, HWND32(parg16->f1));
                        }
                    } else {
                        //
                        // Previous proc was a 16:16 proc
                        //
                        ul = dwWndProc32Old & WNDPROC_MASK;

                        //
                        // if the actual selector had the high bit on then we turned off
                        // bit 2 of the selector (the LDT bit, which will always be on)
                        //
                        if (!(ul & WOWCLASS_VIRTUAL_NOT_BIT31)) {
                            ul |= (WNDPROC_WOW | WOWCLASS_VIRTUAL_NOT_BIT31);
                        }
                    }
                } else {
                    //
                    // Previous proc was a 32-bit proc, use an allocated thunk
                    //
                    pww = FindPWW(HWND32(parg16->f1), WOWCLASS_UNKNOWN);
                    if ( pww == NULL ) {
                        ul = 0;
                    } else {
                        ul = GetThunkWindowProc(dwWndProc32Old, NULL, pww, HWND32(parg16->f1));
                    }

                }
            }
            break;

        case GCL_MENUNAME:
            if (pwc = FindPWC(HWND32(parg16->f1))) {
                ul = pwc->vpszMenu;
                GETPSZPTR(parg16->f3, pszMenu);
                SETWC(HWND32(parg16->f1), GCL_WOWvpszMenu, parg16->f3);
                SetClassLong(HWND32(parg16->f1), GCL_MENUNAME, (LONG)pszMenu);
                FREEPSZPTR(pszMenu);
            }
            break;


        case GCL_CBCLSEXTRA:
            // apps shouldn't do this but of course some do!
            // (see GCW_CBCLSEXTRA notes in thunk for RegisterClass())
            WOW32WARNMSG(0, ("WOW:SetClassLong(): app changing cbClsExtra!"));

            // only allow this to be set by classes registered via WOW
            if(GetClassLong(HWND32(parg16->f1), GCL_WNDPROC) & WNDPROC_WOW) { 

                ul = WORD32(parg16->f3);

                // set the bozo flag & save the value the app passed us
                iOffset =  GetClassLong(HWND32(parg16->f1), GCL_CBCLSEXTRA);
                iOffset -= sizeof(DWORD);
                flag    =  SetClassLong(HWND32(parg16->f1), iOffset, 1);
                iOffset -= sizeof(DWORD);
                ul      =  SetClassLong(HWND32(parg16->f1), iOffset, ul);

                // SetClassLong() returns the "previous" value.
                // if this is the first time the app pulls this stunt it will
                // get back the original cbClsExtra, otherwise it will get back
                // the value it stored here on the previous call.
                if(!flag) {
                    ul = iOffset; // the WOW DWORDs have already been subtracted
                }
            }
            else {
                ul = 0;  // no can do for non-WOW classes
            }
            break;

        default:
            ul = SetClassLong(HWND32(parg16->f1), iOffset, LONG32(parg16->f3));
            break;
    }

    FREEARGPTR(parg16);
    RETURN(ul);
}
示例#13
0
文件: seq.c 项目: bgbock/pyppm
/* ppm_execute: runs the currently downloaded pulse program. */
void ppm_execute (void) {
  /* declare required variables. */
  uint32_t f32, n32;
  uint16_t a16, d16;
  uint8_t a8, en;

  /* declare the current value of the shim dac output. */
  uint16_t dac16 = 0x0000;

  /* initialize all interpreter variables. */
  VAR_INIT (n32);
  VAR_INIT (f32);
  VAR_INIT (d16);
  VAR_INIT (a16);
  VAR_INIT (a8);
  VAR_INIT (en);
  VAR_INIT (dac16);

  /* loop through the pulse program array. */
  for (i_pulprog = 0;
       i_pulprog < n_pulprog &&
       i_pulprog < SZ_PULPROG;
       i_pulprog++) {
    /* determine the pulse program command at the current index. */
    switch (pulprog[i_pulprog]) {
      /* short, imprecise delay. */
#ifdef PPM_PULPROG_HAVE_DEADTIME
      case PPM_PULPROG_DEADTIME:
        /* build the delay time word and run the dead time command. */
        d16 = WORD (pulprog[i_pulprog + 1], pulprog[i_pulprog + 2]);
        ppm_deadtime (d16);

        /* skip to the next pulse program command. */
        i_pulprog += 2;
        break;
#endif

      /* precise delay. */
#ifdef PPM_PULPROG_HAVE_DELAY
      case PPM_PULPROG_DELAY:
        /* build the delay time word and run the delay command. */
        d16 = WORD (pulprog[i_pulprog + 1], pulprog[i_pulprog + 2]);
        dac16 = ppm_delay (d16, dac16);

        /* skip to the next pulse program command. */
        i_pulprog += 2;
        break;
#endif

      /* polarization control. */
#ifdef PPM_PULPROG_HAVE_POLARIZE
      case PPM_PULPROG_POLARIZE:
        /* get the enable byte and run the control command. */
        en = pulprog[i_pulprog + 1];
        ppm_ccs_enable (en);

        /* skip to the next pulse program command. */
        i_pulprog += 1;
        break;
#endif

      /* relay control. */
#ifdef PPM_PULPROG_HAVE_RELAY
      case PPM_PULPROG_RELAY:
        /* get the enable byte and run the control command. */
        en = pulprog[i_pulprog + 1];
        ppm_relay_enable (en);

        /* skip to the next pulse program command. */
        i_pulprog += 1;
        break;
#endif

      /* acquisition. */
#ifdef PPM_PULPROG_HAVE_ACQUIRE
      case PPM_PULPROG_ACQUIRE:
        /* build the acquisition sample count. */
        n32 = WORD32 (pulprog[i_pulprog + 1], pulprog[i_pulprog + 2],
                      pulprog[i_pulprog + 3], pulprog[i_pulprog + 4]);

        /* build the acquisition sample rate overflow. */
        d16 = WORD (pulprog[i_pulprog + 5], pulprog[i_pulprog + 6]);

        /* run the acquisition command. */
        ppm_acquire (n32, d16);

        /* skip to the next pulse program command. */
        i_pulprog += 6;
        break;
#endif

      /* adiabatic polarization rising edge. */
#ifdef PPM_PULPROG_HAVE_TX
      case PPM_PULPROG_TXRISE:
        /* build the sample count word. */
        d16 = WORD (pulprog[i_pulprog + 1], pulprog[i_pulprog + 2]);

        /* build the amplitude step word. */
        a16 = WORD (pulprog[i_pulprog + 3], pulprog[i_pulprog + 4]);

        /* run the rising edge command. */
        dac16 = ppm_txrise (d16, a16, dac16);

        /* skip to the next pulse program command. */
        i_pulprog += 4;
        break;
#endif

      /* adiabatic polarization falling edge. */
#ifdef PPM_PULPROG_HAVE_TX
      case PPM_PULPROG_TXFALL:
        /* build the sample count word. */
        d16 = WORD (pulprog[i_pulprog + 1], pulprog[i_pulprog + 2]);

        /* build the amplitude step word. */
        a16 = WORD (pulprog[i_pulprog + 3], pulprog[i_pulprog + 4]);

        /* run the falling edge command. */
        dac16 = ppm_txfall (d16, a16, dac16);

        /* skip to the next pulse program command. */
        i_pulprog += 4;
        break;
#endif

      /* sinusoidal pulse. */
#ifdef PPM_PULPROG_HAVE_TX
      case PPM_PULPROG_TXPULSE:
        /* build the synthesis sample count. */
        n32 = WORD32 (pulprog[i_pulprog + 1], pulprog[i_pulprog + 2],
                      pulprog[i_pulprog + 3], pulprog[i_pulprog + 4]);

        /* build the frequency tuning word. */
        f32 = WORD32 (pulprog[i_pulprog + 5], pulprog[i_pulprog + 6],
                      pulprog[i_pulprog + 7], pulprog[i_pulprog + 7]);

        /* get the amplitude multiplier byte. */
        a8 = pulprog[i_pulprog + 9];

        /* run the pulse synthesis command. */
        ppm_txpulse (n32, f32, a8);

        /* return the transmit coil dac output to zero. */
        spi_write_dac_a (0x0000);

        /* skip to the next pulse program command. */
        i_pulprog += 9;
        break;
#endif

      /* capacitive tuning. */
#ifdef PPM_PULPROG_HAVE_TUNE
      case PPM_PULPROG_TUNE:
        /* build the tuning word. */
        a16 = WORD (pulprog[i_pulprog + 1], pulprog[i_pulprog + 2]);

        /* run the tuning command. */
        ppm_settune (a16);

        /* skip to the next pulse program command. */
        i_pulprog += 2;
        break;
#endif

      /* x-axis shim. */
#ifdef PPM_PULPROG_HAVE_SHIM_X
      case PPM_PULPROG_SHIM_X:
        /* build the shimming word. */
        a16 = WORD (pulprog[i_pulprog + 1], pulprog[i_pulprog + 2]);

        /* run the shimming command. */
        ppm_setshim_x (a16);

        /* skip to the next pulse program command. */
        i_pulprog += 2;
        break;
#endif

      /* y-axis shim. */
#ifdef PPM_PULPROG_HAVE_SHIM_Y
      case PPM_PULPROG_SHIM_Y:
        /* build the shimming word. */
        a16 = WORD (pulprog[i_pulprog + 1], pulprog[i_pulprog + 2]);

        /* run the shimming command. */
        ppm_setshim_y (a16);

        /* skip to the next pulse program command. */
        i_pulprog += 2;
        break;
#endif

      /* z-axis shim. */
#ifdef PPM_PULPROG_HAVE_SHIM_Z
      case PPM_PULPROG_SHIM_Z:
        /* build the shimming word. */
        a16 = WORD (pulprog[i_pulprog + 1], pulprog[i_pulprog + 2]);

        /* run the shimming command. */
        ppm_setshim_z (a16);

        /* skip to the next pulse program command. */
        i_pulprog += 2;
        break;
#endif

      /* end execution. */
      case PPM_PULPROG_END:
        /* send back a completion code and end execution. */
        ppm_done ();
        return;

      /* unrecognized command. */
      default:
        /* send back an error code and end execution. */
        ppm_error ();
        return;
    }
  }
}
示例#14
0
文件: wdib.c 项目: chunhualiu/OpenNT
ULONG FASTCALL WG32CreateDIBSection(PVDMFRAME pFrame)
{
    ULONG              ul = 0;
    STACKBMI32         bmi32;
    LPBITMAPINFO       lpbmi32;
    HBITMAP            hbm32;
    PVOID              pv16, pvBits, pvIntelBits;
    PVPVOID            vpbmi16;
    PVOID              pvBits32;
    DWORD              dwArg16;

    register PCREATEDIBSECTION16 parg16;

    GETARGPTR(pFrame, sizeof(CREATEDIBSECTION16), parg16);

    // this is performance hack so we don't generate extra code
    dwArg16 = FETCHDWORD(parg16->f4); // do it once here
    pv16 = (PVOID)GetPModeVDMPointer(dwArg16, sizeof(DWORD)); // aligned here!

    WOW32ASSERTMSG(((parg16->f5 == 0) && (parg16->f6 == 0)),
                   ("WOW:WG32CreateDIBSection, hSection/dwOffset non-null\n"));

    vpbmi16 = (PVPVOID)FETCHDWORD(parg16->f2);
    lpbmi32 = CopyBMI16ToBMI32(vpbmi16,
                               (LPBITMAPINFO)&bmi32,
                               FETCHWORD(parg16->f3));

    hbm32 = CreateDIBSection(HDC32(parg16->f1),
                             lpbmi32,
                             WORD32(parg16->f3),
                             &pvBits,
                             NULL,
                             0);

    if (hbm32 != 0)
    {
        PARM16          Parm16;
        PDIBSECTIONINFO pdi;
        ULONG           SelectorLimit;

        SelectorLimit = (ULONG)cjBitmapBitsSize(lpbmi32);
#ifndef i386
        if (!NT_SUCCESS(VdmAddVirtualMemory((ULONG)pvBits,
                                            SelectorLimit,
                                            (PULONG)&pvIntelBits))) {
            LOGDEBUG(LOG_ALWAYS,("\nWOW::WG32CreateDibSection VdmAddVirtualMemory failed\n"));
            goto cds_err;
        }

#else
        pvIntelBits = pvBits;
#endif

        // Create a selector array for the bits backed by pvIntelBits

        Parm16.WndProc.wParam = (WORD)-1;           // -1 => allocate selectors
        Parm16.WndProc.lParam = (LONG) pvIntelBits; // backing pointer
        Parm16.WndProc.wMsg = 0x10;                 // GA_NOCOMPACT
        Parm16.WndProc.hwnd = (WORD)((SelectorLimit+65535)/65536);// selector count

        CallBack16(RET_SETDIBSEL,
                   &Parm16,
                   0,
                   (PVPVOID)&pvBits32);

        // 16:16 pointer is still valid as call above makes no difference
        if (pv16 != NULL) {
            *(UNALIGNED PVOID*)pv16 = pvBits32;
        }

        if (pvBits32 == NULL) {
            LOGDEBUG(LOG_ALWAYS,("\nWOW::WG32CreateDibSection, Callback set_sel_for_dib failed\n"));
            goto cds_err;
        }

#ifndef i386 
        // okay, that was successful - map the descriptors properly

        if (!VdmAddDescriptorMapping(HIWORD(pvBits32),
                                    (USHORT) ((SelectorLimit+65535)/65536),
                                    (ULONG) pvIntelBits,
                                    (ULONG) pvBits)) {
            LOGDEBUG(LOG_ALWAYS,("\nWOW::WG32CreateDibSection VdmAddDescriptorMapping failed\n"));
            goto cds_err;
        }
#endif
        
        LOGDEBUG(LOG_ALWAYS, ("\nWOW:CreateDIBSection: [16:16 %x] [Intel %x] [Flat %x]\n", 
                             pvBits32, pvIntelBits, pvBits));

        ul = GETHBITMAP16(hbm32);

        // Add it to the list used for cleanup at DeleteObject time.

        if ((pdi = malloc_w (sizeof (DIBSECTIONINFO))) != NULL) {
            pdi->di_hbm         = (HBITMAP)(HAND16)hbm32;
            pdi->di_pv16        = pvBits32;
#ifndef i386
            pdi->di_newIntelDib = pvIntelBits;
#endif
            pdi->di_next        = pDibSectionInfoHead;
            pDibSectionInfoHead = pdi;

            // need to turn batching off since a DIBSECTION means the app can
            // also draw on the bitmap and we need synchronization.

            GdiSetBatchLimit(1);

            goto cds_ok;
        }
        else {
            // Failure, free the selector array

            Parm16.WndProc.wParam = (WORD)-1;            // -1 => allocate/free
            Parm16.WndProc.lParam = (LONG) pvBits32; // pointer
            Parm16.WndProc.wMsg = 0x10; // GA_NOCOMPACT
            Parm16.WndProc.hwnd = 0;                     // 0 => free

            CallBack16(RET_SETDIBSEL,
                       &Parm16,
                       0,
                       (PVPVOID)&ul);
#ifndef i386
            VdmRemoveVirtualMemory((ULONG)pvIntelBits);
#endif

        }
    }
    else {
        LOGDEBUG(LOG_ALWAYS,("\nWOW::WG32CreateDibSection, CreateDibSection Failed\n"));
    }

cds_err:

    if (hbm32 != 0) {
        DeleteObject(hbm32);
    }
    LOGDEBUG(LOG_ALWAYS,("\nWOW::WG32CreateDibSection returning failure\n"));
    ul = 0;

cds_ok:
    WOW32APIWARN(ul, "CreateDIBSection");

    FREEMISCPTR(pv16);
    FREEARGPTR(parg16);

    return(ul);
}