The LOCAL directive works only with ebp and is scoped to the procedure. I know there is ASSUME, but ASSUME is scoped until it is unassumed? I've done some weird stuff with LOCAL so I would like something of the same basic functionality but able to specify a reg. Here is some wacky code I wrote a long time ago:
OPTION PROLOGUE:NONE
OPTION EPILOGUE:NONE
align 16
InitD3D PROC PUBLIC
LOCAL ID3D9[0]:_ID3D9
mov .EBP,ebp
invoke Direct3DCreate9,D3D_SDK_VERSION
mov g_pD3D,eax
mov eax,[eax]
mov [D9vt],eax
mov ebp,eax
mov d3dpp.Windowed,TRUE
mov d3dpp.SwapEffect,D3DSWAPEFFECT_DISCARD
mov d3dpp.BackBufferFormat,D3DFMT_UNKNOWN
invoke [ID3D9].CreateDevice,[g_pD3D],\
D3DADAPTER_DEFAULT,D3DDEVTYPE_HAL,\
[Hwnd],\
D3DCREATE_SOFTWARE_VERTEXPROCESSING,\
ADDR d3dpp,\
ADDR g_pd3dDevice
mov eax,g_pd3dDevice
mov eax,[eax]
mov D3Dvt,eax
mov ebp,.EBP
ret
InitD3D endp
Yes I'm using LOCAL without a stack frame. You could do LOCAL ID3D9[-4]:_ID3D9. The [] is just an offset. Negative offsets are really hard to follow. This is the_ID3D9 struc:
_ID3D9 STRUC
QueryInterface FCALL@12 PTR ?
AddRef FCALL@4 PTR ?
Release FCALL@4 PTR ?
RegisterSoftwareDevice FCALL@8 PTR ?
GetAdapterCount FCALL@4 PTR ?
GetAdapterIdentifier FCALL@16 PTR ?
GetAdapterModeCount FCALL@12 PTR ?
EnumAdapterModes FCALL@20 PTR ?
GetAdapterDisplayMode FCALL@12 PTR ?
CheckDeviceType FCALL@24 PTR ?
CheckDeviceFormat FCALL@28 PTR ?
CheckDeviceMultiSampleType FCALL@28 PTR ?
CheckDepthStencilMatch FCALL@24 PTR ?
CheckDeviceFormatConversion FCALL@20 PTR ?
GetDeviceCaps FCALL@16 PTR ?
GetAdapterMonitor FCALL@8 PTR ?
CreateDevice FCALL@28 PTR ?
_ID3D9 ENDS
That the vtable from a COM object. I just use LOCAL to cast. What I want to do is cast structures to variables that are local in scope and choose which reg to base it off of unlike LOCAL. I know a bit about macros but reverser engineering LOCAL is over my head. Any ideas? Any macro writing tutorials?
Thanks.
In MASM, there is, unfortunately, no way how to tell the compiler "I use xyz stack frame register". We can use just EBP.
Petroizki already made pmacros (http://www.masmforum.com/simple/index.php?topic=1063.0) macro set, which allows you to use ESP stack frame. I can imagine you can modify it to your needs, but that would be not so trivial.
FYI, if you'll find pmacros useful for you, ask for the newest, fixed version in that thread.
Thanks. Something for me to study. I mean however any 32 bit reg. In my code above there is no stack frame. I was using LOCAL for scoping and as a movable pointer into a vtable.