memblast.c
来自「高级网络通信编程实串口通信编程实例网络流量监控网站下载网络五子棋系统语音聊天远程」· C语言 代码 · 共 42 行
C
42 行
#include "memblast.h"
//#include "Server.h"
//#include "HuffCompress.h"
#include <windows.h>
// Copy memory range from one location to another
__inline void memblast(void* dest,void* src,DWORD count)
{
DWORD iCount;
__asm
{
// Align Count to a DWORD Boundary
MOV ECX,count
SHR ECX,2
SHL ECX,2
MOV iCount,ECX
// Copy All the DWORDs (32 bits at a Time)
MOV ESI,src // Copy the Source Address to the Register
MOV EDI,dest // Copy the Destination to the Register
MOV ECX,iCount // Copy the Count to the Register
SHR ECX,2 // Divide Count by 4 for DWORD Copy
REP MOVSD // Move all the Source DWORDs to the Dest DWORDs
// Get the Remaining Bytes to Copy
MOV ECX,count
MOV EAX,iCount
SUB ECX,EAX
// Exit if All Bytes Copied
JZ Exit
// Copy the Remaining BYTEs (8 bits at a Time)
MOV ESI,src // Copy the Source Address to the Register
ADD ESI,EAX // Set the Starting Point of the Copy
MOV EDI,dest // Copy the Destination to the Register
ADD EDI,EAX // Set the Destination Point of the Copy
REP MOVSB // Move all the Source BYTEs to the Dest BYTEs
Exit:
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?