Author |
Message |
Mr Ekted Movie Geek

Gender: Joined: Feb 09 2004 Posts: 1379 Offline
|
Posted: Thu Mar 24, 2005 3:12 pm Post maybe stupid Post subject: |
 |
|
|
|
Windows uses the FS segment register for exception handling. When most excpetions occur, it triggers a special set of events and lands in the kernel. Windows then will invoke the application's exception handler stored at FS:[0]. The above instruction is commonly created when using the C++ keyword "try".
http://www.jorgon.freeserve.co.uk/ExceptFrame.htm _________________ 4,691 irradiated haggis! |
|
Back to top |
|
 |
Smong Server Help Squatter

Joined: 1043048991 Posts: 0x91E Offline
|
|
Back to top |
|
 |
Bak ?ls -s 0 in

Age:26 Gender: Joined: Jun 11 2004 Posts: 1826 Location: USA Offline
|
|
Back to top |
|
 |
Cyan~Fire I'll count you!

Age:37 Gender: Joined: Jul 14 2003 Posts: 4608 Location: A Dream Offline
|
Posted: Fri Mar 25, 2005 7:38 pm Post maybe stupid Post subject: |
 |
|
|
|
Eighth: mov edi,[000467E20]
mov eax,[edi][00004]
mov edx,[edi][0000C]
mov ecx,[eax][00018] |
Smong got this ASM with a different disassembler, it's at the very beginning of the func. (Ekted, you only gave us the strictly doors bit, I think?) The 00004 and whatever is addition, but Smong and I can't figure out whether it's offsetting a pointer or just doing math. The value of 0x00467E20 *cough cough* just might be *cough cough* 50 2D CC 00 at, ummm, some point when connected to some zone. Now that doesn't look like a pointer to me, so I think it's math, but Smong and I weren't so sure you could do math like that.
Also, is edi a 16-bit register? I wouldn't think so, but if it is math, 0x2D50 is a much prettier number than 0x00CC2D50. _________________ This help is informational only. No representation is made or warranty given as to its content. User assumes all risk of use. Cyan~Fire assumes no responsibility for any loss or delay resulting from such use.
Wise men STILL seek Him. |
|
Back to top |
|
 |
Mr Ekted Movie Geek

Gender: Joined: Feb 09 2004 Posts: 1379 Offline
|
Posted: Fri Mar 25, 2005 8:00 pm Post maybe stupid Post subject: |
 |
|
|
|
MOV EAX, [EDI+4]
is like doing this in C:
int *edi;
int eax;
eax = edi[1];
All "E" registers are 32-bit. |
|
Back to top |
|
 |
Cyan~Fire I'll count you!

Age:37 Gender: Joined: Jul 14 2003 Posts: 4608 Location: A Dream Offline
|
Posted: Fri Mar 25, 2005 8:52 pm Post maybe stupid Post subject: |
 |
|
|
|
OK, I thought all e registers were 32-bit, thanks.
But this still doesn't make much sense. 1 more line of code: mov edi,[000467E20]
mov eax,[edi][00004]
mov edx,[edi][0000C]
mov ecx,[eax][00018]
xor ecx,edx |
edi is an array of some sort, we know that. But now is it a ptr array or an integer array? eax is set to edi[1], and then indexed again? But then edx (edi[3]) is used as the source of xor? I'm quite confused.
Also, most of the pointers are 0x0046XXXX, but this one is 0x00CCXXXX. Is there something special here which I don't know? |
|
Back to top |
|
 |
Mr Ekted Movie Geek

Gender: Joined: Feb 09 2004 Posts: 1379 Offline
|
Posted: Fri Mar 25, 2005 11:39 pm Post maybe stupid Post subject: |
 |
|
|
|
My post was just an example. EDI could point to a structure. |
|
Back to top |
|
 |
Cyan~Fire I'll count you!

Age:37 Gender: Joined: Jul 14 2003 Posts: 4608 Location: A Dream Offline
|
Posted: Sat Mar 26, 2005 12:48 am Post maybe stupid Post subject: |
 |
|
|
|
OK, I was kinda thinking that myself.
However, is there some kind of limit to the size of a structure before it starts referencing members directly instead of through the first-member pointer? I ask this because all the arena settings have been referenced directly so far.
Unless VIE didn't put the settings in a structure.  |
|
Back to top |
|
 |
Cyan~Fire I'll count you!

Age:37 Gender: Joined: Jul 14 2003 Posts: 4608 Location: A Dream Offline
|
Posted: Mon Mar 28, 2005 9:16 pm Post maybe stupid Post subject: |
 |
|
|
|
No reply?
/*
mov eax,[edi][00004]
mov edx,[edi][0000C]
mov ecx,[eax][00018]
mov eax,010624DD3
xor ecx,edx
movsx edx,w,[00047DD34]
imul ecx,edx
imul ecx
sar edx,006
mov eax,edx
shr eax,01F
add edx,eax
*/
ecx = global5.offset1[6] ^ global5.offset3; //num players?!
edx = settings.PrizeFactor / 1000 * ecx;
edx += (edx >> 31); |
It would seem like global5.offset1[6] ^ global5.offset3 is the number of players, since it's used as a multiplier for PrizeFactor. But WTF? Is there something I'm missing here?? Of course, the offset1[6] could be another struct, but the xor is still rather odd. And anybody have a clue why it's adding one if it's negative? I don't see how it even could be negative.
/*
mov eax,000000400
sub eax,ecx
cdq
sub eax,edx
*/
eax = 1024 - ecx;
eax -= (eax < 0) ? -1 : 0; |
That also seems kinda weird. Is that some familiar operation in C++ which I'm not translating properly? |
|
Back to top |
|
 |
Mr Ekted Movie Geek

Gender: Joined: Feb 09 2004 Posts: 1379 Offline
|
Posted: Mon Mar 28, 2005 9:38 pm Post maybe stupid Post subject: |
 |
|
|
|
Anything in the data space (public/static data) is at a fixed location and will be referenced by fixed address, even elements of structures, unless it is passed around by address. Anything on the stack (local data) or the heap (allocated data) will be reference by pointer, since it's addres is unknown at compile- and/or load-time. |
|
Back to top |
|
 |
Cyan~Fire I'll count you!

Age:37 Gender: Joined: Jul 14 2003 Posts: 4608 Location: A Dream Offline
|
|
Back to top |
|
 |
Mr Ekted Movie Geek

Gender: Joined: Feb 09 2004 Posts: 1379 Offline
|
Posted: Tue Aug 09, 2005 11:36 pm Post maybe stupid Post subject: |
 |
|
|
|
Oh oh. This is an old can of worms. |
|
Back to top |
|
 |
1stStrike Cute like a kitty
Joined: Dec 28 2002 Posts: 427 Offline
|
Posted: Tue Aug 09, 2005 11:39 pm Post maybe stupid Post subject: |
 |
|
|
|
Oh god, make it stop. Programming is the devil. |
|
Back to top |
|
 |
Agurus Server Help Squatter

Age:39 Gender: Joined: May 05 2004 Posts: 353 Location: SSCI Halo Offline
|
Posted: Wed Aug 10, 2005 9:29 am Post maybe stupid Post subject: |
 |
|
|
|
lol _________________ X-SSCI Halo CTF Administrator
"I used to do drugs. I still do, but I used to, too." |
|
Back to top |
|
 |
xor eax Novice
Joined: Jun 01 2005 Posts: 93 Location: Spain Offline
|
Posted: Wed Aug 10, 2005 9:57 am Post maybe stupid Post subject: |
 |
