Recent

Author Topic: what is Erro Code 0xc000007b ?  (Read 11550 times)

senglit

  • Full Member
  • ***
  • Posts: 131
what is Erro Code 0xc000007b ?
« on: July 30, 2019, 07:24:53 am »
Hi all,

I wrote a application on win7/32bit system. It works well. Then I copied the source files to a win7/64bit system and compiled it to run. But after it's smooth compling and linking, the application did not run. A dialog showed to say "Application can not run (0xc000007b), please click "ok" to close it".

I checked the project configuration and the "Target OS", "Target CPU Familiy" are both "Default". And I can see a folder named "lib\x86-64-win64" was created automatically under my source file folder. Everything looks normal, but the application didn't run, even when I double click the generated .exe file.

How to solve this problem?

Roy
I use Win10 + Lazarus 2.2.0 + FPC 3.2.2. All 64bit.

Thaddy

  • Hero Member
  • *****
  • Posts: 16151
  • Censorship about opinions does not belong here.
Re: what is Erro Code 0xc000007b ?
« Reply #1 on: July 30, 2019, 07:36:13 am »
Usually this means you should run the application with elevated rights, e.g. administrator. At least that's where I encountered it the most.
Plz report back if that works. In such a case you can add a manifest resource to your application with the requested rights, so you don't need to run it as administrator explicitly.

There are more causes, though:

1. This error occurs due to lack of some system or program files that include DDL files.
2. It also occurs when the file could be damaged, to run the application or the software that can’t start correctly.
3. At the same time, it may also happen due to virus infection, registry errors, etc.
4. There are chances to see this type of errors 0xc000007b error while you are not running the software as administrator.
5. Outdated Microsoft .NET Framework or Microsoft Visual C++ is one of the reasons to cause this type of error.
6. Even when you migrate from Windows 7 to Windows 8, 8.1 or Windows 10, then you see this error when launching the old applications.
7. However, there is also another reason that may cause this Error Code 0xc000007b that include interrupted installation of updates, the incorrect shutdown of the computer, as well as deletion of the program directly from the installation folder.
8. Wrong dll version, although that usually comes with a more descriptive error.
9. Sometimes by this error codes effect may differ from one app to other and hence, it may block access to apps like Skype, Messenger, Microsoft Office package and even any game.
« Last Edit: July 30, 2019, 07:47:13 am by Thaddy »
If I smell bad code it usually is bad code and that includes my own code.

senglit

  • Full Member
  • ***
  • Posts: 131
Re: what is Erro Code 0xc000007b ?
« Reply #2 on: July 30, 2019, 07:40:58 am »
It seems not related to the administrator right, but something related to a 32bit dll file I used in the application. I do not have a 64 bit version or the source file of that dll file (writen in C language). Any solution?
I use Win10 + Lazarus 2.2.0 + FPC 3.2.2. All 64bit.

Thaddy

  • Hero Member
  • *****
  • Posts: 16151
  • Censorship about opinions does not belong here.
