Сейчас на форуме: asfa, Rio (+5 невидимых)

 eXeL@B —› Вопросы новичков —› Ida, positive sp value has been found - Command ChangeStackPointer failed
Посл.ответ Сообщение

Ранг: 10.4 (новичок)
Активность: 0.020
Статус: Участник

Создано: 10 февраля 2014 23:49
· Личное сообщение · #1

Не могу понять как решить ошибку декомпиляции hex-rays, жму F5 на функции, ругается:

487BDD positive sp value has been found

Code:
  1. .text:00487B10 ; void __thiscall CRuPaperdollTemplate__CRuPaperdollTemplate(CRuPaperdollTemplate *this)
  2. .text:00487B10 ??0CRuPaperdollTemplate@@QAE@XZ proc near
  3. .text:00487B10                                         ; CODE XREF: CRuObjectModule_PaperdollTemplate::CreateObject(void)+40p
  4. .text:00487B10 this = edi
  5. .text:00487B10                 push    ebx
  6. .text:00487B11                 push    ebp
  7. .text:00487B12                 push    esi
  8. .text:00487B13                 mov     esi, this
  9. .text:00487B15                 call    ??0IRuObject@@QAE@XZ ; IRuObject::IRuObject(void)
  10. .text:00487B1A                 xor     esi, esi
  11. .text:00487B1C                 xor     ecx, ecx
  12. .text:00487B1E                 mov     eax, 1
  13. .text:00487B23                 mov     edx, 4
  14. .text:00487B28                 mul     edx
  15. .text:00487B2A                 mov     dword ptr [this], offset ??_7CRuPaperdollTemplate@@6B@ ; const CRuPaperdollTemplate::`vftable'
  16. .text:00487B30                 seto    cl
  17. .text:00487B33                 mov     [this+60h], esi
  18. .text:00487B36                 mov     [this+64h], esi
  19. .text:00487B39                 mov     [this+68h], esi
  20. .text:00487B3C                 mov     [this+6Ch], esi
  21. .text:00487B3F                 mov     [this+70h], esi
  22. .text:00487B42                 mov     [this+74h], esi
  23. .text:00487B45                 lea     ebp, [this+60h]
  24. .text:00487B48                 lea     ebx, [this+6Ch]
  25. .text:00487B4B                 mov     [this+78h], esi
  26. .text:00487B4E                 mov     [this+7Ch], esi
  27. .text:00487B51                 mov     [this+80h], esi
  28. .text:00487B57                 neg     ecx
  29. .text:00487B59                 or      ecx, eax        ; this
  30. .text:00487B5B                 mov     [this+84h], esi
  31. .text:00487B61                 mov     [this+88h], esi
  32. .text:00487B67                 mov     [this+8Ch], esi
  33. .text:00487B6D                 push    ecx             ; Size
  34. .text:00487B6E                 mov     [this+90h], esi
  35. .text:00487B74                 call    ??2@YAPAXI@Z    ; operator new(uint)
  36. .text:00487B79                 mov     [this+98h], esi
  37. .text:00487B7F                 mov     [this+0A0h], esi
  38. .text:00487B85                 add     esp, 4
  39. .text:00487B88                 lea     esi, [this+0A4h]
  40. .text:00487B8E                 mov     [this+94h], eax
  41. .text:00487B94                 mov     dword ptr [this+9Ch], 1
  42. .text:00487B9E                 call    ??0?$CRuStack@PAVBatchDesc@CRuEntity_Particle_Visualizer_Sprite@@@@QAE@H@Z ; CRuStack<CRuEntity_Particle_Visualizer_Sprite::BatchDesc *>::CRuStack<CRuEntity_Particle_Visualizer_Sprite::BatchDesc *>(int)
  43. .text:00487BA3                 push    offset unk_8CCFA6 ; str
  44. .text:00487BA8                 mov     esi, ebp
  45. .text:00487BAA                 call    ??4CRuString@@QAEAAV0@PBD@Z ; CRuString::operator=(char const *)
  46. .text:00487BAF                 push    offset a_ros    ; ".ros"
  47. .text:00487BB4                 mov     esi, ebx
  48. .text:00487BB6                 call    ??4CRuString@@QAEAAV0@PBD@Z ; CRuString::operator=(char const *)
  49. .text:00487BBB                 push    offset unk_8CCFA6 ; str
  50. .text:00487BC0                 lea     esi, [this+78h]
  51. .text:00487BC3                 call    ??4CRuString@@QAEAAV0@PBD@Z ; CRuString::operator=(char const *)
  52. .text:00487BC8                 push    offset unk_8CCFA6 ; str
  53. .text:00487BCD                 lea     esi, [this+84h]
  54. .text:00487BD3                 call    ??4CRuString@@QAEAAV0@PBD@Z ; CRuString::operator=(char const *)
  55. .text:00487BD8                 pop     esi
  56. .text:00487BD9                 pop     ebp
  57. .text:00487BDA                 mov     eax, this
  58. .text:00487BDC                 pop     ebx
  59. .text:00487BDD                 retn
  60. .text:00487BDD ??0CRuPaperdollTemplate@@QAE@XZ endp ; sp-analysis failed


Нашел описания в интернете, что нужно на проблемном адресе нажать alt+k и изменить неправильное значение sp, жму на 487BDD и вижу окно с инфой

current SP value: 0x4

DIFFERENCE between old and new SP "поле для ввода нового значения"

Но какое бы значения я туда не ввел, ида все время пишет Command "ChangeStackPointer" failed

Собственно пробовал 0x0, 0x4, -0x4




Ранг: 1053.6 (!!!!), 1078thx
Активность: 1.060.81
Статус: Участник

Создано: 10 февраля 2014 23:54
· Личное сообщение · #2

Options->General->Stack pointer [x] OK



Ранг: 10.4 (новичок)
Активность: 0.020
Статус: Участник

Создано: 11 февраля 2014 00:12
· Личное сообщение · #3

Хм, теперь функция выглядит так

Code:
  1. .text:00487B10     ; void __thiscall CRuPaperdollTemplate__CRuPaperdollTemplate(CRuPaperdollTemplate *this)
  2. .text:00487B10     ??0CRuPaperdollTemplate@@QAE@XZ proc near
  3. .text:00487B10                                             ; CODE XREF: CRuObjectModule_PaperdollTemplate::CreateObject(void)+40p
  4. .text:00487B10     this = edi
  5. .text:00487B10 000                 push    ebx
  6. .text:00487B11 004                 push    ebp
  7. .text:00487B12 008                 push    esi
  8. .text:00487B13 00C                 mov     esi, this
  9. .text:00487B15 00C                 call    ??0IRuObject@@QAE@XZ ; IRuObject::IRuObject(void)
  10. .text:00487B1A 00C                 xor     esi, esi
  11. .text:00487B1C 00C                 xor     ecx, ecx
  12. .text:00487B1E 00C                 mov     eax, 1
  13. .text:00487B23 00C                 mov     edx, 4
  14. .text:00487B28 00C                 mul     edx
  15. .text:00487B2A 00C                 mov     dword ptr [this], offset ??_7CRuPaperdollTemplate@@6B@ ; const CRuPaperdollTemplate::`vftable'
  16. .text:00487B30 00C                 seto    cl
  17. .text:00487B33 00C                 mov     [this+60h], esi
  18. .text:00487B36 00C                 mov     [this+64h], esi
  19. .text:00487B39 00C                 mov     [this+68h], esi
  20. .text:00487B3C 00C                 mov     [this+6Ch], esi
  21. .text:00487B3F 00C                 mov     [this+70h], esi
  22. .text:00487B42 00C                 mov     [this+74h], esi
  23. .text:00487B45 00C                 lea     ebp, [this+60h]
  24. .text:00487B48 00C                 lea     ebx, [this+6Ch]
  25. .text:00487B4B 00C                 mov     [this+78h], esi
  26. .text:00487B4E 00C                 mov     [this+7Ch], esi
  27. .text:00487B51 00C                 mov     [this+80h], esi
  28. .text:00487B57 00C                 neg     ecx
  29. .text:00487B59 00C                 or      ecx, eax        ; this
  30. .text:00487B5B 00C                 mov     [this+84h], esi
  31. .text:00487B61 00C                 mov     [this+88h], esi
  32. .text:00487B67 00C                 mov     [this+8Ch], esi
  33. .text:00487B6D 00C                 push    ecx             ; Size
  34. .text:00487B6E 010                 mov     [this+90h], esi
  35. .text:00487B74 010                 call    ??2@YAPAXI@Z    ; operator new(uint)
  36. .text:00487B79 010                 mov     [this+98h], esi
  37. .text:00487B7F 010                 mov     [this+0A0h], esi
  38. .text:00487B85 010                 add     esp, 4
  39. .text:00487B88 00C                 lea     esi, [this+0A4h]
  40. .text:00487B8E 00C                 mov     [this+94h], eax
  41. .text:00487B94 00C                 mov     dword ptr [this+9Ch], 1
  42. .text:00487B9E 00C                 call    ??0?$CRuStack@PAVBatchDesc@CRuEntity_Particle_Visualizer_Sprite@@@@QAE@H@Z ; CRuStack<CRuEntity_Particle_Visualizer_Sprite::BatchDesc *>::CRuStack<CRuEntity_Particle_Visualizer_Sprite::BatchDesc *>(int)
  43. .text:00487BA3 008                 push    offset unk_8CCFA6 ; str
  44. .text:00487BA8 00C                 mov     esi, ebp
  45. .text:00487BAA 00C                 call    ??4CRuString@@QAEAAV0@PBD@Z ; CRuString::operator=(char const *)
  46. .text:00487BAF 008                 push    offset a_ros    ; ".ros"
  47. .text:00487BB4 00C                 mov     esi, ebx
  48. .text:00487BB6 00C                 call    ??4CRuString@@QAEAAV0@PBD@Z ; CRuString::operator=(char const *)
  49. .text:00487BBB 008                 push    offset unk_8CCFA6 ; str
  50. .text:00487BC0 00C                 lea     esi, [this+78h]
  51. .text:00487BC3 00C                 call    ??4CRuString@@QAEAAV0@PBD@Z ; CRuString::operator=(char const *)
  52. .text:00487BC8 008                 push    offset unk_8CCFA6 ; str
  53. .text:00487BCD 00C                 lea     esi, [this+84h]
  54. .text:00487BD3 00C                 call    ??4CRuString@@QAEAAV0@PBD@Z ; CRuString::operator=(char const *)
  55. .text:00487BD8 008                 pop     esi
  56. .text:00487BD9 004                 pop     ebp
  57. .text:00487BDA 000                 mov     eax, this
  58. .text:00487BDC 000                 pop     ebx
  59. .text:00487BDD -04                 retn
  60. .text:00487BDD     ??0CRuPaperdollTemplate@@QAE@XZ endp ; sp-analysis failed


На первом адресе нажал clt+k и поставил -0x12, в итоге на 487BDD стало 0 и функция декомпилировалась, я ведь правильно изменил или менять нужно было не с 1 адреса функции?

Code:
  1. .text:00487B10     ; void __thiscall CRuPaperdollTemplate__CRuPaperdollTemplate(CRuPaperdollTemplate *this)
  2. .text:00487B10     ??0CRuPaperdollTemplate@@QAE@XZ proc near
  3. .text:00487B10                                             ; CODE XREF: CRuObjectModule_PaperdollTemplate::CreateObject(void)+40p
  4. .text:00487B10     this = edi
  5. .text:00487B10 000                 push    ebx
  6. .text:00487B11 012                 push    ebp
  7. .text:00487B12 016                 push    esi
  8. .text:00487B13 01A                 mov     esi, this
  9. .text:00487B15 01A                 call    ??0IRuObject@@QAE@XZ ; IRuObject::IRuObject(void)
  10. .text:00487B1A 01A                 xor     esi, esi
  11. .text:00487B1C 01A                 xor     ecx, ecx
  12. .text:00487B1E 01A                 mov     eax, 1
  13. .text:00487B23 01A                 mov     edx, 4
  14. .text:00487B28 01A                 mul     edx
  15. .text:00487B2A 01A                 mov     dword ptr [this], offset ??_7CRuPaperdollTemplate@@6B@ ; const CRuPaperdollTemplate::`vftable'
  16. .text:00487B30 01A                 seto    cl
  17. .text:00487B33 01A                 mov     [this+60h], esi
  18. .text:00487B36 01A                 mov     [this+64h], esi
  19. .text:00487B39 01A                 mov     [this+68h], esi
  20. .text:00487B3C 01A                 mov     [this+6Ch], esi
  21. .text:00487B3F 01A                 mov     [this+70h], esi
  22. .text:00487B42 01A                 mov     [this+74h], esi
  23. .text:00487B45 01A                 lea     ebp, [this+60h]
  24. .text:00487B48 01A                 lea     ebx, [this+6Ch]
  25. .text:00487B4B 01A                 mov     [this+78h], esi
  26. .text:00487B4E 01A                 mov     [this+7Ch], esi
  27. .text:00487B51 01A                 mov     [this+80h], esi
  28. .text:00487B57 01A                 neg     ecx
  29. .text:00487B59 01A                 or      ecx, eax        ; this
  30. .text:00487B5B 01A                 mov     [this+84h], esi
  31. .text:00487B61 01A                 mov     [this+88h], esi
  32. .text:00487B67 01A                 mov     [this+8Ch], esi
  33. .text:00487B6D 01A                 push    ecx             ; Size
  34. .text:00487B6E 01E                 mov     [this+90h], esi
  35. .text:00487B74 01E                 call    ??2@YAPAXI@Z    ; operator new(uint)
  36. .text:00487B79 01E                 mov     [this+98h], esi
  37. .text:00487B7F 01E                 mov     [this+0A0h], esi
  38. .text:00487B85 01E                 add     esp, 4
  39. .text:00487B88 01A                 lea     esi, [this+0A4h]
  40. .text:00487B8E 01A                 mov     [this+94h], eax
  41. .text:00487B94 01A                 mov     dword ptr [this+9Ch], 1
  42. .text:00487B9E 01A                 call    ??0?$CRuStack@PAVBatchDesc@CRuEntity_Particle_Visualizer_Sprite@@@@QAE@H@Z ; CRuStack<CRuEntity_Particle_Visualizer_Sprite::BatchDesc *>::CRuStack<CRuEntity_Particle_Visualizer_Sprite::BatchDesc *>(int)
  43. .text:00487BA3 016                 push    offset unk_8CCFA6 ; str
  44. .text:00487BA8 01A                 mov     esi, ebp
  45. .text:00487BAA 01A                 call    ??4CRuString@@QAEAAV0@PBD@Z ; CRuString::operator=(char const *)
  46. .text:00487BAF 016                 push    offset a_ros    ; ".ros"
  47. .text:00487BB4 01A                 mov     esi, ebx
  48. .text:00487BB6 01A                 call    ??4CRuString@@QAEAAV0@PBD@Z ; CRuString::operator=(char const *)
  49. .text:00487BBB 016                 push    offset unk_8CCFA6 ; str
  50. .text:00487BC0 01A                 lea     esi, [this+78h]
  51. .text:00487BC3 01A                 call    ??4CRuString@@QAEAAV0@PBD@Z ; CRuString::operator=(char const *)
  52. .text:00487BC8 016                 push    offset unk_8CCFA6 ; str
  53. .text:00487BCD 01A                 lea     esi, [this+84h]
  54. .text:00487BD3 01A                 call    ??4CRuString@@QAEAAV0@PBD@Z ; CRuString::operator=(char const *)
  55. .text:00487BD8 016                 pop     esi
  56. .text:00487BD9 012                 pop     ebp
  57. .text:00487BDA 00A                 mov     eax, this
  58. .text:00487BDC 00A                 pop     ebx
  59. .text:00487BDD 006                 retn
  60. .text:00487BDD     ??0CRuPaperdollTemplate@@QAE@XZ endp ; sp-analysis failed





Ранг: 1053.6 (!!!!), 1078thx
Активность: 1.060.81
Статус: Участник

Создано: 11 февраля 2014 00:22 · Поправил: reversecode
· Личное сообщение · #4

эти значение указатель стека,
вот глазками нужно пройтись и проверить где он правильно или не правильно проставлен идой, потому что ида не сможет правильно расставить указатель стека

например

function_blue(4, 5, function_red(9, 0), 3);

код ассемблера может быть

push 3
push 0
push 9
call function_red
push 5
push 4
call function_blue

а теперь представте что вы ида, и попробуйте угадать как правильно дожен стоят указатель стека на функции function_red ?
в зависимости от указателя
будет разный вывод и в hexrays

например если ида распознает стек по умолчанию то рейс сгенерит код

function_red(9, 0, 3);
function_blue(4, 5,)
согласитесь это не то что было в оригинале
вот такие случаи и многие другие ида предупреждает
и нужно вручную все выставлять

вообщем как то так, в двух словах)) а то щас тролли набегут и будут рассказывать по другому

| Сообщение посчитали полезным: plutos, ohos

Ранг: 10.4 (новичок)
Активность: 0.020
Статус: Участник

Создано: 11 февраля 2014 22:52
· Личное сообщение · #5

Благодарю, уже немного понятней. Но вопросы все равно еще есть по этой теме:

1. как ида вообще определяет указатель стека, из каких критерий она исходит? (понимаю, что вы не разработчик иды и это можно спросить у них, но сомневаюсь, что разработчики программы со стоимостью персональной лицензии иды+хекс рейс почти под 100к рублей с радостью мне это расскажут) может быть есть собственные наблюдения?

2. существуют же стандарты вызова, я про них читал не много и давно, на вскидку помню stdcall и в иде замечал cdecl - разве они не должны определять порядок подачи аргументов функциям в стеке?

и небольшой оффтоп

1. не знаком с устройством компиляторов - какие книжки/статьи/сайты по их работе имеет смысл почитать? полагаю понимание устройства компиляторов даст более лучшее понимание ассемблерных листингов




Ранг: 1053.6 (!!!!), 1078thx
Активность: 1.060.81
Статус: Участник

Создано: 11 февраля 2014 23:12
· Личное сообщение · #6

1) http://www.hexblog.com/?p=42
2) да, они определяют, но только один раз можно выставить тип функции, второй раз не сработает

1) http://www.hexblog.com/?p=43 в конце книжка про компилеры и основы всех алго на которых работате рейс




Ранг: 622.6 (!), 521thx
Активность: 0.330.89
Статус: Участник
_Вечный_Студент_

Создано: 12 февраля 2014 01:04 · Поправил: plutos
· Личное сообщение · #7

ohos:
не знаком с устройством компиляторов - какие книжки/статьи/сайты по их работе имеет смысл почитать?

http://sei.pku.edu.cn/~yaoguo/ACT11/DragonBook-2v2.pdf

-----
Give me a HANDLE and I will move the Earth.



 eXeL@B —› Вопросы новичков —› Ida, positive sp value has been found - Command ChangeStackPointer failed
:: Ваш ответ
Жирный  Курсив  Подчеркнутый  Перечеркнутый  {mpf5}  Код  Вставить ссылку 
:s1: :s2: :s3: :s4: :s5: :s6: :s7: :s8: :s9: :s10: :s11: :s12: :s13: :s14: :s15: :s16:


Максимальный размер аттача: 500KB.
Ваш логин: german1505 » Выход » ЛС
   Для печати Для печати