|
|
|
Hey 1stStrike! Nice to see you ;)
I want to clarify some things.
First of all, Cyan, the asm code you’re talking about it’s not Catid’s code. It is the code I gave to him after extracting it from subspace v1.34, subgame and subbill.
Catid wanted to write bots (he was 15 years old) but he knew little programming. He was learning VB while trying to figure out how to get SS critical routines such as encryption. I did put all the critical code in a dll for him. It took me 2 months of very intensive working. While I was hacking subspace he was working on SS protocol.
My dll was working with VB strings, it dissapointed him when he wanted to translate the whole project to C. I told him I could have write a C version of the dll but he decided to translate the asm code to C. He was learning C very fast and a few time after that he ditched me. He wanted it to be HIS code so he had to translate it to some other lang. I would have embbed asm into C but oh well… that’s another story. I have read in Merv’s page that Cyan fixed a tiny encryption problem. I think it couldn’t have happened using the original asm code that I supplied.
My alias wasn’t xor eax, I used to be Coconut emulator at that time.
As for the “mov eax,0” versus “xor eax, eax” I have to say that both operations takes same time on pentium but they didn’t on lower x86 machines, that’s why old school programmers will always use xor.
Most of the rest of the things that you mention would have never been an issue embbebeding “my” original asm into C. |
|
Back to top |
|
 |
Gravitron VIE Vet

Age:43 Gender: Joined: Aug 02 2002 Posts: 993 Location: Israel Offline
|
Posted: Wed Aug 10, 2005 10:02 am Post maybe stupid Post subject: |
 |
|
|
|
Catid gone weird.
He started hanging with two nutjobs, it changed him.
Or maybe he was changed when he met them.
Eitherway, he's not the same catid I remembered and he's hanging in "bad" company. |
|
Back to top |
|
 |
Smong Server Help Squatter

Joined: 1043048991 Posts: 0x91E Offline
|
|
Back to top |
|
 |
Gravitron VIE Vet

Age:43 Gender: Joined: Aug 02 2002 Posts: 993 Location: Israel Offline
|
Posted: Wed Aug 10, 2005 2:34 pm Post maybe stupid Post subject: |
 |
|
|
|
Quite the interesting reading.
Notice catid's use of smilies in the beginning of some of his posts and Ekted's trashtalk stab with the chewbaka defence, he's obviously been worn out and fortified in his position and not willing to defend/explain it any further.
Now there comes Excel with what seems to be the hammer drop down...*resumes reading*
Well, was a good laugh, but if this guy works for Microsoft as his title represents, it is no wonder why windows code fails so miserably.
Dear Excel, next time, please post something useful such as a professional coder's POV on the issue (yes, I know Excel doesn't read this and this whole thread is a year old, but I can't help being a sinical sarcastic SOB).
Well, Ekted said one thing which I agree is right, coding style isn't worth arguing over (unless it's a specific style which hampers efficiency/eating resources unncessarily).
Note to self : learn assembly already.
Seriously, even Juan knows x86 assembly, and he's a god damned fucking awesome artist!
Juan Skills wrote: |
Basic, C/C++, Java, JavaScript, Maxscript, Perl, PHP, SQL, 6502 8086 8088, DOS, UNIX.
|
The fucking kind of an artist is this guy? Picaso Gates?
also wrote: | Adobe After Effects, Adobe Photoshop, Autdodesk Animator Pro, Autodesk Animator Studio, Autodesk 3D Studio, Autodesk 3D Studio Max, Alias Power Animator, Alias|Wavefront Maya, Debabilizer Pro, Deluxe Paint, Deluxe Animate |
I <3 Juan cuz he's Rad n owns j00 |
|
Back to top |
|
 |
Mr Ekted Movie Geek

Gender: Joined: Feb 09 2004 Posts: 1379 Offline
|
Posted: Wed Aug 10, 2005 3:48 pm Post maybe stupid Post subject: |
 |
|
|
|
xor eax wrote: | As for the “mov eax,0” versus “xor eax, eax” I have to say that both operations takes same time on pentium but they didn’t on lower x86 machines, that’s why old school programmers will always use xor. |
Also: "mov eax,0" takes something like 6 bytes to encode, whereas "xor eax,eax" takes 2. |
|
Back to top |
|
 |
xor eax Novice
Joined: Jun 01 2005 Posts: 93 Location: Spain Offline
|
Posted: Wed Aug 10, 2005 4:16 pm Post maybe stupid Post subject: |
 |
|
|
|
Mr Ekted wrote: | [..]
Also: "mov eax,0" takes something like 6 bytes to encode, whereas "xor eax,eax" takes 2. |
True |
|
Back to top |
|
 |
Cyan~Fire I'll count you!

Age:37 Gender: Joined: Jul 14 2003 Posts: 4608 Location: A Dream Offline
|
Posted: Wed Aug 10, 2005 10:49 pm Post maybe stupid Post subject: |
 |
|
|
|
xor eax wrote: | My alias wasn’t xor eax, I used to be Coconut emulator at that time. |
Ahhh, sweet. I knew it was Coconut Emulator's code, but now I know it's yours. I never said it was catid's anyway, only that it was from MERV. I'm amazed that you're still around... I thought you had disappeared into the SS Hall of Fame never to return.
xor eax wrote: | I have read in Merv’s page that Cyan fixed a tiny encryption problem. I think it couldn’t have happened using the original asm code that I supplied. |
I think you're right, but hey, give catid a break, transferring that code to C is hard.
Ekted wrote: | Oh oh. This is an old can of worms. |
Heh, maybe it is, but all I'm trying to do is make this some real C and not C that was obviously ASM at some point. So do you see any functionality difference between the original and my version?
I read the first few posts in that SSF topic, and I assume that you, Ekted, meant that the 2nd case isn't handled. I realize it still isn't, but when would that actually happen? Some timer sync problem? And, if I was to correct it, I'd have to implement some kind of tolerance (since a simple less than comparison would be stupid). What would you suggest? |
|
Back to top |
|
 |
Mr Ekted Movie Geek

Gender: Joined: Feb 09 2004 Posts: 1379 Offline
|
Posted: Wed Aug 10, 2005 11:12 pm Post maybe stupid Post subject: |
 |
|
|
|
Don't try to make the code have a normal and a special case. Assume any sync delta is valid, and compute the result. Then you can decide what to DO with that result after. Also, don't just let the extreme cases fall through the cracks "cuz they don't matter". |
|
Back to top |
|
 |
Cyan~Fire I'll count you!

Age:37 Gender: Joined: Jul 14 2003 Posts: 4608 Location: A Dream Offline
|
Posted: Thu Aug 11, 2005 3:57 pm Post maybe stupid Post subject: |
 |
|
|
|
Heh. I guess I was opening up a can of worms here, a simple question has evolved into huge amounts of writing.
I don't really care about the cases right now, all I'm trying to do is modify the mervbot code to use this isntead of its rather stupid current getShort() get Long() getCrap() functions. Maybe I'll worry about fixing possible bugs later.
Anyway, I'm just going to assume that that code will work alright, I guess any error will show up soon enough when I test this.
Edit: Ahhhhh, overpunctuation!
Last edited by Cyan~Fire on Thu Aug 11, 2005 8:57 pm, edited 1 time in total |
|
Back to top |
|
 |
Mr Ekted Movie Geek

Gender: Joined: Feb 09 2004 Posts: 1379 Offline
|
Posted: Thu Aug 11, 2005 4:20 pm Post maybe stupid Post subject: |
 |
|
|
|
I'm pretty sure all the getShort() get Long() getCrap() stuff was just a carry-over from the original VB code. That's definitely not the way to do it in C. |
|
Back to top |
|
 |
Cyan~Fire I'll count you!

Age:37 Gender: Joined: Jul 14 2003 Posts: 4608 Location: A Dream Offline
|
Posted: Thu Aug 11, 2005 9:02 pm Post maybe stupid Post subject: |
 |
|
|
|
Indeed, but catid's too lazy (aka busy) to fix it these days. I'm also going to try to split off part of class Host (for anyone who knows anything about MERV) into a somewhat self-contained SS protocol wrapper thing that'll theoretically black-box the core protocol.
And yes, I just did use the evil word "wrapper".
And after that, receives go in a separate thread. And maybe a bit of a plugin system modification, but I don't want to touch that backwards-compatability mess just yet.
And why I am doing this? Who knows. |
|
Back to top |
|
 |
|