Click here to Skip to main content
16,004,505 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
The program stops with the execution
Access violation while reading at position 0x0000000000000007


I found out in my Debugger that its on the line:
KeyAuthApp.init();


the information stored in the function init are:

api KeyAuthApp(name, ownerid, secret, version, url);


All strings are correct (I pasted the code from the KeyAuth Dashboard).
So it can't be an access violation due to no connection to the service. Sadly I can't find a solution on the internet or on the support channel from KeyAuth

What I have tried:

I copied the code from the KeyAuth Dashboard. Also I put the KeyAuth related code into a function on a Header file. just to call it in my main function.

AuthFunc.h
C++
static void KAA_Init() {

    KeyAuthApp.init();
    if (!KeyAuthApp.data.success)
    {
        std::cout << skCrypt("\n Status: ") << KeyAuthApp.data.message;
        Sleep(1500);
        exit(1);
    }
....


On my main.cpp I included it the func in my mainfunc above all the other code as told in the documentary on KeyAuth

main.cpp
C++
int main() {
    
    KAA_Init();
    
    AllocConsole();
    FILE* _dummy;
    freopen_s(&_dummy, "CONOUT$", "w", stdout);

    
    DriverController drv;
    drv.Install();
....
Posted
Updated 5-Aug-24 4:49am
v2
Comments
Richard MacCutchan 5-Aug-24 12:19pm    
Why are you putting executable code in a header file? It should be in your main.cpp module. Also where is your instansiation of the api class?
trickstrr 5-Aug-24 12:23pm    
to keep my main() clean xD
the instansiation of the api class is in the auth.hpp

auth.hpp
class api {
public:

std::string name, ownerid, secret, version, url;

api(std::string name, std::string ownerid, std::string secret, std::string version, std::string url) : name(name), ownerid(ownerid), secret(secret), version(version), url(url) {}

void ban();
void init();
void check();
void log(std::string msg);
void license(std::string key);
std::string var(std::string varid);
std::string webhook(std::string id, std::string params);
void setvar(std::string var, std::string vardata);
std::string getvar(std::string var);
bool checkblack();
void upgrade(std::string username, std::string key);
void login(std::string username, std::string password);
void web_login();
void button(std::string value);
std::vector<unsigned char=""> download(std::string fileid);
void regstr(std::string username, std::string password, std::string key);
Richard MacCutchan 5-Aug-24 12:28pm    
That is not instantiation, that is a class definition. If you do not understand the difference then you are going to have a lot of problems with your code. For a proper example please see the code at KeyAuth-CPP-Example/x64/main.cpp at main · KeyAuth/KeyAuth-CPP-Example · GitHub[^]. And that constructor needs to be executed before you can call any of the other functions.
trickstrr 5-Aug-24 12:45pm    
Oh well thank you for your reply, Im still learning c++ and some stuff is completly new to me as like instantiation of classes I will try to learn more about it and try to solve it. Can you throw me a little example of an instantiation for my code I can try to work with?

Edit: Sorry I misunderstood you, I already have the instantiation right above the code

std::string name = skCrypt("name").decrypt();
std::string ownerid = skCrypt("ownerid").decrypt();
std::string secret = skCrypt("secret").decrypt();
std::string version = skCrypt("1.0").decrypt();
std::string url = skCrypt("https://keyauth.win/api/1.2/").decrypt(); // change if you're self-hosting
std::string path = skCrypt("").decrypt(); //optional, set a path if you're using the token validation setting

I replaced the strings with my data I got from the dashboard
Richard MacCutchan 5-Aug-24 13:43pm    
Well you are still missing the instantiation of your api class object. And that is most likely why your call to init is causing the access violation. But this should have shown up when you compiled the code. To be honest you are wasting your time trying to run a rather complicated application without a full understanding of the language you are trying to use. So get yourself a book or a good online tutorial (not YouTube) and learn C++ before you try advanced features .

It is apparently not possible to generate the KeyAuth library from the current Github source code without considerable modification effort. With some effort you can only get the x86 release version. With x64, on the other hand, there are some additional problems.

So I initially resorted to the compiled versions and downloaded the files from Ali Bin Mohammad at:
https://github.com/BINM7MD/KeyAuth-Libraries

However, the compiled libraries are 2 years old and the linker is missing at least 2 functions in example.cpp:

KeyAuth::api::chatget and KeyAuth::api::regstr

The x86 release version of the KeyAuth library can be compiled, and the linker also finds all required functions, however the test programme in the library triggers an access violation exception for the auth.cpp contained in the system call VirtualProtect() at i=94438.
Note: The auth.cpp is compiled into keyauth_x86.lib and is also included in the example in a similar form as source code.

In the self-compiled version, the compiler displays the corresponding source code. According to this, the access violation is at this location:

DWORD new_protect { PAGE_EXECUTE_READWRITE }, old_protect;
VirtualProtect( ( void * )( base_0 + section_0->VirtualAddress + i ), sizeof( BYTE ), new_protect, &old_protect );

Message:
Exception error at 0x00AF80B7 in example.exe: 0xC0000005: Access violation when reading at position 0x0047F124

Obviously something is fundamentally wrong with the init function KeyAuthApp.init() or KeyAuth::api::init.

The high number of warnings shows that the source code of KeyAuth does not seem to be in a good condition.

I have no further interest in the library and will not deal with it any further.
 
Share this answer
 
Probably because, based on your previous question, you commented out
C++
KeyAuthApp.regstr(username, password, key);
Simply commenting out code that causes an issue is NOT a good approach to solving problems. As you have just discovered, it causes other problems.

Before attempting to fix the problem you now have, you need to go back and resolve your linker problem. I quote from OriginalGriff's solution
Quote:
We can't help you fix that, you need to check the KeyAuth library (which appears to most likely be a github thing) and see exactly what it provides or contact the author directly and ask them.
 
Share this answer
 
Comments
trickstrr 5-Aug-24 11:39am    
Well, even If I try to use web_loader api it causes the error. So it couldnt be based on the KeyAuthApp.regstr error because it doesnt even use it. the Web Loader workaround uses just the KeyAuthApp.init(); function and refers then to the web UI.
Dave Kreskowiak 6-Aug-24 10:45am    
Keep in mind that GitHub is source control, nothing more. It's NOT a repository for finished products. It in no way means what you downloaded works, or even compiles. What you got could very well still be a "work in progress".

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900