3-3

it2022-05-09  22

/* * TaskQueM.c * * Sample code for "Multithreading Applications in Win32" * This is from Chapter 3, Listing 3-3 * * Call ThreadFunc NUM_TASKS times, using * no more than THREAD_POOL_SIZE threads. * This version uses WaitForMultipleObjects * to provide a more optimal solution. * * Build command: cl /MD TaskQueM.c */

#define WIN32_LEAN_AND_MEAN#include <stdio.h>#include <stdlib.h>#include <windows.h>#include "MtVerify.h"

DWORD WINAPI ThreadFunc(LPVOID);

#define THREAD_POOL_SIZE 3#define MAX_THREAD_INDEX THREAD_POOL_SIZE-1#define NUM_TASKS 6

int main(){    HANDLE  hThrds[THREAD_POOL_SIZE];    int     slot = 0;    DWORD   threadId;    int     i;    DWORD   rc;

    for (i=1; i<=NUM_TASKS; i++)    {        /* Until we've used all threads in *         * the pool, do not need to wait   *         * for one to exit                 */        if (i > THREAD_POOL_SIZE)        {            /* Wait for one thread to terminate */            rc = WaitForMultipleObjects(                THREAD_POOL_SIZE,                hThrds,                FALSE,                INFINITE );            slot = rc - WAIT_OBJECT_0;            MTVERIFY( slot >= 0                 && slot < THREAD_POOL_SIZE );            printf("Slot %d terminated\n", slot );            MTVERIFY( CloseHandle(hThrds[slot]) );        }        /* Create a new thread in the given         * available slot */        MTVERIFY( hThrds[slot] = CreateThread(NULL,            0,            ThreadFunc,            (LPVOID)slot,            0,            &threadId ) );        printf("Launched thread #%d (slot %d)\n", i, slot);        slot++;    }

    /* Now wait for all threads to terminate */    rc = WaitForMultipleObjects(        THREAD_POOL_SIZE,        hThrds,        TRUE,        INFINITE );    MTVERIFY( rc >= WAIT_OBJECT_0             && rc < WAIT_OBJECT_0+THREAD_POOL_SIZE);    for (slot=0; slot<THREAD_POOL_SIZE; slot++)        MTVERIFY( CloseHandle(hThrds[slot]) );    printf("All slots terminated\n");

    return EXIT_SUCCESS;}

/* * This function just calls Sleep for * a random amount of time, thereby * simulating some task that takes time. * * The param "n" is the index into * the handle array, kept for informational * purposes. */DWORD WINAPI ThreadFunc(LPVOID n){    srand( GetTickCount() );

    Sleep((rand())*800+500);    printf("Slot %d idle\n", n);    return ((DWORD)n);}

od

 

