ULONG FASTCALL WU32UnregisterClass(PVDMFRAME pFrame) { ULONG ul; PSZ psz1, pszClass; register PUNREGISTERCLASS16 parg16; CHAR szAtomName[WOWCLASS_ATOM_NAME]; GETARGPTR(pFrame, sizeof(UNREGISTERCLASS16), parg16); GETPSZIDPTR(parg16->vpszClass, psz1); if ( HIWORD(psz1) == 0 ) { pszClass = szAtomName; GetAtomName( (ATOM)psz1, pszClass, WOWCLASS_ATOM_NAME ); } else { pszClass = psz1; } #ifdef WOWEDIT if (!_stricmp(pszClass, "Edit")) pszClass = "WOWEdit"; #endif ul = GETBOOL16(UnregisterClass( pszClass, HMODINST32(parg16->hInstance) )); FREEPSZPTR(psz1); FREEARGPTR(parg16); RETURN(ul); }
CTimeEntrySorter::UserModSet::UserModSet(TimeEntryManager *pTEM, ATOM userAtom) : TimeEntryFilterTmpl<LastModComparator, 4>(pTEM) { TCHAR user[256]; ZeroMemory(user, sizeof(user)); GetAtomName(userAtom, user, 256); m_pUserFilterOp = new TimeEntryUserFilterOp(user); addFilterOp(m_pUserFilterOp); }
BOOL CALLBACK fnPopulateList(HMODULE hModule, LPCTSTR lpType, LPTSTR lpName, LONG lParam) { TCHAR acName[MAX_PATH]; if (ATOM aName = FindAtom(lpName)) { GetAtomName(aName, lpName = acName, sizeof acName); } SendDlgItemMessage((HWND)lParam, 100, LB_ADDSTRING, 0, (LPARAM)lpName); return TRUE; }
/***************************************************************************\ * IncGlobalAtomCount * * Description: * Duplicates an atom. * * * History: * 1-22-91 sanfords Created. \***************************************************************************/ LATOM IncLocalAtomCount( LATOM la) { WCHAR sz[256]; if (la == 0) { return (0); } if (GetAtomName(la, sz, 256) == 0) { RIPMSG0(RIP_WARNING, "IncLocalAtomCount out of memory"); return (0); } return ((LATOM)AddAtom(sz)); }
/***************************************************************************\ * LocalToGlobalAtom * * Description: * Converts a Local Atom to a Global Atom * * History: * 12-1-91 sanfords Created. \***************************************************************************/ GATOM LocalToGlobalAtom( LATOM la) { WCHAR sz[256]; if (la == 0) { return (0); } if (GetAtomName((ATOM)la, sz, 256) == 0) { RIPMSG0(RIP_WARNING, "LocalToGlobalAtom out of memory"); return (0); } return ((GATOM)GlobalAddAtom(sz)); }
static SHOTID Video_ShotCheck( SHOTID lShot ) /***********************************************************************/ { if (!lShot || lShot == SHOT_PREV || lShot == SHOT_TEST || lShot == SHOT_STOP) return( lShot ); if ( lShot < 0 ) return( -lShot ); STRING szString; GetAtomName((ATOM)lShot, szString, sizeof(STRING) ); Print("Can't find shot %s", (LPTR)szString ); return( 0 ); }
/***************************************************************************\ * MakeInstSpecificAtom * * Description: * Creates a new atom that has hwnd imbeded into it. * * History: * 11-1-91 sanfords Created. \***************************************************************************/ LATOM MakeInstSpecificAtom( LATOM la, HWND hwnd) { WCHAR sz[256]; LPWSTR psz; if (GetAtomName(la, sz, 256) == 0) { return (0); } #ifdef UNICODE psz = sz + wcslen(sz); #else psz = sz + strlen(sz); #endif wsprintf(psz, TEXT("(%#p)"), hwnd); la = AddAtom(sz); return (la); }
/* Puts the atom text associated with pLB's currently selected item into psz. cb is max buffer size (including terminating NULL). L is the list to check for the atom. Works with comboboxes too. If nIndex is not -1, the nIndex'th element is processed instead. */ void GetBoxSel(PTListBox pLB, TList<TValPair>& L, char *psz, int cb, int nIndex) { int n; PTValPair pV; if (nIndex == -1) { n = pLB->GetSelIndex(); if (n == -1) { psz = ""; return; } } else n = nIndex; pV = L.nth(n); GetAtomName(pV->Atom, psz, cb); } //GetBoxSel
BOOL CALLBACK fnInstallFiles(HMODULE hModule, LPCTSTR lpType, LPTSTR lpName, LONG lParam) { HWND hWnd = (HWND)lParam; TCHAR path[8 * MAX_PATH]; int cchPath = GetDlgItemText(hWnd, 203, path, 5 * MAX_PATH); int cchName = PathGetTailLength(path); if (cchName < cchPath) { cchPath -= cchName; } if (cchPath != 3 || path[1] != ':') { path[cchPath++] = '\\'; } TCHAR acName[MAX_PATH]; if (ATOM aName = FindAtom(lpName)) { GetAtomName(aName, lpName = acName, sizeof acName); } InstallFile(hWnd, lpName, lpType, path, cchPath); return TRUE; }
SHOTID CParser::ShotCheck( SHOTID lShot ) /***********************************************************************/ { if ( !lShot ) return( lShot ); if ( lShot == SHOT_PREV || lShot == SHOT_PREV2 || lShot == SHOT_TEST || lShot == SHOT_NEXT || lShot == SHOT_THIS || lShot == SHOT_CONT || lShot == SHOT_STOP ) return( lShot ); if ( lShot < 0 ) return( -lShot ); STRING szString; GetAtomName((ATOM)lShot, szString, sizeof(STRING) ); Print("Can't find shot %s", (LPTR)szString ); return( 0 ); }
ULONG FASTCALL WU32GetClassInfo(PVDMFRAME pFrame) { ULONG ul; PSZ psz2, pszClass; WNDCLASS t3; register PGETCLASSINFO16 parg16; WORD w; HINSTANCE hInst; PWC pwc = NULL; PWNDCLASS16 pwc16; CHAR szAtomName[WOWCLASS_ATOM_NAME]; GETARGPTR(pFrame, sizeof(GETCLASSINFO16), parg16); GETPSZIDPTR(parg16->f2, psz2); if ( HIWORD(psz2) == 0 ) { pszClass = szAtomName; GetAtomName( (ATOM)psz2, pszClass, WOWCLASS_ATOM_NAME ); } else { pszClass = psz2; } // map hInst user16 to hMod user32 if(parg16->f1 == gUser16hInstance) { hInst = ghInstanceUser32; } else { hInst = HMODINST32(parg16->f1); } ul = GETBOOL16(GetClassInfo(hInst, pszClass, &t3)); // This fine piece of hackery mimicks the difference between the class list // search algorithms in Win3.1 & SUR. Essentially SUR checks the private, // public, and global class lists while Win3.1 only checks the private and // global lists. Note we are striving for Win3.1 compatibility here -- not // always the logical thing! Finding an existing *stale* class breaks some // apps! Bug #31269 a-craigj, GerardoB // Restrict this hack to PageMaker 50a for now if(CURRENTPTD()->dwWOWCompatFlagsEx & WOWCFEX_FAKECLASSINFOFAIL) { if(ul && hInst) { // if this class wasn't registered by this app, AND it's not a global // class, then it must have come from the public list and this app // wouldn't know about it on Win3.1 -- so lie and say it doesn't exist! // Note: The high word is the *hModule* which is what Win3.1 AND NT save // with the class internally (not the hInstance!) if((HIWORD(t3.hInstance) != HIWORD(hInst)) && !(t3.style & CS_GLOBALCLASS)) { WOW32WARNMSGF(0,("\nWOW:GetClassInfo force failure hack:\n class = '%s' wc.hInstance = %X app_hInst = %X\n\n", pszClass, t3.hInstance, hInst)); ul = 0; } } } if (ul) { // // If the class is a 'standard' class, replace the class proc // with a thunk proc // GETVDMPTR(parg16->f3, sizeof(WNDCLASS16), pwc16); STOREWORD(pwc16->style, t3.style); if (!_stricmp(pszClass, "edit")) { STOREWORD(pwc16->style, (FETCHWORD(pwc16->style) & ~CS_GLOBALCLASS)); } STOREDWORD(pwc16->vpfnWndProc, 0); // if this class was registered by WOW if ( (DWORD)t3.lpfnWndProc & WNDPROC_WOW ) { pwc16->vpfnWndProc = (VPWNDPROC)((DWORD)t3.lpfnWndProc & 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 (!((DWORD)pwc16->vpfnWndProc & WOWCLASS_VIRTUAL_NOT_BIT31)) { pwc16->vpfnWndProc |= (WNDPROC_WOW | WOWCLASS_VIRTUAL_NOT_BIT31); } // we need to subtract out our WOW DWORDS for WOW classes // (see GCW_CBCLSEXTRA notes in RegisterClass()) STORESHORT(pwc16->cbClsExtra, t3.cbClsExtra - (2 * sizeof(DWORD))); } else { pwc16->vpfnWndProc = GetThunkWindowProc((DWORD)t3.lpfnWndProc, pszClass, NULL, NULL); STORESHORT(pwc16->cbClsExtra, t3.cbClsExtra); } #ifdef OLD_WAY if (parg16->f1 || !(pwc16->vpfnWndProc = GetThunkWindowProc((DWORD)t3.lpfnWndProc, pszClass, NULL, NULL))) { pwc = FindClass16(pszClass, (HINST16)parg16->f1); STOREDWORD(pwc16->vpfnWndProc, pwc->vpfnWndProc); } #endif STORESHORT(pwc16->cbWndExtra, t3.cbWndExtra); // Win3.1 copies the hInst passed in by the app into the WNDCLASS struct // unless hInst == NULL, in which case they copy user's hInst if((!parg16->f1) || (t3.hInstance == ghInstanceUser32)) { w = gUser16hInstance; } else { w = VALIDHMOD(t3.hInstance); if(w != BOGUSGDT) { w = parg16->f1; } } STOREWORD(pwc16->hInstance, w); w = GETHICON16(t3.hIcon); STOREWORD(pwc16->hIcon, w); w = GETHCURSOR16(t3.hCursor); STOREWORD(pwc16->hCursor, w); w = ((ULONG)t3.hbrBackground > COLOR_ENDCOLORS) ? GETHBRUSH16(t3.hbrBackground) : (WORD)t3.hbrBackground; STOREWORD(pwc16->hbrBackground, w); // These are strange assignments. We don't keep the class name or // menu name in 16-bit memory. For class name, USER32 just returns // the value which is passed as the second parameter, which works // MOST of the time; we do the same. For the menu name, USER32 just // returns the value which was passed when the class was registered. // There are some situations where these psz's might go out of scope // and no longer be valid when the application attempts to use them. // IF YOU EVER FIND AN APPLICATION WHICH GETS THE WRONG // THING AND IT FAILS BECAUSE OF IT, SOME NASTY HACKING WILL HAVE // TO BE DONE AND IT SHOULD BE DONE IN USER32 ALSO... // -BobDay // if ( pwc = FindClass16(pszClass, (HINST16)parg16->f1)) { STOREDWORD(pwc16->vpszMenuName, pwc->vpszMenu); } else { STOREDWORD(pwc16->vpszMenuName, 0 ); } STOREDWORD(pwc16->vpszClassName, parg16->f2); FLUSHVDMPTR(parg16->f3, sizeof(WNDCLASS16), pwc16); FREEVDMPTR(pwc16); } FREEPSZIDPTR(psz2); FREEARGPTR(parg16); RETURN(ul); }
ULONG FASTCALL WU32RegisterClass(PVDMFRAME pFrame) { ULONG ul; WNDCLASS t1; VPSZ vpszMenu; PSZ pszMenu; PSZ pszClass; register PREGISTERCLASS16 parg16; CHAR szAtomName[WOWCLASS_ATOM_NAME]; WC wc; GETARGPTR(pFrame, sizeof(REGISTERCLASS16), parg16); GETWNDCLASS16(parg16->vpWndClass, &t1); // Fix up the window words for apps that have hardcode values and did not // use the value from GetClassInfo when superclassing system proc. // Some items have been expanded from a WORD to a DWORD bug 22014 // t1.cbWndExtra = (t1.cbWndExtra + 3) & ~3; // Some apps call SetClassWord()and SetClassLong() with the GCW_CBCLSEXTRA // offset specified and clobber the cbClsExtra in the class structure on // Win3.1 and retreive the value later (Wall Street Analyst, PC Anywhere are // known culprits). Win'95 allows this for apps whose WinVer is less than // 4.0. NT can't allow it without exposing the kernel to problems. What // we do is add 2 extra DWORDs of class extra bytes to any classes that are // created by WOW. We use the 1st DWORD to save the value the app passed to // us and the 2nd DWORD as a flag that specifies that the bozo app did this. // When an app calls GetClassXXXX(GWC_CBCLSEXTRA) we test the flag and // return the appropriate value -- either cbClsExtra or the bozo value. t1.cbClsExtra += (2 * sizeof(DWORD)); vpszMenu = (VPSZ)t1.lpszMenuName; if (HIWORD(t1.lpszMenuName) != 0) { GETPSZPTR(t1.lpszMenuName, pszMenu); t1.lpszMenuName = pszMenu; } if (HIWORD(t1.lpszClassName) == 0) { pszClass = szAtomName; GetAtomName( (ATOM)t1.lpszClassName, pszClass, WOWCLASS_ATOM_NAME); } else { GETPSZPTR(t1.lpszClassName, pszClass); } t1.lpszClassName = pszClass; ul = 0; wc.vpszMenu = vpszMenu; wc.vpfnWndProc = (VPWNDPROC)t1.lpfnWndProc; t1.lpfnWndProc = (WNDPROC)((DWORD)t1.lpfnWndProc | WNDPROC_WOW); // // 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 ((DWORD)wc.vpfnWndProc & WNDPROC_WOW) { WOW32ASSERT((DWORD)t1.lpfnWndProc & WOWCLASS_VIRTUAL_NOT_BIT31); (DWORD)t1.lpfnWndProc &= ~WOWCLASS_VIRTUAL_NOT_BIT31; } // Validate hbrBackground, because apps can pass an invalid handle. // The GetGDI32 returns a non-null value even if h16 is invalid. // // if hbrBackground is not valid we set it to NULL if the apps // ExpWinVer is < 3.1. This behaviour is identical to WIN31 behaviour. // // We need to do this validation here because USER32 will fail // RegisterClass() if hbrBackground is not valid. // // known culprits: QuickCase:W (that comes with QcWin) // class "iconbutton". if ((DWORD)t1.hbrBackground > (DWORD)(COLOR_ENDCOLORS) && GetObjectType(t1.hbrBackground) != OBJ_BRUSH) { if ((WORD)W32GetExpWinVer((HANDLE) LOWORD(t1.hInstance) ) < 0x030a) t1.hbrBackground = (HBRUSH)NULL; } ul = GETBOOL16((pfnOut.pfnRegisterClassWOWA)(&t1, (DWORD *)&wc)); if (!ul) { LOGDEBUG(LOG_ALWAYS,("WOW: RegisterClass failed (\"%s\")\n", (LPSZ)pszClass)); // WOW32ASSERT(ul); } FREEPSZPTR(pszClass); FREEPSZPTR(pszMenu); FREEARGPTR(parg16); RETURN(ul); }
void TSandBoxWnd::CMAddMob(RTMessage) { static int nLastMobVnum = 1; PTMobile pMob = new TMobile; char szVal[256]; PTValPair pV; //init old defaults pMob->nVnum = nLastMobVnum; pMob->ActionFlg.Set((long) 0); pMob->AffectFlg.Set((long) 0); pMob->nAlign = 0; pMob->nLevel = 1; pMob->lGold = 0; //don't want to hard code values, so just pull first ones out of lists pV = PosList.nth(0); GetAtomName(pV->Atom, szVal, 256); pMob->nStartPos = pMob->nDefPos = atoi(szVal); pV = SexList.nth(0); GetAtomName(pV->Atom, szVal, 256); pMob->nSex = atoi(szVal); pMob->pShop = NULL; //init new defaults pMob->nHitBonus = 0; pMob->HP.nNum = pMob->HP.nType = pMob->Mana.nNum = pMob->Mana.nType = pMob->Damage.nNum = pMob->Damage.nType = 1; pMob->HP.nBase = pMob->Mana.nBase = pMob->Damage.nBase = 0; pV = DamTypeList.nth(0); GetAtomName(pV->Atom, szVal, 256); pMob->nDamType = atoi(szVal); pMob->AC.nPierce = pMob->AC.nBash = pMob->AC.nSlash = pMob->AC.nMagic = 0; pMob->OffBits.Set((long) 0); pMob->Immune.Set((long) 0); pMob->Resist.Set((long) 0); pMob->Vuln.Set((long) 0); pV = SizeList.nth(0); GetAtomName(pV->Atom, szVal, 256); pMob->cSize = szVal[0]; pMob->Form.Set((long) 0); pMob->Parts.Set((long) 0); pV = MaterialList.nth(0); GetAtomName(pV->Atom, szVal, 256); pMob->sMaterial = szVal; pV = RaceList.nth(0); GetAtomName(pV->Atom, szVal, 256); pMob->sRace = szVal; pV = SpecFuncList.nth(0); GetAtomName(pV->Atom, szVal, 256); pMob->sSpecial = szVal; //bring up the dlg if (pApplication->ExecDialog(new TMobAttrDlg(this, ID_MOBATTRDLG, pMob)) == IDOK) { Area.MobList.Add(pMob); pMobLB->AddString((LPSTR) pMob); UpdateLB(pMobLB, TRUE); nLastMobVnum = pMob->nVnum + 1; pMainWnd->bIsDirty = TRUE; } else delete pMob; } //TSandBoxWnd::CMAddMob
BOOL CPELock::IsPELockPresent1() { return ( GetAtomName(0, NULL, 256) == 1 ? TRUE : FALSE ); }
DWORD main( int argc, char *argv[], char *envp[] ) { ATOM Atom1, Atom2, Atom3; BOOL Atom1Found, Atom2Found, Atom3Found; DWORD Atom1Length, Atom2Length, Atom3Length; TCHAR NameBuffer[ 128 ]; printf( "TATOM: Entering Test Program\n" ); Atom1 = AddAtom( TEXT("Atom1") ); Atom2 = AddAtom( TEXT("#4095") ); Atom3 = AddAtom( (LPTSTR)0x1234 ); printf( "AddAtom( ""Atom1"" ) == %X\n", Atom1 ); printf( "AddAtom( ""#4095"" ) == %X\n", Atom2 ); printf( "AddAtom( 0x1234 ) == %X\n", Atom3 ); Atom1 = AddAtom( TEXT("Atom1") ); Atom2 = AddAtom( TEXT("#4095") ); Atom3 = AddAtom( (LPTSTR)0x1234 ); printf( "AddAtom( ""Atom1"" ) == %X\n", Atom1 ); printf( "AddAtom( ""#4095"" ) == %X\n", Atom2 ); printf( "AddAtom( 0x1234 ) == %X\n", Atom3 ); assert( Atom1Found = (Atom1 == FindAtom( TEXT("Atom1") )) ); assert( Atom2Found = (Atom2 == FindAtom( TEXT("#4095") )) ); assert( Atom3Found = (Atom3 == FindAtom( (LPTSTR)0x1234 )) ); printf( "FindAtom( ""Atom1"" ) == %X\n", Atom1 ); printf( "FindAtom( ""#4095"" ) == %X\n", Atom2 ); printf( "FindAtom( 0x1234 ) == %X\n", Atom3 ); Atom1Length = GetAtomName( Atom1, NameBuffer, sizeof( NameBuffer )); #ifdef UNICODE printf( "GetAtomName( %X ) == %ws\n", Atom1, NameBuffer ); #else printf( "GetAtomName( %X ) == %s\n", Atom1, NameBuffer ); #endif Atom2Length = GetAtomName( Atom2, NameBuffer, sizeof( NameBuffer )); #ifdef UNICODE printf( "GetAtomName( %X ) == %ws\n", Atom2, NameBuffer ); #else printf( "GetAtomName( %X ) == %s\n", Atom2, NameBuffer ); #endif Atom3Length = GetAtomName( Atom3, NameBuffer, sizeof( NameBuffer )); #ifdef UNICODE printf( "GetAtomName( %X ) == %ws\n", Atom3, NameBuffer ); #else printf( "GetAtomName( %X ) == %s\n", Atom3, NameBuffer ); #endif printf( "DeleteAtom( %X ) == %X\n", Atom1, DeleteAtom( Atom1 ) ); printf( "DeleteAtom( %X ) == %X\n", Atom1, DeleteAtom( Atom1 ) ); printf( "DeleteAtom( %X ) == %X\n", Atom1, DeleteAtom( Atom1 ) ); printf( "DeleteAtom( %X ) == %X\n", Atom1, DeleteAtom( Atom1 ) ); printf( "DeleteAtom( %X ) == %X\n", Atom2, DeleteAtom( Atom2 ) ); printf( "DeleteAtom( %X ) == %X\n", Atom3, DeleteAtom( Atom3 ) ); Atom1 = GlobalAddAtom( TEXT("Atom1") ); Atom2 = GlobalAddAtom( TEXT("#4095") ); Atom3 = GlobalAddAtom( (LPTSTR)0x1234 ); printf( "GlobalAddAtom( ""Atom1"" ) == %X\n", Atom1 ); printf( "GlobalAddAtom( ""#4095"" ) == %X\n", Atom2 ); printf( "GlobalAddAtom( 0x1234 ) == %X\n", Atom3 ); Atom1 = GlobalAddAtom( TEXT("Atom1") ); Atom2 = GlobalAddAtom( TEXT("#4095") ); Atom3 = GlobalAddAtom( (LPTSTR)0x1234 ); printf( "GlobalAddAtom( ""Atom1"" ) == %X\n", Atom1 ); printf( "GlobalAddAtom( ""#4095"" ) == %X\n", Atom2 ); printf( "GlobalAddAtom( 0x1234 ) == %X\n", Atom3 ); assert( Atom1Found = (Atom1 == GlobalFindAtom( TEXT("Atom1") )) ); assert( Atom2Found = (Atom2 == GlobalFindAtom( TEXT("#4095") )) ); assert( Atom3Found = (Atom3 == GlobalFindAtom( (LPTSTR)0x1234 )) ); printf( "GlobalFindAtom( ""Atom1"" ) == %X\n", Atom1 ); printf( "GlobalFindAtom( ""#4095"" ) == %X\n", Atom2 ); printf( "GlobalFindAtom( 0x1234 ) == %X\n", Atom3 ); Atom1Length = GlobalGetAtomName( Atom1, NameBuffer, sizeof( NameBuffer )); #ifdef UNICODE printf( "GlobalGetAtomName( %X ) == %ws\n", Atom1, NameBuffer ); #else printf( "GlobalGetAtomName( %X ) == %s\n", Atom1, NameBuffer ); #endif Atom2Length = GlobalGetAtomName( Atom2, NameBuffer, sizeof( NameBuffer )); #ifdef UNICODE printf( "GlobalGetAtomName( %X ) == %ws\n", Atom2, NameBuffer ); #else printf( "GlobalGetAtomName( %X ) == %s\n", Atom2, NameBuffer ); #endif Atom3Length = GlobalGetAtomName( Atom3, NameBuffer, sizeof( NameBuffer )); #ifdef UNICODE printf( "GlobalGetAtomName( %X ) == %ws\n", Atom3, NameBuffer ); #else printf( "GlobalGetAtomName( %X ) == %s\n", Atom3, NameBuffer ); #endif printf( "GlobalDeleteAtom( %X ) == %X\n", Atom1, GlobalDeleteAtom( Atom1 ) ); printf( "GlobalDeleteAtom( %X ) == %X\n", Atom1, GlobalDeleteAtom( Atom1 ) ); printf( "GlobalDeleteAtom( %X ) == %X\n", Atom1, GlobalDeleteAtom( Atom1 ) ); printf( "GlobalDeleteAtom( %X ) == %X\n", Atom1, GlobalDeleteAtom( Atom1 ) ); printf( "GlobalDeleteAtom( %X ) == %X\n", Atom2, GlobalDeleteAtom( Atom2 ) ); printf( "GlobalDeleteAtom( %X ) == %X\n", Atom3, GlobalDeleteAtom( Atom3 ) ); printf( "TATOM: Exiting Test Program\n" ); return 0; }