看板 Programming 關於我們 聯絡資訊
※ 引述《SeamusBerloz (軒摩斯)》之銘言: <引言刪除> : 以下我寫了簡單的 crash 程式,由華生博士偵測後log 記錄之檔案, : 節錄貼出來,並於後附上 crash 原始碼: : *----> 執行執行緒識別碼 0xeac 的狀態傾印<----* : eax=00000000 ebx=7ffd8000 ecx=00000000 edx=00000000 esi=00000000 edi=00000012 : eip=00401329 esp=0022ff40 ebp=0022ff68 iopl=0 nv up ei pl zr na po nc : cs=001b ss=0023 ds=0023 es=0023 fs=003b gs=0000 efl=00000246 : *** ERROR: Module load completed but symbols could not be loaded for D:\Temp\DrWaston\crash.exe : 功能: crash : 00401310 fc cld : 00401311 fe00 inc byte ptr [eax] : 00401313 0000 add [eax],al : 00401315 7f51 jg crash+0x1368 (00401368) : 00401317 8b45fc mov eax,[ebp-0x4] : 0040131a 8b0d08404000 mov ecx,[crash+0x4008 (00404008)] : 00401320 01c1 add ecx,eax : 00401322 8b55f8 mov edx,[ebp-0x8] : 00401325 b0ff mov al,0xff : 00401327 20d0 and al,dl : 錯誤 ->00401329 8801 mov [ecx],al ds:0023:00000000=?? : int main(void) : { : int i, iCounter = 0; : for(i = 0; i < 255; i ++) : { : g_lpCharacterPointer[i] = (char)(iCounter & 0xff); 根據ASM code,你應該是這一行出問題 你的整個code裡面 g_lpCharacterPointer 是在 TestFunction()裡面才做 allocate,可是main()這邊卻在呼叫 TestFunction() 之前就先填字進去, 當然會crash :p 把allocate memory的動作移到main()裡面 for loop前面吧 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 114.45.186.69
SeamusBerloz:感謝您!不過這個程式只是個示範, 183.4.116.230 09/03 23:09
SeamusBerloz:是我用來觸發 Dr. Watson 用的, 183.4.116.230 09/03 23:10
SeamusBerloz:(煩請參看原貼文) 183.4.116.230 09/03 23:10
SeamusBerloz:目的在於給大家看看 gcc 所編譯的程 183.4.116.230 09/03 23:10
SeamusBerloz:被 Dr. Watson 紀錄的 log 檔案內容 183.4.116.230 09/03 23:10
SeamusBerloz:關於 Label 與函數等都被化為位址偏 183.4.116.230 09/03 23:10
SeamusBerloz:當程式巨大,想要判別是哪一段程式 183.4.116.230 09/03 23:11
SeamusBerloz:產生存取違規,相對困難很多。 183.4.116.230 09/03 23:11
SeamusBerloz:另外因為實際要捕捉的程式相當大, 183.4.116.230 09/03 23:11
SeamusBerloz:出現違規存取的點,也不是固定出現, 183.4.116.230 09/03 23:11
SeamusBerloz:需要慢慢等候運作被中止才能在提供 183.4.116.230 09/03 23:11
SeamusBerloz:上來給大家看看了,再次感謝您的協助 183.4.116.230 09/03 23:12
cole945:dwarf格式windbg不認,mingw也不能生pdb 111.243.156.18 09/03 23:37
cole945:如果你能查出pc值的話. 用-g編,可以用 111.243.156.18 09/03 23:38
cole945:mingw的objdump -dl 查行號對應 111.243.156.18 09/03 23:38
SeamusBerloz:不好意思,不太了解你的意思... 183.4.116.230 09/04 00:06
SeamusBerloz:pc 值是指指令二元碼嗎? 183.4.116.230 09/04 00:07
SeamusBerloz:還是指 EIP 暫存器的值? 183.4.116.230 09/04 00:09
SeamusBerloz:的確!剛剛嘗試了一下,eip 的確可以 183.4.116.230 09/04 00:12
SeamusBerloz:對應到行號,並且正好等於log中的eip 183.4.116.230 09/04 00:14
SeamusBerloz:不知道是不是運氣好?程式載入偏移 183.4.116.230 09/04 00:14
SeamusBerloz:位址剛好相等?dll 之中也這樣嗎? 183.4.116.230 09/04 00:15
SeamusBerloz:我想說,若錯誤發生於 dll 中怎辦? 183.4.116.230 09/04 00:16
SeamusBerloz:因為dll也是我自己寫的說 -__-... 183.4.116.230 09/04 00:18
cole945:xp的話,執行檔應該不會做ASLR,所以會固定 111.243.151.96 09/04 22:35
cole945:dll有被rebase的話,自已算一下offset orz 111.243.151.96 09/04 22:35
SeamusBerloz:瞭解!沒錯!正猜大概要自己算偏移呢 183.4.123.29 09/04 23:15
SeamusBerloz:多一份方案,多一分實力,多多益善 183.4.123.29 09/04 23:17
SeamusBerloz:就是了!感謝您唷! 183.4.123.29 09/04 23:18
drinker: 位址化偏移你首先要抓的重點是base addr 1.162.64.133 10/03 22:14
drinker: 我猜你在log看到的偏移是 00001327 吧? 1.162.64.133 10/03 22:15