News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

mailto x64

Started by Biterider, March 12, 2018, 05:53:18 AM

Previous topic - Next topic

Biterider

Hello everybody
I can confirm that removing the "/LARGEADDRESSAWARE:NO" switch, the problem is gone.
Why it is so, is a matter of discussion.

Thanks for your support!  :t

Biterider

aw27

It works in VS C with some magic done by mainCRTStartup. If we bypass the default mainCRTStartup it is broken as well.


#include <windows.h>
#include <shellapi.h>
#include <ole2.h>

#define __NORMAL

#ifdef __NORMAL // Works
int main()
#else
int mainCRTStartup() // Broken
#endif
{
CoInitializeEx(NULL, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE);
ShellExecute(NULL, "open", "mailto:pepe@hotmail.com", NULL, NULL, SW_SHOWDEFAULT);
    return 0;
}

six_L

it works ok.
.xmm
option casemap:none
option dotname
option win64:11
option stackbase:rsp

POINTER typedef ptr

include \UASM64\include\windows.inc
include \UASM64\include\ole2.inc
;include \UASM64\include\shellapi.inc

includelib \UASM64\Lib\kernel32.lib
includelib \UASM64\Lib\user32.lib
;includelib \UASM64\Lib\Shell32.lib
includelib \UASM64\Lib\ole32.lib

_ShellExecuteEx typedef proto pExecInfo:QWORD
PShellExecuteEx typedef ptr _ShellExecuteEx

.const
Verb db "open",0
File db "mailto:pepe@hotmail.com",0

.data?
@ShellExecuteEx PShellExecuteEx ?
hShell32_dll dq ?
pExecInfo SHELLEXECUTEINFO <?>

.code

WinMainCRTStartup proc

invoke LoadLibrary,CStr("Shell32.dll")
.if rax
mov hShell32_dll,rax
invoke GetProcAddress,hShell32_dll,CStr("ShellExecuteEx")
.if rax!=0
mov @ShellExecuteEx,rax
.else
invoke MessageBox,NULL,CStr("ShellExecuteEx get Failed"),CStr("GetProcAddress"),MB_OK
JMP @exit
.endif
.else
invoke MessageBox,NULL,CStr("shell32.dll load Failed"),CStr("LoadLibrary"),MB_OK
JMP @exit
.endif

invoke CoInitializeEx, NULL, COINIT_APARTMENTTHREADED or COINIT_DISABLE_OLE1DDE

invoke RtlZeroMemory,offset pExecInfo,SIZEOF pExecInfo
mov pExecInfo.cbSize,SIZEOF pExecInfo
lea rax,Verb
mov pExecInfo.lpVerb,rax
lea rax,File
mov pExecInfo.lpFile,rax
mov pExecInfo.nShow,SW_SHOWDEFAULT

invoke @ShellExecuteEx, offset pExecInfo
@exit:
invoke FreeLibrary,hShell32_dll
invoke ExitProcess,NULL
ret
WinMainCRTStartup endp   


end WinMainCRTStartup

Quote\UASM64\bin\uasm64 -c -win64 -Zp8 shelltest.asm
    \UASM64\bin\Link /ENTRY:WinMainCRTStartup /SUBSYSTEM:windows %name%.obj
the Attachment is exe.
Say you, Say me, Say the codes together for ever.

aw27

Quote
\UASM64\bin\Link /ENTRY:WinMainCRTStartup /SUBSYSTEM:windows %name%.obj

Now,  add /LARGEADDRESSAWARE:NO to the link command line.

You forgot to read from the beginning.  :biggrin:

six_L

Quoteadd /LARGEADDRESSAWARE:NO to the link command line.
the error is being happened.
QuoteVirtual Address Space
By default, 64-bit Microsoft Windows-based applications have a user-mode address space of several terabytes. For precise values, see Memory Limits for Windows and Windows Server Releases. However, applications can specify that the system should allocate all memory for the application below 2 gigabytes. This feature is beneficial for 64-bit applications if the following conditions are true:

A 2 GB address space is sufficient.
The code has many pointer truncation warnings.
Pointers and integers are freely mixed.
The code has polymorphism using 32-bit data types.
All pointers are still 64-bit pointers, but the system ensures that every memory allocation occurs below the 2 GB limit, so that if the application truncates a pointer, no significant data is lost. Pointers can be truncated to 32-bit values, then extended to 64-bit values by either sign extension or zero extension.

To specify this memory limitation, use the /LARGEADDRESSAWARE:NO linker option. Note that /LARGEADDRESSAWARE:NO is ignored for an ARM64 binary. However, be aware that problems can occur when using this option. If you build a DLL that uses this option and the DLL is called by an application that does not use this option, the DLL could truncate a 64-bit pointer whose upper 32 bits are significant. This can cause application failure without any warning.

Say you, Say me, Say the codes together for ever.

aw27

As I mentioned, it works from C with the proper runtime initialization.
Although the source code for the runtime is available with all VC distributions it is rather complicated and I can not spend time looking for the magic it does, but would love to know it.