Recent Posts

Pages: [1] 2 3 ... 10
1
UASM Assembler Development / Re: HFILE
« Last post by jj2007 on Today at 08:25:59 AM »
File handles in Win64 are 64 bit. Either,

hFile dq ?  ; .DATA section
or
LOCAL hFile :QWORD


With the exception of the handle returned by OpenFile. Test it yourself...

include \Masm32\MasmBasic\Res\JBasic.inc
.data?
ofs OFSTRUCT <>
Init   ; OPT_64 1              ; put 0 for 32 bit, 1 for 64 bit assembly
  PrintLine Chr$("This code was assembled with ", @AsmUsed$(1), " in ", jbit$, "-bit format")
  ; int 3
  usedeb=1
  jinvoke OpenFile, Chr$("\Masm32\qEditor.exe"), addr ofs, OF_READ
  ; towards the end of OpenFile:
  ; 00000000779E0953   | 8B C7              | mov eax, edi
  mov rsi, offset ofs.szPathName
  deb 4, "Handle", rax, $Err$(), $rsi
  jinvoke CloseHandle, rax
  Inkey "hit any key"
EndOfCode


Output:
Code: [Select]
This code was assembled with ml64 in 64-bit format
Handle
rax     60
$Err$()
Operazione completata.

$rsi    C:\Masm32\qEditor.exe
hit any key
2
UASM Assembler Development / Re: HFILE
« Last post by hutch-- on Today at 08:02:47 AM »
File handles in Win64 are 64 bit. Either,

hFile dq ?  ; .DATA section
or
LOCAL hFile :QWORD
3
UASM Assembler Development / Re: HFILE
« Last post by jj2007 on Today at 07:55:47 AM »
Right. I stumbled over this some time ago, it is indeed very odd:
HFILE
Quote
A handle to a file opened by OpenFile, not CreateFile.
This type is declared in WinDef.h as follows:
typedef int HFILE;

Note the "OpenFile, not CreateFile". It seems a legacy thing...
HFILE WINAPI OpenFile(
HANDLE WINAPI CreateFile(

The VS header files obscure it, as usual, maybe these are the original definitions:
C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Include\WTypes.h
typedef INT HFILE;

C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Include\WinNT.h
typedef PVOID HANDLE;

But there is also this definition in WinDef.h:
#ifndef _MAC
typedef int HFILE;
typedef HICON HCURSOR;      /* HICONs & HCURSORs are polymorphic */
#else
typedef short HFILE;
DECLARE_HANDLE(HCURSOR);    /* HICONs & HCURSORs are not polymorphic */
#endif

So if you are on a Mac, it's a short :biggrin:
4
UASM Assembler Development / VARARG
« Last post by Biterider on Today at 07:10:26 AM »

Hello
Today I needed to use the VARARG proc feature. I noticed that the VARARG arguments default to DWORD instead of QWORD.
Type casting the arguments solves the problem, but in my opinion, the default should be QWORD.


The dissassembly shows what I mean:
Code: [Select]
start:
 sub         rsp,38h 
 mov         dword ptr [rsp+20h],89ABCDEFh 
 mov         r9d,89ABCDEFh 
 mov         r8d,89ABCDEFh 
 mov         rdx,0B23456789ABCDEFh 
 mov         rcx,0A23456789ABCDEFh 
 call        TestProc (0331000h) 
 mov         qword ptr [rsp+20h],rdx 
 mov         r9,rcx 
 mov         r8,rbx 
 mov         rdx,rax 
 mov         rcx,0A23456789ABCDEFh 
 call        TestProc (0331000h) 
 add         rsp,38h 
 ret 
Source
Code: [Select]
.xmm
option casemap:none
option dotname
option frame:auto
option win64:8
option stackbase:rsp


.code


TestProc proc Arg1:QWORD, Arg2:VARARG
    mov r8, Arg1
    mov r9, Arg2
    ret
TestProc endp




start proc
    invoke TestProc, 0123456789ABCDEFh, QWORD ptr 0123456789ABCDEFh, 0123456789ABCDEFh, 0123456789ABCDEFh, 0123456789ABCDEFh
    invoke TestProc, 0A23456789ABCDEFh, rax, rbx, rcx, rdx
    ret
start endp


end start


Regards, Biterider
5
UASM Assembler Development / Re: HFILE
« Last post by Vortex on Today at 04:52:07 AM »
Hi Biterider,

Reading windef.h supplied with Pelles C :

Code: [Select]
typedef int HFILE;
sizeof(int)=4

Testing this Pelles C code ( 64-bit project ) :

Code: [Select]
#include <stdio.h>
#include <windows.h>

int main()
{
printf("sizeof(HFILE)=%llu",sizeof(HFILE));
return 0;
}

Output :
Code: [Select]
sizeof(HFILE)=4
6
UASM Assembler Development / HFILE
« Last post by Biterider on Today at 04:34:17 AM »
Hi
Moving some part of my old code to x64 I stumbled over the HFILE definition in WinBase.inc


Code: [Select]
_HFILE_DEFINED EQU <>
HFILE  typedef DWORD
endif


Shouldn't it be a HANDLE = 64 bit?


Regards, Biterider
7
The Workshop / Re: Creativity question.
« Last post by HSE on Today at 02:42:01 AM »
Hi Hutch!
You can try the SSE backend of SmplMath. In some test with 32bit the calculations take only 75% of FPU backend time, because just a portion of the program is using SmplMath.
8
The Workshop / Re: Creativity question.
« Last post by aw27 on Today at 02:11:28 AM »
Welcome JJ!  :t
This is part of my DMath library which has more than 600 functions and is mostly a ASM translation of the DirectXMath. I can make available the source of a few functions that have some correspondence in the FP unit. But you can always see how it works looking at the Microsoft C++ open source code.  :icon_rolleyes:

@Siekmanski
All right, I will PM you tomorrow.
9
The Workshop / Re: Creativity question.
« Last post by jj2007 on Today at 01:50:18 AM »
As an example, the MASM equivalent of the DirectX XMScalarCos (64-bit).

When I post examples or code it is always complete and ready to be built
::)
10
The Workshop / Re: Creativity question.
« Last post by Siekmanski on Today at 01:05:48 AM »
Hi aw27,
I'm interested.  :t
Pages: [1] 2 3 ... 10