flat assembler
Message board for the users of flat assembler.

Index > Compiler Internals > Bug in fasmw 1.71.26?

Author
Thread Post new topic Reply to topic
madmatt



Joined: 07 Oct 2003
Posts: 1046
Location: Michigan, USA
madmatt
Code below should produce error(s), and doesn't
Code:
     mov        rcx, NULL
     mov        rdx, szAppClass
     mov        r8, szAppTitle
     mov        r9, WS_OVERLAPPEDWINDOW or WS_VISIBLE
     mov        rax, [startx]
     mov        [esp + 32], rax ;Error?
     mov        rax, [starty]
     mov        [esp + 40], rax ;Error?
     mov        [esp + 48], r10 ;Error?
     mov        [esp + 56], r11 ;Error?
     mov        [esp + 64], rcx ;Error?
     mov        [esp + 72], rcx ;Error?
     mov        rax, [hInstance]
     mov        [esp + 80], rax
     mov        [esp + 88], rcx
     call       [CreateWindowEx]
    

_________________
Gimme a sledge hammer! I'LL FIX IT!
Post 13 Nov 2014, 17:12
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 16850
Location: In your JS exploiting you and your system
revolution
It does error for me:
Code:
     mov        rcx, NULL
error: illegal instruction.    
You need to define the constants like NULL somewhere and to use registers like rcx you need to put use64.
Post 13 Nov 2014, 17:14
View user's profile Send private message Visit poster's website Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 16850
Location: In your JS exploiting you and your system
revolution
BTW: the Intel manual has this to say:
Quote:
RIP-relative addressing is enabled by 64-bit mode, not by a 64-bit address-size. The use of the address-size prefix does not disable RIP-relative addressing. The effect of the address-size prefix is to truncate and zero-extend the computed effective address to 32 bits.
Post 13 Nov 2014, 17:24
View user's profile Send private message Visit poster's website Reply with quote
madmatt



Joined: 07 Oct 2003
Posts: 1046
Location: Michigan, USA
madmatt
Forgot to mention that this is 64bit programming, anyways the full source is below. As you can see, I was experimenting with a more raw form of coding. What I was saying is that shouldn't ESP be RSP? no error? or is there something about 64bit programming that I don't know about?

Code:
format PE64 GUI 5.0 on 'nul'
entry WINMAIN

include 'win64a.inc'
include 'equates\msvcrt.inc'
include 'equates\kernel32.inc'
include 'equates\gdi32.inc'
include 'equates\user32.inc'
include 'equates\comctl32.inc'
include 'equates\shell32.inc'

WINDOWWIDTH  = 800
WINDOWHEIGHT = 600
IDI_MAINICON = 500

;DISPLAY "SizeOf: ",<sizeof.WNDCLASSEXA, 10>,13,10
;DISPLAY "SizeOf: $",<sizeof.VS_FIXEDFILEINFO, 16>,13,10
section '.data' data readable writeable
  szAppTitle db "Windows Shell 64A",0
  szAppClass db "WinShellW64",0
  _regclass  db "RegisterClassEx()",0
  _createw   db "CreateWindowEx()",0
  _fontname  db "Courier New",0 ;"Tahoma"
  _error     db "ERROR",0
  _hdtext    db "HARD DRIVE STATS:",0
  _tbytes    db "TotalBytes: %s",0
  _fbytes    db "FreeBytes:  %s",0
  _ubytes    db "UsedBytes:  %s",0

  align 8

  hWnd      dq 0
  hinstance dq 0
  editfont  dq 0

  icex INITCOMMONCONTROLSEX sizeof.INITCOMMONCONTROLSEX, ICC_ALL_CLASSES

section '.code' code readable executable

proc WINMAIN  hInstance, hprevinstance, lpcmdline, ncmdshow
     local msg:MSG, winClass:WNDCLASSEXA, clientrectangle:RECT, startx:QWORD, starty:QWORD

     invoke  InitCommonControlsEx, icex
     cinvoke memset, addr winClass, 0, sizeof.WNDCLASSEXA
     invoke  GetModuleHandle, 0
     mov     [hInstance], rax
     mov     [winClass.hInstance], rax
     mov     [winClass.lpszClassName], szAppClass
     mov     [winClass.cbSize], sizeof.WNDCLASSEXA
     mov     [winClass.style], CS_HREDRAW or CS_VREDRAW
     mov     [winClass.lpfnWndProc], WindowProc
     invoke  LoadIcon, [hInstance], IDI_APPLICATION
     mov     [winClass.hIcon], rax
     mov     [winClass.hIconSm], rax
     invoke  LoadCursor, NULL, IDC_ARROW
     mov     [winClass.hCursor], rax
     invoke  GetStockObject, LTGRAY_BRUSH
     mov     [winClass.hbrBackground], rax
     mov     [winClass.lpszMenuName], NULL
     mov     [winClass.cbClsExtra], 0
     mov     [winClass.cbWndExtra], 0

     ;Register our window class.
     invoke  RegisterClassEx, addr winClass
     .if     rax = NULL
             invoke  MessageBox, NULL, _regclass, _error, MB_OK or MB_ICONERROR
             mov     rax, FALSE
             ret
     .endif

     ;Create window for Direct3D FullScreen mode.
     invoke  GetSystemMetrics, SM_CXFULLSCREEN
     shr     rax, 1
     sub     rax, WINDOWWIDTH shr 1
     mov     [startx], rax

     invoke  GetSystemMetrics, SM_CYFULLSCREEN
     shr     rax, 1
     sub     rax, WINDOWHEIGHT shr 1
     mov     [starty], rax

     invoke  SetRect, addr clientrectangle, 0, 0, WINDOWWIDTH, WINDOWHEIGHT
     invoke  AdjustWindowRect, addr clientrectangle, WS_OVERLAPPEDWINDOW or WS_VISIBLE, FALSE
     movsxd  r10, [clientrectangle.right]
     movsxd  r11, [clientrectangle.left]
     sub     r10, r11
     movsxd  r11, [clientrectangle.bottom]
     movsxd  r12, [clientrectangle.top]
     sub     r11, r12

     mov        rcx, NULL
     mov        rdx, szAppClass
     mov        r8, szAppTitle
     mov        r9, WS_OVERLAPPEDWINDOW or WS_VISIBLE
     mov        rax, [startx]
     mov        [esp + 32], rax
     mov        rax, [starty]
     mov        [esp + 40], rax
     mov        [esp + 48], r10
     mov        [esp + 56], r11
     mov        [esp + 64], rcx
     mov        [esp + 72], rcx
     mov        rax, [hInstance]
     mov        [esp + 80], rax
     mov        [esp + 88], rcx
     call       [CreateWindowEx]
     ;invoke  CreateWindowEx, NULL, szAppClass, szAppTitle, WS_OVERLAPPEDWINDOW or WS_VISIBLE, [startx], [starty], r10, r11,\
     ;        NULL, NULL, [hInstance], NULL
     .if     rax = NULL
             invoke  MessageBox, NULL, _createw, _error, MB_OK or MB_ICONERROR
             mov     rax, FALSE
             ret
     .endif
     mov     [hWnd], rax

     mov     [msg.message], FALSE
     .while  [msg.message] <> WM_QUIT
             invoke  GetMessage, addr msg, NULL, 0, 0
             invoke  TranslateMessage, addr msg
             invoke  DispatchMessage, addr msg
     .endw

     invoke  ExitProcess, 0
     ret
endp

proc WindowProc  hwnd, wmsg, wparam, lparam
     local hdc:QWORD, FreeBytes:QWORD, TotalBytes:QWORD, UsedBytes:QWORD, ps:PAINTSTRUCT, szBuf[128]:BYTE, szBuffer[128]:BYTE
     ;Note that first four parameters are passed in registers,
     ;while names given in the declaration of procedure refer to the stack
     ;space reserved for them - you may store them there to be later accessible
     ;if the contents of registers gets destroyed. This may look like:
     mov     [hwnd], rcx
     mov     [wmsg], rdx
     mov     [wparam], r8
     mov     [lparam], r9

     .if     rdx = WM_CREATE
             invoke  CreateFont, 24, 10, 0, 0, FW_BOLD, NULL, NULL, NULL, ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS,\
                     CLEARTYPE_QUALITY, VARIABLE_PITCH or FF_DONTCARE, _fontname
             mov     [editfont], rax

             mov     rax, NO_ERROR
             ret

     .elseif rdx = WM_PAINT
             invoke  BeginPaint, rcx, addr ps
             mov     [hdc], rax

             .if     [editfont]  .then  invoke  SelectObject, [hdc], [editfont]

             invoke  GetDiskFreeSpaceEx, NULL, addr FreeBytes, addr TotalBytes, NULL
             mov     rax, [TotalBytes]
             sub     rax, [FreeBytes]
             mov     [UsedBytes], rax

             cinvoke sprintf, addr szBuffer, _hdtext
             invoke  TextOut, [hdc], 0, 0, addr szBuffer, rax

             stdcall BigNumToString, [TotalBytes], addr szBuf
             cinvoke sprintf, addr szBuffer, _tbytes, addr szBuf
             invoke  TextOut, [hdc], 0, 20*1+(20/4), addr szBuffer, rax

             stdcall BigNumToString, [FreeBytes], addr szBuf
             cinvoke sprintf, addr szBuffer, _fbytes, addr szBuf
             invoke  TextOut, [hdc], 0, 20*2+(20/4), addr szBuffer, rax

             stdcall BigNumToString, [UsedBytes], addr szBuf
             cinvoke sprintf, addr szBuffer, _ubytes, addr szBuf
             invoke  TextOut, [hdc], 0, 20*3+(20/4), addr szBuffer, rax

             invoke  EndPaint, [hwnd], addr ps

             mov     rax, NO_ERROR
             ret

     .elseif rdx = WM_KEYDOWN
             .if     r8 = VK_ESCAPE
                     .if     [editfont]  .then  invoke  DeleteObject, [editfont]

                     invoke  PostQuitMessage, 0
             .endif

             mov     rax, NO_ERROR
             ret

     .elseif rdx = WM_CLOSE
             .if     [editfont]  .then  invoke  DeleteObject, [editfont]

             invoke  PostQuitMessage, 0

             mov     rax, NO_ERROR
             ret
     .endif

     invoke  DefWindowProc, rcx, rdx, r8, r9
     return
endp

;This function accepts a number and converts it to a string inserting commas where appropriate.
proc BigNumToString  lNum, szBuf
     local wNumDigits:QWORD, wNumChars:QWORD

     mov     [lNum], rcx
     mov     [szBuf], rdx

     xor     rax, rax
     mov     [wNumDigits], rax
     mov     [wNumChars], rax
     .repeat
             ;Put the last digit of the string in the character buffer.
             ;szBuf[wNumChars++] = lNum % 10 + '0'
             mov     rdx, 0
             mov     rcx, 10
             mov     rax, [lNum]
             idiv    rcx
             add     dl, '0'

             mov     rcx, [szBuf]
             mov     rax, [wNumChars]
             mov     [rcx + rax], dl
             add     [wNumChars], 1

             ;Increment the number of digits that we put in the string.
             add     [wNumDigits], 1

             ;For every three digits put in the string, add a comma ",".
             mov     rcx, 3
             mov     rdx, 0
             mov     rax, [wNumDigits]
             idiv    rcx
             .if     rdx = 0
                     mov     rcx, [szBuf]
                     mov     rax, [wNumChars]
                     mov     byte [rcx + rax], ','
                     add     [wNumChars], 1
             .endif

             ;Divide the number by 10 and repeat the process.
             mov     rcx, 10
             mov     rdx, 0
             mov     rax, [lNum]
             idiv    rcx
             mov     [lNum], rax
             ;Continue adding digits to the string until the number is zero.
     .until  [lNum] <= 0

     ;If the last character added to the string was a comma, truncate it.
     mov     rcx, [szBuf]
     mov     rax, [wNumChars]
     .if     byte [rcx + rax - 1] = ','  .then  mov     byte [rcx + rax - 1], 0

     ;Make sure that the string is zero-terminated.
     mov     rcx, [szBuf]
     mov     rax, [wNumChars]
     mov     byte [rcx + rax], 0

     ;We added all of the chaaracters to the string in reverse order.
     ;We must reverse the contents of the string.
     ;strrev(szBuf);
     cinvoke _strrev, [szBuf]

     mov     rax, [szBuf]
     ret
endp

section '.rsrc' resource data readable
  directory RT_MANIFEST, manifest

  resource manifest, 1, LANG_NEUTRAL, xpstyle

  resdata xpstyle
          file '\..\fasmw64\w7include64\winxpstyle.xml'
  endres

section '.idata' import data readable writeable

  library msvcrt,'MSVCRT.DLL',\
          kernel32,'KERNEL32.DLL',\
          user32,'USER32.DLL',\
          gdi32,'GDI32.DLL',\
          comctl32,'COMCTL32.DLL',\
          shell32,'SHELL32.DLL'

  include 'apia\msvcrt.inc'
  include 'apia\kernel32.inc'
  include 'apia\gdi32.inc'
  include 'apia\user32.inc'
  include 'apia\comctl32.inc'
  include 'apia\shell32.inc'
    
Post 13 Nov 2014, 18:33
View user's profile Send private message Reply with quote
l_inc



Joined: 23 Oct 2009
Posts: 881
l_inc
madmatt
Quote:
What I was saying is that shouldn't ESP be RSP? no error?

I suppose, the revolution's point is that both registers are OK to be base registers in the 64 bit mode:
Code:
flat assembler  version 1.71.26  (1572864 kilobytes memory)
0x4021CA:  7 | 48 C7 C1 00 00 00 00    | mov rcx,NULL
0x4021D1:  7 | 48 C7 C2 12 10 40 00    | mov rdx,szAppClass
0x4021D8:  7 | 49 C7 C0 00 10 40 00    | mov r8,szAppTitle
0x4021DF:  7 | 49 C7 C1 00 00 CF 10    | mov r9,WS_OVERLAPPEDWINDOW or WS_VISIBLE
0x4021E6:  8 | 48 8B 84 24 C0 00 00 00 | mov rax,[startx]
0x4021EE:  6 | 67 48 89 44 24 20       | mov [esp+32],rax
0x4021F4:  8 | 48 8B 84 24 C8 00 00 00 | mov rax,[starty]
0x4021FC:  5 | 48 89 44 24 28          | mov [rsp+40],rax
0x402201:  6 | 67 4C 89 54 24 30       | mov [esp+48],r10
0x402207:  5 | 4C 89 5C 24 38          | mov [rsp+56],r11
0x40220C:  6 | 67 48 89 4C 24 40       | mov [esp+64],rcx
0x402212:  5 | 48 89 4C 24 48          | mov [rsp+72],rcx
0x402217:  8 | 48 8B 84 24 E0 00 00 00 | mov rax,[hInstance]
0x40221F:  6 | 67 48 89 44 24 50       | mov [esp+80],rax
0x402225:  5 | 48 89 4C 24 58          | mov [rsp+88],rcx
0x40222A:  6 | FF 15 A0 20 00 00       | call [CreateWindowEx]
Total size of the shown instructions: 102
4 passes, 0.5 seconds, 5632 bytes    

esp is most probably not what you wanna have, but the esp-relative addressing by itself is perfectly valid in the 64 bit mode.

To obtain the above output:
Code:
ilen_ iset
     mov        rcx, NULL 
     mov        rdx, szAppClass 
     mov        r8, szAppTitle 
     mov        r9, WS_OVERLAPPEDWINDOW or WS_VISIBLE 
     mov        rax, [startx] 
     mov        [esp + 32], rax 
     mov        rax, [starty] 
     mov        [rsp + 40], rax 
     mov        [esp + 48], r10 
     mov        [rsp + 56], r11 
     mov        [esp + 64], rcx 
     mov        [rsp + 72], rcx 
     mov        rax, [hInstance] 
     mov        [esp + 80], rax 
     mov        [rsp + 88], rcx 
     call       [CreateWindowEx] 
_ilen    

The relevant macros:
Code:
iset equ bt,in,ja,jb,jc,je,jg,jl,\
jo,jp,js,jz,or,aaa,aad,aam,\
aas,adc,add,and,bsf,bsr,btc,btr,\
bts,cbw,cdq,clc,cld,cli,cmc,cmp,\
cqo,cwd,daa,das,dec,div,fld,fst,\
hlt,inc,ins,int,jae,jbe,jge,jle,\
jmp,jna,jnb,jnc,jne,jng,jnl,jno,\
jnp,jns,jnz,jpe,jpo,lar,lds,lea,\
les,lfs,lgs,lsl,lss,ltr,mov,mul,\
neg,nop,not,out,pop,por,rcl,rcr,\
rep,ret,rol,ror,rsm,sal,sar,sbb,\
shl,shr,stc,std,sti,str,sub,ud2,\
xor,adcx,adox,andn,arpl,blci,blcs,blsi,\
blsr,bzhi,call,cdqe,clac,clgi,clts,cmps,\
cwde,dppd,dpps,emms,fabs,fadd,fbld,fchs,\
fcom,fcos,fdiv,feni,fild,fist,fld1,fldz,\
fmul,fnop,fsin,fstp,fsub,ftst,fxam,fxch,\
idiv,imul,insb,insd,insw,int1,int3,into,\
invd,iret,jcxz,jnae,jnbe,jnge,jnle,lahf,\
lgdt,lidt,lldt,lmsw,lock,lods,loop,movd,\
movq,movs,mulx,orpd,orps,outs,pand,pdep,\
pext,popa,popd,popf,popq,popw,push,pxor,\
repe,repz,retd,retf,retn,retq,retw,rorx,\
sahf,salc,sarx,scas,seta,setb,setc,sete,\
setg,setl,seto,setp,sets,setz,sgdt,shld,\
shlx,shrd,shrx,sidt,sldt,smsw,stac,stgi,\
stos,test,verr,verw,vpor,wait,xadd,xchg,\
xend,xlat,addpd,addps,addsd,addss,andpd,andps,\
bextr,blcic,blsic,bound,bswap,cmova,cmovb,cmovc,\
cmove,cmovg,cmovl,cmovo,cmovp,cmovs,cmovz,cmppd,\
cmpps,cmpsb,cmpsd,cmpsq,cmpss,cmpsw,cpuid,crc32,\
divpd,divps,divsd,divss,enter,extrq,f2xm1,faddp,\
fbstp,fclex,fcomi,fcomp,fdisi,fdivp,fdivr,femms,\
ffree,fiadd,ficom,fidiv,fimul,finit,fistp,fisub,\
fldcw,fldpi,fmulp,fneni,fprem,fptan,fsave,fsqrt,\
fstcw,fstsw,fsubp,fsubr,fucom,fwait,fyl2x,icebp,\
iretd,iretq,iretw,jecxz,jrcxz,lddqu,leave,lodsb,\
lodsd,lodsq,lodsw,loopd,loope,loopq,loopw,loopz,\
lzcnt,maxpd,maxps,maxsd,maxss,minpd,minps,minsd,\
minss,movbe,movsb,movsd,movsq,movss,movsw,movsx,\
movzx,mulpd,mulps,mulsd,mulss,mwait,outsb,outsd,\
outsw,pabsb,pabsd,pabsw,paddb,paddd,paddq,paddw,\
pandn,pause,pavgb,pavgw,pf2id,pf2iw,pfacc,pfadd,\
pfmax,pfmin,pfmul,pfrcp,pfsub,pi2fd,pi2fw,popad,\
popaw,popfd,popfq,popfw,pslld,psllq,psllw,psrad,\
psraw,psrld,psrlq,psrlw,psubb,psubd,psubq,psubw,\
ptest,pusha,pushd,pushf,pushq,pushw,rcpps,rcpss,\
rdmsr,rdpmc,rdtsc,repne,repnz,retfd,retfq,retfw,\
retnd,retnq,retnw,scasb,scasd,scasq,scasw,setae,\
setbe,setge,setle,setna,setnb,setnc,setne,setng,\
setnl,setno,setnp,setns,setnz,setpe,setpo,stosb,\
stosd,stosq,stosw,subpd,subps,subsd,subss,tzcnt,\
tzmsk,vdppd,vdpps,vmovd,vmovq,vmrun,vmxon,vorpd,\
vorps,vpand,vpxor,wrmsr,xlatb,xorpd,xorps,xsave,\
xtest,aesdec,aesenc,aesimc,andnpd,andnps,blcmsk,blsmsk,\
cmovae,cmovbe,cmovge,cmovle,cmovna,cmovnb,cmovnc,cmovne,\
cmovng,cmovnl,cmovno,cmovnp,cmovns,cmovnz,cmovpe,cmovpo,\
comisd,comiss,fcmovb,fcmove,fcmovu,fcomip,fcompp,fdivrp,\
ffreep,ficomp,fidivr,fisttp,fisubr,fldenv,fldl2e,fldl2t,\
fldlg2,fldln2,fnclex,fndisi,fninit,fnsave,fnstcw,fnstsw,\
fpatan,fprem1,frstor,frstpm,fsaved,fsavew,fscale,fsetpm,\
fstenv,fsubrp,fucomi,fucomp,fxsave,getsec,haddpd,haddps,\
hsubpd,hsubps,invept,invlpg,lfence,llwpcb,looped,loopeq,\
loopew,loopne,loopnz,loopzd,loopzq,loopzw,lwpins,lwpval,\
mfence,movapd,movaps,movdqa,movdqu,movhpd,movhps,movlpd,\
movlps,movnti,movntq,movsxd,movupd,movups,paddsb,paddsw,\
pextrb,pextrd,pextrq,pextrw,pfnacc,pfsubr,phaddd,phaddw,\
phsubd,phsubw,pinsrb,pinsrd,pinsrq,pinsrw,pmaxsb,pmaxsd,\
pmaxsw,pmaxub,pmaxud,pmaxuw,pminsb,pminsd,pminsw,pminub,\
pminud,pminuw,pmuldq,pmulhw,pmulld,pmullw,popcnt,psadbw,\
pshufb,pshufd,pshufw,psignb,psignd,psignw,pslldq,psrldq,\
psubsb,psubsw,pswapd,pushad,pushaw,pushfd,pushfq,pushfw,\
rdmsrq,rdrand,rdseed,rdtscp,setalc,setnae,setnbe,setnge,\
setnle,sfence,shufpd,shufps,skinit,slwpcb,sqrtpd,sqrtps,\
sqrtsd,sqrtss,swapgs,sysret,t1mskc,vaddpd,vaddps,vaddsd,\
vaddss,vandpd,vandps,vcmppd,vcmpps,vcmpsd,vcmpss,vdivpd,\
vdivps,vdivsd,vdivss,vlddqu,vmaxpd,vmaxps,vmaxsd,vmaxss,\
vmcall,vminpd,vminps,vminsd,vminss,vmload,vmovsd,vmovss,\
vmread,vmsave,vmulpd,vmulps,vmulsd,vmulss,vmxoff,vpabsb,\
vpabsd,vpabsw,vpaddb,vpaddd,vpaddq,vpaddw,vpandn,vpavgb,\
vpavgw,vpcmov,vpcomb,vpcomd,vpcomq,vpcomw,vpermd,vpermq,\
vpperm,vprotb,vprotd,vprotq,vprotw,vpshab,vpshad,vpshaq,\
vpshaw,vpshlb,vpshld,vpshlq,vpshlw,vpslld,vpsllq,vpsllw,\
vpsrad,vpsraw,vpsrld,vpsrlq,vpsrlw,vpsubb,vpsubd,vpsubq,\
vpsubw,vptest,vrcpps,vrcpss,vsubpd,vsubps,vsubsd,vsubss,\
vxorpd,vxorps,wbinvd,wrmsrq,xabort,xbegin,xgetbv,xrstor,\
xsetbv,blcfill,blendpd,blendps,blsfill,clflush,cmovnae,cmovnbe,\
cmovnge,cmovnle,cmpeqpd,cmpeqps,cmpeqsd,cmpeqss,cmplepd,cmpleps,\
cmplesd,cmpless,cmpltpd,cmpltps,cmpltsd,cmpltss,cmpxchg,fcmovbe,\
fcmovnb,fcmovne,fcmovnu,fdecstp,fincstp,fldenvd,fldenvw,fnsaved,\
fnsavew,fnstenv,frndint,frstord,frstorw,fsincos,fstenvd,fstenvw,\
fucomip,fucompp,fxrstor,fxtract,fyl2xp1,insertq,invlpga,invpcid,\
invvpid,ldmxcsr,loopned,loopneq,loopnew,loopnzd,loopnzq,loopnzw,\
monitor,movddup,movdq2q,movhlps,movlhps,movntdq,movntpd,movntps,\
movntsd,movntss,movq2dq,mpsadbw,paddusb,paddusw,palignr,pavgusb,\
pblendw,pcmpeqb,pcmpeqd,pcmpeqq,pcmpeqw,pcmpgtb,pcmpgtd,pcmpgtq,\
pcmpgtw,pfcmpeq,pfcmpge,pfcmpgt,pfpnacc,pfrsqrt,phaddsw,phsubsw,\
pmaddwd,pmulhrw,pmulhuw,pmuludq,pshufhw,pshuflw,psubusb,psubusw,\
roundpd,roundps,roundsd,roundss,rsqrtps,rsqrtss,stmxcsr,syscall,\
sysexit,sysretq,ucomisd,ucomiss,vaesdec,vaesenc,vaesimc,vandnpd,\
vandnps,vcomisd,vcomiss,vfrczpd,vfrczps,vfrczsd,vfrczss,vhaddpd,\
vhaddps,vhsubpd,vhsubps,vmclear,vmmcall,vmovapd,vmovaps,vmovdqa,\
vmovdqu,vmovhpd,vmovhps,vmovlpd,vmovlps,vmovupd,vmovups,vmptrld,\
vmptrst,vmwrite,vpaddsb,vpaddsw,vpcomub,vpcomud,vpcomuq,vpcomuw,\
vpermpd,vpermps,vpextrb,vpextrd,vpextrq,vpextrw,vphaddd,vphaddw,\
vphsubd,vphsubw,vpinsrb,vpinsrd,vpinsrq,vpinsrw,vpmaxsb,vpmaxsd,\
vpmaxsw,vpmaxub,vpmaxud,vpmaxuw,vpminsb,vpminsd,vpminsw,vpminub,\
vpminud,vpminuw,vpmuldq,vpmulhw,vpmulld,vpmullw,vpsadbw,vpshufb,\
vpshufd,vpsignb,vpsignd,vpsignw,vpslldq,vpsllvd,vpsllvq,vpsravd,\
vpsrldq,vpsrlvd,vpsrlvq,vpsubsb,vpsubsw,vshufpd,vshufps,vsqrtpd,\
vsqrtps,vsqrtsd,vsqrtss,vtestpd,vtestps,xsave64,addsubpd,addsubps,\
blendvpd,blendvps,cmpneqpd,cmpneqps,cmpneqsd,cmpneqss,cmpnlepd,cmpnleps,\
cmpnlesd,cmpnless,cmpnltpd,cmpnltps,cmpnltsd,cmpnltss,cmpordpd,cmpordps,\
cmpordsd,cmpordss,cvtdq2pd,cvtdq2ps,cvtpd2dq,cvtpd2pi,cvtpd2ps,cvtpi2pd,\
cvtpi2ps,cvtps2dq,cvtps2pd,cvtps2pi,cvtsd2si,cvtsd2ss,cvtsi2sd,cvtsi2ss,\
cvtss2sd,cvtss2si,fcmovnbe,fnstenvd,fnstenvw,fxsave64,insertps,maskmovq,\
movmskpd,movmskps,movntdqa,movshdup,movsldup,packssdw,packsswb,packusdw,\
packuswb,pblendvb,pfrcpit1,pfrcpit2,pfrsqit1,pmovmskb,pmovsxbd,pmovsxbq,\
pmovsxbw,pmovsxdq,pmovsxwd,pmovsxwq,pmovzxbd,pmovzxbq,pmovzxbw,pmovzxdq,\
pmovzxwd,pmovzxwq,pmulhrsw,prefetch,rdfsbase,rdgsbase,sysenter,sysexitq,\
unpckhpd,unpckhps,unpcklpd,unpcklps,vblendpd,vblendps,vcmpeqpd,vcmpeqps,\
vcmpeqsd,vcmpeqss,vcmpgepd,vcmpgeps,vcmpgesd,vcmpgess,vcmpgtpd,vcmpgtps,\
vcmpgtsd,vcmpgtss,vcmplepd,vcmpleps,vcmplesd,vcmpless,vcmpltpd,vcmpltps,\
vcmpltsd,vcmpltss,vfmaddpd,vfmaddps,vfmaddsd,vfmaddss,vfmsubpd,vfmsubps,\
vfmsubsd,vfmsubss,vldmxcsr,vmlaunch,vmovddup,vmovhlps,vmovlhps,vmovntdq,\
vmovntpd,vmovntps,vmpsadbw,vmresume,vpaddusb,vpaddusw,vpalignr,vpblendd,\
vpblendw,vpcmpeqb,vpcmpeqd,vpcmpeqq,vpcmpeqw,vpcmpgtb,vpcmpgtd,vpcmpgtq,\
vpcmpgtw,vpcomeqb,vpcomeqd,vpcomeqq,vpcomeqw,vpcomgeb,vpcomged,vpcomgeq,\
vpcomgew,vpcomgtb,vpcomgtd,vpcomgtq,vpcomgtw,vpcomleb,vpcomled,vpcomleq,\
vpcomlew,vpcomltb,vpcomltd,vpcomltq,vpcomltw,vphaddbd,vphaddbq,vphaddbw,\
vphadddq,vphaddsw,vphaddwd,vphaddwq,vphsubbw,vphsubdq,vphsubsw,vphsubwd,\
vpmacsdd,vpmacswd,vpmacsww,vpmaddwd,vpmulhuw,vpmuludq,vpshufhw,vpshuflw,\
vpsubusb,vpsubusw,vroundpd,vroundps,vroundsd,vroundss,vrsqrtps,vrsqrtss,\
vstmxcsr,vucomisd,vucomiss,vzeroall,wrfsbase,wrgsbase,xacquire,xrelease,\
xrstor64,xsaveopt,cmpxchg8b,cvttpd2dq,cvttpd2pi,cvttps2dq,cvttps2pi,cvttsd2si,\
cvttss2si,extractps,fxrstor64,pclmulqdq,pcmpestri,pcmpestrm,pcmpistri,pcmpistrm,\
pmaddubsw,prefetchw,punpckhbw,punpckhdq,punpckhwd,punpcklbw,punpckldq,punpcklwd,\
vaddsubpd,vaddsubps,vblendvpd,vblendvps,vcmpneqpd,vcmpneqps,vcmpneqsd,vcmpneqss,\
vcmpngepd,vcmpngeps,vcmpngesd,vcmpngess,vcmpngtpd,vcmpngtps,vcmpngtsd,vcmpngtss,\
vcmpnlepd,vcmpnleps,vcmpnlesd,vcmpnless,vcmpnltpd,vcmpnltps,vcmpnltsd,vcmpnltss,\
vcmpordpd,vcmpordps,vcmpordsd,vcmpordss,vcvtdq2pd,vcvtdq2ps,vcvtpd2dq,vcvtpd2ps,\
vcvtph2ps,vcvtps2dq,vcvtps2pd,vcvtps2ph,vcvtsd2si,vcvtsd2ss,vcvtsi2sd,vcvtsi2ss,\
vcvtss2sd,vcvtss2si,vfnmaddpd,vfnmaddps,vfnmaddsd,vfnmaddss,vfnmsubpd,vfnmsubps,\
vfnmsubsd,vfnmsubss,vinsertps,vmovmskpd,vmovmskps,vmovntdqa,vmovshdup,vmovsldup,\
vpackssdw,vpacksswb,vpackusdw,vpackuswb,vpblendvb,vpcomequb,vpcomequd,vpcomequq,\
vpcomequw,vpcomgeub,vpcomgeud,vpcomgeuq,vpcomgeuw,vpcomgtub,vpcomgtud,vpcomgtuq,\
vpcomgtuw,vpcomleub,vpcomleud,vpcomleuq,vpcomleuw,vpcomltub,vpcomltud,vpcomltuq,\
vpcomltuw,vpcomneqb,vpcomneqd,vpcomneqq,vpcomneqw,vpermilpd,vpermilps,vphaddubd,\
vphaddubq,vphaddubw,vphaddudq,vphadduwd,vphadduwq,vpmacsdqh,vpmacsdql,vpmacssdd,\
vpmacsswd,vpmacssww,vpmadcswd,vpmovmskb,vpmovsxbd,vpmovsxbq,vpmovsxbw,vpmovsxdq,\
vpmovsxwd,vpmovsxwq,vpmovzxbd,vpmovzxbq,vpmovzxbw,vpmovzxdq,vpmovzxwd,vpmovzxwq,\
vpmulhrsw,vunpckhpd,vunpckhps,vunpcklpd,vunpcklps,aesdeclast,aesenclast,cmpunordpd,\
cmpunordps,cmpunordsd,cmpunordss,cmpxchg16b,loadall286,loadall386,maskmovdqu,phminposuw,\
prefetcht0,prefetcht1,prefetcht2,punpckhqdq,punpcklqdq,vcmptruepd,vcmptrueps,vcmptruesd,\
vcmptruess,vcvttpd2dq,vcvttps2dq,vcvttsd2si,vcvttss2si,vextractps,vgatherdpd,vgatherdps,\
vgatherqpd,vgatherqps,vmaskmovpd,vmaskmovps,vpclmulqdq,vpcmpestri,vpcmpestrm,vpcmpistri,\
vpcmpistrm,vpcomnequb,vpcomnequd,vpcomnequq,vpcomnequw,vpcomtrueb,vpcomtrued,vpcomtrueq,\
vpcomtruew,vperm2f128,vperm2i128,vpermil2pd,vpermil2ps,vpgatherdd,vpgatherdq,vpgatherqd,\
vpgatherqq,vpmacssdqh,vpmacssdql,vpmadcsswd,vpmaddubsw,vpmaskmovd,vpmaskmovq,vpunpckhbw,\
vpunpckhdq,vpunpckhwd,vpunpcklbw,vpunpckldq,vpunpcklwd,vzeroupper,xsaveopt64,pclmulhqhdq,\
pclmullqhdq,prefetchnta,vaesdeclast,vaesenclast,vcmpeq_ospd,vcmpeq_osps,vcmpeq_ossd,vcmpeq_osss,\
vcmpeq_uqpd,vcmpeq_uqps,vcmpeq_uqsd,vcmpeq_uqss,vcmpeq_uspd,vcmpeq_usps,vcmpeq_ussd,vcmpeq_usss,\
vcmpfalsepd,vcmpfalseps,vcmpfalsesd,vcmpfalsess,vcmpge_oqpd,vcmpge_oqps,vcmpge_oqsd,vcmpge_oqss,\
vcmpgt_oqpd,vcmpgt_oqps,vcmpgt_oqsd,vcmpgt_oqss,vcmple_oqpd,vcmple_oqps,vcmple_oqsd,vcmple_oqss,\
vcmplt_oqpd,vcmplt_oqps,vcmplt_oqsd,vcmplt_oqss,vcmpord_spd,vcmpord_sps,vcmpord_ssd,vcmpord_sss,\
vcmpunordpd,vcmpunordps,vcmpunordsd,vcmpunordss,vfmadd132pd,vfmadd132ps,vfmadd132sd,vfmadd132ss,\
vfmadd213pd,vfmadd213ps,vfmadd213sd,vfmadd213ss,vfmadd231pd,vfmadd231ps,vfmadd231sd,vfmadd231ss,\
vfmaddsubpd,vfmaddsubps,vfmsub132pd,vfmsub132ps,vfmsub132sd,vfmsub132ss,vfmsub213pd,vfmsub213ps,\
vfmsub213sd,vfmsub213ss,vfmsub231pd,vfmsub231ps,vfmsub231sd,vfmsub231ss,vfmsubaddpd,vfmsubaddps,\
vinsertf128,vinserti128,vmaskmovdqu,vpcomfalseb,vpcomfalsed,vpcomfalseq,vpcomfalsew,vpcomtrueub,\
vpcomtrueud,vpcomtrueuq,vpcomtrueuw,vphminposuw,vpunpckhqdq,vpunpcklqdq,pclmulhqhqdq,pclmulhqlqdq,\
pclmullqhqdq,pclmullqlqdq,vbroadcastsd,vbroadcastss,vcmpneq_oqpd,vcmpneq_oqps,vcmpneq_oqsd,vcmpneq_oqss,\
vcmpneq_ospd,vcmpneq_osps,vcmpneq_ossd,vcmpneq_osss,vcmpneq_uspd,vcmpneq_usps,vcmpneq_ussd,vcmpneq_usss,\
vcmpnge_uqpd,vcmpnge_uqps,vcmpnge_uqsd,vcmpnge_uqss,vcmpngt_uqpd,vcmpngt_uqps,vcmpngt_uqsd,vcmpngt_uqss,\
vcmpnle_uqpd,vcmpnle_uqps,vcmpnle_uqsd,vcmpnle_uqss,vcmpnlt_uqpd,vcmpnlt_uqps,vcmpnlt_uqsd,vcmpnlt_uqss,\
vextractf128,vextracti128,vfnmadd132pd,vfnmadd132ps,vfnmadd132sd,vfnmadd132ss,vfnmadd213pd,vfnmadd213ps,\
vfnmadd213sd,vfnmadd213ss,vfnmadd231pd,vfnmadd231ps,vfnmadd231sd,vfnmadd231ss,vfnmsub132pd,vfnmsub132ps,\
vfnmsub132sd,vfnmsub132ss,vfnmsub213pd,vfnmsub213ps,vfnmsub213sd,vfnmsub213ss,vfnmsub231pd,vfnmsub231ps,\
vfnmsub231sd,vfnmsub231ss,vpbroadcastb,vpbroadcastd,vpbroadcastq,vpbroadcastw,vpclmulhqhdq,vpclmullqhdq,\
vpcomfalseub,vpcomfalseud,vpcomfalseuq,vpcomfalseuw,vpermilmo2pd,vpermilmo2ps,vpermilmz2pd,vpermilmz2ps,\
vpermiltd2pd,vpermiltd2ps,vcmptrue_uspd,vcmptrue_usps,vcmptrue_ussd,vcmptrue_usss,vcmpunord_spd,vcmpunord_sps,\
vcmpunord_ssd,vcmpunord_sss,vpclmulhqlqdq,vpclmullqlqdq,vbroadcastf128,vbroadcasti128,vcmpfalse_ospd,vcmpfalse_osps,\
vcmpfalse_ossd,vcmpfalse_osss,vfmaddsub132pd,vfmaddsub132ps,vfmaddsub213pd,vfmaddsub213ps,vfmaddsub231pd,vfmaddsub231ps,\
vfmsubadd132pd,vfmsubadd132ps,vfmsubadd213pd,vfmsubadd213ps,vfmsubadd231pd,vfmsubadd231ps,aeskeygenassist,vaeskeygenassist

match ,
{
    local iset_s, totalSize_s, maxSize_s, maxSizeVar_s
    macro ilen_ [iset]
    \{
        \common \local totalSize, maxSize, maxSizeVar, inmacro, omit
        define totalSize_s totalSize
        define maxSize_s maxSize
        define maxSizeVar_s maxSizeVar
        iset_s equ iset
        
        totalSize = 0
        maxSizeVar = 0
        match \\iset,iset \\{ irp i,\\iset
        \\\{
            macro i [args]
            \\\\{
                \\\\common \\\\local iAddr, iSize, buf
                    inmacro = 1
                    iAddr = $
                    i args
                    match =omit,omit
                    \\\\\{
                        if inmacro ;inmacro might have become 0
                            iSize = $-iAddr
                            totalSize = totalSize+iSize
                            if iSize > maxSizeVar
                                maxSizeVar = iSize
                            end if
                            
                            if iAddr relativeto 0
                                dispHex iAddr,,'0x'
                            else
                                dispHex rva iAddr,,'0x'
                            end if
                            display ': '
                            times ((iSize/10)-1)shr 63 display ' '
                            dispDec iSize
                            display ' | '
                            repeat iSize
                                load buf byte from iAddr+(%-1)
                                dispHex buf,2,,' '
                            end repeat
                            times maxSize-iSize display '   '
                            display '| ',\\\\\`i
                            
                            define _token +
                            irps arg,args
                            \\\\\\{
                                \\\\\\common display ' '
                                \\\\\\forward
                                    match \\\\\\`arg,arg \\\\\\\{ rept 0 { \\\\\\\}
                                    match l \\\\\\`arg t,'' '+' '-' '*' '/' '=' '(' ')' '[' ']' '{' '}' ':' ',' '|' '&' '~' ''
                                    \\\\\\\{
                                        define token +
                                        rept 0 {
                                    \\\\\\\}
                                    define token -
                                    match -,_token \\\\\\\{ display ' ' \\\\\\\}
                                    restore _token
                                    _token equ token
                                    restore token
                                    match \\\\\\`arg,arg \\\\\\\{ display "'" \\\\\\\}
                                    display \\\\\\`arg
                                    match \\\\\\`arg,arg \\\\\\\{ display "'" \\\\\\\}
                            \\\\\\}
                            restore _token
                            display 13,10
                        end if
                    \\\\\}
                    inmacro = 0
            \\\\}
        \\\} \\}
        macro virtual [arg]
        \\{
            \\common virtual arg
            define omit +
        \\}
        struc virtual [arg]
        \\{
            \\common . virtual arg
            match =end,. \\\{ restore omit \\\}
        \\}
        macro ilen_ [arg]
        \\{
            \\common
                display 'Error: _ilen missing',13,10
                err
        \\}
    \}
    macro _ilen
    \{
        match iset,iset_s \\{ purge iset \\}
        purge virtual, ilen_
        restruc virtual

        match =totalSize_s,totalSize_s
        \\{
            display "Error: ilen_ missing",13,10
            err
        \\}
        maxSize_s = maxSizeVar_s
        xdisplay 'Total size of the shown instructions: ',d=totalSize_s,13,10
        restore iset_s, totalSize_s, maxSize_s
    \}
}    

_________________
Faith is a superposition of knowledge and fallacy
Post 13 Nov 2014, 20:30
View user's profile Send private message Reply with quote
madmatt



Joined: 07 Oct 2003
Posts: 1046
Location: Michigan, USA
madmatt
revolution wrote:
BTW: the Intel manual has this to say:
Quote:
RIP-relative addressing is enabled by 64-bit mode, not by a 64-bit address-size. The use of the address-size prefix does not disable RIP-relative addressing. The effect of the address-size prefix is to truncate and zero-extend the computed effective address to 32 bits.


So, If I understand. When in 64bit mode, the esp register automatically gets extended to a 64bit address internally? Bescause it compiled and ran fine. This could lead to problems if your accessing over 4gb. Fasmw should still produce a warning to the user.

_________________
Gimme a sledge hammer! I'LL FIX IT!
Post 14 Nov 2014, 18:49
View user's profile Send private message Reply with quote
l_inc



Joined: 23 Oct 2009
Posts: 881
l_inc
madmatt
Quote:
the esp register automatically gets extended to a 64bit address internally?

Not the esp, but the resulting address. esp in an addressing expression is just an indication for fasm, that it needs to put the 0x67 prefix, as I've shown above.
Quote:
This could lead to problems if your accessing over 4gb

Sure. Shooting yourself into your foot could lead to problems as well.
Quote:
Fasmw should still produce a warning to the user.

Why that? If you explicitly state, you wanna have the 32 bit truncation, what warnings do you expect? Typing a minus instead of a plus also might lead to problems, so do you want fasm to warn you, that you typed a plus?

_________________
Faith is a superposition of knowledge and fallacy
Post 14 Nov 2014, 21:03
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 16850
Location: In your JS exploiting you and your system
revolution
l_inc wrote:
Shooting yourself into your foot could lead to problems as well.
I totally agree. Feet should come with the warning: "Do not shoot".
Post 15 Nov 2014, 10:47
View user's profile Send private message Visit poster's website 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-2019, Tomasz Grysztar.

Powered by rwasa.