当前位置: 首页 > news >正文

实时数据库测试-汇编小程序

实时数据库测试-汇编小程序。

hd.asm

.686
.model flat,stdcall
option casemap:none
include         \masm32\include\windows.inc
include         \masm32\include\kernel32.inc
include         \masm32\include\user32.inc
include         \masm32\include\gdi32.inc
include         \masm32\include\advapi32.inc
include         \masm32\include\wsock32.inc
includelib      \masm32\lib\ws2_32.lib
includelib      \masm32\lib\kernel32.lib
includelib      \masm32\lib\user32.lib
includelib      \masm32\lib\gdi32.lib
includelib      \masm32\lib\advapi32.libUSERNAME_PASSWORD_LEN                           =16
USER_INFO_LEN                                   =34
USER_NAME_LEN                                   =16
USER_PASSWORD_LEN                               =16
UDP_PORT                                        =3308
THREAD_CPU_RATIO                                =4
BUF_MULTI_RATIO                                 =2
MAX_RECORD_SUM                                  =10000h
FILE_POINTDIR_SIZE                              =200000h
FILE_USERINFO_SIZE                              =100000H
ENCRYPTION_KEY                                  =0FFH
UDP_PACKAGE_SIZE                                =512
UDP_PACKAGE_HEADER_SIZE                         =16
RECORDING_INDEX_SIZE                            =32
SMALLEST_SAMPLE_PERIOD                          =20
BOOL_PACK_FLAG                                  =2
FLOAT_PACK_FLAG                                 =1
INVALID_POINT_VALUE                             =0ffffffffh_DLG_CLIENT_SHOWVALUE                           =1000h
_LIST_CLIENT_SHOWVALUE                          =1001h.data
align                                           qword
_stSystemInfo                                   SYSTEM_INFO             <>
_stCriticalUserInfo                             CRITICAL_SECTION        <>
_stCriticalPointDir                             CRITICAL_SECTION        <>
_stCriticalReadData                             CRITICAL_SECTION        <>
_stCriticalRealTime                             CRITICAL_SECTION        <>
_stCriticalMemToFile                            CRITICAL_SECTION        <>
_stCriticalDcsToMem                             CRITICAL_SECTION        <>
_stCriticalTransInfo                            CRITICAL_SECTION        <>      ;读文件记录时多线程传递参数_stRecvAddr                                     sockaddr_in             <> szDataBaseFileName                              db 'DataBase.dat',0
szIndexFileName                                 db 'DataBase.idx',0
szPointDirFileName                              db 'PointDir.txt',0
szUserInfoFileName                              db 'UserInfo.txt',0
szJournalFileName                               db 'Journal.txt',0szReadMainError                                 db 'Read Main Error!',0dh,0ah,0
szLaunchReadError                               db 'Launch Read Error!',0dh,0ah,0szClientShowValue                               db '%04d年%02d月%02d日%02d时%02d分%02d秒:%08d',0dh,0ah,0
szInit                                          db ' ',0dh,0ahdb ' ',0dh,0ahdb ' ',0dh,0ahdb '****************************************',0dh,0ahdb '%s数据库开始启动',0dh,0ahdb '****************************************',0dh,0ah,0
szThreadError                                   db '(ERROR)创建线程失败!',0dh,0ah,0
szEventError                                    db '(ERROR)创建事件失败!',0dh,0ah,0
szMemAllocError                                 db '(ERROR)分配内存失败!',0dh,0ah,0
szInputError                                    db '(ERROR)读文件参数错误!',0dh,0ah,0
szSetPriorityClassError                         db '(ERROR)优先级设置错误!',0dh,0ah,0
szFileMapError                                  db '(ERROR)创建文件内存映射失败!',0dh,0ah,0
szFileNoConfig                                  db '(ERROR)未发现配置文件,初始化失败!',0dh,0ah,0szAdminLogon                                    db 'admin',11 dup (20h),'123456',10 dup (20h),0dh,0ah
szDcsSampleCnt                                  db '检索到的数据记录点数量:%d',0dh,0ah,0
szCreateIndex                                   db '新建索引文件!',0dh,0ah,0
szOpenIndex                                     db '成功打开索引文件!',0dh,0ah,0
szCreateDataBase                                db '新建数据库文件!',0dh,0ah,0
szOpenDataBase                                  db '成功打开数据库文件!',0dh,0ah,0
szCreateJournal                                 db '新建日志文件!',0dh,0ah,0
szOpenJournal                                   db '成功打开日志文件!',0dh,0ah,0
szCreatePointDir                                db '新建点目录文件!',0dh,0ah,0
szOpenPointDir                                  db '成功打开点目录文件!',0dh,0ah,0
szCreateUserInfo                                db '新建用户信息文件',0dh,0ah,0
szOpenUserInfo                                  db '成功打开用户信息文件',0dh,0ah,0
szQuit                                          db '所有线程已退出,数据库即将关闭!',0dh,0ah,0
szSystemTime                                    db '%04d年%02d月%02d日%02d时%02d分%02d秒',0
szPointInsert                                   db '%s在点:%s前成功插入点:%s!',0dh,0ah,0
szPointAdd                                      db '%s成功添加点:%s!',0dh,0ah,0
szPointDelete                                   db '%s成功删除点:%s!',0dh,0ah,0
szPointModify                                   db '%s成功将点:%s修改为点:%s!',0dh,0ah,0
szPointSeek                                     db '%s成功查询点:%s!',0dh,0ah,0
szGetPointTable                                 db '%s成功读取点目录文件!',0dh,0ah,0
szJournalWrite                                  db '%s写入第%d%d条记录,总共耗时%d%d微秒 'db '包括内存缓冲区在内的总记录数为%d%d条',0dh,0ah,0
szJournalPack                                   db '%s为止共计收到%d%d个UDP数据包,共计解包%d%d个UDP个',0dh,0ah,0
szJournalSeek                                   db '%s二分查找次数:%d,查找记录号计时:%d微秒!',0dh,0ah,0
szJournalRead                                   db '%s读出第%d%d条----%d%d条记录,总共读出%d条记录,计时:%d微秒!',0dh,0ah,0
szModifyValue                                   db '%s修改从%d%d条开始的%d条记录!',0dh,0ah,0
szEncryptPointDir                               db '%s点目录文件关闭时已经正确加密!',0dh,0ah,0
szDecryptPointDir                               db '%s点目录文件打开时已经正确解密!',0dh,0ah,0
szEncryptUserInfo                               db '%s用户信息文件关闭时已经正确加密!',0dh,0ah,0
szDecryptUserInfo                               db '%s用户信息文件打开时已经正确解密!',0dh,0ah,0
szSeekUserInfo                                  db '%s查询用户信息:%s!',0dh,0ah,0
szAddUserInfo                                   db '%s增加用户信息:%s!',0dh,0ah,0
szDeleteUserInfo                                db '%s删除用户信息:%s!',0dh,0ah,0
szSocketError                                   db '%s网络初始化错误!',0dh,0ah,0
szRecvUdpPackError                              db '%sUDP数据包传送中出现错误,是否因为程序已退出?',0dh,0ah,0   
szRecordingWriteError                           db '%s写入记录过程中发生错误,错误码为:%d',0dh,0ah,0
szUdpUnpackQuit                                 db 'UdpUnpack terminate!',0dh,0ah,0
szRecvUdpPackQuit                               db 'RecvUdp terminate!',0dh,0ah,0
szStoreRecordingQuit                            db 'StoreRecord terminate!',0dh,0ah,0
szWaitSamplePeriodQuit                          db 'WaitPeriod terminate!',0dh,0ah,0
szMsgException                                  db '%s程序发生严重异常,异常地址:%08x,异常错误码:%08x,异常标志位:%08x!',0dh,0ah,0
szGuardPageViolation                            db '%s缓冲区即将溢出,请迅速找到解决方法-->'db '异常地址:%08x,异常错误码:%08x,异常标志位:%08x!',0dh,0ah,0 
szExceptionReadWriteBusy                        db '数据读写繁忙,备用缓冲区已经准备好,异常处理完毕!',0dh,0ah,0
szExceptionReadWriteNotBusy                     db '上一次异常处理正确完成,备用缓冲区已经成功关闭!',0dh,0ah,0 
szExceptionMemUnroll                            db '注意:缓冲区地址空间已经不够,指针将回绕,缓冲区数据将会因为被覆盖而丢失',0dh,0ah,0                          szDllEntry                                      db 'DllEntry函数加载地址为:                     %08x',0dh,0ah,0
szProcTerminate                                 db '_ProcTerminate函数加载地址为:               %08x',0dh,0ah,0
szProcInit                                      db '_ProcInit函数加载地址为:                    %08x',0dh,0ah,0   
szProcOpenFile                                  db '_ProcOpenFile函数加载地址为:                %08x',0dh,0ah,0 
szProcModifyData                                db '_ProcModifyData函数加载地址为:              %08x',0dh,0ah,0
szProcReadData                                  db '_ProcReadData函数加载地址为:                %08x',0dh,0ah,0
szProcReadInterval                              db '_ProcReadInterval函数加载地址为:            %08x',0dh,0ah,0
szThreadReadData                                db '_ThreadReadData线程加载地址为:              %08x',0dh,0ah,0     
szThreadSeekIndex                               db '_ThreadSeekIndex线程加载地址为:             %08x',0dh,0ah,0
szProcOverlappedRead                            db '_ProcOverlappedRead函数加载地址为:          %08x',0dh,0ah,0
szThreadReadSector                              db '_ThreadReadSector线程加载地址为:            %08x',0dh,0ah,0
szThreadWaitSamplePeriod                        db '_ThreadWaitSamplePeriod线程加载地址为:      %08x',0dh,0ah,0
szThreadRecvUdpPack                             db '_ThreadRecvUdpPack线程加载地址为:           %08x',0dh,0ah,0
szThreadUdpUnpack                               db '_ThreadUdpUnpack线程加载地址为:             %08x',0dh,0ah,0
szProcExceptionGuard                            db '_ProcExceptionGuard函数加载地址为:          %08x',0dh,0ah,0
szThreadStoreRecording                          db '_ThreadStoreRecording线程加载地址为:        %08x',0dh,0ah,0
szThreadJournalOfWriteInfo                      db '_ThreadJournalOfWriteInfo线程加载地址为:    %08x',0dh,0ah,0 
szThreadRealTimeData                            db '_ThreadRealTimeData线程加载地址为:          %08x',0dh,0ah,0
szProcRegistryInfo                              db '_ProcRegistryInfo函数加载地址为:            %08x',0dh,0ah,0
szProcGetRealTimeData                           db '_ProcGetRealTimeData函数加载地址为:         %08x',0dh,0ah,0   
szProcInsertPoint                               db '_ProcInsertPoint函数加载地址为:             %08x',0dh,0ah,0
szProcAddPoint                                  db '_ProcAddPoint函数地加载址为:                %08x',0dh,0ah,0
szProcDeletePoint                               db '_ProcDeletePoint函数加载地址为:             %08x',0dh,0ah,0
szProcModifyPoint                               db '_ProcModifyPoint函数加载地址为:             %08x',0dh,0ah,0         
szProcSeekPoint                                 db '_ProcSeekPoint函数加载地址为:               %08x',0dh,0ah,0
szProcGetPointTable                             db '_ProcGetPointTable函数加载地址为:           %08x',0dh,0ah,0
szProcSeekUser                                  db '_ProcSeekUser函数加载地址为:                %08x',0dh,0ah,0
szProcAddUser                                   db '_ProcAddUser函数加载地址为:                 %08x',0dh,0ah,0
szProcDeleteUser                                db '_ProcDeleteUser函数加载地址为:              %08x',0dh,0ah,0align                           qword
_dqRecvPackCnt                  dq 0
_dqUnPackCnt                    dq 0
_dqRecordingCntSum              dq 0
_dqFileTotalRecording           dq 0
_hSockRecv                      dd 0
_dwSamplePeriod                 dd 200 
_dwStoreRecordingPeriod         dd 16000 _dwDcsSampleCnt                 dd 0
_dwFreeRecordCnt                dd 0
_dwDataRecordingSize            dd 0_lpUdpPackRecvBuf               dd 0
_lpUdpPackRecvBufHead           dd 0
_lpUdpPackRecvBufEnd            dd 0
_lpUdpPackRecvBufLimit          dd 0
_dwUdpPackRecvBufSize           dd 0_lpUdpPackAddrBuf               dd 0
_lpUdpPackAddrBufHead           dd 0
_lpUdpPackAddrBufEnd            dd 0
_lpUdpPackAddrBufLimit          dd 0
_dwUdpPackAddrBufSize           dd 0_dwRecordingCntOfBuf            dd 0
_dwRecordingLimitOfBuf          dd 0_lpRecordingBuf                 dd 0
_lpRecordingBufHead             dd 0
_lpRecordingBufEnd              dd 0
_lpRecordingBufLimit            dd 0
_dwRecordingBufSize             dd 0
_dwRecordingBackupBufSize       dd 0_lpRecordReservedBuf            dd 0
_lpRecordReservedBufHead        dd 0
_lpRecordReservedBufLimit       dd 0
_lpIndexReservedBuf             dd 0
_lpIndexReservedBufHead         dd 0
_lpIndexReservedBufLimit        dd 0_lpRecordingIndexBuf            dd 0
_lpRecordingIndexBufHead        dd 0
_lpRecordingIndexBufEnd         dd 0
_lpRecordingIndexBufLimit       dd 0  
_dwRecordingIndexBufSize        dd 0
_dwIndexBackupBufSize           dd 0_lpPointDirBuf                  dd 0
_dwPointDirBufSize              dd 0
_lpUserInfoBuf                  dd 0
_dwUserInfoBufSize              dd 0_lpReadQueueInfoBuf             dd 0
_dwReadQueueInfoBufSize         dd 0
_dwRltDataTableBufSize          dd 0
_lpRltDataTableBuf              dd 0_hFileDataBase                  dd 0
_hFileIndex                     dd 0
_hFilePointDir                  dd 0
_hFileJournal                   dd 0
_hFileUserInfo                  dd 0
_hFileMappingUserInfo           dd 0
_hFileMapPointDir               dd 0_hThreadWaitSamplePeriod        dd 0
_hThreadRecvUdpPack             dd 0
_hThreadUdpUnpack               dd 0
_hThreadStoreRecording          dd 0
_hThreadRealTimeData            dd 0_lpRealTimeDataBuf              dd 0_hEventRealTimeData             dd 0
_hEventStoreRecording           dd 0_hDllInstance                   dd 0
_hThisProcess                   dd 0_dwSecsPerClu                   dd 0
_dwBytesPerSec                  dd 0
_dwFreeCluCnt                   dd 0
_dwCluCnt                       dd 0_flWriteBusying                 dd 0
_flReadWriteBusy                dd 0
_flMemoryNotEnough              dd 0
_flTerminate                    dd 0
_dwRunningThreadCnt             dd 0
_lpOldExceptionFilter           dd 0_hDlgShowValue                  dd 0szOpenScmError                          db 'scm error',0
szOpenServiceError                      db 'open Service error',0
szRegistryServiceError                  db 'Registry error',0
szDispatcherServiceError                db 'dispatcher error',0
szServiceName                           db '清竹公司大数据处理服务',0
szModuleFileName                        db 'D:\masm32\hddata\hddll\IOCPServerWin32Console.exe',0.codeDllEntry proc,hDllInstance,dwReason,dwReserved
mov eax,dwReason
.if eax==DLL_PROCESS_ATTACH
push            hDllInstance
pop             _hDllInstance
mov eax,TRUE
leave
retn 12
.elseif eax==DLL_THREAD_ATTACH
mov eax,TRUE
leave 
retn 12
.elseif eax==DLL_THREAD_DETACH
mov eax,TRUE
leave
retn 12
.elseif eax==DLL_PROCESS_DETACH               ;为何此处不能设置为自动退出?因为手动调用了_ProcTerminate,若进程再次调用则发生异常
call _ProcTerminate
mov eax,TRUE
leave
retn 12
.endif
DllEntry endp_ProcTerminate proc
local @szBuf[200h]:byte
local @szBuffer[100h]:byte
local @dwCounterpush ebx
push esi
push edicld
invoke EnterCriticalSection,addr _stCriticalPointDirjmp DebugNotEncryptmov esi,_lpPointDirBuf
mov eax,FILE_POINTDIR_SIZE
cmp dword ptr [eax+esi-8],1
jz PointDirEncrypted
mov dword ptr [eax+esi-8],1
mov esi,_lpPointDirBuf
mov edi,_lpPointDirBuf
mov ecx,FILE_POINTDIR_SIZE
sub ecx,8
EncryptePointDir:
lodsb
xor al,ENCRYPTION_KEY
stosb
loop EncryptePointDir
PointDirEncrypted:
lea eax,@szBuffer
push eax
call _ProcSysTimeToAsc
invoke wsprintf,addr @szBuf,addr szEncryptPointDir,addr @szBuffer
mov ecx,eax
invoke WriteFile,_hFileJournal,addr @szBuf,ecx,addr @dwCounter,0DebugNotEncrypt:mov esi,_lpUserInfoBuf
mov ebx,FILE_USERINFO_SIZE
cmp dword ptr [esi+ebx-8],1
jz FileInfoEncrypt
mov dword ptr [esi+ebx-8],1
mov ecx,FILE_USERINFO_SIZE
sub ecx,8
mov esi,_lpUserInfoBuf
mov edi,esi
DecryptUserInfo:
lodsb
xor al,ENCRYPTION_KEY
stosb
loop DecryptUserInfo
FileInfoEncrypt:
lea eax,@szBuffer
push eax
call _ProcSysTimeToAsc
invoke wsprintf,addr @szBuf,addr szEncryptUserInfo,addr @szBuffer
mov ecx,eax
invoke WriteFile,_hFileJournal,addr @szBuf,ecx,addr @dwCounter,0  invoke closesocket,_hSockRecv
invoke WSACleanup
mov _flTerminate,1
WaitConsoleThreadRet:
cmp _dwRunningThreadCnt,0
jnz WaitConsoleThreadRet
invoke WriteFile,_hFileJournal,addr szQuit,sizeof szQuit-1,addr @dwCounter,0mov esi,_lpRltDataTableBuf
mov ecx,_dwRltDataTableBufSize
shr ecx,3
CheckPointOrdinal:
push ecx
push esi
lodsd
cmp eax,0ffffffffh
jnz GetValidService
GetNextValidService:
pop esi
add esi,8
pop ecx
loop CheckPointOrdinal
jmp NotFoundValidService
GetValidService:
mov edi,[esi]
mov dword ptr [esi],0ffffffffh
mov dword ptr [esi-4],0ffffffffh
push edi
invoke VirtualFree,edi,_stSystemInfo.dwPageSize,MEM_DECOMMIT           
pop edi
invoke VirtualFree,edi,0,MEM_RELEASE
jmp GetNextValidServiceNotFoundValidService:
invoke VirtualFree,_lpUdpPackRecvBuf,_dwUdpPackRecvBufSize,MEM_DECOMMIT
invoke VirtualFree,_lpUdpPackRecvBuf,0,MEM_RELEASE
invoke VirtualFree,_lpUdpPackAddrBuf,_dwUdpPackAddrBufSize,MEM_DECOMMIT
invoke VirtualFree,_lpUdpPackAddrBuf,0,MEM_RELEASE
invoke VirtualFree,_lpRecordingBuf,_dwRecordingBackupBufSize,MEM_DECOMMIT
invoke VirtualFree,_lpRecordingBuf,0,MEM_RELEASE
invoke VirtualFree,_lpRecordReservedBuf,_dwRecordingBackupBufSize,MEM_DECOMMIT
invoke VirtualFree,_lpRecordReservedBuf,0,MEM_RELEASE
invoke VirtualFree,_lpRecordingIndexBuf,_dwIndexBackupBufSize,MEM_DECOMMIT
invoke VirtualFree,_lpRecordingIndexBuf,0,MEM_RELEASE
invoke VirtualFree,_lpIndexReservedBuf,_dwIndexBackupBufSize,MEM_DECOMMIT
invoke VirtualFree,_lpIndexReservedBuf,0,MEM_RELEASE
invoke VirtualFree,_lpRltDataTableBuf,_dwRltDataTableBufSize,MEM_DECOMMIT
invoke VirtualFree,_lpRltDataTableBuf,0,MEM_RELEASE
invoke VirtualFree,_lpReadQueueInfoBuf,_dwReadQueueInfoBufSize,MEM_DECOMMIT
invoke VirtualFree,_lpReadQueueInfoBuf,0,MEM_RELEASEinvoke UnmapViewOfFile,_lpPointDirBuf
invoke CloseHandle,_hFileMapPointDir
invoke CloseHandle,_hFilePointDir
invoke UnmapViewOfFile,_lpUserInfoBuf
invoke CloseHandle,_hFileMappingUserInfo
invoke CloseHandle,_hFileUserInfo
invoke CloseHandle,_hEventStoreRecording
invoke CloseHandle,_hEventRealTimeData
invoke CloseHandle,_hThreadWaitSamplePeriod
invoke CloseHandle,_hThreadRealTimeData
invoke CloseHandle,_hThreadUdpUnpack
invoke CloseHandle,_hThreadStoreRecording
invoke CloseHandle,_hThreadRecvUdpPack
invoke CloseHandle,_hFileDataBase
invoke CloseHandle,_hFileIndex invoke CloseHandle,_hFileJournal
invoke LeaveCriticalSection,addr _stCriticalPointDir
invoke DeleteCriticalSection,addr _stCriticalUserInfo
invoke DeleteCriticalSection,addr _stCriticalPointDir
invoke DeleteCriticalSection,addr _stCriticalDcsToMem
invoke DeleteCriticalSection,addr _stCriticalMemToFile
invoke DeleteCriticalSection,addr _stCriticalRealTime
invoke DeleteCriticalSection,addr _stCriticalReadData
invoke DeleteCriticalSection,addr _stCriticalTransInfo
invoke SetUnhandledExceptionFilter,_lpOldExceptionFilter
invoke ExitProcess,0
pop edi
pop esi
pop ebx
mov eax,1
mov edx,0
leave
retn 0                            
_ProcTerminate endp_ProcInit proc
local @stWsaData:WSADATA
local @dwCounter
local @flOldProtect
local @szBuffer[100h]:byte
local @szBuf[200h]:bytepush ebx
push esi
push edi     
call _ProcOpenFileinvoke WSAStartup,0202h,addr @stWsaData.if eax!=ERROR_SUCCESSjmp WsaStartupError.endif
invoke socket,AF_INET,SOCK_DGRAM,IPPROTO_UDP.if eax==SOCKET_ERRORjmp SocketError.endif
mov _hSockRecv,eax
mov _stRecvAddr.sin_family,AF_INET
invoke htons,UDP_PORT
mov _stRecvAddr.sin_port,ax
mov _stRecvAddr.sin_addr,INADDR_ANY
invoke bind,_hSockRecv,addr _stRecvAddr,sizeof sockaddr_in.if eax==SOCKET_ERRORinvoke closesocket,_hSockRecvSocketError:invoke WSACleanupWsaStartupError:lea eax,@szBufferpush eaxcall _ProcSysTimeToAscinvoke wsprintf,addr @szBuf,addr szSocketError,addr @szBuffermov ecx,eaxinvoke WriteFile,_hFileJournal,addr @szBuf,ecx,addr @dwCounter,0call _ProcTerminateinvoke ExitProcess,0  .endif lea ebx,_ProcNewExceptionFilter
invoke SetUnhandledExceptionFilter,ebx
mov _lpOldExceptionFilter,eax
invoke InitializeCriticalSection,addr _stCriticalUserInfo
invoke InitializeCriticalSection,addr _stCriticalPointDir
invoke InitializeCriticalSection,addr _stCriticalDcsToMem
invoke InitializeCriticalSection,addr _stCriticalMemToFile
invoke InitializeCriticalSection,addr _stCriticalRealTime
invoke InitializeCriticalSection,addr _stCriticalReadData
invoke InitializeCriticalSection,addr _stCriticalTransInfomov ebx,_stSystemInfo.dwPageSize
mov ecx,ebx
shl ecx,BUF_MULTI_RATIO
mov eax,_dwDcsSampleCnt
shl eax,2
add eax,sizeof SYSTEMTIME
push eax
push ebx
dec ebx
and eax,ebx
pop ebx
sub ebx,eax
add ecx,ebx
pop eax
add eax,ecx
mov _dwDataRecordingSize,eax
shr ecx,2
mov _dwFreeRecordCnt,ecxmov eax,_dwStoreRecordingPeriod
mov edx,0
mov ebx,_dwSamplePeriod
div ebx
mov _dwRecordingLimitOfBuf,eax
mov ebx,_dwDataRecordingSize
mul ebx
shl eax,BUF_MULTI_RATIO
mov _dwRecordingBufSize,eax
shl eax,2
mov _dwRecordingBackupBufSize,eax
invoke VirtualAlloc,NULL,_dwRecordingBackupBufSize,MEM_RESERVE,PAGE_NOACCESS.if eax==0invoke WriteFile,_hFileJournal,addr szMemAllocError,sizeof szMemAllocError-1,addr @dwCounter,0call _ProcTerminate.endif
mov _lpRecordingBuf,eax
invoke VirtualAlloc,_lpRecordingBuf,_dwRecordingBufSize,MEM_COMMIT,PAGE_READWRITE.if eax==0invoke WriteFile,_hFileJournal,addr szMemAllocError,sizeof szMemAllocError-1,addr @dwCounter,0call _ProcTerminate.endif
mov _lpRecordingBuf,eax 
mov _lpRecordingBufHead,eax
mov _lpRecordingBufEnd,eax
mov ecx,_dwRecordingBufSize
shr ecx,BUF_MULTI_RATIO
add eax,ecx
mov _lpRecordingBufLimit,eax
mov ebx,_lpRecordingBuf
add ebx,_dwRecordingBufSize
sub ebx,ecx
invoke VirtualProtect,ebx,ecx,PAGE_READWRITE OR PAGE_GUARD,addr @flOldProtectinvoke VirtualAlloc,NULL,_dwRecordingBackupBufSize,MEM_RESERVE,PAGE_NOACCESS.if eax==0invoke WriteFile,_hFileJournal,addr szMemAllocError,sizeof szMemAllocError-1,addr @dwCounter,0call _ProcTerminate.endif
mov _lpRecordReservedBuf,eax
invoke VirtualAlloc,_lpRecordReservedBuf,_dwRecordingBufSize,MEM_COMMIT,PAGE_READWRITE.if eax==0invoke WriteFile,_hFileJournal,addr szMemAllocError,sizeof szMemAllocError-1,addr @dwCounter,0call _ProcTerminate.endif
mov _lpRecordReservedBuf,eax
mov _lpRecordReservedBufHead,eax
mov ecx,_dwRecordingBufSize
shr ecx,BUF_MULTI_RATIO
add eax,ecx
mov _lpRecordReservedBufLimit,eax
mov ebx,_lpRecordReservedBuf
add ebx,_dwRecordingBufSize
sub ebx,ecx
invoke VirtualProtect,ebx,ecx,PAGE_READWRITE OR PAGE_GUARD,addr @flOldProtectmov eax,_dwRecordingLimitOfBuf
mov ebx,RECORDING_INDEX_SIZE
mul ebx
shl eax,BUF_MULTI_RATIO
mov _dwRecordingIndexBufSize,eax
shl eax,2
mov _dwIndexBackupBufSize,eax
invoke VirtualAlloc,NULL,_dwIndexBackupBufSize,MEM_RESERVE,PAGE_NOACCESS.if eax==0invoke WriteFile,_hFileJournal,addr szMemAllocError,sizeof szMemAllocError-1,addr @dwCounter,0call _ProcTerminate.endif
mov _lpRecordingIndexBuf,eax
invoke VirtualAlloc,_lpRecordingIndexBuf,_dwRecordingIndexBufSize,MEM_COMMIT,PAGE_READWRITE.if eax==0invoke WriteFile,_hFileJournal,addr szMemAllocError,sizeof szMemAllocError-1,addr @dwCounter,0call _ProcTerminate.endif
mov _lpRecordingIndexBuf,eax
mov _lpRecordingIndexBufHead,eax
mov _lpRecordingIndexBufEnd,eax
mov ecx,_dwRecordingIndexBufSize
shr ecx,BUF_MULTI_RATIO
add eax,ecx
mov _lpRecordingIndexBufLimit,eax
mov ebx,_lpRecordingIndexBuf
add ebx,_dwRecordingIndexBufSize
sub ebx,ecx
invoke VirtualProtect,ebx,ecx,PAGE_READWRITE OR PAGE_GUARD,addr @flOldProtectinvoke VirtualAlloc,NULL,_dwIndexBackupBufSize,MEM_RESERVE,PAGE_NOACCESS.if eax==0invoke WriteFile,_hFileJournal,addr szMemAllocError,sizeof szMemAllocError-1,addr @dwCounter,0call _ProcTerminate.endif
mov _lpIndexReservedBuf,eax
invoke VirtualAlloc,_lpIndexReservedBuf,_dwRecordingIndexBufSize,MEM_COMMIT,PAGE_READWRITE.if eax==0invoke WriteFile,_hFileJournal,addr szMemAllocError,sizeof szMemAllocError-1,addr @dwCounter,0call _ProcTerminate.endif
mov _lpIndexReservedBuf,eax
mov _lpIndexReservedBufHead,eax
mov ecx,_dwRecordingIndexBufSize
shr ecx,BUF_MULTI_RATIO
add eax,ecx
mov _lpIndexReservedBufLimit,eax
mov ebx,_lpIndexReservedBuf
add ebx,_dwRecordingIndexBufSize
sub ebx,ecx
invoke VirtualProtect,ebx,ecx,PAGE_READWRITE OR PAGE_GUARD,addr @flOldProtectmov eax,_dwRecordingBufSize
mov _dwUdpPackRecvBufSize,eax 
invoke VirtualAlloc,NULL,_dwUdpPackRecvBufSize,MEM_COMMIT,PAGE_READWRITE.if eax==0invoke WriteFile,_hFileJournal,addr szMemAllocError,sizeof szMemAllocError-1,addr @dwCounter,0call _ProcTerminate.endif
mov _lpUdpPackRecvBuf,eax
mov _lpUdpPackRecvBufHead,eax
mov _lpUdpPackRecvBufEnd,eax
add eax,_dwUdpPackRecvBufSize
mov _lpUdpPackRecvBufLimit,eaxmov eax,_dwUdpPackRecvBufSize
mov edx,0
mov ebx,UDP_PACKAGE_SIZE
div ebx
mov _dwUdpPackAddrBufSize,eax
invoke VirtualAlloc,NULL,_dwUdpPackAddrBufSize,MEM_COMMIT,PAGE_READWRITE.if eax==0invoke WriteFile,_hFileJournal,addr szMemAllocError,sizeof szMemAllocError-1,addr @dwCounter,0call _ProcTerminate.endif
mov _lpUdpPackAddrBuf,eax
mov _lpUdpPackAddrBufHead,eax
mov _lpUdpPackAddrBufEnd,eax
add eax,_dwUdpPackAddrBufSize
mov _lpUdpPackAddrBufLimit,eaxmov eax,_stSystemInfo.dwPageSize
mov _dwRltDataTableBufSize,eax
invoke VirtualAlloc,NULL,_dwRltDataTableBufSize,MEM_COMMIT,PAGE_READWRITE.if eax==0invoke WriteFile,_hFileJournal,addr szMemAllocError,sizeof szMemAllocError-1,addr @dwCounter,0call _ProcTerminate.endif
mov _lpRltDataTableBuf,eax
mov edi,eax
mov ecx,_dwRltDataTableBufSize
shr ecx,2
mov eax,0ffffffffh
cld
rep stosdmov eax,_stSystemInfo.dwPageSize
mov _dwReadQueueInfoBufSize,eax
invoke VirtualAlloc,NULL,_dwReadQueueInfoBufSize,MEM_COMMIT,PAGE_READWRITE.if eax==0invoke WriteFile,_hFileJournal,addr szMemAllocError,sizeof szMemAllocError-1,addr @dwCounter,0call _ProcTerminate.endif
mov _lpReadQueueInfoBuf,eaxinvoke CreateEvent,NULL,TRUE,FALSE,NULL.if eax==0invoke WriteFile,_hFileJournal,addr szEventError,sizeof szEventError-1,addr @dwCounter,0call _ProcTerminate.endif
mov _hEventStoreRecording,eax  
invoke CreateEvent,NULL,TRUE,FALSE,NULL.if eax==0invoke WriteFile,_hFileJournal,addr szEventError,sizeof szEventError-1,addr @dwCounter,0call _ProcTerminate.endif
mov _hEventRealTimeData,eax                     ;自动事件会丢失数据,为什么???lea ebx, _ThreadRecvUdpPack
invoke CreateThread,0,0,ebx,0,CREATE_SUSPENDED,0.if eax==0invoke WriteFile,_hFileJournal,addr szThreadError,sizeof szThreadError-1,addr @dwCounter,0call _ProcTerminate.endif
mov _hThreadRecvUdpPack,eax
invoke SetThreadPriority,_hThreadRecvUdpPack,THREAD_PRIORITY_HIGHEST
invoke ResumeThread,_hThreadRecvUdpPack
lea ebx,_ThreadWaitSamplePeriod
invoke CreateThread,0,0,ebx,0,CREATE_SUSPENDED,0.if eax==0invoke WriteFile,_hFileJournal,addr szThreadError,sizeof szThreadError-1,addr @dwCounter,0call _ProcTerminate.endif
mov _hThreadWaitSamplePeriod,eax
invoke SetThreadPriority,_hThreadWaitSamplePeriod,THREAD_PRIORITY_HIGHEST
invoke ResumeThread,_hThreadWaitSamplePeriod
lea ebx,_ThreadRealTimeData
invoke CreateThread,0,0,ebx,0,CREATE_SUSPENDED,0.if eax==0invoke WriteFile,_hFileJournal,addr szThreadError,sizeof szThreadError-1,addr @dwCounter,0call _ProcTerminate.endif
mov _hThreadRealTimeData,eax
invoke SetThreadPriority,_hThreadRealTimeData,THREAD_PRIORITY_HIGHEST
invoke ResumeThread,_hThreadRealTimeDatalea ebx,_ThreadStoreRecording
invoke CreateThread,0,0,ebx,0,0,0.if eax==0invoke WriteFile,_hFileJournal,addr szThreadError,sizeof szThreadError-1,addr @dwCounter,0call _ProcTerminate.endif
mov _hThreadStoreRecording,eax
lea ebx,_ThreadUdpUnpack
invoke CreateThread,0,0,ebx,0,0,0.if eax==0invoke WriteFile,_hFileJournal,addr szThreadError,sizeof szThreadError-1,addr @dwCounter,0call _ProcTerminate.endif
mov _hThreadUdpUnpack,eaxpop edi
pop esi
pop ebx
mov eax,1
mov edx,0
leave
retn 0                          ; 为何不能用RET指令:RET是宏指令,RETN是机器码
_ProcInit endp_ProcOpenFile proc 
local @stOverlappedRead:OVERLAPPED
local @dwCounter
local @dqFileSize:qword
local @lpFileBuf
local @lpPointDirEnd
local @dwPointDirOrdinal
local @lpCurrentPointHead
local @dwPointIdLen
local @szBuffer[100h]:byte
local @szBuf[400h]:bytepush ebx
push esi
push edi
invoke GetDiskFreeSpace,0,offset _dwSecsPerClu,offset _dwBytesPerSec,offset _dwFreeCluCnt,offset _dwCluCnt
invoke GetSystemInfo,addr _stSystemInfo
invoke CreateFile,offset szJournalFileName,GENERIC_READ OR GENERIC_WRITE,FILE_SHARE_READ,0,OPEN_EXISTING,\
FILE_ATTRIBUTE_NORMAL or FILE_FLAG_RANDOM_ACCESS ,NULL.if eax==INVALID_HANDLE_VALUEinvoke CreateFile,offset szJournalFileName,GENERIC_READ OR GENERIC_WRITE,FILE_SHARE_READ,0,CREATE_ALWAYS,\FILE_ATTRIBUTE_NORMAL or FILE_FLAG_RANDOM_ACCESS,NULLmov _hFileJournal,eaxlea eax,@szBufferpush eaxcall _ProcSysTimeToAsc        invoke wsprintf,addr @szBuf,addr szInit,addr @szBuffermov ecx,eaxinvoke WriteFile,_hFileJournal,addr @szBuf,ecx,addr @dwCounter,0invoke WriteFile,_hFileJournal,addr szCreateJournal,sizeof szCreateJournal-1,addr @dwCounter,0.elsemov _hFileJournal,eax  invoke SetFilePointerEx,_hFileJournal,0,0,0,FILE_ENDlea eax,@szBufferpush eaxcall _ProcSysTimeToAscinvoke wsprintf,addr @szBuf,addr szInit,addr @szBuffermov ecx,eaxinvoke WriteFile,_hFileJournal,addr @szBuf,ecx,addr @dwCounter,0invoke WriteFile,_hFileJournal,addr szOpenJournal,sizeof szOpenJournal-1,addr @dwCounter,0.endiflea ebx,DllEntry
invoke wsprintf,addr @szBuf,addr szDllEntry,ebx
mov ecx,eax
invoke WriteFile,_hFileJournal,addr @szBuf,ecx,addr @dwCounter,0
lea ebx,_ProcTerminate
invoke wsprintf,addr @szBuf,addr szProcTerminate,ebx
mov ecx,eax
invoke WriteFile,_hFileJournal,addr @szBuf,ecx,addr @dwCounter,0
lea ebx,_ProcInit
invoke wsprintf,addr @szBuf,addr szProcInit,ebx
mov ecx,eax
invoke WriteFile,_hFileJournal,addr @szBuf,ecx,addr @dwCounter,0
lea ebx,_ProcOpenFile
invoke wsprintf,addr @szBuf,addr szProcOpenFile,ebx
mov ecx,eax
invoke WriteFile,_hFileJournal,addr @szBuf,ecx,addr @dwCounter,0
lea ebx,_ProcModifyData
invoke wsprintf,addr @szBuf,addr szProcModifyData,ebx
mov ecx,eax
invoke WriteFile,_hFileJournal,addr @szBuf,ecx,addr @dwCounter,0
lea ebx,_ProcReadData
invoke wsprintf,addr @szBuf,addr szProcReadData,ebx
mov ecx,eax
invoke WriteFile,_hFileJournal,addr @szBuf,ecx,addr @dwCounter,0
lea ebx,_ThreadReadData
invoke wsprintf,addr @szBuf,addr szThreadReadData,ebx
mov ecx,eax
invoke WriteFile,_hFileJournal,addr @szBuf,ecx,addr @dwCounter,0
lea ebx,_ThreadSeekIndex
invoke wsprintf,addr @szBuf,addr szThreadSeekIndex,ebx
mov ecx,eax
invoke WriteFile,_hFileJournal,addr @szBuf,ecx,addr @dwCounter,0
lea ebx,_ProcOverlappedRead
invoke wsprintf,addr @szBuf,addr szProcOverlappedRead,ebx
mov ecx,eax
invoke WriteFile,_hFileJournal,addr @szBuf,ecx,addr @dwCounter,0lea ebx,_ThreadReadSector
invoke wsprintf,addr @szBuf,addr szThreadReadSector,ebx
mov ecx,eax
invoke WriteFile,_hFileJournal,addr @szBuf,ecx,addr @dwCounter,0
lea ebx,_ProcReadInterval
invoke wsprintf,addr @szBuf,addr szProcReadInterval,ebx
mov ecx,eax
invoke WriteFile,_hFileJournal,addr @szBuf,ecx,addr @dwCounter,0
lea ebx,_ThreadWaitSamplePeriod
invoke wsprintf,addr @szBuf,addr szThreadWaitSamplePeriod,ebx
mov ecx,eax
invoke WriteFile,_hFileJournal,addr @szBuf,ecx,addr @dwCounter,0
lea ebx,_ThreadRecvUdpPack
invoke wsprintf,addr @szBuf,addr szThreadRecvUdpPack,ebx
mov ecx,eax
invoke WriteFile,_hFileJournal,addr @szBuf,ecx,addr @dwCounter,0
lea ebx,_ThreadUdpUnpack
invoke wsprintf,addr @szBuf,addr szThreadUdpUnpack,ebx
mov ecx,eax
invoke WriteFile,_hFileJournal,addr @szBuf,ecx,addr @dwCounter,0
lea ebx,_ProcExceptionGuard
invoke wsprintf,addr @szBuf,addr szProcExceptionGuard,ebx
mov ecx,eax
invoke WriteFile,_hFileJournal,addr @szBuf,ecx,addr @dwCounter,0
lea ebx,_ThreadStoreRecording
invoke wsprintf,addr @szBuf,addr szThreadStoreRecording,ebx
mov ecx,eax
invoke WriteFile,_hFileJournal,addr @szBuf,ecx,addr @dwCounter,0
lea ebx,_ThreadJournalOfWriteInfo
invoke wsprintf,addr @szBuf,addr szThreadJournalOfWriteInfo,ebx
mov ecx,eax
invoke WriteFile,_hFileJournal,addr @szBuf,ecx,addr @dwCounter,0
lea ebx,_ThreadRealTimeData
invoke wsprintf,addr @szBuf,addr szThreadRealTimeData,ebx
mov ecx,eax
invoke WriteFile,_hFileJournal,addr @szBuf,ecx,addr @dwCounter,0
lea ebx,_ProcRegistryInfo
invoke wsprintf,addr @szBuf,addr szProcRegistryInfo,ebx
mov ecx,eax
invoke WriteFile,_hFileJournal,addr @szBuf,ecx,addr @dwCounter,0
lea ebx,_ProcGetRealTimeData
invoke wsprintf,addr @szBuf,addr szProcGetRealTimeData,ebx
mov ecx,eax
invoke WriteFile,_hFileJournal,addr @szBuf,ecx,addr @dwCounter,0
lea ebx,_ProcInsertPoint
invoke wsprintf,addr @szBuf,addr szProcInsertPoint,ebx
mov ecx,eax
invoke WriteFile,_hFileJournal,addr @szBuf,ecx,addr @dwCounter,0
lea ebx,_ProcAddPoint
invoke wsprintf,addr @szBuf,addr szProcAddPoint,ebx
mov ecx,eax
invoke WriteFile,_hFileJournal,addr @szBuf,ecx,addr @dwCounter,0
lea ebx,_ProcDeletePoint
invoke wsprintf,addr @szBuf,addr szProcDeletePoint,ebx
mov ecx,eax
invoke WriteFile,_hFileJournal,addr @szBuf,ecx,addr @dwCounter,0
lea ebx,_ProcModifyPoint
invoke wsprintf,addr @szBuf,addr szProcModifyPoint,ebx
mov ecx,eax
invoke WriteFile,_hFileJournal,addr @szBuf,ecx,addr @dwCounter,0
lea ebx,_ProcSeekPoint
invoke wsprintf,addr @szBuf,addr szProcSeekPoint,ebx
mov ecx,eax
invoke WriteFile,_hFileJournal,addr @szBuf,ecx,addr @dwCounter,0
lea ebx,_ProcGetPointTable
invoke wsprintf,addr @szBuf,addr szProcGetPointTable,ebx
mov ecx,eax
invoke WriteFile,_hFileJournal,addr @szBuf,ecx,addr @dwCounter,0
lea ebx,_ProcSeekUser
invoke wsprintf,addr @szBuf,addr szProcSeekUser,ebx
mov ecx,eax
invoke WriteFile,_hFileJournal,addr @szBuf,ecx,addr @dwCounter,0
lea ebx,_ProcAddUser
invoke wsprintf,addr @szBuf,addr szProcAddUser,ebx
mov ecx,eax
invoke WriteFile,_hFileJournal,addr @szBuf,ecx,addr @dwCounter,0
lea ebx,_ProcDeleteUser
invoke wsprintf,addr @szBuf,addr szProcDeleteUser,ebx
mov ecx,eax
invoke WriteFile,_hFileJournal,addr @szBuf,ecx,addr @dwCounter,0invoke CreateFile,offset szDataBaseFileName,GENERIC_READ or GENERIC_WRITE,FILE_SHARE_READ,0,OPEN_EXISTING,\
FILE_ATTRIBUTE_NORMAL or FILE_FLAG_OVERLAPPED or FILE_FLAG_NO_BUFFERING or FILE_FLAG_WRITE_THROUGH or \
FILE_FLAG_SEQUENTIAL_SCAN,NULL.if eax==INVALID_HANDLE_VALUEinvoke CreateFile,offset szDataBaseFileName,GENERIC_READ or GENERIC_WRITE,FILE_SHARE_READ,0,CREATE_ALWAYS,\FILE_ATTRIBUTE_NORMAL or FILE_FLAG_OVERLAPPED or FILE_FLAG_NO_BUFFERING or FILE_FLAG_WRITE_THROUGH or \FILE_FLAG_SEQUENTIAL_SCAN,NULLmov _hFileDataBase,eaxinvoke WriteFile,_hFileJournal,addr szCreateDataBase,sizeof szCreateDataBase-1,addr @dwCounter,0.elsemov _hFileDataBase,eaxinvoke WriteFile,_hFileJournal,addr szOpenDataBase,sizeof szOpenDataBase-1,addr @dwCounter,0.endifinvoke VirtualAlloc,0,dword ptr _stSystemInfo.dwPageSize,MEM_COMMIT,PAGE_READWRITE.if eax==0invoke WriteFile,_hFileJournal,addr szMemAllocError,sizeof szMemAllocError-1,addr @dwCounter,0call _ProcTerminate.endif
mov @lpFileBuf,eax
invoke CreateFile,offset szIndexFileName,GENERIC_READ or GENERIC_WRITE,FILE_SHARE_READ,0,OPEN_EXISTING,\
FILE_ATTRIBUTE_NORMAL or FILE_FLAG_OVERLAPPED or FILE_FLAG_NO_BUFFERING or FILE_FLAG_WRITE_THROUGH or \
FILE_FLAG_SEQUENTIAL_SCAN,NULL.if eax!=INVALID_HANDLE_VALUEmov _hFileIndex,eaxinvoke GetFileSizeEx,_hFileIndex,addr @dqFileSizemov eax,dword ptr [@dqFileSize]mov edx,dword ptr [@dqFileSize+4]sub eax,_dwBytesPerSecsbb edx,0 lea esi,@stOverlappedReadmov dword ptr [esi+8],eax         mov dword ptr [esi+12],edxmov dword ptr [esi],0mov dword ptr [esi+4],0invoke CreateEvent,0,TRUE,0,0mov @stOverlappedRead.hEvent,eaxinvoke ReadFile,_hFileIndex,@lpFileBuf,_dwBytesPerSec,addr @dwCounter,addr @stOverlappedRead.if eax==0invoke GetLastError.if eax==ERROR_IO_PENDING      invoke WaitForSingleObject,@stOverlappedRead.hEvent,INFINITEinvoke GetOverlappedResult,_hFileIndex,addr @stOverlappedRead,addr @dwCounter,TRUEmov eax,@dwCounter.if eax==_dwBytesPerSecjmp ToGetRecordCntSum.elsejmp ToCreateNewIndexFile                    .endif.elseif eax==ERROR_HANDLE_EOFjmp ToCreateNewIndexFile.elsejmp ToCreateNewIndexFile                        .endif.elsemov eax,@dwCounter.if eax==_dwBytesPerSecToGetRecordCntSum:sub eax,16mov esi,@lpFileBufmov edx,[eax+esi]mov dword ptr [_dqRecordingCntSum],edxmov edx,[eax+esi+4]   mov dword ptr [_dqRecordingCntSum+4],edxinvoke WriteFile,_hFileJournal,addr szOpenIndex,sizeof szOpenIndex-1,addr @dwCounter,0  .elsejmp ToCreateNewIndexFile.endif   .endif .elseToCreateNewIndexFile:invoke CreateFile,offset szIndexFileName,GENERIC_READ or GENERIC_WRITE,FILE_SHARE_READ,0,CREATE_ALWAYS,\FILE_ATTRIBUTE_NORMAL or FILE_FLAG_OVERLAPPED or FILE_FLAG_NO_BUFFERING or FILE_FLAG_WRITE_THROUGH or \FILE_FLAG_SEQUENTIAL_SCAN,NULLmov _hFileIndex,eax          mov dword ptr _dqRecordingCntSum,0mov dword ptr [_dqRecordingCntSum+4],0invoke WriteFile,_hFileJournal,addr szCreateIndex,sizeof szCreateIndex-1,addr @dwCounter,0.endif
invoke CloseHandle,@stOverlappedRead.hEvent
invoke VirtualFree,@lpFileBuf,_stSystemInfo.dwPageSize,MEM_DECOMMIT
invoke VirtualFree,@lpFileBuf,0,MEM_RELEASEinvoke CreateFile,offset szPointDirFileName,GENERIC_READ OR GENERIC_WRITE,0,0,OPEN_EXISTING,\
FILE_ATTRIBUTE_NORMAL or FILE_FLAG_RANDOM_ACCESS,NULL.if eax!=INVALID_HANDLE_VALUEmov _hFilePointDir,eax       invoke WriteFile,_hFileJournal,addr szOpenPointDir,sizeof szOpenPointDir-1,addr @dwCounter,0ToMemMapping:invoke GetFileSizeEx,_hFilePointDir,addr @dqFileSizeinvoke CreateFileMapping,_hFilePointDir,0,PAGE_READWRITE,0,FILE_POINTDIR_SIZE,0         ;计算方式比例大约为每条记录128B.if eax==0invoke WriteFile,_hFileJournal,addr szFileMapError,sizeof szFileMapError-1,addr @dwCounter,0call _ProcTerminate.endif  mov _hFileMapPointDir,eaxinvoke MapViewOfFile,_hFileMapPointDir,FILE_MAP_READ or FILE_MAP_WRITE,0,0,0.if eax==0invoke WriteFile,_hFileJournal,addr szFileMapError,sizeof szFileMapError-1,addr @dwCounter,0call _ProcTerminate.endif  mov _lpPointDirBuf,eaxmov esi,FILE_POINTDIR_SIZEcmp dword ptr [eax+esi-4],0jnz NotFirstOpenmov ecx,dword ptr [@dqFileSize]mov _dwPointDirBufSize,ecxmov dword ptr [eax+esi-4],ecxjmp CheckEncryptedNotFirstOpen:   mov ecx,dword ptr [eax+esi-4]mov _dwPointDirBufSize,ecx CheckEncrypted:cmp dword ptr [eax+esi-8],0jz NotEncryptedmov dword ptr [eax+esi-8],0mov esi,_lpPointDirBufmov edi,_lpPointDirBufmov ecx,FILE_POINTDIR_SIZEsub ecx,8cldDecrypted:lodsbxor al,ENCRYPTION_KEYstosbloop Decrypted    lea eax,@szBufferpush eaxcall _ProcSysTimeToAscinvoke wsprintf,addr @szBuf,addr szDecryptPointDir,addr @szBuffermov ecx,eaxinvoke WriteFile,_hFileJournal,addr @szBuf,ecx,addr @dwCounter,0  .elseinvoke CreateFile,offset szPointDirFileName,GENERIC_READ OR GENERIC_WRITE,FILE_SHARE_READ,0,CREATE_ALWAYS,\FILE_ATTRIBUTE_NORMAL or FILE_FLAG_RANDOM_ACCESS,NULLmov _hFilePointDir,eaxinvoke WriteFile,_hFileJournal,addr szCreatePointDir,sizeof szCreatePointDir-1,addr @dwCounter,0jmp ToMemMapping.endif  NotEncrypted:
mov @dwPointDirOrdinal,0
mov ebx,_dwPointDirBufSize
mov esi,_lpPointDirBuf
add ebx,esi
mov @lpPointDirEnd,ebx
GetFirstDot:
cmp esi,@lpPointDirEnd
jae ReachFileEnd
lodsb
cmp al,2ch
jnz GetFirstDot
GetSecondDot:
lodsb
cmp al,2ch
jnz GetSecondDot
mov @dwPointIdLen,0
GetPointIdLen:
lodsb
cmp al,2ch
jz CheckPointIdLen
inc @dwPointIdLen
jmp GetPointIdLen
CheckPointIdLen:
cmp @dwPointIdLen,0
jz ReachFileEnd
GetPointInfoEnd:
lodsb
cmp esi,@lpPointDirEnd
jae ReachFileEnd
cmp al,0ah
jnz GetPointInfoEnd
inc @dwPointDirOrdinal
jmp GetFirstDotReachFileEnd:
inc @dwPointDirOrdinal
mov eax,@dwPointDirOrdinal
cmp eax,1
jnz NotEmptyPointDir
invoke WriteFile,_hFileJournal,addr szFileNoConfig,sizeof szFileNoConfig-1,addr @dwCounter,0
call _ProcTerminate
NotEmptyPointDir:
mov _dwDcsSampleCnt,eax
invoke wsprintf,addr @szBuf,addr szDcsSampleCnt,dword ptr _dwDcsSampleCnt
mov ecx,eax
invoke WriteFile,_hFileJournal,addr @szBuf,ecx,addr @dwCounter,0invoke CreateFile,offset szUserInfoFileName,GENERIC_READ OR GENERIC_WRITE,FILE_SHARE_READ,0,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,0
cmp eax,INVALID_HANDLE_VALUE
jz FirstOpenService
mov _hFileUserInfo,eax
jmp NextOperation
FirstOpenService:
invoke CreateFile,offset szUserInfoFileName,GENERIC_READ OR GENERIC_WRITE,FILE_SHARE_READ,0,CREATE_ALWAYS,FILE_ATTRIBUTE_NORMAL,0
mov _hFileUserInfo,eax
invoke WriteFile,_hFileUserInfo,addr szAdminLogon,sizeof szAdminLogon,addr @dwCounter,0
NextOperation:
invoke GetFileSizeEx,_hFileUserInfo,addr @dqFileSize
invoke CreateFileMapping,_hFileUserInfo,0,PAGE_READWRITE,0,FILE_USERINFO_SIZE,0
mov _hFileMappingUserInfo,eax
invoke MapViewOfFile,_hFileMappingUserInfo,FILE_MAP_READ OR FILE_MAP_WRITE,0,0,0
mov _lpUserInfoBuf,eax
mov esi,eax
mov ebx,FILE_USERINFO_SIZE
cmp dword ptr [esi+ebx-4],0
jnz ToGetUserInfoSize
mov eax,dword ptr [@dqFileSize]
mov dword ptr [esi+ebx-4],eax
mov _dwUserInfoBufSize,eax
jmp ToDecryptUserInfo
ToGetUserInfoSize:
mov eax,dword ptr [esi+ebx-4]
mov _dwUserInfoBufSize,eax
ToDecryptUserInfo:
cmp dword ptr [esi+ebx-8],0
jz FileInfoDecrypt
mov dword ptr [esi+ebx-8],0
mov ecx,FILE_USERINFO_SIZE
sub ecx,8
mov esi,_lpUserInfoBuf
mov edi,esi
DecryptUserInfo:
lodsb
xor al,ENCRYPTION_KEY
stosb
loop DecryptUserInfo
FileInfoDecrypt:lea eax,@szBuffer
push eax
call _ProcSysTimeToAsc
invoke wsprintf,addr @szBuf,addr szDecryptUserInfo,addr @szBuffer
mov ecx,eax
invoke WriteFile,_hFileJournal,addr @szBuf,ecx,addr @dwCounter,0  pop edi
pop esi
pop ebx
leave           ;对于函数(不包括线程),若有调用参数或局部变量之一,则编译器默认加ENTER指令,因此要用LEAVE指令清空堆栈             
retn 0          ;RET指令是宏指令,而RETN是机器码
_ProcOpenFile endp_ProcModifyData proc,lpszPointId,lpQueryTimeHead,lpModifyValue
local @dwRecordHeadNum:qword
local @dwSeekHeadOver
local @dwSeekHeadFoundCnt
local @lpRecordHeadPointer
local @lpRecordHeadDateTimelocal @dwQueryDataBufSize
local @lpQueryDataBuf
local @dwQueryPointOrdinal
local @lpModifyValuePointer
local @dwModifyValueCntlocal @dwSectorDetail
local @dwBytesCnt
local @dwPointIdLen
local @lpFileEnd
local @dqRecordHeadPointer:qword
local @stQueryTimeHead:SYSTEMTIME
local @stOverlapped:OVERLAPPED
local @szBuf[100h]:byte
local @szBuffer[80h]:bytepush ebx
push esi
push edi
lock inc dword ptr [_dwRunningThreadCnt]               
cld
mov esi,lpszPointId
GetPointIdLen:
lodsb
cmp al,0
jnz GetPointIdLen
dec esi
sub esi,lpszPointId
cmp esi,0
jz ModifyFault
mov @dwPointIdLen,esimov @dwModifyValueCnt,0
mov esi,lpModifyValue
mov @lpModifyValuePointer,esi
GetValueCnt:
lodsd
cmp eax,0
jz GetValueCntOk
inc dword ptr @dwModifyValueCnt
jmp GetValueCnt
GetValueCntOk:
cmp dword ptr @dwModifyValueCnt,0
jz ModifyFaultinvoke EnterCriticalSection,addr _stCriticalPointDir
mov ebx,_dwPointDirBufSize
add ebx,_lpPointDirBuf
mov @lpFileEnd,ebx
mov @dwQueryPointOrdinal,0
mov esi,_lpPointDirBuf
SeekFirstDot:
lodsb
cmp al,2ch
jnz SeekFirstDot
SeekSecondDot:
lodsb
cmp al,2ch
jnz SeekSecondDot
SeekPointId:
mov edi,lpszPointId
mov ecx,@dwPointIdLen
repz cmpsb
jz CheckLastChar 
GetEnterSymbol:
lodsb
cmp esi,@lpFileEnd
jae NotFoundId
cmp al,0ah
jnz GetEnterSymbol
inc @dwQueryPointOrdinal
jmp SeekFirstDot
NotFoundId:
invoke LeaveCriticalSection,addr _stCriticalPointDir
jmp ModifyFaultCheckLastChar:
lodsb
cmp al,2ch
jnz NotFoundId
invoke LeaveCriticalSection,addr _stCriticalPointDir
mov esi,lpQueryTimeHead
mov eax,[esi]
mov @stQueryTimeHead.wYear,ax
mov eax,[esi+4]
mov @stQueryTimeHead.wMonth,ax
mov eax,[esi+8]
mov @stQueryTimeHead.wDay,ax
mov eax,[esi+12]
mov @stQueryTimeHead.wHour,ax
mov eax,[esi+16]
mov @stQueryTimeHead.wMinute,ax
mov eax,[esi+20]
mov @stQueryTimeHead.wSecond,ax
mov @stQueryTimeHead.wDayOfWeek,0
mov @stQueryTimeHead.wMilliseconds,0mov @dwSeekHeadOver,0
mov @dwSeekHeadFoundCnt,0
lea esi,@dqRecordHeadPointer
mov @lpRecordHeadPointer,esi
lea esi,@stQueryTimeHead
mov @lpRecordHeadDateTime,esi
lea ebx,_ThreadSeekIndex
lea esi,@lpRecordHeadDateTime
invoke CreateThread,0,0,ebx,esi,0,0
invoke CloseHandle,eaxWaitSeekHeadOver:
mov eax,@dwSeekHeadOver
test eax,1
jz WaitSeekHeadOvermov eax,@dwSeekHeadFoundCnt
test eax,1
jz ModifyFaultmov eax,@dwQueryPointOrdinal
shl eax,2
add eax,sizeof SYSTEMTIME
add dword ptr [@dqRecordHeadPointer],eax
adc dword ptr [@dqRecordHeadPointer+4],0
mov eax,dword ptr [@dqRecordHeadPointer]
mov ebx,_dwBytesPerSec
dec ebx
and eax,ebx
mov @dwSectorDetail,eax
not ebx
and dword ptr [@dqRecordHeadPointer],ebxmov eax,_stSystemInfo.dwPageSize
mov @dwQueryDataBufSize,eax
invoke VirtualAlloc,NULL,@dwQueryDataBufSize,MEM_COMMIT,PAGE_READWRITE
mov @lpQueryDataBuf,eaxinvoke CreateEvent,0,TRUE,0,0
mov @stOverlapped.hEvent,eaxlea esi,@stOverlapped
mov dword ptr [esi],0
mov dword ptr [esi+4],0
mov eax,dword ptr [@dqRecordHeadPointer]
mov dword ptr [esi+8],eax
mov eax,dword ptr [@dqRecordHeadPointer+4]
mov dword ptr [esi+12],eaxToReadData:
lea esi,@stOverlapped
mov dword ptr [esi],0
mov dword ptr [esi+4],0
invoke ReadFile,_hFileDataBase,@lpQueryDataBuf,_dwBytesPerSec,addr @dwBytesCnt,addr @stOverlapped.if eax==0invoke GetLastError.if eax==ERROR_IO_PENDINGinvoke GetOverlappedResult,_hFileDataBase,addr @stOverlapped,addr @dwBytesCnt,TRUEmov eax,@dwBytesCnt.if eax==_dwBytesPerSecjmp WriteData.elseToModifyError:jmp ModifyError.endif.elseif eax==ERROR_INVALID_USER_BUFFERinvoke Sleep,0jmp ToReadData.elseif eax==ERROR_NOT_ENOUGH_MEMORYinvoke Sleep,0jmp ToReadData.elseif eax==ERROR_HANDLE_EOFjmp ModifyComplete.elsejmp ToModifyError.endif.elsemov eax,@dwBytesCnt.if eax==_dwBytesPerSecjmp WriteData.elsejmp ToModifyError.endif.endifWriteData:
mov esi,@lpModifyValuePointer
mov edi,@lpQueryDataBuf
add edi,@dwSectorDetail
movsdRewriteData:
lea esi,@stOverlapped
mov dword ptr [esi],0
mov dword ptr [esi+4],0
invoke WriteFile,_hFileDataBase,@lpQueryDataBuf,_dwBytesPerSec,addr @dwBytesCnt,addr @stOverlapped.if eax==0invoke GetLastError.if eax==ERROR_IO_PENDINGinvoke GetOverlappedResult,_hFileDataBase,addr @stOverlapped,addr @dwBytesCnt,TRUEmov eax,@dwBytesCnt.if eax==_dwBytesPerSecjmp WriteDataOk.elsejmp ToModifyError.endif.elseif eax==ERROR_INVALID_USER_BUFFERinvoke Sleep,0jmp RewriteData.elseif eax==ERROR_NOT_ENOUGH_MEMORYinvoke Sleep,0jmp RewriteData.elseif eax==ERROR_HANDLE_EOFjmp ModifyComplete.elsejmp ToModifyError.endif.elsemov eax,@dwBytesCnt.if eax==_dwBytesPerSecjmp WriteDataOk.elsejmp ToModifyError.endif.endif      WriteDataOk:
dec dword ptr @dwModifyValueCnt
cmp dword ptr @dwModifyValueCnt,0
jz ModifyComplete
add dword ptr @lpModifyValuePointer,4
mov eax,_dwDataRecordingSize
lea esi,@stOverlapped
add dword ptr [esi+8],eax
adc dword ptr [esi+12],0
jmp ToReadDataModifyComplete:
invoke VirtualFree,@lpQueryDataBuf,@dwQueryDataBufSize,MEM_DECOMMIT
invoke VirtualFree,@lpQueryDataBuf,0,MEM_RELEASE
invoke CloseHandle,@stOverlapped.hEventlea eax,@szBuffer
push eax
call _ProcSysTimeToAsc
mov esi,@lpModifyValuePointer
add esi,4
sub esi,lpModifyValue
shr esi,2
invoke wsprintf,addr @szBuf,addr szModifyValue,addr @szBuffer,dword ptr [@dwRecordHeadNum+4],dword ptr [@dwRecordHeadNum],esi
mov ecx,eax
invoke WriteFile,_hFileJournal,addr @szBuf,ecx,addr @dwModifyValueCnt,0lock dec dword ptr [_dwRunningThreadCnt]               
pop edi
pop esi
pop ebx
mov eax,1
mov edx,0
leave
retn 12         ModifyError:
invoke VirtualFree,@lpQueryDataBuf,@dwQueryDataBufSize,MEM_DECOMMIT
invoke VirtualFree,@lpQueryDataBuf,0,MEM_RELEASE
invoke CloseHandle,@stOverlapped.hEvent
ModifyFault:
lock dec dword ptr [_dwRunningThreadCnt]               
pop edi
pop esi
pop ebx
mov eax,0
mov edx,0
leave
retn 12                  ;注意RETN 与RET 指令编译器会翻译成不同的指令,在这里只能用RETN指令而不能用RET指令
_ProcModifyData endp_ProcReadData proc,lpszPointId,lpQueryTimeHead,lpQueryTimeEnd
push ebx
push esi
push edilock inc dword ptr [_dwRunningThreadCnt]               
invoke EnterCriticalSection,addr _stCriticalReadData
mov esi,_lpReadQueueInfoBuf
mov ebx,esi
add ebx,_dwReadQueueInfoBufSize
cld
CheckValidPos:
lodsd
cmp eax,0
jz GetValidPos
add esi,28              ;32B ervery struct
cmp esi,ebx
jb CheckValidPosinvoke LeaveCriticalSection,addr _stCriticalReadData
lock dec dword ptr [_dwRunningThreadCnt]               
pop edi
pop esi
pop ebx
mov eax,0
mov edx,0
leave
retn 12GetValidPos:
sub esi,4
mov eax,lpszPointId
mov [esi],eax
mov eax,lpQueryTimeHead
mov [esi+4],eax
mov eax,lpQueryTimeEnd
mov [esi+8],eax
push esi
push esi
push esi
push esi
invoke CreateEvent,0,TRUE,0,0
pop esi
mov [esi+12],eax
lea ebx,_ThreadReadData
invoke CreateThread,0,0,ebx,esi,0,0
invoke CloseHandle,eaxinvoke LeaveCriticalSection,addr _stCriticalReadData
pop esi
invoke WaitForSingleObject,dword ptr [esi+12],INFINITE
pop esi
invoke CloseHandle,dword ptr [esi+12]
pop esi
mov eax,[esi+16]
mov edx,[esi+20]
pop edi
pop esi
pop ebx
lock dec dword ptr [_dwRunningThreadCnt]               
leave                                           ;调用参数或局部变量都需要恢复ESP,EBP
retn 12
_ProcReadData endp;这里传入的参数为年月日时分秒格式的6个整形变量
_ThreadReadData proc,lpReadInfo   
align qword
local @dqBeginCnt:qword
local @dqEndCnt:qword
local @dqCntPerSec:qword
local @dwTimeConst
local @dwReadTimeCost
local @szBuffer[100h]:byte
local @szBuf[200h]:byte
local @dwCounter
local @dwSeekTimeCostlocal @dwFirstSeekTimes
local @dqFirstSeekEndCnt:qword
local @dqRecordHeadNum:qword
local @dwSeekHeadOver
local @dwSeekHeadFoundCnt
local @lpRecordHeadPointer
local @lpRecordHeadDateTimelocal @dwSecondSeekTimes
local @dqSecondSeekEndCnt:qword
local @dqRecordEndNum:qword
local @dwSeekEndOver
local @dwSeekEndFoundCnt
local @lpRecordEndPointer
local @lpRecordEndDateTimelocal @dwQueryDataBufSize
local @dwReadSectorBufSizelocal @dwReadSectorErrorCnt
local @dwSectorDetail
local @dwQueryPointCnt                  ;local @dwReadRecordSum
local @lpQueryDataBuf 
align qword
local @dqDataPointer:qword
local @dqRecordHeadPointer:qword
local @dqRecordEndPointer:qwordlocal @dwQueryPointOrdinal
local @dwPointIdLen
local @lpFileEnd
local @stQueryTimeHead:SYSTEMTIME
local @stQueryTimeEnd:SYSTEMTIMElocal @lpszPointId
local @lpQueryTimeHead
local @lpQueryTimeEndinvoke QueryPerformanceCounter,addr @dqBeginCnt
cld
mov esi,lpReadInfo
lodsd
mov @lpszPointId,eax
lodsd
mov @lpQueryTimeHead,eax
lodsd
mov @lpQueryTimeEnd,eaxmov esi,@lpszPointId
GetPointIdLen:
lodsb
cmp al,0
jnz GetPointIdLen
dec esi
sub esi,@lpszPointId
cmp esi,0
jz ReadDataFault
mov @dwPointIdLen,esi invoke EnterCriticalSection,addr _stCriticalPointDir
mov ebx,_dwPointDirBufSize
add ebx,_lpPointDirBuf
mov @lpFileEnd,ebx
mov @dwQueryPointOrdinal,0
mov esi,_lpPointDirBuf
SeekFirstDot:
lodsb
cmp al,2ch
jnz SeekFirstDot
SeekSecondDot:
lodsb
cmp al,2ch
jnz SeekSecondDot
SeekPointId:
mov edi,@lpszPointId
mov ecx,@dwPointIdLen
repz cmpsb
jz CheckLastChar
GetEnterSymbol:
lodsb
cmp esi,@lpFileEnd
jae NotFoundId
cmp al,0ah
jnz GetEnterSymbol
inc @dwQueryPointOrdinal
jmp SeekFirstDot
NotFoundId:
invoke LeaveCriticalSection,addr _stCriticalPointDir
jmp ReadDataFaultCheckLastChar:
lodsb
cmp al,2ch
jnz NotFoundId
invoke LeaveCriticalSection,addr _stCriticalPointDir
mov esi,@lpQueryTimeHead
mov edi,@lpQueryTimeEnd
mov ecx,6
repz cmpsd
jae ReadDataFaultmov esi,@lpQueryTimeHead
mov eax,[esi]
mov @stQueryTimeHead.wYear,ax
mov ebx,[esi+4]
mov @stQueryTimeHead.wMonth,bx
mov ecx,[esi+8]
mov @stQueryTimeHead.wDay,cx
mov edx,[esi+12]
mov @stQueryTimeHead.wHour,dx
mov edi,[esi+16]
mov @stQueryTimeHead.wMinute,di
mov esi,[esi+20]
mov @stQueryTimeHead.wSecond,si
mov @stQueryTimeHead.wDayOfWeek,0
mov @stQueryTimeHead.wMilliseconds,0mov esi,@lpQueryTimeEnd
mov eax,[esi]
mov @stQueryTimeEnd.wYear,ax
mov ebx,[esi+4]
mov @stQueryTimeEnd.wMonth,bx
mov ecx,[esi+8]
mov @stQueryTimeEnd.wDay,cx
mov edx,[esi+12]
mov @stQueryTimeEnd.wHour,dx
mov edi,[esi+16]
mov @stQueryTimeEnd.wMinute,di
mov esi,[esi+20]
mov @stQueryTimeEnd.wSecond,si
mov @stQueryTimeEnd.wDayOfWeek,0
mov @stQueryTimeEnd.wMilliseconds,0mov @dwSeekHeadOver,0
mov @dwSeekHeadFoundCnt,0
lea esi,@dqRecordHeadPointer
mov @lpRecordHeadPointer,esi
lea esi,@stQueryTimeHead
mov @lpRecordHeadDateTime,esi
lea ebx,_ThreadSeekIndex
lea esi,@lpRecordHeadDateTime
invoke CreateThread,0,0,ebx,esi,0,0
cmp eax,0
jnz CreateEventFirstOk
mov dword ptr @dwSeekEndOver,1
mov dword ptr @dwSeekHeadOver,1
mov dword ptr @dwSeekHeadFoundCnt,0
mov dword ptr @dwSeekEndFoundCnt,0
jmp WaitSeekHeadOver
CreateEventFirstOk:
invoke CloseHandle,eaxmov @dwSeekEndOver,0
mov @dwSeekEndFoundCnt,0
lea esi,@dqRecordEndPointer
mov @lpRecordEndPointer,esi
lea esi,@stQueryTimeEnd
mov @lpRecordEndDateTime,esi
lea ebx,_ThreadSeekIndex
lea esi,@lpRecordEndDateTime
invoke CreateThread,0,0,ebx,esi,0,0
cmp eax,0
jnz CreateEventSecondOk
mov dword ptr @dwSeekEndOver,1
mov dword ptr @dwSeekEndFoundCnt,0
jmp WaitSeekHeadOver
CreateEventSecondOk:
invoke CloseHandle,eaxWaitSeekHeadOver:
invoke Sleep,SMALLEST_SAMPLE_PERIOD
mov eax,@dwSeekHeadOver
test eax,@dwSeekEndOver
jz WaitSeekHeadOvermov eax,@dwSeekHeadFoundCnt
test eax,@dwSeekEndFoundCnt
jz ReadDataFaultmov eax,dword ptr [@dqRecordEndPointer]
mov edx,dword ptr [@dqRecordEndPointer+4]
mov ebx,dword ptr [@dqRecordHeadPointer]
mov ecx,dword ptr [@dqRecordHeadPointer+4]
mov dword ptr [@dqDataPointer],ebx
mov dword ptr [@dqDataPointer+4],ecx
sub eax,ebx
sbb edx,ecx
mov ebx,_dwDataRecordingSize
div ebx
cmp eax,0
jz ReadDataFault
mov @dwQueryPointCnt,eaxmov eax,@dwQueryPointOrdinal
shl eax,2
add eax,sizeof SYSTEMTIME
add dword ptr [@dqDataPointer],eax
adc dword ptr [@dqDataPointer+4],0
mov eax,dword ptr [@dqDataPointer]
mov ebx,_dwBytesPerSec
dec ebx
and eax,ebx
mov @dwSectorDetail,eax
not ebx
and dword ptr [@dqDataPointer],ebxmov eax,@dwQueryPointCnt
mov ebx,4
add ebx,sizeof SYSTEMTIME
mul ebx
mov ebx,_stSystemInfo.dwPageSize
dec ebx
not ebx
and eax,ebx  
add eax,_stSystemInfo.dwPageSize                ;为何此处这样处理??防止内存越界?????
add eax,_stSystemInfo.dwPageSize
mov @dwQueryDataBufSize,eax
invoke VirtualAlloc,NULL,@dwQueryDataBufSize,MEM_COMMIT,PAGE_READWRITE
cmp eax,0
jz ReadDataFault
mov @lpQueryDataBuf,eax
mov edi,eax
mov eax,@dwQueryDataBufSize
mov dword ptr [edi],eax
mov eax,@dwQueryPointCnt
mov dword ptr [edi+4],eax
add @lpQueryDataBuf,8mov @dwReadSectorErrorCnt,0
lea eax,@dqRecordHeadPointer
push eax
call _ProcOverlappedRead
cmp dword ptr @dwReadSectorErrorCnt,0
jnz ReadDataErrormov esi,lpReadInfo
mov edi,esi
mov ecx,3
mov eax,0
rep stosd
mov eax,@lpQueryDataBuf
sub eax,8
mov [esi+16],eax
mov edx,0
mov [esi+20],edx
invoke SetEvent,dword ptr [esi+12]mov dword ptr [@dwTimeConst],1000000
invoke QueryPerformanceCounter,addr @dqEndCnt
invoke QueryPerformanceFrequency,addr @dqCntPerSec
finit                                           ;DLL可以正常运行浮点指令
fild qword ptr @dqBeginCnt
fild qword ptr @dqEndCnt
fsub st(0),st(1)
fild dword ptr @dwTimeConst
fmul st(0),st(1)
fild qword ptr @dqCntPerSec
fdivp st(1),st(0)
fist dword ptr @dwReadTimeCost
finit                                           ;DLL可以正常运行浮点指令
fild qword ptr @dqBeginCnt
fild qword ptr @dqSecondSeekEndCnt
fsub st(0),st(1)
fild dword ptr @dwTimeConst
fmul st(0),st(1)
fild qword ptr @dqCntPerSec
fdivp st(1),st(0)
fist dword ptr @dwSeekTimeCostlea eax,@szBuffer
push eax
call _ProcSysTimeToAsc
invoke wsprintf,addr @szBuf,addr szJournalSeek,addr @szBuffer,dword ptr @dwSecondSeekTimes,dword ptr @dwSeekTimeCost
mov ecx,eax
invoke WriteFile,_hFileJournal,addr @szBuf,ecx,addr @dwCounter,0
invoke wsprintf,addr @szBuf,addr szJournalRead,addr @szBuffer,dword ptr [@dqRecordHeadNum+4],dword ptr [@dqRecordHeadNum],\dword ptr [@dqRecordEndNum+4],dword ptr [@dqRecordEndNum],dword ptr [@dwQueryPointCnt],dword ptr [@dwReadTimeCost]  
mov ecx,eax
invoke WriteFile,_hFileJournal,addr @szBuf,ecx,addr @dwCounter,0
leave
retn 4        ReadDataError:
invoke VirtualFree,@lpQueryDataBuf,@dwQueryDataBufSize,MEM_DECOMMIT
invoke VirtualFree,@lpQueryDataBuf,0,MEM_RELEASE
ReadDataFault:
mov esi,lpReadInfo
mov edi,esi
mov ecx,3
mov eax,0
rep stosd
mov dword ptr [esi+16],0
mov dword ptr [esi+20],0
invoke SetEvent,dword ptr [esi+12]
invoke WriteFile,_hFileJournal,addr szInputError,sizeof szInputError-1,addr @dwReadSectorErrorCnt,0
ErrorInputParam:
leave
retn 4                  
_ThreadReadData endp
;多个线程同时调用同一个函数有什么影响?
;上述所有线程存在于同一个进程中,共享相同的地址空间,共享函数同样存在于该共享地址空间中。
;因为各个线程的SS:ESP不同,因此返回地址和入口参数不会混淆,若是在共享函数中存在中间性的暂时的局部变量,
;则所有线程都可能有机会改变这些局部变量,局部变量可能会在线程切换中发生改变,但是各个线程堆栈不同,共享函数不改变各个线程局部变量;sizeof计算数据(包括数组、变量、类型、结构体等)所占内存空间,用字节数表示。_ThreadSeekIndex proc,lpSeekIndexInfo
local @stOverlappedRead:OVERLAPPED
local @dwReadCnt
local @lpReadIndexBuf
local @dwReadIndexBufSize
local @dwBigBlockSize
local @dwSeekTimeslocal @dqSeekingPtr:qword
local @dqHeadOffset:qword
local @dqEndOffset:qwordcld
invoke CreateEvent,0,TRUE,0,0
cmp eax,0
jz CreateEventFailure
mov @stOverlappedRead.hEvent,eaxmov eax,_dwBytesPerSec
shl eax,4
mov @dwReadIndexBufSize,eax
invoke VirtualAlloc,NULL,@dwReadIndexBufSize,MEM_COMMIT,PAGE_READWRITE 
cmp eax,0
jnz  MemoryAllocOk   
invoke CloseHandle,@stOverlappedRead.hEvent
CreateEventFailure:
mov esi,lpSeekIndexInfo
mov dword ptr [esi+8],0
mov dword ptr [esi+12],1
leave
retn 4
MemoryAllocOk:
mov @lpReadIndexBuf,eaxmov dword ptr [@dqHeadOffset],0
mov dword ptr [@dqHeadOffset+4],0  mov edx,dword ptr [_dqRecordingCntSum+4]
mov eax,dword ptr [_dqRecordingCntSum]
mov ebx,_dwRecordingLimitOfBuf                          ;注意此处指令的作用是保证不会达到文件末尾而发生错误
dec ebx
not ebx
and eax,ebx
shld edx,eax,5
shl eax,5
mov dword ptr [@dqEndOffset],eax
mov dword ptr [@dqEndOffset+4],edxshrd eax,edx,1
shr edx,1
mov ebx,_dwBytesPerSec
dec ebx
not ebx
and eax,ebx
mov dword ptr [@dqSeekingPtr],eax
mov dword ptr [@dqSeekingPtr+4],edxmov @dwSeekTimes,0
ToSearchRecording:
mov eax,dword ptr [@dqEndOffset]
mov edx,dword ptr [@dqEndOffset+4]
sub eax,dword ptr [@dqHeadOffset]
sbb edx,dword ptr [@dqHeadOffset+4]
cmp edx,0
jg HalfSearch
jl ReadError
mov @dwBigBlockSize,eax
cmp eax,0
jl ReadError
cmp eax,@dwReadIndexBufSize
jbe LastMiniBlockHalfSearch: 
inc @dwSeekTimes
lea esi,@stOverlappedRead
mov dword ptr [esi],0
mov dword ptr [esi+4],0
push dword ptr [@dqSeekingPtr]
pop dword ptr [esi+8]
push dword ptr [@dqSeekingPtr+4]
pop dword ptr [esi+12] 
invoke ReadFile,_hFileIndex,@lpReadIndexBuf,_dwBytesPerSec,addr @dwReadCnt,addr @stOverlappedRead.if eax==NULLinvoke GetLastError.if eax==ERROR_IO_PENDINGinvoke GetOverlappedResult,_hFileIndex,addr @stOverlappedRead,addr @dwReadCnt,TRUEmov eax,@dwReadCnt                                  .if eax==_dwBytesPerSecjmp HalfCheckDateTime.elsejmp ReadError.endif .elseif eax==ERROR_INVALID_USER_BUFFERinvoke Sleep,0jmp HalfSearch.elseif eax==ERROR_NOT_ENOUGH_MEMORYinvoke Sleep,0jmp HalfSearch.elseif eax==ERROR_HANDLE_EOFjmp ReadError.elsejmp ReadError.endif.elsemov eax,@dwReadCnt.if eax==_dwBytesPerSecjmp HalfCheckDateTime.elsejmp ReadError.endif .endif;local @dwRecordHeadNum
;local @dwSeekEndOver
;local @dwSeekEndFoundCnt
;local @lpRecordEndPointer
;local @lpRecordEndDateTimeHalfCheckDateTime:
mov esi,lpSeekIndexInfo
mov esi,[esi]
mov edi,@lpReadIndexBuf
mov word ptr [edi+4],0
mov ecx,7
repe cmpsw                              ;此处可以改进,只需要比较7个
jz HalfSearchFind
ja ToFileEnd
jb ToFileHeadToFileEnd:
mov eax,dword ptr [@dqSeekingPtr]
mov edx,dword ptr [@dqSeekingPtr+4]
mov dword ptr [@dqHeadOffset],eax
mov dword ptr [@dqHeadOffset+4],edx
mov ebx,dword ptr [@dqEndOffset]
mov ecx,dword ptr [@dqEndOffset+4]
sub ebx,eax
sbb ecx,edx
shrd ebx,ecx,1
shr ecx,1
mov eax,_dwBytesPerSec
dec eax
not eax
and ebx,eax
add dword ptr [@dqSeekingPtr],ebx
adc dword ptr [@dqSeekingPtr+4],ecx
jmp ToSearchRecordingToFileHead:
mov eax,dword ptr [@dqSeekingPtr]
mov edx,dword ptr [@dqSeekingPtr+4]
mov dword ptr [@dqEndOffset],eax
mov dword ptr [@dqEndOffset+4],edx
sub eax,dword ptr [@dqHeadOffset]
sbb edx,dword ptr [@dqHeadOffset+4]
shrd eax,edx,1
shr edx,1
mov ebx,_dwBytesPerSec
dec ebx
not ebx
and eax,ebx
sub dword ptr [@dqSeekingPtr],eax
sbb dword ptr [@dqSeekingPtr+4],edx
jmp ToSearchRecordingLastMiniBlock:
inc @dwSeekTimes
lea esi,@stOverlappedRead
mov dword ptr [esi],0
mov dword ptr [esi+4],0
push dword ptr [@dqHeadOffset]
pop dword ptr [esi+8]
push dword ptr [@dqHeadOffset+4]
pop dword ptr [esi+12]
invoke ReadFile,_hFileIndex,@lpReadIndexBuf,@dwBigBlockSize,addr @dwReadCnt,addr @stOverlappedRead.if eax==0                              ;MSDN说异步读写dwReadCount参数必须为0,但实际证明是错误的?到底怎么回事?invoke GetLastError.if eax==ERROR_IO_PENDINGinvoke GetOverlappedResult,_hFileIndex,addr @stOverlappedRead,addr @dwReadCnt,TRUEmov eax,@dwReadCnt                                  .if eax==@dwBigBlockSizejmp LastCheckDateTime.elseReadError:mov esi,lpSeekIndexInfomov dword ptr [esi+8],0mov dword ptr [esi+12],1invoke VirtualFree,@lpReadIndexBuf,@dwReadIndexBufSize,MEM_DECOMMITinvoke VirtualFree,@lpReadIndexBuf,0,MEM_RELEASEinvoke CloseHandle,@stOverlappedRead.hEventleaveretn 4.endif .elseif eax==ERROR_INVALID_USER_BUFFERinvoke Sleep,0jmp LastMiniBlock.elseif eax==ERROR_NOT_ENOUGH_MEMORYinvoke Sleep,0jmp LastMiniBlock.elseif eax==ERROR_HANDLE_EOFjmp ReadError.elsejmp ReadError.endif.elsemov eax,@dwReadCnt.if eax==@dwBigBlockSizejmp LastCheckDateTime.elsejmp ReadError.endif .endifLastCheckDateTime:  
mov ecx,@dwReadCnt
shr ecx,5
mov esi,lpSeekIndexInfo
mov esi,[esi]
mov edi,@lpReadIndexBuf
Check:
push ecx
push esi
push edi
mov word ptr [edi+4],0
mov ecx,7
repz cmpsw                     
jz LastBlockFind
pop edi
add edi,32
pop esi
pop ecx
loop Check
jmp ReadErrorLastBlockFind:
pop edi
pop esi
pop ecx
add edi,14
HalfSearchFind:
add edi,2
mov eax,[edi]                                   ;此处不要忘记减1,最多45亿条记录 若一秒最多20条,最少可用8年 若一秒5条,最少30年
mov edx,[edi+4]
sub eax,1                                       ;索引号从1开始
sbb edx,0
mov esi,lpSeekIndexInfo
mov dword ptr [esi+16],eax
mov dword ptr [esi+20],edx
mov ebx,_dwDataRecordingSize                    ;此处由于32位运算限制了记录条数,以后将改为64位运算,取消这一限制
mul ebx
mov edi,[esi+4]
mov dword ptr [edi],eax
mov dword ptr [edi+4],edx
mov dword ptr [esi+8],1         ;先置找到标志,再置结束标志,为什么??????????
mov dword ptr [esi+12],1        ;注意结束查找标志应在取得记录偏移后才能置位,否则可能主线程已经被通知结束,而在读记录时发生错误
add esi,24
push esi
invoke QueryPerformanceCounter,esi
pop esi
push @dwSeekTimes
pop dword ptr [esi+8]
invoke VirtualFree,@lpReadIndexBuf,@dwReadIndexBufSize,MEM_DECOMMIT
invoke VirtualFree,@lpReadIndexBuf,0,MEM_RELEASE
invoke CloseHandle,@stOverlappedRead.hEvent
leave
retn 4
_ThreadSeekIndex endp;1个点2个OVERLAPPED结构,每个OVERLAPPED结构32字节,1024个采样点为单位
;开辟64k字节内存存放OVERLAPPED结构,每个OVERLAPPED结构32字节,共2048个OVERLAPPED结构
_ProcOverlappedRead proc,lpThreadParam
local @dqRecordTimePtr:qword
local @dqRecordValuePtr:qword
local @lpOverlappedInfo
local @dwOverlappedInfoSize
local @lpOverlappedInfoPtr
local @lpOverlappedInfoLimit
local @lpQueryBuf
local @lpQueryDataBufPointer
local @lpQueryTimeBufPointer
local @lpReadBuf
local @dwReadBufSize
local @dwSectorDetail
local @dwReadRecordSum
local @dwReadTimeSectorCnt
local @dwReadValueSectorCnt
local @dwCounter
local @dwElementCnt
local @dwOutStandingCnt
local @dwReadSuccessCnt
local @dwResendCnt;local @dwReadSectorErrorCnt   
;local @dwSectorDetail
;local @dwReadRecordSum
;local @lpQueryDataBuf
;local @dqDataPointer:qword
;local @dqRecordHeadPointer:qword               ;<---参数入口指针mov esi,lpThreadParam
mov eax,[esi]
mov edx,[esi+4]
mov dword ptr [@dqRecordTimePtr],eax
mov dword ptr [@dqRecordTimePtr+4],edx
mov eax,[esi+8]
mov edx,[esi+12]
mov dword ptr [@dqRecordValuePtr],eax
mov dword ptr [@dqRecordValuePtr+4],edx
mov eax,[esi+16]
mov @lpQueryBuf,eax
mov eax,[esi+20]
mov @dwReadRecordSum,eax
mov eax,[esi+24]
mov @dwSectorDetail,eaxmov @dwOverlappedInfoSize,4000h
invoke VirtualAlloc,0,@dwOverlappedInfoSize,MEM_COMMIT,PAGE_READWRITE
mov @lpOverlappedInfo,eax
mov @lpOverlappedInfoPtr,eax
mov ecx,dword ptr @dwReadRecordSum
cmp ecx,256                           
jb ReadCntMinor
mov ecx,256
ReadCntMinor:
mov @dwElementCnt,ecx
mov eax,32
shl eax,1                               
mul ecx
add eax,@lpOverlappedInfo
mov @lpOverlappedInfoLimit,eax
mov @dwReadBufSize,40000h
invoke VirtualAlloc,0,@dwReadBufSize,MEM_COMMIT,PAGE_READWRITE
mov @lpReadBuf,eaxmov @lpQueryDataBufPointer,0
mov esi,@lpReadBuf
mov edi,@lpOverlappedInfo
mov ecx,@dwElementCnt
InitOverlapped:
push ecx
push esi
push edi
mov [edi+20],esi
mov eax,dword ptr [@dqRecordTimePtr]
mov edx,dword ptr [@dqRecordTimePtr+4]
mov [edi+8],eax
mov [edi+12],edx
add eax,_dwDataRecordingSize
adc edx,0
mov dword ptr [@dqRecordTimePtr],eax
mov dword ptr [@dqRecordTimePtr+4],edx
push edi
invoke CreateEvent,0,TRUE,0,0
pop edi
mov [edi+16],eax
mov eax,@lpQueryDataBufPointer
add eax,@lpQueryBuf
mov [edi+24],eax
add dword ptr @lpQueryDataBufPointer,sizeof SYSTEMTIME          ;这里目的指针分别加
pop edi
add edi,32
pop esi
add esi,_dwBytesPerSecpush esi
push edi
mov [edi+20],esi
mov eax,dword ptr [@dqRecordValuePtr]
mov edx,dword ptr [@dqRecordValuePtr+4]
mov [edi+8],eax
mov [edi+12],edx
add eax,_dwDataRecordingSize
adc edx,0
mov dword ptr [@dqRecordValuePtr],eax
mov dword ptr [@dqRecordValuePtr+4],edx
push edi
invoke CreateEvent,0,TRUE,0,0
pop edi
mov [edi+16],eax
mov eax,@lpQueryDataBufPointer
add eax,@lpQueryBuf
mov [edi+24],eax
add dword ptr @lpQueryDataBufPointer,4
pop edi
add edi,32
pop esi
add esi,_dwBytesPerSec
pop ecx
dec ecx
cmp ecx,0
jnz InitOverlappedmov ecx,@dwElementCnt
shl ecx,1
mov esi,@lpOverlappedInfo
LaunchRead:
push ecx
OverlappedReread:
push esi
invoke ReadFile,_hFileDataBase,dword ptr [esi+20],_dwBytesPerSec,addr @dwCounter,esi    ;地址怎样寻址?实际上参数入栈已经寻址完毕
cmp eax,0
jnz CheckDirectRead
invoke GetLastError
cmp eax,ERROR_IO_PENDING
jz SuccessLaunch
cmp eax,ERROR_INVALID_USER_BUFFER
jz BusyReading
cmp eax,ERROR_NOT_ENOUGH_MEMORY
jz BusyReading
pop esi
pop ecx
jmp ReadSectorError
CheckDirectRead:                        ;若是直接读完了,OVERLAPPED内部状态字节不变
mov eax,@dwCounter
cmp eax,_dwBytesPerSec
jz SuccessLaunch
pop esi
pop ecx
jmp ReadSectorError
BusyReading:
pop esi
mov dword ptr [esi],0
mov dword ptr [esi+4],0
invoke Sleep,0
jmp OverlappedReread
SuccessLaunch:
pop esi
add esi,32
pop ecx
loop LaunchReadmov eax,_dwDataRecordingSize
mov ebx,64
mul ebx
push eax
push edx
mov esi,lpThreadParam
add eax,dword ptr [esi]
adc edx,dword ptr [esi+4]
mov dword ptr [@dqRecordTimePtr],eax
mov dword ptr [@dqRecordTimePtr+4],edx
pop edx
pop eax
add eax,dword ptr [esi+8]
adc edx,dword ptr [esi+12]
mov dword ptr [@dqRecordValuePtr],eax
mov dword ptr [@dqRecordValuePtr+4],edx
mov eax,sizeof SYSTEMTIME
add eax,4
mov ebx,64
mul ebx
add eax,@lpQueryBuf
mov @lpQueryTimeBufPointer,eax
add eax,sizeof SYSTEMTIME
mov @lpQueryDataBufPointer,eax
mov @dwReadTimeSectorCnt,0
mov @dwReadValueSectorCnt,0
mov @dwOutStandingCnt,0
mov @dwReadSuccessCnt,0
mov @dwResendCnt,0;检测OVERLAPPED状态,如果读完则取出放到缓冲区并发送下一个读请求,如果错误退出,如果没读完检测下一个
CheckTimeOverlappedStatus:
mov eax,@dwReadTimeSectorCnt
cmp eax,@dwReadRecordSum
jnz TimeCntLess
mov eax,@dwReadValueSectorCnt
cmp eax,@dwReadRecordSum
jz ReadOverlappedEnd
jmp CheckValueOverlappedStausTimeCntLess:
mov esi,@lpOverlappedInfoPtr
lodsd
cmp eax,STATUS_PENDING          ;每次发送都确保内核成功接收读请求,不会有别的值,只有等待和成功
jnz SendTimeRequestOk
inc @dwOutStandingCnt
jmp CheckTimeOverlappedEnd
SendTimeRequestOk:
cmp eax,STATUS_SUCCESS                 
jnz ReadSectorError                       
lodsd
cmp eax,_dwBytesPerSec
jnz ReadSectorError
inc @dwReadSuccessCnt
push esi
mov edi,[esi+16]
mov esi,[esi+12]
mov ecx,4
rep movsd
pop esi
inc dword ptr @dwReadTimeSectorCnt
mov dword ptr [esi-8],0
mov dword ptr [esi-4],0
mov eax,dword ptr [@dqRecordTimePtr]
mov edx,dword ptr [@dqRecordTimePtr+4]
mov dword ptr [esi],eax
mov dword ptr [esi+4],edx
add eax,_dwDataRecordingSize
adc edx,0
mov dword ptr [@dqRecordTimePtr],eax
mov dword ptr [@dqRecordTimePtr+4],edx
mov eax,@lpQueryTimeBufPointer
mov [esi+16],eax
add eax,sizeof SYSTEMTIME
add eax,4
mov @lpQueryTimeBufPointer,eax
sub esi,8
SendReadTimeOverlapped:
invoke ReadFile,_hFileDataBase,dword ptr [esi+20],_dwBytesPerSec,addr @dwCounter,esi
cmp eax,0
jnz CheckReadTimeDirect
invoke GetLastError
cmp eax,ERROR_IO_PENDING
jz CheckTimeOverlappedEnd
cmp eax,ERROR_INVALID_USER_BUFFER
jz ReadTimeBusying
cmp eax,ERROR_NOT_ENOUGH_MEMORY
jz ReadTimeBusying
jmp ReadSectorError 
CheckReadTimeDirect:
mov eax,@dwCounter
cmp eax,_dwBytesPerSec
jz CheckTimeOverlappedEnd
jmp ReadSectorError
ReadTimeBusying:
inc @dwResendCnt
;cmp @dwResendCnt,4
;invoke Sleep,128
TimeRequestNotVeryBusy:
invoke SwitchToThread
cmp eax,0
jz TimeRequestNotVeryBusy
mov esi,@lpOverlappedInfoPtr
mov dword ptr [esi],0
mov dword ptr [esi+4],0
jmp SendReadTimeOverlappedCheckTimeOverlappedEnd:
add @lpOverlappedInfoPtr,32CheckValueOverlappedStaus:
mov eax,@dwReadValueSectorCnt
cmp eax,@dwReadRecordSum
jnz ValueCntLess
mov eax,@dwReadTimeSectorCnt
cmp eax,@dwReadRecordSum
jz ReadOverlappedEnd
jmp CheckTimeOverlappedStatusValueCntLess:
mov esi,@lpOverlappedInfoPtr
lodsd
cmp eax,STATUS_PENDING
jnz SendValueRequestOk
inc @dwOutStandingCnt
jmp CheckValueOverlappedEnd
SendValueRequestOk:
cmp eax,STATUS_SUCCESS 
jnz ReadSectorError
lodsd
cmp eax,_dwBytesPerSec
jnz ReadSectorError
push esi
mov edi,[esi+16]
mov esi,[esi+12]
add esi,@dwSectorDetail
movsd
pop esi
inc dword ptr @dwReadValueSectorCnt
mov dword ptr [esi-8],0
mov dword ptr [esi-4],0
mov eax,dword ptr [@dqRecordValuePtr]
mov edx,dword ptr [@dqRecordValuePtr+4]
mov dword ptr [esi],eax
mov dword ptr [esi+4],edx
add eax,_dwDataRecordingSize
adc edx,0
mov dword ptr [@dqRecordValuePtr],eax
mov dword ptr [@dqRecordValuePtr+4],edx
mov eax,@lpQueryDataBufPointer
mov [esi+16],eax
add eax,sizeof SYSTEMTIME
add eax,4
mov @lpQueryDataBufPointer,eax
sub esi,8
SendReadValueOverlapped:
invoke ReadFile,_hFileDataBase,dword ptr [esi+20],_dwBytesPerSec,addr @dwCounter,esi
cmp eax,0
jnz CheckReadValueDirect
invoke GetLastError
cmp eax,ERROR_IO_PENDING
jz CheckValueOverlappedEnd
cmp eax,ERROR_INVALID_USER_BUFFER
jz ReadValueBusying
cmp eax,ERROR_NOT_ENOUGH_MEMORY
jz ReadValueBusying
jmp ReadSectorError
CheckReadValueDirect:
mov eax,@dwCounter
cmp eax,_dwBytesPerSec
jz CheckValueOverlappedEnd
jmp ReadSectorError
ReadValueBusying:
inc @dwResendCnt
;cmp @dwResendCnt,16
;invoke Sleep,128
ValueRequestNotVeryBusy:
invoke SwitchToThread
cmp eax,0
jz ValueRequestNotVeryBusy
mov esi,@lpOverlappedInfoPtr
mov dword ptr [esi],0
mov dword ptr [esi+4],0
jmp SendReadValueOverlappedCheckValueOverlappedEnd:
add @lpOverlappedInfoPtr,32
mov esi,@lpOverlappedInfoPtr
cmp esi,@lpOverlappedInfoLimit
jnz CheckTimeOverlappedStatus
mov esi,@lpOverlappedInfo
mov @lpOverlappedInfoPtr,esi
mov eax,@dwOutStandingCnt
mov ebx,@dwElementCnt
shr ebx,1
cmp eax,ebx
jbe ContinueExcution
;AllRequestNotVeryBusy:
;invoke SwitchToThread
;cmp eax,0
;jz AllRequestNotVeryBusy
invoke Sleep,128
ContinueExcution:
mov @dwOutStandingCnt,0
mov @dwReadSuccessCnt,0
mov @dwResendCnt,0
jmp CheckTimeOverlappedStatusReadOverlappedEnd:
invoke VirtualFree,@lpReadBuf,@dwReadBufSize,MEM_DECOMMIT
invoke VirtualFree,@lpReadBuf,0,MEM_RELEASE 
mov esi,@lpOverlappedInfo
mov ecx,@dwElementCnt
FreeOverlappedEvent:
push ecx
push esi
invoke CloseHandle,dword ptr [esi+16]
pop esi
add esi,32
pop ecx
loop FreeOverlappedEvent
invoke VirtualFree,@lpReadBuf,@dwReadBufSize,MEM_DECOMMIT
invoke VirtualFree,@lpReadBuf,0,MEM_RELEASE 
mov esi,lpThreadParam
mov dword ptr [esi+28],0
leave
retn 4ReadSectorError:
invoke VirtualFree,@lpReadBuf,@dwReadBufSize,MEM_DECOMMIT
invoke VirtualFree,@lpReadBuf,0,MEM_RELEASE 
mov esi,@lpOverlappedInfo
mov ecx,@dwElementCnt
FreeOverlapped:
push ecx
push esi
invoke CloseHandle,dword ptr [esi+16]
pop esi
add esi,32
pop ecx
loop FreeOverlapped
invoke VirtualFree,@lpOverlappedInfo,@dwOverlappedInfoSize,MEM_DECOMMIT
invoke VirtualFree,@lpOverlappedInfo,0,MEM_RELEASE 
mov esi,lpThreadParam
mov dword ptr [esi+28],1
leave
retn 4
_ProcOverlappedRead endp;local @dwReadSliceErrorCnt
;local @dwSectorDetail
;local @dqDataPointer:qword
;local @lpQueryDataBuf 
;local @lpReadSliceBuf
;local @dwThreadReadSliceCnt            ;<---参数入口指针
;local @dqRecordHeadPointer:qword
;local @dwSeekCntPerThread_ThreadReadSector proc,lpThreadParam
local @stOverlappedData:OVERLAPPED
local @stOverlappedTime:OVERLAPPED
local @dwTimeReadCnt
local @dwDataReadCntlocal @dwSectorDetail
local @lpQueryDataPointer
local @lpReadValueBufPointer
local @lpReadTimeBufPointer
local @dwSeekCntPerThreadinvoke EnterCriticalSection,addr _stCriticalTransInfo          ;加上该函数出错!!!!!为什么
cld
mov esi,lpThreadParam
mov eax,dword ptr [esi]
mov ebx,4
add ebx,sizeof SYSTEMTIME
mul ebx
add eax,dword ptr [esi+8]
mov @lpQueryDataPointer,eaxmov eax,dword ptr [esi]                 ;注意:为何不能改变数据段地址?因为主程序还要释放该内存,若是改变了改地址,释放时出错
shl eax,1
mov ebx,_stSystemInfo.dwPageSize
mul ebx
add eax,dword ptr [esi+4]
mov @lpReadTimeBufPointer,eax
add eax,_stSystemInfo.dwPageSize
mov @lpReadValueBufPointer,eax
lock inc dword ptr [esi]                ;lock 指令只能用于运算指令lea edi,@stOverlappedTime
mov dword ptr [edi],0
mov dword ptr [edi+4],0
mov eax,[esi-8]
mov edx,[esi-4]
mov dword ptr [edi+8],eax
mov dword ptr [edi+12],edx
mov eax,_dwDataRecordingSize
lock add dword ptr [esi-8],eax
lock adc dword ptr [esi-4],0lea edi,@stOverlappedData
mov dword ptr [edi],0
mov dword ptr [edi+4],0
mov eax,[esi+12]
mov edx,[esi+16]
mov dword ptr [edi+8],eax
mov dword ptr [edi+12],edx
mov eax,_dwDataRecordingSize
lock add dword ptr [esi+12],eax
lock adc dword ptr [esi+16],0
invoke LeaveCriticalSection,addr _stCriticalTransInfomov eax,[esi+20]
mov @dwSectorDetail,eax
mov @dwSeekCntPerThread,0invoke CreateEvent,0,TRUE,0,0
cmp eax,0
jz CreateEventFirstFailure
mov @stOverlappedTime.hEvent,eax
invoke CreateEvent,0,TRUE,0,0
cmp eax,0
jnz CreateEventAllOk
invoke CloseHandle,@stOverlappedTime.hEvent
CreateEventFirstFailure:
mov esi,lpThreadParam
lock dec dword ptr [esi]
leave 
retn 4
CreateEventAllOk:
mov @stOverlappedData.hEvent,eaxmov eax,[esi+12]
mov edx,[esi+16]
sub eax,dword ptr [esi-8]
sbb edx,dword ptr [esi-4]
cmp eax,_dwBytesPerSec
jae ReadAllSectorReadTimeSector:
invoke ReadFile,_hFileDataBase,@lpReadTimeBufPointer,_dwBytesPerSec,addr @dwTimeReadCnt,addr @stOverlappedTime.if eax==0invoke GetLastError.if eax==ERROR_IO_PENDINGinvoke WaitForSingleObject,@stOverlappedTime.hEvent,INFINITEinvoke GetOverlappedResult,_hFileDataBase,addr @stOverlappedTime,addr @dwTimeReadCnt,TRUEmov eax,@dwTimeReadCnt.if eax==_dwBytesPerSecGetQueryInfo:mov esi,@lpReadTimeBufPointermov edi,@lpQueryDataPointermov ecx,4rep movsdmov esi,@lpReadTimeBufPointeradd esi,@dwSectorDetailmovsdCheckReadTimeSectorEnd:inc @dwSeekCntPerThreadmov eax,@dwSeekCntPerThreadmov esi,lpThreadParamcmp eax,[esi-12]jae ThreadWorkEndmov eax,4add eax,sizeof SYSTEMTIMEmov ebx,_stSystemInfo.dwNumberOfProcessorsshl ebx,THREAD_CPU_RATIOmul ebxadd @lpQueryDataPointer,eaxlea esi,@stOverlappedTimemov dword ptr [esi],0mov dword ptr [esi+4],0mov eax,_dwDataRecordingSizemov ebx,_stSystemInfo.dwNumberOfProcessorsshl ebx,THREAD_CPU_RATIOmul ebxadd dword ptr [esi+8],eaxadc dword ptr [esi+12],edxjmp ReadTimeSector.elseReadTimeSectorError:mov esi,lpThreadParamlock dec dword ptr [esi]lock inc dword ptr [esi+24]invoke CloseHandle,@stOverlappedTime.hEventinvoke CloseHandle,@stOverlappedData.hEventleaveretn 4.endif.elseif eax==ERROR_INVALID_USER_BUFFERinvoke Sleep,0lea esi,@stOverlappedTimemov dword ptr [esi],0mov dword ptr [esi+4],0jmp ReadTimeSector.elseif eax==ERROR_NOT_ENOUGH_MEMORYinvoke Sleep,0lea esi,@stOverlappedTimemov dword ptr [esi],0mov dword ptr [esi+4],0jmp ReadTimeSector.elseif eax==ERROR_HANDLE_EOFjmp ThreadWorkEnd.elsejmp ReadTimeSectorError.endif .elsemov eax,@dwTimeReadCnt.if eax==_dwBytesPerSecjmp GetQueryInfo.elsejmp ReadTimeSectorError.endif.endifReadAllSector:
invoke ReadFile,_hFileDataBase,@lpReadTimeBufPointer,_dwBytesPerSec,addr @dwTimeReadCnt,addr @stOverlappedTime.if eax==0invoke GetLastError.if eax==ERROR_IO_PENDINGReadDataSector:invoke ReadFile,_hFileDataBase,@lpReadValueBufPointer,_dwBytesPerSec,addr @dwDataReadCnt,addr @stOverlappedData.if eax==0invoke GetLastError.if eax==ERROR_IO_PENDINGinvoke WaitForSingleObject,@stOverlappedTime.hEvent,INFINITEinvoke WaitForSingleObject,@stOverlappedData.hEvent,INFINITE                               invoke GetOverlappedResult,_hFileDataBase,addr @stOverlappedTime,addr @dwTimeReadCnt,TRUEinvoke GetOverlappedResult,_hFileDataBase,addr @stOverlappedData,addr @dwDataReadCnt,TRUECheckDataReadCnt:mov eax,@dwDataReadCnt.if eax==_dwBytesPerSecCheckTimeReadCnt:mov eax,@dwTimeReadCnt.if eax==_dwBytesPerSecjmp ReadNextSec.elseReadAllError:mov esi,lpThreadParamlock dec dword ptr [esi]lock inc dword ptr [esi+24]invoke CloseHandle,@stOverlappedTime.hEventinvoke CloseHandle,@stOverlappedData.hEventleaveretn 4.endif                                       .elsejmp ReadAllError.endif                                .elseif eax==ERROR_INVALID_USER_BUFFERinvoke Sleep,0lea esi,@stOverlappedDatamov dword ptr [esi],0mov dword ptr [esi+4],0jmp ReadDataSector.elseif eax==ERROR_NOT_ENOUGH_MEMORYinvoke Sleep,0lea esi,@stOverlappedDatamov dword ptr [esi],0mov dword ptr [esi+4],0jmp ReadDataSector.elseif eax==ERROR_HANDLE_EOFjmp ThreadWorkEnd.elsejmp ReadAllError.endif.elsemov eax,@dwDataReadCnt.if eax==_dwBytesPerSecinvoke GetOverlappedResult,_hFileDataBase,addr @stOverlappedTime,addr @dwTimeReadCnt,TRUEjmp CheckTimeReadCnt.elsejmp ReadAllError.endif.endif.elseif eax==ERROR_INVALID_USER_BUFFERinvoke Sleep,0lea esi,@stOverlappedTimemov dword ptr [esi],0mov dword ptr [esi+4],0jmp ReadAllSector.ELSEIF eax==ERROR_NOT_ENOUGH_MEMORYinvoke Sleep,0lea esi,@stOverlappedTimemov dword ptr [esi],0mov dword ptr [esi+4],0jmp ReadAllSector.elseif eax==ERROR_HANDLE_EOFjmp ThreadWorkEnd.elsejmp ReadAllError.endif .elsemov eax,@dwTimeReadCnt.if eax==_dwBytesPerSecjmp ReadDataSector.elsejmp ReadAllError.endif.endifReadNextSec:
mov esi,@lpReadTimeBufPointer
mov edi,@lpQueryDataPointer
mov ecx,4
rep movsd
mov esi,@lpReadValueBufPointer
add esi,@dwSectorDetail
movsdCheckReadAllEnd:
inc @dwSeekCntPerThread
mov eax,@dwSeekCntPerThread
mov esi,lpThreadParam
cmp eax,[esi-12]
jae ThreadWorkEndmov eax,4
add eax,sizeof SYSTEMTIME
mov ebx,_stSystemInfo.dwNumberOfProcessors
shl ebx,THREAD_CPU_RATIO
mul ebx
add @lpQueryDataPointer,eaxlea esi,@stOverlappedTime
mov dword ptr [esi],0
mov dword ptr [esi+4],0
mov eax,_dwDataRecordingSize
mov ebx,_stSystemInfo.dwNumberOfProcessors
shl ebx,THREAD_CPU_RATIO
mul ebx
add dword ptr [esi+8],eax
adc dword ptr [esi+12],edxlea esi,@stOverlappedData
add dword ptr [esi+8],eax
adc dword ptr [esi+12],edx
mov dword ptr [esi],0
mov dword ptr [esi+4],0
jmp ReadAllSectorThreadWorkEnd:
mov esi,lpThreadParam
lock dec dword ptr [esi]
invoke CloseHandle,@stOverlappedTime.hEvent
invoke CloseHandle,@stOverlappedData.hEvent
leave 
retn 4
_ThreadReadSector endp_ProcReadInterval proc,lpszPointId,lpQueryTimeHead,lpQueryTimeEnd,nSecInterval
local @dwGroupCnt
local @lpGroupBuf
local @dwGroupBufSize
local @lpReadParam
local @lpRecvBuf
local @dwItemCnt
local @dwTotalValuepush ebx
push esi
push edi
lock inc dword ptr [_dwRunningThreadCnt]               
invoke EnterCriticalSection,addr _stCriticalReadData
mov esi,_lpReadQueueInfoBuf
mov ebx,esi
add ebx,_dwReadQueueInfoBufSize
cld
CheckValidPos:
lodsd
cmp eax,0
jz GetValidPos
add esi,28              ;32B ervery struct
cmp esi,ebx
jb CheckValidPosinvoke LeaveCriticalSection,addr _stCriticalReadData
InvalidParam:
lock dec dword ptr [_dwRunningThreadCnt]               
pop edi
pop esi
pop ebx
mov eax,0
mov edx,0
leave
retn 16GetValidPos:
sub esi,4
mov @lpReadParam,esi
mov eax,lpszPointId
mov dword ptr [esi],eax
mov eax,lpQueryTimeHead
mov dword ptr [esi+4],eax
mov eax,lpQueryTimeEnd
mov dword ptr [esi+8],eaxinvoke CreateEvent,0,TRUE,0,0
mov esi,@lpReadParam
mov dword ptr [esi+12],eaxlea ebx,_ThreadReadData
invoke CreateThread,0,0,ebx,esi,0,0
invoke CloseHandle,eaxinvoke LeaveCriticalSection,addr _stCriticalReadData
mov esi,@lpReadParam
invoke WaitForSingleObject,dword ptr [esi+12],INFINITE
mov esi,@lpReadParam
invoke CloseHandle,dword ptr [esi+12]mov esi,@lpReadParam
mov esi,dword ptr [esi+16]
cmp esi,0
jz InvalidParam
mov @lpRecvBuf,esi
mov eax,nSecInterval
mov ebx,1000
mul ebx
mov ebx,_dwSamplePeriod
div ebx
mov @dwItemCnt,eax
mov ebx,eax
mov eax,dword ptr [esi+4]
mov edx,0
div ebx
cmp eax,0
jle InvalidParam
mov @dwGroupCnt,eax
mov ebx,4
add ebx,sizeof SYSTEMTIME
mul ebx
mov ebx,_stSystemInfo.dwPageSize
dec ebx
not ebx
and eax,ebx
add eax,_stSystemInfo.dwPageSize
add eax,_stSystemInfo.dwPageSize
mov @dwGroupBufSize,eax
invoke VirtualAlloc,0,@dwGroupBufSize,MEM_COMMIT,PAGE_READWRITE
mov @lpGroupBuf,eax
mov ecx,@dwGroupBufSize
mov dword ptr [eax],ecx
mov ecx,@dwGroupCnt
mov dword ptr [eax+4],ecx
add dword ptr @lpGroupBuf,8mov edi,@lpGroupBuf
mov esi,@lpRecvBuf
add esi,8
mov ecx,@dwGroupCnt
NextEverageValue:
push ecx
mov ecx,4
rep movsd
mov ecx,@dwItemCnt
mov @dwTotalValue,0
GetTotalValue:
lodsd
add @dwTotalValue,eax
add esi,sizeof SYSTEMTIME
loop GetTotalValue
mov eax,@dwTotalValue
mov edx,0
mov ebx,@dwItemCnt
div ebx
stosd
sub esi,sizeof SYSTEMTIME
pop ecx
loop NextEverageValuemov esi,@lpRecvBuf
mov ecx,dword ptr [esi]
invoke VirtualFree,@lpRecvBuf,ecx,MEM_DECOMMIT
invoke VirtualFree,@lpRecvBuf,0,MEM_RELEASEmov eax,@lpGroupBuf
sub eax,8
mov edx,0
pop edi
pop esi
pop ebx
lock dec dword ptr [_dwRunningThreadCnt]               
leave 
retn 16
_ProcReadInterval endp_ThreadWaitSamplePeriod proc
local @dqPrevRecvPackCnt:qword
local @dwCountercld
lock inc dword ptr [_dwRunningThreadCnt]
mov eax,dword ptr [_dqRecvPackCnt]
mov edx,dword ptr [_dqRecvPackCnt+4]
mov dword ptr [@dqPrevRecvPackCnt],eax
mov dword ptr [@dqPrevRecvPackCnt+4],edx
mov ecx,_dwSamplePeriod
shl ecx,BUF_MULTI_RATIO
invoke Sleep,ecxWaitTime:
cmp dword ptr _flTerminate,1
jz KillThisThread
invoke Sleep,_dwSamplePeriod
mov eax,dword ptr [_dqRecvPackCnt]
mov edx,dword ptr [_dqRecvPackCnt+4]
cmp eax,dword ptr [@dqPrevRecvPackCnt]
jz WaitTimemov dword ptr [@dqPrevRecvPackCnt],eax
mov dword ptr [@dqPrevRecvPackCnt+4],edx
push ebp
lea ebx,_ProcExceptionGuard
push ebx
assume fs:nothing
push fs:[0]
mov fs:[0],esp
mov esi,_lpRecordingBufHead
invoke GetLocalTime,esi                  ;GetLocalTime参数是否只能先定义为SYSTEMTIME结构?空下16个字节不行么?????行!!!!!
mov esi,_lpRecordingBufHead
mov edi,_lpRecordingIndexBufHead
mov ecx,8
rep movsw
mov eax,dword ptr [_dqRecordingCntSum]
mov edx,dword ptr [_dqRecordingCntSum+4]
add eax,1
adc edx,0
mov dword ptr [_dqRecordingCntSum],eax
mov dword ptr [_dqRecordingCntSum+4],edx 
stosd
mov eax,edx
stosd mov eax,_lpRecordingBufHead             ;保存固定地址,实时值计算地址可以直接计算
mov _lpRealTimeDataBuf,eax
invoke SetEvent,_hEventRealTimeData
mov eax,_dwDataRecordingSize
lock xadd _lpRecordingBufHead,eax
mov ebx,RECORDING_INDEX_SIZE
lock xadd _lpRecordingIndexBufHead,ebx
mov eax,_lpRecordingIndexBufHead
cmp eax,_lpRecordingIndexBufLimit
jb ToWaitTime
sub eax,_lpRecordingIndexBuf
mov ebx,_dwBytesPerSec
dec ebx
and eax,ebx
cmp eax,0
jnz ToWaitTimecmp dword ptr _flWriteBusying,1
jz ToWaitTime
mov eax,dword ptr [_dqRecordingCntSum]
mov edx,dword ptr [_dqRecordingCntSum+4]
mov dword ptr [_dqFileTotalRecording],eax
mov dword ptr [_dqFileTotalRecording+4],edx
;先换头指针,再换基地址,最后交换界限,为什么?????
mov ebx,_lpRecordReservedBuf
lock xchg dword ptr _lpRecordingBuf,ebx
mov _lpRecordReservedBuf,ebx
mov ecx,_lpRecordingBufHead
lock xchg dword ptr _lpRecordReservedBufHead,ecx
mov _lpRecordingBufHead,ecx
mov ebx,_lpRecordReservedBufLimit
lock xchg dword ptr _lpRecordingBufLimit,ebx
mov _lpRecordReservedBufLimit,ebx
mov esi,_lpIndexReservedBuf
lock xchg dword ptr _lpRecordingIndexBuf,esi
mov _lpIndexReservedBuf,esi
mov edx,_lpRecordingIndexBufHead
lock xchg dword ptr _lpIndexReservedBufHead,edx
mov _lpRecordingIndexBufHead,edx
mov esi,_lpIndexReservedBufLimit
lock xchg dword ptr _lpRecordingIndexBufLimit,esi
mov _lpIndexReservedBufLimit,esi
invoke SetEvent,_hEventStoreRecordingToWaitTime:
pop fs:[0]
add esp,8
jmp WaitTimeKillThisThread:
lock dec dword ptr [_dwRunningThreadCnt]
invoke SetEvent,_hEventStoreRecording                   ;用于控制写记录的线程结束
invoke WriteFile,_hFileJournal,addr szWaitSamplePeriodQuit,sizeof szWaitSamplePeriodQuit-1,addr @dwCounter,0
leave
retn 0
_ThreadWaitSamplePeriod endp;若是开启多个线程,还要解决多个线程的共享问题
_ThreadRecvUdpPack proc
local @szBuf[100h]:byte
local @szBuffer[80h]:byte
local @dwCounter
local @stSendAddr:sockaddr_in
local @dwSendAddrSize:dwordmov @dwSendAddrSize,sizeof sockaddr_in
lock inc dword ptr [_dwRunningThreadCnt]
cldRecvUdpData:
invoke recvfrom,_hSockRecv,_lpUdpPackRecvBufHead,UDP_PACKAGE_SIZE,0,addr @stSendAddr,addr @dwSendAddrSize
cmp eax,SOCKET_ERROR
jz RecvFromError
cmp eax,UDP_PACKAGE_SIZE
jnz RecvFromErrorinc dword ptr [_dqRecvPackCnt]
adc dword ptr [_dqRecvPackCnt+4],0mov edi,_lpUdpPackAddrBufHead
mov eax,_lpUdpPackRecvBufHead
stosd
cmp edi,_lpUdpPackAddrBufLimit
jb PacketBufNotEnd
mov edi,_lpUdpPackAddrBuf
PacketBufNotEnd:
mov _lpUdpPackAddrBufHead,edimov eax,_lpUdpPackRecvBufHead
add eax,UDP_PACKAGE_SIZE
cmp eax,_lpUdpPackRecvBufLimit
jb RecvNextUdpData
mov eax,_lpUdpPackRecvBuf
RecvNextUdpData:
mov _lpUdpPackRecvBufHead,eax
jmp RecvUdpDataRecvFromError:
lea eax,@szBuffer
push eax
call _ProcSysTimeToAsc
invoke wsprintf,addr @szBuf,addr szRecvUdpPackError,addr @szBuffer
mov ecx,eax
invoke WriteFile,_hFileJournal,addr @szBuf,ecx,addr @dwCounter,0
lock dec dword ptr [_dwRunningThreadCnt]
leave
retn 0
_ThreadRecvUdpPack endp_ThreadUdpUnpack proc
local @szBuf[100h]:byte
local @szBuffer[80h]:byte
local @dwCounterlock inc dword ptr [_dwRunningThreadCnt]
cld
NoPackNow:
cmp dword ptr _flTerminate,1
jz KillThisThread
invoke Sleep,SMALLEST_SAMPLE_PERIOD                         
mov esi,_lpUdpPackAddrBufEnd
cmp esi,_lpUdpPackAddrBufHead
jz NoPackNowUnPackUdpData:
push ebp
lea ebx,_ProcExceptionGuard
push ebx
assume fs:nothing
push fs:[0]
mov fs:[0],esp
mov esi,_lpUdpPackAddrBufEnd
lodsd
mov esi,eax
test word ptr [esi+10],BOOL_PACK_FLAG
jnz BoolDataFloatData:
movzx ecx,word ptr [esi+8]              ;注意MOVZX指令的用法!!!!!
cmp ecx,0
jz UnpackNext
shr ecx,3
add esi,UDP_PACKAGE_HEADER_SIZE
CopyFloatData:
lodsw
movzx edi,ax                            ;注意MOVZX指令的用法!!!!!
shl edi,2
add edi,sizeof SYSTEMTIME
add edi,dword ptr [_lpRecordingBufHead]
add esi,2
movsd
loop CopyFloatData
jmp UnpackNextBoolData:
movzx ecx,word ptr [esi+8]
cmp ecx,0
jz UnpackNext
shr ecx,2
add esi,UDP_PACKAGE_HEADER_SIZE
CopyBoolData:
lodsw
movzx edi,ax
shl edi,2
add edi,sizeof SYSTEMTIME
add edi,dword ptr [_lpRecordingBufHead]
lodsw
movzx eax,ax
stosd
loop CopyBoolDataUnpackNext:
inc dword ptr [_dqUnPackCnt]
adc dword ptr [_dqUnPackCnt+4],0
pop fs:[0]
add esp,8
mov esi,_lpUdpPackAddrBufEnd
add esi,4
cmp esi,_lpUdpPackAddrBufLimit
jb PackEndNotReachLimit
mov esi,_lpUdpPackAddrBuf
PackEndNotReachLimit:
mov _lpUdpPackAddrBufEnd,esi
cmp esi,_lpUdpPackAddrBufHead
jnz UnPackUdpData
jmp NoPackNowKillThisThread:
lock dec dword ptr [_dwRunningThreadCnt]
invoke WriteFile,_hFileJournal,addr szUdpUnpackQuit,sizeof szUdpUnpackQuit-1,addr @dwCounter,0
leave
retn 0
_ThreadUdpUnpack endp;异常处理函数是由WINDOWS调用的,而且调用的时候是C格式调用,因此由WINDOWS负责恢复堆栈,所以RET返回时不必从堆栈弹出参数
;而且如果按照STDCALL方式弹出堆栈参数后,WINDOWS也会自己恢复原来保存在WINDOWS空间的堆栈,因此自己弹出调用堆栈参数也不出错
_ProcExceptionGuard proc,lpExceptionRecord,lpSeh,lpContext,lpDispatcher
local @szBuf[200h]:byte
local @szBuffer[100h]:byte
local @dwCounterpushad
mov esi,lpExceptionRecord
mov edi,lpContext
assume esi:ptr EXCEPTION_RECORD,edi:ptr CONTEXT
mov eax,[esi].ExceptionCode.if eax==STATUS_GUARD_PAGE_VIOLATIONmov ebx,lpSehmov [edi].regEsp,ebxpush [ebx+8]pop [edi].regEbppush esipush edilea eax,@szBufferpush eaxcall _ProcSysTimeToAscpop edipop esiinvoke wsprintf,addr @szBuf,addr szGuardPageViolation,addr @szBuffer,[esi].ExceptionAddress,[esi].ExceptionCode,\[esi].ExceptionFlags   assume esi:nothing,edi:nothingmov ecx,eaxinvoke WriteFile,_hFileJournal,addr @szBuf,ecx,addr @dwCounter,0popadmov eax,ExceptionContinueExecution       leaveretn 0.elseif eax==EXCEPTION_ACCESS_VIOLATIONAccessViolation:;invoke SuspendThread,_hThreadWaitSamplePeriod     ;加上这两个函数就卡住了,为什么??????????;invoke SuspendThread,_hThreadUdpUnpackmov esi,lpExceptionRecordmov edi,lpContext              assume esi:ptr EXCEPTION_RECORD,edi:ptr CONTEXTmov ebx,[esi].ExceptionFlagstest ebx,1jz ExceptionContinueablecall _ProcTerminateinvoke ExitProcess,0ExceptionContinueable:mov ebx,lpSehmov [edi].regEsp,ebxpush [ebx+8]pop [edi].regEbppush esipush edi              lea eax,@szBufferpush eaxcall _ProcSysTimeToAscpop edipop esiinvoke wsprintf,addr @szBuf,addr szMsgException,addr @szBuffer,[esi].ExceptionAddress,[esi].ExceptionCode,\[esi].ExceptionFlags   assume esi:nothing,edi:nothingmov ecx,eaxinvoke WriteFile,_hFileJournal,addr @szBuf,ecx,addr @dwCounter,0cmp _flMemoryNotEnough,1jz RequestMemoryErrormov ebx,_lpRecordingBufadd ebx,_dwRecordingBufSizemov ecx,_dwRecordingBackupBufSizesub ecx,_dwRecordingBufSizeinvoke VirtualAlloc,ebx,ecx,MEM_COMMIT,PAGE_READWRITEmov ebx,_lpRecordingIndexBufadd ebx,_dwRecordingIndexBufSizemov ecx,_dwIndexBackupBufSizesub ecx,_dwRecordingIndexBufSizeinvoke VirtualAlloc,ebx,ecx,MEM_COMMIT,PAGE_READWRITE                    invoke SetThreadPriority,_hThreadStoreRecording,THREAD_PRIORITY_HIGHESTmov _flReadWriteBusy,1mov _flMemoryNotEnough,1invoke WriteFile,_hFileJournal,addr szExceptionReadWriteBusy,sizeof szExceptionReadWriteBusy-1,addr @dwCounter,0;invoke ResumeThread,_hThreadWaitSamplePeriod   ;这两个函数不会得到执行,为什么??????????;invoke ResumeThread,_hThreadUdpUnpackpopadmov eax,ExceptionContinueExecutionleaveretn 0RequestMemoryError:mov ebx,_lpRecordingBuflock xchg dword ptr _lpRecordingBufHead,ebxmov edx,_lpRecordingIndexBuflock xchg dword ptr _lpRecordingIndexBufHead,edxinvoke SetThreadPriority,_hThreadStoreRecording,THREAD_PRIORITY_HIGHESTmov _flReadWriteBusy,1invoke WriteFile,_hFileJournal,addr szExceptionMemUnroll,sizeof szExceptionMemUnroll-1,addr @dwCounter,0popadmov eax,ExceptionContinueExecutionleaveretn 0.elseif eax==EXCEPTION_IN_PAGE_ERROR  ;0C0000006H               jmp AccessViolation.elseif eax==0c0000027hUnWindProc:invoke RtlUnwind,lpSeh,0,0,0assume esi:nothing,edi:nothingpopadmov eax,ExceptionContinueSearch            leaveretn 0.elseif eax==80000003h          ; int 3.elseif eax==0c000001dh         ; invalid instruction.elseif eax==0c0000094h         ;dividen by 0.elseif eax==80000004h          ;int 1.elseif eax==0c00000fdh         ;stack overflow.elsemov eax,dword ptr [esi+4]test eax,2jnz UnWindProctest eax,4jnz UnWindProcjmp AccessViolation.endif
assume esi:nothing,edi:nothing
popad
mov eax,ExceptionContinueSearch             
leave
retn 0
_ProcExceptionGuard endp;Functions such as ReadFile and WriteFile set event handle to the nonsignaled state before they begin an I/O operation. 
;When the operation has completed, the handle is set to the signaled state
_ThreadStoreRecording proc
align qword
local @dqBeginCount:qword
local @dqFileDataSize:qword
local @dqFileIndexSize:qword
local @dwRecordWriteCnt
local @dwIndexWriteCnt
local @stOverlappedRecord:OVERLAPPED
local @stOverlappedIndex:OVERLAPPED
local @dwRecordWriteSum
local @dwIndexWriteSum
local @szBuf[100h]:byte
local @szBuffer[80h]:byte
local @dwCounter
local @dwWriteErrorCodelock inc dword ptr [_dwRunningThreadCnt]
invoke CreateEvent,0,TRUE,0,0
mov @stOverlappedRecord.hEvent,eax
invoke CreateEvent,0,TRUE,0,0
mov @stOverlappedIndex.hEvent,eaxWaitWriteFile:
invoke WaitForSingleObject,_hEventStoreRecording,INFINITE
invoke ResetEvent,_hEventStoreRecording
cmp dword ptr [_flTerminate],1
jz TerminateThisThreadmov _flWriteBusying,1
invoke QueryPerformanceCounter,addr @dqBeginCount
mov ecx,_lpRecordReservedBufHead
sub ecx,_lpRecordReservedBuf 
mov @dwRecordWriteSum,ecx
mov eax,_lpIndexReservedBufHead 
sub eax,_lpIndexReservedBuf
mov @dwIndexWriteSum,eax    
lea esi,@stOverlappedIndex
mov dword ptr [esi+8],0ffffffffh
mov dword ptr [esi+12],0ffffffffh
lea edi,@stOverlappedRecord
mov dword ptr [edi+8],0ffffffffh
mov dword ptr [edi+12],0ffffffffh
invoke GetFileSizeEx,_hFileDataBase,addr @dqFileDataSize
invoke GetFileSizeEx,_hFileDataBase,addr @dqFileIndexSizeWriteData:
lea esi,@stOverlappedRecord
mov dword ptr [esi],0
mov dword ptr [esi+4],0                          
invoke WriteFile,_hFileDataBase,_lpRecordReservedBuf,dword ptr @dwRecordWriteSum,addr @dwRecordWriteCnt,addr @stOverlappedRecord.if eax==0invoke GetLastError.if eax==ERROR_IO_PENDINGWriteIndexAPC:lea esi,@stOverlappedIndexmov dword ptr [esi],0mov dword ptr [esi+4],0     invoke WriteFile,_hFileIndex,_lpIndexReservedBuf,dword ptr @dwIndexWriteSum,addr @dwIndexWriteCnt,\addr @stOverlappedIndex.if eax==0invoke GetLastError.if eax==ERROR_IO_PENDINGinvoke WaitForSingleObject,@stOverlappedIndex.hEvent,INFINITEinvoke GetOverlappedResult,_hFileIndex,addr @stOverlappedIndex,addr @dwIndexWriteCnt,TRUE    CheckWriteCnt:  invoke WaitForSingleObject,@stOverlappedRecord.hEvent,INFINITEinvoke GetOverlappedResult,_hFileDataBase,addr @stOverlappedRecord,addr @dwRecordWriteCnt,TRUE                                                     mov eax,@dwIndexWriteCnt.if eax==@dwIndexWriteSummov eax,@dwRecordWriteCnt.if eax==@dwRecordWriteSumjmp WriteFileOk.elseWriteError:                                          jmp WriteRecordingError              .endif.elsejmp WriteError.endif.elseif eax==ERROR_INVALID_USER_BUFFERinvoke Sleep,0jmp WriteIndexAPC.ELSEIF eax==ERROR_NOT_ENOUGH_MEMORYinvoke Sleep,0jmp WriteIndexAPC.elsejmp WriteError             .endif.elsemov eax,@dwIndexWriteCnt.if eax==@dwIndexWriteSumjmp CheckWriteCnt.elsejmp WriteError.endif.endif.elseif eax==ERROR_INVALID_USER_BUFFERinvoke Sleep,0jmp WriteData.ELSEIF eax==ERROR_NOT_ENOUGH_MEMORYinvoke Sleep,0jmp WriteData.else jmp WriteError.endif.elsemov eax,@dwRecordWriteCnt.if eax==@dwRecordWriteSumjmp WriteIndexAPC.elsejmp WriteError.endif.endif 
WriteFileOk:
mov edi,_lpRecordReservedBuf
mov ecx,_lpRecordReservedBufHead
sub ecx,edi
shr ecx,2
mov eax,INVALID_POINT_VALUE
rep stosd
mov edi,_lpIndexReservedBuf
mov ecx,_lpIndexReservedBufHead
sub ecx,edi
shr ecx,2
rep stosd
mov edx,_lpRecordReservedBuf
lock xchg dword ptr _lpRecordReservedBufHead,edx
mov ebx,_lpIndexReservedBuf
lock xchg dword ptr _lpIndexReservedBufHead,ebx   
lea esi,@dqBeginCount
lea ebx,_ThreadJournalOfWriteInfo
invoke CreateThread,0,0,ebx,esi,0,0
invoke CloseHandle,eax
;mov _flWriteBusying,0
cmp _flReadWriteBusy,1
jnz WaitWriteFilemov ebx,_lpIndexReservedBuf
add ebx,_dwRecordingIndexBufSize
mov ecx,_dwIndexBackupBufSize
sub ecx,_dwRecordingIndexBufSize
invoke IsBadWritePtr,ebx,ecx
cmp eax,0
jnz WaitWriteFile
mov ebx,_lpRecordReservedBuf
add ebx,_dwRecordingBufSize
mov ecx,_dwRecordingBackupBufSize
sub ecx,_dwRecordingBufSize
invoke VirtualFree,ebx,ecx,MEM_DECOMMIT 
mov ebx,_lpIndexReservedBuf
add ebx,_dwRecordingIndexBufSize
mov ecx,_dwIndexBackupBufSize
sub ecx,_dwRecordingIndexBufSize
invoke VirtualFree,ebx,ecx,MEM_DECOMMIT
invoke SetThreadPriority,_hThreadStoreRecording,THREAD_PRIORITY_NORMAL
mov _flReadWriteBusy,0
mov _flMemoryNotEnough,0
invoke WriteFile,_hFileJournal,addr szExceptionReadWriteNotBusy,sizeof szExceptionReadWriteNotBusy-1,addr @dwCounter,0
jmp WaitWriteFileWriteRecordingError:
lea eax,@szBuffer
push eax
call _ProcSysTimeToAsc
invoke GetLastError
mov @dwWriteErrorCode,eax
invoke wsprintf,addr @szBuf,addr szRecordingWriteError,addr @szBuffer,@dwWriteErrorCode
mov ecx,eax
invoke WriteFile,_hFileJournal,addr @szBuf,ecx,addr @dwCounter,0
lea esi,@stOverlappedRecord
mov eax,dword ptr [@dqFileDataSize]
mov edx,dword ptr [@dqFileDataSize+4]
mov dword ptr [esi+8],eax
mov dword ptr [esi+12],edx
lea edi,@stOverlappedIndex
mov eax,dword ptr [@dqFileIndexSize]
mov edx,dword ptr [@dqFileIndexSize+4]
mov dword ptr [edi+8],eax
mov dword ptr [edi+12],edx
jmp WriteData                    ;忽略错误,继续写入TerminateThisThread:
invoke CloseHandle,@stOverlappedRecord.hEvent
invoke CloseHandle,@stOverlappedIndex.hEvent
lock dec dword ptr [_dwRunningThreadCnt]
invoke WriteFile,_hFileJournal,addr szStoreRecordingQuit,sizeof szStoreRecordingQuit-1,addr @dwCounter,0
leave
retn 0
_ThreadStoreRecording endp;sizeof计算数据(包括数组、变量、类型、结构体等)所占内存空间,用字节数表示。
_ThreadJournalOfWriteInfo proc,lpBeginCount
align qword
local @dqBeginCount:qword
local @dqEndCount:qword
local @dqCountPerSec:qword
local @dqWriteRecordCost:qword
local @dwMicroSecPerSec
local @szBuffer[100h]:byte
local @szBuf[200h]:byte
local @dwCounterlock inc dword ptr [_dwRunningThreadCnt] 
mov dword ptr @dwMicroSecPerSec,1000000
mov esi,lpBeginCount
mov eax,[esi]
mov edx,[esi+4]
mov dword ptr [@dqBeginCount],eax
mov dword ptr [@dqBeginCount+4],edx
invoke QueryPerformanceCounter,addr @dqEndCount
invoke QueryPerformanceFrequency,addr @dqCountPerSec
finit
fild qword ptr @dqBeginCount
fild qword ptr @dqEndCount
fsub st(0),st(1)
fild dword ptr @dwMicroSecPerSec
fmul st(0),st(1)
fild qword ptr @dqCountPerSec
fdivp st(1),st(0)
fistp qword ptr @dqWriteRecordCost      ;fistp可弹出64为整数,fist只能弹出32为整数?????lea eax,@szBuffer
push eax
call _ProcSysTimeToAsc
invoke wsprintf,addr @szBuf,addr szJournalWrite,addr @szBuffer,dword ptr [_dqFileTotalRecording+4],\
dword ptr [_dqFileTotalRecording],dword ptr [@dqWriteRecordCost+4],dword ptr [@dqWriteRecordCost],\
dword ptr [_dqRecordingCntSum+4],dword ptr [_dqRecordingCntSum]
mov ecx,eax
invoke WriteFile,_hFileJournal,addr @szBuf,ecx,addr @dwCounter,0
invoke wsprintf,addr @szBuf,addr szJournalPack,addr @szBuffer,dword ptr dword ptr [_dqRecvPackCnt+4],dword ptr [_dqRecvPackCnt],\
dword ptr [_dqUnPackCnt+4],dword ptr [_dqUnPackCnt]
mov ecx,eax
invoke WriteFile,_hFileJournal,addr @szBuf,ecx,addr @dwCounter,0
lock dec dword ptr [_dwRunningThreadCnt]
leave
retn 4
_ThreadJournalOfWriteInfo endp_ThreadRealTimeData proc
local @dwQueryPointOrdinal
local @lpRltDataBufHead
local @lpRltDataBufEnd
local @lpDcsInputBufPointer
local @lpDcsInputBufcld
lock inc dword ptr [_dwRunningThreadCnt]WaitEventRealTimeData:
invoke WaitForSingleObject,_hEventRealTimeData,INFINITE
invoke ResetEvent,_hEventRealTimeData
cmp dword ptr [_flTerminate],1
jz TerminateThisThread
mov esi,_lpRltDataTableBuf
mov ecx,_dwRltDataTableBufSize
shr ecx,3
cld
CheckRealTimeDataRequest:
push ecx
push esi
lodsd
cmp eax,0ffffffffh
jnz GetValidRequest
CheckRequestEnd:
pop esi
add esi,8
pop ecx
loop CheckRealTimeDataRequest
jmp WaitEventRealTimeDataGetValidRequest:
mov @dwQueryPointOrdinal,eax
lodsd
cmp eax,[eax]
jnz CheckRequestEnd
mov @lpRltDataBufHead,eax
add eax,_stSystemInfo.dwPageSize
mov @lpRltDataBufEnd,eaxmov esi,@lpRltDataBufHead
mov edi,[esi+8]
mov esi,_lpRealTimeDataBuf
push esi
mov ecx,4
rep movsd
pop esi
mov ebx,@dwQueryPointOrdinal
shl ebx,2
add ebx,sizeof SYSTEMTIME
add esi,ebx
movsd
cmp edi,@lpRltDataBufEnd
jb PointerInRange
mov esi,@lpRltDataBufHead
mov edi,esi
add edi,16
mov dword ptr [esi+8],edi
jmp CheckRequestEnd
PointerInRange:
mov esi,@lpRltDataBufHead
mov dword ptr [esi+8],edi
jmp CheckRequestEndTerminateThisThread:
lock dec dword ptr [_dwRunningThreadCnt]
leave
retn 0
_ThreadRealTimeData endp_ProcRegistryInfo proc,lpszPointId,flSignal
local @dwQueryPointOrdinal
local @dwQueryPointIdLen
local @lpPointDirFileEnd
local @lpRealTimeDataBufpush ebx
push esi
push edicld
mov esi,lpszPointId
GetPointIdLen:
lodsb
cmp al,0
jnz GetPointIdLen
dec esi
sub esi,lpszPointId
cmp esi,0
jz ParamError
mov @dwQueryPointIdLen,esiinvoke EnterCriticalSection,addr _stCriticalPointDir
mov ebx,_lpPointDirBuf
add ebx,_dwPointDirBufSize
mov @lpPointDirFileEnd,ebx
mov @dwQueryPointOrdinal,0
mov esi,_lpPointDirBuf
SeekFirstDot:
lodsb
cmp al,2ch
jnz SeekFirstDot
SeekSecondDot:
lodsb
cmp al,2ch
jnz SeekSecondDot
mov edi,lpszPointId
mov ecx,@dwQueryPointIdLen
repz cmpsb
jz CheckLastChar
GetEnterSymbol:
lodsb
cmp esi,@lpPointDirFileEnd
jae ParamError
cmp al,0ah
jnz GetEnterSymbol
inc @dwQueryPointOrdinal
jmp SeekFirstDotParamError:
invoke LeaveCriticalSection,addr _stCriticalPointDir
pop edi
pop esi
pop ebx
mov eax,0
mov edx,0
leave
retn 8CheckLastChar:
lodsb
cmp al,2ch
jnz ParamError
invoke LeaveCriticalSection,addr _stCriticalPointDir
cmp flSignal,0
jz CancelRegistryInfomov esi,_lpRltDataTableBuf
mov ecx,_dwRltDataTableBufSize
shr ecx,3
CheckEmptyRoom:
push ecx
push esi
lodsd
cmp eax,0ffffffffh
jz GetEmptyRoom
pop esi
add esi,8
pop ecx
loop CheckEmptyRoom
jmp RealTimeDataInfoBufFullGetEmptyRoom:
invoke VirtualAlloc,NULL,_stSystemInfo.dwPageSize,MEM_COMMIT,PAGE_READWRITE
mov @lpRealTimeDataBuf,eax
pop esi
pop ecx
mov ebx,@dwQueryPointOrdinal
mov dword ptr [esi],ebx
mov dword ptr [esi+4],eax
mov edi,@lpRealTimeDataBuf
mov dword ptr [edi],eax
add eax,16
mov dword ptr [edi+4],eax
mov dword ptr [edi+8],eax
pop edi
pop esi
pop ebx
mov eax,1
mov edx,0
leave
retn 8RealTimeDataInfoBufFull:
pop edi
pop esi
pop ebx
mov eax,0
mov edx,0
leave
retn 8CancelRegistryInfo:
mov esi,_lpRltDataTableBuf
mov ecx,_dwRltDataTableBufSize
shr ecx,3
CheckPointOrdinal:
push ecx
push esi
lodsd
cmp eax,@dwQueryPointOrdinal
jz GetPointOrdinal
pop esi
add esi,8
pop ecx
loop CheckPointOrdinal
jmp NotFoundPointOrdinalGetPointOrdinal:
pop esi
pop ecx
mov edi,[esi+4]
mov dword ptr [esi],0ffffffffh
mov dword ptr [esi+4],0ffffffffh
push edi
invoke VirtualFree,edi,_stSystemInfo.dwPageSize,MEM_DECOMMIT            ;此处内存已释放,总函数不必释放了
pop edi
invoke VirtualFree,edi,0,MEM_RELEASE
pop edi
pop esi
pop ebx
mov eax,1
mov edx,0
leave
retn 8NotFoundPointOrdinal:
pop edi
pop esi
pop ebx
mov eax,0
mov edx,0
leave
retn 8
_ProcRegistryInfo endp_ProcGetRealTimeData proc,lpszPointId
local @dwQueryPointOrdinal
local @dwQueryPointIdLen
local @lpPointDirFileEnd
local @lpQueryDataBuf
local @lpRealTimeDataBufHead
local @lpRealTimeDataBufEnd
local @dwRealTimeDataCntpush ebx
push esi
push edi
cld
mov esi,lpszPointId
GetPointIdLen:
lodsb
cmp al,0
jnz GetPointIdLen
dec esi
sub esi,lpszPointId
cmp esi,0
jz ErrorParam
mov @dwQueryPointIdLen,esiinvoke EnterCriticalSection,addr _stCriticalPointDir
mov ebx,_dwPointDirBufSize
add ebx,_lpPointDirBuf
mov @lpPointDirFileEnd,ebx
mov @dwQueryPointOrdinal,0
mov esi,_lpPointDirBuf
SeekFirstDot:
lodsb
cmp al,2ch
jnz SeekFirstDot
SeekSecondDot:
lodsb
cmp al,2ch
jnz SeekSecondDot
mov edi,lpszPointId
mov ecx,@dwQueryPointIdLen
repz cmpsb
jz CheckLastChar
GetEnterSymbol:
lodsb
cmp esi,@lpPointDirFileEnd
jae ErrorParam
cmp al,0ah
jnz GetEnterSymbol
inc @dwQueryPointOrdinal
jmp SeekFirstDotErrorParam:
invoke LeaveCriticalSection,addr _stCriticalPointDir
pop edi
pop esi
pop ebx
mov eax,0
mov edx,0
leave
retn 4CheckLastChar:
lodsb
cmp al,2ch
jnz ErrorParam
invoke LeaveCriticalSection,addr _stCriticalPointDir
mov esi,_lpRltDataTableBuf
mov ecx,_dwRltDataTableBufSize
shr ecx,3
CheckRltDataTable:
push ecx
push esi
lodsd
cmp eax,@dwQueryPointOrdinal
jz GetQueryPointOrdinal
pop esi
add esi,8
pop ecx
loop CheckRltDataTable
GetRealTimeDataError:
pop edi
pop esi
pop ebx
mov eax,0
mov edx,0
leave
retn 4GetQueryPointOrdinal:
pop esi
pop ecx
mov eax,[esi+4]
mov @lpRealTimeDataBufHead,eax
cmp eax,dword ptr [eax]
jnz GetRealTimeDataError
invoke VirtualAlloc,NULL,_stSystemInfo.dwPageSize,MEM_COMMIT,PAGE_READWRITE
mov @lpQueryDataBuf,eax
mov dword ptr [eax],eax
mov edi,eax
add edi,8                               ;接收缓冲比实时数据缓冲区大,因此复制时不会发生溢出mov ebx,@lpRealTimeDataBufHead
mov esi,[ebx+4]
mov edx,[ebx+8]
add ebx,_stSystemInfo.dwPageSize
mov @dwRealTimeDataCnt,0CopyDataToBuf:
cmp esi,edx
jz CopyDataOk
cmp esi,ebx
jae RewindEndPointer
CopyToBuf:
mov ecx,5
rep movsd
inc @dwRealTimeDataCnt
jmp CopyDataToBufRewindEndPointer:
mov esi,@lpRealTimeDataBufHead
add esi,16
jmp CopyDataToBufCopyDataOk:
mov edi,@lpRealTimeDataBufHead
mov [edi+4],esi
mov ebx,@lpQueryDataBuf
push @dwRealTimeDataCnt
pop dword ptr [ebx+4]
pop edi
pop esi
pop ebx
mov eax,@lpQueryDataBuf
mov edx,0
leave
retn 4
_ProcGetRealTimeData endp;所有的点的格式必须要保证格式,切最大长度不能超过256字节
_ProcInsertPoint proc stdcall,lpszPointID,lpszPointContent
local @dwDotCnt
local @lpCurrentRecordEnd
local @lpCurrentRecordHead
local @dwPointIdLen
local @dwPointContentLen
local @dwFileEndPos
local @lpInsertID
local @dwInsertIdLen
local @lpInsertHead
local @lpInsertEnd
local @flFound
local @lpszPointContent[200h]:byte
local @szBuf[200h]:byte
local @szBufTime[100h]:bytepush ebx
push esi
push edi
invoke EnterCriticalSection,addr _stCriticalPointDir
cmp dword ptr _dwPointDirBufSize,0
jz InvalidParamcld
mov esi,lpszPointID
GetPointIdLen:
lodsb
cmp al,0
jnz GetPointIdLen
dec esi              
sub esi,lpszPointID
cmp esi,0
jz InvalidParam
mov @dwPointIdLen,esimov esi,lpszPointContent
mov @dwDotCnt,0
GetInsertID:
lodsb
cmp al,2ch
jnz GetInsertID
inc @dwDotCnt
cmp @dwDotCnt,2
jnz GetInsertID
mov @lpInsertID,esimov @dwInsertIdLen,0
GetInsertIdLen:
lodsb
cmp al,2ch
jz GetInsertIdEnd
inc @dwInsertIdLen
jmp GetInsertIdLenGetInsertIdEnd:
cmp @dwInsertIdLen,0
jz InvalidParamGetPointContentLen:
lodsb
cmp al,0
jnz GetPointContentLen
dec esi              
sub esi,lpszPointContent
cmp esi,0
jz InvalidParam
mov @dwPointContentLen,esimov esi,lpszPointContent
lea edi,@lpszPointContent
mov ecx,@dwPointContentLen
rep movsb
mov eax,0a0dh
stosd
add @dwPointContentLen,2mov eax,_lpPointDirBuf
add eax,_dwPointDirBufSize
mov @dwFileEndPos,eaxmov esi,_lpPointDirBuf
mov @lpCurrentRecordHead,esi
GetCurrentRecordEnd:
lodsb
cmp al,0ah
jnz GetCurrentRecordEnd
mov @lpCurrentRecordEnd,esimov @flFound,0
mov @dwDotCnt,0
mov esi,_lpPointDirBuf
GetRecordId:
lodsb
cmp al,2ch
jnz GetRecordId
inc @dwDotCnt
cmp @dwDotCnt,2
jnz GetRecordIdmov @dwDotCnt,0
mov ecx,@dwInsertIdLen
mov edi,@lpInsertID
push esi
repz cmpsb
jnz CheckInsertID
lodsb
cmp al,2ch
jz FindSamePoint
;注意:  不能将比较运算完成后所得的ECX值作为比较相等的参考依据.原因是什么????????????
;原因:例如若要比较12的值是否相等,他们的长度都为1,比较完成后ECX==0,但是他们却不相等CheckInsertID:
pop esi
mov ecx,@dwPointIdLen
mov edi,lpszPointID
repz cmpsb
jnz GetCurrentRecordStart
lodsb
cmp al,2ch
jz GetNextRecordStart
;注意:  不能将比较运算完成后所得的ECX值作为比较相等的参考依据.原因是什么????????????
;原因:例如若要比较12的值是否相等,他们的长度都为1,比较完成后ECX==0,但是他们却不相等GetCurrentRecordStart:
lodsb
cmp esi,@dwFileEndPos
jae GetPointEnd                       
cmp al,0ah
jnz GetCurrentRecordStart
mov @lpCurrentRecordHead,esi
jmp GetRecordIdGetNextRecordStart:
mov dword ptr @flFound,1
push @lpCurrentRecordHead
pop @lpInsertHead
GetNextRecordStartAddr:
lodsb
cmp esi,@dwFileEndPos
jae FindPointEndLast                       
cmp al,0ah
jnz GetNextRecordStartAddr
mov @lpInsertEnd,esi
mov @lpCurrentRecordHead,esi
jmp GetRecordIdFindPointEndLast:
mov @lpInsertEnd,esiGetPointEnd:
mov @lpCurrentRecordEnd,esi
cmp @flFound,1
jnz InvalidParamstd
mov eax,@lpInsertHead
sub eax,_lpPointDirBuf
mov ecx,_dwPointDirBufSize
sub ecx,eax
mov esi,_lpPointDirBuf
add esi,_dwPointDirBufSize
dec esi
mov edi,esi
add edi,@dwPointContentLen
rep movsblea esi,@lpszPointContent
add esi,@dwPointContentLen
dec esi
mov ecx,@dwPointContentLen
rep movsbcld
mov ecx,@dwPointContentLen
add _dwPointDirBufSize,ecxmov esi,FILE_POINTDIR_SIZE
mov eax,_lpPointDirBuf
push _dwPointDirBufSize
pop dword ptr [esi+eax-4]mov eax,_dwFreeRecordCnt
cmp eax,0
jz NotEnoughSpace
lock inc dword ptr _dwDcsSampleCnt
lock dec _dwFreeRecordCntNotEnoughSpace:
invoke LeaveCriticalSection,addr _stCriticalPointDirlea eax,@szBufTime
push eax
call _ProcSysTimeToAscinvoke wsprintf,addr @szBuf,addr szPointInsert,addr @szBufTime,lpszPointID,lpszPointContent
mov ecx,eax
invoke WriteFile,_hFileJournal,addr @szBuf,ecx,addr @dwDotCnt,0pop edi
pop esi
pop ebx
mov eax,1
mov edx,0
leave
retn 8FindSamePoint:
pop esi
InvalidParam:
invoke LeaveCriticalSection,addr _stCriticalPointDir
pop edi
pop esi
pop ebx
mov eax,0
mov edx,0
leave
retn 8
_ProcInsertPoint endp_ProcAddPoint proc,lpszPointContent
local @dwPointContentLen
local @dwPointIdLen
local @dwFileEndPos
local @dwDotCnt
local @szBuf[200h]:byte
local @szBufTime[100h]:byte
local @lpPointIDpush ebx
push esi
push edi
invoke EnterCriticalSection,addr _stCriticalPointDircld
mov esi,lpszPointContent
mov @dwDotCnt,0
GetPointIdHeadPos:
lodsb
cmp al,2ch
jnz GetPointIdHeadPos
inc @dwDotCnt
cmp @dwDotCnt,2
jnz GetPointIdHeadPos
mov @lpPointID,esimov @dwPointIdLen,0
GetPointIdLen:
lodsb
cmp al,2ch
jz GetPointIdEndPos
inc @dwPointIdLen
jmp GetPointIdLenGetPointIdEndPos:
cmp @dwPointIdLen,0
jz KeepLenthGetPointContentLen:
lodsb
cmp al,0
jnz GetPointContentLen
dec esi              
sub esi,lpszPointContent
cmp esi,0
jz KeepLenth
mov @dwPointContentLen,esicmp dword ptr _dwPointDirBufSize,0
jz ToAddPointDirmov eax,_lpPointDirBuf
add eax,_dwPointDirBufSize
mov @dwFileEndPos,eaxmov @dwDotCnt,0                         
mov esi,_lpPointDirBuf
GetRecordId:                            ;检查是否有重复的数据记录
lodsb
cmp al,2ch
jnz GetRecordId
inc @dwDotCnt
cmp @dwDotCnt,2
jnz GetRecordIdmov @dwDotCnt,0
mov ecx,@dwPointIdLen
mov edi,@lpPointID
repz cmpsb
jnz GetCurrentRecordHead
lodsb
cmp al,2ch
jz KeepLenth
;注意:  不能将比较运算完成后所得的ECX值作为比较相等的参考依据.原因是什么????????????
;原因:例如若要比较12的值是否相等,他们的长度都为1,比较完成后ECX==0,但是他们却不相等GetCurrentRecordHead:
lodsb
cmp esi,@dwFileEndPos
jae ToAddPointDir                       
cmp al,0ah
jnz GetCurrentRecordHead
jmp GetRecordIdToAddPointDir:
mov edi,_lpPointDirBuf
add edi,_dwPointDirBufSize
cmp word ptr [edi-2],0a0dh
jz HaveChangeLine
mov ax,0a0dh
stosw
add _dwPointDirBufSize,2
HaveChangeLine:
mov esi,lpszPointContent
mov ecx,@dwPointContentLen
rep movsb
mov ax,0a0dh
stosw
add dword ptr @dwPointContentLen,2mov eax,@dwPointContentLen
add _dwPointDirBufSize,eax
mov esi,FILE_POINTDIR_SIZE
mov eax,_lpPointDirBuf
push _dwPointDirBufSize
pop dword ptr [esi+eax-4]mov eax,_dwFreeRecordCnt
cmp eax,0
jz NotEnoughSpace
lock inc dword ptr _dwDcsSampleCnt
lock dec _dwFreeRecordCnt
NotEnoughSpace:
invoke LeaveCriticalSection,addr _stCriticalPointDirlea eax,@szBufTime
push eax
call _ProcSysTimeToAsc
invoke wsprintf,addr @szBuf,addr szPointAdd,addr @szBufTime,lpszPointContent
mov ecx,eax
invoke WriteFile,_hFileJournal,addr @szBuf,ecx,addr @dwDotCnt,0
pop edi
pop esi
pop ebx
mov eax,1
mov edx,0
leave
retn 4KeepLenth:
invoke LeaveCriticalSection,addr _stCriticalPointDir
pop edi
pop esi
pop ebx
mov eax,0
mov edx,0
leave
retn 4
_ProcAddPoint endp_ProcDeletePoint proc,lpszPointID
local @dwDotCnt
local @lpCurrentRecordEnd
local @lpCurrentRecordHead
local @dwPointIdLen
local @dwFileEndPos
local @szBuf[200h]:byte
local @szBufTime[100h]:bytepush ebx
push esi
push edi
invoke EnterCriticalSection,addr _stCriticalPointDir
cmp _dwPointDirBufSize,0
jz ReachFileEndcld
mov esi,lpszPointID
GetPointIdLen:
lodsb
cmp al,0
jnz GetPointIdLen
dec esi            
sub esi,lpszPointID
cmp esi,0
jz ReachFileEnd
mov @dwPointIdLen,esimov eax,_lpPointDirBuf
add eax,_dwPointDirBufSize
mov @dwFileEndPos,eaxmov esi,_lpPointDirBuf
mov @lpCurrentRecordHead,esi
GetCurrentRecordEnd:
lodsb
cmp al,0ah
jnz GetCurrentRecordEnd
mov @lpCurrentRecordEnd,esimov @dwDotCnt,0
mov esi,_lpPointDirBuf
GetRecordId:
lodsb
cmp al,2ch
jnz GetRecordId
inc @dwDotCnt
cmp @dwDotCnt,2
jnz GetRecordId
mov @dwDotCnt,0
mov ecx,@dwPointIdLen
mov edi,lpszPointID
repz cmpsb
jnz GetCurrentRecordHead
lodsb
cmp al,2ch
jz GetNextRecordStart
;注意:  不能将比较运算完成后所得的ECX值作为比较相等的参考依据.原因是什么????????????
;原因:例如若要比较12的值是否相等,他们的长度都为1,比较完成后ECX==0,但是他们却不相等GetCurrentRecordHead:
lodsb
cmp esi,@dwFileEndPos
jae ReachFileEnd                         ;此处末尾与文件冲突么?????
cmp al,0ah
jnz GetCurrentRecordHead
mov @lpCurrentRecordHead,esi
jmp GetRecordIdGetNextRecordStart:
lodsb
cmp esi,@dwFileEndPos 
jae GetPointEnd                     
cmp al,0ah
jnz GetNextRecordStart
GetPointEnd:
mov @lpCurrentRecordEnd,esimov eax,@lpCurrentRecordEnd
sub eax,_lpPointDirBuf
mov ecx,_dwPointDirBufSize
sub ecx,eax
mov esi,@lpCurrentRecordEnd
mov edi,@lpCurrentRecordHead
rep movsbmov ecx,@lpCurrentRecordEnd
sub ecx,@lpCurrentRecordHead
sub _dwPointDirBufSize,ecx
mov al,0
rep stosbmov esi,FILE_POINTDIR_SIZE
mov eax,_lpPointDirBuf
push _dwPointDirBufSize
pop dword ptr [esi+eax-4]mov eax,_dwDcsSampleCnt
cmp eax,0
jz IsEmptyFile
lock dec dword ptr _dwDcsSampleCnt
lock inc _dwFreeRecordCnt
IsEmptyFile:
invoke LeaveCriticalSection,addr _stCriticalPointDirlea eax,@szBufTime
push eax
call _ProcSysTimeToAsc
invoke wsprintf,addr @szBuf,addr szPointDelete,addr @szBufTime,lpszPointID
mov ecx,eax
invoke WriteFile,_hFileJournal,addr @szBuf,ecx,addr @dwDotCnt,0
pop edi
pop esi
pop ebx
mov eax,1
mov edx,0
leave
retn 4ReachFileEnd:
invoke LeaveCriticalSection,addr _stCriticalPointDir
pop edi
pop esi
pop ebx
mov eax,0
mov edx,0
leave
retn 4
_ProcDeletePoint endp_ProcModifyPoint proc,lpszPointID,lpszPointContent
local @dwDotCnt
local @lpCurrentRecordEnd
local @lpCurrentRecordHead
local @dwPointIdLen
local @dwPointContentLen
local @dwFileEndPos
local @lpInsertID
local @dwInsertIdLen
local @lpszPointContent[100h]:byte
local @szBuf[200h]:byte
local @szBufTime[100h]:bytepush ebx
push esi
push edi
invoke EnterCriticalSection,addr _stCriticalPointDir
cmp dword ptr _dwPointDirBufSize,0
jz InvalidParamcld
mov esi,lpszPointID
GetPointIdLen:
lodsb
cmp al,0
jnz GetPointIdLen
dec esi              
sub esi,lpszPointID
cmp esi,0
jz InvalidParam
mov @dwPointIdLen,esimov @dwDotCnt,0
mov esi,lpszPointContent
GetInsertIDHeadPos:
lodsb
cmp al,2ch
jnz GetInsertIDHeadPos
inc @dwDotCnt
cmp @dwDotCnt,2
jnz GetInsertIDHeadPos
mov @lpInsertID,esimov @dwInsertIdLen,0
GetInsertIdLen:
lodsb
cmp al,2ch
jz GetInsertIdEnd
inc @dwInsertIdLen
jmp GetInsertIdLenGetInsertIdEnd:
cmp @dwInsertIdLen,0
jz InvalidParamGetPointContentLen:
lodsb
cmp al,0
jnz GetPointContentLen
dec esi              
sub esi,lpszPointContent
cmp esi,0
jz InvalidParam
mov @dwPointContentLen,esimov ecx,@dwInsertIdLen
cmp ecx,@dwPointIdLen
jnz InvalidParam
mov esi,lpszPointID
mov edi,@lpInsertID
repz cmpsb
jnz InvalidParammov esi,lpszPointContent
lea edi,@lpszPointContent
mov ecx,@dwPointContentLen
rep movsb
mov eax,0a0dh
stosd
add @dwPointContentLen,2mov eax,_lpPointDirBuf
add eax,_dwPointDirBufSize
mov @dwFileEndPos,eaxmov esi,_lpPointDirBuf
mov @lpCurrentRecordHead,esi
GetCurrentRecordEnd:
lodsb
cmp al,0ah
jnz GetCurrentRecordEnd
mov @lpCurrentRecordEnd,esimov @dwDotCnt,0
mov esi,_lpPointDirBuf
GetRecordId:
lodsb
cmp al,2ch
jnz GetRecordId
inc @dwDotCnt
cmp @dwDotCnt,2
jnz GetRecordIdmov @dwDotCnt,0
mov ecx,@dwPointIdLen
mov edi,lpszPointID
repz cmpsb 
jnz GetCurrentRecordStart
lodsb
cmp al,2ch
jz GetNextRecordStart
;注意:  不能将比较运算完成后所得的ECX值作为比较相等的参考依据.原因是什么????????????
;原因:例如若要比较12的值是否相等,他们的长度都为1,比较完成后ECX==0,但是他们却不相等GetCurrentRecordStart:
lodsb
cmp esi,@dwFileEndPos
jae InvalidParam                       
cmp al,0ah
jnz GetCurrentRecordStart
mov @lpCurrentRecordHead,esi
jmp GetRecordIdGetNextRecordStart:
lodsb
cmp esi,@dwFileEndPos
jae FindPointEndLast                       
cmp al,0ah
jnz GetNextRecordStart
FindPointEndLast:
mov @lpCurrentRecordEnd,esimov eax,@lpCurrentRecordEnd
sub eax,@lpCurrentRecordHead
mov ebx,@dwPointContentLen
cmp eax,ebx
jae ShortLinesub ebx,eax
push ebx
mov esi,_lpPointDirBuf
add esi,_dwPointDirBufSize
dec esi
mov edi,esi
add edi,ebx
mov eax,@lpCurrentRecordEnd
sub eax,_lpPointDirBuf
mov ecx,_dwPointDirBufSize
sub ecx,eax
std
rep movsblea esi,@lpszPointContent
add esi,@dwPointContentLen
dec esi
mov ecx,@dwPointContentLen
rep movsbpop ebx
add _dwPointDirBufSize,ebx
cld
jmp ModifyLenthShortLine:
cld
sub eax,ebx
push eax
lea esi,@lpszPointContent
mov edi,@lpCurrentRecordHead
mov ecx,@dwPointContentLen
rep movsbmov ebx,@lpCurrentRecordEnd
sub ebx,_lpPointDirBuf
mov ecx,_dwPointDirBufSize
sub ecx,ebx
mov esi,@lpCurrentRecordEnd
rep movsb
pop ecx
sub _dwPointDirBufSize,ecx
mov al,0
rep stosbModifyLenth:
mov esi,FILE_POINTDIR_SIZE
mov eax,_lpPointDirBuf
push _dwPointDirBufSize
pop dword ptr [esi+eax-4]invoke LeaveCriticalSection,addr _stCriticalPointDir
lea eax,@szBufTime
push eax
call _ProcSysTimeToAsc
invoke wsprintf,addr @szBuf,addr szPointModify,addr @szBufTime,lpszPointID,lpszPointContent
mov ecx,eax
invoke WriteFile,_hFileJournal,addr @szBuf,ecx,addr @dwDotCnt,0pop edi
pop esi
pop ebx
mov eax,1
mov edx,0
leave
retn 8InvalidParam:
invoke LeaveCriticalSection,addr _stCriticalPointDir
pop edi
pop esi
pop ebx
mov eax,0
mov edx,0
leave
retn 8
_ProcModifyPoint endp_ProcSeekPoint proc,lpszPointID
local @lpCurrentRecordEnd
local @lpCurrentRecordHead
local @dwPointIdLen
local @dwFileEndPos
local @dwDotCnt
local @szBuf[200h]:byte
local @szBufTime[100h]:byte
local @szBuffer[200h]:byte
local @lpSeekPointBufpush ebx
push esi
push edi
invoke EnterCriticalSection,addr _stCriticalPointDir
cmp dword ptr _dwPointDirBufSize,0
jz ReachFileEndcld
mov esi,lpszPointID
GetPointIdLen:
lodsb
cmp al,0
jnz GetPointIdLen
dec esi            
sub esi,lpszPointID
cmp esi,0
jz ReachFileEnd
mov @dwPointIdLen,esimov eax,_lpPointDirBuf
add eax,_dwPointDirBufSize
mov @dwFileEndPos,eaxmov esi,_lpPointDirBuf
mov @lpCurrentRecordHead,esi
GetCurrentRecordEnd:
lodsb
cmp al,0ah
jnz GetCurrentRecordEnd
mov @lpCurrentRecordEnd,esimov @dwDotCnt,0
mov esi,_lpPointDirBuf
GetRecordId:
lodsb
cmp al,2ch
jnz GetRecordId
inc @dwDotCnt
cmp @dwDotCnt,2
jnz GetRecordId
mov @dwDotCnt,0
mov ecx,@dwPointIdLen
mov edi,lpszPointID
repz cmpsb
jnz GetCurrentRecordHead
lodsb
cmp al,2ch
jz GetNextRecordStart
;注意:  不能将比较运算完成后所得的ECX值作为比较相等的参考依据.原因是什么????????????
;原因:例如若要比较12的值是否相等,他们的长度都为1,比较完成后ECX==0,但是他们却不相等GetCurrentRecordHead:
lodsb
cmp esi,@dwFileEndPos
jae ReachFileEnd
cmp al,0ah
jnz GetCurrentRecordHead
mov @lpCurrentRecordHead,esi
jmp GetRecordIdGetNextRecordStart:
lodsb
cmp esi,@dwFileEndPos
jae GetPointEnd                       
cmp al,0ah
jnz GetNextRecordStart
GetPointEnd:
mov @lpCurrentRecordEnd,esiinvoke VirtualAlloc,0,_stSystemInfo.dwPageSize,MEM_COMMIT,PAGE_READWRITE
mov @lpSeekPointBuf,eax
mov edi,eax
mov esi,@lpCurrentRecordHead
mov ecx,@lpCurrentRecordEnd
sub ecx,@lpCurrentRecordHead
rep movsbinvoke LeaveCriticalSection,addr _stCriticalPointDir
lea eax,@szBufTime
push eax
call _ProcSysTimeToAsc
lea edi,@szBuffer
mov esi,@lpSeekPointBuf
mov ecx,@lpCurrentRecordEnd
sub ecx,@lpCurrentRecordHead
sub ecx,2
rep movsb
mov al,0
stosb
invoke wsprintf,addr @szBuf,addr szPointSeek,addr @szBufTime,addr @szBuffer
mov ecx,eax
invoke WriteFile,_hFileJournal,addr @szBuf,ecx,addr @dwDotCnt,0mov eax,@lpSeekPointBuf
mov edx,0
pop edi
pop esi
pop ebx
leave 
retn 4ReachFileEnd:
invoke LeaveCriticalSection,addr _stCriticalPointDir
mov eax,0
mov edx,0
pop edi
pop esi
pop ebx
leave 
retn 4
_ProcSeekPoint endp_ProcGetPointTable proc
local @szBuffer[100h]:byte
local @szBuf[200h]:byte
local @dwCounterpush ebx
push esi
push edi
invoke EnterCriticalSection,addr _stCriticalPointDir
cmp  _dwPointDirBufSize,0
jz NullBuflea eax,@szBuffer
push eax
call _ProcSysTimeToAsc
invoke wsprintf,addr @szBuf,addr szGetPointTable,addr @szBuffer
mov ecx,eax
invoke WriteFile,_hFileJournal,addr @szBuf,ecx,addr @dwCounter,0mov eax,_lpPointDirBuf
mov esi,_dwPointDirBufSize
mov byte ptr [esi+eax],0
invoke LeaveCriticalSection,addr _stCriticalPointDir
mov eax,_lpPointDirBuf
mov edx,0
pop edi
pop esi
pop ebx
leave
retn 0NullBuf:
invoke LeaveCriticalSection,addr _stCriticalPointDir
pop edi
pop esi
pop ebx
mov eax,0
mov edx,0
leave
retn 0
_ProcGetPointTable endp_ProcSysTimeToAsc proc,lpOutPutBuf
local @stSystemTime:SYSTEMTIMEpush ebx
push esi
push edi
invoke GetLocalTime,addr @stSystemTime
mov ax,@stSystemTime.wYear
movzx eax,ax
mov bx,@stSystemTime.wMonth
movzx ebx,bx
mov cx,@stSystemTime.wDay
movzx ecx,cx
mov dx,@stSystemTime.wHour
movzx edx,dx
mov di,@stSystemTime.wMinute
movzx edi,di
mov si,@stSystemTime.wSecond
movzx esi,si
invoke wsprintf,lpOutPutBuf,addr szSystemTime,eax,ebx,ecx,edx,edi,esi
mov edx,0
pop edi
pop esi
pop ebx
leave
retn 4
_ProcSysTimeToAsc endp_ProcNewExceptionFilter proc,lpExceptionPoint
local @szBuffer[100h]:byte
local @szBuf[200h]:byte
local @dwCounterpushad
lea eax,@szBuffer
push eax
call _ProcSysTimeToAsc
mov esi,lpExceptionPoint
assume esi:ptr EXCEPTION_POINTERS
mov edi,[esi].ContextRecord
mov esi,[esi].pExceptionRecord
assume esi:ptr EXCEPTION_RECORD,edi:ptr CONTEXT
invoke wsprintf,addr @szBuf,addr szMsgException,addr @szBuffer,[esi].ExceptionAddress,[esi].ExceptionCode,[esi].ExceptionFlags
mov ecx,eax
invoke WriteFile,_hFileJournal,addr @szBuf,ecx,addr @dwCounter,0call _ProcTerminate
invoke ExitProcess,0
popad
mov eax,EXCEPTION_CONTINUE_SEARCH
leave
retn 4
_ProcNewExceptionFilter endp;用户信息文件初始化:16个字节的用户名(不足用空格补齐),16个字节的密码(不足用空格补齐),回车换行符
_ProcSeekUser proc,lpszUserName,lpszPassWord
local @szPassWord[USER_PASSWORD_LEN]:byte
local @szUserName[USER_NAME_LEN]:byte
local @lpUserInfoEndpush ebx
push esi
push edi
cld
mov esi,lpszUserName
lea edi,@szUserName
GetUserNameLen:
lodsb
cmp al,0
jz GetUserNameEnd
stosb
jmp GetUserNameLen
GetUserNameEnd:
mov esi,edi
lea ebx,@szUserName
sub esi,ebx
cmp esi,0
jz InvalidParam
cmp esi,USERNAME_PASSWORD_LEN
ja InvalidParam
mov ecx,sizeof @szUserName
sub ecx,esi
mov al,20h
rep stosbmov esi,lpszPassWord
lea edi,@szPassWord
GetPassWordLen:
lodsb
cmp al,0
jz GetPassWordEnd
stosb
jmp GetPassWordLen
GetPassWordEnd:
mov esi,edi
lea ebx,@szPassWord
sub esi,ebx
cmp esi,0
jz InvalidParam
cmp esi,USERNAME_PASSWORD_LEN
ja InvalidParam
mov ecx,sizeof @szPassWord
sub ecx,esi
mov al,20h
rep stosbinvoke EnterCriticalSection,addr _stCriticalUserInfo
cmp dword ptr _dwUserInfoBufSize,0
jz ToInvalidParammov esi,_lpUserInfoBuf
mov ebx,esi
add ebx,_dwUserInfoBufSize
mov @lpUserInfoEnd,ebxCheckNextUser:
push esi
lea edi,@szUserName
mov ecx,sizeof @szUserName
repz cmpsb
jnz ToCheckNextUsermov ecx,sizeof @szPassWord
lea edi,@szPassWord
repz cmpsb
jnz ToCheckNextUserpop esi
jmp GetUserNameCorrectToCheckNextUser:
pop esi
add esi,USER_INFO_LEN
cmp esi,@lpUserInfoEnd
jb CheckNextUserToInvalidParam:
invoke LeaveCriticalSection,addr _stCriticalUserInfo
InvalidParam:
mov eax,0
mov edx,0
pop edi
pop esi
pop ebx
leave
retn 8GetUserNameCorrect:
lea esi,szAdminLogon
lea edi,@szUserName
mov ecx,sizeof @szUserName
repz cmpsb
jz AdminiatratorLogon
invoke LeaveCriticalSection,addr _stCriticalUserInfo
mov eax,1
mov edx,0
pop edi
pop esi
pop ebx
leave
retn 8AdminiatratorLogon:
invoke LeaveCriticalSection,addr _stCriticalUserInfo
mov eax,2
mov edx,0
pop edi
pop esi
pop ebx
leave
retn 8
_ProcSeekUser endp_ProcAddUser proc,lpszUserName,lpszPassWord                            
local @szPassWord[USER_PASSWORD_LEN]:byte       ;高位       
local @szUserName[USER_NAME_LEN]:byte           ;低位
local @lpUserInfoEndpush ebx
push esi
push edi
cld
mov esi,lpszUserName
lea edi,@szUserName
GetUserNameLen:
lodsb
cmp al,0
jz GetUserNameEnd
stosb
jmp GetUserNameLen
GetUserNameEnd:
mov esi,edi
lea ebx,@szUserName
sub esi,ebx
cmp esi,0
jz InvalidParam
cmp esi,USERNAME_PASSWORD_LEN
ja InvalidParam
mov ecx,sizeof @szUserName
sub ecx,esi
mov al,20h
rep stosbmov esi,lpszPassWord
lea edi,@szPassWord
GetPassWordLen:
lodsb
cmp al,0
jz GetPassWordEnd
stosb
jmp GetPassWordLen
GetPassWordEnd:
mov esi,edi
lea ebx,@szPassWord
sub esi,ebx
cmp esi,0
jz InvalidParam
cmp esi,USERNAME_PASSWORD_LEN
ja InvalidParam
mov ecx,sizeof @szPassWord
sub ecx,esi
mov al,20h
rep stosbinvoke EnterCriticalSection,addr _stCriticalUserInfo
cmp dword ptr _dwUserInfoBufSize,0
jz AddUserInfomov esi,_lpUserInfoBuf
mov ebx,esi
add ebx,_dwUserInfoBufSize
mov @lpUserInfoEnd,ebxCheckNextUser:
push esi
lea edi,@szUserName
mov ecx,sizeof @szUserName
repz cmpsb
jz FoundSameInfopop esi
add esi,USER_INFO_LEN
cmp esi,@lpUserInfoEnd
jb CheckNextUserAddUserInfo:
lea esi,@szUserName
mov edi,_lpUserInfoBuf
add edi,_dwUserInfoBufSize
mov ecx,sizeof @szUserName
add ecx,sizeof @szPassWord
rep movsb
mov ax,0a0dh
stosw
add dword ptr [_dwUserInfoBufSize],USER_INFO_LEN
push dword ptr [_dwUserInfoBufSize]
mov esi,_lpUserInfoBuf
mov ebx,FILE_USERINFO_SIZE
pop dword ptr [esi+ebx-4]
invoke LeaveCriticalSection,addr _stCriticalUserInfo
mov eax,1
mov edx,0
pop edi
pop esi
pop ebx
leave
retn 8FoundSameInfo:
pop esi
invoke LeaveCriticalSection,addr _stCriticalUserInfo
InvalidParam:
mov eax,0
mov edx,0
pop edi
pop esi
pop ebx
leave
retn 8
_ProcAddUser endp_ProcDeleteUser proc,lpszUserName,lpszPassWord
local @szPassWord[USER_PASSWORD_LEN]:byte
local @szUserName[USER_NAME_LEN]:byte
local @lpUserInfoEndpush ebx
push esi
push edi
cld
mov esi,lpszUserName
lea edi,@szUserName
GetUserNameLen:
lodsb
cmp al,0
jz GetUserNameEnd
stosb
jmp GetUserNameLen
GetUserNameEnd:
mov esi,edi
lea ebx,@szUserName
sub esi,ebx
cmp esi,0
jz InvalidParam
cmp esi,USERNAME_PASSWORD_LEN
ja InvalidParam
mov ecx,sizeof @szUserName
sub ecx,esi
mov al,20h
rep stosblea esi,szAdminLogon
lea edi,@szUserName
mov ecx,sizeof @szUserName
repz cmpsb
jz InvalidParam
invoke EnterCriticalSection,addr _stCriticalUserInfo
cmp dword ptr _dwUserInfoBufSize,0
jz NotFoundSameInfomov esi,_lpUserInfoBuf
mov ebx,esi
add ebx,_dwUserInfoBufSize
mov @lpUserInfoEnd,ebxCheckNextName:
push esi
lea edi,@szUserName
mov ecx,sizeof @szUserName
repz cmpsb
jz GetSameUserName
pop esi
add esi,USER_INFO_LEN
cmp esi,@lpUserInfoEnd
jb CheckNextNameNotFoundSameInfo:
invoke LeaveCriticalSection,addr _stCriticalUserInfo
InvalidParam:
mov eax,0
mov edx,0
pop edi
pop esi
pop ebx
leave
retn 8GetSameUserName:
pop esi
mov edi,esi
add esi,USER_INFO_LEN
mov eax,esi
sub eax,_lpUserInfoBuf
mov ecx,_dwUserInfoBufSize
sub ecx,eax
rep movsb
mov ecx,esi
sub ecx,edi
push ecx
mov al,0
rep stosbpop ecx
sub dword ptr [_dwUserInfoBufSize],ecx
push dword ptr [_dwUserInfoBufSize]
mov esi,_lpUserInfoBuf
mov ebx,FILE_USERINFO_SIZE
pop dword ptr [esi+ebx-4]
invoke LeaveCriticalSection,addr _stCriticalUserInfo
mov eax,1
mov edx,0
pop edi
pop esi
pop ebx
leave
retn 8
_ProcDeleteUser endp_ProcClientShowValue proc,lpValueBuf,nOrdinal
local @dwValue
local @szBuf[200h]:bytepush ebx
push esi
push edi
cmp nOrdinal,1
jnz ToAddTo
lea ebx,_ThreadCreateDlg
invoke CreateThread,0,0,ebx,0,0,0
invoke CloseHandle,eax
WaitInitOk:
cmp _hDlgShowValue,0
jz WaitInitOk
ToAddTo:
mov esi,lpValueBuf
mov ax,word ptr [esi]
movzx eax,ax
mov bx,word ptr [esi+2]
movzx ebx,bx
mov cx,word ptr [esi+6]
movzx ecx,cx
mov dx,word ptr [esi+8]
movzx edx,dx
mov di,word ptr [esi+10]
movzx edi,di
push dword ptr [esi+16]
pop dword ptr @dwValue
mov si,word ptr [esi+12]
movzx esi,si
invoke wsprintf,addr @szBuf,addr szClientShowValue,eax,ebx,ecx,edx,edi,esi,@dwValue
invoke SendDlgItemMessage,_hDlgShowValue,_LIST_CLIENT_SHOWVALUE,LB_ADDSTRING,0,addr @szBuf
ClientShowValueEnd:
pop edi
pop esi
pop ebx
mov eax,1
mov edx,0
leave
retn 8
_ProcClientShowValue endp_ThreadCreateDlg proc       
lea ebx,_DlgProcShowValue
invoke DialogBoxParam,_hDllInstance,_DLG_CLIENT_SHOWVALUE,0,ebx,0               ;为什么不用得到模块句柄,而要用链接库句柄?????
leave
retn 0
_ThreadCreateDlg endp_DlgProcShowValue proc,hWnd,uMsg,wParam,lParam
local @dwValue
local @szBuf[200h]:bytepush ebx
push esi
push edi
mov eax,uMsg.if eax==WM_INITDIALOGpush hWndpop _hDlgShowValue  .elseif eax==WM_CLOSEmov _hDlgShowValue,0invoke EndDialog,hWnd,0.elsemov eax,TRUEpop edipop esipop ebxleavemov eax,FALSEretn 16.endif
mov eax,TRUE
pop edi
pop esi
pop ebx
leave
retn 16
_DlgProcShowValue endp_ProcService proc
local @hScmManager
local @hService
local @stServiceTableEntry:SERVICE_TABLE_ENTRYpush ebx
push esi
push edi
invoke OpenSCManager,0,0,SC_MANAGER_ALL_ACCESS.if eax==0invoke MessageBox,0,offset szOpenScmError,0,MB_OK.endif
mov @hScmManager,eaxinvoke OpenService,@hScmManager,offset szServiceName,SERVICE_QUERY_CONFIG.if eax==0invoke CreateService,@hScmManager,offset szServiceName,offset szServiceName,SERVICE_ALL_ACCESS,SERVICE_WIN32_OWN_PROCESS,\SERVICE_AUTO_START,SERVICE_ERROR_NORMAL,addr szModuleFileName,0,0,0,0,0.if eax==0invoke MessageBox,0,offset szOpenServiceError,0,MB_OK.elsemov @hService,eax.endif.elsemov @hService,eax.endif
invoke CloseServiceHandle,@hScmManagerlea esi,@stServiceTableEntry
lea ebx,szServiceName
mov dword ptr [esi],ebx
lea edi,_ProcServiceMain
mov dword ptr [esi+4],edi
invoke StartServiceCtrlDispatcher,addr @stServiceTableEntry.if eax==0invoke MessageBox,0,offset szDispatcherServiceError,0,MB_OK.endif           
pop edi
pop esi
pop ebx
leave
retn 0
_ProcService endp_ProcServiceMain proc
local @stServiceStatus:SERVICE_STATUS
local @hServiceStatus:SERVICE_STATUS_HANDLEpush ebx
push esi
push edi
invoke RtlZeroMemory,addr @stServiceStatus,sizeof SERVICE_STATUS
mov @stServiceStatus.dwServiceType,SERVICE_WIN32_OWN_PROCESS
mov @stServiceStatus.dwCurrentState,SERVICE_START_PENDING
mov @stServiceStatus.dwControlsAccepted,SERVICE_ACCEPT_STOP
mov @stServiceStatus.dwWin32ExitCode,0
mov @stServiceStatus.dwServiceSpecificExitCode,0
mov @stServiceStatus.dwCheckPoint,0
mov @stServiceStatus.dwWaitHint,0
invoke SetServiceStatus,@hServiceStatus,addr @stServiceStatuslea ebx,_ProcServiceHandler
invoke RegisterServiceCtrlHandler,addr szServiceName,ebx.if eax==0invoke MessageBox,0,offset szRegistryServiceError,0,MB_OK.endif
mov @hServiceStatus,eaxmov @stServiceStatus.dwWin32ExitCode,S_OK
mov @stServiceStatus.dwCheckPoint,0
mov @stServiceStatus.dwWaitHint,0
mov @stServiceStatus.dwCurrentState,SERVICE_RUNNING
invoke SetServiceStatus,@hServiceStatus,addr @stServiceStatusmov ecx,100
ToSleep:
push ecx
invoke Sleep,1000
pop ecx
loop ToSleepmov @stServiceStatus.dwCurrentState,SERVICE_STOPPED
invoke SetServiceStatus,@hServiceStatus,addr @stServiceStatuspop edi
pop esi
pop ebx
leave
retn 0
_ProcServiceMain endp_ProcServiceHandler proc,dwOpCode
push ebx
push esi
push edipop edi
pop esi
pop ebx
leave
retn 4
_ProcServiceHandler endp_ProcRestart proc_ProcRestart endpend DllEntry

