Some Reminders

Discuss, ask for help, share ideas, give suggestions, read tutorials, and tell us about bugs you have found with MicroMacro in here.

Do not post RoM-Bot stuff here. There is a subforum for that.
Forum rules
This is a sub-forum for things specific to MicroMacro.

This is not the place to ask questions about the RoM bot, which uses MicroMacro. There is a difference.
Message
Author
User avatar
BlubBlab
Posts: 948
Joined: Fri Nov 30, 2012 11:33 pm
Location: My little Pony cafe

Some Reminders

#1 Post by BlubBlab » Wed Jan 14, 2015 3:57 am

It is on purpose openly so that maybe some others can say something to it.

First Lua 5.3 is out since 12.01.2015 I already adopted it with my open cv version.

I should remind Admin about the 64-bit version of MM from him^^

I gave admin the packet opcode of the Russian Arche Age client which found on unknowncheats.me since admin had too much to do should I post it some where?
Jack-of-all-trades, but master-of-only of a few :D

My Reps:
https://github.com/BlubBlab/Micromacro-with-OpenCV (My version of MM2 with OpenCV and for MS Visual Studio)
https://github.com/BlubBlab/rom-bot (rombot with no stop WP and advanced human emulation mode and some other extensions)
https://github.com/BlubBlab/Micromacro-2-Bot-Framework ( A work in progress )
My Tools : viewtopic.php?f=10&t=6226

User avatar
Administrator
Site Admin
Posts: 5306
Joined: Sat Jan 05, 2008 4:21 pm

Re: Some Reminders

#2 Post by Administrator » Wed Jan 14, 2015 10:41 am

Don't worry; I haven't forgotten. Just still very busy working on many other projects.

But yes, you should go ahead and create a new thread in the ArcheAge forum in case anyone is interested.

User avatar
Administrator
Site Admin
Posts: 5306
Joined: Sat Jan 05, 2008 4:21 pm

Re: Some Reminders

#3 Post by Administrator » Sat Jan 17, 2015 3:48 pm

Well it was a huge pain in the ass, but I finally got updated to Lua 5.3 at least. It took about 4 hours. Why was it such a pain, you ask?

Well, cygwin build the library, but in a non-functional state so I couldn't link it without errors.
I couldn't get make to not build it without cygwin support-- it would just confuse itself on the flags.
Mingw32-make put up a huge fuss with the PATH, making me jump through all sorts of hoops, and then it still crashed.
So I ended up having to use a Linux environment, customize the path, then managed to sort of get mingw32 to work. It still threw errors, but at least it built the library in a functional way.

Oh boy... I'm really not looking forward to even attempting to get 64-bit support at the moment. At least it is a step in the right direction.

User avatar
BlubBlab
Posts: 948
Joined: Fri Nov 30, 2012 11:33 pm
Location: My little Pony cafe

Re: Some Reminders

#4 Post by BlubBlab » Sun Jan 18, 2015 2:03 pm

I can only say it worked for me fine but what I said I had to change some stuff because some "MACRO" doesn't exist any more.
To be frankly I'm not sure if I'm with

Code: Select all

lua_pushinteger(L , (lua_unsigned)value)
on the correct side but besides that it worked fine. ;)
Jack-of-all-trades, but master-of-only of a few :D

My Reps:
https://github.com/BlubBlab/Micromacro-with-OpenCV (My version of MM2 with OpenCV and for MS Visual Studio)
https://github.com/BlubBlab/rom-bot (rombot with no stop WP and advanced human emulation mode and some other extensions)
https://github.com/BlubBlab/Micromacro-2-Bot-Framework ( A work in progress )
My Tools : viewtopic.php?f=10&t=6226

User avatar
Administrator
Site Admin
Posts: 5306
Joined: Sat Jan 05, 2008 4:21 pm

Re: Some Reminders

#5 Post by Administrator » Sun Jan 18, 2015 6:44 pm

I've fixed up the source and setup the 64-bit compiler, but now I have to compile 64-bit libraries for ncurses, alut, openal, and lua53. I remember ncurses being particularly annoying to work with before, so it's going to take awhile before I can actually link the 64-bit binary.

EDIT: I've got ncurses, lua, and openal libs built. I cannot get ALUT built as it's... pretty much dead and unsupported, making it near impossible to compile.

User avatar
BlubBlab
Posts: 948
Joined: Fri Nov 30, 2012 11:33 pm
Location: My little Pony cafe

Re: Some Reminders

#6 Post by BlubBlab » Mon Jan 19, 2015 1:47 am

The only problem I had with alut is that its CMAKE files are completely outdated what resulted in that It couldn't find the include directories so I needed to add it by hand.(took me 2 hours to get it work) Surprisingly I could built against the newest version of openal32 without problems despite the 8 year different.

I got alut out of there : https://github.com/rpavlik/openal-svn-m ... aster/alut
I built it against this version: http://kcat.strangesoft.net/openal.html

EDIT:
About 64-bit for most of the code you can like I said use size_t(which is a macro) instead of unsigned int(or better said you must do it).

Under 64-bit size_t is the same as uint64_t(stdint.h) which is both the same as unsigned long long, under 32-bit size_t is unsigned long which is the same as unsigned int.

I haven't found a flexible way for int64_t I still didn't port it back so I don't know if I have to, I read a little bit I'm not sure how but it seems it is possible to read/write memory cross 32/64-bit because VS can do it with it the debugger, MS talks in it api documentation as there would be no problem and autoit can do it too some how. I prepared a little but I was to lazy to dive deeper into the topic until now but had add a check in process.open if the process is 32-bit (and also if the open worked) .
Jack-of-all-trades, but master-of-only of a few :D

My Reps:
https://github.com/BlubBlab/Micromacro-with-OpenCV (My version of MM2 with OpenCV and for MS Visual Studio)
https://github.com/BlubBlab/rom-bot (rombot with no stop WP and advanced human emulation mode and some other extensions)
https://github.com/BlubBlab/Micromacro-2-Bot-Framework ( A work in progress )
My Tools : viewtopic.php?f=10&t=6226

User avatar
Administrator
Site Admin
Posts: 5306
Joined: Sat Jan 05, 2008 4:21 pm

Re: Some Reminders

#7 Post by Administrator » Mon Jan 19, 2015 7:51 pm

Yeah. Most of my issues were because of the MinGW32 toolchain under Windows, and you're absolutely right that CMake was absolute garbage. I eventually managed to get all libraries built, but only because I used Linux to cross-compile them.

After a bit of fixing up various things in the source, I'm now able to build the 64-bit MicroMacro executable. It generally seems to be working, but I haven't even touched testing things like reading memory, so it will be awhile before I make an official release yet. Still, things are looking good!

User avatar
BlubBlab
Posts: 948
Joined: Fri Nov 30, 2012 11:33 pm
Location: My little Pony cafe

Re: Some Reminders

#8 Post by BlubBlab » Tue Jan 20, 2015 6:26 am

Cool , if you need it I can give you my modified CMakeList.txt or alut.lib and alut.dll as 64x
Jack-of-all-trades, but master-of-only of a few :D

My Reps:
https://github.com/BlubBlab/Micromacro-with-OpenCV (My version of MM2 with OpenCV and for MS Visual Studio)
https://github.com/BlubBlab/rom-bot (rombot with no stop WP and advanced human emulation mode and some other extensions)
https://github.com/BlubBlab/Micromacro-2-Bot-Framework ( A work in progress )
My Tools : viewtopic.php?f=10&t=6226

User avatar
BlubBlab
Posts: 948
Joined: Fri Nov 30, 2012 11:33 pm
Location: My little Pony cafe

Re: Some Reminders

#9 Post by BlubBlab » Thu Jan 22, 2015 8:03 am

I saw into it if it is possible to open a 32-bit process with an 64-bit version of MM it doesn't seem so at least not the easy way but I'm a little confuse this should throw a little error if so:

Code: Select all

