我免费发布了一堆工具,但最近我开始销售一个有私人研究的应用程序,人们已经能够获得我的源代码,一个人公开发布我的整个源代码.我花了很多时间在这个程序上,只是为了让别人破解它,并释放我的整个源代码.
我怎样才能保护我的程序?我尝试过HWID,但人们仍然可以破解它.我知道我受限于C#,但它最方便使用.我只需要一种方法来保护我的程序免受试图这样做的人的影响.
基本上,我的程序与另一个jar文件一起运行.以下是下载功能的代码:
public void saveUrl(final String filename, final String urlString) throws MalformedURLException, IOException {
BufferedInputStream in = null;
FileOutputStream fout = null;
try {
in = new BufferedInputStream(new URL(urlString).openStream());
fout = new FileOutputStream(filename);
final byte data[] = new byte[1024];
int count;
while ((count = in.read(data, 0, 1024)) != -1) {
fout.write(data, 0, count);
}
} catch (Exception e) {
return;
} finally {
if (in != null) {
in.close();
}
if (fout != null) {
fout.close();
}
}
}
Run Code Online (Sandbox Code Playgroud)
并开始新的过程
public …
Run Code Online (Sandbox Code Playgroud) 我在比较从用户模式类型 LPWSTR 传递到 LDR 表条目类型 UNICODE_STRING 的字符串时遇到困难
内核 C:
struct {
int pid;
int user_pid;
int size;
int protection_mode;
int allocation_type;
void* address;
void* write_buffer;
LPWSTR module_name;
}
userland_operation;
Run Code Online (Sandbox Code Playgroud)
这个结构体通过 deviceiocontrol 传递给内核。对应的用户空间结构如下:
public struct MemOperation
{
public int Pid;
public int UserPid;
public int Size;
public int protection_mode;
public int allocation_type;
public IntPtr Addr;
public IntPtr WriteBuffer;
[MarshalAs(UnmanagedType.LPWStr)] public String ModuleName;
}
Run Code Online (Sandbox Code Playgroud)
字符串在哪里 ModuleName
被编组为 LPWStr。
ModuleName
是进程中加载模块的所需搜索词。现在,事情变得棘手了。我可以通过访问的字符串_LDR_DATA_TABLE_ENTRY
是UNICODE_STRING
. 我想将此 UNICODE_STRING 与我的 LPWSTR 进行比较。
我尝试了以下方法,但没有奏效:
{
UNICODE_STRING …
Run Code Online (Sandbox Code Playgroud) 我在读取二进制 PList 时遇到问题。我使用的是 Windows 计算机,并且尝试了几种 pList 阅读器。我似乎真的无法克服错误“第 1 行出现意外字符 'b'”。
以 C# 结构体为例:
[StructLayout(LayoutKind.Explicit)]
public struct Example
{
[FieldOffset(0x10)]
public IntPtr examplePtr;
[FieldOffset(0x18)]
public IntPtr examplePtr2;
[FieldOffset(0x54)]
public int exampleInt;
}
Run Code Online (Sandbox Code Playgroud)
我可以获取一个字节数组,并将其转换为这个结构,如下所示:
public static T GetStructure<T>(byte[] bytes)
{
var handle = GCHandle.Alloc(bytes, GCHandleType.Pinned);
var structure = (T)Marshal.PtrToStructure(handle.AddrOfPinnedObject(), typeof(T));
handle.Free();
return structure;
}
public static T GetStructure<T>(byte[] bytes, int index)
{
var size = Marshal.SizeOf(typeof(T));
var tmp = new byte[size];
Array.Copy(bytes, index, tmp, 0, size);
return GetStructure<T>(tmp);
}
GetStructure<Example>(arrayOfBytes);
Run Code Online (Sandbox Code Playgroud)
C++ 中是否有等效的功能来获取字节数组并将其转换为结构,其中并非所有字节都用于转换(C# structlayout.explicit w/field offsets)?
我不希望做像下面这样:
struct {
pad_bytes[0x10];
DWORD64 …
Run Code Online (Sandbox Code Playgroud)