相关文章:

实时数据库测试-汇编小程序

实时数据库测试-汇编小程序。 hd.asm .686 .model flat,stdcall option casemap:none include \masm32\include\windows.inc include \masm32\include\kernel32.inc include \masm32\include\user32.inc include \masm32\include\gdi32.inc …...

HTML5 、CSS3 、ES6 新特性

HTML5 新特性 1. 新的语义化元素&#xff1a;article 、footer 、header 、nav 、section 2. 表单增强&#xff0c;新的表单控件&#xff1a;calendar 、date 、time 、email 、url 、search 3. 新的 API&#xff1a;音频(用于媒介回放的 video 和 audio 元素)、图形&#x…...

基于springboot+vue实现的驾校信息管理系统

作者主页&#xff1a;Java码库 主营内容&#xff1a;SpringBoot、Vue、SSM、HLMT、Jsp、PHP、Nodejs、Python、爬虫、数据可视化、小程序、安卓app等设计与开发。 收藏点赞不迷路 关注作者有好处 文末获取源码 技术选型 【后端】&#xff1a;Java 【框架】&#xff1a;spring…...

X进制减法(贪心算法C++实现)

题目 进制规定了数字在数位上逢几进一。 X 进制是一种很神奇的进制&#xff0c;因为其每一数位的进制并不固定&#xff01; 例如说某种 X 进制数&#xff0c;最低数位为二进制&#xff0c;第二数位为十进制&#xff0c;第三数位为八进制&#xff0c;则 X 进制数 321 转换为十…...

