2
* gen_uuid_nt.c -- Use NT api to generate uuid
4
* Written by Andrey Shedel (andreys@ns.cr.cyco.com)
10
#pragma warning(push,4)
12
#pragma comment(lib, "ntdll.lib")
15
// Here is a nice example why it's not a good idea
16
// to use native API in ordinary applications.
17
// Number of parameters in function below was changed from 3 to 4
28
// OUT PUCHAR Seed // 6 bytes
44
NtAllocateUuids_2000)(
54
// Nice, but instead of including ntddk.h ot winnt.h
55
// I should define it here because they MISSED __stdcall in those headers.
65
// The only way to get version information from the system is to examine
66
// one stored in PEB. But it's pretty dangerouse because this value could
67
// be altered in image header.
74
//return NtCuttentTeb()->Peb->OSMajorVersion >= 5;
75
return (int)*(int*)((char*)(int)(*(int*)((char*)NtCurrentTeb() + 0x30)) + 0xA4) >= 5;
81
void uuid_generate(uuid_t out)
85
unsigned char seed[6];
86
((NtAllocateUuids_2000)NtAllocateUuids)(out, ((char*)out)+8, ((char*)out)+12, &seed[0] );
90
NtAllocateUuids(out, ((char*)out)+8, ((char*)out)+12);