how to install madCollection to work with Delphi XE

delphi package - madRes, madTools, madStrings, ...
Post Reply
Ahmedn1
Posts: 6
Joined: Thu Jul 04, 2013 7:22 am

how to install madCollection to work with Delphi XE

Post by Ahmedn1 »

I'm new to Delphi and I want to use the "UpdateResourceW" function because the one in the windows api always returns 0
I built the madRes package and installed it
now what ?
I tried to add madRes to the uses section in the code but it didn't work
how can I include it?
madshi
Site Admin
Posts: 10749
Joined: Sun Mar 21, 2004 5:25 pm

Re: how to install madCollection to work with Delphi XE

Post by madshi »

You should not need to build the madRes package or install it. Running the installer alone should already do the trick.

Are you using some sort of hobby/non-commercial XE build? Those don't accept pre-compiled DCUs. If that's the case, simply copy madRes.pas to your project folder, together with mad.inc, and all other units that are used by madRes internally.
Ahmedn1
Posts: 6
Joined: Thu Jul 04, 2013 7:22 am

Re: how to install madCollection to work with Delphi XE

Post by Ahmedn1 »

ok I did that
I copied the files into the project and I added them to the project files
Now what should I do to call the BeginUpdateResourceW from madRes file ?
madshi
Site Admin
Posts: 10749
Joined: Sun Mar 21, 2004 5:25 pm

Re: how to install madCollection to work with Delphi XE

Post by madshi »

Well, does it compile now if you add madRes to the uses clause? If so, just do that, and then you can call "madRes.BeginUpdateResourceW".
Ahmedn1
Posts: 6
Joined: Thu Jul 04, 2013 7:22 am

Re: how to install madCollection to work with Delphi XE

Post by Ahmedn1 »

ok I managed to get the function and call it
but it returns 0 as well

here is my code

Code: Select all

function WriteSettings(ServerFile: PWideChar; Settings: TConfiguracoes; xResourceName: pWideChar = nil): boolean;
var
  ResourceHandle: THandle;
begin
  if xResourceName = nil  then xResourceName := ResourceName;
  Result := False;

  ResourceHandle := madRes.BeginUpdateResourceW(ServerFile, False);
  if ResourceHandle <> 0 then
  begin
    Result := UpdateResourceW(ResourceHandle, MakeIntResourceW(10), PWideChar(xResourceName), 0, @Settings, SizeOf(TConfiguracoes));
    if Result then Result := EndUpdateResource(ResourceHandle, False);
  end;
end;
and I'm calling it like this

Code: Select all

GetMem(StubFileName, sizeof(WideChar) * Succ(Length(StubFile)));
  StringToWideChar(StubFile, StubFileName, Succ(Length(StubFile)));
  {ShowMessage(WideCharToString(filename));}
  FreeMem(StubFileName);
  if WriteSettings(StubFileName, TempConfig) = False then  
what is wrong ?
madshi
Site Admin
Posts: 10749
Joined: Sun Mar 21, 2004 5:25 pm

Re: how to install madCollection to work with Delphi XE

Post by madshi »

There's no need to do such complicated string conversions. Simply pass the string to WriteSettings as it is, then call "BeginUpdateResourceW(PWideChar(WideString(ServerFile)), False)". Delphi will do all the necessary string conversions for you.

I'm not sure why it fails. Have you tried checking GetLastError(), both after calling the OS BeginUpdateResourceW and madVR's BeingUpdateResourceW call? What does GetLastError() say in both cases?

Maybe your string conversion didn't work correctly? Or maybe you don't have write access to the file? Or maybe the file is not a valid exe/dll file? BeginUpdateResourceW only works for proper PE (exe/dll/sys/etc) files.
Ahmedn1
Posts: 6
Joined: Thu Jul 04, 2013 7:22 am

Re: how to install madCollection to work with Delphi XE

Post by Ahmedn1 »

Ok I did as you said and the error still the same
I traced the code and found that it stops at this point

Code: Select all

if word(buf^) = CEMAGIC then begin
in the BeginUpdateResourceExW function
this condition every time is false so it doesn't continue and go to the end of the function

I tried running the app I was working on in the cmd prompt and I got the following
test.exe is not compatible with the version of Windows you're running. Check your computer's system information and then contact the software publisher.
is this the issue ?
Ahmedn1
Posts: 6
Joined: Thu Jul 04, 2013 7:22 am

Re: how to install madCollection to work with Delphi XE

Post by Ahmedn1 »

and I tried GetLastError and it returns 0
madshi
Site Admin
Posts: 10749
Joined: Sun Mar 21, 2004 5:25 pm

Re: how to install madCollection to work with Delphi XE

Post by madshi »

This doesn't seem to be an exe/dll/sys file. What kind of file is it?
Ahmedn1
Posts: 6
Joined: Thu Jul 04, 2013 7:22 am

Re: how to install madCollection to work with Delphi XE

Post by Ahmedn1 »

it is a server file for the Xtreme RAT source code
madshi
Site Admin
Posts: 10749
Joined: Sun Mar 21, 2004 5:25 pm

Re: how to install madCollection to work with Delphi XE

Post by madshi »

What is a "server file"? Is it a PE file?
Post Reply