[Windows]服务注册工具(nssm)

文章目录 官网下载地址百度云下载地址NSSM常用命令 使用场景&#xff1a;例如现在我们想开启自动启动一个Java服务,nginx,node等。 官网下载地址 https://nssm.cc/download 百度云下载地址 链接&#xff1a;https://pan.baidu.com/s/111fkBWIS7CTlWIj80Kc8Sg?pwdanan 提取码…...

Xilinx缓存使用说明和测试

Xilinx缓存使用说明和测试 1 BRAM说明2 FIFO说明3 实例测试3.1 代码3.2 仿真本文主要介绍Xilinx FPGA芯片中BRAM和FIFO的使用方法和测试结果,主要针对流接口进行仿真。 1 BRAM说明 BRAM是Xilinx芯片中重要的存储资源,其可配置为单端口RAM/ROM或者双端口RAM/ROM,本文以最复杂…...

LeetCode:2952. 需要添加的硬币的最小数量(贪心 Java)

目录 2952. 需要添加的硬币的最小数量 题目描述&#xff1a; 实现代码与解析&#xff1a; 贪心 原理思路&#xff1a; 2952. 需要添加的硬币的最小数量 题目描述&#xff1a; 给你一个下标从 0 开始的整数数组 coins&#xff0c;表示可用的硬币的面值&#xff0c;以及一个…...

