* autoload.cc (UuidCreate): Remove.

(UuidCreateSequential): Remove.
	* passwd.cc (internal_getpwsid): Avoid a strict-aliasing compiler
	error with gcc 4.5.1.
	* fhandler_floppy.cc (fhandler_dev_floppy::get_drive_info): Ditto.
	* ntdll.h (NtAllocateUuids): Declare.
	* syscalls.cc (gethostid): Use NtAllocateUuids function rather than
	UuidCreateSequential/UuidCreate to get rid of rpcrt4 dependency.
This commit is contained in:
Corinna Vinschen 2011-03-29 10:42:11 +00:00
parent cabe8aa22a
commit 5f660ecf24
6 changed files with 41 additions and 22 deletions

View File

@ -1,3 +1,14 @@
2011-03-29 Corinna Vinschen <corinna@vinschen.de>
* autoload.cc (UuidCreate): Remove.
(UuidCreateSequential): Remove.
* passwd.cc (internal_getpwsid): Avoid a strict-aliasing compiler
error with gcc 4.5.1.
* fhandler_floppy.cc (fhandler_dev_floppy::get_drive_info): Ditto.
* ntdll.h (NtAllocateUuids): Declare.
* syscalls.cc (gethostid): Use NtAllocateUuids function rather than
UuidCreateSequential/UuidCreate to get rid of rpcrt4 dependency.
2011-03-29 Corinna Vinschen <corinna@vinschen.de>
* cygwin.din (pthread_spin_destroy): Export.

View File

@ -403,9 +403,6 @@ LoadDLLfuncEx (GetModuleInformation, 16, psapi, 1)
LoadDLLfuncEx (GetProcessMemoryInfo, 12, psapi, 1)
LoadDLLfuncEx (QueryWorkingSet, 12, psapi, 1)
LoadDLLfunc (UuidCreate, 4, rpcrt4)
LoadDLLfuncEx (UuidCreateSequential, 4, rpcrt4, 1)
LoadDLLfunc (LsaDeregisterLogonProcess, 4, secur32)
LoadDLLfunc (LsaFreeReturnBuffer, 4, secur32)
LoadDLLfunc (LsaLogonUser, 56, secur32)

View File

@ -41,6 +41,7 @@ fhandler_dev_floppy::get_drive_info (struct hd_geometry *geo)
char dbuf[256];
char pbuf[256];
DISK_GEOMETRY_EX *dix = NULL;
DISK_GEOMETRY *di = NULL;
PARTITION_INFORMATION_EX *pix = NULL;
PARTITION_INFORMATION *pi = NULL;
@ -57,7 +58,8 @@ fhandler_dev_floppy::get_drive_info (struct hd_geometry *geo)
__seterrno ();
else
{
di = &((DISK_GEOMETRY_EX *) dbuf)->Geometry;
dix = (DISK_GEOMETRY_EX *) dbuf;
di = &dix->Geometry;
if (!DeviceIoControl (get_handle (),
IOCTL_DISK_GET_PARTITION_INFO_EX, NULL, 0,
pbuf, 256, &bytes_read, NULL))

View File

@ -907,6 +907,7 @@ extern "C"
{
NTSTATUS NTAPI NtAdjustPrivilegesToken (HANDLE, BOOLEAN, PTOKEN_PRIVILEGES,
ULONG, PTOKEN_PRIVILEGES, PULONG);
NTSTATUS NTAPI NtAllocateUuids (PLARGE_INTEGER, PULONG, PULONG, PUCHAR);
NTSTATUS NTAPI NtClose (HANDLE);
NTSTATUS NTAPI NtCommitTransaction (HANDLE, BOOLEAN);
NTSTATUS NTAPI NtCreateDirectoryObject (PHANDLE, ACCESS_MASK,

View File

@ -98,11 +98,14 @@ internal_getpwsid (cygpsid &sid)
{
endptr = strchr (sid_string + 2, 0) - 1;
for (int i = 0; i < pr.curr_lines; i++)
if ((pw = passwd_buf + i)->pw_dir > pw->pw_gecos + 8)
for (ptr1 = endptr, ptr2 = pw->pw_dir - 2;
*ptr1 == *ptr2; ptr2--)
if (!*--ptr1)
return pw;
{
pw = passwd_buf + i;
if (pw->pw_dir > pw->pw_gecos + 8)
for (ptr1 = endptr, ptr2 = pw->pw_dir - 2;
*ptr1 == *ptr2; ptr2--)
if (!*--ptr1)
return pw;
}
}
return NULL;
}

View File

@ -3760,24 +3760,29 @@ long gethostid (void)
}
}
UUID Uuid;
RPC_STATUS status = UuidCreateSequential (&Uuid);
if (GetLastError () == ERROR_PROC_NOT_FOUND)
status = UuidCreate (&Uuid);
if (status == RPC_S_OK)
LARGE_INTEGER u1;
ULONG u2, u3;
union {
UCHAR mac[6];
struct {
ULONG m1;
USHORT m2;
};
} u4;
NTSTATUS status = NtAllocateUuids (&u1, &u2, &u3, u4.mac);
if (NT_SUCCESS (status))
{
data[4] = *(unsigned *)&Uuid.Data4[2];
data[5] = *(unsigned short *)&Uuid.Data4[6];
data[4] = u4.m1;
data[5] = u4.m2;
// Unfortunately Windows will sometimes pick a virtual Ethernet card
// e.g. VMWare Virtual Ethernet Adaptor
debug_printf ("MAC address of first Ethernet card: %02x:%02x:%02x:%02x:%02x:%02x",
Uuid.Data4[2], Uuid.Data4[3], Uuid.Data4[4],
Uuid.Data4[5], Uuid.Data4[6], Uuid.Data4[7]);
debug_printf ("MAC address of first Ethernet card: "
"%02x:%02x:%02x:%02x:%02x:%02x",
u4.mac[0], u4.mac[1], u4.mac[2],
u4.mac[3], u4.mac[4], u4.mac[5]);
}
else
{
debug_printf ("no Ethernet card installed");
}
debug_printf ("no Ethernet card installed");
reg_key key (HKEY_LOCAL_MACHINE, KEY_READ, "SOFTWARE", "Microsoft",
"Windows NT", "CurrentVersion", NULL);