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
|
// name lookup
|
||||||
struct hostent* info = gethostbyaddr_winsock(
|
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);
|
addr->m_len, addr->m_addr.sa_family);
|
||||||
if (info == NULL) {
|
if (info == NULL) {
|
||||||
throwNameError(getsockerror_winsock());
|
throwNameError(getsockerror_winsock());
|
||||||
|
@ -772,7 +772,7 @@ ArchNetworkWinsock::addrToString(ArchNetAddress addr)
|
||||||
switch (getAddrFamily(addr)) {
|
switch (getAddrFamily(addr)) {
|
||||||
case kINET: {
|
case kINET: {
|
||||||
struct sockaddr_in* ipAddr =
|
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);
|
return inet_ntoa_winsock(ipAddr->sin_addr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -804,8 +804,8 @@ ArchNetworkWinsock::setAddrPort(ArchNetAddress addr, int port)
|
||||||
switch (getAddrFamily(addr)) {
|
switch (getAddrFamily(addr)) {
|
||||||
case kINET: {
|
case kINET: {
|
||||||
struct sockaddr_in* ipAddr =
|
struct sockaddr_in* ipAddr =
|
||||||
static_cast<struct sockaddr_in*>(&addr->m_addr);
|
reinterpret_cast<struct sockaddr_in*>(&addr->m_addr);
|
||||||
ipAddr->sin_port = htons_winsock(static_cast<u_short>(port));
|
ipAddr->sin_port = htons_winsock(reinterpret_cast<u_short>(port));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -823,7 +823,7 @@ ArchNetworkWinsock::getAddrPort(ArchNetAddress addr)
|
||||||
switch (getAddrFamily(addr)) {
|
switch (getAddrFamily(addr)) {
|
||||||
case kINET: {
|
case kINET: {
|
||||||
struct sockaddr_in* ipAddr =
|
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);
|
return ntohs_winsock(ipAddr->sin_port);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -841,7 +841,7 @@ ArchNetworkWinsock::isAnyAddr(ArchNetAddress addr)
|
||||||
switch (getAddrFamily(addr)) {
|
switch (getAddrFamily(addr)) {
|
||||||
case kINET: {
|
case kINET: {
|
||||||
struct sockaddr_in* ipAddr =
|
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) &&
|
return (addr->m_len == sizeof(struct sockaddr_in) &&
|
||||||
ipAddr->sin_addr.s_addr == INADDR_ANY);
|
ipAddr->sin_addr.s_addr == INADDR_ANY);
|
||||||
}
|
}
|
||||||
|
|
|
@ -414,17 +414,16 @@ ArchTaskBarWindows::staticWndProc(HWND hwnd, UINT msg,
|
||||||
ArchTaskBarWindows* self = NULL;
|
ArchTaskBarWindows* self = NULL;
|
||||||
if (msg == WM_NCCREATE) {
|
if (msg == WM_NCCREATE) {
|
||||||
CREATESTRUCT* createInfo;
|
CREATESTRUCT* createInfo;
|
||||||
createInfo = static_cast<CREATESTRUCT*>(lParam);
|
createInfo = reinterpret_cast<CREATESTRUCT*>(lParam);
|
||||||
self = static_cast<ArchTaskBarWindows*>(
|
self = static_cast<ArchTaskBarWindows*>(
|
||||||
createInfo->lpCreateParams);
|
createInfo->lpCreateParams);
|
||||||
SetWindowLong(hwnd, 0, static_cast<LONG>(self));
|
SetWindowLongPtr(hwnd, 0, self);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// get the extra window data and forward the call
|
// get the extra window data and forward the call
|
||||||
LONG data = GetWindowLong(hwnd, 0);
|
LONG_PTR data = GetWindowLongPtr(hwnd, 0);
|
||||||
if (data != 0) {
|
if (data != 0) {
|
||||||
self = static_cast<ArchTaskBarWindows*>(
|
self = static_cast<ArchTaskBarWindows*>(reinterpret_cast<void*>(data));
|
||||||
static_cast<void*>(data));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -444,6 +443,7 @@ ArchTaskBarWindows::threadMainLoop()
|
||||||
m_taskBarRestart = RegisterWindowMessage(TEXT("TaskbarCreated"));
|
m_taskBarRestart = RegisterWindowMessage(TEXT("TaskbarCreated"));
|
||||||
|
|
||||||
// register a window class
|
// register a window class
|
||||||
|
LPCTSTR className = TEXT("SynergyTaskBar");
|
||||||
WNDCLASSEX classInfo;
|
WNDCLASSEX classInfo;
|
||||||
classInfo.cbSize = sizeof(classInfo);
|
classInfo.cbSize = sizeof(classInfo);
|
||||||
classInfo.style = CS_NOCLOSE;
|
classInfo.style = CS_NOCLOSE;
|
||||||
|
@ -455,13 +455,13 @@ ArchTaskBarWindows::threadMainLoop()
|
||||||
classInfo.hCursor = NULL;
|
classInfo.hCursor = NULL;
|
||||||
classInfo.hbrBackground = NULL;
|
classInfo.hbrBackground = NULL;
|
||||||
classInfo.lpszMenuName = NULL;
|
classInfo.lpszMenuName = NULL;
|
||||||
classInfo.lpszClassName = TEXT("SynergyTaskBar");
|
classInfo.lpszClassName = className;
|
||||||
classInfo.hIconSm = NULL;
|
classInfo.hIconSm = NULL;
|
||||||
ATOM windowClass = RegisterClassEx(&classInfo);
|
ATOM windowClass = RegisterClassEx(&classInfo);
|
||||||
|
|
||||||
// create window
|
// create window
|
||||||
m_hwnd = CreateWindowEx(WS_EX_TOOLWINDOW,
|
m_hwnd = CreateWindowEx(WS_EX_TOOLWINDOW,
|
||||||
static_cast<LPCTSTR>(windowClass),
|
className,
|
||||||
TEXT("Synergy Task Bar"),
|
TEXT("Synergy Task Bar"),
|
||||||
WS_POPUP,
|
WS_POPUP,
|
||||||
0, 0, 1, 1,
|
0, 0, 1, 1,
|
||||||
|
@ -478,7 +478,7 @@ ArchTaskBarWindows::threadMainLoop()
|
||||||
|
|
||||||
// handle failure
|
// handle failure
|
||||||
if (m_hwnd == NULL) {
|
if (m_hwnd == NULL) {
|
||||||
UnregisterClass(static_cast<LPCTSTR>(windowClass), instanceWin32());
|
UnregisterClass(className, instanceWin32());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -494,7 +494,7 @@ ArchTaskBarWindows::threadMainLoop()
|
||||||
// clean up
|
// clean up
|
||||||
removeAllIcons();
|
removeAllIcons();
|
||||||
DestroyWindow(m_hwnd);
|
DestroyWindow(m_hwnd);
|
||||||
UnregisterClass(static_cast<LPCTSTR>(windowClass), instanceWin32());
|
UnregisterClass(className, instanceWin32());
|
||||||
}
|
}
|
||||||
|
|
||||||
void*
|
void*
|
||||||
|
|
Loading…
Reference in New Issue