/////////////////////////////////////////////////////////////////////////////// // RemoveItem /////////////////////////////////////////////////////////////////////////////// void cBlockRecordFile::RemoveItem( cBlockRecordFile::tAddr dataAddr ) //throw (eArchive) { ASSERT( mbOpen ); ASSERT( IsValidAddr( dataAddr ) ); #ifdef _BLOCKFILE_DEBUG AssertValid(); #endif mvBlocks[ dataAddr.mBlockNum ].DeleteItem( dataAddr.mIndex ); // // remove unneeded blocks at the end... // //TODO -- not implemented yet! /* while( mvBlocks.back().GetNumItems() == 0 ) { // if there are >2 blocks, and the back two blocks are both // empty, remove one. We always want to be sure there is at // least one block in the database, and we don't want to remove // single trailing empty blocks because it would perform poorly if // there were a bunch of additions and removals at the end of the file. if( (mvBlocks.size() > 2) && (mvBlocks[ mvBlocks.size()-2 ].GetNumItems() == 0 ) { // TODO -- uncomment these to implement file shrinking... mvBlocks.pop_back(); mBlockFile.DestroyLastBlock(); } } */ }
/////////////////////////////////////////////////////////////////////////////// // GetDataForWriting /////////////////////////////////////////////////////////////////////////////// int8* cBlockRecordFile::GetDataForWriting( cBlockRecordFile::tAddr dataAddr, int32& dataSize ) //throw (eArchive) { ASSERT( mbOpen ); ASSERT( IsValidAddr( dataAddr ) ); #ifdef _BLOCKFILE_DEBUG AssertValid(); #endif return ( mvBlocks[ dataAddr.mBlockNum ].GetDataForWriting( dataAddr.mIndex, dataSize ) ); }
void Debugger::ActivateBreakpoints() { int b, no; BP_ENTRY *bep; no = 4; // disable hardware breakpoints. edi.dr[7] = 0; // First handle data breakpoints. for(b=0, bep=breakpoint_table; b < breakpoint_count; b++, bep++) if(!bep->disabled && no <= 3 && bep->type != BP_Code) { bep->saved = 0; edi.dr[7] |= ((bep->type + ((bep->length-1) << 2)) << (16+4*no) | (2 << (2*no))); edi.dr[no] = bep->addr; no++; } // Now handle code breakpoints. for(b=0, bep=breakpoint_table; b < breakpoint_count; b++, bep++) if (!bep->disabled && bep->type == BP_Code) { if (no <= 3) { bep->saved = 0; edi.dr[7] |= ((BP_Code << (16+4*no)) | (2 << (2*no))); edi.dr[no] = bep->addr; no++; edi.dr[7] |= 0x00000300L; // For 386s we set GE & LE bits. } else { bep->saved = IsValidAddr(bep->addr, 1); if(bep->saved) { read_child(bep->addr, &bep->savedbyte, 1); write_child(bep->addr, (void *)&int03, 1); } } } }
//---------------------------------------------------------------- // CImpIRestrictedProcess::RP_WSPConnect() // //---------------------------------------------------------------- STDMETHODIMP CImpIRestrictedProcess::RP_WSPConnect( IN RPC_SOCKADDR_IN *pInAddr, IN long lAddrLen, IN RPC_WSABUF *pCallerData, OUT RPC_WSABUF *pCalleeData, IN RPC_QOS *pSQOS, IN RPC_QOS *pGQOS, IN DWORD dwTargetPid, OUT DWORD *pTargetSocket, OUT long *pError ) { int iRet; HRESULT hr; BOOL fInherit; DWORD dwSourcePid; DWORD dwAccess; DWORD dwOptions; NTSTATUS NtStatus; HANDLE hSourceProcess; HANDLE hSourceHandle; HANDLE hTargetProcess; *pError = NO_ERROR; dwSourcePid = GetCurrentProcessId(); if (!dwSourcePid) { *pError = GetLastError(); return NOERROR; } if (m_Socket == INVALID_SOCKET) { *pError = WSAEACCES; closesocket(m_Socket); m_Socket = INVALID_SOCKET; return NOERROR; } // // Check to make sure the restricted client is connecting only // to a server that we allow. // hr = IsValidAddr( (char*)&(pInAddr->sin_addr), sizeof(ULONG) ); #ifdef DBG_ALWAYS_RESTRICTED DbgPrint("RP_WSPConnect(): IsValidAdder(): %s\n", (hr == S_OK)? "TRUE" : "FALSE" ); hr = S_OK; #endif if (S_OK != hr) { *pError = WSAEACCES; closesocket(m_Socket); m_Socket = INVALID_SOCKET; return NOERROR; } // Ok, do the connect() on behalf of the restricted client iRet = WSAConnect( m_Socket, (struct sockaddr *)pInAddr, lAddrLen, (WSABUF*)pCallerData, (WSABUF*)pCalleeData, (QOS*)pSQOS, (QOS*)pGQOS ); if (iRet == SOCKET_ERROR) { *pError = WSAGetLastError(); closesocket(m_Socket); m_Socket = INVALID_SOCKET; return NOERROR; } // Get a handle to our own process (to be used by DuplicateHandle()). hSourceProcess = OpenProcess( PROCESS_DUP_HANDLE, TRUE, dwSourcePid ); if (!hSourceProcess) { *pError = GetLastError(); closesocket(m_Socket); m_Socket = INVALID_SOCKET; return NOERROR; } // Get a handle to the restricted process hTargetProcess = OpenProcess( PROCESS_DUP_HANDLE, TRUE, dwTargetPid ); if (!hTargetProcess) { *pError = GetLastError(); closesocket(m_Socket); m_Socket = INVALID_SOCKET; CloseHandle(hSourceProcess); return NOERROR; } // Ok, duplicate the socket into the restricted client. dwAccess = 0; fInherit = FALSE; dwOptions = DUPLICATE_SAME_ACCESS; if (!DuplicateHandle(hSourceProcess, (HANDLE)m_Socket, hTargetProcess, (HANDLE*)pTargetSocket, dwAccess, fInherit, dwOptions )) { *pError = GetLastError(); } // No longer need a local copy of the open socket. closesocket(m_Socket); m_Socket = INVALID_SOCKET; // Done with the process handles. CloseHandle(hSourceProcess); CloseHandle(hTargetProcess); return NOERROR; }