Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3307634
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T21:25:44+00:00 2026-05-17T21:25:44+00:00

I’m writing on a MSN Plus script, which is in fact javascript. For interop

  • 0

I’m writing on a MSN Plus script, which is in fact javascript.
For interop with Windows there is a class called Interop.
With its static function Call one can call s specified function in a specified dll with up to 12 arguments.
My goal is to write a script which gets a process name out of the PID.
I’ve done everything right, but it still doesn’t work.

function GetProcNameFromPID(pid)  
{
    var hnd = Interop.Call("kernel32", "CreateToolhelp32Snapshot", 2, 0);
    var handle = Interop.Call("kernel32", "GetCurrentProcess");
    var StructP = Interop.Allocate(4+4+4+4+4+4+4+4+4+260);//*Allocate space for the ProcessEntry32 struct*
    var hnd_ptr = Interop.Allocate(4);
    var ress = Interop.Call("kernel32", "WriteProcessMemory", handle, StructP, StructP.size.DataPtr, 4, hnd_ptr);
    Debug.Trace(ReadInt(hnd_ptr, 0));
    var res = Interop.Call("kernel32", "Process32FirstW", hnd, StructP.DataPtr);
    if(!res)
    {
        Debug.Trace("FAAAAIIIILLLLL / " + Interop.Call("kernel32", "GetLastError") + " / " + ress);
    }
    else
    {
        do
        {
            var pos = 0;
            ReadInt(StructP, pos);
            ReadInt(StructP, pos);
            var owpid = ReadInt(StructP, pos);
            ReadInt(StructP, pos);
            ReadInt(StructP, pos);
            ReadInt(StructP, pos);
            var parpid = ReadInt(StructP, pos);
            ReadInt(StructP, pos);
            ReadInt(StructP, pos);
            ReadInt(StructP, pos);
            var name = ReadString(pos, 50);
            if(pid == owpid)
                return name;
            StructP = Interop.Allocate(4+4+4+4+4+4+4+8+4+50);
            Interop.Call("kernel32", "WriteProcessMemory", handle, StructP.DataPtr, StructP.size.DataPtr, 4, null);
        }
            while(Interop.Call("kernel32", "Process32NextW", hnd, StructP.DataPtr) == true)
    }
}
function ReadInt(buffer, pos)
{
var res = 0; 
    for(var i = 0; i >> 24;  
    var b2 = addr >> 24;  
    var b3 = addr >> 24;  
    var b4 = addr >> 24;  
    return b4 + b3*256 + b2*256*256 + b1*256*256*256;  
}  

The Process32FirstW function always suceeds, but the struct is empty.
The WriteProcessMemory function suceeds, too. But the number of written bytes is always 0.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T21:25:44+00:00Added an answer on May 17, 2026 at 9:25 pm

    I don’t have a machine to test things on, but your first issue is you don’t appear to be passing the proper parameters to WriteProcessMemory:

    BOOL WINAPI WriteProcessMemory(
      __in   HANDLE hProcess,
      __in   LPVOID lpBaseAddress,
      __in   LPCVOID lpBuffer,
      __in   SIZE_T nSize,
      __out  SIZE_T *lpNumberOfBytesWritten
    );
    

    You’re passing…

    handle => hProcess,
    StructP => lpBaseAddress, // ???
    StructP.size.DataPtr => lpBuffer, // ???
    4 => nSize,
    hnd_ptr => lpNumberOfBytesWritten
    

    Let’s start with an overview of WriteProcessMemory: It’s supposed to take a chunk of data in the curent process, pointed to by lpBuffer, nSize bytes long. It copies that data into the memory space of the process indicated by hProcess and places that data at the address lpBaseAddress in that target process.

    The problems I see with your code are:

    1. lpBaseAddress should be the address in another process which you are writing to. Since your handle points to the current process, I don’t even know why you’d call this function to begin with. You can just use StructP.WriteWORD(Offset, Data) to write data to your structure. But I’ll presume for now you’re doing this for bare minimum demonstraction purposes — to see if you can get WriteProcessMemory() to work at all.

    2. I don’t think this is even valid code. StructP.size exists, but it’s an int, not an object. It has no DataPtr member. StructP.DataPtr also exists. In fact, StructP.DataPtr is what is sent if you just specify StructP according to the help file. So are you trying to write from the structure right back to the structure, again, as a minimum test? If so, both pointers should be StructP

    Following that, I don’t know where the ReadInt() function you are using comes from. It looks to me like Databloc has several member functions for reading values, but you would call them like: hnd_ptr.ReadWORD(0)

    I am unsurprised that the structure is empty after calling Process32FirstW(), as it checks the value of the dwSize member of the structure. Since you are not successfully writing to it, I expect that value is normally 0, and hence no data is written.

    I’ve never fiddled with Messger Plus, so you’ll have to forgive me a little for being befuddled by a lot of this. Let me know if any of this was useful.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
Seemingly simple, but I cannot find anything relevant on the web. What is the
Does anyone know how can I replace this 2 symbol below from the string
this is what i have right now Drawing an RSS feed into the php,
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
I have a French site that I want to parse, but am running into

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.