I have a application that spits out the same error each time i do something specific:
Exception EListError in module foo.exe at 000277CF.
List index out of bounds(0)
(Physical address: XXXXXXX)
As a programmer I would love it if there were a way I could open it up and pinpoint the orgin of the error to the developers.
Would that be possible? I know the language and it's a mix of .NET and with some old Delphi code.
Any want to point me in the right direction? Tutorials? Programs to use?
The EListError exception seems indicate which the executable is a delphi app, Now Is not possible retrieve the original source code from a Delphi Win32 application, because the variable names, methods, parameters and addtional elements are converted to memory address and are lost when the executable is created. So the original code cannot be recreated.
You best option is use a decompiler like IDA to disassemble and debug the exe and determine the location of the issue and then you can create a patch to fix that, but this task is not easy and requiere a lot of knowledge about the pe structures, memory address location and assembly.
Also in your question you mention the posibility which the application is a mix of .net code and delphi code, if that is the case you can use reflector or Telerik JustDecompile to retrieve the original source code.
Related
In our team new programmers does not get access to all the source of our application.
As long as they have to access program forms that depend only classes they can access the source, all is ok. When they have to use other classes from units they have only the .dcu, they get the F2051 error when the classes in the dcu change their interface.
Is there a clean way to get both ?
possibility to hide part of the source from new programmers
avoid the F2051 error when the classes in the "hidden" units change
I searched for a way to compile the Delphi code to a intermediate representation the way to hide the sources but to permit compilation, but I did not find anything.
You have to compile the code after the interface changes, and distribute the new .dcu to each programmer that needs to use it without source, and then they need to rebuild their applications. There is absolutely no other way to do it; the compiler requires it if there are changes in the interface.
For those "hidden" units, put the .dcu in the source control along with the .pas and make sure they are updated and in sync.
The "authorized" developers will fetch the new .pas, while the underlings will only see and fetch the .dcu.
If you really want to go that route of having 2nd class programmers, you have to do the management work that go with it.
That being said I'm personally more often that not stepping into the VCL source code when chasing a bug and trying to understand what's going on.
And I really don't like not having it (like with some low level Delphi SKU)
If you really want to create a stable binary unit that you can share with people you don't trust to read your source code, why don't you put the "secret" bits into a DLL and then load that DLL from the rest of the code.
It's called an "Application Binary Interface", either done natively with plain old pascal procedures exported from a DLL, or with COM Interfaces and a COM type-library.
Delphi has both DLL and BPL technology, to help you create something that isn't source code, but which has a stable ABI, and which will help you avoid whatever crazy little mess it sounds like you've got on your hands right now.
In our program we are using a web service to pull back data from a third party into our program.
Ever since we updated to Delphi XE from Delphi 2009, Windows server 2003 users are receiving the following error message when making a SOAP call to the web service.
msvcrt.dll on Server 2003 does not have the procedure _ftol2_sse which is now being called for some reason..
I know this procedure was not being called when we had our source code on Delphi 2009 because I don't get this error on Windows server 2003 when running those builds.
Is this feasible? Could a change in the IDE affect which dll procedures are being called? Does anyone have any insight or ideas on how I might track down or fix this error?
Thanks
This is the third similar question you have asked on this topic. I'll attempt to give you some background information and help you work out what is going on.
First of all it's important to know that msvcrt.dll is a system component. It is not the MSVC runtime. It is supplied as part of Windows. Back in the bad old days, in the mid-90s, a lot of devlopers assumed that the MSVC6 runtime was always available. And they neglected to install that runtime as part of their program's installation. This occasionally caused trouble when the install program happened to find a machine without MSVC6.
The MSVC team moved to differently named runtime DLLs, msvcrt70.dll, msvcrt80.dll and so on. And they educated the developers that installing the MSVC runtime should be part of all MSVC application's installation programs.
But the Windows team wanted to help out legacy apps that had installers that assumed MSVC6 runtime was available. So they took the MSVC6 runtime under their control and started shipping it with Windows. I think this started around the time of Windows 2000 or XP.
The point I am trying to make is that msvcrt.dll is a system DLL over which you have no control. In your previous questions you have described your attempts to modify that DLL. Don't do that.
Now, from what I can glean, the version of msvcrt.dll that shipped with 2003 server does not export a function named _ftol2_sse. Hardly surprising since SSE floating point was not widely available back in the days of 2003 server. Clearly something in your system is resulting in an attempt to import _ftol2_sse.
You should be able to work out what is provoking this by using Dependency Walker. Use the functions on the Profile menu to start your application and study closely the logs. You should be able to see the chain of events that lead to an attempt to link to _ftol2_sse.
I'd be surprised if any of the Windows code linked to msvcrt.dll. That library is provided purely as a prop for legacy apps that link against MSVC6. But you never know.
Also try loading your executable in Dependency Walker. Look at the list of imported DLLs. Check to see if msvcrt.dll is in the list. If so, see what functions your executable imports, and if _ftol2_sse is in that list. If so then you'll be able to find it somewhere in the Delphi source code.
From the various similar sounding reports on the web I suspect that the problem you face is benign. Many of the people reporting the same issue can OK the dialogs and have their program continue without problem. This suggests that you can simply suppress the error reporting and so solve your problem. Use the SetErrorMode function to do so. You want to include the SEM_FAILCRITICALERRORS flag.
Be aware that SetErrorMode has a rather perverse interface. Almost all code that I have ever seen uses it incorrectly. Including the code in the Delphi RTL, and so many of the commonly used Delphi third party libraries. Raymond Chen, as usual, explains how to use it correctly.
Could switching compilers provoke the behaviour change? Certainly they could. Either the library code that you are using is implemented differently. Or perhaps the error mode is somehow different at the crucial moment.
I tried to copy and paste a component from one data module into another in Delphi XE2. The component was a Fast Report data source link component. The data module was brand new, just created that second, in XE2.
Someone else had the same problem and reported it on quality central as 106369 and same error message leading me to this mysterious DocWiki entry.
So data modules now have a framework affinity, and a designtime-only pseudo property, which according to the docs:
"Because the ClassGroup pseudo-property is used only by the IDE and is not a compiler-generated property (hence, 'pseudo-property'), ClassGroup is not documented in the compiler-generated Libraries Reference. The page you are reading is the documentation for ClassGroup."
So, the first time I even learn this exists is when it blocks me from copy and pasting components into my data module from an existing set of designtime building blocks that I didn't wish to rebuild from scratch.
Once I change the data module affinity, I can paste stuff into data modules without it bugging me. Thank goodness for Google-that-error or I'd be stuck.
If it is intended to help us write cross platform data modules, and yet it only affects the IDE, according to the documentation, that's inconsistent with the warning that you get when you play with this at designtime, here's the error you get if you change it:
EInvalidType : The following component(s) are not available in the specified
class group. This is likely to cause compile or runtime errors.
frxDBSet.TfrxDBDataset.
What I can't see is how that error message can be correct, and the documentation can also be correct.
The warnings seem to suggest compile, link, and runtime errors if this is set incorrectly. Curious minds who want to know what's really going on, want to know: What is this thing about and why did it get added to the data modules in XE2. I anticipate other people will stumble upon this weird feature, with the feeling that they've stepped in something like dinosaur droppings, and want to know what is up with this feature.
My best answer at this point is that a data module affinity for TPersistent which means, in XE2 lingo, that this data module doesn't want non-visual controls in it, that are VCL-specific. In a future version of Delphi, perhaps a similar marker would allow us to mark forms as being "clean of dependencies on the VCL or windows" too?
Update 1: The .PAS source code of your data module stores this pseudo-property in a way that looks a bit like a compiler directive, like this:
implementation
{%CLASSGROUP 'Vcl.Controls.TControl'}
I think it is pretty obviously what its intended use is for, and the documentation you link to is pretty extensive about that purpose.
It is meant to prevent VCL-only components from being placed on a FireMonkey-accessible DataModule, and vice versa.
Since TDataModule is initially framework-neutral, only framework-neutral components can be placed on it.
So obviously, your source DataModule has a different affinity than your new DataModule, which is why copy/paste does not work until you change the affinity of the new DataModule to match the affinity of the source DataModule.
When an EXE raised an exception message like "access violation at address XXXXXXXX...", the address XXXXXXXX is a hex value, and we can get the source code line number that caused the exception, by looking at the map file. Details below (by madshi at EE):
you need to substract the image base,
which is most probably $400000.
Furthermore you need to substract the
"base of code" address, which is
stored in the image nt headers of each
module (exe/dll). It's usually $1000.
You can check which value it has by
using the freeware tool "PEProwse
Pro". It's the field "Base Of Code" in
the "Details" of the "Optional
Header". You'll also find the image
base address there.
My question is: How to get the source line number for a DLL? Does the same calculation apply? Thanks!
Note 1: the map file is generated by Delphi and I'm not sure if this matters.
Note 2: I've been using JCL DEBUG but it couldn't catch the exception which seems occurred at the startup of the DLL (an Office add-in, actually).
Same calculations apply, with the following note: instead of image base address of EXE you'll need to take actual address where DLL had been loaded. Base of code for a DLL should taken in the same manner as for EXE (stored in PE's IMAGE_OPTIONAL_HEADER).
Btw, EXE and DLL are actually the same thing from the point of view of PE format.
Two binaries can not be loaded at the same address. So the image base address stored in the DLL/EXE is only a suggestion for which the binary is optimized. Where the binary actually gets loaded into memory depends on many factors, like other binaries loaded in the process first, Windows version, injected 3rd party dlls, etc.
As suggested you can use a debugger or a tool like Process Explorer to find out at what address the DLL is loaded at that time. Or if you want to know from code you can by getting the HInstance or HModule from the DLL since both are the same and are the address in memory the DLL is loaded at. Delphi gets you the HModule for other DLL's through the GetModuleHandle method. Newer Delphi versions also have other methods to find HInstance.
in C# you can easily open an assembly (just another word from an EXE) and then get reflection information from that assembly. I've been looking for something similar for Delphi where I can write a Delphi program that can point to a Delphi EXE then get me reflection information. How can I archive this? Thanks
There are a handful of programs that can extract RTTI from Delphi programs and DLLs. It's not as rich as what's available for .NET, but it can be done to a limited degree. There's a lot more RTTI available in Delphi 2010 and later versions, but as far as I know there's no program out yet that can extract info from them.
I was at the conference where this system was formally announced, and a bunch of people asked how this would affect security. Barry Kelly, who created the new RTTI, said that there would not be enough metadata available to create a "Delphi Reflector".
Well, sad news is, you probably can't. You can easily view .NET assemblies because they a) are compiled to what is called intermediate language (thus you can even get the code back using the likes of Reflector etc.), and b) contain metadata. Delphi, on the other hand, compiles to native code that and produces regular PE files that do not include rich metadata like a .NET assembly.
Delphi just doesn't work that way.
There are tools that can assist in reversing (Delphi written) executables but it will never be easy and it requires good x86 assembly knowledge.
Some examples of such tools are:
IDA Pro and/or Hex Rays
DeDe
Interactive Delphi Reconstructor
PE Explorer
The resource sections of a Delphi Executable also reveals usefull info like the form and it's components.
See also Is there a program to decompile Delphi?
If you have Delphi2010+ you can load a bpl and then use the rich rtti over it lik. e you do with c# and a .net assembly. If you need to do this in a .exe AFAIK you can't.
TestComplete seems to identify most objects in a running Delphi executable. You can extract this information with a script. A demo can be downloaded from http://www.automatedqa.com/downloads/testcomplete
This is maybe not the type of application you want as it is big and made for GUI-testing, but yes it can identify the objects.
As mentioned Remko, IDR (Interactive Delphi Reconstructor) can extract all RTTI information (if program contains it!) for Delphi version from 2 to 2009. Version 2010 will be available later. Moreover IDR can use all information that it finds in program to create a lot of comments to disassemled program code (this is a first step of analyses). You can also look forms and easy go to event hadlers associated with controls.