企业员工在线培训系统功能介绍

随着信息技术的飞速发展&#xff0c;企业员工培训方式正逐步从传统的面授转向灵活高效的在线培训。一个综合性的企业员工在线培训系统能够为员工提供多样化的学习资源、便捷的学习途径和有效的学习监督&#xff0c;以下是该系统的主要功能详细介绍&#xff1a; 1. 课程功能 线…...

服了,一线城市的后端都卷成这样了吗!?

声明&#xff1a;本文首发在同名公众号&#xff1a;王中阳Go&#xff0c;未经授权禁止转载。 先听TA的故事 投稿的主人公是一名工作5年的后端开发工程师&#xff0c;最近2年用Golang&#xff0c;之前其他语言。去年春节前被裁员了&#xff0c;各种心酸史&#xff0c;好愁人啊。…...

Qt扫盲-QAssisant 集成其他qch帮助文档

QAssisant 集成其他qch帮助文档 一、概述二、Cmake qch例子1. 下载 Cmake.qch2. 添加qch1. 直接放置于Qt 帮助的目录下2. 在 QAssisant中添加 一、概述 QAssisant是一个很好的帮助文档&#xff0c;他提供了供我们在外部添加新的 qch帮助文档的功能接口&#xff0c;一般有两中添…...

[lesson01]学习C++的意义

