Rev 261 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 261 | Rev 323 | ||
---|---|---|---|
Line 205... | Line 205... | ||
205 | 205 | ||
Line 206... | Line 206... | ||
206 | mov [eax + SOCKET.Status], dword SOCK_OPEN |
206 | mov [eax + SOCKET.Status], dword SOCK_OPEN |
207 | 207 | ||
208 | xchg bh, bl |
- | |
209 | mov [eax + SOCKET.LocalPort], bx |
- | |
210 | ; mov [eax + 12], byte bh ; Local port ( LS 16 bits ) |
208 | xchg bh, bl |
211 | ; mov [eax + 13], byte bl ; Local port ( LS 16 bits ) |
209 | mov [eax + SOCKET.LocalPort], bx |
212 | xchg ch, cl |
- | |
213 | mov [eax + SOCKET.RemotePort], cx |
- | |
Line 214... | Line 210... | ||
214 | ; mov [eax + 20], ch ; Remote Port ( LS 16 bits ) |
210 | xchg ch, cl |
215 | ; mov [eax + 21], cl ; Remote Port ( LS 16 bits ) |
211 | mov [eax + SOCKET.RemotePort], cx |
216 | 212 | ||
217 | mov ebx, [stack_ip] |
213 | mov ebx, [stack_ip] |
Line 545... | Line 541... | ||
545 | 541 | ||
546 | sor_exit: |
542 | sor_exit: |
Line -... | Line 543... | ||
- | 543 | ret |
|
- | 544 | ||
- | 545 | ||
- | 546 | ;*************************************************************************** |
|
- | 547 | ; Function |
|
- | 548 | ; socket_read_packet |
|
- | 549 | ; |
|
- | 550 | ; Description |
|
- | 551 | ; socket # in ebx |
|
- | 552 | ; datapointer # in ecx |
|
- | 553 | ; buffer size in edx |
|
- | 554 | ; returns # of bytes copied in eax |
|
- | 555 | ; |
|
- | 556 | ;*************************************************************************** |
|
- | 557 | socket_read_packet: |
|
- | 558 | Index2RealAddr ebx ; get real socket address |
|
- | 559 | mov eax, [ebx + SOCKET.rxDataCount] ; get count of bytes |
|
- | 560 | test eax, eax ; if count of bytes is zero.. |
|
- | 561 | jz .exit ; exit function (eax will be zero) |
|
- | 562 | ||
- | 563 | test edx, edx ; if buffer size is zero, copy all data |
|
- | 564 | jz .copyallbytes |
|
- | 565 | cmp edx, eax ; if buffer size is larger then the bytes of data, copy all data |
|
- | 566 | jge .copyallbytes |
|
- | 567 | ||
- | 568 | sub eax, edx ; store new count (data bytes in buffer - bytes we're about to copy) |
|
- | 569 | mov [ebx + SOCKET.rxDataCount], eax ; |
|
- | 570 | push eax |
|
- | 571 | mov eax, edx ; number of bytes we want to copy must be in eax |
|
- | 572 | call .startcopy ; copy to the application |
|
- | 573 | ||
- | 574 | mov esi, ebx ; now we're going to copy the remaining bytes to the beginning |
|
- | 575 | add esi, SOCKETHEADERSIZE ; we dont need to copy the header |
|
- | 576 | mov edi, esi ; edi is where we're going to copy to |
|
- | 577 | add esi, edx ; esi is from where we copy |
|
- | 578 | pop ecx ; count of bytes we have left |
|
- | 579 | push ecx ; push it again so we can re-use it later |
|
- | 580 | shr ecx, 2 ; divide eax by 4 |
|
- | 581 | cld |
|
- | 582 | rep movsd ; copy all full dwords |
|
- | 583 | pop ecx |
|
- | 584 | and ecx, 3 |
|
- | 585 | rep movsb ; copy remaining bytes |
|
- | 586 | ||
- | 587 | ret ; at last, exit |
|
- | 588 | ||
- | 589 | .copyallbytes: |
|
- | 590 | xor esi, esi |
|
- | 591 | mov [ebx + SOCKET.rxDataCount], esi ; store new count (zero) |
|
- | 592 | ||
- | 593 | .startcopy: |
|
- | 594 | mov edi, ecx ; |
|
- | 595 | add edi, std_application_base_address ; get data pointer to buffer in application |
|
- | 596 | ||
- | 597 | mov esi, ebx ; |
|
- | 598 | add esi, SOCKETHEADERSIZE ; we dont need to copy the header |
|
- | 599 | mov ecx, eax ; eax is count of bytes |
|
- | 600 | push ecx |
|
- | 601 | shr ecx, 2 ; divide eax by 4 |
|
- | 602 | cld ; copy all full dwords |
|
- | 603 | rep movsd ; |
|
- | 604 | pop ecx |
|
- | 605 | and ecx, 3 |
|
- | 606 | rep movsb ; copy the rest bytes |
|
- | 607 | ||
- | 608 | .exit: |
|
- | 609 | ret ; exit, or go back to shift remaining bytes if any |
|
Line 547... | Line 610... | ||
547 | ret |
610 | |
548 | 611 | ||
549 | 612 | ||
550 | 613 |