flat assembler
Message board for the users of flat assembler.

Index > Windows > how do i do this in FASM

Author
Thread Post new topic Reply to topic
FrozenKnight



Joined: 24 Jun 2005
Posts: 128
FrozenKnight 26 Jul 2006, 20:18
Code:
tp.Privileges[0].Luid       = luid;    
i'm working on creating a tool that lets me kill any process in windows. and a segiment of code i'm translating from msdn had this statement how does this translate in fasm?
Post 26 Jul 2006, 20:18
View user's profile Send private message Reply with quote
madmatt



Joined: 07 Oct 2003
Posts: 1045
Location: Michigan, USA
madmatt 27 Jul 2006, 06:46
could you show the code where this structure is defined?
Post 27 Jul 2006, 06:46
View user's profile Send private message Reply with quote
FrozenKnight



Joined: 24 Jun 2005
Posts: 128
FrozenKnight 27 Jul 2006, 07:50
never mind i figured it out
Post 27 Jul 2006, 07:50
View user's profile Send private message Reply with quote
Angler



Joined: 28 Jul 2006
Posts: 13
Angler 28 Jul 2006, 08:16
could you help me?

How to translate code like (Delphi)

try
...
finally
...
end;

into FASM?
Post 28 Jul 2006, 08:16
View user's profile Send private message Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid 28 Jul 2006, 08:31
Smile hardly.

no, really. i am not sure about delphi, but i believe it something with SEH. There was already something about SEH on this forum, so search it, and google for it
Post 28 Jul 2006, 08:31
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8353
Location: Kraków, Poland
Tomasz Grysztar 28 Jul 2006, 08:38
Really? I always thought try-finally is just a structural substitute for the error-handling jumps (just to make one more excuse to use GOTO inapplicable). Makes not much sense if you are really into assembly, IMHO.
Post 28 Jul 2006, 08:38
View user's profile Send private message Visit poster's website Reply with quote
zhak



Joined: 12 Apr 2005
Posts: 501
Location: Belarus
zhak 28 Jul 2006, 09:16
yes, TRY is exception handling in delphi. As far as I remember, you can define a block of code to TRY and set exception handling routine with EXCEPT directive. So, if TRY block fails, then EXCEPT block will be executed. FINALLY is executed in all circumstances, and if EXCEPT block wasn't defined, then program will end with error.
Post 28 Jul 2006, 09:16
View user's profile Send private message Reply with quote
Mr_Silent



Joined: 25 Apr 2006
Posts: 30
Mr_Silent 28 Jul 2006, 10:44
Post 28 Jul 2006, 10:44
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8353
Location: Kraków, Poland
Tomasz Grysztar 28 Jul 2006, 13:00
At least for try-throw-catch-finally combination I don't really see why exceptions would be needed. The throw-catch can be implemented with simple conditional jump.
Of course there is also division by zero, etc. - but usually the exceptions are not really needed to handle errors.
Post 28 Jul 2006, 13:00
View user's profile Send private message Visit poster's website Reply with quote
Angler



Joined: 28 Jul 2006
Posts: 13
Angler 29 Jul 2006, 09:51
Спасибо!!! Thank you!!
Post 29 Jul 2006, 09:51
View user's profile Send private message Reply with quote
Angler



Joined: 28 Jul 2006
Posts: 13
Angler 29 Jul 2006, 15:12
Code:
proc OpenCD drive

        mov     [Flags],MCI_OPEN_TYPE or MCI_OPEN_ELEMENT
        mov     [OpenParm.dwCallback],0
        mov     [OpenParm.lpstrDeviceType],szDeviceType ; = 'CDAudio'
        push    [drive]
        pop     [OpenParm.lpstrElementName]
        invoke  mciSendCommand,0,MCI_OPEN,[Flags],OpenParm
        cmp     eax,0
        jne     .finish
        push    [OpenParm.wDeviceID]
        pop     [DeviceID]
        invoke  mciSendCommand,[DeviceID],MCI_SET,MCI_SET_DOOR_OPEN,0
        invoke  mciSendCommand,[DeviceID],MCI_CLOSE,[Flags],OpenParm
  .finish:
        ret
endp
    


I've read about SEH.. But it's hard to understand. Confused

How to execute last opcode?
Code:
        invoke  mciSendCommand,[DeviceID],MCI_CLOSE,[Flags],OpenParm
    


