AutoHotkey Community

It is currently May 27th, 2012, 5:35 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: Auto Assembly & AHk ?
PostPosted: March 14th, 2010, 5:46 am 
Offline

Joined: February 27th, 2010, 9:04 pm
Posts: 10
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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 14th, 2010, 5:58 am 
Offline

Joined: December 21st, 2008, 7:29 pm
Posts: 181
You can covert it to machine code and run it with Laszlo's MCode


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 14th, 2010, 3:20 pm 
Offline

Joined: February 27th, 2010, 9:04 pm
Posts: 10
yeah but how to convert it into machine code then ?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 14th, 2010, 3:43 pm 
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.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: March 14th, 2010, 9:47 pm 
Offline

Joined: February 27th, 2010, 9:04 pm
Posts: 10
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")


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: Bing [Bot], dra, HotkeyStick, migz99, rbrtryn, XstatyK and 58 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group