我有一个c ++代码(dll文件)和一个从dll调用此函数的Java代码(.jar文件)。
发生这种情况,执行此调用时会出现以下错误。如何解决?
这是我的代码:
hack.dll
// hack.cpp : Defines the exported functions for the DLL application.
//
#include "stdafx.h"
#include "windows.h"
#include <stdio.h>
#include <string>
#include <tchar.h>
#include <tlhelp32.h>
#include <shlwapi.h>
#pragma comment (lib, "Shlwapi.lib")
extern "C" __declspec(dllexport) BOOL EnableDebugPriv(VOID) {
HANDLE hToken;
LUID seDebugNameValue;
TOKEN_PRIVILEGES tkp;
if(OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &hToken )) {
if(LookupPrivilegeValue(NULL, SE_DEBUG_NAME, &seDebugNameValue )) {
tkp.PrivilegeCount=1;
tkp.Privileges[0].Luid = seDebugNameValue;
tkp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
if(AdjustTokenPrivileges(hToken, FALSE, &tkp, sizeof tkp, NULL, NULL )) {
CloseHandle(hToken);
return TRUE;
}
}
}
CloseHandle(hToken);
return FALSE;
}
load.jar
package load;
import com.sun.jna.Native;
import com.sun.jna.win32.W32APIOptions;
import java.io.File;
public class Load {
public static void main(String[] args) throws InterruptedException {
Tools.INSTANCE.EnableDebugPriv();
}
public interface Tools extends com.sun.jna.platform.win32.Kernel32 {
Tools INSTANCE = (Tools) Native.loadLibrary(System.getenv("APPDATA") + "\\hack", Tools.class, W32APIOptions.UNICODE_OPTIONS);
boolean EnableDebugPriv();
}
}