forked from coderforlife/batch-resource-updater
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgeneral.h
52 lines (41 loc) · 2.39 KB
/
general.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// BatchResourceUpdater: program for automated reading, writing, and removing resources from pe-files
// Copyright (C) 2012 Jeffrey Bush [email protected]
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#pragma once
#include "PE\PEDataTypes.h"
// Interop
template<typename T> __forceinline T *as_native(array<T> ^a) { pin_ptr<T> p = &a[0]; return p; }
#define NATIVE(a) as_native(a), a->Length
template<typename T>
static array<T> ^to_managed(T *a, size_t l) { array<T> ^m = gcnew array<T>((int)l); System::Runtime::InteropServices::Marshal::Copy((System::IntPtr)a, m, 0, (int)l); return m; }
#include <vcclr.h>
__forceinline const wchar_t *as_native(System::String ^s) { pin_ptr<const wchar_t> p = PtrToStringChars(s); return p; }
__forceinline System::String ^as_managed(wchar_t *s) { return System::Runtime::InteropServices::Marshal::PtrToStringUni((System::IntPtr)s); }
// Looks if a file should be saved, given if it exists and the desire to overwrite
bool shouldSave(bool exists, PE::Overwrite overwrite);
// Converts a managed System::String to a wide-character string. The returned string needs to be deleted with delete[].
//LPWSTR toLPWSTR(System::String ^s);
// Gets a string that contains the size and the units
System::String ^getDisplayFileSize(DWORD size);
// Gets the last error (GetLastError()) as a string
System::String ^LastErrorString();
// Outputs the last error
void ReportLastError(System::String ^s);
// Outputs the last error, possibly only as a warning
void ReportLastError(System::String ^s, bool warning);
// Convert a string to the resource ID, which may involve converting to WORD
LPCWSTR convertToId(System::String ^s);
// Converts a string to a PE file resource variable, converting names like "BITMAP" to the proper id and numbers to number ids.
LPCWSTR getBuiltInResourceType(System::String ^s);