Page 1 of 2

Magic.c

PostPosted: 28 Feb 2012, 14:31
by Gargaroz
Here's an old decryption of Magic.exe in C. Most of the stuff is still really basic, with casual variable names and so on.
If we could work on fully rewriting it in C, it will help me a lot in future developments. Since most of the code is still in ASM-like form, I couldn't really read it correctly, so if someone more proficiend could help, I'll appreciate it a lot.
In the package there's also "manalink.h" and "manalink.lds", which hosts the current names of some variables / functions / events.

Edit by Aswan Jaguar: For current status see the link not the attachment:
viewtopic.php?f=56&t=6528&start=15#p147097

Re: Magic.c

PostPosted: 01 Mar 2012, 23:04
by foolosopher
This has been tried before, check this thread

viewtopic.php?f=56&t=973&start=45

I think what Mok said is the best way to go, which is to slowly strip down cards from the exe into c and isolate the basic game engine, then recode little by little.

Re: Magic.c

PostPosted: 02 Mar 2012, 12:36
by gmzombie
but i think this can help us a bit at renaming some subs and locations in the exe. then gather and discuss that and see if there is anything we have missed. but this wil help us out no doubt about it.

Re: Magic.c

PostPosted: 02 Mar 2012, 14:55
by Gargaroz
Yup, we could start with what is actually known and labeled (and this is why I inluded the two Manalink files) and the first job is a carefully renaming.
Then, we'll discuss if something is to be renamed.

Re: Magic.c

PostPosted: 02 Mar 2012, 23:45
by gmzombie
hey how old is this by the way..obviously pre 2k fix but do u know how old?

Re: Magic.c

PostPosted: 03 Mar 2012, 14:07
by Gargaroz
No, it was sent to my by Jatill. It seems it was decoded until Antiquities, as Legends card aren't featured.
But id doesn't matter, it's still useful to understant how some part of the game works. My main interest is the targeting part, so we could inject new keywords.

Re: Magic.c

PostPosted: 27 Apr 2012, 13:26
by Gargaroz
I'm bumping this topic up as I really would like to rewrite the targeting function in order to incorporate new keywords and fix all the issues with subtypes. Anyone that has ASM knowledge, please help !

Re: Magic.c

PostPosted: 03 May 2012, 13:04
by Huggybaby
I asked a friend about this who knows x86, 680x0, and z80 flavors of asm, and the principles of amd64 (x86_64) asm.
He deals almost entirely with Linux, so take that into consideration. Anyway, he's the only guy I know working with asm, other than Steve gibson at GRC, and I don't know Steve. Maybe someone could ask him!

My friend's edited replies:
Courageous project I would say, working on the optimized output of a compiler is quite horrible, I did it a long time ago when I cracked a few things, but stopped a long time ago (since I switched to linux, in linux you don't need to crack anything, it's better this way !).
Well I heard there are some uncompilers for this kind of work, but never saw any, and I guess they would work best with some debug symbols and unoptimized code anyway.
And later:
On 2nd thought I am not even sure your project is doable.
The problem are the debug symbols : with them it would be hard but possible.
Without them... ? The big problem are the external libraries, if you can't understand the system calls then you can't get anything out of this code.
Now your chance is that it's windows, so it means less external libs than in linux for example, and if I remember correctly you might be able to read dll calls even without debug symbols. Still very tedious to translate, you need a good api documentatino to reverse all that.

Anyway that's the part which decides if your idea is feasable or not, and even if it is it will be hard and tedious.
Good luck again !

Re: Magic.c

PostPosted: 05 May 2012, 12:40
by Gargaroz
The fact is, we don't need to reverse engineer ALL the stuff : the graphic part could stay alone for now, for example. But some areas need to be reworked to allow updating the rules and similat stuff : mainly the targeting functions and the stack system. The second is really over me, but I understood 50% of the targeting functions, the only problem is that I know almost nothing of ASM, so a lot of symbols generated by the decompiler are quite obscure to me.

Re: Magic.c

PostPosted: 15 May 2012, 13:05
by Gargaroz
Guys, please, I know I'm stressing everyone about this fact but this will be a major improvement to the game : everyone that can undestand ASM please get in touch with me so we could recode the targeting functions ! Moderators, please "stick" this thread.

Re: Magic.c

PostPosted: 19 May 2012, 19:59
by gmzombie
Garg i wish i could help but i havent picked back up in learning the asm or c books yet..too busy at the moment. the only thing i can recommend is the book i currently have which is more like a textbook by Kip. R Irvine Assembly language for intel based computers. I have the 4th edition in text book and a pdf if your interested in trying to learn asm. The only reason why i didnt get to far is i dont know C. that is why i stopped reading asm and jumped into learning c. im still not even close to learning that though. :( i think i would have to goto a class to really learn this stuff.. anyways hit me up if you would like that pdf file and ill email it to ya. i have about 8 gbs of programming info and vids that i got off of a torrent.

Re: Magic.c

PostPosted: 30 Nov 2012, 18:21
by gmzombie
I had a thought though. Is there anyway anyone could strip just the card code left out of magic.exe. Then possibly in a separate area strip the visual winodws api out of it. Then we should be left with just ai code i believe. Im just trying to think outside the bo,.

Re: Magic.c

PostPosted: 17 Jul 2013, 13:54
by Korath
What I've got labelled currently.

(If anyone has access to Hex Rays and could post what it comes up with for Shandalar.exe, I'd like to take a look at that eventually, too.)

Re: Magic.c

PostPosted: 17 Jul 2013, 16:16
by gmzombie
As soon as I get home I will build a .c for shandalar. I have hex rays 5.5 I believe also pe explorer and of course ollydbg

Re: Magic.c

PostPosted: 17 Jul 2013, 16:38
by Gargaroz
Well, a recode / improvement for Shandalar will be a dream came true.