Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C#
  4. C++ -> C# VirtualAllocEx!

C++ -> C# VirtualAllocEx!

Scheduled Pinned Locked Moved C#
csharpc++comperformancehelp
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    suguimoto
    wrote on last edited by
    #1

    Hello! I got a problem with the lines below. I don´t know how to use VirtualAllocEx in C# , because I must allocate a certain space for a struct and an item (both are pointers). I´d like to know if anyone got any idea how I can do the same thing in c#. This code is from: http://www.codeproject.com/threads/int64_memsteal.asp?df=100&forumid=29535&exp=0&select=727974&mpp=50#xx727974xx[^] "Stealing Program's Memory"

    LVITEM lvi, *_lvi;
    char item[512], subitem[512];
    char *_item;
    HANDLE process;

    _lvi=(LVITEM*)VirtualAllocEx(process, NULL, sizeof(LVITEM), MEM_COMMIT, PAGE_READWRITE);
    _item=(char*)VirtualAllocEx(process, NULL, 512, MEM_COMMIT, PAGE_READWRITE);

    Thank you!!

    J 1 Reply Last reply
    0
    • S suguimoto

      Hello! I got a problem with the lines below. I don´t know how to use VirtualAllocEx in C# , because I must allocate a certain space for a struct and an item (both are pointers). I´d like to know if anyone got any idea how I can do the same thing in c#. This code is from: http://www.codeproject.com/threads/int64_memsteal.asp?df=100&forumid=29535&exp=0&select=727974&mpp=50#xx727974xx[^] "Stealing Program's Memory"

      LVITEM lvi, *_lvi;
      char item[512], subitem[512];
      char *_item;
      HANDLE process;

      _lvi=(LVITEM*)VirtualAllocEx(process, NULL, sizeof(LVITEM), MEM_COMMIT, PAGE_READWRITE);
      _item=(char*)VirtualAllocEx(process, NULL, 512, MEM_COMMIT, PAGE_READWRITE);

      Thank you!!

      J Offline
      J Offline
      Josh Smith
      wrote on last edited by
      #2

      If you are trying to allocate memory in an unmanaged process, you can probably use PInvoke[^] to make it work. If the memory you need to allocate will be in another managed process, then those unmanaged APIs will not work. What you would need to do in that situation is, probably, use .NET remoting to communicate between the two managed processes. Josh

      S 1 Reply Last reply
      0
      • J Josh Smith

        If you are trying to allocate memory in an unmanaged process, you can probably use PInvoke[^] to make it work. If the memory you need to allocate will be in another managed process, then those unmanaged APIs will not work. What you would need to do in that situation is, probably, use .NET remoting to communicate between the two managed processes. Josh

        S Offline
        S Offline
        suguimoto
        wrote on last edited by
        #3

        Hi Josh, thanks for the reply! What I´m trying to do is read a TreeView(Folder Browser Dialog) from another program. By reading each item´s text I can select a especific Folder. I noticed that usual codes did not catch anything from outside my program. For instance: SubString Text = new SubString(255); tvItem.pszText = Text; SendMessage(TreeHandle, TVM_GETITEM, 0, ref tvItem); This code works perfectly if the treeview is in your application, but SendMessage returns only false if the treeview is in another application(process). Thank you

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups