i can't seem to figure this out. after filling out an EDITSTREAM struct and sending EM_STREAMIN, this callback is called and then it crashes. the msdn isn't very helpful, so i thought maybe someone here could help. EditStreamWrite PROC dwCookie:DWORD, pbBuff:DWORD, cb:DWORD, pcb:DWORD mov ecx, cb mov ebx, ecx mov edi, pbBuff mov esi, OFFSET error1 rep movsb mov DWORD PTR, ebx xor eax, eax ret EditStreamWrite ENDP anyone know what the problem is?
Posted on 2000-11-15 15:58:00 by Sloat
The following works for me. mov hFile, eax mov EditS.dwCookie, eax mov EditS.pfnCallback, offset EditStreamRead mov EditS.dwError, 0 ;===================================================== EditStreamRead PROC uses ebx dwCookie:DWORD, pbBuff, cb, pcb INVOKE ReadFile, dwCookie, pbBuff, cb, pcb, 0 mov ebx, pcb mov eax, ; Get count read so far cmp eax, cb ; compare to amount needed jg EditRet ; if read < size, then more to read later mov eax, 0 ; otherwise, file completely read EditRet: RET EditStreamRead ENDP ;======================================================= ;======================================================== mov hFile, eax mov EditS.dwCookie, eax mov EditS.dwError, 0 mov EditS.pfnCallback, offset EditStreamWrite ;=================================================== EditStreamWrite PROC dwCookie:DWORD, pbBuff, cb, pcb INVOKE WriteFile, dwCookie, pbBuff, cb, pcb, 0 mov eax, 0 ; File completely read RET EditStreamWrite ENDP
Posted on 2000-11-15 16:16:00 by Ewayne
Probably register saving conventions. EBX, EDI, and ESI must have the same values on exit that they had on entry. Save and restore. Also, mov DWORD PTR,ebx doesn't do what you think it does. The DWORD PTR is redundant according to MASM interpretation. You need to load the pointer into a register because the x86 doesn't do indirection via memory (except for JMP and CALL). As it is, you are changing the pointer argument, not the count byte it's pointing to.
Posted on 2000-11-15 20:44:00 by ub1
well, i wrote it different and saved edi and esi, but it still doesn't work right. if i return eax as 0, it'll freeze, but if eax!=0 then it'll pass through once and clear the richedit box.
Posted on 2000-11-18 02:28:00 by Sloat