Windows error 0x0000005C, 92

Detailed Error Information

HAL_INITIALIZATION_FAILED[1]

This is a Blue Screen of Death stop code. More information is available in the Knowledge Base article Bug Check 0x5C: HAL_INITIALIZATION_FAILED.

HRESULT analysis[2]

This is probably not the correct interpretation of this error. The Win32 error above is more likely to indicate the actual problem.
FlagsSeveritySuccess

This code indicates success, rather than an error. This may not be the correct interpretation of this code, or possibly the program is handling errors incorrectly.

Reserved (R)false
OriginMicrosoft
NTSTATUSfalse
Reserved (X)false
FacilityCode0 (0x000)
NameFACILITY_NULL[2][3]
DescriptionThe default facility code.[2][3]
Error Code92 (0x005c)

Possible solutions

5

Get base address of process

c++
windows
pointers

If you want to get the virtual address within the other process's address space, you can do that like so:

  1. Open the process using OpenProcess -- if successful, the value returned is a handle to the process, which is just an opaque token used by the kernel to identify a kernel object. Its exact integer value (0x5c in your case) has no meaning to userspace programs, other than to distinguish it from other handles and invalid handles.
  2. Call GetProcessImageFileName to get the name of the main executable module of the process.
  3. Use EnumProcessModules to enumerate the list of all modules in the target process.
  4. For each module, call GetModuleFileNameEx to get the filename, and compare it with the executable's filename.
  5. When you've found the executable's module, call GetModuleInformation to get the raw entry point of the executable.

This will give you the virtual address, but there's not a whole lot you can do with it since it's not mapped into your current process's address space.

answered on Stack Overflow Jan 22, 2013 by Adam Rosenfield
5

VS 2013 exception when using C++11 unrestricted unions

c++
c++11
visual-studio-2013
unions

VS 2013 doesn't support C++11 unrestricted unions, that is it implements unions as per C++03:

An object of a class with a non-trivial constructor (12.1), a non-trivial copy constructor (12.8), a non-trivial destructor (12.4), or a non-trivial copy assignment operator (13.5.3, 12.8) cannot be a member of a union

You successfully fooled the compiler by using unnamed structs, but that doesn't solve the problem: the objects are non-trivial, and VS2013 doesn't support that.

