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

Commit

Permalink
-GetClipboard
Browse files Browse the repository at this point in the history
-SetClipBoard
-ToolStripMenu : startHere - copySelectedLine
-add arrayLength : now we can define the Length of the array
-make some register functions return bool to check it later which line have the error
  • Loading branch information
Ahmadmansoor committed Jan 22, 2019
1 parent 3c6c186 commit c242c0c
Show file tree
Hide file tree
Showing 8 changed files with 211 additions and 120 deletions.
2 changes: 1 addition & 1 deletion AdvancedScript/AdvancedScript.vcxproj
Expand Up @@ -108,7 +108,7 @@
<ExceptionHandling>Async</ExceptionHandling>
</ClCompile>
<Link>
<AdditionalDependencies />
<AdditionalDependencies>user32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
Expand Down
50 changes: 43 additions & 7 deletions AdvancedScript/HelperFunctions.cpp
Expand Up @@ -382,13 +382,49 @@ VarType GetVarType(String^ vartype) {
return VarType::int_;
}

char* GetClipBoard() {
HANDLE clip;
if (!std::OpenClipboard(NULL))
Generic::List<String^>^ GetClipBoard() {
//HANDLE clip;
if (!OpenClipboard(NULL))
Script::Gui::Message("Can't open clipboard");
char* clip =(char*) GetClipboardData(CF_TEXT);
CloseClipboard();
String^ text = CharArr2Str(clip);
String^ tem;
Generic::List<String^>^ temp = gcnew Generic::List<String^>;

//clip = ::GetClipboardData(CF_TEXT);
char* clip_text = (char*)clip;
//::CloseClipboard();
return clip_text;
for (int i = 0; i < text->Length; i++)
{
int dd = Microsoft::VisualBasic::Strings::Asc(text->Substring(i, 1));
if (( Microsoft::VisualBasic::Strings::Asc(text->Substring(i,1)) != 10) && (Microsoft::VisualBasic::Strings::Asc(text->Substring(i, 1)) != 13)) { //10 is new line char
tem += text->Substring(i, 1);
}
else
{
if (Microsoft::VisualBasic::Strings::Asc(text->Substring(i, 1)) != 13) { // just CR carriage return
if (tem->Trim() != "") {
temp->Add(tem);
tem = "";
}
}
}
if (i == text->Length - 1) {
if (tem->Trim() != "") {
temp->Add(tem);
tem = "";
}
}
}
return temp;
}

void SetClipBoard(String^ input) {
const char* output = Str2ConstChar(input);
const size_t len = strlen(output) + 1;
HGLOBAL hMem = GlobalAlloc(GMEM_MOVEABLE, len);
memcpy(GlobalLock(hMem), output, len);
GlobalUnlock(hMem);
OpenClipboard(0);
EmptyClipboard();
SetClipboardData(CF_TEXT, hMem);
CloseClipboard();
}
3 changes: 2 additions & 1 deletion AdvancedScript/HelperFunctions.h
Expand Up @@ -45,7 +45,8 @@ enum VarType
};

VarType GetVarType(String^ vartype);
char* GetClipBoard();
Generic::List<String^>^ GetClipBoard();
void SetClipBoard(String^ input);

System::Void GetArg(String^ input, Generic::List<String^>^% arguments, bool brackets=false);

