flat assembler
Message board for the users of flat assembler.

Index > Windows > UuidCreate in rpcrt4.dll wrapping executable

Author
Thread Post new topic Reply to topic
Trojany



Joined: 31 May 2010
Posts: 5
Trojany
Just a little uuid-creator, if someone needs...

- no include files
- error checking

If you for any reason can't download the attached source file:
Code:
format PE

section '.text' executable

push _Uuid
call [UuidCreate]

cmp eax, 0
jne _End

push _StringUuid
push _Uuid
call [UuidToString]

cmp eax, 0
jne _End

push -11
call [GetStdHandle]

cmp eax, -1
je _End
mov [_OutHandle], eax

_Loop:
push 0
push _BytesWritten
push [_BytesToWrite]
push [_StringUuid]
push [_OutHandle]
call [WriteFile]

sub eax, 2
cmp eax, -2
je _End

mov eax, [_BytesWritten]
add [_StringUuid], eax
sub [_BytesToWrite], eax
jnz _Loop

mov eax, 0
_End:
ret

section 'data' readable writable

_Uuid dd 0, 0, 0, 0
_StringUuid dd 0
_OutHandle dd 0
_BytesWritten dd 0
_BytesToWrite dd 36

section '.idata' import readable

dd rva lkernel32, 0, 0, rva nkernel32, rva akernel32
dd rva lrpcrt4, 0, 0, rva nrpcrt4, rva arpcrt4
dd 0, 0, 0, 0, 0

lkernel32:
dd rva nGetStdHandle
dd rva nWriteFile
dd 0
nkernel32 db 'kernel32.dll', 0
akernel32:
GetStdHandle dd rva nGetStdHandle
WriteFile dd rva nWriteFile
dd 0
nGetStdHandle db 0, 0, 'GetStdHandle', 0
nWriteFile db 0, 0, 'WriteFile', 0

lrpcrt4:
dd rva nUuidCreate
dd rva nUuidToString
dd 0
nrpcrt4 db 'rpcrt4.dll', 0
arpcrt4:
UuidCreate dd rva nUuidCreate
UuidToString dd rva nUuidToString
dd 0
nUuidCreate db 0, 0, 'UuidCreate', 0
nUuidToString db 0, 0, 'UuidToStringA', 0
    
Just call:
FASM.EXE UuidCreate.asm UuidCreate.exe
UuidCreate.exe

will give you a unique string if successful, or an %errorlevel% if not.


Description: Usage:
FASM.EXE UuidCreate.asm UuidCreate.exe

Download
Filename: UuidCreate.asm
Filesize: 1.29 KB
Downloaded: 30 Time(s)

Post 04 Jun 2010, 02:01
View user's profile Send private message Reply with quote
coconut



Joined: 02 Apr 2004
Posts: 326
Location: usa
coconut
Please make example of using UUIDCreateSequential
Post 21 Jul 2010, 18:50
View user's profile Send private message 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-2020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.

Website powered by rwasa.