Rev 2314 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 2314 | Rev 2364 | ||
---|---|---|---|
Line 674... | Line 674... | ||
674 | ; query class = IN (internet IPv4 address) = 1 |
674 | ; query class = IN (internet IPv4 address) = 1 |
675 | ; Note that network byte order is big-endian. |
675 | ; Note that network byte order is big-endian. |
676 | mov eax, 0x01000100 |
676 | mov eax, 0x01000100 |
677 | stosd |
677 | stosd |
678 | ; 7. Get DNS server address. |
678 | ; 7. Get DNS server address. |
679 | mcall 75, 0x00000004 ; protocol IP=0, device number=0, function=get DNS address |
679 | mcall 76, 0x00000004 ; protocol IP=0, device number=0, function=get DNS address |
680 | cmp eax, -1 |
680 | cmp eax, -1 |
681 | je .ret.dnserr |
681 | je .ret.dnserr |
682 | mov esi, eax ; put server address to esi |
682 | mov esi, eax ; put server address to esi |
683 | ; 8. Open UDP socketnum to DNS server, port 53. |
683 | ; 8. Open UDP socketnum to DNS server, port 53. |
684 | ; 8a. Create new socketnum. |
684 | ; 8a. Create new socketnum. |
685 | mcall 74, 0, AF_INET4, SOCK_DGRAM |
685 | mcall 75, 0, AF_INET4, SOCK_DGRAM |
686 | cmp eax, -1 ; error? |
686 | cmp eax, -1 ; error? |
687 | jz .ret.dnserr |
687 | jz .ret.dnserr |
688 | mov ecx, eax ; put socketnum handle to ecx |
688 | mov ecx, eax ; put socketnum handle to ecx |
689 | ; 8b. Create sockaddr structure on the stack. |
689 | ; 8b. Create sockaddr structure on the stack. |
690 | push 0 |
690 | push 0 |
691 | push 0 ; sin_zero |
691 | push 0 ; sin_zero |
692 | push esi ; sin_addr |
692 | push esi ; sin_addr |
693 | push AF_INET4 + (53 shl 16) |
693 | push AF_INET4 + (53 shl 16) |
694 | ; sin_family and sin_port in network byte order |
694 | ; sin_family and sin_port in network byte order |
695 | ; 8c. Connect. |
695 | ; 8c. Connect. |
696 | mcall 74, 4, , esp, sizeof.sockaddr_in |
696 | mcall 75, 4, , esp, sizeof.sockaddr_in |
697 | ; 8d. Restore the stack, undo 8b. |
697 | ; 8d. Restore the stack, undo 8b. |
698 | add esp, esi |
698 | add esp, esi |
699 | ; 8e. Check result. |
699 | ; 8e. Check result. |
700 | cmp eax, -1 |
700 | cmp eax, -1 |
701 | jz .ret.close |
701 | jz .ret.close |
702 | ; 9. Send DNS request packet. |
702 | ; 9. Send DNS request packet. |
703 | sub edi, esp ; get packet length |
703 | sub edi, esp ; get packet length |
704 | mov esi, edi |
704 | mov esi, edi |
705 | xor edi, edi |
705 | xor edi, edi |
706 | mcall 74, 6, , esp |
706 | mcall 75, 6, , esp |
707 | cmp eax, -1 |
707 | cmp eax, -1 |
708 | jz .ret.close |
708 | jz .ret.close |
709 | mov eax, [.reqdata] |
709 | mov eax, [.reqdata] |
710 | mov [eax+__gai_reqdata.socketnum], ecx |
710 | mov [eax+__gai_reqdata.socketnum], ecx |
711 | push -1 |
711 | push -1 |
712 | pop eax ; return status: more processing required |
712 | pop eax ; return status: more processing required |
713 | jmp .ret.dns |
713 | jmp .ret.dns |
714 | .ret.close: |
714 | .ret.close: |
715 | mcall 74, 1 |
715 | mcall 75, 1 |
716 | .ret.dnserr: |
716 | .ret.dnserr: |
717 | push EAI_AGAIN |
717 | push EAI_AGAIN |
718 | pop eax |
718 | pop eax |
719 | .ret.dns: |
719 | .ret.dns: |
720 | ; 6. Restore stack pointer and return. |
720 | ; 6. Restore stack pointer and return. |
Line 760... | Line 760... | ||
760 | push ebx esi edi |
760 | push ebx esi edi |
761 | mov edi, [.reqdata] |
761 | mov edi, [.reqdata] |
762 | ; 2. Read UDP datagram. |
762 | ; 2. Read UDP datagram. |
763 | mov ecx, [edi+__gai_reqdata.socketnum] |
763 | mov ecx, [edi+__gai_reqdata.socketnum] |
764 | push edi |
764 | push edi |
765 | mcall 74, 7, , , 512, 0 |
765 | mcall 75, 7, , , 512, 0 |
766 | pop edi |
766 | pop edi |
767 | ; 3. Ignore events for other socketnums (return if no data read) |
767 | ; 3. Ignore events for other socketnums (return if no data read) |
768 | test eax, eax |
768 | test eax, eax |
769 | jz .ret.more_processing_required |
769 | jz .ret.more_processing_required |
770 | ; 4. Sanity check: discard too short packets. |
770 | ; 4. Sanity check: discard too short packets. |
Line 921... | Line 921... | ||
921 | .ret.close: |
921 | .ret.close: |
922 | ; 15. Close socketnum. |
922 | ; 15. Close socketnum. |
923 | push eax |
923 | push eax |
924 | mov ecx, [.reqdata] |
924 | mov ecx, [.reqdata] |
925 | mov ecx, [ecx+__gai_reqdata.socketnum] |
925 | mov ecx, [ecx+__gai_reqdata.socketnum] |
926 | mcall 74, 1 |
926 | mcall 75, 1 |
927 | pop eax |
927 | pop eax |
928 | ; 16. Restore used registers, destroy stack frame and return. |
928 | ; 16. Restore used registers, destroy stack frame and return. |
929 | .ret: |
929 | .ret: |
930 | pop edi esi ebx |
930 | pop edi esi ebx |
931 | mov esp, ebp |
931 | mov esp, ebp |
Line 1221... | Line 1221... | ||
1221 | ; 0. Save used registers for __stdcall. |
1221 | ; 0. Save used registers for __stdcall. |
1222 | push ebx |
1222 | push ebx |
1223 | ; 1. Allocated resources: only socketnum, so close it and return. |
1223 | ; 1. Allocated resources: only socketnum, so close it and return. |
1224 | mov eax, [esp+8] |
1224 | mov eax, [esp+8] |
1225 | mov ecx, [eax+__gai_reqdata.socketnum] |
1225 | mov ecx, [eax+__gai_reqdata.socketnum] |
1226 | mcall 74, 1 |
1226 | mcall 75, 1 |
1227 | ; 2. Restore used registers and return. |
1227 | ; 2. Restore used registers and return. |
1228 | pop ebx |
1228 | pop ebx |
1229 | ret 4 |
1229 | ret 4 |
Line 1230... | Line 1230... | ||
1230 | 1230 |