学习C的意义 C语言特点 C语言是在实践的过程中逐步完善起来的 没有深思熟路的设计过程残留量过多低级语言的特征 C语言的目标是高效 最终程序执行效率的高效 软件方法论的发展 面相过程程序设计&#xff1a;数据结构 算法 主要解决科学计算问题&#xff0c;用户需求简单而…...

LabVIEW双通道太阳射电频谱观测系统

LabVIEW双通道太阳射电频谱观测系统 开发了一个基于LabVIEW平台开发的双通道高速太阳射电频谱观测系统。该系统实时监测太阳射电爆发&#xff0c;具有随机性、持续时间短、变化快等特点。通过高速信号采集卡实现1.5 GS/s的信号采集&#xff0c;时间分辨率可达4ms&#xff0c;频…...

Trapcode Particular---打造惊艳粒子效果

Trapcode Particular是Adobe After Effects中的一款强大3D粒子系统插件&#xff0c;其能够创造出丰富多样的自然特效&#xff0c;如烟雾、火焰和闪光&#xff0c;以及有机的和高科技风格的图形效果。Trapcode Particular功能丰富且特色鲜明&#xff0c;是一款为Adobe After Eff…...

从0到1利用express搭建后端服务

目录 1 架构的选择2 环境搭建3 安装express4 创建启动文件5 express的核心功能6 加入日志记录功能7 日志记录的好处本节代码总结 不知不觉学习低代码已经进入第四个年头了&#xff0c;既然低代码很好&#xff0c;为什么突然又自己架构起后端了呢&#xff1f;我有一句话叫低代码…...

