• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>

            簡單的CreateRemoteThread例程2Dll-初學(xué)者必看

            // dll.cpp : Defines the initialization routines for the DLL.
            // Author:秋鎮(zhèn)菜

            #include "stdafx.h"
            #include <afxdllx.h>

            #ifdef _DEBUG
            #define new DEBUG_NEW
            #undef THIS_FILE
            static char THIS_FILE[] = __FILE__;
            #endif


            static AFX_EXTENSION_MODULE DllDLL = { NULL, NULL };

            extern "C" int APIENTRY
            DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
            {
            // Remove this if you use lpReserved
            UNREFERENCED_PARAMETER(lpReserved);

            if (dwReason == DLL_PROCESS_ATTACH)
            {
               TRACE0("DLL.DLL Initializing!\n");
              
               // Extension DLL one-time initialization
               if (!AfxInitExtensionModule(DllDLL, hInstance))
                return 0;

               // Insert this DLL into the resource chain
               // NOTE: If this Extension DLL is being implicitly linked to by
               // an MFC Regular DLL (such as an ActiveX Control)
               // instead of an MFC application, then you will want to
               // remove this line from DllMain and put it in a separate
               // function exported from this Extension DLL. The Regular DLL
               // that uses this Extension DLL should then explicitly call that
               // function to initialize this Extension DLL. Otherwise,
               // the CDynLinkLibrary object will not be attached to the
               // Regular DLL's resource chain, and serious problems will
               // result.
               MessageBox(NULL, "對(duì)話框", NULL, MB_OK);
               new CDynLinkLibrary(DllDLL);
            }
            else if (dwReason == DLL_PROCESS_DETACH)
            {
               TRACE0("DLL.DLL Terminating!\n");
               // Terminate the library before destructors are called
               AfxTermExtensionModule(DllDLL);
            }
            return 1;   // ok
            }


            // remotethread.cpp : Defines the entry point for the console application.
            // Author:秋鎮(zhèn)菜

            #include "stdafx.h"
            #include "windows.h"

            int main(int argc, char* argv[])
            {
            HWND hWnd = FindWindow("notepad", NULL);
            DWORD dwId;
            GetWindowThreadProcessId(hWnd, &dwId);
            HANDLE hProcess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, dwId);
            if (! hProcess)
               return 0;

            char sz[MAX_PATH];
            GetModuleFileName(NULL, sz, MAX_PATH);
            strcpy(strstr(sz,".exe"), ".dll");
            strcpy(sz, "c:\\windows\\dll.dll");
            void *pData = VirtualAllocEx(hProcess, 0, sizeof (sz), MEM_COMMIT, PAGE_READWRITE);
            if (! pData)
               return 0;
            if (! WriteProcessMemory(hProcess, pData, sz, sizeof (sz), 0))
               return 0;
            HANDLE hThread = CreateRemoteThread(hProcess, NULL, 0,
               (LPTHREAD_START_ROUTINE)GetProcAddress(
               LoadLibrary("kernel32.dll"), "LoadLibraryA"), pData, 0, 0);
            if (hThread == NULL)
               return 0;
            printf("sssssssssssssssssssssssssssssss\r\n");
            WaitForSingleObject(hThread, INFINITE);
            DWORD dwModule;
            GetExitCodeThread(hThread, &dwModule);
            CloseHandle(hThread);
            VirtualFreeEx(hProcess, pData, sizeof (sz), MEM_RELEASE);
            printf("...............................\r\n");
            hThread = CreateRemoteThread(hProcess, NULL, 0,
               (LPTHREAD_START_ROUTINE)GetProcAddress(
               LoadLibrary("kernel32.dll"), "FreeLibrary"), &dwModule, 0, 0);
            if (hThread == NULL)
               return 0;
            WaitForSingleObject(hThread, INFINITE);
            CloseHandle(hThread);
            CloseHandle(hProcess);
            printf(sz);
            printf("\r\n");
            Sleep(2000);
            return 0;
            }

            posted on 2010-06-21 22:53 lhking 閱讀(376) 評(píng)論(0)  編輯 收藏 引用


            只有注冊用戶登錄后才能發(fā)表評(píng)論。
            網(wǎng)站導(dǎo)航: 博客園   IT新聞   BlogJava   博問   Chat2DB   管理


            導(dǎo)航

            <2010年6月>
            303112345
            6789101112
            13141516171819
            20212223242526
            27282930123
            45678910

            統(tǒng)計(jì)

            常用鏈接

            留言簿

            隨筆檔案

            搜索

            最新評(píng)論

            閱讀排行榜

            評(píng)論排行榜

            久久久久久久女国产乱让韩| 久久婷婷色综合一区二区| 久久精品黄AA片一区二区三区| 精品国产99久久久久久麻豆| 久久亚洲春色中文字幕久久久| 国产精品久久久久无码av| 久久强奷乱码老熟女| 久久久久久久精品妇女99| 久久久久久狠狠丁香| 久久久久亚洲精品日久生情| 久久久久一本毛久久久| 九九精品久久久久久噜噜| 久久国产精品77777| 久久久久久国产a免费观看不卡| 伊人久久大香线蕉av不卡| 国产99久久久国产精品~~牛| 久久久久18| 国产A级毛片久久久精品毛片| 久久亚洲欧洲国产综合| 精品国产乱码久久久久软件 | 久久亚洲AV永久无码精品| 97久久国产综合精品女不卡| 丰满少妇人妻久久久久久4| 漂亮人妻被黑人久久精品| 久久免费大片| 久久99精品久久久久久水蜜桃| 无码人妻精品一区二区三区久久 | 色婷婷噜噜久久国产精品12p| 69久久夜色精品国产69| 午夜精品久久久久久毛片| 久久亚洲AV无码精品色午夜麻豆 | 亚洲va久久久噜噜噜久久狠狠| 久久久久99精品成人片三人毛片 | 久久免费视频6| 久久综合久久性久99毛片| 久久精品一区二区影院| 99国内精品久久久久久久| 久久本道伊人久久| 久久亚洲精品中文字幕三区| 国产精品禁18久久久夂久| 久久久老熟女一区二区三区|