Actually, the question is how to execute this code for sure, if the code:
"invoke mciSendCommand,[DeviceID],MCI_SET,MCI_SET_DOOR_OPEN,0"
is executed?

Does anybody have an idea or suggestion?

Thank you?
Post 29 Jul 2006, 15:12
View user's profile Send private message Reply with quote
Angler



Joined: 28 Jul 2006
Posts: 13
Angler 29 Jul 2006, 15:13
Anyway, thanx..
Post 29 Jul 2006, 15:13
View user's profile Send private message Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid 29 Jul 2006, 15:22
that code is executed always when "invoke mciSendCommand,[DeviceID],MCI_SET,MCI_SET_DOOR_OPEN,0" is executed - because it's just behind it and there is no jump between then

btw:
Quote:
How to execute last opcode?

it's macro call, that is assembled to set of instructions

opcode is numeric representation for one instruction, for example opcode for NOP is 90h
Post 29 Jul 2006, 15:22
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
okasvi



Joined: 18 Aug 2005
Posts: 382
Location: Finland
okasvi 29 Jul 2006, 16:10
vid wrote:
that code is executed always when "invoke mciSendCommand,[DeviceID],MCI_SET,MCI_SET_DOOR_OPEN,0" is executed - because it's just behind it and there is no jump between then

btw:
Quote:
How to execute last opcode?

it's macro call, that is assembled to set of instructions

opcode is numeric representation for one instruction, for example opcode for NOP is 90h


I've always thought it's macro call which is preprocessed to set of instructions which are assembled to binary(opcodes), no? Razz Might be that I've just read wrong, my english isnt very good Sad

_________________
When We Ride On Our Enemies
support reverse smileys |:
Post 29 Jul 2006, 16:10
View user's profile Send private message MSN Messenger Reply with quote
Angler



Joined: 28 Jul 2006
Posts: 13
Angler 29 Jul 2006, 18:46
vid wrote:
that code is executed always when "invoke mciSendCommand,[DeviceID],MCI_SET,MCI_SET_DOOR_OPEN,0" is executed - because it's just behind it and there is no jump between then

btw:
Quote:
How to execute last opcode?

it's macro call, that is assembled to set of instructions

opcode is numeric representation for one instruction, for example opcode for NOP is 90h


You didn't understand..

When program sends message to CD/DVD
Code:
        invoke  mciSendCommand,[DeviceID],MCI_SET,MCI_SET_DOOR_CLOSED,0
    


there might be some problems with a few types of CD/DVD. And i need to give handle back to the Windows, with
Code:
invoke  mciSendCommand,[DeviceID],MCI_CLOSE,[Flags],OpenParm
    


But due to error in the first statement (the error message appears), the 2nd is not executed. So CD/DVD
becomes locked, and it will be unlocked only after restarting Windows.
Post 29 Jul 2006, 18:46
View user's profile Send private message Reply with quote
Angler



Joined: 28 Jul 2006
Posts: 13
Angler 29 Jul 2006, 18:50
And as for macrocall and opcode you are right, but i thought that they are the same.
Post 29 Jul 2006, 18:50
View user's profile Send private message Reply with quote
Reverend



Joined: 24 Aug 2004
Posts: 408
Location: Poland
Reverend 29 Jul 2006, 20:46
Win32 API Reference wrote:
mciSendCommand
(...)

Return Values

Returns zero if successful or an error otherwise. The low-order word of the returned doubleword value contains the error return value. If the error is device-specific, the high-order word of the return value is the driver identifier; otherwise, the high-order word is zero. For a list of possible return values, see Constants: MCIERR Return Values.
To retrieve a text description of mciSendCommand return values, pass the return value to the mciGetErrorString function.

Remarks

Error values that are returned when a device is being opened are listed with the MCI_OPEN command message. In addition to the MCI_OPEN error return values, this function can return the values listed in Constants: MCIERR Return Values.[/b]
Just "test eax, eax\ jnz .error" after invoke.
Post 29 Jul 2006, 20:46
View user's profile Send private message Visit poster's website Reply with quote
Angler



Joined: 28 Jul 2006
Posts: 13
Angler 03 Aug 2006, 10:00
Thank you Reverend i figured out the problem. =)
Post 03 Aug 2006, 10:00
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot 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


Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.