Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix circular includes #156

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions format.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,23 @@

#include "format.h"

#include <stdlib.h>
#include <inttypes.h>

#include "errors.h"

// Add DPRINT macro from donut.h since it is needed but all of donut.h cannot be included
#if defined(DEBUG)
#define DPRINT(...) { \
fprintf(stderr, "DEBUG: %s:%d:%s(): ", __FILE__, __LINE__, __FUNCTION__); \
fprintf(stderr, __VA_ARGS__); \
fprintf(stderr, "\n"); \
}
#else
#define DPRINT(...) // Don't do anything in release builds
#endif


/**
Encoding: base64
Author : Odzhan
Expand Down
25 changes: 1 addition & 24 deletions include/donut.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@

#endif

#include "errors.h" // Donut errors
#include "hash.h" // api hashing
#include "encrypt.h" // symmetric encryption of instance+module
#include "format.h" // output format for loader
Expand Down Expand Up @@ -110,30 +111,6 @@ typedef struct _GUID {
#define DONUT_KEY_LEN 16
#define DONUT_BLK_LEN 16

#define DONUT_ERROR_OK 0
#define DONUT_ERROR_FILE_NOT_FOUND 1
#define DONUT_ERROR_FILE_EMPTY 2
#define DONUT_ERROR_FILE_ACCESS 3
#define DONUT_ERROR_FILE_INVALID 4
#define DONUT_ERROR_NET_PARAMS 5
#define DONUT_ERROR_NO_MEMORY 6
#define DONUT_ERROR_INVALID_ARCH 7
#define DONUT_ERROR_INVALID_URL 8
#define DONUT_ERROR_URL_LENGTH 9
#define DONUT_ERROR_INVALID_PARAMETER 10
#define DONUT_ERROR_RANDOM 11
#define DONUT_ERROR_DLL_FUNCTION 12
#define DONUT_ERROR_ARCH_MISMATCH 13
#define DONUT_ERROR_DLL_PARAM 14
#define DONUT_ERROR_BYPASS_INVALID 15
#define DONUT_ERROR_INVALID_FORMAT 16
#define DONUT_ERROR_INVALID_ENGINE 17
#define DONUT_ERROR_COMPRESSION 18
#define DONUT_ERROR_INVALID_ENTROPY 19
#define DONUT_ERROR_MIXED_ASSEMBLY 20
#define DONUT_ERROR_HEADERS_INVALID 21
#define DONUT_ERROR_DECOY_INVALID 22

// target architecture
#define DONUT_ARCH_ANY -1 // for vbs and js files
#define DONUT_ARCH_X86 1 // x86
Expand Down
59 changes: 59 additions & 0 deletions include/errors.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/**
BSD 3-Clause License

Copyright (c) 2019, TheWover, Odzhan. All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.

* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.

* Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

#ifndef ERRORS_H
#define ERRORS_H

#define DONUT_ERROR_OK 0
#define DONUT_ERROR_FILE_NOT_FOUND 1
#define DONUT_ERROR_FILE_EMPTY 2
#define DONUT_ERROR_FILE_ACCESS 3
#define DONUT_ERROR_FILE_INVALID 4
#define DONUT_ERROR_NET_PARAMS 5
#define DONUT_ERROR_NO_MEMORY 6
#define DONUT_ERROR_INVALID_ARCH 7
#define DONUT_ERROR_INVALID_URL 8
#define DONUT_ERROR_URL_LENGTH 9
#define DONUT_ERROR_INVALID_PARAMETER 10
#define DONUT_ERROR_RANDOM 11
#define DONUT_ERROR_DLL_FUNCTION 12
#define DONUT_ERROR_ARCH_MISMATCH 13
#define DONUT_ERROR_DLL_PARAM 14
#define DONUT_ERROR_BYPASS_INVALID 15
#define DONUT_ERROR_INVALID_FORMAT 16
#define DONUT_ERROR_INVALID_ENGINE 17
#define DONUT_ERROR_COMPRESSION 18
#define DONUT_ERROR_INVALID_ENTROPY 19
#define DONUT_ERROR_MIXED_ASSEMBLY 20
#define DONUT_ERROR_HEADERS_INVALID 21
#define DONUT_ERROR_DECOY_INVALID 22

#endif // ERRORS_H
5 changes: 4 additions & 1 deletion include/format.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,10 @@
#ifndef FORMAT_H
#define FORMAT_H

#include "donut.h"
#include <stdint.h>
#include <stdio.h>

#include "hash.h"

#ifdef __cplusplus
extern "C" {
Expand Down