2017年2月12日 星期日

呼叫c++寫的dll時發生 "找不到指定的模組,發生例外狀況於HRESULT:0x8007007E)"

一般來說,被引用的dll檔放在執行檔目錄下都可以正確被引用
本篇要解決的問題是,被呼叫的dll檔確定已存在正確位置
執行程式呼叫該dll檔卻發生找不到dll檔的問題。

簡單紀錄解決方法如下:

1.開啟 VS2015開發人員命令提示字元
(通常在開始功能表的Visual Studio 2015下)

2.執行 dumpbin.exe xxxxx.dll /dependents 列出該dll檔所引用的其它dll
(xxxxx.dll就是你的程式執行時系統說找不到的dll檔名)



3.逐一確認發生問題電腦上是否有安裝這些dll

  • x86程式用的應該在 C:\Windows\SysWOW64
  • x64程式用的應該在 C:\Windows\System32

4.從安全的來源將缺少的dll檔補上
如果不知道該安裝那些軟體會重新安裝這些dll,可嘗試從其它電腦複製

2016年1月24日 星期日

VirtualBox複製硬碟檔發生 "虛擬硬碟的UUID已存在系統" 問題

VirtualBox 4.1.8 r75467還算穩定運作數個月後
原硬碟快滿了,將VM目錄完整複製到系統新硬碟
修改VirtualBox內VM設定,將虛擬硬碟檔案指向新位置失敗

因為該虛擬硬碟的UUID已存在系統,無法重覆註冊
使用下列修改新虛擬硬碟檔的UUID後就可以了


VBoxManage internalcommands setvdiuuid mydrive.vmdk

註1 
VBoxManage可能在C:\Program Files\Oracle\VirtualBox請自行蒐尋

註2
原PO內改的是.vdi檔,我的檔案是vmdk格式一樣沒問題

2015年3月15日 星期日

安裝於CentOS的supervisord無預警關閉 (crash with system time change - fixed)

有一隻自己寫的Linux程式跑在CentOS 6.6 x86_64上
寫的不好 執行發生錯誤時有可能會當掉
但為了某些原因它必須重新跑起來
[I installed supervisord 3.1.3 on CentOS 6.6 x86_64 to monitor a daemon
and to respawn it automatically whenever necessary]

網路文說supervisord是宣稱唯一不需要搶系統優先控制權的工具

簡單裝起來 只把自己的程式路徑名稱寫入設定檔
用預設值就跑起來了 以為一切就是這麼簡單美妙
[With almost everything in default value, supervisord started to run as exepcted]

第二天進系統檢查一下....


我的程式還苟活著 不錯

咦~ supervisord不見了 它......竟然掛了!
[However, surprise came to me on the second day. Supervisord crashed with no hint at all. It just gone!]


查遍各大論壇 終於看到有人po文表示:
自己的Linux時間常跑掉 用ntp對時後supervisord就無預警的掛了
[Some thread in a forum mentioned a symptom that supervisord crashes after ntpdate adjusted system time]

回測自己主機 確實在手動將時間往前調之後supervisord就閃退了
[I made some tests with manual 'date' command to turn back system time (hours). Oops! Same here: crash... crash... and crash.....]

再經過一番努力搜尋又測了三天 確認這個解法有用
[Luckily I found a solution by the honorable person "Mook-as". And his/hers solution was tested to work on my system]

 Use monotonic time for process state tracking by Mook-as

成因大致是supervisord處理time的方式讓它在系統時間倒退後出了問題
(例如某程序在檢查目前時間是否已到執行某工作時 發現自己回到過去了)

把所有time.time()換成monotonic_time()就好了
[For those who having the same problem as I did, apply the patch (I did it by manual input) to replace time.time() then it should work]

連結就是上方的標題

有相同需求的朋友請自行patch你的.py程式吧
[Thank you, Mook-as!]

cheers~

2015年2月24日 星期二

Tomato by Shibby之Access Restriction失效問題

為了限制部分電腦只能於特定時間上網
找了部Tenda N6改成Tomato by Shibby

設定Access Restriction功能後測試  無效!!!

電腦的IP位址已經被鎖了,卻仍可上網

挖出用過沒問題的無線路由器來比對

兩台路由器只有韌體版本不同

