Skip to content
This repository was archived by the owner on Feb 28, 2022. It is now read-only.

Commit afd060d

Browse files
committed
- version 4.0
- done F11 and F12 step and Auto Steps. - add open Script from out side. - refresh by menu and F5. - add var of x64dbg system. - change save path to handle out Script files. - fix IniLoadData . - fix highlight_Line_ByLineIndex. - done highlight_AllRTB_Script Functions. - add SetNextLineColor_StepOn - fix Scriptargument structures variables names and meaning. - change if way to not deal with line number just by labels and 0 for next line.
1 parent dbb7c6f commit afd060d

File tree

7 files changed

+432
-248
lines changed

7 files changed

+432
-248
lines changed

AdvancedScript/AdvSconfig.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
Varx ; variable type(int-str-array),variable name add [] for array, value optional(str,array);Teal;
2+
Var ; define x64dbg variable type is just int;Teal;
23
Getx ; $varname, value;Teal;
34
Setx ; $variable name;Teal;
45
Movx ; P1, P2(will analyzed);Teal;
@@ -40,7 +41,7 @@ inputbox ; variable, message, title;Teal;
4041
commentsetx ; address,String comment;Teal;
4142
GetdesCallJmp ; variable, address of call;Teal;
4243
run; ;Teal;
43-
ego;passing all first-chance exceptions to the debuggee.;Teal;
44+
erun;passing all first-chance exceptions to the debuggee.;Teal;
4445
pause; ;Teal;
4546
StepInto; ;Teal;
4647
StepOver; ;Teal;

AdvancedScript/AdvancedScript.vcxproj

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,7 @@ copy "$(ProjectDir)\HelpAdvancedScript.txt" "$(OutDir)"</Command>
127127
</Link>
128128
<PreBuildEvent>
129129
<Command>copy "$(ProjectDir)\AdvSconfig.txt" "$(OutDir)"
130-
copy "$(ProjectDir)\HelpAdvancedScript.txt" "$(OutDir)"
131-
</Command>
130+
copy "$(ProjectDir)\HelpAdvancedScript.txt" "$(OutDir)"</Command>
132131
</PreBuildEvent>
133132
</ItemDefinitionGroup>
134133
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
@@ -162,8 +161,7 @@ copy "$(ProjectDir)\HelpAdvancedScript.txt" "$(OutDir)"</Command>
162161
</Link>
163162
<PreBuildEvent>
164163
<Command>copy "$(ProjectDir)\AdvSconfig.txt" "$(OutDir)"
165-
copy "$(ProjectDir)\HelpAdvancedScript.txt" "$(OutDir)"
166-
</Command>
164+
copy "$(ProjectDir)\HelpAdvancedScript.txt" "$(OutDir)"</Command>
167165
</PreBuildEvent>
168166
</ItemDefinitionGroup>
169167
<ItemGroup>