When you switch to more C++11-compliant compiler, such as VS 2015, you'll have to implement constructor, destructor, copy constructor etc. for the union in a way that it safely constructs/destructs/copies appropriate part of the union. There's an example in the standard (I'm quoting C++14 draft N4140 [class.union]/4):

Consider an object u of a union type U having non-static data members m of type M and n of type N. If M has a non-trivial destructor and N has a non-trivial constructor (for instance, if they declare or inherit virtual functions), the active member of u can be safely switched from m to n using the destructor and placement new operator as follows:

u.m.~M();
new (&u.n) N;
answered on Stack Overflow Jun 25, 2015 by Anton Savin
4

Procedure in a component that uses another procedure in a DLL

delphi
dll

A global procedure and a class method are not the same thing. A class method has a hidden Self parameter, which your DLL does not take into account when the class method is passed to the DLL. That is why your code crashes - the call stack is not set up correctly.

Given your "working" code, your component code needs to look like this:

TExecute = procedure(eval: pointer; var variableArray: double); cdecl;

TMyComponent = Class(TComponent)
public
    FHandle: THandle;
    FExecute: TExecute;
    procedure Calculate;
    class procedure eval(var x: double); static;
end;

var
    n: integer;
    x: array of double;

implementation

class procedure TMyComponent.eval(var x:double);
var
    mx: Array[0..200] of double absolute x;
begin
    mx[0]:= 2*mx[0];
end;

procedure TMyComponent.Calculate;
begin
    FHandle:= LoadLibrary(.....);
    FExecute:= GetProcAddress(FHandle, 'main');

    n:=2;
    setlength(fx,n);

    FExecute(@eval,x[0]);
end;

Since your eval() method only accesses global variable, this works fine. But if it needs to access members of the component, you have a problem since the static directive eliminates the Self parameter. In which case, you have three options.

  1. If you can, change the DLL function to accept an additional parameter that the component can pass its Self value in, and then have the DLL pass that value to eval() as a parameter, eg:

    TExecute = procedure(eval: pointer, var variableArray: double; userdata: pointer); cdecl;
    
    TMyComponent = Class(TComponent)
    public
        FHandle: THandle;
        FExecute: TExecute;
        procedure Calculate;
        class procedure eval(var x: double; userdata: pointer); static;
    end;
    
    var
        n: integer;
        x: array of double;
    
    implementation
    
    class procedure TMyComponent.eval(var x: double; userdata: pointer);
    begin
        // use TMyComponent(userdata) as needed...
    end;
    
    procedure TMyComponent.Calculate;
    begin
        FHandle:= LoadLibrary(.....);
        FExecute:= GetProcAddress(FHandle, 'main');
    
        n:=2;
        setlength(fx,n);
    
        FExecute(@eval, x[0], Self);
    end;
    
  2. If #1 is not possible, and if there is only one instance of your component calling the DLL function at a time, then use a global pointer to your component, eg:

    TExecute = procedure(eval: pointer, var variableArray: double); cdecl;
    
    TMyComponent = Class(TComponent)
    public
        FHandle: THandle;
        FExecute: TExecute;
        procedure Calculate;
        class procedure eval(var x: double); static;
    end;
    
    var
        n: integer;
        x: array of double;
    
    implementation
    
    var
        MyComp: TMyComponent;
    
    class procedure TMyComponent.eval(var x: double);
    begin
        // use MyComp as needed...
    end;
    
    procedure TMyComponent.Calculate;
    begin
        FHandle:= LoadLibrary(.....);
        FExecute:= GetProcAddress(FHandle, 'main');
    
        n:=2;
        setlength(fx,n);
    
        MyComp := Self;
        FExecute(@eval, x[0]);
    end;
    
  3. If #2 is not possible because multiple component instances need to call into the DLL at the same time, then the only option left is to use a dynamic proxy. Allocate a block of executable memory and store special stub code in it along with the component Self pointer, then pass that memory block to the DLL as if it were a normal procedure. When the DLL calls the "procedure", it's stub code is called, which can extract the component pointer from the proxy and use it as needed. This is the approach that the VCL itself uses for assigning the non-static TWinControl.WndProc() method as Win32 API window procedure callbacks. I can't provide that code here right now, but look in the VCL's source code at the Classes.MakeObjectInstance() function for an example.

answered on Stack Overflow May 19, 2013 by Remy Lebeau • edited May 19, 2013 by Rudy Velthuis
4

Pointer gets lost in the release build

c++
pointers
visual-studio-2005

You initialize m_pszBuf like this:

m_pszBuf = new char[260];

then you call Device constructor like this:

device = new Device(m_pszBuf);

Inside Device constructor, there is a strcpy call from m_pszBuf source:

Device::Device(char* _ptr) // _ptr == m_pszBuf
{
    strcpy(dest, _ptr);
}

But if m_pszBuf is not NUL-terminated, strcpy doesn't stop at the end of the allocated buffer, and it can copy garbage from out-of-bounds memory, and you can overrun the dest buffer.

So, before passing m_pszBuf to Device constructor, make sure that it is NUL-terminated and that strcpy destination pointer is big enough.

Note: This analysis is based just on the code snippet you showed. (I don't know if in your actual code that you omitted to show there are other problems.)

answered on Stack Overflow Feb 28, 2013 by Mr.C64
3

Get base address of process

c++
windows
pointers

I wanted to elaborate a bit on @Adam Rosenfield's answer. I will use League of Legends as an example here.


In order to open the process (Getting a handle) we need it's PID (Process ID). We can do that via a window handle (HWND) because usually the title of the window is known

//You will need to change this the name of the window of the foreign process
HWND WindowHandle = FindWindow(nullptr, L"League of Legends (TM) Client");
DWORD PID;
GetWindowThreadProcessId(WindowHandle, &PID);
PVOID hProcess = OpenProcess(PROCESS_VM_READ | PROCESS_QUERY_INFORMATION, 0, PID);

Now that we are able to get a handle to the process let's continue

HMODULE Module = GetModule();
DWORD BaseAddress = (DWORD)Module;

The GetModule function

HMODULE GetModule()
{
    HMODULE hMods[1024];
    HANDLE pHandle = GetHandle();
    DWORD cbNeeded;
    unsigned int i;

    if (EnumProcessModules(pHandle, hMods, sizeof(hMods), &cbNeeded))
        {
        for (i = 0; i < (cbNeeded / sizeof(HMODULE)); i++)
        {
            TCHAR szModName[MAX_PATH];
            if (GetModuleFileNameEx(pHandle, hMods[i], szModName, sizeof(szModName) / sizeof(TCHAR)))
            {
                wstring wstrModName = szModName;
                //you will need to change this to the name of the exe of the foreign process
                wstring wstrModContain = L"League of Legends.exe"; 
                if (wstrModName.find(wstrModContain) != string::npos)
                {
                    CloseHandle(pHandle);
                    return hMods[i];
                }
            }
        }
    }
    return nullptr;
}

as for me personally I like to write 2 separate functions one for getting a handle and one for getting the module.

There we go, we have successfully gotten the base address of a foreign process.

answered on Stack Overflow Aug 8, 2015 by (unknown user) • edited Jan 31, 2017 by Remy Lebeau
2

How can I make my Java-generated zip file identical to a WinZip-generated one

java
zip

I worked around the issue, I don't understand what the root cause was but by using the org.apache.commons.compress library the zip file is now usable. I'll dig into it again tomorrow because I'm curious to know what the difference is. Meanwhile, here's the updated class.

package com.mycompany.utils;

import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import org.apache.commons.compress.archivers.zip.ZipArchiveEntry;
import org.apache.commons.compress.archivers.zip.ZipArchiveOutputStream;
import org.apache.log4j.Logger;

public class FileZipper {

    private static final Logger LOGGER = Logger.getLogger(OldFileZipper.class);
    private String destinationZipFile;
    private String sourceDirectory;

    List<String> fileList;
    private File zipFile;

    public File getZipFile() {
        return zipFile;
    }

    /**
     * Zips a source directory into the destination zip file
     * 
     * @param source
     * @param destination
     */
    FileZipper(String source, String destination) {
        LOGGER.info("Zipping source directory: "+source);
        LOGGER.info("To destination zip file:  "+destination);
        this.destinationZipFile = destination;
        this.sourceDirectory = source;
        fileList = new ArrayList<String>();
        generateFileList(new File(sourceDirectory));
        compressDirectoryContentsToZip(sourceDirectory, destinationZipFile);
    }

    /**
     * Traverse a directory and get all files, and add the file into fileList
     * 
     * @param node
     *            file or directory
     */
    public void generateFileList(File node) {

        // add file only
        if (node.isFile()) {
            fileList.add(generateZipEntry(node.getAbsoluteFile().toString()));
        }

        if (node.isDirectory()) {
            if(node.toString() != sourceDirectory) {
                fileList.add(generateZipEntry(node.getAbsoluteFile().toString()));
            }
            String[] subNodes = node.list();
            for (String filename : subNodes) {
                generateFileList(new File(node, filename));
            }
        }

    }

    /**
     * Compress a directory to a zip file
     * @param sourceDirectory
     * @param destinationZipFile
     */
    public void compressDirectoryContentsToZip(String sourceDirectory, String destinationZipFile) {

        this.zipFile = new File(destinationZipFile);

        byte[] buffer = new byte[4096];

        try {

            FileOutputStream fos = new FileOutputStream(destinationZipFile);
            BufferedOutputStream bos = new BufferedOutputStream(fos);
            ZipArchiveOutputStream zos = new ZipArchiveOutputStream(bos);
            zos.setMethod(ZipArchiveOutputStream.DEFLATED);
            zos.setLevel(0);
            LOGGER.info("Zipping to : " + destinationZipFile);

            for (String entry : this.fileList) {
                long fileSizeInBytes = new File(sourceDirectory + File.separator + entry).length();

                if(new File(sourceDirectory + File.separator + entry).isFile()) {
                    LOGGER.info("File Added : " + entry + " ("+String.valueOf(fileSizeInBytes)+" bytes)");
                    ZipArchiveEntry ze = new ZipArchiveEntry(entry);
                    zos.putArchiveEntry(ze);
                    FileInputStream in = new FileInputStream(sourceDirectory
                            + File.separator + entry);
                    int len;
                    while ((len = in.read(buffer)) > 0) {
                        zos.write(buffer, 0, len);
                    }

                    in.close();
                    zos.closeArchiveEntry();

                } else if(new File(sourceDirectory  + File.separator + entry).isDirectory()) {
                    LOGGER.info("Directory Added : " + entry);
                    ZipArchiveEntry ze = new ZipArchiveEntry(entry+File.separator);
                    zos.putArchiveEntry(ze);
                    zos.closeArchiveEntry();
                } else {
                    LOGGER.warn("Not a file or directory: "+entry);
                }
            }

            zos.close();

            LOGGER.info("Zipping completed successfully");
        } catch (IOException ex) {
            LOGGER.error(ex);
            System.exit(1);
        }
        LOGGER.info("Generated zip file: "+ destinationZipFile);
    }


    /**
     * Format the filename for archiving by removing the path
     * of the source directory
     * 
     * @param file
     * @return
     */
    private String generateZipEntry(String file) {
        LOGGER.debug("Stripping '"+file+"' to '"+file.substring(sourceDirectory.length() + 1, file.length())+"'");
        return file.substring(sourceDirectory.length() + 1, file.length());
    }

}
answered on Stack Overflow Nov 4, 2014 by conorgriffin • edited Nov 4, 2014 by conorgriffin
1

Building a path from strings in C

c
special-characters
filepath
strcat

The third line from the bottom is

int l = 0;

If you comment it out, your code will not compile, because you need to declare l before using it.

The fourth line from the bottom is

//strcat(buffer, PATH_SEP);

The line

char *PATH_SEP = '\\';

makes no sense, because you initialize string (char*) with character (char). Anything in double quotes is a string, anything in single quotes is a character. So your PATH_SEP points to a garbage.

answered on Stack Overflow Nov 6, 2017 by user31264 • edited Nov 6, 2017 by eyllanesc
1

Building a path from strings in C

c
special-characters
filepath
strcat

Character constants such as PATH_SEP are not automatically NUL-terminated. When you call

strcat(buffer, PATH_SEP);

the strcat routine expects both arguments to point to NUL-terminated strings. Because PATH_SEP isn't NUL terminated the routine continues scanning memory, looking for a NUL byte. Eventually it either overwrites something important or access memory it shouldn't.

Change

char *PATH_SEP = '\\';

to

char *PATH_SEP = "\\";

and your code should perform as expected.

Best of luck.

answered on Stack Overflow Nov 6, 2017 by Bob Jarvis • edited Nov 6, 2017 by BLUEPIXY
1

nasm/ld failing to do %include on cygwin

assembly
macros
include
cygwin
nasm

Your error was to assemble io.mac. It is a textfile which is included in sample.asm "as is". io.obj is not an assembled io.mac. With assembling io.mac you destroyed the original io.obj. But even if you extract the original io.obj from win_nasm_progs.zip you will fail. It is not a Windows file but a MS-DOS file (yes, this is very annoying). You can't either use the Linux file (io.o) because Cygwin needs Windows system calls. So you can't use the samples of Dandamudi's book outside of Linux. The only thing that comes to my mind is changing the calls in io.mac to calls to a C-function (and other adjusts) and linking the object file against GCC.

answered on Stack Overflow Dec 6, 2014 by rkhb
1

Can we type strings with use of hex codes in c# like we type integers like that int a = 0x0000cd54;?

c#
.net
string
hex
string str = "\x45 \xac \x1b \5c"

http://msdn.microsoft.com/en-us/library/aa691090%28v=vs.71%29.aspx

answered on Stack Overflow Dec 5, 2014 by pm100
0

AndEngine GLES1 Destroy and Create Object During Box2D Collision crashes app

android
box2d
andengine

You can't change anything in the world inside the Step function. You'll need to create the new body after the Step function.

The same problem happens if you try to destroy a body inside the contact listener callback, and that seems to be a much more common situation, so you could try searching for problems related to removing bodies, eg. AndEngine Sprite/Box2D Body removal crashes my program with no error/exception information?

The typical method is to have some kind of list that can be accessed from both the main loop (where Step() is called) and inside the contact listener. Make a note of what needs to be modified by adding to the list, and in the main loop immediately after the Step function, you can carry out the changes.

answered on Stack Overflow Jun 7, 2014 by iforce2d • edited May 23, 2017 by Community
0

Pointer gets lost in the release build

c++
pointers
visual-studio-2005

Great input but i have solved it with something else. I had some Header files "out of sync" which were used for a library. i just needed to update them. Strange how this affected something else.

answered on Stack Overflow Feb 28, 2013 by the baconing
0

nasm/ld failing to do %include on cygwin

assembly
macros
include
cygwin
nasm

I decided to abandon the I/O scheme from Guide to Assembly Language Programming in Linux and go with that (which works on Cygwin/nasm) of Carter, Paul A. PC assembly language. Raleigh, NC: Lulu Press, 2007(i.e., its driver.c cdecl.h asm_io.inc asm_io.asm files)

answered on Stack Overflow Dec 7, 2014 by boardrider
-1

Windows boot error. code:0x0000005C

windows-8
boot

As Moab suggested it could be the hard drive:

Boot your DVD and go to repair, start console aka command prompt.

CHKDSK C: /F where c: is drive where Windows is installed

Operation can take a lot of time, be patient.

answered on Super User Mar 22, 2016 by snayob

Comments

Leave a comment

(plain text only)

Sources

  1. https://docs.microsoft.com/en-us/windows-hardware/drivers/debugger/bug-check-code-reference2
  2. https://msdn.microsoft.com/en-us/library/cc231198.aspx
  3. winerror.h from Windows SDK 10.0.14393.0

User contributions licensed under CC BY-SA 3.0