Physical Sector Size on Windows XP for advanced format hard disks - c++

I need to retrieve the physical sector size of a hard disk to determine if the hard disk is of advanced format or not in Windows XP.
I tried to use STORAGE_ACCESS_ALIGNMENT_DESCRIPTOR, but it is not compatible in Windows XP. Any method I use would return 512 instead of 4096, which includes WMI where the only value returned is 512.
I have been coding in C++ and I would be very thankful if one can point me to a method which would help me find the actual physical sector size.

According to Microsoft's MSDN article:
Windows XP, Windows Server 2003, and Windows Server 2003 R2 do not
support 512e or 4Kn media. While the system may boot up and be able to
operate minimally, there may be unknown scenarios of functionality
issues, data loss, or sub-optimal performance. Thus, Microsoft
strongly cautions against using 512e media with Windows XP or other
products based on the Windows XP codebase (such as Windows Home Server
1.0, Windows Server 2003, Windows Server 2003 R2, Windows XP 64-bit Edition, Windows XP Embedded, Windows Small Business Server 2003, and
Windows Small Business Server 2003 R2).
Under Windows XP, you will not be able to get a true physical sector size because the OS itself assumes that it is 512 bytes.

Related

DXGI flip in Windows 8.1?

Does Windows 8.1 support the DXGI flip model? I.e. DXGI_SWAP_EFFECT_FLIP_SEQUENTIAL and DXGI_SWAP_EFFECT_FLIP_DISCARD? I am seeing conflicting information online.
Link1 and link2 indicate that at least DXGI_SWAP_EFFECT_FLIP_SEQUENTIAL is supported by Windows 8, yet the common way to test for DXGI flip model support is:
ComPtr<IDXGIFactory4> factory4;
if (FAILED(m_dxgiFactory.As(&factory4)))
{
m_options &= ~c_FlipPresent;
}
which seems to fail on Windows 8.1. I'm using Visual Studio 2019 with Windows SDK version 10.0.14393.0. Here's my GPU info:
As a quick sanity check, I've run the SimpleInstancingPC example from Xbox-ATG-Samples / DirectXTK. It states:
INFO: Flip swap effects not supported
Direct3D Adapter (0): VID:10DE, PID:1F82 - NVIDIA GeForce GTX 1650
If DXGI_SWAP_EFFECT_FLIP_SEQUENTIAL is in fact supported by Windows 8.1 but DXGI_SWAP_EFFECT_FLIP_DISCARD is not, what is the correct way to check for this functionality, given that the IDXGIFactory4 approach fails?
The optimization work that is discussed in the "Use the flip model" blog post is only in Windows 10, so it's best to stick with legacy blit and treat Windows 8.x and Windows 7 the same.
For Windows 8.x, the main and only real use for DXGI_SWAP_EFFECT_FLIP_SEQUENTIAL is Windows Store apps.
The background here that game developers don't worry much about Windows 8.x these days given the Steam Hardware Survey numbers: It's less than 1% total.
UPDATE: See this blog post series as well for more guidance on swapchains.

get mac addresses of wireless adapters in c++ on WinXP and above

I would like to have the above.
I found the IP Helper API, and it works. Only problem is that on systems older than Vista I can not identify whether the adapter is wireless or a regular Ethernet.
I need to support WinXP and Server 2003 as well.
Here is the relevant quote from the documentation(IP Helper):
An IEEE 802.11 wireless network interface.
Note This adapter type is returned on Windows Vista and later. On Windows Server 2003 and >Windows XP , an IEEE 802.11 wireless network interface returns an adapter type of >MIB_IF_TYPE_ETHERNET.
So what is a good way to identify wireless adapters and get their MAC addresses on WinXP/Server2003 and later?
GetAdapterAddresses is a part of the windows api, and should provide you with both information about mac addresses and NIC type.
The call return a structure pointing to a linked list of adapters.
Make sure that you do not hard code the size of the structure to maintain portability between windows versions, because the IP_ADAPTER_ADDRESSES structure have changed size between versions.
Edit:
This obviously only give you the mac address, since it only reports correct type after Vista
But,
GetIfTable returns a MIB_IFTABLE structure, from this you can read a MIB_IFROW which has a dwType, which might be of the type IF_TYPE_IEEE80211 or not. This has no notes that this is spesific for Vista and should be valid for XP unless MS messed up their documentation.
Both of these should have a physical address, so you should be able to match these two entries to identify one single card.
If you are going to support XP from scratch, this is before the Native Wifi API was introduced to XP (SP 2 & 3 support the Native Wifi API).
I think there still might be an opportunity through WMI. You might be able to create a Win32_NetworkAdapter (A deprecated WMI class) In this class you should be able to extract AdapterTypeID which tells if it is a wireless device or not and MACAddress which gives you the MAC address.
So I think you choice is to either support Windows XP SP 2 and up or have to integrate with WMI and a deprecated class. Looks like there are camels to swallow in any case.

Check what is the device(pc / tablet) in Windows 8

Does anyone here knows how to check which device is running an app in windows 8?
Preferably the Directx + Xaml version .
Thanks
When we developed Windows 8 we intentionally made it so that "tablet" and "PC" are one in the same. If you look at the new generation of hardware (UltraBooks that un-dock to become tablets, ARM-based laptops, etc) you'll see why it wouldn't be possible to guarantee to the app developer that a device is either a "tablet" or a "PC". You could string together a number of capabilities checks to take a guess but you run the risk of inadvertently causing a bad user experience for an unexpected use case.
Anticipating the "But Apple..." replies: This is different for the Apple ecosystem because their PC hardware runs a completely different OS than their tablet and their platform is only available on a small number known Apple devices. It's also different when you compare phones to tablets because a smartphone is essentially a tablet with a smaller screen. The intent of Windows is to run on a wide variety of devices from a wide variety of hardware makers. There are pluses and minuses with both scenarios.

Code To block a port for a process in C++, Windows 7

I'm developing a windows Firewall as my Final Year Project. For this I want to block port for processes in c++. Which API should be used to do this, or if there's any KERNEL MODE API which can be overridden like PsSetCreateNrocessNotifyRoutine?
For Windows Vista and later, you should be using the Windows Filtering Platform, which is accessible from both user-mode and kernel-mode. See this article for an example.

How to run mscomm32.ocx under Windows 7?

We get an app that was working fine until update Windows from Vista Home Basic to 7 Home Premium. We use mscomm32.ocx to control serial port, but it seems it's not supported for 64 bits OS.
Each time we try to read the port: Thisform.msCommControl.Input We got the following:
OLE IDispath exception code 0 from MSComm: Error reading comm devide
We've made a lot of unsuccessful tests. Does any one know how to fix this problem?
The solution is to use an updated control that is contantly under development so newer Windows are also supported. ADONTEC's SuperCom ActiveX is a MSComm compatible ActiveX that developers use for many years in order to replace the MSComm. It is compatible with 32 and 64 bit of Windows 2000/XP/7/8 and Windows 10. You are almost done in few minutes. In many cases the application runs not only faster but is by far more stable and it also offers by far more functionality. See more info here.
that MSCOMM32.OCX will not work with Windows 7 64 bit machines. However, strange as it may seem I have a VB6 program controlling equipment from a virtual comm port (USB ~ serial converter)
It works fine on windows 8.64 bit machine.
The only thing is that the converter driver had to be modified to run on 64 bit.
If you are using a real com port that doesn't matter.
Try it on a 64 bit machine with Windows 8