GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — 添加文件 · 550cc/linuxKernelRoot@a0809ff

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • ida_patch_cmd_creator
    • 3rdparty
      • aarch64-linux-android-as.exe
      • arm-linux-androideabi-as.exe
    • ArmAsmHelper.h
    • IDAPythonScripHelper.h
    • empty
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎ida_patch_cmd_creator/3rdparty/aarch64-linux-android-as.exe‎

Copy file name to clipboard
1.41 MB
Binary file not shown.
Collapse file

‎ida_patch_cmd_creator/3rdparty/arm-linux-androideabi-as.exe‎

Copy file name to clipboard
1.34 MB
Binary file not shown.
Collapse file

‎ida_patch_cmd_creator/ArmAsmHelper.h‎

Copy file name to clipboard
+96Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
#ifndef ARM_ASM_HELPER_H_
2+
#define ARM_ASM_HELPER_H_
3+
#include <string>
4+
#include <windows.h>
5+
#include <fstream>
6+
#include <sstream>
7+
8+
std::string AsmToBytes(const std::string & strArm64Asm)
9+
{
10+
//获取汇编文本
11+
12+
//获取自身运行目录
13+
char szFileName[MAX_PATH] = { 0 };
14+
::GetModuleFileNameA(NULL, szFileName, MAX_PATH);
15+
std::string strMyPath = szFileName;
16+
strMyPath = strMyPath.substr(0, strMyPath.find_last_of('\\') + 1);
17+
18+
//写出input.txt
19+
std::ofstream inputFile;
20+
inputFile.open(strMyPath + "input.txt", std::ios_base::out | std::ios_base::trunc);
21+
inputFile << strArm64Asm;
22+
inputFile.close();
23+
24+
//ARM64
25+
DeleteFileA(std::string(strMyPath + "output.txt").c_str());
26+
27+
std::string cmd = strMyPath + "aarch64-linux-android-as.exe -ahlm " + strMyPath + "input.txt >> " + strMyPath + "output.txt";
28+
system(cmd.c_str());
29+
30+
//未开发的
31+
//ARM:arm-linux-as.exe -ahlm -k -mthumb-interwork -march=armv7-a %s >> %s
32+
//Thumb:arm-linux-as.exe -ahlm -k -mthumb-interwork -march=armv7 %s >> %s
33+
34+
//读取output.txt
35+
std::ifstream in(strMyPath + "output.txt");
36+
std::stringstream ssOutput;
37+
std::string line;
38+
bool bIsFirstLine = true;
39+
if (in) // 有该文件
40+
{
41+
while (getline(in, line)) // line中不包括每行的换行符
42+
{
43+
if(bIsFirstLine)
44+
{
45+
bIsFirstLine = false;
46+
continue;
47+
}
48+
if(!line.length()) { continue; }
49+
if(line.length() == 1 && line == "\n") { continue; }
50+
51+
std::stringstream ssGetMidBuf;
52+
std::string word;
53+
ssGetMidBuf << line;
54+
int n = 0;
55+
while (ssGetMidBuf >> word)
56+
{
57+
n++;
58+
if (n == 3)
59+
{
60+
ssOutput << word;
61+
}
62+
word.empty();
63+
}
64+
65+
66+
}
67+
in.close();
68+
}
69+
70+
return ssOutput.str();
71+
72+
}
73+
74+
const char HEX[16] = {
75+
'0', '1', '2', '3',
76+
'4', '5', '6', '7',
77+
'8', '9', 'a', 'b',
78+
'c', 'd', 'e', 'f'
79+
};
80+
81+
/* Convert byte array to hex string. */
82+
std::string bytesToHexString(const byte* input, size_t length) {
83+
84+
std::string str;
85+
str.reserve(length << 1);
86+
for (size_t i = 0; i < length; ++i) {
87+
int t = input[i];
88+
int a = t / 16;
89+
int b = t % 16;
90+
str.append(1, HEX[a]);
91+
str.append(1, HEX[b]);
92+
}
93+
return str;
94+
}
95+
96+
#endif /* ARM_ASM_HELPER_H_ */
Collapse file

‎ida_patch_cmd_creator/IDAPythonScripHelper.h‎

Copy file name to clipboard
+60Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
#ifndef IDA_PYTHON_SCRIPT_HELPER_H_
2+
#define IDA_PYTHON_SCRIPT_HELPER_H_
3+
#include <string>
4+
#include <windows.h>
5+
#include <fstream>
6+
#include <sstream>
7+
8+
9+
inline std::string& replace_all_distinct(std::string& str, const std::string& old_value, const std::string& new_value)
10+
{
11+
for (std::string::size_type pos(0); pos != std::string::npos; pos += new_value.length())
12+
{
13+
if ((pos = str.find(old_value, pos)) != std::string::npos)
14+
{
15+
str.replace(pos, old_value.length(), new_value);
16+
}
17+
else
18+
{
19+
break;
20+
}
21+
}
22+
return str;
23+
}
24+
25+
26+
std::string GetFormatAsmBytes(const std::string & strAsmBytesLine)
27+
{
28+
if (strAsmBytesLine.length() % 2)
29+
{
30+
return std::string();
31+
}
32+
33+
std::stringstream ssFormatBytesTxt;
34+
int n = 0;
35+
for (size_t i = 0; i < strAsmBytesLine.length(); i++)
36+
{
37+
ssFormatBytesTxt << strAsmBytesLine[i];
38+
n++;
39+
if (n == 2 && i != strAsmBytesLine.length() - 1)
40+
{
41+
ssFormatBytesTxt << " ";
42+
n = 0;
43+
}
44+
}
45+
return ssFormatBytesTxt.str();
46+
}
47+
48+
49+
std::string GetIdaAsmScript(const std::string & strBytes, size_t writeAddr)
50+
{
51+
std::string formatBytes = GetFormatAsmBytes(strBytes);
52+
std::stringstream ssScript;
53+
ssScript
54+
<< "buf = [0x" << replace_all_distinct(formatBytes, " ", ", 0x") << "]" << std::endl
55+
<< "for index in range(len(buf)) :" << std::endl
56+
<< "\t" << "patch_byte(0x" << std::hex << writeAddr << " + index, buf[index]);";
57+
return ssScript.str();
58+
}
59+
60+
#endif /* IDA_PYTHON_SCRIPT_HELPER_H_ */
Collapse file

‎ida_patch_cmd_creator/empty‎

Copy file name to clipboardExpand all lines: ida_patch_cmd_creator/empty
Whitespace-only changes.

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.