AdvancedScript/HelperFunctions.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,4 +57,4 @@ System::Void GetArg(String^ input, Generic::List<String^>^% arguments, bool brac
5757
///////////////////////////////////////////////////////////////////Helper Functions
5858
ref class MyException : public System::Exception {};
5959

60-
static char* ads_version = "3.1";
60+
static char* ads_version = "4.0";

AdvancedScript/MainForm.h

Lines changed: 319 additions & 155 deletions
Large diffs are not rendered by default.

AdvancedScript/MainForm.resx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1285,4 +1285,7 @@
12851285
+P////z///8KAAAAAAAAAACkAAEAAff////8////CgAAAAAAAAAAfwABAAs=
12861286
</value>
12871287
</data>
1288+
<metadata name="openFileDialog1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
1289+
<value>527, 17</value>
1290+
</metadata>
12881291
</root>

AdvancedScript/ScriptArgumentWindow.h

Lines changed: 51 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,10 @@ namespace ScriptWindowArg {
1313
ref class Scriptargument
1414
{
1515
private:
16-
int lineNumber = 0;
16+
int CurrentlineIndex = 0;
1717
int MaxLine = 0;
18-
Color OldColor=Color::Black;
18+
Color OldColor ;
19+
int OldLineIndex = 0;
1920
public:
2021
int isCommandsExist(String^ input_) {
2122
array <String^>^ CommandsArray_ = {
@@ -54,34 +55,40 @@ namespace ScriptWindowArg {
5455
};
5556
public:
5657
int CommandsNeedwait(String^ input_) { /// this command need time to finish so we will make wait clock gif so user no thing it is not responding
57-
array <String^>^ CommandsArray_ = {
58+
array <String^>^ CommandsArray_ = {
5859
"BPxx",
5960
"findallmemx"
6061
};
6162
return Array::IndexOf(CommandsArray_, input_->ToLower()); // if -1 then not found
6263
};
63-
public:
64-
void setLineNumber(int LineNum) {
65-
lineNumber = LineNum;
66-
};
64+
public: void setCurrentlineIndex(int LineIndx) {
65+
CurrentlineIndex = LineIndx;
66+
}
67+
public: void SetOldlineIndex_Color(int OldLineIndex_, Color color_) {
68+
OldColor = color_;
69+
OldLineIndex = OldLineIndex_;
70+
}
6771
public: void setOldColor(Color color_) {
6872
OldColor = color_;
6973
}
70-
public: Color getColor() {
74+
public: Color GetOldColor() {
7175
return OldColor;
7276
}
73-
public:
74-
void setMaxLine(int MaxLine_) {
75-
MaxLine = MaxLine_;
76-
}
77-
public:
78-
int GetMaxLine() {
79-
return MaxLine;
80-
}
81-
public:
82-
int GetLineNumber() {
83-
return lineNumber;
84-
};
77+
public: void setMaxLine(int MaxLine_) {
78+
MaxLine = MaxLine_;
79+
}
80+
public: int GetMaxLine() {
81+
return MaxLine;
82+
}
83+
public: int GetCurrentlineIndex() {
84+
return CurrentlineIndex;
85+
}
86+
public: void SetOldlineIndex(int OldLineIndex_) {
87+
OldLineIndex = OldLineIndex_;
88+
}
89+
public: int GetOldlineIndex() {
90+
return OldLineIndex;
91+
}
8592
};
8693

8794
ref class ScriptargumentClass
@@ -129,19 +136,24 @@ namespace ScriptWindowArg {
129136
bool readLine(String^ Line_, int MaxLine) {
130137
bool ret_ = false;
131138
if (Line_->Trim()->EndsWith(":")) {
132-
ScriptargumentClass::Scriptargument_->setLineNumber(ScriptargumentClass::Scriptargument_->GetLineNumber() + 1);
139+
ScriptargumentClass::Scriptargument_->setCurrentlineIndex(ScriptargumentClass::Scriptargument_->GetCurrentlineIndex() + 1);
133140
return true;
134141
}
135142
if (Line_->Trim() == "") {
136-
ScriptargumentClass::Scriptargument_->setLineNumber(ScriptargumentClass::Scriptargument_->GetLineNumber() + 1);
143+
ScriptargumentClass::Scriptargument_->setCurrentlineIndex(ScriptargumentClass::Scriptargument_->GetCurrentlineIndex() + 1);
137144
return true;
138145
}
139146
if (Line_->Trim()->ToLower() == "ret") {
147+
///reset Script
148+
//ScriptargumentClass::Scriptargument_->SetOldlineIndex(0);
149+
//ScriptargumentClass::Scriptargument_->setCurrentlineIndex(0);
140150
reten_ = true;
141151
return true;
142152
}
153+
if (Line_->Contains("//"))
154+
Line_ = Line_->Substring(0, Line_->IndexOf("//"));
143155
if (Line_->Trim()->IndexOf(" ") > 0) { /// >0 it mean it has command at the begining
144-
String^ cmd_ = Line_->Substring(0, Line_->IndexOf(" "));
156+
String^ cmd_ = Line_->Substring(0, Line_->IndexOf(" "));
145157
int CmdExist = ScriptargumentClass::Scriptargument_->isCommandsExist(cmd_->Trim());
146158
if (CmdExist >= 0) {
147159
//char* argv = new char[50];
@@ -231,7 +243,7 @@ namespace ScriptWindowArg {
231243
case ScriptWindowArg::ifx:
232244
{
233245
String^ Line2Jmp_;
234-
ret_ = ifCond(Line_, Line2Jmp_, ScriptargumentClass::Scriptargument_->GetLineNumber());
246+
ret_ = ifCond(Line_, Line2Jmp_, ScriptargumentClass::Scriptargument_->GetCurrentlineIndex());
235247
if (!ret_) {
236248
break;
237249
}
@@ -242,7 +254,7 @@ namespace ScriptWindowArg {
242254
}
243255
else
244256
{
245-
ScriptargumentClass::Scriptargument_->setLineNumber(Line2Jmp);
257+
ScriptargumentClass::Scriptargument_->setCurrentlineIndex(Line2Jmp);
246258
return true;
247259
}
248260
break;
@@ -260,7 +272,7 @@ namespace ScriptWindowArg {
260272
}
261273
else
262274
{
263-
ScriptargumentClass::Scriptargument_->setLineNumber(Line2Jmp);
275+
ScriptargumentClass::Scriptargument_->setCurrentlineIndex(Line2Jmp);
264276
return true;
265277
}
266278
}
@@ -269,7 +281,7 @@ namespace ScriptWindowArg {
269281
break;
270282
}
271283
if (ret_) {
272-
ScriptargumentClass::Scriptargument_->setLineNumber(ScriptargumentClass::Scriptargument_->GetLineNumber() + 1);
284+
ScriptargumentClass::Scriptargument_->setCurrentlineIndex(ScriptargumentClass::Scriptargument_->GetCurrentlineIndex() + 1);
273285
return ret_;
274286
}
275287
else
@@ -283,7 +295,7 @@ namespace ScriptWindowArg {
283295
ret_ = DbgCmdExecDirect(Str2ConstChar(Line_));
284296
//Script::Debug::Wait();
285297
if (ret_) {
286-
ScriptargumentClass::Scriptargument_->setLineNumber(ScriptargumentClass::Scriptargument_->GetLineNumber() + 1);
298+
ScriptargumentClass::Scriptargument_->setCurrentlineIndex(ScriptargumentClass::Scriptargument_->GetCurrentlineIndex() + 1);
287299
return ret_;
288300
}
289301
else
@@ -300,7 +312,7 @@ namespace ScriptWindowArg {
300312
ret_ = DbgCmdExecDirect(Str2ConstChar(Line_));
301313
//Script::Debug::Wait();
302314
if (ret_) {
303-
ScriptargumentClass::Scriptargument_->setLineNumber(ScriptargumentClass::Scriptargument_->GetLineNumber() + 1);
315+
ScriptargumentClass::Scriptargument_->setCurrentlineIndex(ScriptargumentClass::Scriptargument_->GetCurrentlineIndex() + 1);
304316
return ret_;
305317
}
306318
else
@@ -316,19 +328,23 @@ namespace ScriptWindowArg {
316328
}
317329

318330
void waitPauseProcess() {
331+
if (!DbgIsDebugging())
332+
return;
319333
while (!_plugin_waituntilpaused()) {
320334
Application::DoEvents();
321335
}
322336

323337
}
324338

325-
339+
326340
bool Need_wait(String^ cmd_) {
327-
cmd_ = cmd_->Substring(0, cmd_->IndexOf(" ")); /// get command
328-
int Need_wait = ScriptargumentClass::Scriptargument_->CommandsNeedwait(cmd_->ToLower()->Trim());
329-
if (Need_wait >= 0) {
330-
return true;
331-
}
341+
if (cmd_->Trim()->Contains(" ")) {
342+
cmd_ = cmd_->Substring(0, cmd_->IndexOf(" ")); /// get command
343+
int Need_wait = ScriptargumentClass::Scriptargument_->CommandsNeedwait(cmd_->ToLower()->Trim());
344+
if (Need_wait >= 0) {
345+
return true;
346+
}
347+
}
332348
return false;
333349
}
334350

AdvancedScript/ScriptFun.cpp

Lines changed: 54 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -697,7 +697,7 @@ bool dumpmem(String^ addr, String^ size, String^ para) {
697697
bool WriteStr_(duint address, String^ text, bool replace) {
698698
String^ intValue;
699699
const char* text_ = Str2ConstChar(text);
700-
if (CheckHexIsValid(duint2Hex(address), intValue)>0) {
700+
if (CheckHexIsValid(duint2Hex(address), intValue) > 0) {
701701
if (!replace) {
702702
return Script::Memory::Write(address, text_, strlen(text_), &address);
703703
}
@@ -800,26 +800,26 @@ bool gotox_(String^ input, String^% lineNumber) {
800800
{
801801
case 1: {
802802
/// first we check if its decimal it should hold d at the end
803-
if ((arguments[0]->EndsWith("d")) && (Information::IsNumeric((arguments[0]->Substring(0, arguments[0]->Length - 1))))) {
804-
lineNumber = arguments[0]->Substring(0, arguments[0]->Length - 1);
803+
//if ((arguments[0]->EndsWith("d")) && (Information::IsNumeric((arguments[0]->Substring(0, arguments[0]->Length - 1))))) {
804+
// lineNumber = arguments[0]->Substring(0, arguments[0]->Length - 1);
805+
// return true;
806+
//}
807+
//else /// if its not decimal then we should analyze the string if it's hex value
808+
//{
809+
//lineNumber = StrAnalyze(arguments[0], VarType::int_);
810+
//if (!Information::IsNumeric(lineNumber)) { /// in case the value not numric that mean it could be a Lable
811+
LableLine^ LLine = GetLineByLable(arguments[0]);
812+
if (LLine->Lable != "") {
813+
lineNumber = int2Str(LLine->LableLineNumber);
805814
return true;
806815
}
807-
else /// if its not decimal then we should analyze the string if it's hex value
816+
else
808817
{
809-
lineNumber = StrAnalyze(arguments[0], VarType::int_);
810-
if (!Information::IsNumeric(lineNumber)) { /// in case the value not numric that mean it could be a Lable
811-
LableLine^ LLine = GetLineByLable(arguments[0]);
812-
if (LLine->Lable != "") {
813-
lineNumber = int2Str(LLine->LableLineNumber);
814-
return true;
815-
}
816-
else
817-
{
818-
_plugin_logputs(Str2ConstChar(Environment::NewLine + lineNumber + " : true line is incorect"));
819-
return false;
820-
}
821-
}
818+
_plugin_logputs(Str2ConstChar(Environment::NewLine + lineNumber + " : true line is incorect"));
819+
return false;
822820
}
821+
//}
822+
//}
823823
break;
824824
}
825825
default:
@@ -843,49 +843,51 @@ bool ifCond(String^ input, String^% lineNumber, int currentLine) { // if condti
843843
String^ trueline; String^ falseline;
844844
if (arguments[2]->Trim() != "0") { /// we add option if 0 then go next line
845845
/// first we check if its decimal it should hold d at the end
846-
if ((arguments[2]->EndsWith("d")) && (Information::IsNumeric((arguments[2]->Substring(0, arguments[2]->Length - 1))))) {
847-
trueline = arguments[2]->Substring(0, arguments[2]->Length - 1);
846+
// after I add richTextBox I remove jmp to line number
847+
848+
//if ((arguments[2]->EndsWith("d")) && (Information::IsNumeric((arguments[2]->Substring(0, arguments[2]->Length - 1))))) {
849+
// trueline = arguments[2]->Substring(0, arguments[2]->Length - 1);
850+
//}
851+
//else /// if its not decimal then we should analyze the string if it's hex value
852+
//{
853+
//trueline = StrAnalyze(arguments[2], VarType::int_);
854+
//if (!Information::IsNumeric(trueline)) { /// in case the value not numric that mean it could be a Lable
855+
LableLine^ LLine = GetLineByLable(arguments[2]);
856+
if (LLine->Lable != "") {
857+
trueline = int2Str(LLine->LableLineNumber);
848858
}
849-
else /// if its not decimal then we should analyze the string if it's hex value
859+
else
850860
{
851-
trueline = StrAnalyze(arguments[2], VarType::int_);
852-
if (!Information::IsNumeric(trueline)) { /// in case the value not numric that mean it could be a Lable
853-
LableLine^ LLine = GetLineByLable(arguments[2]);
854-
if (LLine->Lable != "") {
855-
trueline = int2Str(LLine->LableLineNumber);
856-
}
857-
else
858-
{
859-
_plugin_logputs(Str2ConstChar(Environment::NewLine + trueline + " : true line is incorect"));
860-
return false;
861-
}
862-
}
861+
_plugin_logputs(Str2ConstChar(Environment::NewLine + trueline + " : true line is incorect"));
862+
return false;
863863
}
864+
//}
865+
//}
864866
}
865867
else
866868
{
867869
trueline = int2Str(currentLine + 1);
868870
}
869871
if (arguments[3]->Trim() != "0") { /// we add option if 0 then go next line
870872
/// first we check if its decimal it should hold d at the end
871-
if ((arguments[3]->EndsWith("d")) && (Information::IsNumeric((arguments[3]->Substring(0, arguments[3]->Length - 1))))) {
872-
falseline = arguments[3]->Substring(0, arguments[3]->Length - 1);
873+
//if ((arguments[3]->EndsWith("d")) && (Information::IsNumeric((arguments[3]->Substring(0, arguments[3]->Length - 1))))) {
874+
// falseline = arguments[3]->Substring(0, arguments[3]->Length - 1);
875+
//}
876+
//else /// if its not decimal then we should analyze the string if it's hex value
877+
//{
878+
//falseline = StrAnalyze(arguments[3], VarType::int_);
879+
//if (!Information::IsNumeric(falseline)) { /// in case the value not numric that mean it could be a Lable
880+
LableLine^ LLine = GetLineByLable(arguments[3]);
881+
if (LLine->Lable != "") {
882+
falseline = int2Str(LLine->LableLineNumber);
873883
}
874-
else /// if its not decimal then we should analyze the string if it's hex value
884+
else
875885
{
876-
falseline = StrAnalyze(arguments[3], VarType::int_);
877-
if (!Information::IsNumeric(falseline)) { /// in case the value not numric that mean it could be a Lable
878-
LableLine^ LLine = GetLineByLable(arguments[3]);
879-
if (LLine->Lable != "") {
880-
falseline = int2Str(LLine->LableLineNumber);
881-
}
882-
else
883-
{
884-
_plugin_logputs(Str2ConstChar(Environment::NewLine + falseline + " : true line is incorect"));
885-
return false;
886-
}
887-
}
886+
_plugin_logputs(Str2ConstChar(Environment::NewLine + falseline + " : true line is incorect"));
887+
return false;
888888
}
889+
//}
890+
//}
889891
}
890892
else
891893
{
@@ -942,12 +944,12 @@ String^ condtion_(String^ input, String^ typo) {
942944
left_ = StrAnalyze(left_, VarType::str);
943945
right_ = StrAnalyze(right_, VarType::str);
944946
if ((left_->StartsWith("NULL/")) || (right_->StartsWith("NULL/"))) {
945-
_plugin_logprint(Str2ConstChar(Environment::NewLine + "can't resolve sides" + "left_="+ left_ + " - right_:"+ right_));
947+
_plugin_logprint(Str2ConstChar(Environment::NewLine + "can't resolve sides" + "left_=" + left_ + " - right_:" + right_));
946948
MsgBoxResult MsgRet = Interaction::MsgBox("can't resolve sides" + Environment::NewLine + "left_=" + left_ + " - right_:" + right_ + Environment::NewLine + "Yes to ret true" + Environment::NewLine + "No to ret false" + Environment::NewLine + "Cancel to Stop", MsgBoxStyle::YesNoCancel, "Error");
947949
switch (MsgRet)
948-
{
949-
case Microsoft::VisualBasic::MsgBoxResult::Cancel:
950-
return "NULL/";
950+
{
951+
case Microsoft::VisualBasic::MsgBoxResult::Cancel:
952+
return "NULL/";
951953
case Microsoft::VisualBasic::MsgBoxResult::Yes:
952954
return "1";
953955
case Microsoft::VisualBasic::MsgBoxResult::No:
@@ -956,7 +958,7 @@ String^ condtion_(String^ input, String^ typo) {
956958
break;
957959
}
958960

959-
961+
960962
}
961963
if (left_->StartsWith(right_)) {
962964
return "1"; // true

0 commit comments

Comments
 (0)