1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Asm > c++

Discussion in 'Programming' started by Subarashii, Aug 1, 2010.

  1. Subarashii

    Subarashii Well-Known Member

    Yeah I'm still really nubish at converting larger eMS scripts to C++, so somebody (Krow maybe) can help me with converting these scripts:

    Pvac Right

    Code (Text):
    1.  
    2. [enable]
    3. alloc(PrevNext,50)
    4. label(PrevNextRet)
    5.  
    6. 0091638A://8B 86 ?? ?? ?? ?? 8B 58 ?? 8B 86 ?? ?? ?? ?? 57 8d 48 ?? e8 ?? ?? ?? ?? dd 5d ?? 8b 86 ?? ?? ?? ?? dd 40 ?? 51 51 dd 1c 24 e8
    7. jmp PrevNext
    8. db 90
    9. PrevNextRet:
    10.  
    11. PrevNext:
    12. mov eax,[esi+110] // main opcode
    13. mov [eax+4c],00
    14. jmp PrevNextRet
    15.  
    16. [disable]
    17. 0091638A:
    18. db 8B 86 10 01 00 00
    19. dealloc(PrevNext)
    20.  
    Lemmings

    Code (Text):
    1. [ENABLE]
    2. Alloc(MAXONE,512)
    3. Alloc(ONEKEY00,4)
    4. Alloc(JUPKEY,4)
    5. Alloc(JUPKEY2,4)
    6. Registersymbol(MAXONE)
    7. Registersymbol(ONEKEY00)
    8. Registersymbol(JUPKEY)
    9. Registersymbol(JUPKEY2)
    10. Label(MAXONE00)
    11. Label(ONE)
    12. Label(ONE00)
    13. Label(TWO)
    14. Label(TWO00)
    15.  
    16. ONEKEY00:
    17. dd 1
    18. JUPKEY:
    19. dd 1
    20. JUPKEY2:
    21. dd 1
    22.  
    23.  
    24. MAXONE:
    25. fld qword ptr [ebp-14]
    26. leave
    27. cmp [ONEKEY00],0
    28. je MAXONE00
    29. cmp dword ptr [esp],009215C6 //DC 6D ?? 83 C4 10 DD 55 ?? DC 1D ?? ?? ?? ?? DF E0 9E 0F 84
    30. je ONE               // take the first result -.- you will get 2 addresses
    31. cmp dword ptr [esp],00921AC2 //DC 5D ?? 59 59 DF E0 9E ?? ?? DD 45 ?? 8B CE 51 51 DD 1C 24 E8 ?? ?? ?? ?? 89 46 ?? 83 BF ?? ?? 00 00 00 74 ?? 6A 00 6A
    32. je TWO               // take the first result -.- you will get 2 addresses
    33.  
    34.  
    35. MAXONE00:
    36. ret
    37.  
    38.  
    39. ONE:
    40. add esp,4
    41. cmp [JUPKEY],1
    42. jne ONE00
    43. cmp [ebx+248],2 // 8B 83 ?? ?? 00 00 83 F8 01 0F 85 ?? ?? ?? ?? DD 45
    44. jne ONE00
    45. mov [ebx+4A8],0 // + the same as the one above
    46. fsubr qword ptr [ebp-18]
    47. add esp,10
    48. fst qword ptr [ebp-18]
    49. fcomp qword ptr [00A38C30] //00 00 00 00 00 00 00 00 66 00 61 00 69 00 ?? 00 00 00
    50. jmp 00921955 //FF 75 ?? 8B CB FF 75 ?? E8 ?? ?? ?? ?? 5F 5E 5B C9 C2 ?? ?? 55 8B EC 51 51 53 56 8B D9 57
    51.  
    52.  
    53. ONE00:
    54. fsubr qword ptr [ebp-18]
    55. jmp 009215C9 //83 C4 ?? DD 55 ?? DC 1D ?? ?? ?? ?? DF E0 9E 0F 84 ?? ?? ?? ?? 8B 83 ?? ?? 00 00 83 F8 01
    56.  
    57.        
    58. TWO:
    59. add esp,4
    60. cmp [JUPKEY2],1
    61. jne TWO00
    62. fcomp qword ptr [ebp-08]
    63. pop ecx
    64. pop ecx
    65. jmp 00921B2C //83 BF ?? ?? ?? ?? 03 0F 85 ?? ?? ?? ?? FF 77 ?? 83 65 ?? 00
    66.  
    67.  
    68. TWO00:
    69. fcomp qword ptr [ebp-08]
    70. jmp 00921AC5 //59 59 DF E0 9E 73 21 DD 45 F8 8B CE 51 51 DD 1C 24 E8
    71.  
    72.  
    73. 0059E202:    //DD 45 ?? C9 C3 56 6A FF FF 74 24 ?? 8B F1 E8 ?? ?? ?? ?? 8B c6 5e c2
    74. jmp MAXONE    
    75.  
    76. [DISABLE]
    77. 0059E202:
    78. db DD 45 EC C9 C3
    79.  
    80. dealloc(MAXONE)
    81. dealloc(ONEKEY00)
    82. dealloc(JUPKEY)
    83. dealloc(JUPKEY2)
    84. unregistersymbol(MAXONE)
    85. unregistersymbol(ONEKEY00)
    86. unregistersymbol(JUPKEY)
    87. unregistersymbol(JUPKEY2)
    88.  

    And yeah, please explain how to do it, cuz I can't ask you guys the whole time :P
    If someone can explain that good, I would really appreciate it! Thanks :D

    ~ Tariq
     
  2. Subarashii

    Subarashii Well-Known Member

    Or should this be moved to General Programming?
    Answer please :P
     
  3. DarkSpace

    DarkSpace Well-Known Member Coder

    here is pvac

    Code (Text):
    1.  
    2. #define jmp(frm, to) (int)(((int)to - (int)frm) - 5)
    3. DWORD pvacPointer = 0x0091638A;
    4. DWORD pvacReturn = pvacPointer + 5;
    5.  
    6. __declspec(naked) void __stdcall pvacHook()
    7. {
    8.                  __asm
    9.         {
    10.             mov eax, [esi + 0x110]
    11.             mov dword ptr[eax + 0x4c], 0x00
    12.             jmp pvacReturn
    13.         }
    14. }
    15.  
    16. void enablePvac()
    17. {
    18.     *(BYTE*)pvacPointer = 0xe9; //jump
    19.     *(DWORD*)(pvacPointer + 1) = jmp(pvacPointer, pvacHook);
    20.     *(BYTE*)(pvacPointer + 5) = 0x90;
    21. }
    22.  
    other one is too long to long. no time =P
     
  4. Subarashii

    Subarashii Well-Known Member


    Thanks ;) Can you also explain it maybe? :P
    Cuz I don't want to ask those things all the time, I wanna do it by myself you know :P
     
  5. [D.R.T]

    [D.R.T] (҂ `з´ ).︻╦̵̵̿╤── Coder Donor

    if you just want to learn AA -> ASM, you alone will suffice to give a few glances at a few source codes and you can understand, I am new to ASM yet but what is AA -> ASM is not difficult
     
  6. Subarashii

    Subarashii Well-Known Member

    Hmm allright, cuz I was like making a little trainer for some friends and shit, and I encountered this problem :P

    So I first have to go learn AA -> ASM a lil'?
     
  7. [D.R.T]

    [D.R.T] (҂ `з´ ).︻╦̵̵̿╤── Coder Donor

    This is AA
    Code (Text):
    1. [enable]
    2. alloc(PrevNext,50)
    3. label(PrevNextRet)
    4.  
    5. 0091638A://8B 86 ?? ?? ?? ?? 8B 58 ?? 8B 86 ?? ?? ?? ?? 57 8d 48 ?? e8 ?? ?? ?? ?? dd 5d ?? 8b 86 ?? ?? ?? ?? dd 40 ?? 51 51 dd 1c 24 e8
    6. jmp PrevNext
    7. db 90
    8. PrevNextRet:
    9.  
    10. PrevNext:
    11. mov eax,[esi+110] // main opcode
    12. mov [eax+4c],00
    13. jmp PrevNextRet
    14.  
    15. [disable]
    16. 0091638A:
    17. db 8B 86 10 01 00 00
    18. dealloc(PrevNext)
    This is ASM
    Code (Text):
    1.  
    2. mov eax, [esi + 0x110]
    3. mov dword ptr[eax + 0x4c], 0x00
    4. jmp pvacReturn
    5.  
     
  8. Subarashii

    Subarashii Well-Known Member

    Code (Text):
    1.  
    2. [enable]
    3. alloc(7Miss,60)
    4. label(7MissRet)
    5.  
    6. 008C064B: // 39 75 ?? 75 ?? 39 75 ?? 74 ?? 8b 45 ?? db 45 ?? 8b 88 ?? ?? ?? ?? 51 51 dd 1c 24
    7. jmp 7Miss
    8. 7MissRet:
    9.  
    10. 7Miss:
    11. [COLOR="Red"][B]mov [ebp+0c],00//KB (Main)
    12. inc [7Miss+32]
    13. cmp dword ptr [7Miss+32],07//Miss Amount
    14. jg 7Miss+22
    15. mov [ebp+08],00
    16. jmp 7MissRet
    17. 7Miss+22:
    18. mov [7Miss+32],00
    19. jmp 7MissRet[/B][/COLOR]
    20.  
    21. [disable]
    22. 008C064B:
    23. db 39 5D 0C 75 05
    24. dealloc(7Miss)
    25.  
    Red part is ASM part?
     
  9. [D.R.T]

    [D.R.T] (҂ `з´ ).︻╦̵̵̿╤── Coder Donor

    yep do not forget to add 0x to the numbers

    That would look so:
    Code (Text):
    1.  
    2.                 mov dword ptr ds: [ebp+0x0c],0x00 //KB
    3.         inc [Miss7C+0x32]
    4.         cmp dword ptr [Miss7C+0x32],0x07 //Miss Amount
    5.         jg  Miss
    6.         mov dword ptr ds: [ebp+0x08],0x00//Dmg
    7.         jmp [dw7MissKBRet]
    8.  
    9.         Miss:
    10.         mov [Miss7C+0x32],0x00
    11.         jmp [dw7MissKBRet]
    12.  
     
  10. Razz

    Razz Dedicated Supporter Dedicated Donor

    And if you want to make your bot little CPU don't use newbytes old bytes. just *(*WORD) = 0x9090;
     
  11. Subarashii

    Subarashii Well-Known Member

    Hmm, so this script is going to be in C++:

    Code (Text):
    1.  
    2.  
    3. __declspec(naked) void __stdcall 7MissGodmode()
    4. {
    5.                  __asm
    6.         {
    7.                 mov dword ptr ds: [ebp+0x0c],0x00 //KB
    8.         inc [Miss7C+0x32]
    9.         cmp dword ptr [Miss7C+0x32],0x07 //Miss Amount
    10.         jg  Miss
    11.         mov dword ptr ds: [ebp+0x08],0x00//Dmg
    12.         jmp [dw7MissKBRet]
    13.  
    14.         Miss:
    15.         mov [Miss7C+0x32],0x00
    16.         jmp [dw7MissKBRet]
    17.         }
    18. }
    19.  
    20.  
    What do I have to put in DWORD and such now?
     
  12. [D.R.T]

    [D.R.T] (҂ `з´ ).︻╦̵̵̿╤── Coder Donor

    dw7MissKB = 0x008C064B;
    dw7MissKBRet = dw7MissKB+5;

    7MissRet : the value of this comes to be your addy + the number of byte that has your addy

    Code (Text):
    1.  
    2. Addy : 008C064B    Byte :39 5D 0C 75 05
    3.  
    then
    7MissRet = you addy +5
     
  13. Subarashii

    Subarashii Well-Known Member


    So if it was:

    Code (Text):
    1.  
    2. Addy : 008C064B    Byte : 0C 75 05
    3.  
    then
    7MissRet = +3 right?
    But why are you writer dw and not DWORD or something?
     
  14. [D.R.T]

    [D.R.T] (҂ `з´ ).︻╦̵̵̿╤── Coder Donor

    Yep
    Code (Text):
    1.  
    2. DWORD dw7MissKB = 0x008C064B;
    3. DWORD dw7MissKBRet = dw7MissKB+5;
    just remove it to make the example
     
  15. Subarashii

    Subarashii Well-Known Member

    Code (Text):
    1.  
    2. DWORD dw7MissKB = 0x008C064B;
    3. DWORD dw7MissKBRet = dw7MissKB+5;
    4.  
    5. __declspec(naked) void __stdcall 7MissGodmode()
    6. {
    7.                  __asm
    8.         {
    9.                 mov dword ptr ds: [ebp+0x0c],0x00 //KB
    10.         inc [Miss7C+0x32]
    11.         cmp dword ptr [Miss7C+0x32],0x07 //Miss Amount
    12.         jg  Miss
    13.         mov dword ptr ds: [ebp+0x08],0x00//Dmg
    14.         jmp [dw7MissKBRet]
    15.  
    16.         Miss:
    17.         mov [Miss7C+0x32],0x00
    18.         jmp [dw7MissKBRet]
    19.         }
    20. }
    21.  
    22.  

    So that's the C++ then right?
     
  16. [D.R.T]

    [D.R.T] (҂ `з´ ).︻╦̵̵̿╤── Coder Donor

    do not forget this
    Code (Text):
    1. [enable]
    2. alloc(7Miss,60)
    3. label(7MissRet)
    4.  
    5. 008C064B: // 39 75 ?? 75 ?? 39 75 ?? 74 ?? 8b 45 ?? db 45 ?? 8b 88 ?? ?? ?? ?? 51 51 dd 1c 24
    6. jmp 7Miss
    7. 7MissRet:
    8.  
    9. 7Miss:
    10. mov [ebp+0c],00//KB (Main)
    11. inc [[COLOR="Red"]7Miss[/COLOR]+32]
    12. cmp dword ptr [7Miss+32],07//Miss Amount
    13. jg 7Miss+22
    14. mov [ebp+08],00
    15. jmp 7MissRet
    16. 7Miss+22:
    17. mov [7Miss+32],00
    18. jmp 7MissRet
    19.  
    20. [disable]
    21. 008C064B:
    22. db 39 5D 0C 75 05
    23. dealloc(7Miss)
    Code (Text):
    1. DWORD dw7MissKB = 0x008C064B;
    2. DWORD dw7MissKBRet = dw7MissKB+5;
    3.  
    4. __declspec(naked) void __stdcall 7MissGodmode()
    5. {
    6.                  __asm
    7.         {
    8.                 mov dword ptr ds: [ebp+0x0c],0x00 //KB
    9.         inc [[COLOR="Red"]Miss7C[/COLOR]+0x32]
    10.         cmp dword ptr [Miss7C+0x32],0x07 //Miss Amount
    11.         jg  Miss
    12.         mov dword ptr ds: [ebp+0x08],0x00//Dmg
    13.         jmp [dw7MissKBRet]
    14.  
    15.         Miss:
    16.         mov [Miss7C+0x32],0x00
    17.         jmp [dw7MissKBRet]
    18.         }
    19. }
    I would fail because that is not declared

    all I had to do was declare it, but always look out for that very reason all is well

    Code (Text):
    1.  
    2. DWORD dw7MissKB = 0x008C064B;
    3. DWORD dw7MissKBRet = dw7MissKB+5;
    4. DWORD Miss7C;
    5.  
    6. __declspec(naked) void __stdcall Miss7NoKBASM(){
    7.  
    8.     __asm{
    9.  
    10.         mov dword ptr ds: [ebp+0x0c],0x00 //KB
    11.         inc [Miss7C+0x32]
    12.         cmp dword ptr [Miss7C+0x32],0x07 //Miss Amount
    13.         jg  Miss
    14.         mov dword ptr ds: [ebp+0x08],0x00//Dmg
    15.         jmp [dw7MissKBRet]
    16.  
    17.         Miss:
    18.         mov [Miss7C+0x32],0x00
    19.         jmp [dw7MissKBRet]
    20.  
    21.     }
    22. }
    23.  
     
  17. Subarashii

    Subarashii Well-Known Member

    So I've to declare everything *not bytes* between this [text+0x00]
    And in the 7Miss, the Miss7C only is DWORD, because it doesn't have a own addy or something?
     
  18. [D.R.T]

    [D.R.T] (҂ `з´ ).︻╦̵̵̿╤── Coder Donor

    uhmmm

    would not know how to explain, just see this, if that variable is not declared'll get an error.

    Now ask yourself in the code AA is some value to be declared?

    Like I said I am still new to ASM, and thus take it logically and I think it's okay
     
  19. Subarashii

    Subarashii Well-Known Member

    Code (Text):
    1. DWORD dw7MissKB = 0x008C064B;
    2. DWORD dw7MissKBRet = dw7MissKB+5;
    3. DWORD Miss7C;
    4.  
    5.         VOID MissGodmode(__in BOOL bEnable)
    6.    
    7. [COLOR="Red"]       __declspec(naked) void __stdcall MissGodmode(){[/COLOR]
    8.  
    9.     __asm{
    10.  
    11.         mov dword ptr ds: [ebp+0x0c],0x00 //KB
    12.         inc [Miss7C+0x32]
    13.         cmp dword ptr [Miss7C+0x32],0x07 //Miss Amount
    14.         jg  Miss
    15.         mov dword ptr ds: [ebp+0x08],0x00//Dmg
    16.         jmp [dw7MissKBRet]
    17.  
    18.         Miss:
    19.         mov [Miss7C+0x32],0x00
    20.         jmp [dw7MissKBRet]
    21.  
    22.     }
    23. }
    24.  
    That's my script but I get error at red line: " Error 1 error C2144: syntax error : 'void' should be preceded by ';'
     
  20. [D.R.T]

    [D.R.T] (҂ `з´ ).︻╦̵̵̿╤── Coder Donor

    what you're doing is really bad, I recommend you see some source code that contains code cave

    but I'll leave it

    Code (Text):
    1.  
    2. DWORD dw7MissKB = 0x008C064B;//39 75 0C 75 ?? 39 75 10 74 ?? 8B 45 F0 DB 45 10 8B 88 ?? ?? 00 00 51 51 DD 1C
    3. DWORD dw7MissKBRet = dw7MissKB+5;
    4. DWORD Miss7C;
    5. BYTE b7MissOriginal[] = {0x39, 0x5D, 0x0C, 0x75, 0x05};
    6.  
    7. __declspec(naked) void __stdcall Miss7KBASM(){
    8.  
    9.     __asm{
    10.  
    11.         mov dword ptr ds: [ebp+0x0c],0x00 //KB
    12.         inc [Miss7C+0x32]
    13.         cmp dword ptr [Miss7C+0x32],0x07 //Miss Amount
    14.         jg  Miss
    15.         mov dword ptr ds: [ebp+0x08],0x00//Dmg
    16.         jmp [dw7MissKBRet]
    17.  
    18.         Miss:
    19.         mov [Miss7C+0x32],0x00
    20.         jmp [dw7MissKBRet]
    21.  
    22.     }
    23. }
    24.  
    25. void Miss7KB(bool state)
    26. {
    27.     if (state)
    28.     {
    29.         *(BYTE*)dw7MissKB = 0xE9;
    30.         *(DWORD*)(dw7MissKB + 1) = jmp(dw7MissKB, Miss7KBASM);
    31.     }
    32.     else
    33.     {
    34.         for (int i = 0; i < sizeof(b7MissOriginal); i++)
    35.             *(BYTE*)(dw7MissKB + i) = b7MissOriginal[i];
    36.     }
    37. }
    38.  
     

Share This Page