Delphi Programming Forum
C++Builder  |  Delphi  |  FireMonkey  |  C/C++  |  Free Pascal  |  Firebird
볼랜드포럼 BorlandForum
 경고! 게시물 작성자의 사전 허락없는 메일주소 추출행위 절대 금지
델파이 포럼
Q & A
FAQ
팁&트릭
강좌/문서
자료실
컴포넌트/라이브러리
FreePascal/Lazarus
볼랜드포럼 홈
헤드라인 뉴스
IT 뉴스
공지사항
자유게시판
해피 브레이크
공동 프로젝트
구인/구직
회원 장터
건의사항
운영진 게시판
회원 메뉴
북마크
델마당
볼랜드포럼 광고 모집

델파이 Q&A
Delphi Programming Q&A
[14483] WriteProcessMemory 질문!!
홍홍홍 [imjm97] 2986 읽음    2012-11-03 13:35
WriteProcessMmory를 쓰는데 메모리값이 안써져용
어디서잘못된거죠?


procedure TMainForm.AddMenuClick(Sender: TObject);
var
  Form : TAddCheatForm;
  Cheat : PCheat;
  i : Integer;
  hProc : THandle;
  iWritten : Cardinal;
  xByte : Byte;
  xWord : Word;
  xDword : DWORD;
begin
  Form := TAddCheatForm.Create(Self);

  Form.Address.Text := Results.Selected.Caption;
  Form.Value.Text := Results.Selected.SubItems[0];

  Case Mode of
    smByte:
      Form.Size.ItemIndex := 0;
    smWord:
      Form.Size.ItemIndex := 1;
    smDword:
      Form.Size.ItemIndex := 2;
  End;

  Form.ActiveControl := Form.Description;

  try
    if Form.ShowModal = mrOK then
    begin
      FreezeTimer.Enabled := False;
      CheatsTimer.Enabled := False;

      New(Cheat);

      Cheat^.Address :=  HexToInt(Form.Address.Text);
      Cheat^.Value := StrToInt(Form.Value.Text);
      Cheat^.Freeze := Form.Freeze.Checked;

      if Form.Description.Text = '' then
        Cheat^.Description := 'Description'
      else
        Cheat^.Description := Form.Description.Text;

      Case Form.Size.ItemIndex of
        0:
          Cheat^.Size := 1;
        1:
          Cheat^.Size := 2;
        2:
          Cheat^.Size := 4;
      End;

      Cheats.Add(Cheat);

      hProc := OpenProcess(PROCESS_VM_WRITE, False, Process.th32ProcessID);

      if hProc = 0 then
      begin
        exit;
      end;

      Case PCheat(Cheats.Items[Cheats.Count-1])^.Size of
      1:
      begin
        xByte := PCheat(Cheats.Items[Cheats.Count-1])^.Value;

        WriteProcessMemory(hProc, Pointer(PCheat(Cheats.Items[Cheats.Count-1])^.Address), @xByte, 1, iWritten);
      end;
      2:
      begin
        xWord := PCheat(Cheats.Items[Cheats.Count-1])^.Value;

        WriteProcessMemory(hProc, Pointer(PCheat(Cheats.Items[Cheats.Count-1])^.Address), @xWord, 2, iWritten);
      end;
      4:
      begin
        xDword := PCheat(Cheats.Items[Cheats.Count-1])^.Value;

        WriteProcessMemory(hProc, Pointer(PCheat(Cheats.Items[Cheats.Count-1])^.Address), @xDword, 4, iWritten);
      end;
      end;

      bIsDirty := True;
      end;

    CloseHandle(hProc);

    RefreshCheats;

    SaveMenu.Enabled := True;
    SaveButton.Enabled := True;

    FreezeTimer.Enabled := True;
    CheatsTimer.Enabled := True;
  finally

  end;
end;

+ -

관련 글 리스트
14483 WriteProcessMemory 질문!! 홍홍홍 2986 2012/11/03
Google
Copyright © 1999-2015, borlandforum.com. All right reserved.