Skip to content

Instantly share code, notes, and snippets.

View 0xF6's full-sized avatar
🧬

Yuuki Wesp 0xF6

🧬
View GitHub Profile
public static boolean is64bitProcess()
{
String wow64_kernel = System.getenv("systemroot") + "\\SysWOW64\\kernel32.dll";
if (new File(wow64_kernel).exists())
{
try
{
System.load(wow64_kernel);
}
catch (UnsatisfiedLinkError e)
@0xF6
0xF6 / CLRArrayToJNIArray.cpp
Created November 9, 2015 11:05
CLR Byte Array to JNI byte Array
jbyteArray toJByteArray(JNIEnv * pEnv, array<byte>^ arr)
{
jbyteArray jab = pEnv->NewByteArray(arr->Length);
pin_ptr<unsigned char> pUnmanagedArr = &arr[0];
pEnv->SetByteArrayRegion(jab, 0, arr->Length , (jbyte*)pUnmanagedArr);
return jab;
}
@0xF6
0xF6 / CLRStringToJNIString.cpp
Created November 9, 2015 11:07
CLR String to JNI String
jstring Aix::tojString(JNIEnv * pEnv, String^ str)
{
array<byte>^ arr = Encoding::UTF8->GetBytes(str);
pin_ptr<Byte> pinnedBytes = &arr[0];
jstring s = pEnv->NewStringUTF(reinterpret_cast<char*>(pinnedBytes));
return s;
}
@0xF6
0xF6 / JStringToContChar.cpp
Created November 9, 2015 11:08
JNI String to const char*
const char* toConstChar(JNIEnv* pEnv, jstring jStr)
{
const char* nativeString = pEnv->GetStringUTFChars(jStr, JNI_FALSE);
pEnv->ReleaseStringUTFChars(jStr, nativeString);
return nativeString;
}
@0xF6
0xF6 / PointStream.cs
Created November 9, 2015 11:11
Manipulate a pointer to a stream.
public struct StreamPoint
{
private Stream stream;
private long offset;
public StreamPoint(Stream s) : this(s, s.Position) { }
public StreamPoint(Stream s, long pos)
{
if (s == null)
throw new ArgumentNullException("stream");
stream = s;
@0xF6
0xF6 / StramReadStructure.cs
Created November 9, 2015 11:14
Read a structure in stream
using System;
using System.IO;
public unsafe static T Read<T>(this Stream s) where T : struct
{
int i = System.Runtime.InteropServices.Marshal.SizeOf(typeof(T));
byte[] buffer = new byte[i];
s.Read(buffer, 0, i);
fixed (byte* pBuffer = &buffer[0])
return (T)System.Runtime.InteropServices.Marshal.PtrToStructure((IntPtr)pBuffer, typeof(T));
@0xF6
0xF6 / decompile.ps1
Created September 20, 2018 02:32
How to decompile to java files intellij idea 2018.2
java -cp ".\plugins\java-decompiler\lib\java-decompiler.jar" org.jetbrains.java.decompiler.main.decompiler.ConsoleDecompiler -dgs=true .\JARFILE.jar .\src
[1549,7009,7710,2616,3740]
@0xF6
0xF6 / calc.cs
Last active May 3, 2019 21:39
Mini Calculator
namespace Calculator
{
using static System.Console;
using Sprache;
using System.Linq;
internal class Program
{
public static void Main(string[] args)
{