int Process_lua::open(lua_State *L)
{
	if( lua_gettop(L) != 1 )
		wrongArgs(L);
	checkType(L, LT_NUMBER, 1);

	HANDLE handle;
	DWORD procId = (DWORD)lua_tointeger(L, 1);
	DWORD access = PROCESS_VM_OPERATION | PROCESS_VM_READ | PROCESS_VM_WRITE  | PROCESS_QUERY_INFORMATION;

	handle = OpenProcess(access, false, procId);

	if ((handle != NULL) && (GetProcessId(handle) !=  procId))
	{ /* !!! re-check result of OpenProcess, if handle is not pointing to the selected pid, close the handle */
		CloseHandle(handle); handle = NULL; SetLastError(0);
	}
	if( handle == NULL)
	{ // An error occurred!
		pushLuaErrorEvent(L, "Error opening process.");
		return 0;
	}
	
	if (!(IsWow64(handle)))
	{
		is32bit = true;
	}
	HANDLE *pHandle = (HANDLE *)lua_newuserdata(L, sizeof(HANDLE));
	luaL_getmetatable(L, LuaType::metatable_handle);
	lua_setmetatable(L, -2);
	*pHandle = handle;

	return 1;
}
Doesn't throw pushLuaErrorEvent not an error?

Anyway what I got was this:

Code: Select all

Script> aiontest
Running 'aiontest'

Failed to run init function, err code: 7 (Runtime error)
Could not find Aion process. You must have the game running to use this script

stack traceback:
        [C]: in function 'error'
        aiontest.lua:24: in function <aiontest.lua:17>

Please enter the script name to run.
Type in 'exit' (without quotes) to exit.
with this code:

Code: Select all

local targetWindowClass = "Aion Client";
local targetWindowName = "Aion Client";

-- Main script
function macro.init()
	win = window.find(targetWindowName);
	if( not win ) then
		error("Could not find Aion window. You must have the game running to use this script.\n", 0);
	end
	procHandle = process.open(win);
	if( not procHandle ) then
		error("Could not find Aion process. You must have the game running to use this script.\n", 0);
	end
	local module = process.getModuleAddress(procHandle," game.dll");
	if( not module ) then
		error("Could not find Aion module. You must have the game running to use this script.\n", 0);
	end
	local level = process.read(procHandle,"int", 0xE269A0 + module); 
	print("Level : "..level); 
end
Most of the stuff I read suggest to force the process execution into x86 mode to access the 32-bit variant of the Kernel32.dll, with inline asm like a trampoline.
Jack-of-all-trades, but master-of-only of a few :D

My Reps:
https://github.com/BlubBlab/Micromacro-with-OpenCV (My version of MM2 with OpenCV and for MS Visual Studio)
https://github.com/BlubBlab/rom-bot (rombot with no stop WP and advanced human emulation mode and some other extensions)
https://github.com/BlubBlab/Micromacro-2-Bot-Framework ( A work in progress )
My Tools : viewtopic.php?f=10&t=6226

User avatar
Administrator
Site Admin
Posts: 5306
Joined: Sat Jan 05, 2008 4:21 pm

Re: Some Reminders

#10 Post by Administrator » Thu Jan 22, 2015 12:24 pm

You can now thunk 32-bit and 64-bit processes with the latest 64-bit code (just pushed to Github last night).

I think your problem is that you're passing the window's HWND ('win') to process.open() instead of the process ID. Use this:

Code: Select all

procId = process.findByWindow(win);
proc = process.open(procId);

User avatar
BlubBlab
Posts: 948
Joined: Fri Nov 30, 2012 11:33 pm
Location: My little Pony cafe

Re: Some Reminders

#11 Post by BlubBlab » Thu Jan 22, 2015 3:55 pm

I think you used uint 2x in process.read I think one was meant to be uint64 ^^
and you missing the 64(40)bit pointers I would just merge change some types.

Okay after I merged with your version it seems to work kinda :

Code: Select all

Failed to run init function, err code: 7 (Runtime error)
aiontest.lua:30: bad argument #1 to 'getModuleAddress' (number expected, got use
rdata)
stack traceback:
        [C]: in field 'getModuleAddress'
        aiontest.lua:30: in function <aiontest.lua:17>

Please enter the script name to run.
Type in 'exit' (without quotes) to exit.
A number make not much sense and the wiki say use a handle.

if I use :

Code: Select all

	local module = process.getModuleAddress(procId,"game.dll");
	if( not module ) then
		error("Could not find Aion module. You must have the game running to use this script.\n", 0);
	end
I got:
Failed to run init function, err code: 7 (Runtime error)
Could not find Aion module. You must have the game running to use this script.

stack traceback:
[C]: in function 'error'
aiontest.lua:32: in function <aiontest.lua:17>

Please enter the script name to run.
Type in 'exit' (without quotes) to exit.

EDIT: The only thing I think of is that the name got somehow scrambled through the UTF-8 support.
Jack-of-all-trades, but master-of-only of a few :D

My Reps:
https://github.com/BlubBlab/Micromacro-with-OpenCV (My version of MM2 with OpenCV and for MS Visual Studio)
https://github.com/BlubBlab/rom-bot (rombot with no stop WP and advanced human emulation mode and some other extensions)
https://github.com/BlubBlab/Micromacro-2-Bot-Framework ( A work in progress )
My Tools : viewtopic.php?f=10&t=6226

User avatar
Administrator
Site Admin
Posts: 5306
Joined: Sat Jan 05, 2008 4:21 pm

Re: Some Reminders

#12 Post by Administrator » Thu Jan 22, 2015 8:06 pm

I think you used uint 2x in process.read I think one was meant to be uint64 ^^
and you missing the 64(40)bit pointers I would just merge change some types.
Can you be more specific?


As for getModuleAddress, you're right; it looks like a documentation error there. It should be accepting a process ID and not a process handle.

As for the other issue, it seems to work fine with me using a different application as the target. Try this, though. Change line 1391 of process_lua.cpp to:

Code: Select all

	HANDLE snapshot = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE | TH32CS_SNAPMODULE32, procId);
Does it work now?




I'm testing with 64-bit Cheat Engine:

Code: Select all

function macro.init()
	local addr = 0x7FEFBADCD08;
	local procId = process.findByWindow(window.find("Cheat Engine 6.4", "Window"));
	print("procId:", procId);

	local modName = "guard64.dll";-- "cheatengine-x86_64.exe";
	local modAddr = process.getModuleAddress(procId, modName);
	printf("modAddr: 0x%X\n", modAddr);

	local proc = process.open(procId);
	print("proc:", proc);

	local int = process.read(proc, "int64", addr);
	print("int:", int);

	local chunk = process.readChunk(proc, addr, 32);
	print("chunk:", chunk:getData("int", 0));
end

function macro.main()
	return false;
end

function macro.event(e, ...)
	if( e == "error" ) then
		print("[ERROR] :", ...);
	end
end

User avatar
BlubBlab
Posts: 948
Joined: Fri Nov 30, 2012 11:33 pm
Location: My little Pony cafe

Re: Some Reminders

#13 Post by BlubBlab » Fri Jan 23, 2015 5:26 am

thx it works now. I can access the memory from 32-bit and 64-bit processes from my 64-bit MM2

About pointers yeah MM reads unsigned int for 32-bit but in 64-bit pointers have the maximum size of unsigned long long. In my version I wrote readPtr64 and writePtr64 to get that. I added in the new version I will upload in a few minutes process.is32(handle), so you can check if the attached process is 32 or 64-bit and choose the pointer function which you need.

I couldn't add the stuff you did with the directories VS don't like it and says illegal try to access memory in 0xFFFF FFFF
Jack-of-all-trades, but master-of-only of a few :D

My Reps:
https://github.com/BlubBlab/Micromacro-with-OpenCV (My version of MM2 with OpenCV and for MS Visual Studio)
https://github.com/BlubBlab/rom-bot (rombot with no stop WP and advanced human emulation mode and some other extensions)
https://github.com/BlubBlab/Micromacro-2-Bot-Framework ( A work in progress )
My Tools : viewtopic.php?f=10&t=6226

User avatar
Administrator
Site Admin
Posts: 5306
Joined: Sat Jan 05, 2008 4:21 pm

Re: Some Reminders

#14 Post by Administrator » Fri Jan 23, 2015 12:50 pm

I added in the new version I will upload in a few minutes process.is32(handle)
Good idea. I already added macro.is32bit() and macro.is64bit(), but maybe I'll move it to process instead. Could you rename your function to is32bit() and is64bit()?


You shouldn't need to write a new readMemory64 function; just change the readMemory template calls for realAddress to size_t in readPtr:

Code: Select all

		realAddress = readMemory<size_t>(*pHandle, address, err) + offsets.at(0);
	}
	else
	{
		realAddress = address;
		for(unsigned int i = 0; i < offsets.size() - 1; i++)
		{
			realAddress = readMemory<site_t>(*pHandle, realAddress + offsets.at(i), err); // Get value
Do the same for writePtr. Let me know if this works.

Code: Select all

I couldn't add the stuff you did with the directories VS don't like it and says illegal try to access memory in 0xFFFF FFFF[/quote]
You mean these changes? https://code.google.com/p/micromacro/source/diff?spec=svn511bc6b56efab7dc05ddd83a7a946aa58a197097&r=511bc6b56efab7dc05ddd83a7a946aa58a197097&format=side&path=/src/filesystem.cpp

If so, that seems like it would be something specific to your compiler and it will be near impossible for me to duplicate, so I'll need you to track down where it is crashing. If you run it through a debugger, it should tell you exactly where the crash is. If you don't have a debugger ready, try putting a printf("test xxx") line into those functions to find out which one(s) are causing issues. Then narrow it down to which lines. The last line shown before it crashes should tell you something.

User avatar
BlubBlab
Posts: 948
Joined: Fri Nov 30, 2012 11:33 pm
Location: My little Pony cafe

Re: Some Reminders

#15 Post by BlubBlab » Fri Jan 23, 2015 2:17 pm

I know that with the readMemory template I had the readPtr64 since the first fork in it.

I don't think this will work the size of size_t is determinant at the compile time I could use isWOW64 function I wrote inside it but
1.) It will be slow.
2.) I doesn't work always as intended e.g DP has in the object list not 64-bit pointers instead it use 32-bit pointers inside it 64-bit application version (_dp64.exe).

At best I could fusion both version and make it like :

Code: Select all

local is32 = process.is32(handle);
.
.
process.readPtr(handle, addresses + module,is32);
We could combine that all and when the 3 parameter is missing it will be determinant automatically but honestly isn't that not a little bit overload?
Jack-of-all-trades, but master-of-only of a few :D

My Reps:
https://github.com/BlubBlab/Micromacro-with-OpenCV (My version of MM2 with OpenCV and for MS Visual Studio)
https://github.com/BlubBlab/rom-bot (rombot with no stop WP and advanced human emulation mode and some other extensions)
https://github.com/BlubBlab/Micromacro-2-Bot-Framework ( A work in progress )
My Tools : viewtopic.php?f=10&t=6226

User avatar
Administrator
Site Admin
Posts: 5306
Joined: Sat Jan 05, 2008 4:21 pm

Re: Some Reminders

#16 Post by Administrator » Fri Jan 23, 2015 2:41 pm

DP has in the object list not 64-bit pointers instead it use 32-bit pointers inside it 64-bit application version (_dp64.exe).
That doesn't seem right. A 64-bit process needs to use 32-bit pointers. The first 4 bytes should be NULL, though. If you're seeing a chain of 32-bit numbers, I think those are just a list of offsets the game uses, and you should just read them as ints, then do a read on the address + offset.

User avatar
BlubBlab
Posts: 948
Joined: Fri Nov 30, 2012 11:33 pm
Location: My little Pony cafe

Re: Some Reminders

#17 Post by BlubBlab » Fri Jan 23, 2015 4:17 pm