pytest和unittest 如何选择?

目录 如何选择?pytest和unittest哪个更强大pytest和unittest是否可同时应用如何选择? pytest和unittest都是Python中常用的测试框架,它们各自具有一些特点和优势,选择哪一个取决于你的具体需求和偏好。以下是一些关于这两个框架的对比和选择建议: 易用性和简洁性: pytes…...

《QT实用小工具·四》屏幕拾色器

1、概述 源码放在文章末尾 该项目实现了屏幕拾色器的功能&#xff0c;可以根据鼠标指定的位置识别当前位置的颜色 项目功能包含&#xff1a; 鼠标按下实时采集鼠标处的颜色。 实时显示颜色值。 支持16进制格式和rgb格式。 实时显示预览颜色。 根据背景色自动计算合适的前景色…...

【Linux C | 多线程编程】线程的连接、分离,资源销毁情况

&#x1f601;博客主页&#x1f601;&#xff1a;&#x1f680;https://blog.csdn.net/wkd_007&#x1f680; &#x1f911;博客内容&#x1f911;&#xff1a;&#x1f36d;嵌入式开发、Linux、C语言、C、数据结构、音视频&#x1f36d; ⏰发布时间⏰&#xff1a;2024-04-01 1…...

kubernetes-Pod基于污点、容忍度、亲和性的多种调度策略(二)

