• <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>

            從頭再來

            #

            asio服務器



            原來使用boost::asio 庫時,基本上只用了一個io_serve   這種情況下,其實并不能把多線程的好處利用起來。 當異步任務多的時候,集中到一個線程上去了。

            這邊有網友貼了一個完整的asio 多線程服務器。

            http://blog.sina.com.cn/s/blog_48d4cf2d0100nvei.html

            粗看了一下, 服務器里面的session封裝不給力,沒有用到shared_ptr 。 多次出現delete .  

            這個其實用智能指針,可以很方便的管理生命周期。

            posted @ 2014-06-16 15:25 易寶@byhh 閱讀(169) | 評論 (0)編輯 收藏

            Android 逆向

            APKTool反編譯后再打包出錯(Error retrieving parent for item: No resource found that matches the given name '@*android:style/Theme.Light')  


             看出錯情形,是styles.xml出錯了,因為是自己寫的,所以打開原始的XML與反編譯后的XML一對比,發現反編譯后的XML里<resources>/<style>parent屬性出錯了,由原本的android:Theme.xxx變成了@*android:style/Theme.xxx,前面多出來@*,中間多出來style/,原因找到就好辦了,將這些XML改正確,再打包,成了!

            http://dreamisx.blog.163.com/blog/static/1150048392012112024649308/


            另外還有一些@*的不能改。 

            如果報lib png 的錯。直接打開畫圖程序一個個重新覆蓋一下就行了。 這個是體力活。

            posted @ 2014-04-06 22:08 易寶@byhh 閱讀(168) | 評論 (0)編輯 收藏

            Linux 服務器配置證書登陸


            一、背景
            項目需要,研究了使用ossec ,其中有一個ossec agentless的功能,可以實現遠程的文件完整性校驗 。為方便使用, 決定采用證書模式來處理登陸。


            二、配置過程

            以下直接抄了  http://praetorianprefect.com/archives/2009/11/ossec-agentless-to-save-the-day/

            obsd46# sudo -u ossec ssh-keygen Generating public/private rsa key pair. Enter file in which to save the key (/var/ossec/.ssh/id_rsa): Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /var/ossec/.ssh/id_rsa. Your public key has been saved in /var/ossec/.ssh/id_rsa.pub. The key fingerprint is: b8:c3:47:9a:33:09:5c:eb:54:a0:82:39:a6:06:63:08 ossec@obsd45.ptnsecurity.com   The key's randomart image is: +--[ RSA 2048]----+ |E     .          | |oo   . .         | |Bo. . . .        | |=o o . +         | |..  o + S        | |.    = *         | |      @ .        | |       =         | |                 | +-----------------+ 

            Now that the SSH keys are present, we can add the host without a password. The special command line argument used with register_host.sh is NOPASS in all capitals, which will tell OSSEC supplied scripts to make use of SSH keys.

            obsd46# /var/ossec/agentless/register_host.sh add root@172.17.20.20   NOPASS 

            Enabling SSH key on the host to be monitored.

            You will now need to securely get the contents of /var/ossec/.ssh/id_rsa.pub to 172.17.20.20.

            Using SSH and the password for a single time will make this simple. This will create the /root/.ssh if it is not already created, but might throw an error as it does if the directory is already present. This is not a problem and can be ignored.

            obsd46# cat /var/ossec/.ssh/id_rsa.pub | ssh root@172.17.20.20   "( mkdir /root/.ssh/;  cat - >> /root/.ssh/authorized_keys )" root@172.17.20.20  's password: mkdir: cannot create directory `/root/.ssh/': File exists obsd46# ssh root@172.17.20.20   "cat  /root/.ssh/authorized_keys " root@172.17.20.20  's password: ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAzyTBo7CqkI0TISR9S+KPS/gYY60nkD7Qe8wTTXrAEFvPNFJ NJJpVVKsij6zw86lvTZ6hx9ib1M+MXvt+70uF/z1hYwnYrczR2TR03Z5nwOUA9OK61nBWXVwCi9GsQs6Oeo mY9vkBDoKzB52+TKKSk9ZoC+HYPiT5SaiHZvMOV7kWuwF67lnYwlG5FdkRdOiXp7DcRjje4/Hixg7RLLl7o dEXpIakzGfalt3yQDmwvSUZhyg3OuoKimTeNiKU/jlHlmEPuDZpiQe6QhFH38EeEIZTdHsYITodl8sY+n9I eNMalGIHPs+bph+qcK+6cOb1RGaeGqJBFjaqPUyismz0bw== ossec@obsd45.ptnsecurity.com   

            We can also verify that it worked with the following command.

            obsd46# sudo -u ossec ssh root@172.17.20.20   The authenticity of host '172.17.20.20 (172.17.20.20)' can't be established. RSA key fingerprint is 14:cd:f2:e9:c3:5b:07:28:68:75:a7:b5:88:c2:6b:77. Are you sure you want to continue connecting (yes/no)? yes Warning: Permanently added '172.17.20.20' (RSA) to the list of known hosts. Last login: Tue Oct  6 12:40:05 2009 from 172.17.20.154 [linux26.ptnsecurity.com ~]# exit 

            三、問題
            在以上各種折騰完成后,使用root賬號已經可以正常登陸使用了
            但在使用普通賬號的mytest時卻一直失敗。 經網上搜索有以下版本的信息

            http://www.2cto.com/os/201206/137286.html
            http://serverfault.com/questions/230771/ssh-configuration-publickeys-permission-denied-publickey-password-error 
            另外還有一個網址一時忘記了。

            中途試著將密碼鑒權關閉,直接報錯:
            Permission denied (publickey,gssapi-keyex,gssapi-with-mic).  

            最終查看 /var/log/secure Authentication refused: bad ownership or modes for directory /home/mytest/.ssh

            想起來我忘記的那個網址上有一句話: .ssh 目錄需要是 755 不能是775 。。。然后修改就搞定了!!!!完成收工。

            posted @ 2014-04-01 14:20 易寶@byhh 閱讀(500) | 評論 (0)編輯 收藏

            將系統線程與設備驅動程序相關聯


            當設備驅動 程序創建一個 系統線程運行時,線程運行在system process中,任務管理器在計算cpu占用時,以進程為單位,無法確定CPU實際消耗在哪個驅動上。


            以下為一個使用的例子

            1、打開cmd窗口。
            2、執行dir \\computername\c$ /s 遍歷列出c盤文件,這個list會很大,所以一直會運行。
            3、運行process explorer ,打開system process 屬性頁面
            4、切換到線程標簽頁
            5、按Cswith data 排序 ,在start address處將可以看到srv2.sys 設備驅動。此處即表示線程對應的驅動程序。點擊module按鈕可以瀏覽驅動文件的屬性。

            posted @ 2013-08-24 23:18 易寶@byhh 閱讀(216) | 評論 (0)編輯 收藏

            Failed to create snapshot. Error -3941


            早上收到郵件。VDR又故障了,這次的錯是  Failed to create snapshot. Error -3941

            google了一下, VDR的知識文章還是略少了。 各種都不相關啊。

            最后在官方的KB中 找到一篇看上去有點像的文章  http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=1028924

            結果
            也是大失所望。居然說是磁盤超過備份限制。。。官方的文章果然各種二。


            最后各種折騰,發現是虛擬機上直聯了一塊PCI設備。導致無法創建快照。

            posted @ 2013-07-03 09:17 易寶@byhh 閱讀(1249) | 評論 (0)編輯 收藏

            vSphere Data Protection 備份失敗

            E100007: Miscellaneous error 
            到VDP 控制臺去查看日志后 有以下結果。
            avvcbimage error  12041   disk size in backup  is different than target and changed block processing was requested, restore of disk   at    failed please collect administrator log and submit a support request


            原因應當是我修改硬盤屬性導致。

            posted @ 2013-01-09 10:48 易寶@byhh 閱讀(511) | 評論 (0)編輯 收藏

            windows 進程 可打開的最大句柄數

            以下文字摘自"Windows Internals Fifth Edition "


            An object handle is an index into a process-specific handle table, pointed to by the executive
            process (EPROCESS) block (described in Chapter 5). The first handle index is 4, the second
            8, and so on. A process’s handle table contains pointers to all the objects that the process
            has opened a handle to. Handle tables are implemented as a three-level scheme, similar
            to the way that the x86 memory management unit implements virtual-to-physical address
            152 Windows Internals, Fifth Edition
            translation, giving a maximum of more than 16,000,000 handles per process


            The test program Testlimit from Sysinternals has an option to open handles to an object
            until it cannot open any more handles. You can use this to see how many handles can
            be created in a single process on your system. Because handle tables are allocated from
            paged pool, you might run out of paged pool before you hit the maximum number of
            handles that can be created in a single process. To see how many handles you can create
            on your system, follow these steps:
            1. Download the Testlimit .zip file from www.microsoft.com/technet/ sysinternals, and
            unzip it into a directory.
            Run Process Explorer, and then click View and then System Information. Notice
            the current and maximum size of paged pool. (To display the maximum pool size
            values, Process Explorer must be configured properly to access the symbols for
            the kernel image, Ntoskrnl.exe.) Leave this system information display running so
            that you can see pool utilization when you run the Testlimit program.
            3. Open a command prompt.
            4. Run the Testlimit program with the -h switch (do this by typing testlimit –h).
            When Testlimit fails to open a new handle, it will display the total number of
            handles it was able to create. If the number is less than approximately 16 million,
            you are probably running out of paged pool before hitting the theoretical perprocess
            handle limit.
            5. Close the Command Prompt window; doing this will kill the Testlimit process, thus
            closing all the open handles.

            posted @ 2012-11-07 17:26 易寶@byhh 閱讀(2608) | 評論 (0)編輯 收藏

            Linux 內存尋址 - 常規分頁

            從80386開始,Intel 處理器處理 4KB的頁。


            32位線性地址分為 10 10 12 三部分。 directory table offset

            cr3控制寄存器中存放正使用的頁目錄的物理地址。


            一個頁目錄項與頁表項結構相同。 其中有20位Field 包含頁框的物理地址。

            當從cr3 中獲取到頁目錄地址時,取線性地址的高10位取頁目錄(4KB,每一個32位占4字節,共1024個頁表)中指向的頁表項地址(20位的Field)

            使用取出來的物理地址得到頁表地址,線性地址的中間10位,取頁表內偏移量,取含有數據的頁的物理地址。

            最終使用線性地址的12位取頁內數據偏移量。


            頁目錄項指向的頁表中有4096的物理地址,也就是對應1024個頁表項,剛好與線性地址的10位相符。

            而頁表項指向的項含有4096的物理地址,偏移量需要線性地址的12來取offset



            cr4寄存器,PSE標記,可使得擴展分頁與常規分頁共存。

            cr0 的PG = 0時,線性地址被解析為物理地址。

            posted @ 2012-04-30 20:10 易寶@byhh 閱讀(371) | 評論 (1)編輯 收藏

            webkit 隨筆

            How to: Set a Thread Name in Native Code

            dddd

            最近在分析webkit 項目 。

            分享其中幾個tips!

            一、WTF庫
            WTF的詳細含義未找到出處,在webkit上找了找,大致是webkit 項目 繼承使用的之前的一個封裝庫。其中包涵了數值轉換,字符串,智能指針,線程管理,線程間同步等函數庫。
            從源代碼的命名來看,有多種移植版本,如以下注釋 

            // For portability, we do not use thread-safe statics natively supported by some compilers (e.g. gcc).
            #define AtomicallyInitializedStatic(T, name) \
                WTF::lockAtomicallyInitializedStaticMutex(); \
                static T name; \
                WTF::unlockAtomicallyInitializedStaticMutex();

            二、

            How to: Set a Thread Name in Native Code

               MSDN的釋義是To set a thread name in your program, use the SetThreadName function

            原文見:http://msdn.microsoft.com/en-us/library/xcb2z8hs(VS.90).aspx

             
             1
            //
             2 // Usage: SetThreadName (-1, "MainThread");
             3 //
             4 #include <windows.h>
             5 const DWORD MS_VC_EXCEPTION=0x406D1388;
             6 
             7 #pragma pack(push,8)
             8 typedef struct tagTHREADNAME_INFO
             9 {
            10    DWORD dwType; // Must be 0x1000.
            11    LPCSTR szName; // Pointer to name (in user addr space).
            12    DWORD dwThreadID; // Thread ID (-1=caller thread).
            13    DWORD dwFlags; // Reserved for future use, must be zero.
            14 } THREADNAME_INFO;
            15 #pragma pack(pop)
            16 
            17 void SetThreadName( DWORD dwThreadID, char* threadName)
            18 {
            19    THREADNAME_INFO info;
            20    info.dwType = 0x1000;
            21    info.szName = threadName;
            22    info.dwThreadID = dwThreadID;
            23    info.dwFlags = 0;
            24 
            25    __try
            26    {
            27       RaiseException( MS_VC_EXCEPTION, 0, sizeof(info)/sizeof(ULONG_PTR), (ULONG_PTR*)&info );
            28    }
            29    __except(EXCEPTION_EXECUTE_HANDLER)
            30    {
            31    }
            32 }


            posted @ 2012-04-28 22:32 易寶@byhh 閱讀(460) | 評論 (0)編輯 收藏

            chrome 編譯

            一、準備編譯
               此步參照網絡上的文章,中文翻譯或者直接查看官網,推薦 官網,翻譯后的文章可能會少掉一些步驟。

            二、編譯中注意事項

            下載與安裝 DirectX SDK 這一步是必須的,否則會提示少了d3d9.h 文件以及一系列的lib文件。

            i18n.cc 文件中可能有一個錯誤

            typedef BOOL( WINAPI* GetPreferredUILanguages_Fn)(DWORD, PULONG, PWZZSTR, PULONG);
            這一行報錯。 __stdcall 前缺少) ,經查看,此函數聲明對應一個指針數組中的函數。

            第三個參數應當為PWSTR .修改后。base.lib 項目編譯通過

            -- update 此處是windows SDK 7 中的函數聲明。需要更新SDK包后就編譯OK啦。

            三、編譯最好選在休息時間。

            夜間編譯其實也不錯,但若出問題,可能反而浪費了時間。

            posted @ 2012-04-01 21:05 易寶@byhh 閱讀(763) | 評論 (0)編輯 收藏

            僅列出標題
            共3頁: 1 2 3 
            人人狠狠综合88综合久久| 成人国内精品久久久久一区| 中文字幕亚洲综合久久| 久久国产热精品波多野结衣AV| 国产成人精品久久亚洲高清不卡 | 久久综合九色综合网站| 久久久久免费视频| 国产欧美久久一区二区| 久久久久AV综合网成人| 99热成人精品免费久久| 伊人色综合久久天天人手人婷| 噜噜噜色噜噜噜久久| 久久精品中文字幕大胸| 久久夜色精品国产亚洲| 成人亚洲欧美久久久久| 99久久精品免费看国产一区二区三区| 久久―日本道色综合久久| 一极黄色视频久久网站| 久久久国产精华液| 日韩人妻无码一区二区三区久久 | 久久国产V一级毛多内射| 狠狠色婷婷综合天天久久丁香| 一本色综合久久| 欧美精品福利视频一区二区三区久久久精品| 国产精品综合久久第一页 | 久久精品国产只有精品66 | 色欲综合久久躁天天躁蜜桃| 亚洲国产精品一区二区久久hs| 青青热久久国产久精品 | 久久久久亚洲av成人网人人软件 | 久久婷婷午色综合夜啪| 国产精品激情综合久久| 69国产成人综合久久精品| 国内精品伊人久久久久影院对白| 久久99久久99精品免视看动漫| 色偷偷久久一区二区三区| 亚洲国产精品无码久久久不卡 | 开心久久婷婷综合中文字幕| 久久精品亚洲精品国产欧美| 久久精品国产一区二区三区不卡 | 成人资源影音先锋久久资源网|