From cddcd7483a7c472598af098e759e5d309024f606 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Sun, 26 Dec 2021 20:31:39 +0300 Subject: DWORD -> uint32_t --- plugins/Db3x_mmap/src/database.cpp | 14 ++-- plugins/Db3x_mmap/src/dbcache.cpp | 20 +++--- plugins/Db3x_mmap/src/dbcontacts.cpp | 44 ++++++------- plugins/Db3x_mmap/src/dbcrypt.cpp | 20 +++--- plugins/Db3x_mmap/src/dbevents.cpp | 70 ++++++++++---------- plugins/Db3x_mmap/src/dbintf.h | 110 ++++++++++++++++---------------- plugins/Db3x_mmap/src/dbmodulechain.cpp | 14 ++-- plugins/Db3x_mmap/src/dbsettings.cpp | 40 ++++++------ 8 files changed, 166 insertions(+), 166 deletions(-) (limited to 'plugins/Db3x_mmap/src') diff --git a/plugins/Db3x_mmap/src/database.cpp b/plugins/Db3x_mmap/src/database.cpp index e1e1920c59..05aa49b89c 100644 --- a/plugins/Db3x_mmap/src/database.cpp +++ b/plugins/Db3x_mmap/src/database.cpp @@ -23,9 +23,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "stdafx.h" -DWORD CDb3Mmap::CreateNewSpace(int bytes) +uint32_t CDb3Mmap::CreateNewSpace(int bytes) { - DWORD ofsNew = m_dbHeader.ofsFileEnd; + uint32_t ofsNew = m_dbHeader.ofsFileEnd; m_dbHeader.ofsFileEnd += bytes; if (m_dbHeader.ofsFileEnd > m_dwFileSize) ReMap(m_dbHeader.ofsFileEnd - m_dwFileSize); @@ -34,7 +34,7 @@ DWORD CDb3Mmap::CreateNewSpace(int bytes) return ofsNew; } -void CDb3Mmap::DeleteSpace(DWORD ofs, int bytes) +void CDb3Mmap::DeleteSpace(uint32_t ofs, int bytes) { if (ofs + bytes == m_dbHeader.ofsFileEnd) { log2("freespace %d@%08x", bytes, ofs); @@ -48,12 +48,12 @@ void CDb3Mmap::DeleteSpace(DWORD ofs, int bytes) DBFill(ofs, bytes); } -DWORD CDb3Mmap::ReallocSpace(DWORD ofs, int oldSize, int newSize) +uint32_t CDb3Mmap::ReallocSpace(uint32_t ofs, int oldSize, int newSize) { if (oldSize >= newSize) return ofs; - DWORD ofsNew; + uint32_t ofsNew; if (ofs + oldSize == m_dbHeader.ofsFileEnd) { ofsNew = ofs; m_dbHeader.ofsFileEnd += newSize - oldSize; @@ -70,9 +70,9 @@ DWORD CDb3Mmap::ReallocSpace(DWORD ofs, int oldSize, int newSize) ///////////////////////////////////////////////////////////////////////////////////////// -static DWORD DatabaseCorrupted = 0; +static uint32_t DatabaseCorrupted = 0; static wchar_t *msg = nullptr; -static DWORD dwErr = 0; +static uint32_t dwErr = 0; static wchar_t tszPanic[] = LPGENW("Miranda has detected corruption in your database. Miranda will now shut down."); void __cdecl dbpanic(void *) diff --git a/plugins/Db3x_mmap/src/dbcache.cpp b/plugins/Db3x_mmap/src/dbcache.cpp index 4d9cee8392..01af3873cb 100644 --- a/plugins/Db3x_mmap/src/dbcache.cpp +++ b/plugins/Db3x_mmap/src/dbcache.cpp @@ -25,7 +25,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. void CDb3Mmap::Map() { - DWORD dwProtectMode, dwAccess; + uint32_t dwProtectMode, dwAccess; if (m_bReadOnly) dwProtectMode = PAGE_READONLY, dwAccess = FILE_MAP_READ; else @@ -40,7 +40,7 @@ void CDb3Mmap::Map() else DatabaseCorruption(L"%s (CreateFileMapping failed. Code: %d)"); } -void CDb3Mmap::ReMap(DWORD needed) +void CDb3Mmap::ReMap(uint32_t needed) { KillTimer(nullptr, m_flushBuffersTimerId); @@ -51,7 +51,7 @@ void CDb3Mmap::ReMap(DWORD needed) if (needed + m_dwFileSize > m_dbHeader.ofsFileEnd + m_ChunkSize) DatabaseCorruption(L"%s (Too large increment)"); else { - DWORD x = m_dbHeader.ofsFileEnd / m_ChunkSize; + uint32_t x = m_dbHeader.ofsFileEnd / m_ChunkSize; m_dwFileSize = (x + 1)*m_ChunkSize; } } @@ -65,7 +65,7 @@ void CDb3Mmap::ReMap(DWORD needed) Map(); } -void CDb3Mmap::DBMoveChunk(DWORD ofsDest, DWORD ofsSource, int bytes) +void CDb3Mmap::DBMoveChunk(uint32_t ofsDest, uint32_t ofsSource, int bytes) { int x = 0; //log3("move %d %08x->%08x",bytes,ofsSource,ofsDest); @@ -85,7 +85,7 @@ void CDb3Mmap::DBMoveChunk(DWORD ofsDest, DWORD ofsSource, int bytes) } //we are assumed to be in a mutex here -uint8_t* CDb3Mmap::DBRead(DWORD ofs, int *bytesAvail) +uint8_t* CDb3Mmap::DBRead(uint32_t ofs, int *bytesAvail) { // buggy read if (ofs >= m_dwFileSize) { @@ -101,7 +101,7 @@ uint8_t* CDb3Mmap::DBRead(DWORD ofs, int *bytesAvail) } //we are assumed to be in a mutex here -void CDb3Mmap::DBWrite(DWORD ofs, PVOID pData, int bytes) +void CDb3Mmap::DBWrite(uint32_t ofs, PVOID pData, int bytes) { //log2("write %d@%08x",bytes,ofs); if (ofs + bytes > m_dwFileSize) @@ -111,7 +111,7 @@ void CDb3Mmap::DBWrite(DWORD ofs, PVOID pData, int bytes) } //we are assumed to be in a mutex here -void CDb3Mmap::DBFill(DWORD ofs, int bytes) +void CDb3Mmap::DBFill(uint32_t ofs, int bytes) { //log2("zerofill %d@%08x",bytes,ofs); if ((ofs + bytes) <= m_dwFileSize) @@ -167,7 +167,7 @@ int CDb3Mmap::InitMap(void) // Align to chunk if (!m_bReadOnly) { - DWORD x = m_dwFileSize % m_ChunkSize; + uint32_t x = m_dwFileSize % m_ChunkSize; if (x) m_dwFileSize += m_ChunkSize - x; } @@ -179,9 +179,9 @@ int CDb3Mmap::InitMap(void) return 0; } -DWORD CDb3Mmap::GetSettingsGroupOfsByModuleNameOfs(DBContact *dbc, DWORD ofsModuleName) +uint32_t CDb3Mmap::GetSettingsGroupOfsByModuleNameOfs(DBContact *dbc, uint32_t ofsModuleName) { - DWORD ofsThis = dbc->ofsFirstSettings; + uint32_t ofsThis = dbc->ofsFirstSettings; while (ofsThis) { DBContactSettings *dbcs = (DBContactSettings*)DBRead(ofsThis, nullptr); if (dbcs->signature != DBCONTACTSETTINGS_SIGNATURE) DatabaseCorruption(nullptr); diff --git a/plugins/Db3x_mmap/src/dbcontacts.cpp b/plugins/Db3x_mmap/src/dbcontacts.cpp index 04e4aa5a78..26401b14de 100644 --- a/plugins/Db3x_mmap/src/dbcontacts.cpp +++ b/plugins/Db3x_mmap/src/dbcontacts.cpp @@ -40,7 +40,7 @@ STDMETHODIMP_(int) CDb3Mmap::DeleteContact(MCONTACT contactID) return 1; mir_cslockfull lck(m_csDbAccess); - DWORD ofsContact = GetContactOffset(contactID); + uint32_t ofsContact = GetContactOffset(contactID); DBContact *dbc = (DBContact*)DBRead(ofsContact, nullptr); if (dbc->signature != DBCONTACT_SIGNATURE) @@ -61,11 +61,11 @@ STDMETHODIMP_(int) CDb3Mmap::DeleteContact(MCONTACT contactID) lck.lock(); // delete settings chain - DWORD ofsThis = dbc->ofsFirstSettings; - DWORD ofsFirstEvent = dbc->ofsFirstEvent; + uint32_t ofsThis = dbc->ofsFirstSettings; + uint32_t ofsFirstEvent = dbc->ofsFirstEvent; while (ofsThis) { DBContactSettings *dbcs = (DBContactSettings*)DBRead(ofsThis, nullptr); - DWORD ofsNext = dbcs->ofsNext; + uint32_t ofsNext = dbcs->ofsNext; DeleteSpace(ofsThis, offsetof(DBContactSettings, blob) + dbcs->cbBlob); ofsThis = ofsNext; } @@ -74,7 +74,7 @@ STDMETHODIMP_(int) CDb3Mmap::DeleteContact(MCONTACT contactID) ofsThis = ofsFirstEvent; while (ofsThis) { DBEvent *dbe = (DBEvent*)DBRead(ofsThis, nullptr); - DWORD ofsNext = dbe->ofsNext; + uint32_t ofsNext = dbe->ofsNext; DeleteSpace(ofsThis, offsetof(DBEvent, blob) + dbe->cbBlob); ofsThis = ofsNext; } @@ -85,7 +85,7 @@ STDMETHODIMP_(int) CDb3Mmap::DeleteContact(MCONTACT contactID) DBWrite(0, &m_dbHeader, sizeof(m_dbHeader)); } else { - DWORD ofsNext = dbc->ofsNext; + uint32_t ofsNext = dbc->ofsNext; ofsThis = m_dbHeader.ofsFirstContact; DBContact *dbcPrev = (DBContact*)DBRead(ofsThis, nullptr); while (dbcPrev->ofsNext != ofsContact) { @@ -115,7 +115,7 @@ STDMETHODIMP_(int) CDb3Mmap::DeleteContact(MCONTACT contactID) STDMETHODIMP_(MCONTACT) CDb3Mmap::AddContact() { - DWORD ofsNew; + uint32_t ofsNew; log0("add contact"); DBContact dbc = { 0 }; @@ -189,7 +189,7 @@ BOOL CDb3Mmap::MetaMergeHistory(DBCachedContact *ccMeta, DBCachedContact *ccSub) else { // there're events in both meta's & sub's event chains // relink sub's event chain to meta without changing events themselves - for (DWORD ofsMeta = dbMeta->ofsFirstEvent; ofsMeta != 0;) { + for (uint32_t ofsMeta = dbMeta->ofsFirstEvent; ofsMeta != 0;) { DBEvent *pev = (DBEvent*)DBRead(ofsMeta, nullptr); if (pev->signature != DBEVENT_SIGNATURE) { // broken chain, don't touch it ret = 2; @@ -200,7 +200,7 @@ BOOL CDb3Mmap::MetaMergeHistory(DBCachedContact *ccMeta, DBCachedContact *ccSub) ofsMeta = pev->ofsNext; } - for (DWORD ofsSub = dbSub->ofsFirstEvent; ofsSub != 0;) { + for (uint32_t ofsSub = dbSub->ofsFirstEvent; ofsSub != 0;) { DBEvent *pev = (DBEvent*)DBRead(ofsSub, nullptr); if (pev->signature != DBEVENT_SIGNATURE) { // broken chain, don't touch it ret = 2; @@ -216,18 +216,18 @@ BOOL CDb3Mmap::MetaMergeHistory(DBCachedContact *ccMeta, DBCachedContact *ccSub) dbMeta->eventCount = arEvents.getCount(); DBEvent *pFirst = arEvents[0]; - dbMeta->ofsFirstEvent = DWORD((uint8_t*)pFirst - m_pDbCache); + dbMeta->ofsFirstEvent = uint32_t((uint8_t*)pFirst - m_pDbCache); pFirst->ofsPrev = 0; dbMeta->ofsFirstUnread = pFirst->markedRead() ? 0 : dbMeta->ofsFirstEvent; DBEvent *pLast = arEvents[arEvents.getCount() - 1]; - dbMeta->ofsLastEvent = DWORD((uint8_t*)pLast - m_pDbCache); + dbMeta->ofsLastEvent = uint32_t((uint8_t*)pLast - m_pDbCache); pLast->ofsNext = 0; for (int i = 1; i < arEvents.getCount(); i++) { DBEvent *pPrev = arEvents[i - 1], *pNext = arEvents[i]; - pPrev->ofsNext = DWORD((uint8_t*)pNext - m_pDbCache); - pNext->ofsPrev = DWORD((uint8_t*)pPrev - m_pDbCache); + pPrev->ofsNext = uint32_t((uint8_t*)pNext - m_pDbCache); + pNext->ofsPrev = uint32_t((uint8_t*)pPrev - m_pDbCache); if (dbMeta->ofsFirstUnread == 0 && !pNext->markedRead()) dbMeta->ofsFirstUnread = pPrev->ofsNext; @@ -264,7 +264,7 @@ BOOL CDb3Mmap::MetaSplitHistory(DBCachedContact *ccMeta, DBCachedContact *ccSub) if (ret = WipeContactHistory(&dbSub)) __leave; - DWORD dwOffset = dbMeta.ofsFirstEvent; + uint32_t dwOffset = dbMeta.ofsFirstEvent; DBEvent *evMeta = nullptr, *evSub = nullptr; dbMeta.eventCount = 0; dbMeta.ofsFirstEvent = dbMeta.ofsLastEvent = dbMeta.ofsFirstUnread = dbMeta.tsFirstUnread = 0; @@ -273,14 +273,14 @@ BOOL CDb3Mmap::MetaSplitHistory(DBCachedContact *ccMeta, DBCachedContact *ccSub) if (evCurr->signature != DBEVENT_SIGNATURE) break; - DWORD dwNext = evCurr->ofsNext; evCurr->ofsNext = 0; + uint32_t dwNext = evCurr->ofsNext; evCurr->ofsNext = 0; // extract it to sub's chain if (evCurr->contactID == ccSub->contactID) { dbSub.eventCount++; if (evSub != nullptr) { evSub->ofsNext = dwOffset; - evCurr->ofsPrev = DWORD((uint8_t*)evSub - m_pDbCache); + evCurr->ofsPrev = uint32_t((uint8_t*)evSub - m_pDbCache); } else { dbSub.ofsFirstEvent = dwOffset; @@ -297,7 +297,7 @@ BOOL CDb3Mmap::MetaSplitHistory(DBCachedContact *ccMeta, DBCachedContact *ccSub) dbMeta.eventCount++; if (evMeta != nullptr) { evMeta->ofsNext = dwOffset; - evCurr->ofsPrev = DWORD((uint8_t*)evMeta - m_pDbCache); + evCurr->ofsPrev = uint32_t((uint8_t*)evMeta - m_pDbCache); } else { dbMeta.ofsFirstEvent = dwOffset; @@ -331,11 +331,11 @@ BOOL CDb3Mmap::MetaSplitHistory(DBCachedContact *ccMeta, DBCachedContact *ccSub) struct COldMeta { - COldMeta(DWORD _id, DBCachedContact *_cc) : + COldMeta(uint32_t _id, DBCachedContact *_cc) : hMetaID(_id), cc(_cc) {} - DWORD hMetaID; + uint32_t hMetaID; DBCachedContact *cc; }; @@ -343,12 +343,12 @@ void CDb3Mmap::FillContacts() { OBJLIST arMetas(10, NumericKeySortT); - for (DWORD dwOffset = m_dbHeader.ofsFirstContact; dwOffset != 0;) { + for (uint32_t dwOffset = m_dbHeader.ofsFirstContact; dwOffset != 0;) { DBContact *p = (DBContact*)DBRead(dwOffset, nullptr); if (p->signature != DBCONTACT_SIGNATURE) break; - DWORD dwContactID; + uint32_t dwContactID; if (m_dbHeader.version >= DB_095_VERSION) { dwContactID = p->dwContactID; if (dwContactID >= m_dwMaxContactId) @@ -440,7 +440,7 @@ void CDb3Mmap::FillContacts() } } -DWORD CDb3Mmap::GetContactOffset(MCONTACT contactID, DBCachedContact **pcc) +uint32_t CDb3Mmap::GetContactOffset(MCONTACT contactID, DBCachedContact **pcc) { if (contactID == 0) { if (pcc) *pcc = nullptr; diff --git a/plugins/Db3x_mmap/src/dbcrypt.cpp b/plugins/Db3x_mmap/src/dbcrypt.cpp index bd8b1495f0..6743eea64d 100644 --- a/plugins/Db3x_mmap/src/dbcrypt.cpp +++ b/plugins/Db3x_mmap/src/dbcrypt.cpp @@ -162,7 +162,7 @@ STDMETHODIMP_(BOOL) CDb3Mmap::EnableEncryption(BOOL bEnable) void CDb3Mmap::ToggleSettingsEncryption(MCONTACT contactID) { - DWORD ofsContact = GetContactOffset(contactID); + uint32_t ofsContact = GetContactOffset(contactID); if (ofsContact == 0) return; @@ -172,7 +172,7 @@ void CDb3Mmap::ToggleSettingsEncryption(MCONTACT contactID) // fast cycle through all settings DBContactSettings *setting = (DBContactSettings*)DBRead(contact->ofsFirstSettings, nullptr); - DWORD offset = contact->ofsFirstSettings; + uint32_t offset = contact->ofsFirstSettings; char *szModule = GetModuleNameByOfs(setting->ofsModuleName); if (szModule == nullptr) return; @@ -181,7 +181,7 @@ void CDb3Mmap::ToggleSettingsEncryption(MCONTACT contactID) OBJLIST arSettings(10); char szSetting[256]; int bytesRemaining, len; - DWORD ofsBlobPtr = offset + offsetof(DBContactSettings, blob), ofsNext = setting->ofsNext; + uint32_t ofsBlobPtr = offset + offsetof(DBContactSettings, blob), ofsNext = setting->ofsNext; uint8_t *pBlob = (uint8_t*)DBRead(ofsBlobPtr, &bytesRemaining); while (pBlob[0]) { NeedBytes(1); @@ -269,7 +269,7 @@ void CDb3Mmap::ToggleSettingsEncryption(MCONTACT contactID) void CDb3Mmap::ToggleEventsEncryption(MCONTACT contactID) { - DWORD ofsContact = GetContactOffset(contactID); + uint32_t ofsContact = GetContactOffset(contactID); if (ofsContact == 0) return; @@ -278,20 +278,20 @@ void CDb3Mmap::ToggleEventsEncryption(MCONTACT contactID) return; // fast cycle through all events - for (DWORD offset = contact.ofsFirstEvent; offset != 0;) { + for (uint32_t offset = contact.ofsFirstEvent; offset != 0;) { DBEvent evt = *(DBEvent*)DBRead(offset, nullptr); if (evt.signature != DBEVENT_SIGNATURE) return; size_t len; - DWORD ofsDest; + uint32_t ofsDest; mir_ptr pBlob; uint8_t *pSource = DBRead(offset + offsetof(DBEvent, blob), nullptr); if (!m_bEncrypted) { // we need more space if ((pBlob = m_crypto->encodeBuffer(pSource, evt.cbBlob, &len)) == nullptr) return; - ofsDest = ReallocSpace(offset, offsetof(DBEvent, blob) + evt.cbBlob, offsetof(DBEvent, blob) + (DWORD)len); + ofsDest = ReallocSpace(offset, offsetof(DBEvent, blob) + evt.cbBlob, offsetof(DBEvent, blob) + (uint32_t)len); if (evt.ofsNext) { DBEvent *e = (DBEvent*)DBRead(evt.ofsNext, nullptr); @@ -320,12 +320,12 @@ void CDb3Mmap::ToggleEventsEncryption(MCONTACT contactID) evt.flags &= ~DBEF_ENCRYPTED; if (len < evt.cbBlob) - DBFill(ofsDest + offsetof(DBEvent, blob) + (DWORD)len, evt.cbBlob - (DWORD)len); + DBFill(ofsDest + offsetof(DBEvent, blob) + (uint32_t)len, evt.cbBlob - (uint32_t)len); } - evt.cbBlob = (DWORD)len; + evt.cbBlob = (uint32_t)len; DBWrite(ofsDest, &evt, offsetof(DBEvent, blob)); - DBWrite(ofsDest + offsetof(DBEvent, blob), pBlob, (DWORD)len); + DBWrite(ofsDest + offsetof(DBEvent, blob), pBlob, (uint32_t)len); offset = evt.ofsNext; } diff --git a/plugins/Db3x_mmap/src/dbevents.cpp b/plugins/Db3x_mmap/src/dbevents.cpp index 806f51e955..6037ec19df 100644 --- a/plugins/Db3x_mmap/src/dbevents.cpp +++ b/plugins/Db3x_mmap/src/dbevents.cpp @@ -72,19 +72,19 @@ MEVENT CDb3Mmap::AddEvent(MCONTACT contactID, const DBEVENTINFO *dbei) uint8_t *pResult = m_crypto->encodeBuffer(pBlob, dbe.cbBlob, &len); if (pResult != nullptr) { pCryptBlob = pBlob = pResult; - dbe.cbBlob = (DWORD)len; + dbe.cbBlob = (uint32_t)len; dbe.flags |= DBEF_ENCRYPTED; } } mir_cslockfull lck(m_csDbAccess); - DWORD ofsContact = GetContactOffset(contactID); + uint32_t ofsContact = GetContactOffset(contactID); DBContact dbc = *(DBContact*)DBRead(ofsContact, nullptr); if (dbc.signature != DBCONTACT_SIGNATURE) return 0; - DWORD ofsNew = CreateNewSpace(offsetof(DBEvent, blob) + dbe.cbBlob); + uint32_t ofsNew = CreateNewSpace(offsetof(DBEvent, blob) + dbe.cbBlob); dbe.ofsModuleName = GetModuleNameOfs(dbei->szModule); // find where to put it - sort by timestamp @@ -105,7 +105,7 @@ MEVENT CDb3Mmap::AddEvent(MCONTACT contactID, const DBEVENTINFO *dbei) } else { // Loop through the chain, starting at the end - DWORD ofsThis = dbc.ofsLastEvent; + uint32_t ofsThis = dbc.ofsLastEvent; dbeTest = (DBEvent*)DBRead(ofsThis, nullptr); for (;;) { // If the new event's timesstamp is equal to or greater than the @@ -168,7 +168,7 @@ MEVENT CDb3Mmap::AddEvent(MCONTACT contactID, const DBEVENTINFO *dbei) BOOL CDb3Mmap::DeleteEvent(MEVENT hDbEvent) { mir_cslockfull lck(m_csDbAccess); - DBEvent dbe = *(DBEvent*)DBRead((DWORD)hDbEvent, nullptr); + DBEvent dbe = *(DBEvent*)DBRead((uint32_t)hDbEvent, nullptr); if (dbe.signature != DBEVENT_SIGNATURE) return 1; @@ -182,7 +182,7 @@ BOOL CDb3Mmap::DeleteEvent(MEVENT hDbEvent) } else cc = nullptr; - DWORD ofsContact = (cc) ? cc->dwOfsContact : m_dbHeader.ofsUser; + uint32_t ofsContact = (cc) ? cc->dwOfsContact : m_dbHeader.ofsUser; DBContact dbc = *(DBContact *)DBRead(ofsContact, nullptr); if (dbc.signature != DBCONTACT_SIGNATURE) return 1; @@ -196,17 +196,17 @@ BOOL CDb3Mmap::DeleteEvent(MEVENT hDbEvent) // get back in lck.lock(); dbc = *(DBContact*)DBRead(ofsContact, nullptr); - dbe = *(DBEvent*)DBRead((DWORD)hDbEvent, nullptr); + dbe = *(DBEvent*)DBRead((uint32_t)hDbEvent, nullptr); // check if this was the first unread, if so, recalc the first unread - if (dbc.ofsFirstUnread == (DWORD)hDbEvent) { + if (dbc.ofsFirstUnread == (uint32_t)hDbEvent) { for (DBEvent *dbeNext = &dbe;;) { if (dbeNext->ofsNext == 0) { dbc.ofsFirstUnread = 0; dbc.tsFirstUnread = 0; break; } - DWORD ofsThis = dbeNext->ofsNext; + uint32_t ofsThis = dbeNext->ofsNext; dbeNext = (DBEvent*)DBRead(ofsThis, nullptr); if (!dbeNext->markedRead()) { dbc.ofsFirstUnread = ofsThis; @@ -250,7 +250,7 @@ BOOL CDb3Mmap::DeleteEvent(MEVENT hDbEvent) DBWrite(ofsContact, &dbc, sizeof(DBContact)); // delete event - DeleteSpace((DWORD)hDbEvent, offsetof(DBEvent, blob) + dbe.cbBlob); + DeleteSpace((uint32_t)hDbEvent, offsetof(DBEvent, blob) + dbe.cbBlob); // also update a sub if (cc && dbe.contactID != cc->contactID) { @@ -271,7 +271,7 @@ BOOL CDb3Mmap::EditEvent(MCONTACT, MEVENT, const DBEVENTINFO*) int CDb3Mmap::GetBlobSize(MEVENT hDbEvent) { mir_cslock lck(m_csDbAccess); - DBEvent *dbe = AdaptEvent((DWORD)hDbEvent, 0); + DBEvent *dbe = AdaptEvent((uint32_t)hDbEvent, 0); return (dbe->signature != DBEVENT_SIGNATURE) ? -1 : dbe->cbBlob; } @@ -284,7 +284,7 @@ BOOL CDb3Mmap::GetEvent(MEVENT hDbEvent, DBEVENTINFO *dbei) } mir_cslock lck(m_csDbAccess); - DBEvent *dbe = AdaptEvent((DWORD)hDbEvent, 0); + DBEvent *dbe = AdaptEvent((uint32_t)hDbEvent, 0); if (dbe->signature != DBEVENT_SIGNATURE) return 1; @@ -293,7 +293,7 @@ BOOL CDb3Mmap::GetEvent(MEVENT hDbEvent, DBEVENTINFO *dbei) dbei->flags = dbe->flags; dbei->eventType = dbe->wEventType; - DWORD cbBlob = dbe->cbBlob; + uint32_t cbBlob = dbe->cbBlob; size_t bytesToCopy = cbBlob; if (dbei->cbBlob == -1) dbei->pBlob = (uint8_t*)mir_calloc(cbBlob + 2); @@ -304,9 +304,9 @@ BOOL CDb3Mmap::GetEvent(MEVENT hDbEvent, DBEVENTINFO *dbei) if (bytesToCopy && dbei->pBlob) { uint8_t *pSrc; if (m_dbHeader.version >= DB_095_1_VERSION) - pSrc = DBRead(DWORD(hDbEvent) + offsetof(DBEvent, blob), nullptr); + pSrc = DBRead(uint32_t(hDbEvent) + offsetof(DBEvent, blob), nullptr); else - pSrc = DBRead(DWORD(hDbEvent) + offsetof(DBEvent_094, blob), nullptr); + pSrc = DBRead(uint32_t(hDbEvent) + offsetof(DBEvent_094, blob), nullptr); if (dbe->flags & DBEF_ENCRYPTED) { dbei->flags &= ~DBEF_ENCRYPTED; size_t len; @@ -337,9 +337,9 @@ BOOL CDb3Mmap::MarkEventRead(MCONTACT contactID, MEVENT hDbEvent) else cc = nullptr; mir_cslockfull lck(m_csDbAccess); - DWORD ofsContact = (cc) ? cc->dwOfsContact : m_dbHeader.ofsUser; + uint32_t ofsContact = (cc) ? cc->dwOfsContact : m_dbHeader.ofsUser; DBContact dbc = *(DBContact*)DBRead(ofsContact, nullptr); - DBEvent *dbe = (DBEvent*)DBRead((DWORD)hDbEvent, nullptr); + DBEvent *dbe = (DBEvent*)DBRead((uint32_t)hDbEvent, nullptr); if (dbe->signature != DBEVENT_SIGNATURE || dbc.signature != DBCONTACT_SIGNATURE) return -1; @@ -348,16 +348,16 @@ BOOL CDb3Mmap::MarkEventRead(MCONTACT contactID, MEVENT hDbEvent) // log1("mark read @ %08x", hContact); dbe->flags |= DBEF_READ; - DBWrite((DWORD)hDbEvent, dbe, sizeof(DBEvent)); + DBWrite((uint32_t)hDbEvent, dbe, sizeof(DBEvent)); BOOL ret = dbe->flags; - if (dbc.ofsFirstUnread == (DWORD)hDbEvent) { + if (dbc.ofsFirstUnread == (uint32_t)hDbEvent) { for (;;) { if (dbe->ofsNext == 0) { dbc.ofsFirstUnread = 0; dbc.tsFirstUnread = 0; break; } - DWORD ofsThis = dbe->ofsNext; + uint32_t ofsThis = dbe->ofsNext; dbe = (DBEvent*)DBRead(ofsThis, nullptr); if (!dbe->markedRead()) { dbc.ofsFirstUnread = ofsThis; @@ -377,14 +377,14 @@ BOOL CDb3Mmap::MarkEventRead(MCONTACT contactID, MEVENT hDbEvent) MCONTACT CDb3Mmap::GetEventContact(MEVENT hDbEvent) { mir_cslock lck(m_csDbAccess); - DBEvent *dbe = AdaptEvent((DWORD)hDbEvent, INVALID_CONTACT_ID); + DBEvent *dbe = AdaptEvent((uint32_t)hDbEvent, INVALID_CONTACT_ID); return (dbe->signature != DBEVENT_SIGNATURE) ? INVALID_CONTACT_ID : dbe->contactID; } MEVENT CDb3Mmap::FindFirstEvent(MCONTACT contactID) { DBCachedContact *cc; - DWORD ofsContact = GetContactOffset(contactID, &cc); + uint32_t ofsContact = GetContactOffset(contactID, &cc); mir_cslock lck(m_csDbAccess); DBContact *dbc = (DBContact*)DBRead(ofsContact, nullptr); @@ -399,7 +399,7 @@ MEVENT CDb3Mmap::FindFirstEvent(MCONTACT contactID) if (dbc->signature != DBCONTACT_SIGNATURE) return 0; - for (DWORD dwOffset = dbc->ofsFirstEvent; dwOffset != 0;) { + for (uint32_t dwOffset = dbc->ofsFirstEvent; dwOffset != 0;) { DBEvent *dbe = AdaptEvent(dwOffset, contactID); if (dbe->signature != DBEVENT_SIGNATURE) return 0; @@ -413,7 +413,7 @@ MEVENT CDb3Mmap::FindFirstEvent(MCONTACT contactID) MEVENT CDb3Mmap::FindFirstUnreadEvent(MCONTACT contactID) { DBCachedContact *cc; - DWORD ofsContact = GetContactOffset(contactID, &cc); + uint32_t ofsContact = GetContactOffset(contactID, &cc); mir_cslock lck(m_csDbAccess); DBContact *dbc = (DBContact*)DBRead(ofsContact, nullptr); @@ -428,7 +428,7 @@ MEVENT CDb3Mmap::FindFirstUnreadEvent(MCONTACT contactID) if (dbc->signature != DBCONTACT_SIGNATURE) return 0; - for (DWORD dwOffset = dbc->ofsFirstUnread; dwOffset != 0;) { + for (uint32_t dwOffset = dbc->ofsFirstUnread; dwOffset != 0;) { DBEvent *dbe = AdaptEvent(dwOffset, contactID); if (dbe->signature != DBEVENT_SIGNATURE) return 0; @@ -442,7 +442,7 @@ MEVENT CDb3Mmap::FindFirstUnreadEvent(MCONTACT contactID) MEVENT CDb3Mmap::FindLastEvent(MCONTACT contactID) { DBCachedContact *cc; - DWORD ofsContact = GetContactOffset(contactID, &cc); + uint32_t ofsContact = GetContactOffset(contactID, &cc); mir_cslock lck(m_csDbAccess); DBContact *dbc = (DBContact*)DBRead(ofsContact, nullptr); @@ -457,7 +457,7 @@ MEVENT CDb3Mmap::FindLastEvent(MCONTACT contactID) if (dbc->signature != DBCONTACT_SIGNATURE) return 0; - for (DWORD dwOffset = dbc->ofsLastEvent; dwOffset != 0;) { + for (uint32_t dwOffset = dbc->ofsLastEvent; dwOffset != 0;) { DBEvent *dbe = AdaptEvent(dwOffset, contactID); if (dbe->signature != DBEVENT_SIGNATURE) return 0; @@ -473,13 +473,13 @@ MEVENT CDb3Mmap::FindNextEvent(MCONTACT contactID, MEVENT hDbEvent) DBCachedContact *cc = (contactID) ? m_cache->GetCachedContact(contactID) : nullptr; mir_cslock lck(m_csDbAccess); - DBEvent *dbe = AdaptEvent((DWORD)hDbEvent, contactID); + DBEvent *dbe = AdaptEvent((uint32_t)hDbEvent, contactID); if (dbe->signature != DBEVENT_SIGNATURE) return 0; if (!cc || !cc->IsSub()) return MEVENT(dbe->ofsNext); - for (DWORD dwOffset = dbe->ofsNext; dwOffset != 0;) { + for (uint32_t dwOffset = dbe->ofsNext; dwOffset != 0;) { dbe = AdaptEvent(dwOffset, contactID); if (dbe->signature != DBEVENT_SIGNATURE) return 0; @@ -495,13 +495,13 @@ MEVENT CDb3Mmap::FindPrevEvent(MCONTACT contactID, MEVENT hDbEvent) DBCachedContact *cc = (contactID) ? m_cache->GetCachedContact(contactID) : nullptr; mir_cslock lck(m_csDbAccess); - DBEvent *dbe = AdaptEvent((DWORD)hDbEvent, contactID); + DBEvent *dbe = AdaptEvent((uint32_t)hDbEvent, contactID); if (dbe->signature != DBEVENT_SIGNATURE) return 0; if (!cc || !cc->IsSub()) return MEVENT(dbe->ofsPrev); - for (DWORD dwOffset = dbe->ofsPrev; dwOffset != 0;) { + for (uint32_t dwOffset = dbe->ofsPrev; dwOffset != 0;) { dbe = AdaptEvent(dwOffset, contactID); if (dbe->signature != DBEVENT_SIGNATURE) return 0; @@ -512,7 +512,7 @@ MEVENT CDb3Mmap::FindPrevEvent(MCONTACT contactID, MEVENT hDbEvent) return 0; } -DBEvent* CDb3Mmap::AdaptEvent(DWORD ofs, DWORD dwContactID) +DBEvent* CDb3Mmap::AdaptEvent(uint32_t ofs, uint32_t dwContactID) { if (m_dbHeader.version >= DB_095_1_VERSION) return (DBEvent*)DBRead(ofs, nullptr); @@ -520,7 +520,7 @@ DBEvent* CDb3Mmap::AdaptEvent(DWORD ofs, DWORD dwContactID) DBEvent_094 *pOldEvent = (DBEvent_094*)DBRead(ofs, nullptr); m_tmpEvent.signature = pOldEvent->signature; m_tmpEvent.contactID = dwContactID; - memcpy(&m_tmpEvent.ofsPrev, &pOldEvent->ofsPrev, sizeof(DBEvent_094) - sizeof(DWORD)); + memcpy(&m_tmpEvent.ofsPrev, &pOldEvent->ofsPrev, sizeof(DBEvent_094) - sizeof(uint32_t)); return &m_tmpEvent; } @@ -530,12 +530,12 @@ DBEvent* CDb3Mmap::AdaptEvent(DWORD ofs, DWORD dwContactID) int CDb3Mmap::WipeContactHistory(DBContact *dbc) { // drop subContact's history if any - for (DWORD dwOffset = dbc->ofsFirstEvent; dwOffset != 0;) { + for (uint32_t dwOffset = dbc->ofsFirstEvent; dwOffset != 0;) { DBEvent *pev = (DBEvent*)DBRead(dwOffset, nullptr); if (pev->signature != DBEVENT_SIGNATURE) // broken chain, don't touch it return 2; - DWORD dwNext = pev->ofsNext; + uint32_t dwNext = pev->ofsNext; DeleteSpace(dwOffset, offsetof(DBEvent, blob) + pev->cbBlob); dwOffset = dwNext; } diff --git a/plugins/Db3x_mmap/src/dbintf.h b/plugins/Db3x_mmap/src/dbintf.h index 10daa4517c..3163af2516 100644 --- a/plugins/Db3x_mmap/src/dbintf.h +++ b/plugins/Db3x_mmap/src/dbintf.h @@ -68,7 +68,7 @@ DBHeader #define NeedBytes(n) if (bytesRemaining<(n)) pBlob = (uint8_t*)DBRead(ofsBlobPtr,&bytesRemaining) #define MoveAlong(n) {int x = n; pBlob += (x); ofsBlobPtr += (x); bytesRemaining -= (x);} -DWORD __forceinline GetSettingValueLength(uint8_t *pSetting) +uint32_t __forceinline GetSettingValueLength(uint8_t *pSetting) { if (pSetting[0] & DBVTF_VARIABLELENGTH) return 2 + *(PWORD)(pSetting + 1); @@ -84,45 +84,45 @@ struct DBSignature struct ModuleName { char *name; - DWORD ofs; + uint32_t ofs; }; #include struct DBHeader { uint8_t signature[16]; // 'Miranda ICQ DB',0,26 - DWORD version; // as 4 bytes, ie 1.2.3.10 = 0x0102030a - DWORD ofsFileEnd; // offset of the end of the database - place to write new structures - DWORD slackSpace; // a counter of the number of bytes that have been + uint32_t version; // as 4 bytes, ie 1.2.3.10 = 0x0102030a + uint32_t ofsFileEnd; // offset of the end of the database - place to write new structures + uint32_t slackSpace; // a counter of the number of bytes that have been // wasted so far due to deleting structures and/or // re-making them at the end. We should compact when // this gets above a threshold - DWORD contactCount; // number of contacts in the chain,excluding the user - DWORD ofsFirstContact; // offset to first DBContact in the chain - DWORD ofsUser; // offset to DBContact representing the user - DWORD ofsModuleNames; // offset to first struct DBModuleName in the chain + uint32_t contactCount; // number of contacts in the chain,excluding the user + uint32_t ofsFirstContact; // offset to first DBContact in the chain + uint32_t ofsUser; // offset to DBContact representing the user + uint32_t ofsModuleNames; // offset to first struct DBModuleName in the chain }; #define DBCONTACT_SIGNATURE 0x43DECADEu struct DBContact { - DWORD signature; - DWORD ofsNext; // offset to the next contact in the chain. zero if + uint32_t signature; + uint32_t ofsNext; // offset to the next contact in the chain. zero if // this is the 'user' contact or the last contact in the chain - DWORD ofsFirstSettings; // offset to the first DBContactSettings in the chain for this contact. - DWORD eventCount; // number of events in the chain for this contact - DWORD ofsFirstEvent, // offsets to the first and + uint32_t ofsFirstSettings; // offset to the first DBContactSettings in the chain for this contact. + uint32_t eventCount; // number of events in the chain for this contact + uint32_t ofsFirstEvent, // offsets to the first and ofsLastEvent; // last DBEvent in the chain for this contact - DWORD ofsFirstUnread; // offset to the first (chronological) unread event in the chain, 0 if all are read - DWORD tsFirstUnread; // timestamp of the event at ofsFirstUnread - DWORD dwContactID; + uint32_t ofsFirstUnread; // offset to the first (chronological) unread event in the chain, 0 if all are read + uint32_t tsFirstUnread; // timestamp of the event at ofsFirstUnread + uint32_t dwContactID; }; #define DBMODULENAME_SIGNATURE 0x4DDECADEu struct DBModuleName { - DWORD signature; - DWORD ofsNext; // offset to the next module name in the chain + uint32_t signature; + uint32_t ofsNext; // offset to the next module name in the chain uint8_t cbName; // number of characters in this module name char name[1]; // name, no nul terminator }; @@ -130,10 +130,10 @@ struct DBModuleName #define DBCONTACTSETTINGS_SIGNATURE 0x53DECADEu struct DBContactSettings { - DWORD signature; - DWORD ofsNext; // offset to the next contactsettings in the chain - DWORD ofsModuleName; // offset to the DBModuleName of the owner of these settings - DWORD cbBlob; // size of the blob in bytes. May be larger than the + uint32_t signature; + uint32_t ofsNext; // offset to the next contactsettings in the chain + uint32_t ofsModuleName; // offset to the DBModuleName of the owner of these settings + uint32_t cbBlob; // size of the blob in bytes. May be larger than the // actual size for reducing the number of moves // required using granularity in resizing uint8_t blob[1]; // the blob. a back-to-back sequence of DBSetting @@ -143,30 +143,30 @@ struct DBContactSettings #define DBEVENT_SIGNATURE 0x45DECADEu struct DBEvent_094 // previous event storage format { - DWORD signature; - DWORD ofsPrev, ofsNext; // offset to the previous and next events in the + uint32_t signature; + uint32_t ofsPrev, ofsNext; // offset to the previous and next events in the // chain. Chain is sorted chronologically - DWORD ofsModuleName; // offset to a DBModuleName struct of the name of + uint32_t ofsModuleName; // offset to a DBModuleName struct of the name of // the owner of this event - DWORD timestamp; // seconds since 00:00:00 01/01/1970 - DWORD flags; // see m_database.h, db/event/add + uint32_t timestamp; // seconds since 00:00:00 01/01/1970 + uint32_t flags; // see m_database.h, db/event/add uint16_t wEventType; // module-defined event type - DWORD cbBlob; // number of bytes in the blob + uint32_t cbBlob; // number of bytes in the blob uint8_t blob[1]; // the blob. module-defined formatting }; struct DBEvent { - DWORD signature; + uint32_t signature; MCONTACT contactID; // a contact this event belongs to - DWORD ofsPrev, ofsNext; // offset to the previous and next events in the + uint32_t ofsPrev, ofsNext; // offset to the previous and next events in the // chain. Chain is sorted chronologically - DWORD ofsModuleName; // offset to a DBModuleName struct of the name of + uint32_t ofsModuleName; // offset to a DBModuleName struct of the name of // the owner of this event - DWORD timestamp; // seconds since 00:00:00 01/01/1970 - DWORD flags; // see m_database.h, db/event/add + uint32_t timestamp; // seconds since 00:00:00 01/01/1970 + uint32_t flags; // see m_database.h, db/event/add uint16_t wEventType; // module-defined event type - DWORD cbBlob; // number of bytes in the blob + uint32_t cbBlob; // number of bytes in the blob uint8_t blob[1]; // the blob. module-defined formatting bool __forceinline markedRead() const @@ -179,7 +179,7 @@ struct DBEvent struct DBCachedContact : public DBCachedContactBase { - DWORD dwOfsContact; + uint32_t dwOfsContact; }; struct CDb3Mmap : public MDatabaseCommon, public MZeroedObject @@ -245,13 +245,13 @@ public: STDMETHODIMP_(DATABASELINK*) GetDriver() override; protected: - DWORD GetSettingsGroupOfsByModuleNameOfs(DBContact *dbc, DWORD ofsModuleName); - void InvalidateSettingsGroupOfsCacheEntry(DWORD) {} + uint32_t GetSettingsGroupOfsByModuleNameOfs(DBContact *dbc, uint32_t ofsModuleName); + void InvalidateSettingsGroupOfsCacheEntry(uint32_t) {} - void DBMoveChunk(DWORD ofsDest, DWORD ofsSource, int bytes); - uint8_t* DBRead(DWORD ofs, int *bytesAvail); - void DBWrite(DWORD ofs, PVOID pData, int bytes); - void DBFill(DWORD ofs, int bytes); + void DBMoveChunk(uint32_t ofsDest, uint32_t ofsSource, int bytes); + uint8_t* DBRead(uint32_t ofs, int *bytesAvail); + void DBWrite(uint32_t ofs, PVOID pData, int bytes); + void DBFill(uint32_t ofs, int bytes); void DBFlush(int setting); int InitMap(void); void FillContacts(void); @@ -259,29 +259,29 @@ protected: uint8_t* m_pNull; void Map(); - void ReMap(DWORD needed); + void ReMap(uint32_t needed); protected: wchar_t* m_tszProfileName; HANDLE m_hDbFile; DBHeader m_dbHeader; - DWORD m_ChunkSize; + uint32_t m_ChunkSize; bool m_safetyMode, m_bReadOnly, m_bShared; //////////////////////////////////////////////////////////////////////////// // database stuff public: UINT_PTR m_flushBuffersTimerId; - DWORD m_flushFailTick; + uint32_t m_flushFailTick; uint8_t* m_pDbCache; HANDLE m_hMap; protected: - DWORD m_dwFileSize, m_dwMaxContactId; + uint32_t m_dwFileSize, m_dwMaxContactId; - DWORD CreateNewSpace(int bytes); - void DeleteSpace(DWORD ofs, int bytes); - DWORD ReallocSpace(DWORD ofs, int oldSize, int newSize); + uint32_t CreateNewSpace(int bytes); + void DeleteSpace(uint32_t ofs, int bytes); + uint32_t ReallocSpace(uint32_t ofs, int oldSize, int newSize); //////////////////////////////////////////////////////////////////////////// // settings @@ -292,14 +292,14 @@ protected: // contacts int WipeContactHistory(DBContact *dbc); - DWORD GetContactOffset(MCONTACT contactID, DBCachedContact **cc = nullptr); + uint32_t GetContactOffset(MCONTACT contactID, DBCachedContact **cc = nullptr); //////////////////////////////////////////////////////////////////////////// // events DBEvent m_tmpEvent; - DBEvent* AdaptEvent(DWORD offset, DWORD hContact); + DBEvent* AdaptEvent(uint32_t offset, uint32_t hContact); //////////////////////////////////////////////////////////////////////////// // modules @@ -309,11 +309,11 @@ protected: MCONTACT m_hLastCachedContact; ModuleName *m_lastmn; - void AddToList(char *name, DWORD ofs); - DWORD FindExistingModuleNameOfs(const char *szName); + void AddToList(char *name, uint32_t ofs); + uint32_t FindExistingModuleNameOfs(const char *szName); int InitModuleNames(void); - DWORD GetModuleNameOfs(const char *szName); - char* GetModuleNameByOfs(DWORD ofs); + uint32_t GetModuleNameOfs(const char *szName); + char* GetModuleNameByOfs(uint32_t ofs); //////////////////////////////////////////////////////////////////////////// // encryption diff --git a/plugins/Db3x_mmap/src/dbmodulechain.cpp b/plugins/Db3x_mmap/src/dbmodulechain.cpp index 6c64391bfb..96bb85d110 100644 --- a/plugins/Db3x_mmap/src/dbmodulechain.cpp +++ b/plugins/Db3x_mmap/src/dbmodulechain.cpp @@ -23,7 +23,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "stdafx.h" -void CDb3Mmap::AddToList(char *name, DWORD ofs) +void CDb3Mmap::AddToList(char *name, uint32_t ofs) { ModuleName *mn = (ModuleName*)HeapAlloc(m_hModHeap, 0, sizeof(ModuleName)); mn->name = name; @@ -40,7 +40,7 @@ void CDb3Mmap::AddToList(char *name, DWORD ofs) int CDb3Mmap::InitModuleNames(void) { - DWORD ofsThis = m_dbHeader.ofsModuleNames; + uint32_t ofsThis = m_dbHeader.ofsModuleNames; DBModuleName *dbmn = (struct DBModuleName*)DBRead(ofsThis, nullptr); while (ofsThis) { if (dbmn->signature != DBMODULENAME_SIGNATURE) @@ -60,7 +60,7 @@ int CDb3Mmap::InitModuleNames(void) return 0; } -DWORD CDb3Mmap::FindExistingModuleNameOfs(const char *szName) +uint32_t CDb3Mmap::FindExistingModuleNameOfs(const char *szName) { ModuleName mn = { (char*)szName, 0 }; if (m_lastmn && !mir_strcmp(mn.name, m_lastmn->name)) @@ -77,9 +77,9 @@ DWORD CDb3Mmap::FindExistingModuleNameOfs(const char *szName) } // will create the offset if it needs to -DWORD CDb3Mmap::GetModuleNameOfs(const char *szName) +uint32_t CDb3Mmap::GetModuleNameOfs(const char *szName) { - DWORD ofsExisting = FindExistingModuleNameOfs(szName); + uint32_t ofsExisting = FindExistingModuleNameOfs(szName); if (ofsExisting) return ofsExisting; @@ -89,7 +89,7 @@ DWORD CDb3Mmap::GetModuleNameOfs(const char *szName) int nameLen = (int)mir_strlen(szName); // need to create the module name - DWORD ofsNew = CreateNewSpace(nameLen + offsetof(struct DBModuleName, name)); + uint32_t ofsNew = CreateNewSpace(nameLen + offsetof(struct DBModuleName, name)); DBModuleName dbmn; dbmn.signature = DBMODULENAME_SIGNATURE; @@ -110,7 +110,7 @@ DWORD CDb3Mmap::GetModuleNameOfs(const char *szName) return ofsNew; } -char* CDb3Mmap::GetModuleNameByOfs(DWORD ofs) +char* CDb3Mmap::GetModuleNameByOfs(uint32_t ofs) { if (m_lastmn && m_lastmn->ofs == ofs) return m_lastmn->name; diff --git a/plugins/Db3x_mmap/src/dbsettings.cpp b/plugins/Db3x_mmap/src/dbsettings.cpp index 26c2361b5b..16757fe6c8 100644 --- a/plugins/Db3x_mmap/src/dbsettings.cpp +++ b/plugins/Db3x_mmap/src/dbsettings.cpp @@ -90,19 +90,19 @@ LBL_Seek: return 1; DBCachedContact *cc; - DWORD ofsContact = GetContactOffset(contactID, &cc); + uint32_t ofsContact = GetContactOffset(contactID, &cc); - DWORD ofsModuleName = GetModuleNameOfs(szModule); + uint32_t ofsModuleName = GetModuleNameOfs(szModule); DBContact dbc = *(DBContact*)DBRead(ofsContact, nullptr); if (dbc.signature != DBCONTACT_SIGNATURE) return 1; - DWORD ofsSettingsGroup = GetSettingsGroupOfsByModuleNameOfs(&dbc, ofsModuleName); + uint32_t ofsSettingsGroup = GetSettingsGroupOfsByModuleNameOfs(&dbc, ofsModuleName); if (ofsSettingsGroup) { int bytesRemaining; unsigned varLen; - DWORD ofsBlobPtr = ofsSettingsGroup + offsetof(DBContactSettings, blob); + uint32_t ofsBlobPtr = ofsSettingsGroup + offsetof(DBContactSettings, blob); uint8_t *pBlob = DBRead(ofsBlobPtr, &bytesRemaining); while (pBlob[0]) { NeedBytes(1 + settingNameLen); @@ -223,14 +223,14 @@ STDMETHODIMP_(BOOL) CDb3Mmap::WriteContactSettingWorker(MCONTACT contactID, DBCO { log1(" write database as %s", printVariant(&dbcws.value)); - DWORD settingNameLen = (DWORD)mir_strlen(dbcws.szSetting); - DWORD ofsBlobPtr, ofsContact = GetContactOffset(contactID); + uint32_t settingNameLen = (uint32_t)mir_strlen(dbcws.szSetting); + uint32_t ofsBlobPtr, ofsContact = GetContactOffset(contactID); if (ofsContact == 0) { _ASSERT(false); // contact doesn't exist? return 2; } - DWORD ofsModuleName = GetModuleNameOfs(dbcws.szModule); + uint32_t ofsModuleName = GetModuleNameOfs(dbcws.szModule); DBContact dbc = *(DBContact*)DBRead(ofsContact, nullptr); if (dbc.signature != DBCONTACT_SIGNATURE) return 1; @@ -239,7 +239,7 @@ STDMETHODIMP_(BOOL) CDb3Mmap::WriteContactSettingWorker(MCONTACT contactID, DBCO uint8_t *pBlob; int bytesRequired, bytesRemaining; DBContactSettings dbcs; - DWORD ofsSettingsGroup = GetSettingsGroupOfsByModuleNameOfs(&dbc, ofsModuleName); + uint32_t ofsSettingsGroup = GetSettingsGroupOfsByModuleNameOfs(&dbc, ofsModuleName); if (ofsSettingsGroup == 0) { //module group didn't exist - make it switch (dbcws.value.type) { case DBVT_ASCIIZ: case DBVT_UTF8: @@ -295,7 +295,7 @@ STDMETHODIMP_(BOOL) CDb3Mmap::WriteContactSettingWorker(MCONTACT contactID, DBCO NeedBytes(3); int nameLen = 1 + settingNameLen; int valLen = 1 + GetSettingValueLength(pBlob); - DWORD ofsSettingToCut = ofsBlobPtr - nameLen; + uint32_t ofsSettingToCut = ofsBlobPtr - nameLen; MoveAlong(valLen); NeedBytes(1); while (pBlob[0]) { @@ -350,10 +350,10 @@ STDMETHODIMP_(BOOL) CDb3Mmap::WriteContactSettingWorker(MCONTACT contactID, DBCO bytesRequired += 2 + settingNameLen; bytesRequired += ofsBlobPtr + 1 - (ofsSettingsGroup + offsetof(DBContactSettings, blob)); - if ((DWORD)bytesRequired > dbcs.cbBlob) { + if ((uint32_t)bytesRequired > dbcs.cbBlob) { // doesn't fit: move entire group DBContactSettings *dbcsPrev; - DWORD ofsDbcsPrev, ofsNew; + uint32_t ofsDbcsPrev, ofsNew; InvalidateSettingsGroupOfsCacheEntry(ofsSettingsGroup); bytesRequired += (DB_SETTINGS_RESIZE_GRANULARITY - (bytesRequired % DB_SETTINGS_RESIZE_GRANULARITY)) % DB_SETTINGS_RESIZE_GRANULARITY; @@ -453,19 +453,19 @@ STDMETHODIMP_(BOOL) CDb3Mmap::DeleteContactSetting(MCONTACT contactID, LPCSTR sz mir_cslock lck(m_csDbAccess); char *szCachedSettingName = m_cache->GetCachedSetting(szModule, szSetting, moduleNameLen, settingNameLen); if (szCachedSettingName[-1] == 0) { // it's not a resident variable - DWORD ofsModuleName = GetModuleNameOfs(szModule); - DWORD ofsContact = GetContactOffset(contactID); + uint32_t ofsModuleName = GetModuleNameOfs(szModule); + uint32_t ofsContact = GetContactOffset(contactID); DBContact *dbc = (DBContact*)DBRead(ofsContact, nullptr); if (dbc->signature != DBCONTACT_SIGNATURE) return 1; // make sure the module group exists - DWORD ofsSettingsGroup = GetSettingsGroupOfsByModuleNameOfs(dbc, ofsModuleName); + uint32_t ofsSettingsGroup = GetSettingsGroupOfsByModuleNameOfs(dbc, ofsModuleName); if (ofsSettingsGroup == 0) return 1; // find if the setting exists - DWORD ofsBlobPtr = ofsSettingsGroup + offsetof(DBContactSettings, blob); + uint32_t ofsBlobPtr = ofsSettingsGroup + offsetof(DBContactSettings, blob); int bytesRemaining; uint8_t *pBlob = (uint8_t*)DBRead(ofsBlobPtr, &bytesRemaining); while (pBlob[0]) { @@ -486,7 +486,7 @@ STDMETHODIMP_(BOOL) CDb3Mmap::DeleteContactSetting(MCONTACT contactID, LPCSTR sz NeedBytes(3); int nameLen = 1 + settingNameLen; int valLen = 1 + GetSettingValueLength(pBlob); - DWORD ofsSettingToCut = ofsBlobPtr - nameLen; + uint32_t ofsSettingToCut = ofsBlobPtr - nameLen; MoveAlong(valLen); NeedBytes(1); while (pBlob[0]) { @@ -524,7 +524,7 @@ STDMETHODIMP_(BOOL) CDb3Mmap::EnumContactSettings(MCONTACT contactID, DBSETTINGE mir_cslock lck(m_csDbAccess); - DWORD ofsContact = GetContactOffset(contactID); + uint32_t ofsContact = GetContactOffset(contactID); if (ofsContact == 0) return -1; @@ -532,12 +532,12 @@ STDMETHODIMP_(BOOL) CDb3Mmap::EnumContactSettings(MCONTACT contactID, DBSETTINGE if (dbc->signature != DBCONTACT_SIGNATURE) return -1; - DWORD ofsModuleName = GetModuleNameOfs(szModule); - DWORD ofsSettings = GetSettingsGroupOfsByModuleNameOfs(dbc, ofsModuleName); + uint32_t ofsModuleName = GetModuleNameOfs(szModule); + uint32_t ofsSettings = GetSettingsGroupOfsByModuleNameOfs(dbc, ofsModuleName); if (!ofsSettings) return -1; - DWORD ofsBlobPtr = ofsSettings + offsetof(DBContactSettings, blob); + uint32_t ofsBlobPtr = ofsSettings + offsetof(DBContactSettings, blob); int bytesRemaining; uint8_t *pBlob = (uint8_t*)DBRead(ofsBlobPtr, &bytesRemaining); if (pBlob[0] == 0) -- cgit v1.2.3