Expand Down
86 changes: 59 additions & 27 deletions AdvancedScript/MainForm.h
Expand Up @@ -12,11 +12,11 @@ namespace AdvancedScript {
/// <summary>
/// Summary for MainForm
/// </summary>

public ref class MainForm : public System::Windows::Forms::Form
{
public:

MainForm(void)
{
InitializeComponent();
Expand All @@ -43,8 +43,9 @@ namespace AdvancedScript {
private: System::Windows::Forms::ContextMenuStrip^ CMT1;
private: System::Windows::Forms::ToolStripMenuItem^ startHereToolStripMenuItem;
private: System::Windows::Forms::ToolStripMenuItem^ pasteToolStripMenuItem;
private: System::Windows::Forms::ToolStripMenuItem^ copySelectedLineToolStripMenuItem;
private: System::ComponentModel::IContainer^ components;


protected:

Expand Down Expand Up @@ -80,13 +81,13 @@ namespace AdvancedScript {
this->CMT1 = (gcnew System::Windows::Forms::ContextMenuStrip(this->components));
this->startHereToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
this->pasteToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
this->copySelectedLineToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
(cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->DGV1))->BeginInit();
this->CMT1->SuspendLayout();
this->SuspendLayout();
//
// DGV1
//
this->DGV1->AllowUserToOrderColumns = true;
this->DGV1->Anchor = static_cast<System::Windows::Forms::AnchorStyles>(((System::Windows::Forms::AnchorStyles::Top | System::Windows::Forms::AnchorStyles::Left)
| System::Windows::Forms::AnchorStyles::Right));
this->DGV1->AutoSizeColumnsMode = System::Windows::Forms::DataGridViewAutoSizeColumnsMode::Fill;
Expand Down Expand Up @@ -145,27 +146,34 @@ namespace AdvancedScript {
//
// CMT1
//
this->CMT1->Items->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^ >(2) {
this->CMT1->Items->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^ >(3) {
this->startHereToolStripMenuItem,
this->pasteToolStripMenuItem
this->pasteToolStripMenuItem, this->copySelectedLineToolStripMenuItem
});
this->CMT1->Name = L"CMT1";
this->CMT1->Size = System::Drawing::Size(158, 48);
this->CMT1->Size = System::Drawing::Size(175, 92);
//
// startHereToolStripMenuItem
//
this->startHereToolStripMenuItem->Name = L"startHereToolStripMenuItem";
this->startHereToolStripMenuItem->Size = System::Drawing::Size(157, 22);
this->startHereToolStripMenuItem->Size = System::Drawing::Size(174, 22);
this->startHereToolStripMenuItem->Text = L"Start Here";
this->startHereToolStripMenuItem->Click += gcnew System::EventHandler(this, &MainForm::startHereToolStripMenuItem_Click);
//
// pasteToolStripMenuItem
//
this->pasteToolStripMenuItem->Name = L"pasteToolStripMenuItem";
this->pasteToolStripMenuItem->Size = System::Drawing::Size(157, 22);
this->pasteToolStripMenuItem->Size = System::Drawing::Size(174, 22);
this->pasteToolStripMenuItem->Text = L"Paste Clipboard";
this->pasteToolStripMenuItem->Click += gcnew System::EventHandler(this, &MainForm::pasteToolStripMenuItem_Click);
//
// copySelectedLineToolStripMenuItem
//
this->copySelectedLineToolStripMenuItem->Name = L"copySelectedLineToolStripMenuItem";
this->copySelectedLineToolStripMenuItem->Size = System::Drawing::Size(174, 22);
this->copySelectedLineToolStripMenuItem->Text = L"Copy Selected Line";
this->copySelectedLineToolStripMenuItem->Click += gcnew System::EventHandler(this, &MainForm::copySelectedLineToolStripMenuItem_Click);
//
// MainForm
//
this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
Expand All @@ -184,7 +192,7 @@ namespace AdvancedScript {
private: System::Void DGV1_KeyUp(System::Object^ sender, System::Windows::Forms::KeyEventArgs^ e) {
if (e->KeyCode == Keys::F12) {
DGV1->ClearSelection();
if (ScriptargumentClass::Scriptargument_->GetLineNumber() < DGV1->RowCount-1) {
if (ScriptargumentClass::Scriptargument_->GetLineNumber() < DGV1->RowCount - 1) {
DGV1->ClearSelection();
DGV1->Rows[ScriptargumentClass::Scriptargument_->GetLineNumber()]->Selected = true;
readLine(DGV1->Rows[ScriptargumentClass::Scriptargument_->GetLineNumber()]->Cells[1]->Value->ToString(), DGV1->Rows->Count);
Expand All @@ -209,22 +217,46 @@ namespace AdvancedScript {
DGV1->Rows[i]->Cells[0]->Value = i;
}
}
private: System::Void startHereToolStripMenuItem_Click(System::Object^ sender, System::EventArgs^ e) {
ScriptargumentClass::Scriptargument_->setLineNumber(DGV1->CurrentRow->Index - 1);
}
private: System::Void pasteToolStripMenuItem_Click(System::Object^ sender, System::EventArgs^ e) {
DGV1->Rows->Clear();
char* line=GetClipBoard();
int i = 0;
/*while ((line = MyClassScriptArray::ScriptArray->ReadLine()) != nullptr)
{
DGV1->Rows->Add();
DGV1->Rows[i]->Cells[0]->Value = i;
DGV1->Rows[i]->Cells[1]->Value = line;
i += 1;
}*/

}
private: System::Void startHereToolStripMenuItem_Click(System::Object^ sender, System::EventArgs^ e) {
ScriptargumentClass::Scriptargument_->setLineNumber(DGV1->CurrentRow->Index);
}
private: System::Void pasteToolStripMenuItem_Click(System::Object^ sender, System::EventArgs^ e) {
DGV1->Rows->Clear();
Generic::List<String^>^ lines = GetClipBoard();
int i = 0;
for (int i = 0; i < lines->Count; i++)
{
DGV1->Rows->Add();
DGV1->Rows[i]->Cells[0]->Value = i;
if (lines[i]->Contains("//")) {
DGV1->Rows[i]->Cells[1]->Value = (lines[i]->Substring(0, lines[i]->IndexOf("//")))->Trim();
DGV1->Rows[i]->Cells[2]->Value = (lines[i]->Substring(lines[i]->IndexOf("//") + 2, lines[i]->Length - (lines[i]->IndexOf("//") + 2)))->Trim();
}
else {
DGV1->Rows[i]->Cells[1]->Value = lines[i]->Trim();
}
}
}
private: System::Void copySelectedLineToolStripMenuItem_Click(System::Object^ sender, System::EventArgs^ e) {
String^ HoldClipBoradStr = String::Empty;
DataGridViewSelectedRowCollection^ DGVRC = DGV1->SelectedRows;
//DGVRC= DGVRC->
for (int i = 0; i < DGVRC->Count; i++)
{

if (DGVRC[i]->Cells[1]->Value != nullptr) {
if (DGVRC[i]->Cells[2]->Value == nullptr) {
HoldClipBoradStr += DGVRC[i]->Cells[1]->Value->ToString() + Environment::NewLine; //DGVRC[i]->Cells[2]->Value->ToString() +
}
else {
HoldClipBoradStr += DGVRC[i]->Cells[1]->Value->ToString() + " //" + DGVRC[i]->Cells[2]->Value->ToString() + Environment::NewLine; //
}
}

}

};
SetClipBoard(HoldClipBoradStr);

}
};
}
15 changes: 8 additions & 7 deletions AdvancedScript/Parser.cpp
Expand Up @@ -30,25 +30,26 @@ String^ readVarName(String^ input, int arrayIndex, String^% VarString2Replace) {
String^ value_ = "";
String^ value_1 = "";
String^ vartype = "";
int arrayLength;
int index_ = 0;
int index_t = 0;
for (int i = 0; i < temp->Length; i++)
{
value_ = value_ + temp->Substring(i, 1);
if (i + 1 == temp->Length) { /// if this later is the end of string
if (Varexist(value_, vartype, index_)) {
if (Varexist(value_, vartype, index_, arrayLength)) {
VarString2Replace = value_;
return ScriptFunList::VarList[index_]->varvalue[arrayIndex];
}
else { return "NULL/ "; }
}
if (temp->Substring(i + 1, 1) == " ") { /// if the next letter is space
if (Varexist(value_, vartype, index_)) {
if (Varexist(value_, vartype, index_, arrayLength)) {
VarString2Replace = value_;
return ScriptFunList::VarList[index_]->varvalue[arrayIndex];
}
}
while (Varexist(value_, vartype, index_))
while (Varexist(value_, vartype, index_, arrayLength))
{
if (i + 1 < temp->Length) {
i += 1;
Expand All @@ -72,7 +73,7 @@ String^ findVarValue(String^ input, VarType retAsVartype, String^% VarString) {
// In case Var is int then no need to check for Hex validation
// but if the Var is string we need to check for hex validation and shift it to int
String^ ArrayIndexValue = "";
String^ var_name = "";
String^ var_name = ""; int arrayLength;
String^ vartype_ = ""; int indexofVar = 0;
if (!input->Contains("$")) {
return "NULLx/ no Variable name"; // this mean there are no variable in this string
Expand All @@ -83,7 +84,7 @@ String^ findVarValue(String^ input, VarType retAsVartype, String^% VarString) {
}
if ((input->IndexOf("[") > 0) && (input->IndexOf("$") < 0)) { // variable is Array /// we must check if there are another var ( contain $ ) so we not mix with other var's
var_name = input->Substring(0, input->IndexOf("[")); // get Var name
if (Varexist(var_name->Trim(), vartype_, indexofVar)) { /// check if var exist // we clear space here just , because we need to build VarString
if (Varexist(var_name->Trim(), vartype_, indexofVar, arrayLength)) { /// check if var exist // we clear space here just , because we need to build VarString
if (vartype_ == "array" && input->IndexOf("]") > 0) { // var type must be array and the rest of string must have close ]
for (int i = input->IndexOf("[") + 1; i < input->Length; i++) //get index of var
{
Expand Down Expand Up @@ -145,7 +146,7 @@ String^ findVarValue(String^ input, VarType retAsVartype, String^% VarString) {
}
if (input->IndexOf(" ") > 0) { /// var is int or str
var_name = input->Substring(0, input->IndexOf(" ")); // get Var name and clear spaces
if (Varexist(var_name->Trim(), vartype_, indexofVar)) { /// check if var exist
if (Varexist(var_name->Trim(), vartype_, indexofVar, arrayLength)) { /// check if var exist
VarString = "$" + var_name; // this is the end index of var we will used later to replace string

if (retAsVartype == VarType::str) {/// if we need ret var value as string it will back as str no need to change the value
Expand Down Expand Up @@ -178,7 +179,7 @@ String^ findVarValue(String^ input, VarType retAsVartype, String^% VarString) {
else
{ /// there are no space at the end we need to search the rest of the string
var_name = input; /// we didn't find it as array or didn't find space then we get all string as var name
if (Varexist(var_name->Trim(), vartype_, indexofVar)) { /// check if var exist
if (Varexist(var_name->Trim(), vartype_, indexofVar, arrayLength)) { /// check if var exist
VarString = "$" + var_name; // this is the end index of var we will used later to replace string

if (retAsVartype == VarType::str) {/// if we need ret var value as string it will back as str no need to change the value
Expand Down
20 changes: 8 additions & 12 deletions AdvancedScript/Register_UnRegister_Commands.cpp
Expand Up @@ -183,7 +183,7 @@ static void ShowDialog_Script()

static bool cbMainForm(int argc, char* argv[])
{
_plugin_logputs("[Script Window] Loading Form!");
_plugin_logputs("[Script Window] Loading.......!");
///////////////////////////////////////////////////////////////////////////////////////
// this will keep form activate and x64dbg unable to do it's work by excuted commands
//ScriptS::IATFixer IATFixer;
Expand Down Expand Up @@ -440,12 +440,10 @@ static bool Varx(int argc, char* argv[]) { //Varx_(String^ vartype, String^ varn
switch ((arguments->Count))
{
case 2: {
Varx_(arguments[0], arguments[1]); // varvalue will make it ""
break;
return Varx_(arguments[0], arguments[1]); // varvalue will make it ""
}
case 3: {
Varx_(arguments[0], arguments[1], arguments[2]);
break;
return Varx_(arguments[0], arguments[1], arguments[2]);
}
default:
_plugin_logputs(Str2ConstChar(Environment::NewLine + "worng arguments"));
Expand All @@ -454,7 +452,7 @@ static bool Varx(int argc, char* argv[]) { //Varx_(String^ vartype, String^ varn
return true;
}

static bool SetVarx(int argc, char* argv[]) { //SetVarx_(String^ varname, int index_,String^ value_)
static bool SetVarx(int argc, char* argv[]) { //Setx_(String^ varname, int index_,String^ value_)
Generic::List<String^>^ arguments;
GetArg(charPTR2String(argv[0]), arguments); // this function use by refrence so the list will fill direct
String^ arrayIndex;
Expand All @@ -473,21 +471,19 @@ static bool SetVarx(int argc, char* argv[]) { //SetVarx_(String^ varname, int
}
else
{ /// we checkd that array index is int, need to check the value of the array
SetVarx_(arguments[0]->Substring(0, arguments[0]->IndexOf("["))->Trim(), (int)Str2duint(arrayIndex->Trim()), arguments[1]);
return SetVarx_(arguments[0]->Substring(0, arguments[0]->IndexOf("["))->Trim(), (int)Str2duint(arrayIndex->Trim()), arguments[1]);
}

}
else /// var is str or int
{
SetVarx_(arguments[0], 0, arguments[1]);
}
break;
return SetVarx_(arguments[0], 0, arguments[1]);
}
}
default:
_plugin_logputs(Str2ConstChar(Environment::NewLine + "worng arguments"));
return false;
}
return true;
}
}

static bool GetVarx(int argc, char* argv[]) { //GetVarx_(String^ varname,int index)
Expand Down

0 comments on commit c242c0c

Please sign in to comment.