VMDump::VMDump(const char *fileName) : Dump(fileName, "rb") { char fmbk_id[8] = {0xc8, 0xc3, 0xd7, 0xc4, 0xc6, 0xd4, 0xc2, 0xd2}; ebcdicAsciiConv = iconv_open("ISO-8859-1", "EBCDIC-US"); /* Record 1: adsrRecord */ dump_seek(fh,0,SEEK_SET); dump_read(&adsrRecord,sizeof(adsrRecord),1,fh); if(debug) { char buf[1024]; int i; dump_seek(fh,adsrRecord.sec3_offset,SEEK_SET); dump_read(buf, adsrRecord.sec3_len,1,fh); ebcAsc(buf,adsrRecord.sec3_len); for(i=0; i < adsrRecord.sec3_len; i++) { if((buf[i]==0) || iscntrl(buf[i])) buf[i]=' '; } buf[adsrRecord.sec3_len]=0; printf("symptom string1: %s\n",buf); } /* Record 2: fmbk */ dump_seek(fh,0x1000,SEEK_SET); dump_read(&fmbkRecord,sizeof(fmbkRecord),1,fh); /* Check if this is a vmdump */ if(memcmp(fmbkRecord.id, fmbk_id, 8) != 0) { throw DumpException("Input file is not a vmdump"); } /* Record 3-7: fir records read by subclasses */ /* Record 8: albk */ dump_seek(fh,(fmbkRecord.rec_nr_access-1)*0x1000 ,SEEK_SET); dump_read(&albkRecord,sizeof(albkRecord),1,fh); }
void VMDump::readMem(char* buf, int size) { int i; if(pageOffset == 0) dump_seek(fh, memoryStartRecord, SEEK_SET); if(size % 0x1000 != 0) { throw(DumpException("internal error: VMDump::readMem() "\ "can only handle sizes which are multiples of page size")); } for(i = 0; i < size; i += 0x1000) { if(testPage(pageOffset)) { dump_read(buf + i, 0x1000,1,fh); } else { memset(buf + i, 0, 0x1000); } pageOffset += 1; } }
void __stdcall ReceivedMsgServer(DWORD dwConnectionIndex,char* pMsg,DWORD dwLength) { EXCEPTION_POINTERS* pException = NULL;//020508 lsw __try //020508 lsw { BYTE bID; bID = (BYTE)pMsg[0]; if (dwConnectionIndex == 0) { #ifdef __ON_DEBUG // _asm int 3; #endif return; } if( bID == (BYTE)PTCL_NOTIFY_SERVER_UP ) { if( g_pServerTable->OnRecvServerUpMsg(dwConnectionIndex, *(WORD*)(pMsg+1)) ) { #ifdef __ON_DEBUG // _asm int 3; #endif } return; } LP_SERVER_DATA pSender = g_pServerTable->GetConnectedServerData( dwConnectionIndex ); if( !pSender ) return; switch (bID) { // ------------- // 기본패킷 // ------------- // 전용 case PTCL_ORDER_SET_SERVER_LIST: case PTCL_ORDER_CONNECT_TO_SERVERS: case PTCL_ORDER_SET_DB_DEMON: case PTCL_ORDER_TO_REPORT_SERVER_DATAS: case PTCL_NOTIFY_YOU_ARE_CERTIFIED: //공통 case PTCL_ORDER_DESTROY_SERVER: case PTCL_NOTIFY_SERVER_STATUS: case PTCL_SERVER_TRY_TO_CHECK_CONNECTION: case PTCL_SERVER_CONNECTION_OK: case PTCL_ORDER_TO_REPORT_SERVER_STATUS: { if( !g_pServerTable->OnRecvNegotiationMsgs( pSender, bID, pMsg+1, dwLength-1 ) ) { MyLog( LOG_FATAL, "OnRecvNegotiationMsg() Failed :: (pSender(%d), bId(%d), MsgLength(%d))", pSender->wPort, bID, dwLength ); #ifdef __ON_DEBUG // _asm int 3; #endif } } break; case PTCL_AGENT_TO_DB_REMOVE_USER_FROM_LOGIN_TABLE: { char id[20]; memset(id,0,20); memcpy(id,pMsg+4+1,20); if(LocalMgr.IsAbleNation(TAIWAN|CHINA|HONGKONG))//021007 lsw { //2001/02/24 zhh if(dwLength>1+4+ID_LENGTH+2+15) { char in[15],out[15]; memset(in,0,15); memset(out,0,15); memcpy(out,pMsg+1+4+ID_LENGTH+2, 15); memcpy(in ,pMsg+1+4+ID_LENGTH+2+15, 15); //2001/08/30 zhh char IP[20]={0,}; memcpy(IP ,pMsg+1+4+ID_LENGTH+2+15+15, 20); //2001/02/19 zhh for(int i=0;i<14;i++) { if(out[i]==' ') out[i]='0'; if( in[i]==' ') in[i]='0'; } // acer5 if(ConQ && out[0]!=0 && in[0]!=0) ConQ->AskCheckLogoutWithIP(id,in,out,IP); } } //001218 zhh int ret = onepass.DeleteUsedID_SQL_ForPay(NULL,id,0); if( ret != 1 ) { MyLog( LOG_NORMAL, "<zoung>%d %s close ret = %d(1 = success)", dwConnectionIndex, id, ret); } } break; case PTCL_AGENT_TO_DB_REQUEST_REMOVE_USER: { ClearUserCN(dwConnectionIndex,pMsg,dwLength); } break; case PTCL_AGENT_TO_DB: case PTCL_MAP_TO_DB: { DWORD dwUniqID; t_packet raja_packet; memset(&raja_packet,0,sizeof(t_packet)); memcpy(&dwUniqID, pMsg+1, 4); memcpy(raja_packet.h.data, pMsg+1+4, HEADER_SIZE); memcpy(raja_packet.u.data, pMsg+1+4+HEADER_SIZE, raja_packet.h.header.size); DWORD cn = GetUserCN( pSender, dwUniqID, raja_packet.h.header.type ); //if( cn == -1 ) break; /////////////////////////////////////////////////////////////////////////// connections[cn].dwUserID = dwUniqID; connections[cn].dwConIndex = dwConnectionIndex; //sprintf(txt,"cn: %d USERID %d Index %d",cn, dwUniqID,dwConnectionIndex); //WriteText(txt); HandleCommand( connections, dwConnectionIndex, &raja_packet ,dwUniqID,cn ); } break; // Added by chan78 at 2000/12/17 case PTCL_ORDER_TO_CLEAR_PAY_TABLE: { onepass.DeleteUsedID_SQL_ForPay(NULL," ", (int)*(WORD*)(pMsg+1)); } break; // Added by chan78 at 2001/03/16 // ----------------------------- case PTCL_MANAGER_QUERY: { if( !OnRecvMsgFromManager( (LP_MANAGER_PACKET)pMsg, dwLength ) ) { MyLog( LOG_FATAL, "PTCL_MANAGER_ANSWER :: OnRecvMsgFromManager() has return false(%d)", pSender->wPort ); break; } } break; // Added by chan78 at 2001/03/16 case PTCL_MANAGER_ANSWER: { // 있을 수 없다. MyLog( LOG_FATAL, "PTCL_MANAGER_ANSWER :: has received!!!(%d)", pSender->wPort ); g_pServerTable->DestroyServer( FINISH_TYPE_UNKNOWN_ERROR); } break; // ----------------------------- // Added by KBS 011012 case PTCL_RM_FROM_PROXY: { RMProc(dwConnectionIndex, pMsg, dwLength); } break; // default: { MyLog( LOG_FATAL, "Unknown bID(%d) Received. From %s(wPort:%d) Size(%d) ConnectionID(%d)", bID, GetTypedServerText(pSender->dwServerType), pSender->wPort, dwLength, dwConnectionIndex); #ifdef __ON_DEBUG // _asm int 3; #endif } break; } } __except(pException = GetExceptionInformation())//020508 lsw { //acer7 DumpException( pException, "Exception Raised on HadleCommand()", pMsg, dwLength ); ProcessEnd(FINISH_TYPE_UNKNOWN_ERROR); }
Dump::DumpType VMDump::getDumpType(const char* inputFileName) { FILE* fh; struct _fmbk fmbk; struct _fir_basic fir; char fmbk_id[8] = {0xc8, 0xc3, 0xd7, 0xc4, 0xc6, 0xd4, 0xc2, 0xd2}; char msg[200]; fh = fopen(inputFileName,"r"); if(!fh) { sprintf(msg,"Could not open '%s'",inputFileName); throw DumpErrnoException(msg); } /* Record 2: fmbk */ dump_seek(fh,0x1000,SEEK_SET); if(fread(&fmbk,sizeof(fmbk),1,fh) != 1) { if(ferror(fh)) { sprintf(msg,"Could not read header of vmdump '%s'", inputFileName); fclose(fh); throw DumpErrnoException(msg); } else{ sprintf(msg,"Input file '%s' is not a vmdump", inputFileName); fclose(fh); throw DumpException(msg); } } /* Check if this is a vmdump */ if(memcmp(fmbk.id, fmbk_id, 8) != 0) { fclose(fh); sprintf(msg,"Input file '%s' is not a vmdump",inputFileName); throw DumpException(msg); } /* Record 3-7: fir */ dump_seek(fh,(fmbk.rec_nr_fir-1)* 0x1000,SEEK_SET); if(fread(&fir,sizeof(fir),1,fh) != 1) { if(ferror(fh)) { sprintf(msg,"Could not read header of vmdump '%s'", inputFileName); fclose(fh); throw DumpErrnoException(msg); } else{ sprintf(msg,"Could not read header of vmdump '%s'", inputFileName); fclose(fh); throw DumpException(msg); } } fclose(fh); if(fir.fir_format == 0) { return DT_VM32; } else if(fir.fir_format == 0x02) {/*XXX && (fir.dump_format == 0x1))*/ return DT_VM64_BIG; } else if(fir.fir_format == 0x82) { return DT_VM64; } else { return DT_UNKNOWN; } }