⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 test.c

📁 汇编语言编的TOOLHELPasm.rar程序,初学者可能会用到哦^_^TOOLHELPasm.rar
💻 C
📖 第 1 页 / 共 4 页
字号:

            /* Put some fun garbage in the text buffer */
            if (bHasData[Global.wType])
                sprintf(temp, "%s %d",
                    szBlockTypes[Global.wType], Global.wData);
            else
                lstrcpy(temp,szBlockTypes[Global.wType]);
            sprintf(npstr,
                "A=%08lX h=%04X S=%08lX O=%04X %c %-8s %s",
                Global.dwAddress, Global.hBlock, Global.dwBlockSize,
                Global.hOwner,
                Global.wHeapPresent ? 'Y' : 'N',
                Module.szModule,
                temp);

            /* Bump to the next spot */
            npstr += LIST_WIDTH + 1;
            ++i;
        }
        while (GlobalNext(&Global, GLOBAL_ALL));
    }

    /* Create number of items string */
    sprintf(szText, "GLOBAL_ALL:  Items = %u Really = %u",
        GlobalInf.wcItems, i);

    /* Clear list box */
    SendMessage(hwndList, WM_SETREDRAW, FALSE, 0L);
    SendMessage(hwndList, LB_RESETCONTENT, 0, 0L);

    /* Loop through all blocks, putting them in list box */
    for (i = 0, npstr = npText ; i < GlobalInf.wcItems ;
        ++i, npstr += LIST_WIDTH + 1)
        if (*npstr)
            SendMessage(hwndList, LB_ADDSTRING, 0,
                (LONG)(LPSTR)npstr);
    LocalFree((HANDLE)npText);
        
    /* OK to redraw list box now.  Also draw its title */
    SendMessage(hwndList, WM_SETREDRAW, TRUE, 0L);
    InvalidateRect(hwndList, NULL, TRUE);
    SetWindowText(hwndListStatic, szText);
    InvalidateRect(hwndListStatic, NULL, TRUE);

    /* Done with hourglass */
    ShowCursor(FALSE);
    SetCursor(hCursor);

    return 0L;
}


/*  WalkFreeList
 *      Walks the free list, putting the result in a list box.
 */

LONG WalkFreeList(
    HWND hwnd)
{
    GLOBALINFO GlobalInf;
    GLOBALENTRY Global;
    MODULEENTRY Module;
    char *npText;
    char *npstr;
    int i;
    HCURSOR hCursor;

    /* Turn on the hourglass */
    hCursor = SetCursor(LoadCursor(NULL, IDC_WAIT));
    ShowCursor(TRUE);
    wListStatus = LIST_GLOBAL;

    /* Allocate a buffer to store this stuff in */
    GlobalInf.dwSize = sizeof (GLOBALINFO);
    GlobalInfo(&GlobalInf);
    npText = npstr = (char *)LocalAlloc(LMEM_FIXED | LMEM_ZEROINIT,
        (GlobalInf.wcItemsFree + 10) * (LIST_WIDTH + 1));
    if (!npText)
        return 0L;

    /* Loop through the global heap */
    Global.dwSize = sizeof (GLOBALENTRY);
    if (GlobalFirst(&Global, GLOBAL_FREE))
    {
        i = 0;
        do
        {
            /* Get the module name */
            Module.dwSize = sizeof (MODULEENTRY);
            if (!Global.hOwner)
                lstrcpy(Module.szModule, "FREE");
            else if (!ModuleFindHandle(&Module, Global.hOwner))
                *Module.szModule = '\0';

            /* Put some fun garbage in the text buffer */
            sprintf(npstr, "A=%08lX h=%04X S=%08lX O=%04X f=%02X T=%2d %c %s",
                Global.dwAddress, Global.hBlock, Global.dwBlockSize,
                Global.hOwner, Global.wFlags, Global.wType,
                Global.wHeapPresent ? 'Y' : 'N', Module.szModule);

            /* Bump to the next spot */
            npstr += LIST_WIDTH + 1;
            ++i;
        }
        while (GlobalNext(&Global, GLOBAL_FREE));
    }

    /* Create number of items string */
    sprintf(szText, "GLOBAL_FREE:  Items = %u Really = %u",
        GlobalInf.wcItemsFree, i);

    /* Clear list box */
    SendMessage(hwndList, WM_SETREDRAW, FALSE, 0L);
    SendMessage(hwndList, LB_RESETCONTENT, 0, 0L);

    /* Loop through all blocks, putting them in list box */
    for (i = 0, npstr = npText ; i < GlobalInf.wcItemsFree ;
        ++i, npstr += LIST_WIDTH + 1)
        if (*npstr)
            SendMessage(hwndList, LB_ADDSTRING, 0,
                (LONG)(LPSTR)npstr);
    LocalFree((HANDLE)npText);
        
    /* OK to redraw list box now.  Also draw its title */
    SendMessage(hwndList, WM_SETREDRAW, TRUE, 0L);
    InvalidateRect(hwndList, NULL, TRUE);
    SetWindowText(hwndListStatic, szText);
    InvalidateRect(hwndListStatic, NULL, TRUE);

    /* Done with hourglass */
    ShowCursor(FALSE);
    SetCursor(hCursor);

    return 0L;
}


