Share this article

Improve this guide

How to Fix ERROR_INVALID_BLOCK in Function Detours

Make sure that the function is large enough for the detour

3 min. read

Updated onSeptember 4, 2024

updated onSeptember 4, 2024

Share this article

Improve this guide

Read our disclosure page to find out how can you help Windows Report sustain the editorial teamRead more

For fixing Windows errors, we recommend Fortect:

Fortect will identify and deploy the correct fix for your Windows errors. Follow the 3 easy steps to get rid of Windows errors:

Dealing with the ERROR_INVALID_BLOCK issue can be quite a headache for developers, especially when working with function detours. It usually comes accompanied by the9 (0x9) The storage control block address is invaliderror message.

How do I fix ERROR_INVALID_BLOCK?

How do I fix ERROR_INVALID_BLOCK?

1. Ensure the target function is large enough to be detoured

This ensures that the function is large enough for the detour to attach properly and prevents the ERROR_INVALID_BLOCK error from occurring.

2. Initialize the target function pointer correctly

This avoids the ERROR_INVALID_BLOCK by ensuring that the function pointer is set up correctly before attaching the detour.

3. Use DetourTransaction API correctly

Here’s an example of using DetourTransaction API:

This ensures that the detour is part of a transaction and helps in orderly attaching and detaching of detours, preventing errors.

4. Check for memory availability

Ensuring that there is enough memory available prevents the ERROR_INVALID_BLOCK error due to memory constraints.

5. Verify the integrity of the function being detoured

Ensuring the integrity of the target function prevents errors related to function size or corruption.

6. Handle special cases in automation calls (VBA/COM)

For example, using the correct type in a VBA call:

This method ensures that the argument types match the function’s expectations, preventing block errors.

By following these solutions, you can effectively address the ERROR_INVALID_BLOCK error in your detour operations and ensure smooth and error-free function hooking. Always remember to check your function sizes and memory availability to prevent such issues in the future. You can also learn how to resolve a similar issue,CNSS_FILE_SYSTEM_FILTER.

Did you manage to fix the ERROR_INVALID_BLOCK issue? Let us know in the comments below.

More about the topics:Error Code,Programming tools and tips

Claudiu Andone

Windows Toubleshooting Expert

Oldtimer in the tech and science press, Claudiu is focused on whatever comes new from Microsoft.

His abrupt interest in computers started when he saw the first Home Computer as a kid. However, his passion for Windows and everything related became obvious when he became a sys admin in a computer science high school.

With 14 years of experience in writing about everything there is to know about science and technology, Claudiu also likes rock music, chilling in the garden, and Star Wars. May the force be with you, always!

User forum

0 messages

Sort by:LatestOldestMost Votes

Comment*

Name*

Email*

Commenting as.Not you?

Save information for future comments

Comment

Δ

Claudiu Andone

Windows Toubleshooting Expert

Oldtimer in the tech and science press, with 14 years of experience in writing on everything there is to know about science, technology, and Microsoft