Page 1 of 1

how to install madCollection to work with Delphi XE

Posted: Thu Jul 04, 2013 7:30 am
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?

Re: how to install madCollection to work with Delphi XE

Posted: Thu Jul 04, 2013 7:43 am
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.

Re: how to install madCollection to work with Delphi XE

Posted: Thu Jul 04, 2013 10:24 am
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 ?

Re: how to install madCollection to work with Delphi XE

Posted: Thu Jul 04, 2013 10:36 am
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".

Re: how to install madCollection to work with Delphi XE

Posted: Thu Jul 04, 2013 10:47 am
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 ?

Re: how to install madCollection to work with Delphi XE

Posted: Thu Jul 04, 2013 11:26 am
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.

Re: how to install madCollection to work with Delphi XE

Posted: Thu Jul 04, 2013 11:39 am
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 ?

Re: how to install madCollection to work with Delphi XE

Posted: Thu Jul 04, 2013 11:58 am
by Ahmedn1
and I tried GetLastError and it returns 0

Re: how to install madCollection to work with Delphi XE

Posted: Thu Jul 04, 2013 12:29 pm
by madshi
This doesn't seem to be an exe/dll/sys file. What kind of file is it?

Re: how to install madCollection to work with Delphi XE

Posted: Thu Jul 04, 2013 1:21 pm
by Ahmedn1
it is a server file for the Xtreme RAT source code

Re: how to install madCollection to work with Delphi XE

Posted: Thu Jul 04, 2013 2:53 pm
by madshi
What is a "server file"? Is it a PE file?