Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


Altering bytes in C++?

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
Christbru
Newbie cheater
Reputation: 0

Joined: 11 Jan 2013
Posts: 15

PostPosted: Fri Jan 11, 2013 4:51 pm    Post subject: Altering bytes in C++? Reply with quote

I am creating a dll to inject my d3d menu, using the lua engine works but I'm not sure on how to alter bytes with C++

Code in lua:

Code:

sc_Enable_Walkthrough = [[
~Address~:
db 90 90 90 90 90 90 90
]]

sc_Disable_Walkthrough = [[
~Address~:
db FF 24 85 08 58 98 00
]]



background=createPicture()
bmp=picture_getBitmap(background);

graphic_setHeight(bmp,1)
graphic_setWidth(bmp,1)
c=rasterimage_getCanvas(bmp)

canvas_setPixel(c,0,0,0x000000)

highlighter=createPicture()
bmp=picture_getBitmap(highlighter);

graphic_setHeight(bmp,1)
graphic_setWidth(bmp,1)
c=rasterimage_getCanvas(bmp)

canvas_setPixel(c,0,0,0x0000ff)

Y_Pos = 180

d3dhook_initializeHook()
bgtexture=d3dhook_createTexture(background)

bgsprite=d3dhook_createSprite(bgtexture);
d3dhook_renderobject_setAlphablend(bgsprite, 0.5)
d3dhook_renderobject_setX(bgsprite, 1) --center it horizontally
d3dhook_renderobject_setY(bgsprite, Y_Pos) --center it horizontally
d3dhook_sprite_setWidth(bgsprite,200)
d3dhook_sprite_setHeight(bgsprite,200)

highlightertexture=d3dhook_createTexture(highlighter)
hlsprite=d3dhook_createSprite(highlightertexture)
d3dhook_renderobject_setAlphablend(hlsprite, 0.2)
d3dhook_renderobject_setVisible(hlsprite, false) --don't show it just yet
d3dhook_renderobject_setX(hlsprite, 1) --center (so matches with the background)
d3dhook_renderobject_setY(hlsprite, Y_Pos) --center (so matches with the background)
d3dhook_sprite_setWidth(hlsprite,200)



font=createFont()
font_setColor(font,0x0000ff)
font_setSize(font, 12)
fontmap=d3dhook_createFontmap(font)

onfont=createFont()
font_setColor(onfont,0x00ff00)
font_setSize(onfont, 12)
onfontmap=d3dhook_createFontmap(onfont)

lineheight=d3dhook_texture_getHeight(fontmap) --fontmap inherits from texture so this can be used

d3dhook_sprite_setHeight(hlsprite,lineheight) --make the highlightr the same height as a textline

Option1=d3dhook_createTextContainer(fontmap,1,Y_Pos,'Walkthrough: OFF')
Option1State=false


selectedOption=1

function setHighlighterToSelectedOption()
  d3dhook_renderobject_setY(hlsprite, Y_Pos+lineheight*(selectedOption-1))
end


setHighlighterToSelectedOption()
d3dhook_renderobject_setVisible(hlsprite, true)

function ExecuteSelectedOption()
  local onoff="OFF";

  if (selectedOption==1) then
    Option1State=not Option1State
    if (Option1State) then
   autoAssemble(sc_Enable_Walkthrough)
   d3dhook_textcontainer_setFontMap(Option1,onfontmap)
      onoff="ON"
    else
   autoAssemble(sc_Disable_Walkthrough)
   d3dhook_textcontainer_setFontMap(Option1,fontmap)
      onoff="OFF"
    end
    d3dhook_textcontainer_setText(Option1,'Walkthrough: '..onoff);
  end


end

function objectclick(object, x, y)
  --bla=userDataToInteger(object)
  --print(string.format("click on %x",bla))


  if (object==Option1) then
    selectedOption=1
    ExecuteSelectedOption()
  end

  setHighlighterToSelectedOption()
end
d3dhook_onClick(objectclick)

function keydown(virtualkey,char)
  if (virtualkey==VK_DOWN) then
    --down arrow
    if (selectedOption<3) then
      selectedOption=selectedOption+1
    end
  end

  if (virtualkey==VK_UP) then
    --up arrow
    if (selectedOption>1) then
      selectedOption=selectedOption-1
    end
  end

  if (virtualkey==VK_RETURN) then
    ExecuteSelectedOption()
  end

  setHighlighterToSelectedOption()

  return true
end

d3dhook_onKey(keydown)


all I need to know is how to do stuff like autoAssemble( [[
~Address~:
db FF 24 85 08 58 98 00
]])
and
autoAssemble( [[
~Address~:
db 90 90 90 90 90 90 90
]])
Back to top
View user's profile Send private message
atom0s
Moderator
Reputation: 205

Joined: 25 Jan 2006
Posts: 8587
Location: 127.0.0.1

PostPosted: Fri Jan 11, 2013 9:55 pm    Post subject: Reply with quote

You can simulate the script using WriteProcessMemory.
_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites