BOOL GetTaskExpWinVer(HTASK hTask, LPWORD pwVer) { LPBYTE pTDB = LPBYTE(MAKELP(hTask, 0)); if (!BAD_PTR(pTDB, 0xfc) && pTDB[0xfa] == 'T' && pTDB[0xfb] == 'D' && (pTDB[0x16] & 0x10) == 0x00) // !Win32 task { *pwVer = MAKEWORD(pTDB[0x1a], pTDB[0x1b]); return (TRUE); } return (FALSE); }
void IT_ISBADCODEPTR (ENV *envp,LONGPROC f) { DWORD retcode; LPSTR lpString; lpString = MAKELP(GETWORD(SP+8),GETWORD(SP+6)); retcode = (f)(lpString,0); envp->reg.sp += LP_86 + RET_86; envp->reg.ax = LOWORD(retcode); envp->reg.dx = HIWORD(retcode); }
BOOL GetModuleExpWinVer(HMODULE hModule, LPWORD pwVer) { hModule = GetExePtr(hModule); LPBYTE pMDB = LPBYTE(MAKELP(hModule, 0)); if (!BAD_PTR(pMDB, 0x40) && pMDB[0x00] == 'N' && pMDB[0x01] == 'E' && (pMDB[0x0c] & 0x10) == 0x00) // !Win32 module { *pwVer = MAKEWORD(pMDB[0x3e], pMDB[0x3f]); return (TRUE); } return (FALSE); }
LPVOID getWindowData(HWND hwnd, LPCSTR lpcID) { #ifdef WIN32 // (sizeof(HANDLE) == 4) return((LPVOID)GetProp(hwnd, lpcID)); #else char szID1[32], szID2[32]; wsprintf(szID1, "%s.1", lpcID); wsprintf(szID2, "%s.2", lpcID); return(MAKELP(GetProp(hwnd, szID1), GetProp(hwnd, szID2))); #endif }
BOOL SetModuleExpWinVer(HMODULE hModule, WORD wVer) { hModule = GetExePtr(hModule); LPBYTE pMDB = LPBYTE(MAKELP(hModule, 0)); if (!BAD_PTR(pMDB, 0x40) && pMDB[0x00] == 'N' && pMDB[0x01] == 'E' && (pMDB[0x0c] & 0x10) == 0x00) // !Win32 module { pMDB[0x3e] = LOBYTE(wVer); // minor pMDB[0x3f] = HIBYTE(wVer); // major return (TRUE); } return (FALSE); }
void InitRealModeFlag(PPROPLINK ppl) { PROPPRG prg; if (!PifMgr_GetProperties((int)ppl, MAKELP(0,GROUP_PRG), &prg, SIZEOF(prg), GETPROPS_NONE)) { return; /* Weird */ } if (prg.flPrgInit & PRGINIT_REALMODE) { ppl->flProp |= PROP_REALMODE; } else { ppl->flProp &= ~PROP_REALMODE; } }
void IT_LOCKRESOURCE (ENV *envp,LONGPROC f) { DWORD retcode = 0L; WORD wSel; HGLOBAL hGlobal; wSel = GETWORD(SP+4); hGlobal = GetSelectorHandle(wSel); if ((retcode = (DWORD)GlobalLock(hGlobal))) retcode = (DWORD)MAKELP(wSel | 1,0); envp->reg.ax = LOWORD(retcode); envp->reg.dx = HIWORD(retcode); envp->reg.sp += HANDLE_86 + RET_86; }
BOOL SetTaskExpWinVer(HTASK hTask, WORD wVer) { LPBYTE pTDB = LPBYTE(MAKELP(hTask, 0)); if (!BAD_PTR(pTDB, 0xfc) && pTDB[0xfa] == 'T' && pTDB[0xfb] == 'D' && (pTDB[0x16] & 0x10) == 0x00) // !Win32 task { WORD wSel = MAKEWORD(pTDB[0x20], pTDB[0x21]); if (SetQueueExpWinVer(HGLOBAL(wSel), wVer)) { pTDB[0x1a] = LOBYTE(wVer); // minor pTDB[0x1b] = HIBYTE(wVer); // major return (TRUE); } } return (FALSE); }
static BOOL SetQueueExpWinVer(HGLOBAL hQueue, WORD wVer) { LPBYTE pMQ = LPBYTE(MAKELP(hQueue, 0)); if (!BAD_PTR(pMQ, 0x44)) { if (IsWin95()) { pMQ[0x42] = LOBYTE(wVer); // minor pMQ[0x43] = HIBYTE(wVer); // major } else { pMQ[0x36] = LOBYTE(wVer); // minor pMQ[0x37] = HIBYTE(wVer); // major } return (TRUE); } return (FALSE); }
BOOL FAR PASCAL __loadds FreeRing0Callgate( WORD callgate ) { CALLGATE_DESCRIPTOR far *callgate_desc; unsigned short ldt_alias; if ( (ldt_alias = GetLDTAlias()) == 0 ) return FALSE; // // Create a pointer to the call gate descriptor // callgate_desc = MAKELP( ldt_alias, callgate & 0xFFF8 ); // // First, free the ring 0 alias selector stored in the LDT // call gate descriptor, then free the call gate selector. // FreeSelector( callgate_desc->selector ); FreeSelector( callgate ); }
void IT_GLOBALLOCK (ENV *envp,LONGPROC f) { DWORD retcode; WORD wSel; HGLOBAL hGlobal=0; HMODULE hModule; MODULEINFO *modinfo = NULL; UINT memflags; wSel = GETWORD(SP+4) | 1; /* This is extra work that should be eliminated */ if (!(wSel & OM_MASK)) { /* can be hInstance */ hGlobal = GetSelectorHandle(wSel); memflags = GlobalFlags(hGlobal); retcode = (DWORD)GlobalLock(hGlobal); } else { if ((hModule = GetModuleFromInstance(wSel))) { modinfo = GETMODULEINFO(hModule); if ((wSel = GetDataSelectorFromInstance(wSel))) { hGlobal = GetSelectorHandle(wSel); retcode = (DWORD)GlobalLock(hGlobal); } else retcode = (DWORD) NULL; } else retcode = (DWORD) NULL; } envp->reg.sp += HANDLE_86 + RET_86; if (retcode) retcode = (DWORD)MAKELP(wSel,0); envp->reg.ax = LOWORD(retcode); envp->reg.dx = HIWORD(retcode); if (modinfo != NULL) RELEASEMODULEINFO(modinfo); }
/* RegMakeFilterSpec() - Retrieves class-associated default extensions. * * This function returns a filter spec, to be used in the "Change Link" * standard dialog box, which contains all the default extensions which * are associated with the given class name. Again, the class names are * guaranteed to be in ASCII. * * Returns: The index nFilterIndex stating which filter item matches the * extension, or 0 if none is found or -1 if error. ** *hFilterSpec is allocated and must be freed by caller. */ int FAR RegMakeFilterSpec(LPSTR lpstrClass, LPSTR lpstrExt, HANDLE *hFilterSpec) { DWORD dwSize; LPSTR lpstrFilterSpec; char szClass[KEYNAMESIZE]; char szName[KEYNAMESIZE]; char szString[KEYNAMESIZE]; unsigned int i; int idWhich = 0; int idFilterIndex = 0; if (*hFilterSpec == NULL) { if ((*hFilterSpec = GlobalAlloc(GMEM_MOVEABLE|GMEM_ZEROINIT,KEYNAMESIZE+16)) == NULL) return -1; lpstrFilterSpec = MAKELP(*hFilterSpec,0); } RegOpenKey(HKEY_CLASSES_ROOT,NULL,&hkeyRoot); for (i = 0; !RegEnumKey(HKEY_CLASSES_ROOT, i++, szName, KEYNAMESIZE); ) { if (*szName == '.' /* Default Extension... */ /* ... so, get the class name */ && (dwSize = KEYNAMESIZE) && !RegQueryValue(HKEY_CLASSES_ROOT, szName, szClass, &dwSize) /* ... and if the class name matches (null class is wildcard) */ && (!lpstrClass || !lstrcmpi(lpstrClass, szClass)) /* ... get the class name string */ && (dwSize = KEYNAMESIZE) && !RegQueryValue(HKEY_CLASSES_ROOT, szClass, szString, &dwSize)) { int offset; idWhich++; /* If the extension matches, save the filter index */ if (lpstrExt && !lstrcmpi(lpstrExt, szName)) idFilterIndex = idWhich; offset = lpstrFilterSpec - MAKELP(*hFilterSpec,0); if ((GlobalSize(*hFilterSpec) - offset) < (lstrlen(szString) + 16)) { if ((*hFilterSpec = GlobalReAlloc(*hFilterSpec,GlobalSize(*hFilterSpec)+KEYNAMESIZE+16, GMEM_MOVEABLE|GMEM_ZEROINIT)) == NULL) { GlobalFree(*hFilterSpec); *hFilterSpec = NULL; idFilterIndex = -1; break; } lpstrFilterSpec = (LPSTR)MAKELP(*hFilterSpec,0) + offset; } /* Copy over "<Class Name String> (*<Default Extension>)" * e.g. "Server Picture (*.PIC)" */ lstrcpy(lpstrFilterSpec, szString); lstrcat(lpstrFilterSpec, " (*"); lstrcat(lpstrFilterSpec, szName); lstrcat(lpstrFilterSpec, ")"); lpstrFilterSpec += lstrlen(lpstrFilterSpec) + 1; /* Copy over "*<Default Extension>" (e.g. "*.PIC") */ lstrcpy(lpstrFilterSpec, "*"); lstrcat(lpstrFilterSpec, szName); lpstrFilterSpec += lstrlen(lpstrFilterSpec) + 1; } } /* Add another NULL at the end of the spec (+ 16 accounts for this) */ if (idFilterIndex > -1) *lpstrFilterSpec = 0; if (hkeyRoot) { RegCloseKey(hkeyRoot); hkeyRoot = NULL; } return idFilterIndex; }
WORD FAR PASCAL __loadds GetRing0Callgate( DWORD func_address, unsigned cParams ) { CALLGATE_DESCRIPTOR far *callgate_desc; CODE_SEG_DESCRIPTOR far *ring0_desc; unsigned short ldt_alias; unsigned short ring_0_alias; unsigned short callgate_selector; if ( (ldt_alias = GetLDTAlias()) == 0 ) return 0; // // Grab a selector from Windows to use as the CS at ring 0 // if ( !(ring_0_alias = AllocSelector(0)) ) return 0; // // Set up the fields in the descriptor to be a ring 0, flat model seg // ring0_desc = MAKELP( ldt_alias, ring_0_alias & 0xFFF8 ); ring0_desc->limit_0_15 = 0xFFFF; ring0_desc->base_0_15 = 0; ring0_desc->base_16_23 = 0; ring0_desc->readable = 1; ring0_desc->conforming = 0; ring0_desc->code_data = 1; ring0_desc->app_system = 1; ring0_desc->dpl = 0; ring0_desc->present = 1; ring0_desc->limit_16_19 = 0xF; ring0_desc->always_0 = 0; ring0_desc->seg_16_32 = 1; ring0_desc->granularity = 1; ring0_desc->base_24_31 = 0; // // Allocate the selector that'll be used for the call gate // if ( (callgate_selector= AllocSelector(0)) == 0 ) { FreeSelector( ring_0_alias ); return 0; } // // Create a pointer to the call gate descriptor // callgate_desc = MAKELP( ldt_alias, callgate_selector & 0xFFF8 ); // // Fill in the fields of the call gate descriptor with the // appropriate values for a 16 bit callgate. // callgate_desc->offset_0_15 = LOWORD( func_address ); callgate_desc->selector = ring_0_alias; callgate_desc->param_count = cParams; callgate_desc->some_bits = 0; callgate_desc->type = 0xC; // 386 call gate callgate_desc->app_system = 0; // A system descriptor callgate_desc->dpl = 3; // Ring 3 code can call callgate_desc->present = 1; callgate_desc->offset_16_31 = HIWORD(func_address); return callgate_selector; }