Re: what is Erro Code 0xc000007b ?
« Reply #3 on: July 30, 2019, 07:44:45 am »
I edited my answer above to describe all possible causes.
Note you can not use a 32 bit dll with 64 bit applications (without thunking, that is), but I expect you already understood that.
OTOH this  "lib\x86-64-win64"  suggests you compiled for 64 bit.  You should compile for 32 bit. (Isn't it  "lib\x86_64-win64" ? note the underscore)
« Last Edit: July 30, 2019, 07:54:40 am by Thaddy »
If I smell bad code it usually is bad code and that includes my own code.

440bx

  • Hero Member
  • *****
  • Posts: 4727
Re: what is Erro Code 0xc000007b ?
« Reply #4 on: July 30, 2019, 07:57:48 am »
It seems not related to the administrator right, but something related to a 32bit dll file I used in the application. I do not have a 64 bit version or the source file of that dll file (writen in C language). Any solution?

From MSDN
Quote
0xC000007B

STATUS_INVALID_IMAGE_FORMAT

{Bad Image} %hs is either not designed to run on Windows or it contains an error. Try installing the program again using the original installation media or contact your system administrator or the software vendor for support.
There is probably a setting incompatible with another one that causes the compiler to produce an executable the Windows loader will not load.

From the description you provided in your original post, the likely contradictory setting is the "Target Processor", change that to "default" as well, recompile and try again.

ETA:

Another possibility is that your 64bit program is trying to load a 32bit dll (the dll you mention is written in C), in that case, just make sure the dll being loaded matches the bitness of your executable.

Also, you are correct that, that error has nothing to do with elevated rights or administrator rights.
« Last Edit: July 30, 2019, 08:02:58 am by 440bx »
(FPC v3.0.4 and Lazarus 1.8.2) or (FPC v3.2.2 and Lazarus v3.2) on Windows 7 SP1 64bit.

Thaddy

  • Hero Member
  • *****
  • Posts: 16151
  • Censorship about opinions does not belong here.
Re: what is Erro Code 0xc000007b ?
« Reply #5 on: July 30, 2019, 08:16:12 am »
The latter is not true. It can be caused if the image or one of the components used (dll, ocx) has insufficient rights to run. That would make it an invalid image for user mode context.
To debug, read this tech blog:
https://blogs.msdn.microsoft.com/dsvc/2017/09/20/diagnosing-status_invalid_image_format-c000007b-errors/

But I give you that this is not immediately obvious from the MSDN entry itself. MS uses it sometimes as a kind of catch-all, even if their own messages have more descriptive alternatives.
This information is from Microsoft tech support itself. Their solution - in our case - was to advise to add a proper manifest.

This error is basically one that appears if it happens to propagate first.

A complete list is here: https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-erref/596a1078-e883-4972-9bbc-49e60bebca55 but note my remarks, that can also be found on msdn.
It is well within the interpretation of invalid image. Although I think that is not the case here. I also suspect bitness mix-up.
« Last Edit: July 30, 2019, 08:31:16 am by Thaddy »
If I smell bad code it usually is bad code and that includes my own code.

440bx

  • Hero Member
  • *****
  • Posts: 4727
Re: what is Erro Code 0xc000007b ?
« Reply #6 on: July 30, 2019, 08:31:33 am »
It can be caused if the image or one of the components used (dll, ocx) has insufficient rights to run. That would make it an invalid image for user mode context.
Do you have an article from a credible source to support that statement ? ... if you do, I'd like to read it.
(FPC v3.0.4 and Lazarus 1.8.2) or (FPC v3.2.2 and Lazarus v3.2) on Windows 7 SP1 64bit.

Thaddy

  • Hero Member
  • *****
  • Posts: 16151
  • Censorship about opinions does not belong here.
Re: what is Erro Code 0xc000007b ?
« Reply #7 on: July 30, 2019, 08:37:54 am »
I have many, but start here https://getalltech.com/how-to-fix-error-code-0xc000007b-windows-7-64-bit/ which is a quite reputable third party source.
Or this: https://errorcodespro.com/fix-error-code-0xc000007b-windows-7-10/
I will look up the msdn entries related. See also the msdn blog.
« Last Edit: July 30, 2019, 08:44:42 am by Thaddy »
If I smell bad code it usually is bad code and that includes my own code.

440bx

  • Hero Member
  • *****
  • Posts: 4727
Re: what is Erro Code 0xc000007b ?
« Reply #8 on: July 30, 2019, 08:53:00 am »
I do have to give you credit for providing some links that support what you stated.
(FPC v3.0.4 and Lazarus 1.8.2) or (FPC v3.2.2 and Lazarus v3.2) on Windows 7 SP1 64bit.

BosseB

  • Sr. Member
  • ****
  • Posts: 473
Re: what is Erro Code 0xc000007b ?
« Reply #9 on: March 31, 2023, 05:26:51 pm »
Found this when searching for an explanation to the erroir code I am getting when building then running the examples from this github IPC project, which uses a unit provided with FPC itself.

I have started a thread on using IPC communication on this forum. The replies steered me to the GitHub project linked above.

So I retrieved the project and built its target dll and then the demo-lazarus projects with a simple client and a server.
All using Lazarus 2.2.4/Fpc 3.2.2 on Windows 10 x64.

No matter what I do I get the error 0xc000007b when I try to start the server but not the client, both using the same dll compiled as step 1.

I wonder if there was a solution to this problem found in this thread?
--
Bo Berglund
Sweden

Thaddy

  • Hero Member
  • *****
  • Posts: 16151
  • Censorship about opinions does not belong here.
Re: what is Erro Code 0xc000007b ?
« Reply #10 on: March 31, 2023, 06:18:07 pm »
No matter what I do I get the error 0xc000007b when I try to start the server but not the client, both using the same dll compiled as step 1.

I wonder if there was a solution to this problem found in this thread?

You implicity gave the answer yourself: rights, security. A client needs less rights, a server needs more rights.
Simple.

Also, a server needs to be up to date, a client may lag behind.
Protocols.

Came to mind a really stupid question this week, which got really nice - patient - answer.
( I will ask Remy to drop anything below TLS 1.2 anyway. I have no patience)
« Last Edit: March 31, 2023, 06:25:35 pm by Thaddy »
If I smell bad code it usually is bad code and that includes my own code.

 

TinyPortal © 2005-2018