i have this part of c++ one part is LogId.cpp and the other ones is vLogID.cpp. my issue is how to connect this assembly language to java ? any example of using JNI or JNA ?
string res = Trades.trades.LogID.Decode(bytes, 0).ToString();
and here example of LogID.cpp for LogID.cpp
#include "vLoginId.h"
#using <mscorlib.dll>
using namespace System;
using namespace System::Runtime::InteropServices;
using namespace System::Collections::Generic;
#pragma once
namespace Trades
{
namespace trades
{
public ref class LogID
{
public:
static ULONGLONG Decode(array<Byte>^ data, int arg8)
{
pin_ptr<Byte> pData = &data[0];
vLoginId login;
return login.Decode((ULONGLONG*)pData, data->Length / 8, arg8);
}
};
}
}
and here for vLogId.cpp
#include "vLoginId.h"
extern "C" ULONGLONG _aullrem(ULONGLONG a, ULONGLONG b);
int main(int, char**)
{
return 0;
}
ULONGLONG t00D62EC8[64] = {
0x145C311F09F7FC13, 0x35527CFB98BC2B31, 0x5648C8D827805A4F, 0x773F14B4B644896D,
0x183560914508B88A, 0x392BAC6DD3CCE7A8, 0x5A21F84A629116C6, 0x7B184426F15545E4,
0x1C0E900380197503, 0x3D04DBE00EDDA421, 0x5DFB27BC9DA1D33F, 0x7EF173992C66025D,
0x1FE7BF75BB2A317A, 0x40DE0B5249EE6098, 0x61D4572ED8B28FB6, 0x02CAA30B6776BED5,
0x23C0EEE7F63AEDF3, 0x44B73AC484FF1D11, 0x65AD86A113C34C2F, 0x06A3D27DA2877B4C,
0x279A1E5A314BAA6A, 0x48906A36C00FD988, 0x6986B6134ED408A6, 0x0A7D01EFDD9837C5,
0x2B734DCC6C5C66E3, 0x4C6999A8FB209601, 0x6D5FE58589E4C51F, 0x0E56316218A8F43C,
0x2F4C7D3EA76D235A, 0x5042C91B36315278, 0x713914F7C4F58196, 0x122F60D453B9B0B5,
0x3325ACB0E27DDFD3, 0x541BF88D71420EF1, 0x7512446A00063E0F, 0x160890468ECA6D2C,
0x36FEDC231D8E9C4A, 0x57F527FFAC52CB68, 0x78EB73DC3B16FA86, 0x19E1BFB8C9DB29A5,
0x3AD80B95589F58C3, 0x5BCE5771E76387E1, 0x7CC4A34E7627B6FF, 0x1DBAEF2B04EBE61C,
0x3EB13B0793B0153A, 0x5FA786E422744458, 0x009DD2C0B1387377, 0x21941E9D3FFCA295,
0x428A6A79CEC0D1B3, 0x6380B6565D8500D1, 0x04770232EC492FEE, 0x256D4E0F7B0D5F0C,
0x466399EC09D18E2A, 0x6759E5C89895BD48, 0x085031A52759EC67, 0x29467D81B61E1B85,
0x4A3CC95E44E24AA3, 0x6B33153AD3A679C1, 0x0C296117626AA8DE, 0x2D1FACF3F12ED7FC,
0x4E15F8D07FF3071A, 0x6F0C44AD0EB73638, 0x100290899D7B6557, 0x30F8DC662C3F9475 };
ULONGLONG t00D630C8[64] = {
0x145C311F09F7FC12, 0x35527CFB98BC2B33, 0x5648C8D827805A4B, 0x773F14B4B6448965,
0x183560914508B89A, 0x392BAC6DD3CCE788, 0x5A21F84A62911686, 0x7B184426F1554564,
0x1C0E900380197403, 0x3D04DBE00EDDA621, 0x5DFB27BC9DA1D73F, 0x7EF173992C660A5D,
0x1FE7BF75BB2A217A, 0x40DE0B5249EE4098, 0x61D4572ED8B2CFB6, 0x02CAA30B67763ED5,
0x23C0EEE7F63BEDF3, 0x44B73AC484FD1D11, 0x65AD86A113C74C2F, 0x06A3D27DA28F7B4C,
0x279A1E5A315BAA6A, 0x48906A36C02FD988, 0x6986B6134E9408A6, 0x0A7D01EFDD1837C5,
0x2B734DCC6D5C66E3, 0x4C6999A8F9209601, 0x6D5FE5858DE4C51F, 0x0E56316210A8F43C,
0x2F4C7D3EB76D235A, 0x5042C91B16315278, 0x713914F784F58196, 0x122F60D4D3B9B0B5,
0x3325ACB1E27DDFD3, 0x541BF88F71420EF1, 0x7512446E00063E0F, 0x1608904E8ECA6D2C,
0x36FEDC331D8E9C4A, 0x57F527DFAC52CB68, 0x78EB739C3B16FA86, 0x19E1BF38C9DB29A5,
0x3AD80A95589F58C3, 0x5BCE5571E76387E1, 0x7CC4A74E7627B6FF, 0x1DBAE72B04EBE61C,
0x3EB12B0793B0153A, 0x5FA7A6E422744458, 0x009D92C0B1387377, 0x21949E9D3FFCA295,
0x428B6A79CEC0D1B3, 0x6382B6565D8500D1, 0x04730232EC492FEE, 0x25654E0F7B0D5F0C,
0x467399EC09D18E2A, 0x6779E5C89895BD48, 0x081031A52759EC67, 0x29C67D81B61E1B85,
0x4B3CC95E44E24AA3, 0x6933153AD3A679C1, 0x08296117626AA8DE, 0x251FACF3F12ED7FC,
0x5E15F8D07FF3071A, 0x4F0C44AD0EB73638, 0x500290899D7B6557, 0xB0F8DC662C3F9475 };
ULONGLONG d00D632C8 = 0xFFFFFFFFFFFFFFFF;
ULONGLONG d00D632D0 = 0xFFFFFFFFFFFFFFFF;
ULONGLONG d00D632D8 = 0xFFFFFFFFFFFFFFFF;
ULONGLONG d00D632E0 = 0xFFFFFFFFFFFFFFFF;
ULONGLONG d00D632E8 = 0xFFFFFFFFFFFFFFFF;
ULONGLONG d00D632F0 = 0xFFFFFFFFFFFFFFFF;
ULONGLONG d00D632F8 = 0xFFFFFFFFFFFFFFFF;
ULONGLONG d00D63300 = 0xFFFFFFFFFFFFFFFF;
ULONGLONG d00D63308 = 0xFFFFFFFFFFFFFFFF;
ULONGLONG d00D63310 = 0xFFFFFFFFFFFFFFFF;
ULONGLONG d00D63318 = 0xFFFFFFFFFFFFFFFF;
ULONGLONG d00D63320 = 0xFFFFFFFFFFFFFFFF;
ULONGLONG d00D63328 = 0xFFFFFFFFFFFFFFFF;
ULONGLONG d00D63330 = 0xFFFFFFFFFFFFFFFF;
ULONGLONG d00D63338 = 0xFFFFFFFFFFFFFFFF;
ULONGLONG d00D63340 = 0xFFFFFFFFFFFFFFFF;
ULONGLONG d00D63348 = 0xFFFFFFFFFFFFFFFF;
//-------------------------------------------------------------------------------
//+401000 c
vLoginId::vLoginId()
{
s0 = 0;
s8 = 0;
s10 = 0;
s18 = 0;
}
//+401040 c
ULONGLONG vLoginId::Decode(ULONGLONG* pData, size_t szData, int arg8)
{
__asm
{
sub esp, 0x000001C0
mov ebx, ecx
mov ecx, dword ptr ss:[ebp + 8] //ecx = pData
test ecx, ecx
je l0130767D
mov dword ptr ss:[esp + 0x00000034], 0
mov dword ptr ss:[esp + 0x00000030], 0
mov eax, dword ptr [ecx]
mov ecx, dword ptr [ecx + 4]
mov dword ptr ss:[esp + 0x0000002C], ecx
mov dword ptr ss:[esp + 0x00000028], eax
mov eax, dword ptr ss:[esp + 0x00000028]
mov ecx, dword ptr ss:[esp + 0x0000002C]
mov edx, dword ptr ss:[esp + 0x0000002C]
add eax, dword ptr ss:[esp + 0x00000028]
adc edx, ecx
mov ecx, dword ptr ss:[esp + 0x00000028]
mov esi, dword ptr ss:[esp + 0x0000002C]
and esi, dword ptr ss:[esp + 0x0000002C]
and ecx, dword ptr ss:[esp + 0x00000028]
sub eax, ecx
mov ecx, dword ptr ss:[esp + 0x00000028]
sbb edx, esi
mov esi, dword ptr ss:[esp + 0x0000002C]
and esi, dword ptr ss:[esp + 0x0000002C]
and ecx, dword ptr ss:[esp + 0x00000028]
sub eax, ecx
sbb edx, esi
mov dword ptr ss:[esp + 0x00000018], eax
mov dword ptr ss:[esp + 0x0000001C], edx
mov eax, dword ptr ss:[esp + 0x00000028]
mov ecx, dword ptr ss:[esp + 0x0000002C]
mov edx, dword ptr ss:[esp + 0x00000028]
mov esi, dword ptr ss:[esp + 0x0000002C]
not esi
not edx
and esi, ecx
and edx, eax
mov dword ptr ss:[esp + 4], esi
mov dword ptr ss:[esp], edx
mov eax, dword ptr ss:[esp]
mov ecx, dword ptr ss:[esp + 4]
mov edx, dword ptr ss:[esp + 0x00000028]
mov esi, dword ptr ss:[esp + 0x0000002C]
not esi
not edx
or esi, ecx
or edx, eax
mov dword ptr ss:[esp + 0x00000024], esi
mov dword ptr ss:[esp + 0x00000020], edx
mov dword ptr ss:[esp + 0x00000014], 0
mov dword ptr ss:[esp + 0x00000010], 0
mov eax, dword ptr ss:[esp + 0x00000010]
mov ecx, dword ptr ss:[esp + 0x00000014]
mov edx, dword ptr ss:[esp + 0x00000014]
add eax, dword ptr ss:[esp + 0x00000010]
adc edx, ecx
mov ecx, dword ptr ss:[esp + 0x00000010]
mov esi, dword ptr ss:[esp + 0x00000014]
and esi, dword ptr ss:[esp + 0x00000014]
and ecx, dword ptr ss:[esp + 0x00000010]
sub eax, ecx
mov ecx, dword ptr ss:[esp + 0x00000010]
sbb edx, esi
mov esi, dword ptr ss:[esp + 0x00000014]
and esi, dword ptr ss:[esp + 0x00000014]
and ecx, dword ptr ss:[esp + 0x00000010]
sub eax, ecx
sbb edx, esi
mov dword ptr ss:[esp], eax
mov dword ptr ss:[esp + 4], edx
mov eax, dword ptr ss:[esp + 0x00000010]
mov ecx, dword ptr ss:[esp + 0x00000014]
and eax, dword ptr ss:[esp + 0x00000010]
and ecx, dword ptr ss:[esp + 0x00000014]
mov dword ptr ss:[esp + 0x0000000C], ecx
mov dword ptr ss:[esp + 8], eax
mov eax, dword ptr ss:[esp]
mov ecx, dword ptr ss:[esp + 4]
mov edx, dword ptr ss:[esp + 0x0000000C]
add eax, dword ptr ss:[esp + 8]
adc edx, ecx
mov ecx, dword ptr ss:[esp]
mov esi, dword ptr ss:[esp + 4]
and esi, dword ptr ss:[esp + 0x0000000C]
and ecx, dword ptr ss:[esp + 8]
sub eax, ecx
mov ecx, dword ptr ss:[esp]
sbb edx, esi
mov esi, dword ptr ss:[esp + 4]
and esi, dword ptr ss:[esp + 0x0000000C]
and ecx, dword ptr ss:[esp + 8]
sub eax, ecx
sbb edx, esi
not eax
not edx
mov dword ptr ss:[esp + 0x00000010], eax
mov dword ptr ss:[esp + 0x00000014], edx
mov eax, dword ptr ss:[esp + 0x00000020]
mov ecx, dword ptr ss:[esp + 0x00000024]
mov edx, dword ptr ss:[esp + 0x00000014]
add eax, dword ptr ss:[esp + 0x00000010]
adc edx, ecx
mov dword ptr ss:[esp], eax
mov dword ptr ss:[esp + 4], edx
mov eax, dword ptr ss:[esp + 0x00000020]
mov ecx, dword ptr ss:[esp + 0x00000024]
and eax, dword ptr ss:[esp + 0x00000010]
and ecx, dword ptr ss:[esp + 0x00000014]
shld ecx, eax, 1
add eax, eax
mov dword ptr ss:[esp + 0x0000000C], ecx
mov dword ptr ss:[esp + 8], eax
mov eax, dword ptr ss:[esp]
mov ecx, dword ptr ss:[esp + 4]
sub eax, dword ptr ss:[esp + 8]
sbb ecx, dword ptr ss:[esp + 0x0000000C]
mov dword ptr ss:[esp + 4], ecx
mov dword ptr ss:[esp], eax
mov eax, dword ptr ss:[esp + 0x00000018]
mov ecx, dword ptr ss:[esp + 0x0000001C]
mov edx, dword ptr ss:[esp + 4]
add eax, dword ptr ss:[esp]
adc edx, ecx
mov ecx, dword ptr ss:[esp + 0x00000018]
mov esi, dword ptr ss:[esp + 0x0000001C]
and esi, dword ptr ss:[esp + 4]
and ecx, dword ptr ss:[esp]
sub eax, ecx
mov ecx, dword ptr ss:[esp + 0x00000018]
sbb edx, esi
mov esi, dword ptr ss:[esp + 0x0000001C]
and esi, dword ptr ss:[esp + 4]
and ecx, dword ptr ss:[esp]
}
}
and this is my c# program
using System;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Microsoft.AspNetCore.Mvc;
using System.Collections.Generic;
using System.Threading;
using System.Security.Cryptography;
using System.Web;
using System.IO;
using Microsoft.AspNetCore.Http;
using System.Net;
namespace TrialCheck
{
class Program
{
static void Main(string[] args)
{
string[] urls = new string[] { "http://localhost:9900" };
if (File.Exists("urls.txt"))
urls = File.ReadAllLines("urls.txt");
var webHost = new WebHostBuilder()
.UseKestrel()
.UseUrls(urls)
.UseStartup<Program>()
.Build();
webHost.Run();
}
public void ConfigureServices(IServiceCollection services)
{
services.AddMvc();
}
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
loggerFactory.AddConsole(LogLevel.Information);
app.UseMvc();
}
}
}
namespace TrialCheck
{
public class Trial : Controller
{
[Route("ping")]
[HttpGet]
public IActionResult Ping()
{
Response.Headers.Add("Access-Control-Allow-Origin", "*");
return Ok(DateTime.Now.ToString());
}
[Route("loginid")]
[HttpPost]
public IActionResult LoginId()
{
try
{
string str = new StreamReader(Request.Body).ReadToEnd();
byte[] bytes = Convert.FromBase64String(str);
string res = Trades.trade.LoginId.Decode(bytes, 0).ToString();
Console.Write(".");
return Ok(res);
}
catch (Exception ex)
{
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine(ex.Message);
Console.ForegroundColor = ConsoleColor.Red; Console.ForegroundColor = ConsoleColor.White;
return new NoContentResult();
}
}
}
}
i have try using macbook but i cannot compile this code become apps. i have installed .net core for macbook. when i try build this apps in windows i got error like this one. i am new for .net programming
User contributions licensed under CC BY-SA 3.0