Pretty much from the moment, personal computers go into our lives we see a specific type of programs that claim that they will improve performance. Modern versions of these programs promise to have more free memory, registry cleaner, and performance optimizations.

So far I haven’t seen any such program that does anything good. Moreover, most of them do bad things that look like good things. Let’s start with programs that make more free memory.

If you open Task Manager and then go to the “Performance” tab you will see “Free” or “Available” memory. And after you run a program that promises to free more memory, you will see that this number increases. Sometimes it increases by a lot. As a

The previous part is here. In this part, we will investigate more exotic cases of intercepting function calls.

VMT for Case 1

VMT stands for virtual method table. VMT is created by the compiler when the class introduces a virtual method or overrides one from any parent class.

Finding VMT depends on the language and the compiler, so I will not explain it here. For most languages, the first 4 bytes in x86 or 8 bytes in x64 points to VMT. Then you need to know where is pointer to the function is in this table.

Then you need to save this address somewhere. Then write a different address into VMT using the WriteProcessMemory function. After that,

In the previous part, I explained certain issues in Example 2 for all types of cases: multithreading issues, and issues with recursive calls. Also must state that there is also a cost involved in calling the WriteProcessMemory function twice each call to the XYZ function. If the XYZ function is called often then we will have a performance hit. But is there anything we can improve? And it turns out that we can for Case 1.

Example 3 for Case 1

The main idea for this case is to call the WriteProcessMemory function only once. And when we need to call the original function we need to simulate instructions that were overwritten with jump instruction

Why

There are times when you want to change the behavior of a function that you cannot recompile for some reason. For example, there could be a bug in a runtime function of your language. Changing the version of your language is typically quite a challenge and it could be much better to patch that function instead of making drastic changes like switching to a different version.

Or as another example, there could be some 3rd party library that has a bug and the author didn’t provide a source code. Or perhaps you want to do some pre or post-processing. For example, you may want to save some input or output parameters or even modify them.

For further discussion let's

Disclaimer: I have no financial or any other interest in this or any other products mentioned in this review. I review this product because I really like it.

Typically at home, I use relatively cheap headphones to listen to music, play computer games, and discuss stuff over Zoom or any other applications. Typically I buy something in the range of $25-$35.

Last several years I have been buying Koss multimedia headphones (SB45 or SB49). They cost around $32 and to the most degree, they were fine. But they have a few issues that eventually start to annoy me.

The most common issue is that, after some time fake leather starts to peel from head cups and stick to the skin

People don’t need electric vehicles anymore and the EV revolution is over. People don’t want EVs, they want hybrids. This is exactly the statement that mass media are trying to push to consumers.

But this is quite far from the truth. People still want EVs, but unfortunately, while demand is strong, the proposition is quite weak for each market segment except the most expensive one. And even in expensive segment proposition is quite bad.

But before I explain why, I must state that in most cases you want to buy an EV only in case you have a house or any other reliable place to charge it. Otherwise, it will be an unnecessary pain for your money.

If you try

I was never a fan of Intel for quite a simple reason – buying Intel chips was not optimal from my point of view. Other companies provided a better performance-to-price ratio. But I understand that nobody can tell any company how much money they should ask for their products and it is strictly up to them. If Intel wants to sell their processors for a lot of money it is their business. But in general, they were making good and solid products.

But everything changed from the release of Pentium 4. At that time Intel figured out that everybody was buying megahertz they decided to create a CPU with a lot of megahertz. And then Pentium 4 was born.

It

JavaScript is one of the languages that wasn’t designed properly. In fact, it wasn’t designed at all. It was an afterthought that just slapped into the browser to have some kind of programming. And because Java was a hot subject at that time, it got Java in its name. It has absolutely no relation to Java, except for some syntax similarity and garbage collection.

There were a lot of attempts to make it better and it has become better but it still has all the fundamental issues that almost all script languages have – lack of type system and that makes it unusable to write anything big or complex.

In a language with the type system compiler knows the type

  •   Posted in:
  • .NET

The previous part is here.

And finally, we are in the most important part which explains what works differently between the .NET Framework and .NET 6. Just in case I will talk about behavioral changes and about obvious parts like some methods that do not exist in .NET 6 but I will

  1. The .NET Framework will suppress all exceptions when it releases a reference to a COM object but .NET 6 will crash. One example of such a problem is when some object is freed despite having a reference count of more than zero. It is a bug and needs to be fixed. I just was surprised by how often it happened in our application.
  2. Accessing .NET from DllMain will lead to deadlocks. We had these in the .NET Framework, but they happened much more often in the .NET 6. And obviously, it needs to be fixed. It will take some time because it works most of the time and deadlock happens quite seldom.
  3. string.GetHashCode will return different values every time you start the application. Basically during startup runtime will generate a random seed and add it to the hash code. If you want hash code to persist then write a function that hashes string differently.
  4. When the application converts a floating point number to a string, the result will be slightly different. Here blog post that explains the changes. For example, when the .NET Framework outputs 3.1415, .NET may output as 3.141500001 or 3.141499999.
  5. Encoding.Default will be always UTF8 in .NET 6. If you want to return old behavior then you need to create Encoding from the current Windows code page.
  6. System.Diagnostics.ProcessStartInfo.UseShellExecute is true for .NET Framework but false for .NET As a result, previously it was possible to open the http link without changing properties but now UseShellExecute must be set specifically to true.
  7. Previously it was possible to bind to read-only property in WPF. Now it throws an exception and you need to add “, Mode=OneWay”.
  8. SHA512.Create("System.Security.Cryptography.SHA512CryptoServiceProvider") will return null. We replaced it with new SHA512CryptoServiceProvider().
  9. There is no SHA512Cng class. We replaced it with SHA512CryptoServiceProvider class that uses SHA512Cng internally when the application is running for Windows.
  10. Setting SecurityProtocolType.Ssl3 will throw an exception.
  11. Some controls were removed from WinForms. For example ContextMenu. They were replaced with a set of different controls quite some time ago but our code used an old version for some reason.
  12. In the .NET Framework, your application can load assembly A 2.0.0.0 from the application directory. Later it can load assembly K located in a different directory and assembly K can load assembly A version 1.0.0.0 from the same directory that contains assembly K and it will work. This will fail in the .NET 6 because another version with a higher version is already loaded. To fix this you will need to use AssemblyLoadContext.
  13. If you are using different assembly versions in WPF then it will work properly. You will have to rename assemblies to include the version in the assembly name. I spent quite a bit of time on this and I didn’t find any better way.
  14. If you are enumerating over HashSet sometimes it will contain elements in a different order in .NET 6. We found that during tests. But HashSet does not guarantee the order so it was an issue on our side.
  15. string.Compare("C-O", "CA") will return 1 for the .NET Framework and -1 for .NET 6. It is because Microsoft changed how comparing works to have the same result for all platforms. Previously it used Windows API for this.