I think this it is because this list was part of an GC/ object management, which is typical RW implemented the wrong way by using a fix size(instead of sizeof(pointer) for the pointers because those other 8 bytes looked like reference counters.(some where is a picture) It is just luck that they haven't pointers behind the 4 GB limit.
Jack-of-all-trades, but master-of-only of a few :D

My Reps:
https://github.com/BlubBlab/Micromacro-with-OpenCV (My version of MM2 with OpenCV and for MS Visual Studio)
https://github.com/BlubBlab/rom-bot (rombot with no stop WP and advanced human emulation mode and some other extensions)
https://github.com/BlubBlab/Micromacro-2-Bot-Framework ( A work in progress )
My Tools : viewtopic.php?f=10&t=6226

User avatar
BlubBlab
Posts: 948
Joined: Fri Nov 30, 2012 11:33 pm
Location: My little Pony cafe

Re: Some Reminders

#18 Post by BlubBlab » Mon Jan 26, 2015 10:12 am

Okay I thought again about it there was one fast way.
I already check if a process is 32bit when MM open the process and set a global flag, unfortunately this only say something about the last opened process, so if you cross open 32-bit processes and 64-processes it will screw up the readPtr/writePtr calls by reading the wrong pointer size.

Together what DP does with it tables if I want fully support it I came to this:

I use the global flag if nobody say others, you can say others by the last argument which can be a table of booleans or simple a boolean.
The tables of offsets and boolean must have the same size and order.

I know I could simple let them use read but to be true I had the same issue with CE and I wasn't the only one who wanted to read 32-bit pointer out of 64-bit applications with it but because of this I feel it is option that is missing.

I currently testing a little bit but it can take time^^
Jack-of-all-trades, but master-of-only of a few :D

My Reps:
https://github.com/BlubBlab/Micromacro-with-OpenCV (My version of MM2 with OpenCV and for MS Visual Studio)
https://github.com/BlubBlab/rom-bot (rombot with no stop WP and advanced human emulation mode and some other extensions)
https://github.com/BlubBlab/Micromacro-2-Bot-Framework ( A work in progress )
My Tools : viewtopic.php?f=10&t=6226

User avatar
Administrator
Site Admin
Posts: 5306
Joined: Sat Jan 05, 2008 4:21 pm

Re: Some Reminders

#19 Post by Administrator » Mon Jan 26, 2015 1:09 pm

You're still minimizing that if the process is 64-bit, all pointers must be 64-bit. While you can dynamically cast a 32-bit address to a 64-bit address, it would be a huge pain to write memory ready operations that mix this--especially given that it is specific to a single program.

That means you can just use something like this:

Code: Select all

local ptr = process.read(proc, "int", base);
local value = process.read(proc, "int", ptr);
Yes, that means two reads, but this is all MicroMacro does internally with pointers anyways--so you're not saving anything by using readPtr().

User avatar
BlubBlab
Posts: 948
Joined: Fri Nov 30, 2012 11:33 pm
Location: My little Pony cafe

Re: Some Reminders

#20 Post by BlubBlab » Mon Jan 26, 2015 2:21 pm

I already went through the pain.. but besides the luxes having all stuff at one place, what I want to avoid is running each time when readPtr is called that this also run:

Code: Select all

bool IsWow64(HANDLE process)
{
	BOOL bIsWow64 = FALSE;
	LPFN_ISWOW64PROCESS fnIsWow64Process;
	//IsWow64Process is not available on all supported versions of Windows.
 	//Use GetModuleHandle to get a handle to the DLL that contains the function
	//and GetProcAddress to get a pointer to the function if available.

	fnIsWow64Process = (LPFN_ISWOW64PROCESS) GetProcAddress(
		GetModuleHandle(TEXT("kernel32")),"IsWow64Process");

	if(NULL != fnIsWow64Process)
	{
		if (!fnIsWow64Process(process,&bIsWow64))
		{
			printf("failed to check if it is a 64-bit process \n");
		}
	}
	return bIsWow64;
}

Jack-of-all-trades, but master-of-only of a few :D

My Reps:
https://github.com/BlubBlab/Micromacro-with-OpenCV (My version of MM2 with OpenCV and for MS Visual Studio)
https://github.com/BlubBlab/rom-bot (rombot with no stop WP and advanced human emulation mode and some other extensions)
https://github.com/BlubBlab/Micromacro-2-Bot-Framework ( A work in progress )
My Tools : viewtopic.php?f=10&t=6226

Post Reply

Who is online

Users browsing this forum: No registered users and 16 guests