/*  WalkLRUList
 *      Walks the LRU list, putting the result in a list box.
 */

LONG WalkLRUList(
    HWND hwnd)
{
    GLOBALINFO GlobalInf;
    GLOBALENTRY Global;
    MODULEENTRY Module;
    char *npText;
    char *npstr;
    int i;
    HCURSOR hCursor;

    /* Turn on the hourglass */
    hCursor = SetCursor(LoadCursor(NULL, IDC_WAIT));
    ShowCursor(TRUE);
    wListStatus = LIST_GLOBAL;

    /* Allocate a buffer to store this stuff in */
    GlobalInf.dwSize = sizeof (GLOBALINFO);
    GlobalInfo(&GlobalInf);
    npText = npstr = (char *)LocalAlloc(LMEM_FIXED | LMEM_ZEROINIT,
        (GlobalInf.wcItemsLRU + 10) * (LIST_WIDTH + 1));
    if (!npText)
        return 0L;

    /* Loop through the global heap */
    Global.dwSize = sizeof (GLOBALENTRY);
    if (GlobalFirst(&Global, GLOBAL_LRU))
    {
        i = 0;
        do
        {
            /* Get the module name */
            Module.dwSize = sizeof (MODULEENTRY);
            if (!Global.hOwner)
                lstrcpy(Module.szModule, "FREE");
            else if (!ModuleFindHandle(&Module, Global.hOwner))
                *Module.szModule = '\0';

            /* Put some fun garbage in the text buffer */
            sprintf(npstr, "A=%08lX h=%04X S=%08lX O=%04X f=%02X T=%2d %c %s",
                Global.dwAddress, Global.hBlock, Global.dwBlockSize,
                Global.hOwner, Global.wFlags, Global.wType,
                Global.wHeapPresent ? 'Y' : 'N', Module.szModule);

            /* Bump to the next spot */
            npstr += LIST_WIDTH + 1;
            ++i;
        }
        while (GlobalNext(&Global, GLOBAL_LRU));
    }

    /* Create number of items string */
    sprintf(szText, "GLOBAL_LRU:  Items = %u Really = %u",
        GlobalInf.wcItemsLRU, i);

    /* Clear list box */
    SendMessage(hwndList, WM_SETREDRAW, FALSE, 0L);
    SendMessage(hwndList, LB_RESETCONTENT, 0, 0L);

    /* Loop through all blocks, putting them in list box */
    for (i = 0, npstr = npText ; i < GlobalInf.wcItemsLRU ;
        ++i, npstr += LIST_WIDTH + 1)
        if (*npstr)
            SendMessage(hwndList, LB_ADDSTRING, 0,
                (LONG)(LPSTR)npstr);
    LocalFree((HANDLE)npText);
        
    /* OK to redraw list box now.  Also draw its title */
    SendMessage(hwndList, WM_SETREDRAW, TRUE, 0L);
    InvalidateRect(hwndList, NULL, TRUE);
    SetWindowText(hwndListStatic, szText);
    InvalidateRect(hwndListStatic, NULL, TRUE);

    /* Done with hourglass */
    ShowCursor(FALSE);
    SetCursor(hCursor);

    return 0L;
}


