I was debugging a particular audio problem and I needed a process dump with full memory.
I used an internal gather-dumps tool and asked it to give me a bunch of dumps of the problem with full memory… and it gave me some dumps without full memory.
This told me that either the gather-dumps tool was broken, or MiniDumpWriteDump was broken, or perhaps both were working fine and my debugger was lying to me about the full-memory-ness of the dumps I was looking at.
To help narrow the problem down, I created a tool that is a very simple wrapper around MiniDumpWriteDump. This grabbed full memory dumps just fine, so I turned my attention toward the internal gather-dumps tool.
2019-11-17: Thanks Eric! https://t.co/6Ai7bqto3P (Reply to Eric Trump: “The DOW closed at over 28,000 for the first time in HISTORY. All three US stock indexes closed today at record highs!!! Good job dad! @realDonaldTrump #MAGA 🇺🇸🇺🇸🇺🇸”)
Recently I was involved in a Windows 7 audio support issue that involved SHA-1 deprecation and Trusted Audio Drivers. It was very handy to be able to collect audio logs and Code Integrity logs on Windows 7, but it turns out the Windows 7 version of Windows Performance Recorder has slightly different syntax requirements for WPRP files.
Secure communications like HTTPS, SSH, SFTP and others rely on cryptographic handshakes like the Diffie-Hellman key exchange to negotiate a shared key.
There are lots of ways to set up a Diffie-Hellman key exchange. The Logjam security vulnerability starts with a flaw in the negotiation process to ensure a relatively weak one is used – finite-field with a small prime – and ends up with a man-in-the-middle attack.
The paper uses the term “safe prime” and thought I would dig a little into exactly what that meant.
Refresher: a given prime p defines the Galois field GF(p). This contains p elements: 0 through p – 1 inclusive. Addition and multiplication are both modulo p. We can start with any one of these elements – call it g, for “generator” – and form the sequence 1, g, g2, g3, and so on, until we eventually come back to 1. Call the “period” (length) of this sequence x. It is a law of mathematics that x always evenly divides p – 1.
The vulnerable Diffie-Hellman key exchange goes something like this, skipping over some details:
Alice has a secret key a; Bob has a secret key b.
Alice and Bob start a conversation where the attacker Eve can hear them – they publicly agree to a particular prime p and a generator g.
Alice calculates ga mod p and shares it; Bob calculates gb mod p and shares it.
Alice calculates (gb)a mod p and Bob calculates (ga)b mod p. These are necessarily equal, and their shared value is used as a secret symmetric key for the rest of the conversation.
For cryptographic reasons, we want g’s period in GF(p) to be reasonably large. If the period is small, that gives Eve a reasonable chance to guess the shared secret, which is even worse than her man-in-the-middle attack from Logjam.
So how do we ensure the period is small? One way to do it (not necessarily a good way to do it) is to arrange for p – 1 to have very few divisors.
Could p – 1 be prime? Well, yes, there are two consecutive primes – namely, (2, 3) – but choosing p = 3 has some other cryptographic drawbacks which outweigh the benefit 🙂
OK, well, then, if p – 1 can’t be prime, can it be a semiprime?
Yes, it can. In fact, it can be of the form 2q where q is also prime. In this case, the prime pair (q, p = 2q + 1) are called a (Sophie Germain prime, safe prime) pair. This is the technical definition of “safe prime.”
To illustrate this, let’s choose a couple of primes and see what their generator cycles look like. In particular, let’s look at the safe prime 59 (59 – 1 = 2 * 29 so the corresponding Sophie Germain prime is 29) and the “unsafe prime” 61 (61 – 1 = 60 is a smooth number with quite a lot of factors.)
For each prime I made a table where the rows are all the possible generators g and the columns are the exponents i in gi. I highlighted the columns x where x is a factor of p – 1
Here’s the safe prime 59:
And here’s the unsafe prime 61:
Notice that there are only four periods for 59, in particular x = 1, 2, 29, and 58. These are the four factors of (59 – 1). When choosing a generator, periods 1 and 2 are of course to be avoided; this is easy to do. Period 58 is as good as possible. Period 29 might be accepted as good enough; but if you wanted to go the extra mile, you could detect and correct as follows.
Calculate g(p – 1)/2. This will always be -1 or 1.
If it’s -1, g has period p – 1, which is as good as it gets.
If it’s 1, g has period (p – 1)/2. Use –g instead, which has period p – 1, unless (q, p) = (2, 5), which we reject for the same reasons as (2, 3).
By contrast, there are no fewer than 12 periods for 61, in particular x = 1, 2, 3, 4, 5, 6, 10, 12, 15, 20, 30, 60. These are the factors of (61 – 1). It is not so easy to decide where the threshold of acceptability lies (30? 12?), and it is not so easy to correct generators with small periods, or even to detect them (other than 0, 1, and p – 1, which are still trivial to avoid.)
Real cryptographic primes are of course much, much bigger than 61, but this serves as an illustration of why safe primes are called “safe”.
Okay, so I’m standing on a space station that is a rotating toroid so I experience One gravity under my feet. I’m holding a coffee cup and let it drop. Isn’t its drop going to follow a V*cos function? Unless the space station is really small it’s going to look like it accelerates at one G, but what is the force it experiences on impact?
It seems that that force won’t be the same as if it were truly accelerating. Now add a little push, in the direction of spin, and anti-spin. Won’t the behavior vary?
I’m writing a science fiction book and would like to get it right.
To answer this question, it is important to emphasize the difference between gravityper se and centripetal acceleration.
Exists between any two objects with mass Stronger between objects of large mass Stronger as objects are closer together
Keeps one object in orbit around another object Stronger as the radius of orbit increases Stronger as the time of orbit decreases
On the space station, the situation is exactly reversed. Centripetal acceleration is king, and gravity can mostly be ignored.
Let’s define a “day” as the amount of time it takes for our space station to undergo a single complete rotation. We’ll also define t as the length of the “day”, in seconds.
Let r be the radius of the space station, in meters.
We can manipulate the formula a = v2/r to relate the length of the day and the radius of the space station. Start with a = v2/r and substitute both a = 9.8 m/s2 (which is what humans on Earth are used to) and v = 2πr/t. Then do some manipulation to get:
9.8t2 = 4π2r
The radius is proportional to the square of the orbital time. That is, smaller space stations need to spin faster. The bigger the space station, the longer the day.
For story purposes, if we want a particular size, we can calculate the required length of the day. Solving for t:
t = √(4π2r/9.8) = 2.0√r
For example, a space station of radius 150 meters would need to have a day of 24 seconds; a space station of radius 1,500 meters would need to have a day of 77 seconds.
Or if we want a particular day length, we can calculate the required size. Solving for r:
r = 9.8t2/(4π2) = 0.25t2
So if we want a day to last 60 seconds, we need a space station of radius 900 m; if we want a day to last 120 seconds, we need a space station of radius 3.6 km.
The acceleration varies as you wander throughout the space station. The closer you are to the rotational axis, the weaker the effect. So things near the ceiling will be accelerated slightly less than things on the floor.
The variation will be minimal if the hole in the toroid is large; that is to say, if the ceiling and the floor are both quite far from the rotational axis.
So if the space station is large, the coffee cup will behave almost exactly as it does on the Earth. If you add a little push, the coffee cup will follow a parabolic path to the floor. If the floor is hard, the cup will break.
If the space station is small, and you had a fairly precise scale, you would notice that the cup weighs less on the top shelf than it does on the floor.
Just for fun, suppose that in addition to the inhabited toroidal part of the space station, there was a service area in the center, on the rotational axis. People would be weightless here.
Perhaps the service area is connected to the toroidal part by spokes, so that it can be reached without going outside. You would experience a gradual transition between full Earth gravity and complete weightlessness as you went along the spoke. Perhaps you have a ladder on the spoke which has rungs quite close together near the edge, where there is full gravity; and as you ascend toward the hub, the rungs get farther apart, as you move from climbing, to jumping, to swimming, to floating.
Earth accelerates you in two different directions at once. Earth’s gravity pulls you one way, and its rotation pushes you another. We consider the direction, magnitude, and variation of these forces at various points on the Earth’s surface.
Direction: gravity pulls you toward the center of the Earth.
Magnitude: if you are on or above the Earth’s surface, the pull’s strength follows the “Acceleration due to Earth’s gravity” formula from “Formulas and facts” below.
Variation: the pull’s strength is inversely proportional to the square of your distance from the center of the Earth, so long as you’re on or above the surface. The closer you get to the center, the stronger gravity is; the further away you get from the center, the weaker gravity is.
The Earth is shaped like a sphere. Well… not quite like a sphere. It’s flattened a bit, like an M&M. The “M”s are printed at the North and South Poles, and the Equator goes around the edge. This means that when you’re at the Poles, you’re closer to the center of the Earth than you are at the Equator. So gravity is stronger at the Poles, and weaker at the Equator.
Also, but to a much lesser degree, the Earth’s surface is uneven. There are bumps (mountains) and crannies (valleys.) At a given latitude, when you’re at the bottom of a valley, you’re closer to the center of the Earth than you are at the top of a mountain. So gravity is weaker on mountains. (It is tempting to say that gravity is stronger in valleys, but valleys are a little complicated, because the higher land around you pulls you in the opposite direction than the rest of the Earth. It is true to say that gravity is stronger on low-laying plains, though.)
The strongest gravity is at the North Pole, which is pretty much at sea level. (The South Pole is on a plateau.)
The weakest gravity is at the peak of Mt. Chimborazo in Ecuador.
What about Mt. Everest, you say? Well, Mt. Everest is the highest mountain above sea level, but the sea follows the M&M shape, so Mt. Chimborazo is further from the center of the Earth.
Direction: centripetal acceleration pushes you away from Earth’s axis of rotation.
If you’re at the Equator, this is straight up; if you are at the North Pole or South Pole, the only effect is to make you very slightly dizzy; and if you are somewhere in between, you can get a basic feel for the direction by looking at the nearest satellite dish.
You can get a more precise direction by knowing your latitude and compass heading:
Point an arrow straight up (that is, away from the center of the Earth.)
If your latitude is zero, you’re on the Equator. You’re done.
Bend it down, in the direction of the Equator, by an angle equal to your latitude.
If you are in the Northern hemisphere, bend it South.
If you are in the Southern hemisphere, bend it North.
The final direction of the arrow is the way centripetal acceleration is pushing you.
Magnitude: the pull’s strength follows the “Acceleration due to Earth’s rotation” formula.
Variation: the pull’s strength is proportional to the square of your distance from Earth’s axis of rotation. The closer you get to the axis, the weaker centripetal acceleration is. The further you get from the axis, the stronger centripetal acceleration is.
In particular, centripetal acceleration is strongest at the Equator. It is weakest at the Poles. (In fact, it is zero at the Poles.)
Putting the two together
Direction: gravity is much stronger than centripetal acceleration, so the sum of the two vectors always points almost completely in the direction of the gravity vector.
Magnitude: the pull’s strength follows the “Combined acceleration due to Earth’s gravity and rotation” formula. The angle between the two vectors is always between 90° and 180°, so the forces counteract each other; the total acceleration is always a little bit less than gravity alone (or, in the case of the Poles, exactly equal to gravity alone.)
Variation: because of the M&M shape, centripetal acceleration (which counteracts gravity) is strongest in the same places where gravity is already weak – the Equator, and mountains. So centripetal acceleration just exaggerates the weakness of already-weak gravity.
Here’s a table. I throw in La Rinconada, in Peru, because it’s the highest permanently inhabited place, and it’s also quite near the equator. The table has the strongest combined acceleration at the top and the lowest at the bottom.
To center (m)
To axis (m)
In conclustion, a varies across the Earth from 9.769 m/s2 to 9.863 m/s2, which is a variation of about 0.95%. About 0.84% of this comes from variation in gravity, and the other 0.11% comes from variation in centripetal acceleration.
Facts and formulas
Newton’s second law of motion F is the force applied to an object m is the mass of the object a is the acceleration experienced by the object F = ma
Gravitational constant G = 6.674e-11 m3/(kg s2)
Earth mass M⊕ = 5.9722e24 kg
Earth radius (at sea level)
At the North Pole or South Pole = 6.357e6 m
Mean = 6.371e6 m
At the Equator = 6.378e6 m
Acceleration due to Earth’s gravity G is the gravitational constant M⊕ is Earth’s mass r is the distance of the object from the center of the Earth ag = GM⊕/r2
Centripetal acceleration v is the speed of an object orbiting a fixed point r is the radius of the orbit t is the time to complete a single orbit; note that v = 2πr/t a is the acceleration experienced by the object a = v2 /r = 4π2r/t2
Nominal time for one solar rotation: 24 * 60 * 60 = 8.6400e4 s
Actual time for one solar rotation: a teensy bit more due to leap seconds
Actual time for one sidereal rotation: T⊕ = 8.6164e4 s
Acceleration due to Earth’s rotation r is the distance between the object and the Earth’s axis of rotation (not the center of the Earth) T⊕ is the time for one sidereal rotation ar is the acceleration experienced by the object ar = 4π2r/T⊕2
Vector addition a is a vector b is another vector θ is the angle between a and b when placed tail-to-tail |a + b|2 = |a|2 + |b|2 + 2|a||b|cos θ
Combined acceleration due to Earth’s gravity and rotation ag is the acceleration due to Earth’s gravity ar is the acceleration due to Earth’s rotation L is the latitude of the object, in degrees; the angle of the two vectors in radians is π – (πL/180) a is the combined acceleration |a|2 = |ag|2 + |ar|2 + 2|ag||ar|cos (π – (πL/180))
Usually my approach is to learn techniques using Techcopy.
But Irga’s Wither Tackle 3 and Super Goalie are both locked until she learns at least one key technique (or maybe two.)
Which means I’m looking at Pile Wither…
… but Pile Wither cannot be Techcopy’d.
So in order for Irga to achieve her full potential, I need to either:
Win Pile Wither in a tournament and award it to her
Win Tech Find in a tournament and use it to unlock either Wither Tackle 3 or Super Goalie for her, so she can Techcopy it later
Release her as a free agent and hope some other team helps her learn a key technique
I am unwilling to release her because I like having her on my team. So I’m looking at the “win Pile Wither” or “win Tech Find” approaches. Luckily, these can be tried in parallel.
The “win Pile Wither” approach is straightforward.
But for the “win Tech Find” approach to work, I need to know where Wither Tackle 3 and Super Goalie are on the list of techniques.
That is, I need a map of the techniques.
I built up my recruiting skill to maximum level and chatted up all the players on my team (and a couple of people not on my team who happened to be nearby) and got a pretty good map, which follows. The techniques marked with question marks are just guesses based on the pattern and fuzzy memories of previous games I’ve played:
If you pair the device, you can look in Device Manager for the “Bluetooth class of device” property. Here’s a screenshot showing the class of device for the E7 headset paired with my Windows system:
To parse the hexadecimal value 0x00240404, truncate it to 24 bits and rewrite it in binary first: 0010 0100 0000 0100 0000 0100. Then number the bits as follows: (bit 23) (bit 22) (bit 21) … (bit 3) (bit 2) (bit 1) (bit 0)
The eleven bits 23 through 13 inclusive are the “major service class.” This is set to 001 0010 0000. In particular, bits 21 and 18 are set. Bit 21 is defined as “Audio” and bit 18 is defined as “Rendering”.
The five bits 12 through 8 inclusive are the “major device class.” This is set to 0 0100 which is defined as “Audio/Video”.
The six bits 7 through 2 inclusive are the “minor device class.” This is set to 00 0001. For the major device class “Audio/Video”, this is defined as Wearable Headset Device, which is the kind of audio device this is.
(The final two bits 1 through 0 inclusive are undefined.)
The Bluetooth A2DP profile driver btha2dp.sys translates the “Wearable Headset Device” minor class of device to a KSPIN_DESCRIPTOR.Category value of KSNODETYPE_HEADPHONES.
The Bluetooth Hands-Free profile driver bthhfenum.sys translates “Wearable Headset Device” to KSNODETYPE_HEADSET.
Many built-in sound cards and graphics cards follow the Intel High Definition Audio Specification 1.0a (PDF). (Note that “Intel High Definition Audio” is the name of the specification – the audio device does not need to be made by Intel, it just needs to follow the spec Intel published.)
In Intel High Definition Audio-speak, the “kind of device” is called a “Default Device.” It is defined in section 188.8.131.52 Configuration Default.
This is a 32-bit register which is written by sound card manufacturer or the OEM as part of the BIOS or UEFI definition. The bits are numbered bit 31 through bit 0. The four bits 23 through 20 inclusive are used for “Default Device”. To quote the spec:
Default Device indicates the intended use of the jack or device. This can indicate either the label on the jack or the device that is hardwired to the port, as with integrated speakers and the like. The encodings of the Default Device field are defined in Table 111.
Intel High Definition Audio Specification 1.0a section 184.108.40.206 Configuration Default
Table 111. Default Device
Line Out – 0h
Speaker – 1h
HP Out – 2h
CD – 3h
SPDIF Out – 4h
Digital Other Out – 5h
Modem Line Side – 6h
Modem Handset Side – 7h
Line In – 8h
AUX – 9h
Mic In – Ah
Telephony – Bh
SPDIF In – Ch
Digital Other In – Dh
Reserved – Eh
Other – Fh
The Microsoft High Definition Audio class driver hdaudio.sys reads the Configuration Default register, looks at the Default Device, and transforms that into a KSPIN_DESCRIPTOR.Category value. For example, “HP Out” becomes KSNODETYPE_HEADPHONES.
At one time Microsoft had a High Definition Audio Utility (HDAU.exe) which you could use to see the configuration default for the Intel High Definition Audio device in your system. It used IOCTL_AZALIABUS_SENDVERBS to query the Configuration Default register from the Microsoft Intel High Definition Audio class driver hdaudio.sys.
The IOCTL_AZALIABUS_SENDVERBS IOCTL is used by the Hdau.exe pin configuration tool when you define sound topologies for your audio adapters… This IOCTL is supported in the Windows 7 Hdaudio.sys audio class driver.
Communicating Verbs with the HD Audio Codec
Alas, this utility is defunct.
The Hardware Logo Kit (HLK) comes with UAA Test, which (among other things) helps to validate configuration default settings for Intel High Definition Audio devices.
In USB Audio-speak, the “kind of device” in question is called a “terminal type.” Each of the USB Audio specifications includes the USB Audio Terminal Types specification by reference. for example:
USB Audio 1.0 section 220.127.116.11.4 Headphone Input Terminal ID10 Descriptor says Allowed values for the wTerminalType field can be found in the Audio 1.0 Terminal Types Specification.
USB Audio 2.0 section 18.104.22.168 Output Terminal Descriptor and USB Audio 3.0 section 22.214.171.124 OUTPUT TERMINAL DESCRIPTOR both say A complete list of Terminal Type codes is provided in a separate document, USB Audio Terminal Types that is considered part of this specification.
Terminals can be input, or output, or bi-directional, or… well, a couple other things. Each version of the terminal types specification has a list for each of these. For example, here’s the list of bi-directional terminal types from the USB Audio Terminal Types 3.0 spec:
Bi-directional Undefined – 0x0400
Handset – 0x0401
Headset – 0x0402
Speakerphone, no echo reduction – 0x0403
Echo-suppressing speakerphone – 0x0404
Echo-canceling speakerphone – 0x0405
Microsoft provides a USBView tool which can show you the USB descriptor for any USB device. Here’s a screenshot showing the USB audio terminal types for the USB audio device on my desk:
Windows’ USB Audio class driver reads the terminal type from the descriptor, converts it to a Kernel Streaming pin category GUID as listed in ksmedia.h, and reports it to Windows via the KSPIN_DESCRIPTOR for the pin factory corresponding to the terminal.