After screwing around for several days trying to figure out how to set up my system to produce 64-bit programs using uasm and wininc, it occurred to me that maybe I didn't have to keep both 32 and 64 bit working. Before jumping to conclusions based upon nebulous trial and error I thought I'd just ask.
(Assuming I'm working on a computer with 64-bit windows running,) If one uses uasm64, can it also produce 32bit programs, or do I also need to keep uasm32 for 32-bit only programs? If 64 will produce 32bit programs, are there any special s-field options that need to be different? (Currently I normally use /nologo /c /coff /Cp /Fl /Sn /Sg)
Also, it this the place to ask such questions, or would the uasm people prefer it be in the generic "64 bit assembler" subforum?
\masm32\bin\UAsm64 -Zp8 -win64 somesource.asm should do the job. Probably the -Zp8 is no longer needed, but let's hear the experts on that ;)
And yes, on a 64-bit machine you need only UAsm64. It can generate 32-bit code.
uasm32 and uasm64 can both produce 32bit or 64bit output formats. The only reason both exist is so that you can run it at all on a 32bit system. Additionally uasm32 is built with XP compatibility toolset. :)
What does this flag mean in uasm -Fs[=<file_name>] - Write symbolic debug info? How can it be used?
It writes out the debugging symbols into a simple format that easy for you to view or use in other debugging applications. It was added mainly as a way to provide symbolic debugging when generating flat binary files. IE: for OS development etc. It's documented in the user guide.
How can I use Windows COM objects (such as IFileOperation)?
Do you have any sample in uasm?
Quote from: morgot on March 29, 2019, 06:17:02 AM
How can I use Windows COM objects (such as IFileOperation)?
Do you have any sample in uasm?
A quick COM example :
http://masm32.com/board/index.php?topic=6736.msg72337#msg72337
http://masm32.com/board/index.php?topic=6861.msg73732#msg73732
Quote from: Vortex on March 29, 2019, 06:30:30 AM
A quick COM example :
OK, but where I can get value for CLSID_FileOperation ?
In you source are
sCLSID_IActiveDesktop TEXTEQU <{075048700h,0EF1Fh,011D0h,{098h,088h,00h,060h,097h,0DEh,0ACh,0F9h}}>
sIID_IActiveDesktop TEXTEQU <{0F490EB00h,01240h,011D1h,{098h,088h,00h,060h,097h,0DEh,0ACh,0F9h}}>
where same values for another COM ?
Quote from: morgot on April 03, 2019, 11:56:43 PMOK, but where I can get value for CLSID_FileOperation ?
CLSID_FileOperation GuidFromString (http://www.webalice.it/jj2006/MasmBasicQuickReference.htm#Mb1136)("3ad05575-8857-4850-9277-11b85bdb8e09")
(and Google is your friend)
Thank you jj2007!
COM is very hard technology.
Hi morgot,
You can check the file shlguid.inc coming with the asmc package :
https://github.com/nidud/asmc
Reading shlguid.inc :
DEFINE_GUID( CLSID_ActiveDesktop, 0x75048700, 0xEF1F, 0x11D0, 0x98, 0x88, 0x00, 0x60, 0x97, 0xDE, 0xAC, 0xF9);
DEFINE_GUID(IID_IActiveDesktop, 0xF490EB00, 0x1240, 0x11D1, 0x98, 0x88, 0x00, 0x60, 0x97, 0xDE, 0xAC, 0xF9);
deleted
Quote from: morgot on April 04, 2019, 12:22:00 AMCOM is very hard technology.
The learning curve is a bit steep, right. However, the main problem is that there are so many functions available, and there is no central documentation where to find all those cryptic CLSID and IID values. Even the Visual Studio include files don't have CLSID_ActiveDesktop, for example. Once you have those for your project, it can be quite straightforward:
include \masm32\MasmBasic\MasmBasic.inc
Init ; ## COM demo: open Internet Explorer ##
invoke OleInitialize, NULL
.if eax==S_OK
push Chr$("http://masm32.com/board/index.php?action=unread")
call MyBrowser
.endif
invoke OleUninitialize
Exit
CLSID_IExplorer GuidFromString("0002DF01-0000-0000-C000-000000000046") ; either use quoted text syntax or...
IID_IWebBrowser2 GuidFromString({D30C1661-CDAF-11D0-8A3E-00C04FC9E26E}) ; ... paste copied registry key name
MyBrowser proc uses edi url
LOCAL vEmpty:VARIANT, hWin, WebInterface
ClearLocals
lea edi, WebInterface
pInterface equ dword ptr [edi]
invoke CoCreateInstance, addr CLSID_IExplorer, NULL, CLSCTX_LOCAL_SERVER, addr IID_IWebBrowser2, edi
.if eax==S_OK
CoInvoke pInterface, IWebBrowserVtbl.put_StatusBar, VARIANT_FALSE ; OK, now configure the browser
CoInvoke pInterface, IWebBrowserVtbl.put_MenuBar, VARIANT_FALSE ; false = no menu
CoInvoke pInterface, IWebBrowserVtbl.put_Visible, VARIANT_TRUE
CoInvoke pInterface, IWebBrowserVtbl.get_HWND, addr hWin
lea edx, vEmpty ; Navigate needs pointers to four empty VARIANTS
; Ole$(url): COM wants a BSTR, so the ANSI URL needs to be converted
CoInvoke pInterface, IWebBrowserVtbl.Navigate, Ole$(url), edx, edx, edx, edx
.endif
ret
MyBrowser endp
end start
Time to do something about that, for example static GUID/IIDs ?
We can always create a program to convert or lookup GUID/IID from uuid.lib.
My example in so hated C in this site ;)
One problem is that '_' before name in 32-bit files.
CLSIDConv.ini in user's Documents folder:
[Lib]
LIB=C:\code\WDDK710\lib
EDIT: example removed, as it had an errors.
[Lib]
LIB=C:\code\WDDK710\lib\
[Libs]
LIB_0=uuid.lib
LIB_1=dxguid.lib
LIB_2=windowscodecs.lib
a4
[Lib]
LIB=C:\code\WDDK710\lib\
[Libs]
LIB_0=uuid.lib
LIB_1=dxguid.lib
LIB_2=windowscodecs.lib
[Lib1]
LIB=C:\code\PellesC\lib
[Libs1]
LIB_0=reguids.lib
Hi TimoVJL
Quote
"My example in so hated C in this site"
In martial arts there is a legend about a root style that is perfection. It is known as
The Sun Source (Assembly) and that all other martial art styles are derived from it (C,C++,etc).
Thus they are not perfection.
I do not hate C. It is much cleaner than all the others as well as been elegant.
Quote from: TimoVJL on April 07, 2019, 06:38:50 AM
We can always create a program to convert or lookup GUID/IID from uuid.lib.
It can also look in
dxguid.lib
d2d1.lib
d3d11.lib
dxgi.lib
ole32.lib
windowscodecs.lib
dwrite.lib
if no success make a Google search.
And if does not find report "Sorry, I could not find"
Quote from: AW on April 07, 2019, 03:43:52 PM
Quote from: TimoVJL on April 07, 2019, 06:38:50 AM
We can always create a program to convert or lookup GUID/IID from uuid.lib.
It can also look in
dxguid.lib
d2d1.lib
d3d11.lib
dxgi.lib
ole32.lib
windowscodecs.lib
dwrite.lib
if no success make a Google search.
And if does not find report "Sorry, I could not find"
Just use https://www.magnumdb.com/
Great link, Sinsi :t
ITextDocument
1 IID_ITextDocument2 Guid c241f5e0-7206-11d8-a2c7-00a0d1d6c6b3
2 IID_ITextDocument2Old Guid 01c25500-4268-11d1-883a-3c8b00c10000
3 IID_ITextDocument Guid beee4ddb-90b2-408c-a2f6-0a0ac31e33e4
4 IID_ITextDocument Guid 8cc497c0-a1df-11ce-8098-00aa0047be5d
Try to compile Win64_4.asm
Have error in string " lea rsi, CStr("Hello, world",13,10) "
Win64_4.asm(29) : Error A2227: Missing right parenthesis in expression
Delete Cstr (what is it? macro?), edit string for
.DATA
cstrr db "Hello, world",13,10,0
lea rsi, cstrr
Then link /subsystem:console /Libpath:d:\uasm\UASM-SDK-master\lib\x64 Win64_4.obj
but again error
LINK : fatal error LNK1171: unable to load mspdbst.dll (error code: 126)
check that mspdbst.dll exists in your uasm\bin folder
check if file was unblocked. https://winaero.com/blog/how-to-unblock-files-downloaded-from-internet-in-windows-10/
Make sure the entire zip was unblocked - ideally you downloaded it as Source code (zip) from release section and unblocked the zip.
So, I have next error
'\uasm\UASM-SDK-master\lib\x64\kernel32.lib : warning LNK4003: invalid library format; library ignored'
What that UASM-SDK-master is ?
Something wrong with that linker, as in my test link.exe don't even need that mspdbst.dll, and i don't even have a it in test folder.
Could be the library is corrupt or trying to link an x86 program with an x64 library or vice versa.
I used the following to build Win64_4.asm, (where I installed UASM in my M: drive):
uasm64 -c -win64 -Zp8 -I"M:\UASM\Include" Win64_4.asm
link /subsystem:console /Libpath:"M:\UASM\Lib\x64" Win64_4.obj
Im guessing the library is blocked or is corrupt though
@TimeVJL - probably referring to my unofficial uasm sdk on github: https://github.com/mrfearless/UASM-SDK (https://github.com/mrfearless/UASM-SDK) - which combines some of the visual studio 2013 (v12) linker, lib and other bin tools, the wininc includes and libraries, along with uasm (2.46 i think at the time it was uploaded) - if you clone/download from the repo it will download it all as UASM-SDK-master.zip
The example should build fine with the correct paths, correct link.exe paths etc.
However, there is a bug in UASM I noticed after looking at something mentioned above:
In some cases we can assemble instructions in the DATA section when we should not.
Extract from Win64_4.asm:
.CODE
main proc FRAME uses rbx rsi rdi
local dwWritten:DWORD
invoke GetStdHandle,STD_OUTPUT_HANDLE
mov rbx,rax
.DATA ; We are in the data section now but it will assemble happily the intel instructions
cstrr db "Hello, world",13,10,0
lea rsi, cstrr
lea rdi, CStr("Hello, world",13,10)
invoke lstrlen, rsi
mov edi, eax
invoke WriteConsoleA, rbx, rsi, edi, addr dwWritten, 0
ret
main endp
If we comment out
; lea rdi, CStr("Hello, world",13,10)
it will produce an error. Not the expected error but some error anyway.
Maybe some lib files are corrupted. So, where I can get normal lib for x64 ? For 32 bit I get from masm.
Quote from: morgot on August 11, 2019, 11:38:19 PM
Maybe some lib files are corrupted. So, where I can get normal lib for x64 ? For 32 bit I get from masm.
You can use the masm32\64bit kernel32.lib or you can build the UASM libs by downloading Wininc from the UASM website. There are instructions in the Wininc on how to build the libs. kernel32.lib is also available in Windows kits and a few other places.
Yes, Wininc build the libs with polib, or PellesC libraries from Lib\Win64or Windows SDK/Kits (Windows Kits\8.1\Lib\winv6.3\um\x64, Microsoft SDKs\Windows\v7.1A\Lib\x64 etc)
I don't want to create it myself, I can do something wrong (I'm a noob). Took libs from PellesС, it seems to work.
But it's still difficult to code x64... I will still ask.
As example - what prototype must be for x64? QWORD or DWORD? Or what? This code fails with Acess violation
.x64 ; -pe requires to set cpu, model & language
.model flat, fastcall
option casemap:none
option frame:auto ; generate SEH-compatible prologues and epilogues
option win64:3 ; init shadow space, reserve stack at PROC level
option dllimport:<kernel32>
ExitProcess proto :dword
option dllimport:<shell32>
ShellExecuteA proto :dword, :dword, :dword, :dword, :dword
option DLLIMPORT:<urlmon>
URLDownloadToFileA proto :qword, :qword, :qword, :dword, :qword
option dllimport:none
.data
ClassName db "https://forum.pellesc.de/index.php?topic=3253.0",0
AppName db "PellesC.htm",0
.code
WinMainCRTStartup proc FRAME
invoke URLDownloadToFileA,0,addr ClassName,addr AppName,0,0
xor eax,eax
invoke ExitProcess, eax
WinMainCRTStartup endp
end WinMainCRTStartup
This is modifiyed TimoVJL C sample
Open C sample in IDA dizasm, it say me that prototype is URLDownloadToFileA proto :dword, :qword, :qword, :qword, :qword
(first parametr is ECX - 32 bit register, another is 64 bit). But why? I mean, that in x64 all pointers are 64 bit values..
Win 64 uses 64 bit aligned locations for all arguments between BYTE and QWORD.
ExitProcess proto :dword
ShellExecuteA proto :ptr, :ptr, :ptr, :ptr, :ptr, :dword
URLDownloadToFileA proto :ptr, :ptr, :ptr, :dword, :ptr
as LP... is a pointerHRESULT URLDownloadToFile(LPUNKNOWN pCaller, LPCTSTR szURL, LPCTSTR szFileName, _Reserved_ DWORD dwReserved, LPBINDSTATUSCALLBACK lpfnCB);
HINSTANCE ShellExecuteA(HWND hwnd, LPCSTR lpOperation, LPCSTR lpFile, LPCSTR lpParameters, LPCSTR lpDirectory, INT nShowCmd);
uasm and asmcoption casemap:none
option win64:15
option stackbase:rsp
includelib kernel32
includelib urlmon
ExitProcess proto :dword
URLDownloadToFileA proto :ptr, :ptr, :ptr, :dword, :ptr
.data
url db "https://forum.pellesc.de/index.php?topic=3253.0",0
align 8
htm db "PellesC.htm",0
.code
WinMainCRTStartup proc FRAME
invoke URLDownloadToFileA, 0, addr url, addr htm, 0, 0
xor ecx, ecx
invoke ExitProcess, ecx
WinMainCRTStartup endp
END
a test with ml64 too:includelib kernel32
includelib urlmon
extern __imp_URLDownloadToFileA :proc
extern __imp_ExitProcess :proc
.data
url db "https://forum.pellesc.de/index.php?topic=3253.0",0
align 8
htm db "PellesC.htm",0
public WinMainCRTStartup
.code
WinMainCRTStartup:
sub rsp, 38h
xor ecx, ecx
lea rdx, url
lea r8, htm
xor r9d, r9d
;mov qword ptr [rsp+20h], 0h
mov qword ptr [rsp+20h], rcx
call qword ptr [__imp_URLDownloadToFileA]
xor ecx, ecx
call qword ptr [__imp_ExitProcess]
END
and poasm:includelib kernel32
includelib urlmon
extern __imp_URLDownloadToFileA :proc
extern __imp_ExitProcess :proc
.data
url db "https://forum.pellesc.de/index.php?topic=3253.0",0
align 8
htm db "PellesC.htm",0
public WinMainCRTStartup
.code
WinMainCRTStartup:
sub rsp, 38h
xor ecx, ecx
lea rdx, [rip+url]
lea r8, [rip+htm]
xor r9d, r9d
;mov qword ptr [rsp+20h], 0h
mov qword ptr [rsp+20h], rcx
call qword ptr [rip+__imp_URLDownloadToFileA]
xor ecx, ecx
call qword ptr [rip+__imp_ExitProcess]
END
with invokeincludelib kernel32
includelib urlmon
ExitProcess proto :dword
URLDownloadToFileA proto :ptr, :ptr, :ptr, :dword, :ptr
.data
url db "https://forum.pellesc.de/index.php?topic=3253.0",0
align 8
htm db "PellesC.htm",0
.code
WinMainCRTStartup proc PARMAREA=5*8
invoke URLDownloadToFileA, 0, addr url, addr htm, 0, 0
mov ecx, ecx
invoke ExitProcess, ecx
WinMainCRTStartup endp
END