久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

  1. <legend id='tbYoB'><style id='tbYoB'><dir id='tbYoB'><q id='tbYoB'></q></dir></style></legend>

    <small id='tbYoB'></small><noframes id='tbYoB'>

    • <bdo id='tbYoB'></bdo><ul id='tbYoB'></ul>
    <tfoot id='tbYoB'></tfoot>

    <i id='tbYoB'><tr id='tbYoB'><dt id='tbYoB'><q id='tbYoB'><span id='tbYoB'><b id='tbYoB'><form id='tbYoB'><ins id='tbYoB'></ins><ul id='tbYoB'></ul><sub id='tbYoB'></sub></form><legend id='tbYoB'></legend><bdo id='tbYoB'><pre id='tbYoB'><center id='tbYoB'></center></pre></bdo></b><th id='tbYoB'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='tbYoB'><tfoot id='tbYoB'></tfoot><dl id='tbYoB'><fieldset id='tbYoB'></fieldset></dl></div>

    1. C++ 獲取程序打開套接字的句柄

      C++ Get Handle of Open Sockets of a Program(C++ 獲取程序打開套接字的句柄)

    2. <tfoot id='n7Nme'></tfoot>

            <small id='n7Nme'></small><noframes id='n7Nme'>

            • <bdo id='n7Nme'></bdo><ul id='n7Nme'></ul>

              • <i id='n7Nme'><tr id='n7Nme'><dt id='n7Nme'><q id='n7Nme'><span id='n7Nme'><b id='n7Nme'><form id='n7Nme'><ins id='n7Nme'></ins><ul id='n7Nme'></ul><sub id='n7Nme'></sub></form><legend id='n7Nme'></legend><bdo id='n7Nme'><pre id='n7Nme'><center id='n7Nme'></center></pre></bdo></b><th id='n7Nme'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='n7Nme'><tfoot id='n7Nme'></tfoot><dl id='n7Nme'><fieldset id='n7Nme'></fieldset></dl></div>
                <legend id='n7Nme'><style id='n7Nme'><dir id='n7Nme'><q id='n7Nme'></q></dir></style></legend>
                  <tbody id='n7Nme'></tbody>
                本文介紹了C++ 獲取程序打開套接字的句柄的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

                問題描述

                如何獲取程序創(chuàng)建的socket的Socket ID(句柄)?

                How is it possible to get the Socket ID (Handle) of the created sockets of a program?

                我知道我可以通過 GetTcpTable() 獲取所有程序中所有打開的套接字,但它有兩個問題:

                I know I can get all the open sockets in all programs by GetTcpTable() but it has two problems:

                1. 它顯示所有程序套接字
                2. 它不返回套接字的 ID(句柄)

                推薦答案

                正如 Remy 所說,這并非微不足道.您必須為系統(tǒng)中的每個進(jìn)程調(diào)用 OpenProcessPROCESS_DUP_HANDLE.您可能還需要 PROCESS_QUERY_INFORMATIONPROCESS_VM_READ,但我從不需要它(我見過使用它的其他代碼).

                As Remy said, its not trivial. You have to call OpenProcess with PROCESS_DUP_HANDLE for each process in the system. You might also need PROCESS_QUERY_INFORMATION and PROCESS_VM_READ, but I've never needed it (I've seen other code that uses it).

                對于每個進(jìn)程,您使用NtQuerySystemInformation(具有SystemHandleInformation 的信息類)訪問施主進(jìn)程的句柄表.最后,您調(diào)用 DuplicateHandle 使進(jìn)程的句柄也成為您的句柄.

                For each process, you access the donor process's handle table with NtQuerySystemInformation (with an information class of SystemHandleInformation). Finally, you call DuplicateHandle to make the process's handle your handle, too.

                在枚舉捐贈者進(jìn)程的句柄表時,您必須過濾句柄類型.對于您復(fù)制的每個句柄,使用 ObjectTypeInformation 調(diào)用 NtQueryObject.如果類型是套接字,則將其保持打開狀態(tài)并將其放入列表中.否則,關(guān)閉它并繼續(xù).

                You will have to filter the handle types when enumerating the donor process's handle table. For each handle you have duplicated, call NtQueryObject with ObjectTypeInformation. If the type is a socket, you keep it open and put it in your list. Otherwise, close it and go on.

                要執(zhí)行比較,代碼類似于下面.類型作為 UNICODE_STRING 返回:

                To perform the compare, the code looks similar to below. The type is returned as a UNICODE_STRING:

                // info was returned from NtQueryObject, ObjectTypeInformation
                POBJECT_TYPE_INFORMATION pObjectTypeInfo = (POBJECT_TYPE_INFORMATION)(LPVOID)info;
                
                wstring type( pObjectTypeInfo->Name.Buffer, pObjectTypeInfo->Name.Length );
                if( 0 != wcscmp( L"Socket", type.c_str() ) ) { /* Not a Socket */ }
                

                如果沒有 Socket 類型(我不記得了),您應(yīng)該嘗試獲取與句柄關(guān)聯(lián)的名稱(它仍然是 UNICODE_STRING),然后查找 \設(shè)備\Tcp.這一次,您將使用相同的句柄,但使用 ObjectNameInformation 調(diào)用 NtQueryObject:

                If there is no Socket type (I don't recall), you should try to get the name associated with the handle (its still a UNICODE_STRING), and look for \Device\Tcp. This time, you would use the same handle, but call NtQueryObject with ObjectNameInformation:

                // info was returned from NtQueryObject, ObjectNameInformation
                POBJECT_NAME_INFORMATION pObjectNameInfo = (POBJECT_NAME_INFORMATION)(LPVOID)info;
                
                wstring name( pObjectNameInfo->Name.Buffer, pObjectNameInfo->Name.Length );
                if( name.substr(0, 11) == "\Device\Tcp" ) ) { /* It's a TCP Socket */ }
                

                我自己是另一個人,幾年前也做過類似的事情.我們沒有使用套接字,而是使用互斥體和事件來使特權(quán)防病毒組件從其用戶級 UI 程序(與 IPC 的特權(quán)組件共享句柄)中崩潰.請參閱舊狗和新把戲:你知道你的把手在哪里嗎?.

                Myself an another fellow did similar a few years ago. Instead of Sockets, we used Mutexes and Events to crash privileged Antivirus components from their userland UI program (which was sharing handles with the privileged component for IPC). See Old Dogs and New Tricks: Do You Know Where Your Handles Are?.

                這篇關(guān)于C++ 獲取程序打開套接字的句柄的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

                【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請聯(lián)系我們刪除處理,感謝您的支持!

                相關(guān)文檔推薦

                In what ways do C++ exceptions slow down code when there are no exceptions thown?(當(dāng)沒有異常時,C++ 異常會以何種方式減慢代碼速度?)
                Why catch an exception as reference-to-const?(為什么要捕獲異常作為對 const 的引用?)
                When and how should I use exception handling?(我應(yīng)該何時以及如何使用異常處理?)
                Scope of exception object in C++(C++中異常對象的范圍)
                Catching exceptions from a constructor#39;s initializer list(從構(gòu)造函數(shù)的初始化列表中捕獲異常)
                Difference between C++03 throw() specifier C++11 noexcept(C++03 throw() 說明符 C++11 noexcept 之間的區(qū)別)
                • <i id='vF8ie'><tr id='vF8ie'><dt id='vF8ie'><q id='vF8ie'><span id='vF8ie'><b id='vF8ie'><form id='vF8ie'><ins id='vF8ie'></ins><ul id='vF8ie'></ul><sub id='vF8ie'></sub></form><legend id='vF8ie'></legend><bdo id='vF8ie'><pre id='vF8ie'><center id='vF8ie'></center></pre></bdo></b><th id='vF8ie'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='vF8ie'><tfoot id='vF8ie'></tfoot><dl id='vF8ie'><fieldset id='vF8ie'></fieldset></dl></div>
                    <bdo id='vF8ie'></bdo><ul id='vF8ie'></ul>

                        <tbody id='vF8ie'></tbody>

                      <small id='vF8ie'></small><noframes id='vF8ie'>

                          <legend id='vF8ie'><style id='vF8ie'><dir id='vF8ie'><q id='vF8ie'></q></dir></style></legend>
                          <tfoot id='vF8ie'></tfoot>
                          主站蜘蛛池模板: 欧美日韩专区 | 成人精品鲁一区一区二区 | 国产日韩久久 | 国产精品美女视频 | 免费成人高清在线视频 | 播放一级毛片 | 国产精品69毛片高清亚洲 | 午夜欧美a级理论片915影院 | 中文字幕一区二区三 | 亚洲成人精| 免费精品 | eeuss国产一区二区三区四区 | 久在线精品视频 | 特级做a爰片毛片免费看108 | 中文字幕97 | 亚洲欧美一区二区三区国产精品 | 欧美精品一二三 | 欧美高清视频 | 色婷婷亚洲国产女人的天堂 | 亚洲精品免费视频 | 毛片视频免费观看 | www.日本三级 | 成人精品视频在线观看 | 色综合天天综合网国产成人网 | 亚洲精品视频一区 | 国产黄色大片 | 成人性生交大片免费看中文带字幕 | 欧美一区二区三区 | 亚洲人成一区二区三区性色 | 欧洲精品在线观看 | 韩国av网站在线观看 | 91社区视频 | 成人永久免费视频 | 成人依人 | 国产网站在线免费观看 | 欧美成人免费 | 久久久夜 | 亚洲免费在线观看 | 天天看天天操 | 日本视频免费 | 欧美国产日韩在线观看 |