static void _LocalGetPrinterDriverLevel2(PLOCAL_PRINTER_HANDLE pHandle, PDRIVER_INFO_2W* ppDriverInfo, PBYTE* ppDriverInfoEnd, PDWORD pcbNeeded) { DWORD n; PCWSTR pwszStrings[5]; /* Clearly these things should not be hardcoded, so when it is needed, someone can add meaningfull values here */ pwszStrings[0] = pHandle->pPrinter->pwszPrinterDriver; // pName pwszStrings[1] = wszCurrentEnvironment; // pEnvironment pwszStrings[2] = L"c:\\reactos\\system32\\localspl.dll"; // pDriverPath pwszStrings[3] = L"c:\\reactos\\system32\\localspl.dll"; // pDataFile pwszStrings[4] = L"c:\\reactos\\system32\\localspl.dll"; // pConfigFile // Calculate the string lengths. if (!ppDriverInfo) { for (n = 0; n < _countof(pwszStrings); ++n) { *pcbNeeded += (wcslen(pwszStrings[n]) + 1) * sizeof(WCHAR); } *pcbNeeded += sizeof(DRIVER_INFO_2W); return; } (*ppDriverInfo)->cVersion = 3; // Finally copy the structure and advance to the next one in the output buffer. *ppDriverInfoEnd = PackStrings(pwszStrings, (PBYTE)(*ppDriverInfo), dwDriverInfo2Offsets, *ppDriverInfoEnd); (*ppDriverInfo)++; }
static void _LocalGetPrinterDriverLevel1(PLOCAL_PRINTER_HANDLE pHandle, PDRIVER_INFO_1W* ppDriverInfo, PBYTE* ppDriverInfoEnd, PDWORD pcbNeeded) { DWORD n; PCWSTR pwszStrings[1]; /* This value is only here to send something, I have not verified if it is actually correct */ pwszStrings[0] = pHandle->pPrinter->pwszPrinterDriver; // Calculate the string lengths. if (!ppDriverInfo) { for (n = 0; n < _countof(pwszStrings); ++n) { *pcbNeeded += (wcslen(pwszStrings[n]) + 1) * sizeof(WCHAR); } *pcbNeeded += sizeof(DRIVER_INFO_1W); return; } // Finally copy the structure and advance to the next one in the output buffer. *ppDriverInfoEnd = PackStrings(pwszStrings, (PBYTE)(*ppDriverInfo), dwDriverInfo1Offsets, *ppDriverInfoEnd); (*ppDriverInfo)++; }
LPBYTE CopyIniPortToPort( PINIPORT pIniPort, DWORD Level, LPBYTE pPortInfo, LPBYTE pEnd ) { LPWSTR SourceStrings[sizeof(PORT_INFO_1)/sizeof(LPWSTR)]; LPWSTR *pSourceStrings=SourceStrings; PPORT_INFO_1 pPort1 = (PPORT_INFO_1)pPortInfo; DWORD *pOffsets; switch (Level) { case 1: pOffsets = PortInfo1Offsets; break; default: return pEnd; } switch (Level) { case 1: *pSourceStrings++=pIniPort->pName; pEnd = PackStrings(SourceStrings, pPortInfo, pOffsets, pEnd); break; default: return pEnd; } return pEnd; }
LPBYTE CopyIniPortToPort( PINIPORT pIniPort, DWORD Level, LPBYTE pPortInfo, LPBYTE pEnd ) { LPWSTR *SourceStrings, *pSourceStrings; PPORT_INFO_2 pPort2 = (PPORT_INFO_2)pPortInfo; WCHAR szLocalMonitor[MAX_PATH+1], szPortDesc[MAX_PATH+1]; DWORD *pOffsets; DWORD Count; switch (Level) { case 1: pOffsets = PortInfo1Strings; break; case 2: pOffsets = PortInfo2Strings; break; default: DBGMSG(DBG_ERROR, ("CopyIniPortToPort: invalid level %d", Level)); return NULL; } for ( Count = 0 ; pOffsets[Count] != -1 ; ++Count ) { } SourceStrings = pSourceStrings = AllocSplMem(Count * sizeof(LPWSTR)); if ( !SourceStrings ) { DBGMSG( DBG_WARNING, ("Failed to alloc port source strings.\n")); return NULL; } switch (Level) { case 1: *pSourceStrings++=pIniPort->pName; break; case 2: *pSourceStrings++=pIniPort->pName; LoadString(hInst, IDS_LOCALMONITORNAME, szLocalMonitor, sizeof(szLocalMonitor)-1); LoadString(hInst, IDS_LOCALMONITOR, szPortDesc, sizeof(szPortDesc)-1); *pSourceStrings++ = szLocalMonitor; *pSourceStrings++ = szPortDesc; // How do i findout other types ??? pPort2->fPortType = PORT_TYPE_WRITE; // Reserved pPort2->Reserved = 0; break; default: DBGMSG(DBG_ERROR, ("CopyIniPortToPort: invalid level %d", Level)); return NULL; } pEnd = PackStrings(SourceStrings, pPortInfo, pOffsets, pEnd); FreeSplMem(SourceStrings); return pEnd; }
// Given the player's current standings, generate the ranking data. // Returns a pointer to newly malloc()ed memory, which must be freed // by the caller. // // Returns NULL if unable to complete the request. // RankingType *Server_BuildRanking(ServerState *state, RankingInfo *rankingInfo, unsigned short *bodySize, DBID *idp) { RankingType *rankings, metric; GameInfo *gameInfo; long numGames, gameID; int i, gm, rk, nextrk; char numBuf1[11], numBuf2[11], strBuf[64]; char *vector[kNumRankStrings]; unsigned char *ucp, *metric1, *metric2; unsigned short *usp; unsigned short size; if ((gameInfo = Common_GetGameInfo(&numGames)) == NULL) { Logmsg("WHOA: couldn't get GameInfo; Very Bad\n"); return (NULL); } gameID = rankingInfo->gameID; // ID to search for; affected by aliases for (gm = 0; gm < numGames; gm++) { if (gameInfo[gm].gameID == gameID) { if (gameInfo[gm].alias != 0) { // found an alias; change gameID and start over gameID = gameInfo[gm].alias; gm = -1; continue; } // found the game, find the right rank for (rk = 0; rk < gameInfo[gm].numRanks; rk++) { if (gameInfo[gm].ranks[rk].xpoints > rankingInfo->xpoints) { // we passed it, use the previous one nextrk = rk; rk--; break; } } if (rk == gameInfo[gm].numRanks) { // highest rank? rk--; // make this equal highest rank nextrk = rk; // can't go any higher } break; } } if (gm == numGames) { Logmsg("Unable to find rank chart for %.8lx\n", rankingInfo->gameID); goto bail; } // XBAND Points sprintf(numBuf1, "%d", rankingInfo->xpoints); // Points Needed if (rk == nextrk) strcpy(numBuf2, "---"); // can't go no higher else sprintf(numBuf2, "%d", gameInfo[gm].ranks[nextrk].xpoints - rankingInfo->xpoints); vector[0] = gameInfo[gm].gameName; vector[1] = gameInfo[gm].ranks[rk].rankName; vector[2] = numBuf1; if (rk == nextrk) vector[3] = "---"; // that's all, folks! else vector[3] = gameInfo[gm].ranks[nextrk].rankName; vector[4] = numBuf2; Logmsg("Rank for 0x%.8lx: %s %s %s %s %s\n", rankingInfo->gameID, vector[0], vector[1], vector[2], vector[3], vector[4]); size = 0; for(i = 0; i < kNumRankStrings; i++) size += strlen(vector[i]) + 1; //size += sizeof(RankingType) - 1; // sizeof won't work; it's a 7 byte structure, but sizeof tells us // that it's 8 to keep things happy metric1 = (unsigned char *)&metric; metric2 = (unsigned char *)&(metric.rankData[0]); size += (metric2 - metric1); rankings = (RankingType *)malloc((long)size + kSecretChunk); rankings->gameID = gameID; // use aliased gameID here rankings->userID = state->loginData.userID.userID; PackStrings(rankings->rankData, kNumRankStrings, vector); // Set up the secret rankings. Right now, every game gets two. All // of this stuff has to fit within kSecretChunk bytes. // rankings->numHiddenStats = 2; if (rankings->gameID == kNBAJamGameID || rankings->gameID == 0x39677bdb) rankings->numHiddenStats++; // ATM // first secret rank: total points size += (size & 1); // 16-bit word-align ucp = (unsigned char *)rankings; ucp += size; *ucp++ = 2, size++; // make it a two-key sequence *ucp++ = 0, size++; // pad usp = (unsigned short *) ucp; *usp++ = kUP, size += 2; *usp++ = kUP, size += 2; ucp = (unsigned char *) usp; sprintf(strBuf, "Total points for: %ld, against: %ld", rankingInfo->pointsFor, rankingInfo->pointsAgainst); strcpy((char *)ucp, strBuf); ucp += strlen(strBuf) +1, size += strlen(strBuf) +1; size += (size & 1); // 16-bit word-align // second secret rank: win/loss, and my opinion size += (size & 1); // 16-bit word-align ucp = (unsigned char *)rankings; ucp += size; *ucp++ = 2, size++; // make it a two-key sequence *ucp++ = 0, size++; // pad usp = (unsigned short *) ucp; *usp++ = kUP, size += 2; *usp++ = kDOWN, size += 2; ucp = (unsigned char *) usp; sprintf(strBuf, "Total wins: %ld, losses: %ld", rankingInfo->wins, rankingInfo->losses); if (rankingInfo->wins > rankingInfo->losses) strcat(strBuf, " (you rewl)"); else strcat(strBuf, " (you suck)"); strcpy((char *)ucp, strBuf); ucp += strlen(strBuf) +1, size += strlen(strBuf) +1; size += (size & 1); // 16-bit word-align // third secret rank: only for NBA Jam if (rankings->numHiddenStats > 2) { size += (size & 1); // 16-bit word-align ucp = (unsigned char *)rankings; ucp += size; *ucp++ = 7, size++; // try 7 keys; max is 16 (up/down only sucks) *ucp++ = 0, size++; // pad usp = (unsigned short *) ucp; //*usp++ = kDOWN, size += 2; *usp++ = kDOWN | kLEFT, size += 2; *usp++ = kDOWN, size += 2; *usp++ = kDOWN, size += 2; *usp++ = kDOWN, size += 2; *usp++ = kDOWN, size += 2; *usp++ = kDOWN, size += 2; *usp++ = kUP, size += 2; ucp = (unsigned char *) usp; strcpy(strBuf, "Dave, Brian, & Andy2 were here"); strcpy((char *)ucp, strBuf); ucp += strlen(strBuf) +1, size += strlen(strBuf) +1; size += (size & 1); // 16-bit word-align } // All done! *bodySize = size; *idp = gameInfo[gm].gameID; Common_FreeGameInfo(gameInfo); return (rankings); bail: Common_FreeGameInfo(gameInfo); return (NULL); }