Can a DLL compiled to 32-bit not be invoked by the original 64-bit program?

Asked 1 years ago, Updated 1 years ago, 79 views

I wrote DLLs through C language and Visual Studio 2017. It's no problem making it x86, and somehow putting it on another C project.

I'm trying to call this from Python using ctypes, but it keeps... stretching?

I can't show you because the error message is broken strangely, but I thought about it for a second.

Python version is for 64-bit,

DLL is to get the whole "already compiled section",

So suddenly jumping from x64 to x86 is logically impossible in the first place Not only Python, but also all programs can't use a bit number of dlls that are different from theirs...I think it's going out too much...

Please give us your views on this.

Can DLLs be invoked independently of the number of bits? Or is it possible to call DLL only when the architecture is the same?

dll

2022-09-22 19:58

1 Answers

It's not a topic that can be described briefly first.

The extensions exe, dll, sys are called PE files in x86 windows and PE+ or PE32+ in X64 windows.

As the name is different, the two are not compatible. This means that 32 bits can be used between 32 bits and 64 bits can be used between 64 bits.

When dll is loaded, it is registered once in physical memory and mapped to the virtual address of the process.

This means that even if multiple processes load the same dll, physical memory only loads once and maps to the virtual memory address for each process. In user mode, you can never handle physical memory (kernel memory) directly.(However, this time, it is possible due to CPU vulnerability)

What's important here is that the file that we use called exe has a format. The dll and functional addresses that exe will call are stored in a structure called the Import Address Table (IAT) (this address size will vary by 32 bits and 64 bits).)

Now the process here has 32-bit address space, and the dll with 64-bit address space obviously can't load. The same goes for the opposite.

If you study PE file, you will understand a lot. Focus on IAT, PE32+ Try learning format.


2022-09-22 19:58

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.