Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add user-defined function and variable type in script engine #342

Merged
merged 1 commit into from
Mar 2, 2024

Conversation

xmaple555
Copy link
Member

Description

@SinaKarvandi please make script-engine branch to receive all PRs about script-engine. It requires a long time to develop script-engine more like C language.

This commit adds define function and variable type.
Variable type does nothing for now, I just add variable type syntax.
And if you are free, you can help me to add stack buffer for each logic core in hyperdbg/hprdbgkd/code/debugger/core/Debugger.c.

Void Function

HyperDbg> ? {
> void myfun(int var,int var2){
> printf("var = %d, var2 = %d\n",var,var2);
> return ;
> printf("222\n");
> }
> for(int i=0;i<3;i++){
> myfun(1,2);
> }
>
>
> int myvar=79;
> printf("%x\n",myvar);
> }
this command should not be used while you're in VMI-Mode or not in debugger-mode, the results that you see is a simulated result for TESTING script-engine and is not based on the status of your system. You can use this command, ONLY in debugger-mode

test expression : {
void myfun(int var,int var2){
printf("var = %d, var2 = %d\n",var,var2);
return ;
printf("222\n");
}
for(int i=0;i<3;i++){
myfun(1,2);
}


int myvar=79;
printf("%x\n",myvar);
}
var = 1, var2 = 2
var = 1, var2 = 2
var = 1, var2 = 2
79

Int Function

HyperDbg> ? {
> int myfun1(int var1){
> result = var1 + 1;
> printf("myfun1 %d\n",result);
> return result;
> }
> int myfun2(int var1){
> result = var1 * 2;
> printf("myfun2 %d\n",result);
> return result;
> }
> int myfun3(int var1){
> result = var1 * 2;
> printf("myfun3 %d\n",result);
> return result;
> }
> int myfun4(int var1){
> result = myfun1(var1)+myfun2(var1) + myfun3(var1);
> printf("myfun4 %d\n",result);
> return result;
> }
>
> printf("%d\n",myfun4(2));
> }
this command should not be used while you're in VMI-Mode or not in debugger-mode, the results that you see is a simulated result for TESTING script-engine and is not based on the status of your system. You can use this command, ONLY in debugger-mode

test expression : {
int myfun1(int var1){
result = var1 + 1;
printf("myfun1 %d\n",result);
return result;
}
int myfun2(int var1){
result = var1 * 2;
printf("myfun2 %d\n",result);
return result;
}
int myfun3(int var1){
result = var1 * 2;
printf("myfun3 %d\n",result);
return result;
}
int myfun4(int var1){
result = myfun1(var1)+myfun2(var1) + myfun3(var1);
printf("myfun4 %d\n",result);
return result;
}

printf("%d\n",myfun4(2));
}
myfun1 3
myfun2 4
myfun3 4
myfun4 11
11

Recursive Fibonacci

HyperDbg> ? {
> int myfun(int var1) {
> if(var1 == 0) {
> return 0;
> }
> if(var1 == 1) {
> return 1 ;
> }
> return myfun(var1 - 1)  + myfun(var1 -2);
>
> }
> var = myfun(9);
> printf("%d",var);
> }
this command should not be used while you're in VMI-Mode or not in debugger-mode, the results that you see is a simulated result for TESTING script-engine and is not based on the status of your system. You can use this command, ONLY in debugger-mode

test expression : {
int myfun(int var1) {
if(var1 == 0) {
return 0;
}
if(var1 == 1) {
return 1 ;
}
return myfun(var1 - 1)  + myfun(var1 -2);

}
var = myfun(9);
printf("%d",var);
}
34

Iterative Fibonacci

HyperDbg> ? {
>
> int myfun(int varn) {
>   int varf0 = 0;
>   int varf1 = 1;
>   int varfn=0;  //comment
>
>   if(varn == 0) {
>     return varf0;
>   }
>   if(varn == 1) {
>     return varf1;
>   }
>
>   int i=0;
>   for(i = 2; i <= varn; i++) {
>     varfn = varf0 + varf1;
>     varf0 = varf1;
>     varf1 = varfn;
>   }
>
>   return varfn;
> }
> printf("%d",myfun(9));
> }
this command should not be used while you're in VMI-Mode or not in debugger-mode, the results that you see is a simulated result for TESTING script-engine and is not based on the status of your system. You can use this command, ONLY in debugger-mode

test expression : {

int myfun(int varn) {
  int varf0 = 0;
  int varf1 = 1;
  int varfn=0;  //comment

  if(varn == 0) {
    return varf0;
  }
  if(varn == 1) {
    return varf1;
  }

  int i=0;
  for(i = 2; i <= varn; i++) {
    varfn = varf0 + varf1;
    varf0 = varf1;
    varf1 = varfn;
  }

  return varfn;
}
printf("%d",myfun(9));
}
34

@SinaKarvandi SinaKarvandi merged commit c66acd6 into HyperDbg:dev Mar 2, 2024
3 checks passed
@SinaKarvandi
Copy link
Member

Hi,
Thanks a lot for implementing it, it's a huge contribution.

The branch is created:
https://github.com/HyperDbg/HyperDbg/tree/script-engine

FYI, right now, I'm fixing all warnings in the code that are available at this branch:
https://github.com/HyperDbg/HyperDbg/tree/fix-warnings

My big plan is to make HyperDbg OS-independent so we can release a Linux version. (I estimate that it take one year or more as it's complicated).

And if you are free, you can help me to add stack buffer for each logic core in hyperdbg/hprdbgkd/code/debugger/core/Debugger.c.

Yes, please let me know, how I can help with that.

@SinaKarvandi SinaKarvandi mentioned this pull request Mar 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants