Jump to content
Sign in to follow this  
H5O2OH

DllCall problem

Recommended Posts

H5O2OH

This is a part of the source in the dll

uses
  Windows,
  Messages,
  SysUtils,
  Variants,
  Classes,
  Graphics,
  Controls,
  Forms,
  Dialogs,
  StdCtrls,
  ExtCtrls;

{$R *.res}


const
basepointer:DWORD=$CEBB4C;
CurrentHP:DWORD=$450;

function GetBasePointer:DWORD;
begin
Result:=basepointer;
end;
function GetCurrentHP(wnd:HWND):DWORD stdcall;
 var  ProcessId : integer;  HandleWindow : Cardinal;   baseadress,erg:DWord;  BytesRead : Cardinal;

 begin

  if wnd <> 0 then
  begin
    GetWindowThreadProcessId(wnd,@ProcessId);
    HandleWindow := OpenProcess(PROCESS_VM_READ,False,ProcessId);
    ReadProcessMemory(HandleWindow, Pointer(basepointer),@baseAdress, Sizeof(DWord) ,BytesRead );
    ReadProcessMemory(HandleWindow,Pointer(baseadress+CurrentHP),@erg, Sizeof(DWord) ,BytesRead );
  end;
Result:=erg;


And my script
end;

$result = DllCall("Mydll.dll", "int", "GetCurrentHP")
IF @error Then
    Msgbox(0,"Error!",@error)
    exit
EndIf
msgbox(0, "", $result)

In the end - @error is 3. :)

Edited by H5O2OH

Share this post


Link to post
Share on other sites
FreeFry

If reading the memory of some application is all that you want to do(with your dll), then you should know that reading memory can be done with pure autoit alone(no need for the dll).

Share this post


Link to post
Share on other sites
Siao

In the end - @error is 3. :)

And that doesn't tell you anything?

GetCurrentHP isn't exported. What language is this, Delphi? There should be some "export" keyword to be used in func declaration...


"be smart, drink your wine"

Share this post


Link to post
Share on other sites
H5O2OH

FreeFry, I know,but can't i use the dll as a plugin?

Siao,yeah pure delphi,could you help me a with that keyword?

Edited by H5O2OH

Share this post


Link to post
Share on other sites
FreeFry

FreeFry, I know,but can't i use the dll as a plugin?

Siao,yeah pure delphi,could you help me a with that keyword?

If you follow Siao's advice yes, but why use a DLL, when you can do it solely in AutoIt itself? :)

Share this post


Link to post
Share on other sites
H5O2OH

Okay,so could you guys help me with that export "keyword"?

In the end the integer will be placed in erg (Result:=erg;)

How can i make it call that function and export that function?

Edited by H5O2OH

Share this post


Link to post
Share on other sites
FreeFry

Sorry, DLL's ain't my thing. :E

Share this post


Link to post
Share on other sites
Siao

I'm not familiar with Delphi, but it could be something like...

function GetCurrentHP(wnd:HWND):DWORD stdcall; export;

Geez, just read some delphi help on how to make proper usable DLLs.


"be smart, drink your wine"

Share this post


Link to post
Share on other sites
H5O2OH

That's how it is in delphi

function GetCurrentHP(wnd:HWND):DWORD;stdcall;external 'MyDll.dll';

How to do it in au3? >.>

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.