how to install madCollection to work with Delphi XE

delphi package - madRes, madTools, madStrings, ...

how to install madCollection to work with Delphi XE

Postby Ahmedn1 » Thu Jul 04, 2013 7:30 am

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?
Ahmedn1
 
Posts: 6
Joined: Thu Jul 04, 2013 7:22 am

Re: how to install madCollection to work with Delphi XE

Postby madshi » Thu Jul 04, 2013 7:43 am

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.
madshi
Site Admin
 
Posts: 9265
Joined: Sun Mar 21, 2004 5:25 pm

Re: how to install madCollection to work with Delphi XE

Postby Ahmedn1 » Thu Jul 04, 2013 10:24 am

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 ?
Ahmedn1
 
Posts: 6
Joined: Thu Jul 04, 2013 7:22 am

Re: how to install madCollection to work with Delphi XE

Postby madshi » Thu Jul 04, 2013 10:36 am

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".
madshi
Site Admin
 
Posts: 9265
Joined: Sun Mar 21, 2004 5:25 pm

Re: how to install madCollection to work with Delphi XE

Postby Ahmedn1 » Thu Jul 04, 2013 10:47 am

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 ?
Ahmedn1
 
Posts: 6
Joined: Thu Jul 04, 2013 7:22 am

Re: how to install madCollection to work with Delphi XE

Postby madshi » Thu Jul 04, 2013 11:26 am

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.
madshi
Site Admin
 
Posts: 9265
Joined: Sun Mar 21, 2004 5:25 pm

Re: how to install madCollection to work with Delphi XE

Postby Ahmedn1 » Thu Jul 04, 2013 11:39 am

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

Postby Ahmedn1 » Thu Jul 04, 2013 11:58 am

and I tried GetLastError and it returns 0
Ahmedn1
 
Posts: 6
Joined: Thu Jul 04, 2013 7:22 am

Re: how to install madCollection to work with Delphi XE

Postby madshi » Thu Jul 04, 2013 12:29 pm

This doesn't seem to be an exe/dll/sys file. What kind of file is it?
madshi
Site Admin
 
Posts: 9265
Joined: Sun Mar 21, 2004 5:25 pm

Re: how to install madCollection to work with Delphi XE

Postby Ahmedn1 » Thu Jul 04, 2013 1:21 pm

it is a server file for the Xtreme RAT source code
Ahmedn1
 
Posts: 6
Joined: Thu Jul 04, 2013 7:22 am

Re: how to install madCollection to work with Delphi XE

Postby madshi » Thu Jul 04, 2013 2:53 pm

What is a "server file"? Is it a PE file?
madshi
Site Admin
 
Posts: 9265
Joined: Sun Mar 21, 2004 5:25 pm


Return to madBasic

Who is online

Users browsing this forum: No registered users and 1 guest