[winpr] fix OVERLAPPED and SYSTEM_INFO definitions

rename them to conform to windows versions
This commit is contained in:
akallabeth
2024-10-29 15:45:07 +01:00
committed by Armin Novak
parent 06214fec26
commit 17295d114b
5 changed files with 23 additions and 19 deletions

View File

@@ -45,9 +45,9 @@ typedef struct
{
DWORD Offset;
DWORD OffsetHigh;
};
} DUMMYSTRUCTNAME;
PVOID Pointer;
};
} DUMMYUNIONNAME;
HANDLE hEvent;
} OVERLAPPED, *LPOVERLAPPED;

View File

@@ -84,8 +84,8 @@ extern "C"
{
WORD wProcessorArchitecture;
WORD wReserved;
};
};
} DUMMYSTRUCTNAME;
} DUMMYUNIONNAME;
DWORD dwPageSize;
LPVOID lpMinimumApplicationAddress;

View File

@@ -332,7 +332,7 @@ BOOL NamedPipeRead(PVOID Object, LPVOID lpBuffer, DWORD nNumberOfBytesToRead,
/* synchronous behavior */
lpOverlapped->Internal = 0;
lpOverlapped->InternalHigh = (ULONG_PTR)nNumberOfBytesToRead;
lpOverlapped->Pointer = (PVOID)lpBuffer;
lpOverlapped->DUMMYUNIONNAME.Pointer = (PVOID)lpBuffer;
(void)SetEvent(lpOverlapped->hEvent);
#endif
}
@@ -426,7 +426,7 @@ BOOL NamedPipeWrite(PVOID Object, LPCVOID lpBuffer, DWORD nNumberOfBytesToWrite,
PVOID pv;
} cnv;
cnv.cpv = lpBuffer;
lpOverlapped->Pointer = cnv.pv;
lpOverlapped->DUMMYUNIONNAME.Pointer = cnv.pv;
}
(void)SetEvent(lpOverlapped->hEvent);
#endif
@@ -782,7 +782,7 @@ BOOL ConnectNamedPipe(HANDLE hNamedPipe, LPOVERLAPPED lpOverlapped)
/* synchronous behavior */
lpOverlapped->Internal = 2;
lpOverlapped->InternalHigh = (ULONG_PTR)0;
lpOverlapped->Pointer = (PVOID)NULL;
lpOverlapped->DUMMYUNIONNAME.Pointer = (PVOID)NULL;
(void)SetEvent(lpOverlapped->hEvent);
}

View File

@@ -20,6 +20,7 @@
#include <winpr/config.h>
#include <winpr/assert.h>
#include <winpr/sysinfo.h>
#include <winpr/platform.h>
@@ -226,17 +227,14 @@ static DWORD GetSystemPageSize(void)
void GetSystemInfo(LPSYSTEM_INFO lpSystemInfo)
{
lpSystemInfo->wProcessorArchitecture = GetProcessorArchitecture();
lpSystemInfo->wReserved = 0;
const SYSTEM_INFO empty = { 0 };
WINPR_ASSERT(lpSystemInfo);
*lpSystemInfo = empty;
lpSystemInfo->DUMMYUNIONNAME.DUMMYSTRUCTNAME.wProcessorArchitecture =
GetProcessorArchitecture();
lpSystemInfo->dwPageSize = GetSystemPageSize();
lpSystemInfo->lpMinimumApplicationAddress = NULL;
lpSystemInfo->lpMaximumApplicationAddress = NULL;
lpSystemInfo->dwActiveProcessorMask = 0;
lpSystemInfo->dwNumberOfProcessors = GetNumberOfProcessors();
lpSystemInfo->dwProcessorType = 0;
lpSystemInfo->dwAllocationGranularity = 0;
lpSystemInfo->wProcessorLevel = 0;
lpSystemInfo->wProcessorRevision = 0;
}
void GetNativeSystemInfo(LPSYSTEM_INFO lpSystemInfo)

View File

@@ -4,16 +4,22 @@
int TestGetNativeSystemInfo(int argc, char* argv[])
{
SYSTEM_INFO sysinfo;
SYSTEM_INFO sysinfo = { 0 };
WINPR_UNUSED(argc);
WINPR_UNUSED(argv);
GetNativeSystemInfo(&sysinfo);
#if defined(DUMMYUNIONNAME) && defined(DUMMYSTRUCTNAME)
#define DUMMYXPTR(x) x.DUMMYUNIONNAME.DUMMYSTRUCTNAME
#else
#define DUMMYXPTR(x) x
#endif
printf("SystemInfo:\n");
printf("\twProcessorArchitecture: %" PRIu16 "\n", sysinfo.wProcessorArchitecture);
printf("\twReserved: %" PRIu16 "\n", sysinfo.wReserved);
printf("\twProcessorArchitecture: %" PRIu16 "\n", DUMMYXPTR(sysinfo).wProcessorArchitecture);
printf("\twReserved: %" PRIu16 "\n", DUMMYXPTR(sysinfo).wReserved);
printf("\tdwPageSize: 0x%08" PRIX32 "\n", sysinfo.dwPageSize);
printf("\tlpMinimumApplicationAddress: %p\n", sysinfo.lpMinimumApplicationAddress);
printf("\tlpMaximumApplicationAddress: %p\n", sysinfo.lpMaximumApplicationAddress);