/*  WalkLocalHeap
 *      Walks the local heap into the second list box
 */

LONG WalkLocalHeap(
    HWND hwnd,
    HANDLE hBlock)
{
    LOCALENTRY Local;
    LOCALINFO LocalInf;
    char *npText;
    char *npstr;
    HCURSOR hCursor;
    WORD i;

    /* Turn on the hourglass */
    hCursor = SetCursor(LoadCursor(NULL, IDC_WAIT));
    ShowCursor(TRUE);

    /* Allocate a buffer to do the local heapwalk */
    LocalInf.dwSize = sizeof (LOCALINFO);
    LocalInfo(&LocalInf, hBlock);
    npText = npstr = (char *)LocalAlloc(LMEM_FIXED | LMEM_ZEROINIT,
        LocalInf.wcItems * (LIST_WIDTH + 1));
    if (!npText)
        return 0L;

    /* Loop through the local heap */
    Local.dwSize = sizeof (LOCALENTRY);
    if (LocalFirst(&Local, hBlock))
    {
        char temp[30];

        do
        {
            /* Get the type string */
            if (Local.wFlags & LF_FREE)
                strcpy(temp, "Free");
            else if (Local.wHeapType == GDI_HEAP &&
                Local.wType <= LT_GDI_MAX)
                strcpy(temp, szGDI[Local.wType]);
            else if (Local.wHeapType == USER_HEAP &&
                Local.wType <= LT_USER_MAX)
                strcpy(temp, szUser[Local.wType]);
            else
                strcpy(temp, "Unknown");

            /* Put some fun garbage in the text buffer */
            sprintf(npstr, "Ad=%04X h=%04X Sz=%04X %-8s L=%02X %s",
                Local.wAddress, Local.hHandle, Local.wSize,
                szLocalFlags[Local.wFlags & 7], Local.wcLock, temp);

            /* Bump to the next spot */
            npstr += LIST_WIDTH + 1;
        }
        while (LocalNext(&Local));
    }

    /* Clear list box */
    SendMessage(hwndListLocal, WM_SETREDRAW, FALSE, 0L);
    SendMessage(hwndListLocal, LB_RESETCONTENT, 0, 0L);

    /* Loop through all blocks, putting them in list box */
    for (i = 0, npstr = npText ; i < LocalInf.wcItems ;
        ++i, npstr += LIST_WIDTH + 1)
        if (*npstr)
            SendMessage(hwndListLocal, LB_ADDSTRING, 0,
                (LONG)(LPSTR)npstr);
    LocalFree((HANDLE)npText);
        
    /* OK to redraw list box now */
    SendMessage(hwndListLocal, WM_SETREDRAW, TRUE, 0L);
    InvalidateRect(hwndListLocal, NULL, TRUE);

    /* Done with hourglass */
    ShowCursor(FALSE);
    SetCursor(hCursor);

    return 0L;
}



/*  WalkModuleList
 *      Walks the module list into the list box
 */

