views:

91

answers:

1

Hi there,

I'm using Ollydbg to disasemble a program. What I need to do is inject code into the program and save an EDX value at a certain point. I'm guessing the easiest way would be for me to create a dll with a single function like so...

function WriteEAXValue(EAX: PChar): LongBool

and then inject code into the program so it calls the DLL when needed.

What I think I need is the equivelent of the following delphi code, but in assembly so I can add it into the program. Can someone help me? Thanks

type
  TFunc = function (EAX: PChar): LongBool;

Var
  A: THandle;
  F: TFunc;
begin
  A := LoadLibrary('C:\My_Dll.dll');
  @F := GetProcAddress(A,'WriteEAXValue');
  F('EAX');
  FreeLibrary(A);
end.
+1  A: 

Finding the assembly equivalent of Delphi code is pretty simple. Just compile the code, run it, and put a breakpoint at the start of the procedure and view it in the CPU view. You'll get a full disassembly that way.

Mason Wheeler
Thanks, it worked :)
Doobi