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

  • SEARCH
  • Home
  • 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 8353311
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T09:13:03+00:00 2026-06-09T09:13:03+00:00

I am creating scripting language. When I allocate thing ,it’s allocate the thing and

  • 0

I am creating scripting language.
When I allocate thing ,it’s allocate the thing and returns the address
and then I do whatever with it and then delete it. I can’t control the variables in it
like creating struct in my lang (Struct with pointer and bool to check if pointer is pointing to valid data) and etc because it’ll make my lang slower and bigger in the RAM.

For example: (My scripting language is easily to understood. I doubt you’ll not understand this ,but I’ll put some comments in it anyway)

MyStruct = { //Function. For create object with it use 'new' before it.
    TestAliveVar=0
}
Func = { //I'll explain what exactly this function does every place it runs.
    if (!exists(arg0)) //C++: ???
        exit;
    arg0.TestAliveVar=1
    println "Still alive!";
}
var MyVar=new MyStruct(); //Returns address of the new object in the heap
                          //and runs on it the `MyStruct` function.
Func(MyVar);              //Sets his 'TestAliveVar' to 1
                          //and prints 'Still Alive!' with new line
delete(MyVar);            //C++: free(MyVar);
Func(MyVar);              //Does nothing

The question is how to create the function exists you saw in this code.
BTW I can run C++ codes in this lang.

  • 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-06-09T09:13:05+00:00Added an answer on June 9, 2026 at 9:13 am

    This valid check checked in windows only (VS),here is the function:

    #pragma once
    //ptrvalid.h
    __inline bool isValid(void* ptr) {
        if (((uint)ptr)&7==7)
            return false; //Not valid address at all (Maybe random pointer?)
        char _prefix;
        __try {
            _prefix=*(((char*)ptr)-1); //Get the prefix of this data
        } __except (true) { //Catch all unique exceptions (Windows exceptions) 
            return false; //Can't reach this memory
        }
        switch (_prefix) {
        case 0:    //Running release mode with debugger
        case -128: //Running release mode without debugger
        case -2:   //Running debug mode with debugger
        case -35:  //Running debug mode without debugger
            return false; //Deleted :(
            break;
        }
        return true; //Still alive!
    }
    

    Usage:

    #include <stdio.h>
    #include "ptrvalid.h"
    
    void PrintValid(void* ptr) {
        if (isValid(ptr))
            printf("%d is valid.\n",ptr);
        else
            printf("%d is not valid.\n",ptr);
    }
    
    int main() {
        int* my_array=(int*)malloc(4);
        PrintValid(my_array);
        PrintValid((void*)99);
        free(my_array);
        PrintValid(my_array);
        my_array=new int[4];
        PrintValid(my_array);
        delete my_array;
        PrintValid(my_array);
        getchar();
    }
    

    Output:

    764776 is valid.
    99 is not valid.
    764776 is not valid.
    774648 is valid.
    774648 is not valid.
    

    Function’s explanation: (What it does)

    The functions check before the real checking ,if the address is valid\start point to memory.
    After that he checks if this process can reach this memory’s prefix (If caught exception if can’t) and the last checking is checking what the prefix of this memory if deleted at any mode. (Debugging\Without Debug Mode\Release Mode)
    If the function passed all of those checks ,it returns true.

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

Sidebar

Related Questions

I've always had this dream of creating a 'real exe' from a scripting language.
I'm working on a scripting language and would like to write a compiler /
I'm creating a game in XNA and was thinking of creating my own scripting
Creating a google map with store locations within 50 miles of user entered address.
I'd like to request some help in creating a Batch file to run on
While creating classes, I followed OO conventions and declared all class variables before using
I'm creating a scripting engine for my game, and I need C# scripts to
I'm using groovy scripting in java. Here is how it operates: I'm creating in
I'm creating a javascript widget so third partys (web designers) can post a link
So I'm aware of the big ammount of general-purpose scripting languages like Ruby, Python,

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.