Server Help Forum Index Server Help
Community forums for Subgame, ASSS, and bots
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   StatisticsStatistics   RegisterRegister 
 ProfileProfile   Login to check your private messagesLogin to check your private messages   LoginLogin (SSL) 

Server Help | ASSS Wiki (0) | Shanky.com
Attn: Assembly Nerds

 
Post new topic   Reply to topic Printable version
 View previous topic  Assassin2684's website was hacked Post :: Post FTP server search (Round two)  View next topic  
Author Message
Cerium
Server Help Squatter


Age:42
Gender:Gender:Male
Joined: Mar 05 2005
Posts: 807
Location: I will stab you.
Offline

PostPosted: Tue Nov 28, 2006 10:03 pm   Post maybe stupid    Post subject: Attn: Assembly Nerds Reply to topic Reply with quote

I'm having a bit of trouble dereferencing a pointer in (x86) asm. The block of code Im working with is:


invoke ReadConsoleInput, hConsoleHandle, dwEventAddr, 1, addr dwEventsRead
mov ax, (INPUT_RECORD PTR [dwEventAddr]).EventType
cmp (INPUT_RECORD PTR [dwEventAddr]).EventType, KEY_EVENT

(Note: The mov instruction is strictly for debugging purposes so I can see what the cmp instruction is doing. It will eventually be removed).

Here's the problem:
After the call to ReadConsoleInput, dwEventAddr contains the address of a INPUT_RECORD struct. I can view the info in the struct by putting "(INPUT_RECORD*) dwEventAddr" into VS' watch window and it appears to be correct. However, the mov instruction does not get the value of the EventType field, but rather moves the lower 16 bits of dwEventAddr into ax. (IE: After the mov instruction, dwEventAddr contains 0x001529c8, and AX contains 0x29c8).

What I'm trying to do is mov the value of the EventType field into ax, but I can't figure out how to use what I have to reference it. It seems every bit of casting and dereferencing results in the same instruction (mov ax, word ptr [dwEventAddr]). Any and all help would be appreciated.


-C
_________________
There are 7 user(s) ignoring me right now.
Back to top
View users profile Send private message Add User to Ignore List AIM Address
Cerium
Server Help Squatter


Age:42
Gender:Gender:Male
Joined: Mar 05 2005
Posts: 807
Location: I will stab you.
Offline

PostPosted: Wed Nov 29, 2006 12:05 am   Post maybe stupid    Post subject: Reply to topic Reply with quote

Ok, you guys are friggen slow...


Code: Show/Hide
invoke   ReadConsoleInput, hConsoleHandle, dwEventAddr, 1, addr dwEventsRead
mov      eax, dwEventAddr
cmp      (INPUT_RECORD PTR [eax]).EventType, KEY_EVENT



Seems adding brackets to a variable does nothing, where on a register they do what I expected them to do (Translation: I'm not entirely sure why this works, so if anyone can provide some insight, please do so).
Back to top
View users profile Send private message Add User to Ignore List AIM Address
K'
You can win any war if you start a year early


Gender:Gender:Male
Joined: Jul 13 2006
Posts: 271
Location: Southtown
Offline

PostPosted: Wed Nov 29, 2006 4:57 am   Post maybe stupid    Post subject: Reply to topic Reply with quote

http://www.asmcommunity.net/board/index.php
Back to top
View users profile Send private message Add User to Ignore List
Cyan~Fire
I'll count you!
I'll count you!


Age:37
Gender:Gender:Male
Joined: Jul 14 2003
Posts: 4608
Location: A Dream
Offline

PostPosted: Wed Nov 29, 2006 11:00 am   Post maybe stupid    Post subject: Reply to topic Reply with quote

I've never been too sure about how much you can do in one instruction with ASM, but your problem is probably just that you have to have the structure ptr in a register before you can do anything to it. Doesn't make much sense to me, but that's why people don't code in ASM anymore...

(Implied question: why are you?)
_________________
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
View users profile Send private message Add User to Ignore List Visit posters website
Cerium
Server Help Squatter


Age:42
Gender:Gender:Male
Joined: Mar 05 2005
Posts: 807
Location: I will stab you.
Offline

PostPosted: Wed Nov 29, 2006 11:22 am   Post maybe stupid    Post subject: Reply to topic Reply with quote

From what I gather, you can only dereference a pointer in a register, not a variable. It doesn't make sense to me either, but that's how it works.

I'm doing this because my asm instructor wont let me turn in my projects in C.

Not that asm is terribly hard (or much extra work, for that matter), there's just a few oddities in the syntax that other languages don't have to deal with. I doubt I'll ever write any large scale programs in asm, but I have no problem writing small utilities/libraries with it.
Back to top
View users profile Send private message Add User to Ignore List AIM Address
K'
You can win any war if you start a year early


Gender:Gender:Male
Joined: Jul 13 2006
Posts: 271
Location: Southtown
Offline

PostPosted: Wed Nov 29, 2006 5:12 pm   Post maybe stupid    Post subject: Reply to topic Reply with quote

Cyan~Fire wrote:
Doesn't make much sense to me, but that's why people don't code in ASM anymore...

I agree.
Most new coders nowdays are far inferior and lacking in intelligence to be able to manage ASM.

http://www.theprodukkt.com
Back to top
View users profile Send private message Add User to Ignore List
Display posts from previous:   
Post new topic   Reply to topic    Server Help Forum Index -> Trash Talk All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
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 vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum
View online users | View Statistics | View Ignored List


Software by php BB © php BB Group
Server Load: 149 page(s) served in previous 5 minutes.

phpBB Created this page in 0.678242 seconds : 31 queries executed (83.8%): GZIP compression disabled