Is there equivalent commands for the following?
1. The $ operator meaning this address
StartOfHandles = $
hMoveLeft dd MoveLeft
hMoveRight dd MoveRight
hMoveUp dd MoveUp
hMoveDown dd MoveDown
EndOfHandles = $
LengthOfTable = EndOfHandles-StartOfHandles
etc.
2. Are there any command line options? e.g. /Fl to get a listing?
3. What would be the equivalent of doing the following?
.data?
MenusToHide textequ <0,1,2,5,6,7>
%for MenuNum,<MenusToHide>
mi&MenuNum& MENUITEMINFO <?>
mi&MenuNum&Caption db 20 dup (?)
endm
4. What is the syntax error with this? mov eax,[edx].NMHDR.idFrom
Quote from: Jimg on January 02, 2006, 02:57:52 PM
Is there equivalent commands for the following?
1. The $ operator meaning this address
There is an $ operator, but it's evaluate later/different than in MASM - so maybe something like this:
StartOfHandles:
hMoveLeft dd MoveLeft
hMoveRight dd MoveRight
hMoveUp dd MoveUp
hMoveDown dd MoveDown
EndOfHandles:
LengthOfHandles EQU (EndOfHandles - StartOfHandles)
Quote from: Jimg on January 02, 2006, 02:57:52 PM
2. Are there any command line options? e.g. /Fl to get a listing?
No.
Quote from: Jimg on January 02, 2006, 02:57:52 PM
3. What would be the equivalent of doing the following?
Like this, for example (you need 0.93):
MenusToHide textequ <0,1,2,5,6,7>
for MenuNum, MenusToHide
mi # MenuNum MENUITEMINFO <?>
mi # MenuNum # Caption db 20 dup (?)
endm
Quote from: Jimg on January 02, 2006, 02:57:52 PM
4. What is the syntax error with this? mov eax,[edx].NMHDR.idFrom
I want to be able to use a dot in identifiers, which limits the possibility to use it in other contexts (struct.elem or union.elem is a special case).
You can, of course, get the same result with this:
mov eax,[edx + NMHDR.idFrom]
mov eax,[NMHDR.idFrom + edx]
Pelle
Thank you. I appreciate your efforts, despite how it may appear elsewhere.
This similar to question 4.
If I define a simple structure-
IconPositionData STRUCT ; format of PDatPos
PosX dd ? ; current X position
PosY dd ? ; current Y position
Offt dd ? ; Offset to start of text in Titles
Ofty dd ? ; Offset to type (Type is stored in Titles immediately following Caption)
Icon dd ? ; icon image info is stored as dword
Diix dd ? ; original index into desktop listview
ODat POINT <> ; original X and Y position at start of program
IconPositionData ENDS
and set up an array of these, I put the address of the one I want in ebx so that I can use-
pdatb equ [ebx.IconPositionData] ; shorthand to get position data
and then later, after I have set the address of the array item wanted in ebx, I can (in masm)
access the items using the simple syntax-
mov ecx,pdatb.Offt
I get the error " error: Invalid use of 'pdatb'."
I've tried several different things, but no luck. Would you show me a simple syntax to access these values please?
The only thing I can think of is something like this...
pdatb MACRO elem:REQ
EXITM [ebx + IconPositionData # <.> # elem]
ENDM
...and then use it like this...
mov ecx,pdatb(Offt)
It's almost as short, but with a different syntax. Perhaps "mov ecx,pdatb.Offt" is clearer for a structure reference. Also, if you want to redefine pdatb for different structures, the macro approach is less flexible...
As I think I said before, I need to see structname.elemname as a "single unit" - anything like [structname].elemname, structname + 45 + elemname etc will not work.
Pelle
Just a few more-
How do I do this?
mov [eax],byte ptr 0
I get
error: Invalid combination of opcode and operands (or wrong CPU setting)
similarly-
mov [eax],word ptr 005Dh
and a different one-
pop [eax]
and one final one-
aaa proc
call abc
ret
aaa EndP
abc:
ret
I can't use a proto on a routine that isn't a proc.
FWIW, MASM will turn the first two into:
00401000 C60000 mov byte ptr [eax],0
00401003 66C7005D00 mov word ptr [eax],5Dh
Which IMO is how they should be expressed in the source, and 'aaa' is an instruction mnemonic.
Ok, so I made that up on the fly. try any other name for the proc.
And thanks for the byte ptr thing. I've ofter coded it that way myself and it works. This is one case where I think that is the correct way to code it. There was just too many other things I was fighting for that bit of knowledge to kick in.
And I tried-
pop dword ptr [eax]
and it assembled too.
So all thats left is the myriad of small routines I have scattered about where I just call a label, not a proc.
Now that I finally assembled, I'm crashing in this piece of code-
.data
shell32dll db "Shell32.DLL",0
.data?
OSinfo OSVERSIONINFO <>
.code
invoke GetModuleHandle,addr shell32dll ;for image stuff
mov hShell32,eax
mov OSinfo.dwOSVersionInfoSize,sizeof OSinfo
inv GetVersionEx,addr OSinfo ; test for NT vs. 95/98
.if OSinfo.dwPlatformId >= 2
mov NT,1 ; it's NT
invoke GetProcAddress,hShell32,660 ; initialize system image list
.if eax!=0
push dword ptr 1
call eax
.endif
.endif
any idea what poasm is doing different with this code? Without a listing, it's a bit tough to figure out. And OllyDbg doesn't seem to be able to find the source file.
EDIT...
When I move this bit of code to a program of it's own, it runs. In the large program, it's definately bombing off on the call eax. ugh.
Edit2...
left out a bit of code. added in above. same problems though...
Edit3...
When I comment out the later code, even though it is never executed, the program doesn't bomb. This is gonna take some time to figure out.
The problem appears to be the:
push dword ptr 1
MASM would turn this into:
push 1
Which is how I would code it. PoAsm turns it into:
push dword ptr [1]
If I comment out the initial:
push dword ptr 1
pop eax
Then the program runs OK, assuming GetModuleHandle fails.
; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
.486 ; create 32 bit code
.model flat, stdcall ; 32 bit memory model
option casemap :none ; case sensitive
include \masm32\include\windows.inc
include \masm32\include\masm32.inc
include \masm32\include\gdi32.inc
include \masm32\include\user32.inc
include \masm32\include\kernel32.inc
include \masm32\include\Comctl32.inc
include \masm32\include\comdlg32.inc
include \masm32\include\shell32.inc
include \masm32\include\oleaut32.inc
include \masm32\include\msvcrt.inc
includelib \masm32\lib\masm32.lib
includelib \masm32\lib\gdi32.lib
includelib \masm32\lib\user32.lib
includelib \masm32\lib\kernel32.lib
includelib \masm32\lib\Comctl32.lib
includelib \masm32\lib\comdlg32.lib
includelib \masm32\lib\shell32.lib
includelib \masm32\lib\oleaut32.lib
includelib \masm32\lib\msvcrt.lib
OPTION CSTRINGS:ON
cprint MACRO args:VARARG
LOCAL pstr
.data
pstr db args ; <<<< NO appended terminator
.code
invoke StdOut,OFFSET pstr
ENDM
getkey MACRO
call ret_key
ENDM
.data?
OSinfo OSVERSIONINFO <>
.data
hShell32 dd 0
NT dd 0
shell32dll db "Shell32.DLL",0
.code
start:
; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
push dword ptr 1
pop eax
invoke GetModuleHandle,addr shell32dll ;for image stuff
mov hShell32,eax
.if eax == 0
cprint "GetModuleHandle failed\n"
.endif
mov OSinfo.dwOSVersionInfoSize,sizeof OSinfo
invoke GetVersionEx,addr OSinfo ; test for NT vs. 95/98
.if OSinfo.dwPlatformId >= 2
mov NT,1 ; it's NT
invoke GetProcAddress,hShell32,660 ; initialize system image list
.if eax!=0
push dword ptr 1
call eax
.endif
.endif
getkey
invoke ExitProcess,0
; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
end start
Disassembly
00401000 start:
00401000 FF3501000000 push dword ptr [1]
00401006 58 pop eax
00401007 6808204000 push 402008h
0040100C E805010000 call fn_00401116
00401011 A300204000 mov [402000h],eax
00401016 85C0 test eax,eax
00401018 750A jnz loc_00401024
0040101A 6814204000 push 402014h
0040101F E850000000 call fn_00401074
00401024 loc_00401024:
00401024 C7056859400094000000 mov dword ptr [405968h],94h
0040102E 6868594000 push 405968h
00401033 E8E4000000 call fn_0040111C
00401038 833D7859400002 cmp dword ptr [405978h],2
0040103F 7226 jb loc_00401067
00401041 C7050420400001000000 mov dword ptr [402004h],1
0040104B 6894020000 push 294h
00401050 FF3500204000 push dword ptr [402000h]
00401056 E8C7000000 call fn_00401122
0040105B 85C0 test eax,eax
0040105D 7408 jz loc_00401067
0040105F FF3501000000 push dword ptr [1]
00401065 FFD0 call eax
00401067 loc_00401067:
00401067 E844000000 call fn_004010B0
0040106C 6A00 push 0
0040106E E8B5000000 call fn_00401128
00401073 CC int 3
00401074 fn_00401074:
00401074 55 push ebp
00401075 8BEC mov ebp,esp
00401077 83C4F4 add esp,0FFFFFFF4h
0040107A 6AF5 push 0FFFFFFF5h
0040107C E8AD000000 call fn_0040112E
00401081 8945FC mov [ebp-4],eax
00401084 FF7508 push dword ptr [ebp+8]
00401087 E854000000 call fn_004010E0
0040108C 8945F4 mov [ebp-0Ch],eax
0040108F 6A00 push 0
00401091 8D45F8 lea eax,[ebp-8]
00401094 50 push eax
00401095 FF75F4 push dword ptr [ebp-0Ch]
00401098 FF7508 push dword ptr [ebp+8]
0040109B FF75FC push dword ptr [ebp-4]
0040109E E891000000 call fn_00401134
004010A3 8B45F8 mov eax,[ebp-8]
004010A6 C9 leave
004010A7 C20400 ret 4
004010AA CC int 3
004010AB CC int 3
004010AC CC int 3
004010AD CC int 3
004010AE CC int 3
004010AF CC int 3
004010B0 fn_004010B0:
004010B0 6AF6 push 0FFFFFFF6h
004010B2 E877000000 call fn_0040112E
004010B7 50 push eax
004010B8 E87D000000 call fn_0040113A
004010BD FF154C2F4000 call dword ptr [_getch]
004010C3 33C9 xor ecx,ecx
004010C5 85C0 test eax,eax
004010C7 7407 jz loc_004010D0
004010C9 3DE0000000 cmp eax,0E0h
004010CE 750B jnz loc_004010DB
004010D0 loc_004010D0:
004010D0 FF154C2F4000 call dword ptr [_getch]
004010D6 B901000000 mov ecx,1
004010DB loc_004010DB:
004010DB C3 ret
004010DC CC int 3
004010DD CC int 3
004010DE CC int 3
004010DF CC int 3
004010E0 fn_004010E0:
004010E0 8B442404 mov eax,[esp+4]
004010E4 53 push ebx
004010E5 8D5003 lea edx,[eax+3]
004010E8 loc_004010E8:
004010E8 8B18 mov ebx,[eax]
004010EA 83C004 add eax,4
004010ED 8D8BFFFEFEFE lea ecx,[ebx-1010101h]
004010F3 F7D3 not ebx
004010F5 23CB and ecx,ebx
004010F7 81E180808080 and ecx,80808080h
004010FD 74E9 jz loc_004010E8
004010FF F7C180800000 test ecx,8080h
00401105 7506 jnz loc_0040110D
00401107 C1E910 shr ecx,10h
0040110A 83C002 add eax,2
0040110D loc_0040110D:
0040110D D0E1 shl cl,1
0040110F 1BC2 sbb eax,edx
00401111 5B pop ebx
00401112 C20400 ret 4
00401115 CC int 3
00401116 fn_00401116:
00401116 FF25F42B4000 jmp dword ptr [GetModuleHandleA]
0040111C fn_0040111C:
0040111C FF25F82B4000 jmp dword ptr [GetVersionExA]
00401122 fn_00401122:
00401122 FF25FC2B4000 jmp dword ptr [GetProcAddress]
00401128 fn_00401128:
00401128 FF25002C4000 jmp dword ptr [ExitProcess]
0040112E fn_0040112E:
0040112E FF25042C4000 jmp dword ptr [GetStdHandle]
00401134 fn_00401134:
00401134 FF25082C4000 jmp dword ptr [WriteFile]
0040113A fn_0040113A:
0040113A FF250C2C4000 jmp dword ptr [FlushConsoleInputBuffer]
Thanks Michael. I just spent 3 hours trying to track down the problem in the full program. Push 1 solved it. It was very strange that when I commented out procs farther down in the program, it assembled and ran with the push dword ptr 1. So I started eliminating stuff until I got to the problem line. Here's a simple console program to show what I mean. If you comment out the shgetfileinfo invoke in the dummy proc, it runs, perhaps incorrectly, but it runs. With it in there it crashes. Very strange, even if push dword ptr 1 is wrong.
.MODEL flat, stdcall
Include windowspo.inc ; this is the windows.inc that Hutch made for poasm
uselib MACRO libname:req
include libname#.inc
includelib libname#.lib
ENDM
uselib user32
uselib kernel32
uselib shell32
uselib comctl32
uselib masm32
soff Macro QuotedText:Vararg ; returns offset to a string
Local LocalText
.data
LocalText db QuotedText,0
.code
Exitm <offset LocalText>
Endm
Print_Text Macro txt:REQ ;;note txt is not a pointer
Invoke StdOut,ADDR txt
EndM
Get_Input Macro prompt:REQ,buffer:REQ ;;note prompt is not a pointer
Invoke StdOut,ADDR prompt
Invoke StdIn,ADDR buffer, LengthOf buffer
EndM
prt macro txt:req
pusha
invoke StdOut,soff(txt,13,10)
popa
EndM
.DATA
Msg4 DB "Success, Press Enter to Exit",0
.DATA?
inbuf DB 100 DUP (?)
.data
NT dd 0 ; NT flag, assume not NT
shell32dll db "Shell32.DLL",0
potst db "",0
.data?
OSinfo OSVERSIONINFO <>
hShell32 dd ?
IDL dd 256 dup (?)
sfi SHFILEINFO <?>
.code
Program:
prt "starting test"
invoke GetModuleHandle,addr shell32dll ;for image stuff
mov hShell32,eax
mov OSinfo.dwOSVersionInfoSize,sizeof OSinfo
invoke GetVersionEx,addr OSinfo ; test for NT vs. 95/98
.if OSinfo.dwPlatformId >= 2
mov NT,1 ; it's NT
invoke GetProcAddress,hShell32,660 ; initialize system image list
.if eax!=0
push dword ptr 1
call eax
.endif
.endif
prt "test good"
Get_Input Msg4,inbuf
Invoke ExitProcess,0
Dummy proc
; if you comment out the following line, everything works ok.
invoke SHGetFileInfo,addr IDL,0,addr sfi,SIZEOF SHFILEINFO,SHGFI_SYSICONINDEX+SHGFI_TYPENAME+SHGFI_PIDL+SHGFI_ICON
ret
Dummy Endp
End Program