Pod调度策略 一.污点-Taint二.容忍度-Tolerations三.Pod常见状态和重启策略1.Pod常见状态2.Pod的重启策略2.1测试Always重启策略2.2测试Never重启策略2.3测试OnFailure重启策略&#xff08;生产环境中常用&#xff09; 一.污点-Taint 在 Kubernetes 中&#xff0c;污点&#x…...

数码管时钟--LABVIEW编程

一、程序的前面板 1.获取系统时钟&#xff0c;年月日&#xff0c;时分秒&#xff0c;用14个数码管显示。 2.闹钟设定小时和分钟。 二、程序的后面板 三、程序运行图 四、程序源码 源程序可以在百度网盘自行下载&#xff0c;地址链接见下方。 链接&#xff1a;https://pan.b…...

linux安装指定版本docker

目录 查看主机上docker版本 配置docker的yum源 安装指定版本docker-20.10.14 查看yum中docker的版本 此命令装完后&#xff0c;任然会是最新版本的docker 卸载已安装docker 安装docker docker依赖包有冲突 解决冲突报错 再次执行安装docker命令 查看主机上docker版本 …...

C++刷题篇——05静态扫描

一、题目 二、解题思路 注意&#xff1a;注意理解题目&#xff0c;缓存的前提是先扫描一次 1、使用两个map&#xff0c;两个map的key相同&#xff0c;map1&#xff1a;key为文件标识&#xff0c;value为文件出现的次数&#xff1b;map2&#xff1a;key为文件标识&#xff0c;va…...