00401000  /$  81EC 18010000 sub     esp, 11800401006  |.  53            push    ebx00401007  |.  8B1D 1C204000 mov     ebx, dword ptr [<&KERNEL32.WaitF>;  kernel32.WaitForMultipleObjects0040100D  |.  55            push    ebp0040100E  |.  8B2D 30204000 mov     ebp, dword ptr [<&MSVCRTD.printf>;  MSVCRTD.printf00401014  |.  56            push    esi00401015  |.  57            push    edi00401016  |.  33F6          xor     esi, esi00401018  |.  BF 01000000   mov     edi, 10040101D  |>  83FF 03       /cmp     edi, 300401020  |.  7E 3A         |jle     short 0040105C00401022  |.  6A FF         |push    -100401024  |.  8D4424 1C     |lea     eax, dword ptr [esp+1C]00401028  |.  6A 00         |push    00040102A  |.  50            |push    eax0040102B  |.  6A 03         |push    30040102D  |.  FFD3          |call    ebx                             ;  kernel32.waitformultipleobjects0040102F  |.  8BF0          |mov     esi, eax00401031  |.  85F6          |test    esi, esi00401033  |.  0F8C 14010000 |jl      0040114D00401039  |.  83FE 03       |cmp     esi, 30040103C  |.  0F8D 0B010000 |jge     0040114D00401042  |.  56            |push    esi00401043  |.  68 68314000   |push    00403168                        ;  ASCII "Slot %d terminated",LF00401048  |.  FFD5          |call    ebp                             ;  printf0040104A  |.  8B4CB4 20     |mov     ecx, dword ptr [esp+esi*4+20]0040104E  |.  83C4 08       |add     esp, 800401051  |.  51            |push    ecx                             ; /hObject00401052  |.  FF15 18204000 |call    dword ptr [<&KERNEL32.CloseHand>; \CloseHandle00401058  |.  85C0          |test    eax, eax0040105A  |.  74 71         |je      short 004010CD0040105C  |>  8D5424 24     |lea     edx, dword ptr [esp+24]00401060  |.  52            |push    edx                             ; /pThreadId00401061  |.  6A 00         |push    0                               ; |CreationFlags = 000401063  |.  56            |push    esi                             ; |pThreadParm00401064  |.  68 70134000   |push    00401370                        ; |ThreadFunction = TaskQueM.0040137000401069  |.  6A 00         |push    0                               ; |StackSize = 00040106B  |.  6A 00         |push    0                               ; |pSecurity = NULL0040106D  |.  FF15 14204000 |call    dword ptr [<&KERNEL32.CreateThr>; \CreateThread00401073  |.  85C0          |test    eax, eax00401075  |.  8944B4 18     |mov     dword ptr [esp+esi*4+18], eax00401079  |.  0F84 4E010000 |je      004011CD0040107F  |.  56            |push    esi00401080  |.  57            |push    edi00401081  |.  68 48314000   |push    00403148                        ;  ASCII "Launched thread #%d (slot %d)",LF00401086  |.  FFD5          |call    ebp                             ;  printf00401088  |.  83C4 0C       |add     esp, 0C0040108B  |.  46            |inc     esi0040108C  |.  47            |inc     edi0040108D  |.  83FF 06       |cmp     edi, 600401090  |.^ 7E 8B         \jle     short 0040101D00401092  |.  6A FF         push    -100401094  |.  8D4424 1C     lea     eax, dword ptr [esp+1C]00401098  |.  6A 01         push    10040109A  |.  50            push    eax0040109B  |.  6A 03         push    30040109D  |.  FFD3          call    ebx                              ;  kernel32.waitformultipleobjects0040109F  |.  83F8 03       cmp     eax, 3004010A2  |.  0F83 3C020000 jnb     004012E4004010A8  |.  33F6          xor     esi, esi004010AA  |.  8D7C24 18     lea     edi, dword ptr [esp+18]004010AE  |>  8B0F          /mov     ecx, dword ptr [edi]004010B0  |.  51            |push    ecx                             ; /hObject004010B1  |.  FF15 18204000 |call    dword ptr [<&KERNEL32.CloseHand>; \CloseHandle004010B7  |.  85C0          |test    eax, eax004010B9  |.  0F84 8E010000 |je      0040124D004010BF  |.  46            |inc     esi004010C0  |.  83C7 04       |add     edi, 4004010C3  |.  83FE 03       |cmp     esi, 3004010C6  |.^ 7C E6         \jl      short 004010AE004010C8  |.  E9 00020000   jmp     004012CD004010CD  |>  FF15 10204000 call    dword ptr [<&KERNEL32.GetLastErr>; [GetLastError004010D3  |.  6A 00         push    0                                ; /Arguments = NULL004010D5  |.  8D4C24 14     lea     ecx, dword ptr [esp+14]          ; |004010D9  |.  6A 00         push    0                                ; |BufSize = 0004010DB  |.  51            push    ecx                              ; |Buffer004010DC  |.  6A 00         push    0                                ; |LanguageId = 0 (LANG_NEUTRAL)004010DE  |.  50            push    eax                              ; |MessageId004010DF  |.  6A 00         push    0                                ; |pSource = NULL004010E1  |.  68 00110000   push    1100                             ; |Flags = ALLOCATE_BUFFER|FROM_SYSTEM|0004010E6  |.  FF15 0C204000 call    dword ptr [<&KERNEL32.FormatMess>; \FormatMessageA004010EC  |.  8B5424 10     mov     edx, dword ptr [esp+10]004010F0  |.  8D4424 28     lea     eax, dword ptr [esp+28]004010F4  |.  52            push    edx                              ; /<%s>004010F5  |.  68 2C314000   push    0040312C                         ; |<%s> = "CloseHandle(hThrds[slot])"004010FA  |.  68 20314000   push    00403120                         ; |<%s> = "TaskQueM.c"004010FF  |.  6A 34         push    34                               ; |<%d> = 34 (52.)00401101  |.  68 DC304000   push    004030DC                         ; |Format = LF,"The following call failed at line %d in %s:",LF,LF,"    %s",LF,LF,"Reason: %s",LF,""00401106  |.  50            push    eax                              ; |s00401107  |.  FF15 6C204000 call    dword ptr [<&USER32.wsprintfA>]  ; \wsprintfA0040110D  |.  83C4 18       add     esp, 1800401110  |.  8D4C24 14     lea     ecx, dword ptr [esp+14]00401114  |.  8D7C24 28     lea     edi, dword ptr [esp+28]00401118  |.  33C0          xor     eax, eax0040111A  |.  6A 00         push    0                                ; /pOverlapped = NULL0040111C  |.  51            push    ecx                              ; |pBytesWritten0040111D  |.  83C9 FF       or      ecx, FFFFFFFF                    ; |00401120  |.  8D5424 30     lea     edx, dword ptr [esp+30]          ; |00401124  |.  F2:AE         repne   scas byte ptr es:[edi]           ; |00401126  |.  F7D1          not     ecx                              ; |00401128  |.  49            dec     ecx                              ; |00401129  |.  51            push    ecx                              ; |nBytesToWrite0040112A  |.  52            push    edx                              ; |Buffer0040112B  |.  6A F4         push    -0C                              ; |/DevType = STD_ERROR_HANDLE0040112D  |.  FF15 08204000 call    dword ptr [<&KERNEL32.GetStdHand>; |\GetStdHandle00401133  |.  50            push    eax                              ; |hFile00401134  |.  FF15 04204000 call    dword ptr [<&KERNEL32.WriteFile>>; \WriteFile0040113A  |.  68 B80B0000   push    0BB8                             ; /Timeout = 3000. ms0040113F  |.  FF15 00204000 call    dword ptr [<&KERNEL32.Sleep>]    ; \Sleep00401145  |.  6A 01         push    1                                ; /status = 100401147  |.  FF15 2C204000 call    dword ptr [<&MSVCRTD.exit>]      ; \exit0040114D  |>  FF15 10204000 call    dword ptr [<&KERNEL32.GetLastErr>; [GetLastError00401153  |.  6A 00         push    0                                ; /Arguments = NULL00401155  |.  8D4C24 14     lea     ecx, dword ptr [esp+14]          ; |00401159  |.  6A 00         push    0                                ; |BufSize = 00040115B  |.  51            push    ecx                              ; |Buffer0040115C  |.  6A 00         push    0                                ; |LanguageId = 0 (LANG_NEUTRAL)0040115E  |.  50            push    eax                              ; |MessageId0040115F  |.  6A 00         push    0                                ; |pSource = NULL00401161  |.  68 00110000   push    1100                             ; |Flags = ALLOCATE_BUFFER|FROM_SYSTEM|000401166  |.  FF15 0C204000 call    dword ptr [<&KERNEL32.FormatMess>; \FormatMessageA0040116C  |.  8B5424 10     mov     edx, dword ptr [esp+10]00401170  |.  8D4424 28     lea     eax, dword ptr [esp+28]00401174  |.  52            push    edx                              ; /<%s>00401175  |.  68 B4304000   push    004030B4                         ; |<%s> = "slot >= 0 && slot < THREAD_POOL_SIZE"0040117A  |.  68 20314000   push    00403120                         ; |<%s> = "TaskQueM.c"0040117F  |.  6A 32         push    32                               ; |<%d> = 32 (50.)00401181  |.  68 DC304000   push    004030DC                         ; |Format = LF,"The following call failed at line %d in %s:",LF,LF,"    %s",LF,LF,"Reason: %s",LF,""00401186  |.  50            push    eax                              ; |s00401187  |.  FF15 6C204000 call    dword ptr [<&USER32.wsprintfA>]  ; \wsprintfA0040118D  |.  83C4 18       add     esp, 1800401190  |.  8D4C24 14     lea     ecx, dword ptr [esp+14]00401194  |.  8D7C24 28     lea     edi, dword ptr [esp+28]00401198  |.  33C0          xor     eax, eax0040119A  |.  6A 00         push    0                                ; /pOverlapped = NULL0040119C  |.  51            push    ecx                              ; |pBytesWritten0040119D  |.  83C9 FF       or      ecx, FFFFFFFF                    ; |004011A0  |.  8D5424 30     lea     edx, dword ptr [esp+30]          ; |004011A4  |.  F2:AE         repne   scas byte ptr es:[edi]           ; |004011A6  |.  F7D1          not     ecx                              ; |004011A8  |.  49            dec     ecx                              ; |004011A9  |.  51            push    ecx                              ; |nBytesToWrite004011AA  |.  52            push    edx                              ; |Buffer004011AB  |.  6A F4         push    -0C                              ; |/DevType = STD_ERROR_HANDLE004011AD  |.  FF15 08204000 call    dword ptr [<&KERNEL32.GetStdHand>; |\GetStdHandle004011B3  |.  50            push    eax                              ; |hFile004011B4  |.  FF15 04204000 call    dword ptr [<&KERNEL32.WriteFile>>; \WriteFile004011BA  |.  68 B80B0000   push    0BB8                             ; /Timeout = 3000. ms004011BF  |.  FF15 00204000 call    dword ptr [<&KERNEL32.Sleep>]    ; \Sleep004011C5  |.  6A 01         push    1                                ; /status = 1004011C7  |.  FF15 2C204000 call    dword ptr [<&MSVCRTD.exit>]      ; \exit004011CD  |>  FF15 10204000 call    dword ptr [<&KERNEL32.GetLastErr>; [GetLastError004011D3  |.  6A 00         push    0                                ; /Arguments = NULL004011D5  |.  8D4C24 14     lea     ecx, dword ptr [esp+14]          ; |004011D9  |.  6A 00         push    0                                ; |BufSize = 0004011DB  |.  51            push    ecx                              ; |Buffer004011DC  |.  6A 00         push    0                                ; |LanguageId = 0 (LANG_NEUTRAL)004011DE  |.  50            push    eax                              ; |MessageId004011DF  |.  6A 00         push    0                                ; |pSource = NULL004011E1  |.  68 00110000   push    1100                             ; |Flags = ALLOCATE_BUFFER|FROM_SYSTEM|0004011E6  |.  FF15 0C204000 call    dword ptr [<&KERNEL32.FormatMess>; \FormatMessageA004011EC  |.  8B5424 10     mov     edx, dword ptr [esp+10]004011F0  |.  8D4424 28     lea     eax, dword ptr [esp+28]004011F4  |.  52            push    edx                              ; /<%s>004011F5  |.  68 64304000   push    00403064                         ; |<%s> = "hThrds[slot] = CreateThread(NULL, 0, ThreadFunc, (LPVOID)slot, 0, &threadId )"004011FA  |.  68 20314000   push    00403120                         ; |<%s> = "TaskQueM.c"004011FF  |.  6A 3D         push    3D                               ; |<%d> = 3D (61.)00401201  |.  68 DC304000   push    004030DC                         ; |Format = LF,"The following call failed at line %d in %s:",LF,LF,"    %s",LF,LF,"Reason: %s",LF,""00401206  |.  50            push    eax                              ; |s00401207  |.  FF15 6C204000 call    dword ptr [<&USER32.wsprintfA>]  ; \wsprintfA0040120D  |.  83C4 18       add     esp, 1800401210  |.  8D4C24 14     lea     ecx, dword ptr [esp+14]00401214  |.  8D7C24 28     lea     edi, dword ptr [esp+28]00401218  |.  33C0          xor     eax, eax0040121A  |.  6A 00         push    0                                ; /pOverlapped = NULL0040121C  |.  51            push    ecx                              ; |pBytesWritten0040121D  |.  83C9 FF       or      ecx, FFFFFFFF                    ; |00401220  |.  8D5424 30     lea     edx, dword ptr [esp+30]          ; |00401224  |.  F2:AE         repne   scas byte ptr es:[edi]           ; |00401226  |.  F7D1          not     ecx                              ; |00401228  |.  49            dec     ecx                              ; |00401229  |.  51            push    ecx                              ; |nBytesToWrite0040122A  |.  52            push    edx                              ; |Buffer0040122B  |.  6A F4         push    -0C                              ; |/DevType = STD_ERROR_HANDLE0040122D  |.  FF15 08204000 call    dword ptr [<&KERNEL32.GetStdHand>; |\GetStdHandle00401233  |.  50            push    eax                              ; |hFile00401234  |.  FF15 04204000 call    dword ptr [<&KERNEL32.WriteFile>>; \WriteFile0040123A  |.  68 B80B0000   push    0BB8                             ; /Timeout = 3000. ms0040123F  |.  FF15 00204000 call    dword ptr [<&KERNEL32.Sleep>]    ; \Sleep00401245  |.  6A 01         push    1                                ; /status = 100401247  |.  FF15 2C204000 call    dword ptr [<&MSVCRTD.exit>]      ; \exit0040124D  |>  FF15 10204000 call    dword ptr [<&KERNEL32.GetLastErr>; [GetLastError00401253  |.  6A 00         push    0                                ; /Arguments = NULL00401255  |.  8D5424 14     lea     edx, dword ptr [esp+14]          ; |00401259  |.  6A 00         push    0                                ; |BufSize = 00040125B  |.  52            push    edx                              ; |Buffer0040125C  |.  6A 00         push    0                                ; |LanguageId = 0 (LANG_NEUTRAL)0040125E  |.  50            push    eax                              ; |MessageId0040125F  |.  6A 00         push    0                                ; |pSource = NULL00401261  |.  68 00110000   push    1100                             ; |Flags = ALLOCATE_BUFFER|FROM_SYSTEM|000401266  |.  FF15 0C204000 call    dword ptr [<&KERNEL32.FormatMess>; \FormatMessageA0040126C  |.  8B4424 10     mov     eax, dword ptr [esp+10]00401270  |.  8D4C24 28     lea     ecx, dword ptr [esp+28]00401274  |.  50            push    eax                              ; /<%s>00401275  |.  68 2C314000   push    0040312C                         ; |<%s> = "CloseHandle(hThrds[slot])"0040127A  |.  68 20314000   push    00403120                         ; |<%s> = "TaskQueM.c"0040127F  |.  6A 4B         push    4B                               ; |<%d> = 4B (75.)00401281  |.  68 DC304000   push    004030DC                         ; |Format = LF,"The following call failed at line %d in %s:",LF,LF,"    %s",LF,LF,"Reason: %s",LF,""00401286  |.  51            push    ecx                              ; |s00401287  |.  FF15 6C204000 call    dword ptr [<&USER32.wsprintfA>]  ; \wsprintfA0040128D  |.  8D7C24 40     lea     edi, dword ptr [esp+40]00401291  |.  83C9 FF       or      ecx, FFFFFFFF00401294  |.  33C0          xor     eax, eax00401296  |.  83C4 18       add     esp, 1800401299  |.  F2:AE         repne   scas byte ptr es:[edi]0040129B  |.  F7D1          not     ecx0040129D  |.  8D5424 14     lea     edx, dword ptr [esp+14]004012A1  |.  6A 00         push    0                                ; /pOverlapped = NULL004012A3  |.  49            dec     ecx                              ; |004012A4  |.  52            push    edx                              ; |pBytesWritten004012A5  |.  8D4424 30     lea     eax, dword ptr [esp+30]          ; |004012A9  |.  51            push    ecx                              ; |nBytesToWrite004012AA  |.  50            push    eax                              ; |Buffer004012AB  |.  6A F4         push    -0C                              ; |/DevType = STD_ERROR_HANDLE004012AD  |.  FF15 08204000 call    dword ptr [<&KERNEL32.GetStdHand>; |\GetStdHandle004012B3  |.  50            push    eax                              ; |hFile004012B4  |.  FF15 04204000 call    dword ptr [<&KERNEL32.WriteFile>>; \WriteFile004012BA  |.  68 B80B0000   push    0BB8                             ; /Timeout = 3000. ms004012BF  |.  FF15 00204000 call    dword ptr [<&KERNEL32.Sleep>]    ; \Sleep004012C5  |.  6A 01         push    1                                ; /status = 1004012C7  |.  FF15 2C204000 call    dword ptr [<&MSVCRTD.exit>]      ; \exit004012CD  |>  68 4C304000   push    0040304C                         ;  ASCII "All slots terminated",LF004012D2  |.  FFD5          call    ebp004012D4  |.  83C4 04       add     esp, 4004012D7  |.  33C0          xor     eax, eax004012D9  |.  5F            pop     edi004012DA  |.  5E            pop     esi004012DB  |.  5D            pop     ebp004012DC  |.  5B            pop     ebx004012DD  |.  81C4 18010000 add     esp, 118004012E3  |.  C3            retn004012E4  |>  FF15 10204000 call    dword ptr [<&KERNEL32.GetLastErr>; [GetLastError004012EA  |.  6A 00         push    0                                ; /Arguments = NULL004012EC  |.  8D4C24 14     lea     ecx, dword ptr [esp+14]          ; |004012F0  |.  6A 00         push    0                                ; |BufSize = 0004012F2  |.  51            push    ecx                              ; |Buffer004012F3  |.  6A 00         push    0                                ; |LanguageId = 0 (LANG_NEUTRAL)004012F5  |.  50            push    eax                              ; |MessageId004012F6  |.  6A 00         push    0                                ; |pSource = NULL004012F8  |.  68 00110000   push    1100                             ; |Flags = ALLOCATE_BUFFER|FROM_SYSTEM|0004012FD  |.  FF15 0C204000 call    dword ptr [<&KERNEL32.FormatMess>; \FormatMessageA00401303  |.  8B5424 10     mov     edx, dword ptr [esp+10]00401307  |.  8D4424 28     lea     eax, dword ptr [esp+28]0040130B  |.  52            push    edx                              ; /<%s>0040130C  |.  68 10304000   push    00403010                         ; |<%s> = "rc >= WAIT_OBJECT_0 && rc < WAIT_OBJECT_0+THREAD_POOL_SIZE"00401311  |.  68 20314000   push    00403120                         ; |<%s> = "TaskQueM.c"00401316  |.  6A 49         push    49                               ; |<%d> = 49 (73.)00401318  |.  68 DC304000   push    004030DC                         ; |Format = LF,"The following call failed at line %d in %s:",LF,LF,"    %s",LF,LF,"Reason: %s",LF,""0040131D  |.  50            push    eax                              ; |s0040131E  |.  FF15 6C204000 call    dword ptr [<&USER32.wsprintfA>]  ; \wsprintfA00401324  |.  83C4 18       add     esp, 1800401327  |.  8D4C24 14     lea     ecx, dword ptr [esp+14]0040132B  |.  8D7C24 28     lea     edi, dword ptr [esp+28]0040132F  |.  33C0          xor     eax, eax00401331  |.  6A 00         push    0                                ; /pOverlapped = NULL00401333  |.  51            push    ecx                              ; |pBytesWritten00401334  |.  83C9 FF       or      ecx, FFFFFFFF                    ; |00401337  |.  8D5424 30     lea     edx, dword ptr [esp+30]          ; |0040133B  |.  F2:AE         repne   scas byte ptr es:[edi]           ; |0040133D  |.  F7D1          not     ecx                              ; |0040133F  |.  49            dec     ecx                              ; |00401340  |.  51            push    ecx                              ; |nBytesToWrite00401341  |.  52            push    edx                              ; |Buffer00401342  |.  6A F4         push    -0C                              ; |/DevType = STD_ERROR_HANDLE00401344  |.  FF15 08204000 call    dword ptr [<&KERNEL32.GetStdHand>; |\GetStdHandle0040134A  |.  50            push    eax                              ; |hFile0040134B  |.  FF15 04204000 call    dword ptr [<&KERNEL32.WriteFile>>; \WriteFile00401351  |.  68 B80B0000   push    0BB8                             ; /Timeout = 3000. ms00401356  |.  FF15 00204000 call    dword ptr [<&KERNEL32.Sleep>]    ; \Sleep0040135C  |.  6A 01         push    1                                ; /status = 10040135E  |.  FF15 2C204000 call    dword ptr [<&MSVCRTD.exit>]      ; \exit00401364  |.  90            nop00401365  |.  90            nop00401366  |.  90            nop00401367  |.  90            nop00401368  |.  90            nop00401369  |.  90            nop0040136A  |.  90            nop0040136B  |.  90            nop0040136C  |.  90            nop0040136D  |.  90            nop0040136E  |.  90            nop0040136F  |.  90            nop00401370  |.  56            push    esi00401371  |.  FF15 20204000 call    dword ptr [<&KERNEL32.GetTickCou>; [GetTickCount00401377  |.  50            push    eax                              ; /seed00401378  |.  FF15 38204000 call    dword ptr [<&MSVCRTD.srand>]     ; \srand0040137E  |.  83C4 04       add     esp, 400401381  |.  FF15 34204000 call    dword ptr [<&MSVCRTD.rand>]      ; [rand00401387  |.  99            cdq00401388  |.  B9 0A000000   mov     ecx, 0A0040138D  |.  F7F9          idiv    ecx0040138F  |.  8D0492        lea     eax, dword ptr [edx+edx*4]00401392  |.  8D1480        lea     edx, dword ptr [eax+eax*4]00401395  |.  C1E2 05       shl     edx, 500401398  |.  81C2 F4010000 add     edx, 1F40040139E  |.  52            push    edx                              ; /Timeout0040139F  |.  FF15 00204000 call    dword ptr [<&KERNEL32.Sleep>]    ; \Sleep004013A5  |.  8B7424 08     mov     esi, dword ptr [esp+8]004013A9  |.  56            push    esi                              ; /<%d>004013AA  |.  68 7C314000   push    0040317C                         ; |format = "Slot %d idle",LF,""004013AF  |.  FF15 30204000 call    dword ptr [<&MSVCRTD.printf>]    ; \printf004013B5  |.  83C4 08       add     esp, 8004013B8  |.  8BC6          mov     eax, esi004013BA  |.  5E            pop     esi004013BB  \.  C2 0400       retn    4

 

 

thread

 

00401370  |.  56            push    esi00401371  |.  FF15 20204000 call    dword ptr [<&KERNEL32.GetTickCou>; [GetTickCount00401377  |.  50            push    eax                              ; /seed00401378  |.  FF15 38204000 call    dword ptr [<&MSVCRTD.srand>]     ; \srand0040137E  |.  83C4 04       add     esp, 400401381  |.  FF15 34204000 call    dword ptr [<&MSVCRTD.rand>]      ; [rand00401387  |.  99            cdq00401388  |.  B9 0A000000   mov     ecx, 0A0040138D  |.  F7F9          idiv    ecx0040138F  |.  8D0492        lea     eax, dword ptr [edx+edx*4]00401392  |.  8D1480        lea     edx, dword ptr [eax+eax*4]00401395  |.  C1E2 05       shl     edx, 500401398  |.  81C2 F4010000 add     edx, 1F40040139E  |.  52            push    edx                              ; /Timeout0040139F  |.  FF15 00204000 call    dword ptr [<&KERNEL32.Sleep>]    ; \Sleep004013A5  |.  8B7424 08     mov     esi, dword ptr [esp+8]004013A9  |.  56            push    esi                              ; /<%d>004013AA  |.  68 7C314000   push    0040317C                         ; |format = "Slot %d idle",LF,""004013AF  |.  FF15 30204000 call    dword ptr [<&MSVCRTD.printf>]    ; \printf004013B5  |.  83C4 08       add     esp, 8004013B8  |.  8BC6          mov     eax, esi004013BA  |.  5E            pop     esi004013BB  \.  C2 0400       retn    4

 ida

 

 

转载于:https://www.cnblogs.com/nanshouyong326/archive/2010/07/08/1773586.html


最新回复(0)