新: Tomato Firmware 1.28.0000 MIPSR2-124 K26 Max
舊: Tomato Firmware 1.28.0000 MIPSR2-123 K26 Max

直接將Tenda N6降版到123沒改設定,功能生效了

結論: 目前最新版v1.28 build 124的部分功能有問題

Function "Access Restriction" does not work properly in Tomato by Shibby v1.28 build 124. Pretty sure it's a bug in latest version because the same setting works after I downgrade firmware to v1.28 build 123.


2015年2月11日 星期三

kamailio IPv6運作超難搞 (失敗收場)


如果你想試試SIP/IPv6,很可能會搜尋到這篇文章:
Run your own SIP VoIP service on both IPv4 and IPv6


讀來如此簡單而美好

花兩天時間試過裝在以下各VM
CentOS 6.3 x86 (source編譯安裝)
Debian 7.7.0 i386 (source編譯安裝)
Debian 6.0.4 i386 (source編譯安裝)
Debian 7.0.0 i386 (直接從repo用apt-get安裝)

全部同樣的情況:
IPv4幾乎不需要設定就能動
IPv6怎麼設定5060 port都不收封包 (netstat確定有listen)

怎麼送封包給kamailio,只有下面這個系統回應
ICMPv6 Destination Unreachable (Port unreachable)

功力太淺,放棄

(kamailio has put me in hell for two days. too tired now to write in English..... 
my suggestion to the ones who got the same ICMPv6 Port unreachable packet is,
"give it up, now!", this is no fun at all)

2014年12月30日 星期二

C# 從 textbox 讀進 IP位址後移除前面0的原始碼

剛好需要用到,不懂C#靠著google瞎矇搞定了,貼給需要的人

如果你讀到 IP位址格式是這樣 "172.016.001.123"

但是你的程式必須轉換成 "172.16.1.123" 格式 (不能帶前面的 "0")

把這段加進去用
(程式碼寫到剛好可用,看不慣的請自行優化)
(只有下面這段我懂,其他 C# 我都不懂)

static class Extensions
{
    public static string Right(this string value, int length)
    {
        return value.Substring(value.Length - length);
    }

    public static string RemoveUnwantedZeros(this string value)
    {
        int i;
        string subStr="";
        bool ignore = false;


        for (i = 0; i < value.Length; i++)
        {
            if (value.Substring(i, 1).Equals("."))
            {
                subStr += value.Substring(i, 1);
                ignore = false;
            }
            else if (value.Substring(i, 1).Equals("0"))
            {
                if (ignore)
                {
                    subStr += value.Substring(i, 1);
                }
            }

            else
            {
                subStr += value.Substring(i, 1);
                ignore = true;
            }
        }
        return subStr;
    }
}


然後你程式內就可以用這個功能消掉不要的 '0'

realIP = Extensions.RemoveUnwantedZeros(txtIP);

祝福你~

2014年10月24日 星期五

ASUS RT-N12 D1無法燒Tomato by Shibby磚塊解法

2014.10 買了ASUS RT-N12 D1版 無線路由器
Tomato by Shibby支援的硬體裡 便宜又易買的選擇
拿來當翻牆用的PPtP VPN server

先試了N12內建的 PPtP server
做得很標準  只能連回來存取家裡網路的NAS跟PC

改燒Tomato韌體時 發現沒預期中簡單

網路上大家都說
插電時按住reset十秒左右 就會進入急救(recovery)模式
再用ASUS官網的Firmware Restoration軟體就可以硬燒

試了無數多次 這台完全進不了狀況

乾脆心一橫  改採極端的磚塊製造模式
(以下步驟,不想機器真的變磚塊的請勿模仿)

1.從官網下載原廠韌體
2.登入N12網頁進行韌體更新
3.進行到一半(我是讓它跑到90%確定正在寫flash)
4.拔電...

終於  它掛了!

重開幾次之後  在嘗試用瀏覽器登入192.168.1.1

哈~ Broadcom好樣的
Bootloader裡還有簡易版的web server讓你重燒韌體

就這樣把tomato-K26-1.28.RT-N5x-MIPSR2-123-Max.trx燒進去

重新開機後  番茄icon出現在瀏覽器tab上

大功告成!