invoke GlobalAlloc

Тема в разделе "WASM.ENGLISH", создана пользователем Guest, 4 апр 2005.

  1. Guest

    Guest Guest

    Публикаций:
    0
    Hello, everybody.

    five days ago, i asked the problem for the coder of named f0dder in Win32ASM Community messageboard . untill now he can't figure out it. the question is :

    1. my tested code sometimes can worked, another times it collapsed.

    2. when second clicked button "Get List", it must collapsed.



    regards.
     
  2. dcskm4200_1

    dcskm4200_1 New Member

    Публикаций:
    0
    Регистрация:
    4 апр 2005
    Сообщения:
    12
  3. dcskm4200_1

    dcskm4200_1 New Member

    Публикаций:
    0
    Регистрация:
    4 апр 2005
    Сообщения:
    12
  4. Quantum

    Quantum Паладин дзена

    Публикаций:
    0
    Регистрация:
    6 янв 2003
    Сообщения:
    3.143
    Адрес:
    Ukraine
    Here you are.

    Lots of errors there...

    1. You were using esi & edi registers in a thread function without saving them in the stack - FIXED

    2. You were freeing dynamic memory in one thread and using it in another. Actually, it sometimes happened to free memory before it was parsed in list_IP subrutine. FIXED

    3. dwIP_addr_first incremented in the while loop, so it was equal to dwIP_addr_end the second time you try to scan the IP range. FIXED



    Works almost fine now, but it crashes after 5-10 runs. That's because very high CPU and memory usage: about 40Mb in heap - not good at all. You should consider using virtual memory in a global buffer instead.

    [​IMG] _994730663__lv_8.zip
     
  5. Quantum

    Quantum Паладин дзена

    Публикаций:
    0
    Регистрация:
    6 янв 2003
    Сообщения:
    3.143
    Адрес:
    Ukraine
    Another suggestion: why not appending the IP-MAC items directly to the list view without using an intermediate buffer?
     
  6. dcskm4200_1

    dcskm4200_1 New Member

    Публикаций:
    0
    Регистрация:
    4 апр 2005
    Сообщения:
    12
    Hello, Quantum.



    Thank you very much.



    Now, it crashed sometimes in my PC when our Local net Ip >61.

    if it ran, process is becoming big id.

    collapse MSG:

    "0x7c938fea" Instruction used "0x00000010" memory. it is disable "written"

    "terminate" or "debug"

    ;===================================

    in list_IP proc

    actually. the bak_lpMacbuf looks as below:

    ;-------------------------------------------------

    name1$66.150.127.8=00:C0:9F:33:7F:99*Name2$66.150.127.4=00:06:5B:4B:lol: F :0A*name3$66.150.127.3=00:02:55:FC:6E:92*

    ;-------------------------------------------------

    so, i think "jz L1 ; FIX" is not to be need.



    I used buffer to get list name-ip-mac. it is foolish. because listview can't work in the Arp_IP2MAC proc CreateThread.



    Thanks again. my tested code has already improved a lot.



    regards
     
  7. dcskm4200_1

    dcskm4200_1 New Member

    Публикаций:
    0
    Регистрация:
    4 апр 2005
    Сообщения:
    12
    I don't know how use virtual memory in a global buffer instead.
     
  8. dcskm4200_1

    dcskm4200_1 New Member

    Публикаций:
    0
    Регистрация:
    4 апр 2005
    Сообщения:
    12
    Hey, Quantum.



    I modified some code for simpleness. but it crashed everytime.

    How debuged a CreateThread proc is difficult to me. I don't know where the tested code is error.



    regards.



    [​IMG] 952368842__lv_9.zip
     
  9. q_q

    q_q New Member

    Публикаций:
    0
    Регистрация:
    5 окт 2003
    Сообщения:
    1.706
    dcskm4200_1
    Код (Text):
    1. ...
    2. dwThread    dd 0
    3. szMacFmt1   db "%s",0  
    4. ;; ++ add by q_q
    5. szMacFmt2   db "%02X%02X%02X%02X%02X%02X",0
    6. ;; -- add by q_q
    7. unknown     db "unknow",0
    8. ...
    9. mov al,pulMac[0] ; eax= MAC address
    10. ;; ++ add by q_q
    11. push eax
    12. ;; -- add by q_q
    13.  
    14. invoke wsprintf,lpNamebuf,addr szMacFmt1,lpNamebuf ; HostName
    15. invoke wsprintf,lpIpbuf,addr szMacFmt1,lpIpbuf     ; IP addresss   
    16. invoke wsprintf,lpMacbuf,addr szMacFmt2            ; MAC address
    17. ;                             ~~~~~~~~~
    18. ;                             change by q_q
    19. add esp,6*DWORD ; <-- FIX STACK!!!
    20. ;       ~
    21. ;       change by q_q
    22.  
    23. invoke AddItemInt, ListIndex, 0d, sum_num        
    24. ...
     
  10. dcskm4200_1

    dcskm4200_1 New Member

    Публикаций:
    0
    Регистрация:
    4 апр 2005
    Сообщения:
    12
    Hey, q_q

    Thanks you for help.

    the listview started working. but its work isn't pretty well.

    for example:

    1. a lot of same index.

    2. some blank rows is there.

    3. sometimes it collapsed.

    msg:dntknw:"0x7c938fea" Instruction used "0x00000010" memory. it is disable "written"

    "terminate" or "debug" )



    I think how limit the thread number is next to do.



    thanks again.



    regards.
     
  11. dcskm4200_1

    dcskm4200_1 New Member

    Публикаций:
    0
    Регистрация:
    4 апр 2005
    Сообщения:
    12
    Hey, q_q

    Thanks you for help.

    the listview started working. but its work isn't pretty well.

    for example:

    1. a lot of same index.

    2. some blank rows is there.

    3. sometimes it collapsed.



    msg:dntknw:"0x7c938fea" Instruction used "0x00000010" memory. it is disable "written"

    "terminate" or "debug" )



    4. if added "



    ;====================================

    push eax

    add esp,6*DWORD ; <-- FIX STACK!!!

    ;====================================

    your MAC address isn't right.





    I think how limit the thread number is next to do.



    thanks again.



    regards.
     
  12. q_q

    q_q New Member

    Публикаций:
    0
    Регистрация:
    5 окт 2003
    Сообщения:
    1.706
    dcskm4200_1
    Код (Text):
    1. ...
    2. Arp_IP2MAC proc dwIpaddr:DWORD
    3.  
    4.     LOCAL pulMac[8]:BYTE
    5.     LOCAL ulLen:DWORD
    6.     LOCAL lpNamebuf,lpIpbuf,lpMacbuf:DWORD
    7.  
    8. ;; ++ q_q move to getMAC
    9. ;;  mov ListIndex,0
    10. ;;  mov sum_num,1
    11. ;; -- q_q
    12.  
    13.     mov ulLen,6 ; MAC ADDR 6 byte
    14. ...
    15.  
    16. ;; ++ q_q !!! need inside critical section
    17.         inc ListIndex ; start 0
    18.         inc sum_num
    19.         invoke LeaveCriticalSection,ADDR stCS
    20. ;; -- q_q
    21.  
    22.     .ENDIF
    23.     ret
    24. Arp_IP2MAC endp
    25.  
    26. ...
    27.  
    28. getMAC proc lhwnd:DWORD
    29.     LOCAL lpObjarr:DWORD
    30.  
    31. ;; ++ q_q move from Arp_IP2MAC
    32.     mov ListIndex,0
    33.     mov sum_num,1
    34. ;; -- q_q
    35.  
    36.     pushad
    37. ...
     
  13. dcskm4200_1

    dcskm4200_1 New Member

    Публикаций:
    0
    Регистрация:
    4 апр 2005
    Сообщения:
    12
    Hey, q_q

    Thanks you for help.

    I'v done according to you said, the below problems is still there.

    ;===========================

    1. a lot of same index.

    2. some blank rows is there.

    ;===========================

    regards
     
  14. q_q

    q_q New Member

    Публикаций:
    0
    Регистрация:
    5 окт 2003
    Сообщения:
    1.706
    dcskm4200_1

    check code
     
  15. q_q

    q_q New Member

    Публикаций:
    0
    Регистрация:
    5 окт 2003
    Сообщения:
    1.706
  16. dcskm4200_1

    dcskm4200_1 New Member

    Публикаций:
    0
    Регистрация:
    4 апр 2005
    Сообщения:
    12
    Hey, q_q



    Thanks you very much.

    it is becoming more and more nice.



    1. once lv_10.exe ran, the processes id and his thread id of to be running in the OS, will be become very big num.

    2. in my pc, when i click button "get list". sometimes it is ok, another times it is collapsed. every crash has the same MSG.

    msg:

    ("0x7c938fea" Instruction used "0x00000010" memory. it is disable "written"

    "terminate" or "debug" )



    best regards.