Solved

# check if my process's code was changed in memory.

Posted on 2003-03-09
Medium Priority
120 Views
hey, lets say i have a function and i would like to check if it was changed inside the memory, how can i do this ?
0
Question by:wsock32_
[X]
###### Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

• Help others & share knowledge
• Earn cash & points
• 4
• 3

Author Comment

ID: 8101434
increased points.. please, some help here..
0

LVL 9

Expert Comment

ID: 8101479
seems you have to calc checksum of function code on programm startup and then compare it with stored value.

0

Author Comment

ID: 8101496
i know that, but how can i calc the checksum of the function, how can i fetch that data into a buffer? :/
0

LVL 9

Expert Comment

ID: 8101572
I saw sample about how to acces executable code in this topic area. Let me know if you didn't found it.
0

Author Comment

ID: 8101789
nope tried the google search, but its not here
0

LVL 9

Expert Comment

ID: 8101818
ok, just a moment....
0

LVL 9

Accepted Solution

ITugay earned 1200 total points
ID: 8101871
here is a sample.
Proc1 - procedure that must be checked.
DummyProc - place it just after Proc1 to calculate Proc1 size.

procedure Proc1(var M: Integer);
begin
M := 1000;
end;

procedure DummyProc;
begin

end;

procedure TForm1.SpeedButton1Click(Sender: TObject);
var
A: Pointer;
L: Integer;
CS: Integer;
begin
A := @Proc1;

// size of procedure
L := Integer(@DummyProc) - Integer(@Proc1);

// check summ
CS := 0;
while L > 0 do
begin
CS := CS + Byte(A^);
dec(L);
A := Pointer(Integer(A) + 1);
end;

// show result
ShowMessage(IntToStr(CS));
end;

-----
Igor

PS: if you need to copy code of proc1 to buffer, then use  A as pointer of area and L as length in bytes
0

## Featured Post

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…