LONG WalkModuleList(
    HWND hwnd)
{
    MODULEENTRY Module;
    HCURSOR hCursor;

    /* Turn on the hourglass */
    hCursor = SetCursor(LoadCursor(NULL, IDC_WAIT));
    ShowCursor(TRUE);
    wListStatus = LIST_MODULE;

    /* Clear list box */
    SendMessage(hwndList, WM_SETREDRAW, FALSE, 0L);
    SendMessage(hwndList, LB_RESETCONTENT, 0, 0L);

    /* Loop through the module list */
    Module.dwSize = sizeof (MODULEENTRY);
    if (ModuleFirst(&Module))
        do
        {
            /* Put some fun garbage in the text buffer */
            sprintf(szText, "Mod=%s Path=%s", 
                Module.szModule, Module.szExePath);

            /* Put the string in the list box */
            SendMessage(hwndList, LB_ADDSTRING, 0, (LONG)(LPSTR)szText);
        }
        while (ModuleNext(&Module));

    /* OK to redraw list box now.  Also draw its title */
    SendMessage(hwndList, WM_SETREDRAW, TRUE, 0L);
    InvalidateRect(hwndList, NULL, TRUE);
    SetWindowText(hwndListStatic, "Module List");
    InvalidateRect(hwndListStatic, NULL, TRUE);

    /* Done with hourglass */
    ShowCursor(FALSE);
    SetCursor(hCursor);

    return 0L;
}



/*  WalkTaskList
 *      Walks the module list into the list box
 */

LONG WalkTaskList(
    HWND hwnd)
{
    TASKENTRY Task;
    HCURSOR hCursor;

    /* Turn on the hourglass */
    hCursor = SetCursor(LoadCursor(NULL, IDC_WAIT));
    ShowCursor(TRUE);
    wListStatus = LIST_TASK;

    /* Clear list box */
    SendMessage(hwndList, WM_SETREDRAW, FALSE, 0L);
    SendMessage(hwndList, LB_RESETCONTENT, 0, 0L);

    /* Loop through the task list */
    Task.dwSize = sizeof (TASKENTRY);
    if (TaskFirst(&Task))
        do
        {
            /* Put some fun garbage in the text buffer */
            sprintf(szText,
                "hTask=%04X Par=%04X hInst=%04X Mod=%04X szMod=%s",
                Task.hTask, Task.hTaskParent, Task.hInst, Task.hModule,
                Task.szModule);

            /* Put the string in the list box */
            SendMessage(hwndList, LB_ADDSTRING, 0, (LONG)(LPSTR)szText);
        }
        while (TaskNext(&Task));

    /* OK to redraw list box now.  Also draw its title */
    SendMessage(hwndList, WM_SETREDRAW, TRUE, 0L);
    InvalidateRect(hwndList, NULL, TRUE);
    SetWindowText(hwndListStatic, "Task List");
    InvalidateRect(hwndListStatic, NULL, TRUE);

    /* Done with hourglass */
    ShowCursor(FALSE);
    SetCursor(hCursor);

    return 0L;
}



/*  WalkClassList
 *      Walks the module list into the list box
 */

LONG WalkClassList(
    HWND hwnd)
{
    CLASSENTRY Class;
    HCURSOR hCursor;
    char szTemp[80];

    /* Turn on the hourglass */
    hCursor = SetCursor(LoadCursor(NULL, IDC_WAIT));
    ShowCursor(TRUE);
    wListStatus = LIST_CLASS;

    /* Clear list box */
    SendMessage(hwndList, WM_SETREDRAW, FALSE, 0L);
    SendMessage(hwndList, LB_RESETCONTENT, 0, 0L);

    /* Loop through the class list */
    Class.dwSize = sizeof (CLASSENTRY);
    if (ClassFirst(&Class))
        do
        {
            /* Put some fun garbage in the text buffer */
            sprintf(szText, "Name = %s  hInst = %04X",
                Class.szClassName, Class.hInst);

            /* Put the string in the list box */
            SendMessage(hwndList, LB_ADDSTRING, 0, (LONG)(LPSTR)szText);
        }
        while (ClassNext(&Class));

    /* OK to redraw list box now.  Also draw its title */
    SendMessage(hwndList, WM_SETREDRAW, TRUE, 0L);
    InvalidateRect(hwndList, NULL, TRUE);
    SetWindowText(hwndListStatic, "Class List");
    InvalidateRect(hwndListStatic, NULL, TRUE);

    /* Done with hourglass */
    ShowCursor(FALSE);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -