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