|
|
|
[求助]数据对齐的问题!百思不解
class A { public: char a; char b; int* p; }; 但是这样一个类的大小还是8,难道是虚继承改变了什么规则? 求教于达人,谢谢! |
|
[求助]虚拟继承时如何从基类到派生类进行指针转换?
谢谢楼上的回答 在虚拟继承下,我加上(void*)可以正常编译,但运行出错啊。我想是不是因为在虚拟继承下,牵涉到编译器给对象的内存块加入了指针的原因啊? 你也是VC6吗? |
|
[求助]虚拟继承时如何从基类到派生类进行指针转换?
难道问题太小白,都没人理?= = |
|
[求助]一个关于API HOOK的问题,请大家解释一下我心中的疑惑?
记得是有影响,而且由于WINDOWS是抢占式的系统,不太推荐这样做,因为搞不好就影响别的进程了 |
|
|
|
[求助]关于SOCKET发送文件大小不一的问题[已经附上源码]
有人指教下吗? |
|
[求助]关于SOCKET发送文件大小不一的问题[已经附上源码]
厄。。。这样不对啊 根据接收方的代码 先发送整数10,那么接收方申请缓冲区10字节,后面再发送的6个字节就被填入该缓冲区内(不足的补0)。 再发送4字节,刚好又是一个int类型的长度,但是由于字串都是"0000000000",所以接收方不会申请缓冲区的…… 算了,干脆附上源码 |
|
[求助]关于SOCKET发送文件大小不一的问题[已经附上源码]
我懂您的意思,我就是为了避免这种情况,专门把要发送的文件自己分了包。每个包的大小都是1024个字节(当然最后一个包可能不够这个数目),然后再循环地一个个发送出去。(详细可见我红色部分的代码) 但是这样做不出问题的前提是:系统不会再对1024字节大小的包进行再分包,如果再分的话,立刻就会出现您说的问题。 目前这个代码,对大多数文件的传输没啥问题,但是小部分文件还是会出现错误,原因不明。 |
|
[求助]关于SOCKET发送文件大小不一的问题[已经附上源码]
接收的代码: void CMySocket::OnReceive(int nErrorCode) { CMyServerXDlg* pDlg=(CMyServerXDlg*)AfxGetApp()->GetMainWnd(); pDlg->m_edit1.SetWindowText("开始接收客户端信息……"); int byteNum=0; Receive(&byteNum,sizeof(int),0); BYTE* buffer=new BYTE[byteNum]; memset(buffer,0,byteNum); Receive(buffer,byteNum,0); myFile.WriteHuge(buffer,byteNum); delete []buffer; if(byteNum==1) { myFile.Close(); pDlg->m_edit1.SetWindowText("信息接收完毕!"); } CSocket::OnReceive(nErrorCode); } |
|
[求助]关于SOCKET发送文件大小不一的问题[已经附上源码]
这个是发送的代码: void CMyServerXDlg::OnButton2() { if(m_bConnected) { CFileDialog dlg( true, "", "", OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT, "所有文件(*.*)|*.*||", NULL); int structsize=0; DWORD dwVersion=::GetVersion(); DWORD dwWindowMajorVersion, dwWindowMinorVersion; dwWindowMajorVersion=(DWORD)(LOBYTE(LOWORD(dwVersion))); dwWindowMinorVersion=(DWORD)(HIBYTE(LOWORD(dwVersion))); if(dwVersion<0x80000000) structsize=88; else structsize=76; dlg.m_ofn.lStructSize=structsize; dlg.m_ofn.Flags=dlg.m_ofn.Flags|OFN_SHOWHELP|OFN_LONGNAMES; CString FilePathName; if(dlg.DoModal()==IDOK) { FilePathName=dlg.GetPathName(); CFile myFile; myFile.Open((LPTSTR)(LPCTSTR)FilePathName,CFile::modeRead|CFile::typeBinary,NULL); int len=myFile.GetLength(); for(int i=0;i<len;i+=1024) { if(i+1024>len) { int byteNum=len-i; if(byteNum==1) { socket.Send(&byteNum,sizeof(int),0); BYTE* buffer=new BYTE[byteNum]; memset(buffer,0,byteNum); myFile.ReadHuge(buffer,byteNum); socket.Send(buffer,byteNum,0); delete []buffer; break; } else if(byteNum>1) { int byteNumX=byteNum-1; socket.Send(&byteNumX,sizeof(int),0); BYTE* buffer=new BYTE[byteNumX]; memset(buffer,0,byteNumX); myFile.ReadHuge(buffer,byteNumX); socket.Send(buffer,byteNumX,0); delete []buffer; byteNumX=1; socket.Send(&byteNumX,sizeof(int),0); buffer=new BYTE[byteNumX]; memset(buffer,0,byteNumX); myFile.ReadHuge(buffer,byteNumX); socket.Send(buffer,byteNumX,0); delete []buffer; break; } else AfxMessageBox("传输发生错误!",MB_OK); } else if(i+1024<=len) { const int byteNum=1024; socket.Send(&byteNum,sizeof(int),0); BYTE* buffer=new BYTE[1024]; memset(buffer,0,1024); myFile.ReadHuge(buffer,1024); socket.Send(buffer,1024,0); delete []buffer; } else AfxMessageBox("传输发生错误!",MB_OK); } myFile.Close(); } else return; } else AfxMessageBox("服务器尚未连接!",MB_OK); } |
|
[求助]看《Windows核心编程》有地方不明白请大虾指教
我是这样想的,基本和您的观点一样。 可写页面,根据橙色部分的话,其物理内存在页文件里。现在要改写,根据COPY-ON-WRITE机制,系统会新分配一个页面出来,把老的数据COPY过去。 1) 系统查找R A M中的一个空闲内存页面。注意,当该模块初次被映射到进程的地址空间时,该空闲页面将被页文件中已分配的页面之一所映射。当该模块初次被映射时,由于系统要分配所有可能需要的页文件,因此这一步不可能运行失败。 参照红色部分的话,这个新页面是在RAM中查找的,而且还说这个新页面一定是存在的。 “该空闲页面将被页文件中已分配的页面之一所映射” 这句话到底什么意思呢? |
|
[求助]看《Windows核心编程》有地方不明白请大虾指教
那这样的话,橙色部分怎么理解了呢? 当一个. e x e或D L L模块被映射到一个内存地址时,系统将计算有多少页面是可以写入的(通常包含代码的页面标为PA G E _ E X E C U T E _ R E A D,而包含数据的页面则标为PA G E _ R E A D W R I T E)。然后,系统从页文件中分配内存,以适应这些可写入的页面的需要。 感觉从这句话来理解的话,模块被映射的时候,其内部被分成了可以写入的、不可以写入的两个部分。可以写入的部分所对应的物理内存在页文件中,不可以写入的部分所对应的物理内存在哪里没说(不过我想除了页文件,只有RAM了啊) 映射应该确实是反映的您说的一种对应关系,但是应该是地址空间与RAM或者页文件的对应关系吧。 |
|
[求助]求助~Hook ExitProcess为什么我的新函数沒有调用?WriteProcessMemory成功
更正一下 这2天仔细对比了一下代码 发现应该是 WriteProcessMemory( hCurr, &(ptd->u1.Function), &pfnNew, sizeof(pfnNew), NULL); 是我自己搞错了 |
|
[求助]求助~Hook ExitProcess为什么我的新函数沒有调用?WriteProcessMemory成功
好了 结论是不要用WriteProcessMemory 换了个函数 和《Windows核心编程》不一样啊 |
操作理由
RANk
{{ user_info.golds == '' ? 0 : user_info.golds }}
雪币
{{ experience }}
课程经验
{{ score }}
学习收益
{{study_duration_fmt}}
学习时长
基本信息
荣誉称号:
{{ honorary_title }}
能力排名:
No.{{ rank_num }}
等 级:
LV{{ rank_lv-100 }}
活跃值:
在线值:
浏览人数:{{ visits }}
最近活跃:{{ last_active_time }}
注册时间:{{ user_info.create_date_jsonfmt }}
勋章
兑换勋章
证书
证书查询 >
能力值