WinAsm Studio, The Assembly IDE - Free Downloads, Source Code
Sponsors
Articles
Programming Quick Start
32-bit Assembler is Easy
Porting Iczelion tutorials
What is FASM
Hard Drive Recovery
Wiring your own LAN
Personal menu
Welcome Guest
User:
Pass:
Register!
Resend Validation Email
 
Forum
 

Using INVOKE through an indirect DWORD?, Can't remember / find in MASM prgm'sG.

filofel
Quote Post


New Member
*

Group: Members
Posts: 8
Member No.: 1579
Joined: 16-October 05


Hi All,

(I know this is not really a WinASM section, but I expect to find a good number of experienced MASM coders around here, so, I hope you'll forgive me, Antonis unsure.gif )

I can't remember how one defines a TYPEDEF for a function prototype that takes parms. I think it can be done, since I remember doing it in the past (and spending lotta time finding out how to do it!) - but that was many years ago, when hardly anyone knew one could use MASM with Win32 and I was among the first to post a startup note on the net explaining how to do it (yes, I'm *that* old. Must explain the memory problems tongue.gif ).

A direct prototype would be something like this:
CODE
PXEEntry PROTO FAR C, Code:WORD, DataOffset:WORD, DataSegment:WORD


but the address of the function is defined something like this

CODE
PXESysCall  DWORD ?


Now how can I define the PROTO (or in fact TYPEDEF) that would allow me to
code something like

CODE
    INVOKE PXESysCall, pxenv_undi_shutdown, offset pxe_status, ds


adding I want it to generate exactly this:

CODE
       push    ds
       push    offset pxe_status
       push    pxenv_undi_shutdown
       call    PXESysCall
       add     sp,6


Thanks in advance! /Ph.

PMEmail Poster
Top
blues
Quote Post


Member
******

Group: Members
Posts: 435
Member No.: 20
Joined: 20-May 04


give a look in the "macros.asm" file under the "macros" directory of the masm32 distribution... there is a macro called DDPROTO that does what you need.
in the macros file there is also a short explanation for the usage of the macro.

blues
PMEmail Poster
Top
filofel
Quote Post


New Member
*

Group: Members
Posts: 8
Member No.: 1579
Joined: 16-October 05


Thank you, blues.

As a matter of fact, I ended up finding what I was looking for on top of page 198 of the original MASM programmer's Guide, under "Invoke Procedures Indirectly" (doh!)

And the solution is...
Define it as:
CODE
PXE_PROTO  TYPEDEF PROTO FAR C, Code:WORD, DataOffset:WORD, DataSegment:WORD
PXESysCall TYPEDEF PTR PXE_PROTO


and call it as
CODE
       INVOKE PXESysCall PTR npxe_entry, pxenv_undi_close, offset pxe_status, ds


The worse part is that I finally found where it was documented by looking into the kinda seminal paper I wrote and posted (on Compuserve and on the net, back in early 96, updated sometime in 97) under the name Win32ASM.
I just Googled on "Win32ASM+auphelle", and sure eenuff, the article is still lying around! Even discovered that there still was a copy of it on Iczelion's Win32 Assembly Homepage, at
http://win32assembly.online.fr/source2.html
Owell...

PMEmail Poster
Top
blues
Quote Post


Member
******

Group: Members
Posts: 435
Member No.: 20
Joined: 20-May 04


QUOTE
And the solution is...

that's basicly the same that the macro does as far as i understand.

blues

ps. it's look like you are a "VIP" for the win32asm community smile.gif nice to see you here.
PMEmail Poster
Top
Vortex
Quote Post


Extremely Active Member
******

Group: Moderators
Posts: 140
Member No.: 8
Joined: 13-May 04


Hi filofel,

My method is to use a micro simulating invoke :

CODE

.386
.model flat,stdcall
option casemap:none

include \masm32\include\windows.inc
include \masm32\include\kernel32.inc
includelib \masm32\lib\kernel32.lib

include invoke.inc

.data
user32 db "user32.dll",0
func db "MessageBoxA",0
message db "Calling MessageBoxA through eax",0
caption db "invoke simulator demo",0

.code
start:
invoke LoadLibrary,ADDR user32
invoke GetProcAddress,eax,ADDR func
_invoke eax,0,ADDR message,ADDR caption,MB_OK ; macro simulating invoke
invoke ExitProcess,0
END start


Attached File ( Number of downloads: 23 )
 Login or Register to download
PMEmail PosterUsers Website
Top
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

Topic Options Reply to this topicStart new topicStart Poll

 

Sponsors
Computer Science

Internet
C/C++
Hardware & PC maintenance

HiEditor

General Discussions
Suggestions/Bug Reports
WinAsm Studio

General Discussions
Suggestions/Bug Reports
WinAsm Studio FAQ
Multilingual User Interface
Add-Ins
Assembly Programming

Main
Newbies
Projects
Custom Controls
Snippets
Announcements & Rules

Announcements

General

Online Degrees - Distance Learning
The Heap
Russian
Google