AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Auto Assembly & AHk ?

 
Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
DistortioN



Joined: 27 Feb 2010
Posts: 10

PostPosted: Sun Mar 14, 2010 4:46 am    Post subject: Auto Assembly & AHk ? Reply with quote

Can i use auto assembly code in ahk ? if so how ?
i want to use that cause i want to implement a script i have for detecting a game master in a game i made a bot for.

this is the code i want to use
Code:
[ENABLE]
alloc(DetectGM,25)
label(ReturnName)

00553763: //C7 46 0C 00 00 00 00 89 47 04
jmp DetectGM
nop
nop
ReturnName:

DetectGM:
cmp [eax+70],5D4D475B //[GM]
je 00000000
mov [esi+0c],00000000
jmp ReturnName

[DISABLE]
dealloc(DetectGM)
00553763:
mov [esi+0c],00000000


thanks in advance
Back to top
View user's profile Send private message
entropic



Joined: 21 Dec 2008
Posts: 181

PostPosted: Sun Mar 14, 2010 4:58 am    Post subject: Reply with quote

You can covert it to machine code and run it with Laszlo's MCode
Back to top
View user's profile Send private message
DistortioN



Joined: 27 Feb 2010
Posts: 10

PostPosted: Sun Mar 14, 2010 2:20 pm    Post subject: Reply with quote

yeah but how to convert it into machine code then ?
Back to top
View user's profile Send private message
assembler
Guest





PostPosted: Sun Mar 14, 2010 2:43 pm    Post subject: Reply with quote

DistortioN wrote:
yeah but how to convert it into machine code then ?

You write your code in ASM mnemonics, then you use an assembler to convert the ASM to machine code (binary processor instructions). If the code is small and you know what you are doing you can also use a debugger to covert mnemonics to binary code.

Note that it is the responibility of your code to save and restrore any registers (and/or memory) that you might use before returning from your code. Also, you must get your data from the processor stack and clean it up before returning (just like a normal dll does). A summary of these concerns may be found x86 calling conventions. Reading though the posts in the mcode thread will further enlighten you.
Back to top
DistortioN



Joined: 27 Feb 2010
Posts: 10

PostPosted: Sun Mar 14, 2010 8:47 pm    Post subject: Reply with quote

Ive managed to create a dll in c++ with a function for the asm code.
it looks like this :
Code:
// GM Detect.cpp : Defines the exported functions for the DLL application.
//
#include "stdafx.h"
#include <windows.h>
#define JMP(frm,to) (((int)to - (int)frm)-5)
DWORD Adress = 0x00553A83;
DWORD RetAdress = (Adress + 7); // cause 2 nops
__declspec(naked) void myCodeCave ()
{
  __asm
  {
cmp [eax+0x70], 0x5D4D475B          //[GM]
je [00000000]
mov [esi+0x0c],0x00000000
jmp RetAdress     
  }
}

void GMDetect ()
{
   *(BYTE*)Adress = 0xe9; // defining jump opcode
   *(DWORD*)(Adress+1) = JMP(Adress,myCodeCave);
   *(WORD*)Adress = 0x9090;
}


but then if i would call upon that function with dllcall() it doenst run ..
i use this code in ahk :
Code:
DllCall("LoadLibrary","Str","GMDetect.dll")
hModule:=DllCall("GetModuleHandle")
DllCall("GetProcAddress","UInt",hModule,"Str","GMDetect")
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group