mirror of
https://github.com/debauchee/barrier.git
synced 2024-11-27 00:42:30 +03:00
Restore safe reinterpret_casts in Windows TaskBar
This commit is contained in:
parent
5a03e37d15
commit
d77b5f1176
@ -754,7 +754,7 @@ ArchNetworkWinsock::addrToName(ArchNetAddress addr)
|
||||
|
||||
// name lookup
|
||||
struct hostent* info = gethostbyaddr_winsock(
|
||||
static_cast<const char FAR*>(&addr->m_addr),
|
||||
reinterpret_cast<const char FAR*>(&addr->m_addr),
|
||||
addr->m_len, addr->m_addr.sa_family);
|
||||
if (info == NULL) {
|
||||
throwNameError(getsockerror_winsock());
|
||||
@ -772,7 +772,7 @@ ArchNetworkWinsock::addrToString(ArchNetAddress addr)
|
||||
switch (getAddrFamily(addr)) {
|
||||
case kINET: {
|
||||
struct sockaddr_in* ipAddr =
|
||||
static_cast<struct sockaddr_in*>(&addr->m_addr);
|
||||
reinterpret_cast<struct sockaddr_in*>(&addr->m_addr);
|
||||
return inet_ntoa_winsock(ipAddr->sin_addr);
|
||||
}
|
||||
|
||||
@ -804,8 +804,8 @@ ArchNetworkWinsock::setAddrPort(ArchNetAddress addr, int port)
|
||||
switch (getAddrFamily(addr)) {
|
||||
case kINET: {
|
||||
struct sockaddr_in* ipAddr =
|
||||
static_cast<struct sockaddr_in*>(&addr->m_addr);
|
||||
ipAddr->sin_port = htons_winsock(static_cast<u_short>(port));
|
||||
reinterpret_cast<struct sockaddr_in*>(&addr->m_addr);
|
||||
ipAddr->sin_port = htons_winsock(reinterpret_cast<u_short>(port));
|
||||
break;
|
||||
}
|
||||
|
||||
@ -823,7 +823,7 @@ ArchNetworkWinsock::getAddrPort(ArchNetAddress addr)
|
||||
switch (getAddrFamily(addr)) {
|
||||
case kINET: {
|
||||
struct sockaddr_in* ipAddr =
|
||||
static_cast<struct sockaddr_in*>(&addr->m_addr);
|
||||
reinterpret_cast<struct sockaddr_in*>(&addr->m_addr);
|
||||
return ntohs_winsock(ipAddr->sin_port);
|
||||
}
|
||||
|
||||
@ -841,7 +841,7 @@ ArchNetworkWinsock::isAnyAddr(ArchNetAddress addr)
|
||||
switch (getAddrFamily(addr)) {
|
||||
case kINET: {
|
||||
struct sockaddr_in* ipAddr =
|
||||
static_cast<struct sockaddr_in*>(&addr->m_addr);
|
||||
reinterpret_cast<struct sockaddr_in*>(&addr->m_addr);
|
||||
return (addr->m_len == sizeof(struct sockaddr_in) &&
|
||||
ipAddr->sin_addr.s_addr == INADDR_ANY);
|
||||
}
|
||||
|
@ -414,17 +414,16 @@ ArchTaskBarWindows::staticWndProc(HWND hwnd, UINT msg,
|
||||
ArchTaskBarWindows* self = NULL;
|
||||
if (msg == WM_NCCREATE) {
|
||||
CREATESTRUCT* createInfo;
|
||||
createInfo = static_cast<CREATESTRUCT*>(lParam);
|
||||
createInfo = reinterpret_cast<CREATESTRUCT*>(lParam);
|
||||
self = static_cast<ArchTaskBarWindows*>(
|
||||
createInfo->lpCreateParams);
|
||||
SetWindowLong(hwnd, 0, static_cast<LONG>(self));
|
||||
SetWindowLongPtr(hwnd, 0, self);
|
||||
}
|
||||
else {
|
||||
// get the extra window data and forward the call
|
||||
LONG data = GetWindowLong(hwnd, 0);
|
||||
LONG_PTR data = GetWindowLongPtr(hwnd, 0);
|
||||
if (data != 0) {
|
||||
self = static_cast<ArchTaskBarWindows*>(
|
||||
static_cast<void*>(data));
|
||||
self = static_cast<ArchTaskBarWindows*>(reinterpret_cast<void*>(data));
|
||||
}
|
||||
}
|
||||
|
||||
@ -444,6 +443,7 @@ ArchTaskBarWindows::threadMainLoop()
|
||||
m_taskBarRestart = RegisterWindowMessage(TEXT("TaskbarCreated"));
|
||||
|
||||
// register a window class
|
||||
LPCTSTR className = TEXT("SynergyTaskBar");
|
||||
WNDCLASSEX classInfo;
|
||||
classInfo.cbSize = sizeof(classInfo);
|
||||
classInfo.style = CS_NOCLOSE;
|
||||
@ -455,13 +455,13 @@ ArchTaskBarWindows::threadMainLoop()
|
||||
classInfo.hCursor = NULL;
|
||||
classInfo.hbrBackground = NULL;
|
||||
classInfo.lpszMenuName = NULL;
|
||||
classInfo.lpszClassName = TEXT("SynergyTaskBar");
|
||||
classInfo.lpszClassName = className;
|
||||
classInfo.hIconSm = NULL;
|
||||
ATOM windowClass = RegisterClassEx(&classInfo);
|
||||
|
||||
// create window
|
||||
m_hwnd = CreateWindowEx(WS_EX_TOOLWINDOW,
|
||||
static_cast<LPCTSTR>(windowClass),
|
||||
className,
|
||||
TEXT("Synergy Task Bar"),
|
||||
WS_POPUP,
|
||||
0, 0, 1, 1,
|
||||
@ -478,7 +478,7 @@ ArchTaskBarWindows::threadMainLoop()
|
||||
|
||||
// handle failure
|
||||
if (m_hwnd == NULL) {
|
||||
UnregisterClass(static_cast<LPCTSTR>(windowClass), instanceWin32());
|
||||
UnregisterClass(className, instanceWin32());
|
||||
return;
|
||||
}
|
||||
|
||||
@ -494,7 +494,7 @@ ArchTaskBarWindows::threadMainLoop()
|
||||
// clean up
|
||||
removeAllIcons();
|
||||
DestroyWindow(m_hwnd);
|
||||
UnregisterClass(static_cast<LPCTSTR>(windowClass), instanceWin32());
|
||||
UnregisterClass(className, instanceWin32());
|
||||
}
|
||||
|
||||
void*
|
||||
|
Loading…
Reference in New Issue
Block a user