Unity AI Navigation自动寻路

目录 前言一、Unity中AI Navigation是什么&#xff1f;二、使用步骤1.安装AI Navigation2.创建模型和材质3.编写向目标移动的脚本4.NavMeshLink桥接组件5.NavMeshObstacle组件6.NavMeshModifler组件 三、效果总结 前言 Unity是一款强大的游戏开发引擎&#xff0c;而人工智能&a…...

HarmonyOS实战开发-如何实现一个简单的健康生活应用(上)

介绍 本篇Codelab介绍了如何实现一个简单的健康生活应用&#xff0c;主要功能包括&#xff1a; 用户可以创建最多6个健康生活任务&#xff08;早起&#xff0c;喝水&#xff0c;吃苹果&#xff0c;每日微笑&#xff0c;刷牙&#xff0c;早睡&#xff09;&#xff0c;并设置任…...

React中使用antDesign框架

1.在React项目中使用Ant Design&#xff0c;首先需要安装Ant Design: npm install antd --save 2.按需引入Ant Design组件&#xff0c;以减小最终打包的大小。使用babel-plugin-import插件可以实现按需加载。首先安装插件&#xff1a; npm install babel-plugin-import --save-…...

Electron安全防护实战:应对常见安全问题及权限控制措施

Electron安全防护实战&#xff1a;应对常见安全问题及权限控制措施 引言常见安全问题及其危害提升 Electron 应用安全性的措施限制渲染进程权限防止XSS与内容注入加固应用更新流程严格管理硬件权限使用安全的第三方模块加密敏感数据存储实现进程间通信&#xff08;IPC&#xff…...

StringBuffer与StringBuilder

1.区别 (1). String : 不可变字符序列. (2). StringBuffer : 可变字符序列.线程安全&#xff0c;但效率低. (3). StringBuilder : 可变字符序列.线程不安全&#xff0c;但效率高. 既然StringBuffer与StringBuilder都是可变字符序列&#xff0c;但二者咋区分开呢&#xff1f…...

HCIP综合实验拓扑

实验要求 1.R5为ISP&#xff0c;只能进行IP地址配置&#xff0c;其所有地址均配为公有I地址; 2、R1和R5间使用PPP的PAP认证&#xff0c;R5为主认证方: R2与R5之间使用ppp的CHAP认证&#xff0c;R5为主认证方; R3与R5之间使用HDLC封装; 3R1、R2、R3构建一个MGRE环境&#xf…...

nuxt学习

一、遇到的问题 1、nuxt初始化失败问题解决方案 使用npm和pnpm初始化都失败 原因&#xff1a;主机连不上DNS服务器 解决方案 Step1: 打开文件夹 Windows:路径&#xff1a;C:\Windows\System32\drivers\etc Mac: 路径&#xff1a;/etc/hosts Step2: 使用记事本方式打开 …...

VS学习建议

Visual Studio&#xff08;简称VS&#xff09;是由微软公司开发的一款集成开发环境&#xff08;IDE&#xff09;&#xff0c;支持多种编程语言&#xff0c;主要用于Windows平台上的应用程序开发。学习使用Visual Studio涉及多个方面&#xff0c;以下是一些关键的学习内容&#…...

java汇总区间

给定一个 无重复元素 的 有序 整数数组 nums 。 返回 恰好覆盖数组中所有数字 的 最小有序 区间范围列表 。也就是说&#xff0c;nums 的每个元素都恰好被某个区间范围所覆盖&#xff0c;并且不存在属于某个范围但不属于 nums 的数字 x 。 列表中的每个区间范围 [a,b] 应该按…...

做外贸网站要花多少钱/seo软件推广哪个好

ios打包和调试 Mac系统安装XCode方便调试 在App Store下载并安装Xcode。注意&#xff0c;xcode版本低的话&#xff0c;也会影响打包的。推荐使用XCode9. 如果你的OS版本不满足安装xcode的版本要求&#xff0c;你可以寻找对应版本的xcode下载链接&#xff0c;然后在safari打开…...

《动态网站建设》第02章在线测试/seo优化流程

环境:1.在hadoop36机器&#xff0c;ping hadoop38机器的pod的ip&#xff0c;为172.30.1.42.该pod的service的external-ip的ip为hadoop36的ip3.下面机器的ip&#xff0c;已经使用xx.xx.xx.来替代和加图层覆盖掉问题: 无法通过服务EXTERNAL-IPport,访问对应的pod的服务&#xff0…...

网站title keywords/哪个平台推广效果最好

part 1Java基础核心技术总结 万事都离不开根基&#xff0c;Java基础对于一些老鸟来说可能已经很熟悉了&#xff0c;但是对于很多开发5年以下的朋友掌握的或许不是很牢固&#xff0c;因此这份笔记更适合温故而知新。 Part 2并发编程&#xff08;架构师筑基必备&#xff09; 并发…...

网站建设流程/权威解读当前经济热点问题

有无符号数是CPU架构决定的&#xff0c;是硬件特性直接反映到汇编指令中。C语言忠实的展现了汇编的特性。无符号数比较&#xff1a;ja、jae、jb、jbe、je或jne小于、小于等于、等于、不等于、大于或大于等于&#xff1b;有符号数比较&#xff1a;则使用jl、jle、je、jne、jg、j…...

少儿编程加盟费一般多少钱/seo自学网免费

最好用的WIN8开始菜单&#xff0c;多国语言新版下载 http://files.cnblogs.com/yipu/StartIsBack.v2.0.2.MULTILINGUAL-CRD.rar...

怎么网站建设怎么样/百度竞价排名多少钱

作者&#xff1a;alben来源&#xff1a;https://albenw.github.io/posts/69a9647f/ 概要 Spring实现了一套重试机制&#xff0c;功能简单实用。Spring Retry是从Spring Batch独立出来的一个功能&#xff0c;已经广泛应用于Spring Batch,Spring Integration, Spring for Apach…...